incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [26/46] wp7 commit: rejigger to the new structure
Date Sat, 14 Jul 2012 00:24:42 GMT
rejigger to the new structure


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/commit/62d32605
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/tree/62d32605
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/diff/62d32605

Branch: refs/heads/master
Commit: 62d3260511546832f072d26aed48a62e428ebecd
Parents: c41bba4
Author: Jesse <purplecabbage@gmail.com>
Authored: Wed Jul 11 17:49:53 2012 -0700
Committer: Jesse <purplecabbage@gmail.com>
Committed: Wed Jul 11 17:49:53 2012 -0700

----------------------------------------------------------------------
 framework/Cordova/BrowserMouseHelper.cs            |  345 -
 framework/Cordova/CommandFactory.cs                |  104 -
 framework/Cordova/Commands/Accelerometer.cs        |  195 -
 framework/Cordova/Commands/AudioPlayer.cs          |  601 --
 framework/Cordova/Commands/BaseCommand.cs          |  129 -
 framework/Cordova/Commands/Battery.cs              |   79 -
 framework/Cordova/Commands/Camera.cs               |  435 --
 framework/Cordova/Commands/Capture.cs              |  737 --
 framework/Cordova/Commands/Compass.cs              |  364 -
 framework/Cordova/Commands/Contacts.cs             |  634 --
 framework/Cordova/Commands/DebugConsole.cs         |   49 -
 framework/Cordova/Commands/Device.cs               |  124 -
 framework/Cordova/Commands/File.cs                 | 1406 ----
 framework/Cordova/Commands/FileTransfer.cs         |  521 --
 framework/Cordova/Commands/GeoLocation.cs          |   34 -
 framework/Cordova/Commands/ImageExifHelper.cs      |  213 -
 framework/Cordova/Commands/Media.cs                |  493 --
 framework/Cordova/Commands/MimeTypeMapper.cs       |   99 -
 framework/Cordova/Commands/NetworkStatus.cs        |  124 -
 framework/Cordova/Commands/Notification.cs         |  310 -
 framework/Cordova/CordovaCommandCall.cs            |   86 -
 framework/Cordova/DOMStorageHelper.cs              |  145 -
 framework/Cordova/JSON/JsonHelper.cs               |   97 -
 framework/Cordova/NativeExecution.cs               |  207 -
 framework/Cordova/OrientationHelper.cs             |  128 -
 framework/Cordova/PluginResult.cs                  |  165 -
 framework/Cordova/ScriptCallback.cs                |   80 -
 framework/Cordova/UI/AudioCaptureTask.cs           |  105 -
 framework/Cordova/UI/AudioRecorder.xaml            |   66 -
 framework/Cordova/UI/AudioRecorder.xaml.cs         |  387 -
 framework/Cordova/UI/ImageCapture.xaml             |   26 -
 framework/Cordova/UI/ImageCapture.xaml.cs          |  107 -
 framework/Cordova/UI/NotificationBox.xaml          |   62 -
 framework/Cordova/UI/NotificationBox.xaml.cs       |   41 -
 framework/Cordova/UI/VideoCaptureTask.cs           |  104 -
 framework/Cordova/UI/VideoRecorder.xaml            |   52 -
 framework/Cordova/UI/VideoRecorder.xaml.cs         |  405 --
 templates/standalone/App.xaml                      |   37 +
 templates/standalone/App.xaml.cs                   |  154 +
 templates/standalone/ApplicationIcon.png           |  Bin 0 -> 4951 bytes
 templates/standalone/Background.png                |  Bin 0 -> 10259 bytes
 templates/standalone/BuildManifestProcessor.js     |   80 +
 templates/standalone/CordovaAppProj.csproj         |  227 +
 templates/standalone/CordovaSolution.sln           |   22 +
 templates/standalone/MainPage.xaml                 |   52 +
 templates/standalone/MainPage.xaml.cs              |   72 +
 templates/standalone/Properties/AppManifest.xml    |    6 +
 templates/standalone/Properties/AssemblyInfo.cs    |   38 +
 templates/standalone/Properties/WMAppManifest.xml  |   41 +
 templates/standalone/SplashScreenImage.jpg         |  Bin 0 -> 33248 bytes
 templates/standalone/VERSION                       |    1 +
 templates/standalone/cordova/debug.bat             |   68 +
 templates/standalone/cordova/emulate.bat           |   24 +
 .../standalone/cordovalib/BrowserMouseHelper.cs    |  345 +
 templates/standalone/cordovalib/CommandFactory.cs  |  104 +
 .../cordovalib/Commands/Accelerometer.cs           |  195 +
 .../standalone/cordovalib/Commands/AudioPlayer.cs  |  605 ++
 .../standalone/cordovalib/Commands/BaseCommand.cs  |  129 +
 .../standalone/cordovalib/Commands/Battery.cs      |   79 +
 templates/standalone/cordovalib/Commands/Camera.cs |  435 ++
 .../standalone/cordovalib/Commands/Capture.cs      |  738 ++
 .../standalone/cordovalib/Commands/Compass.cs      |  364 +
 .../standalone/cordovalib/Commands/Contacts.cs     |  634 ++
 .../standalone/cordovalib/Commands/DebugConsole.cs |   49 +
 templates/standalone/cordovalib/Commands/Device.cs |  124 +
 templates/standalone/cordovalib/Commands/File.cs   | 1406 ++++
 .../standalone/cordovalib/Commands/FileTransfer.cs |  521 ++
 .../standalone/cordovalib/Commands/GeoLocation.cs  |   34 +
 .../cordovalib/Commands/ImageExifHelper.cs         |  222 +
 templates/standalone/cordovalib/Commands/Media.cs  |  493 ++
 .../cordovalib/Commands/MimeTypeMapper.cs          |   99 +
 .../cordovalib/Commands/NetworkStatus.cs           |  124 +
 .../standalone/cordovalib/Commands/Notification.cs |  310 +
 .../standalone/cordovalib/CordovaCommandCall.cs    |   86 +
 templates/standalone/cordovalib/CordovaView.xaml   |   65 +
 .../standalone/cordovalib/CordovaView.xaml.cs      |  451 ++
 .../standalone/cordovalib/DOMStorageHelper.cs      |  145 +
 .../cordovalib/Images/appbar.back.rest.png         |  Bin 0 -> 375 bytes
 .../cordovalib/Images/appbar.close.rest.png        |  Bin 0 -> 359 bytes
 .../Images/appbar.feature.video.rest.png           |  Bin 0 -> 433 bytes
 .../cordovalib/Images/appbar.next.rest.png         |  Bin 0 -> 388 bytes
 .../cordovalib/Images/appbar.save.rest.png         |  Bin 0 -> 297 bytes
 .../cordovalib/Images/appbar.stop.rest.png         |  Bin 0 -> 350 bytes
 templates/standalone/cordovalib/JSON/JsonHelper.cs |   97 +
 templates/standalone/cordovalib/NativeExecution.cs |  207 +
 .../standalone/cordovalib/OrientationHelper.cs     |  128 +
 templates/standalone/cordovalib/PluginResult.cs    |  165 +
 templates/standalone/cordovalib/ScriptCallback.cs  |   80 +
 .../standalone/cordovalib/UI/AudioCaptureTask.cs   |  105 +
 .../standalone/cordovalib/UI/AudioRecorder.xaml    |   66 +
 .../standalone/cordovalib/UI/AudioRecorder.xaml.cs |  387 +
 .../standalone/cordovalib/UI/ImageCapture.xaml     |   26 +
 .../standalone/cordovalib/UI/ImageCapture.xaml.cs  |  107 +
 .../standalone/cordovalib/UI/NotificationBox.xaml  |   62 +
 .../cordovalib/UI/NotificationBox.xaml.cs          |   41 +
 .../standalone/cordovalib/UI/VideoCaptureTask.cs   |  104 +
 .../standalone/cordovalib/UI/VideoRecorder.xaml    |   52 +
 .../standalone/cordovalib/UI/VideoRecorder.xaml.cs |  405 ++
 .../cordovalib/resources/notification-beep.wav     |  Bin 0 -> 16630 bytes
 templates/standalone/www/cordova-1.9.0.js          | 5642 +++++++++++++++
 templates/standalone/www/index.html                |   55 +
 templates/standalone/www/master.css                |   28 +
 102 files changed, 16336 insertions(+), 9259 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/62d32605/framework/Cordova/BrowserMouseHelper.cs
----------------------------------------------------------------------
diff --git a/framework/Cordova/BrowserMouseHelper.cs b/framework/Cordova/BrowserMouseHelper.cs
deleted file mode 100644
index 6118a6c..0000000
--- a/framework/Cordova/BrowserMouseHelper.cs
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements.  See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership.  The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License.  You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied.  See the License for the
- specific language governing permissions and limitations
- under the License. 
- */
-using System.Linq;
-using System.Windows;
-using System.Windows.Controls;
-using Microsoft.Phone.Controls;
-using System.Windows.Input;
-using System.Diagnostics;
-using System.Windows.Media;
-using System;
-using System.Collections.Generic;
-
-namespace WP7CordovaClassLib
-{
-
-    /// <summary>
-    /// Suppresses pinch zoom and optionally scrolling of the WebBrowser control
-    /// </summary>
-    public class BrowserMouseHelper
-    {
-
-        /**
-         * 
-         * Full Script below, in use it is minified.
-        */
-        /*
-        private static string mouseScript =
-        @"(function(win,doc){
-            var mPro = MouseEvent.prototype;
-            var def = Object.defineProperty;
-            def( mPro, 'pageX', {
-               configurable: true,
-               get: function(){ return this.clientX }
-            });
-            def( mPro, 'pageY', {
-               configurable: true,
-               get: function(){ return this.clientY }
-            });
-
-            win.onNativeMouseEvent = function(type,x,y){
-                try {
-                    var xMod = screen.logicalXDPI / screen.deviceXDPI;
-                    var yMod = screen.logicalYDPI / screen.deviceYDPI;
-                    var evt = doc.createEvent('MouseEvents');
-                    var xPos =  doc.body.scrollLeft + Math.round(xMod * x);
-                    var yPos =  doc.body.scrollTop + Math.round(yMod * y);
-                    var element = doc.elementFromPoint(xPos,yPos);
-                    
-                    evt.initMouseEvent(type, true, true, win, 1, xPos, yPos, xPos, yPos, false, false, false, false, 0, element);
-                    evt.timeStamp = +new Date;
-                    evt.isCordovaEvent = true;
-                    
-                    var canceled = element ? !element.dispatchEvent(evt) : !doc.dispatchEvent(evt);
-                    return canceled ? 'true' : 'false';
-                }
-                catch(e) { return e;}
-            }
-        })(window,document);";
-        */
-
-        private static string MinifiedMouseScript = "(function(g,a){var c=MouseEvent.prototype,d=Object.defineProperty;d(c,'pageX',{configurable:!0,get:function(){return this.clientX}});d(c,'pageY',{configurable:!0,get:function(){return this.clientY}});g.onNativeMouseEvent=function(c,d,i)"
-        + "{try{var j=screen.logicalXDPI/screen.deviceXDPI,k=screen.logicalYDPI/screen.deviceYDPI,b=a.createEvent('MouseEvents'),e=a.body.scrollLeft+Math.round(j*d),f=a.body.scrollTop+Math.round(k*i),h=a.elementFromPoint(e,f);b.initMouseEvent(c,!0,!0,g,1,e,f,e,f,!1,!1,!1,!1,0,"
-        + "h);b.timeStamp=+new Date;b.isCordovaEvent=!0;return(h?!h.dispatchEvent(b):!a.dispatchEvent(b))?'true':'false'}catch(l){return l}}})(window,document);";
-
-
-        private WebBrowser _browser;
-
-        /// <summary>
-        /// Gets or sets whether to suppress the scrolling of
-        /// the WebBrowser control;
-        /// </summary>
-        public bool ScrollDisabled { get; set; }
-
-        private bool userScalable = true;
-        private double maxScale = 2.0;
-        private double minScale = 0.5;
-        protected Border border;
-        private bool firstMouseMove = false;
-
-        /// <summary>
-        /// Represents last known mouse down position. 
-        /// Used to determine mouse move delta to avoid duplicate mouse events.
-        /// </summary>
-        private Point mouseDownPos;
-
-        /// <summary>
-        /// Represent min delta value to consider event as a mouse move. Experimental calculated.
-        /// </summary>
-        private const int MouseMoveDeltaThreshold = 10;
-
-
-        public BrowserMouseHelper(ref WebBrowser browser)
-        {
-            _browser = browser;
-            browser.Loaded += new RoutedEventHandler(browser_Loaded);
-        }
-
-        private void browser_Loaded(object sender, RoutedEventArgs e)
-        {
-            var border0 = VisualTreeHelper.GetChild(_browser, 0);
-            var border1 = VisualTreeHelper.GetChild(border0, 0);
-            var panZoom = VisualTreeHelper.GetChild(border1, 0);
-            var grid = VisualTreeHelper.GetChild(panZoom, 0);
-            border = VisualTreeHelper.GetChild(grid, 0) as Border;
-
-            if (border != null)
-            {
-                border.ManipulationStarted += Border_ManipulationStarted;
-                border.ManipulationDelta += Border_ManipulationDelta;
-                border.ManipulationCompleted += Border_ManipulationCompleted;
-                border.DoubleTap += Border_DoubleTap;
-                border.Tap += Border_Tap;
-                border.Hold += Border_Hold;
-                border.MouseLeftButtonDown += Border_MouseLeftButtonDown;
-            }
-
-            _browser.LoadCompleted += Browser_LoadCompleted;
-
-        }
-
-
-
-
-        void ParseViewportMeta()
-        {
-            string metaScript = "(function() { return document.querySelector('meta[name=viewport]').content; })()";
-
-            try
-            {
-                string metaContent = _browser.InvokeScript("eval", new string[] { metaScript }) as string;
-                string[] arr = metaContent.Split(new[] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
-                Dictionary<string, string> metaDictionary = new Dictionary<string, string>();
-                foreach (string val in arr)
-                {
-                    string[] keyVal = val.Split('=');
-                    metaDictionary.Add(keyVal[0], keyVal[1]);
-                }
-
-                this.userScalable = false; // reset to default
-                if (metaDictionary.ContainsKey("user-scalable"))
-                {
-                    this.userScalable = metaDictionary["user-scalable"] == "yes";
-                }
-
-                this.maxScale = 2.0;// reset to default
-                if (metaDictionary.ContainsKey("maximum-scale"))
-                {
-                    this.maxScale = double.Parse(metaDictionary["maximum-scale"]);
-                }
-
-                this.minScale = 0.5;// reset to default
-                if (metaDictionary.ContainsKey("minimum-scale"))
-                {
-                    this.minScale = double.Parse(metaDictionary["minimum-scale"]);
-                }
-            }
-            catch (Exception)
-            {
-
-            }
-        }
-
-        void Browser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
-        {
-            ParseViewportMeta();
-
-            try
-            {
-                _browser.InvokeScript("execScript", MinifiedMouseScript);
-            }
-            catch (Exception)
-            {
-                Debug.WriteLine("BrowserHelper Failed to install mouse script in WebBrowser");
-            }
-        }
-
-        bool InvokeSimulatedMouseEvent(string eventName, Point pos)
-        {
-            bool bCancelled = false;
-            try
-            {
-                string strCancelled = _browser.InvokeScript("onNativeMouseEvent", new string[] { eventName, pos.X.ToString(), pos.Y.ToString() }) as string;                
-                if (bool.TryParse(strCancelled, out bCancelled))
-                {
-                    return bCancelled;
-                }
-            }
-            catch (Exception)
-            {
-                // script error
-            }
-
-            return bCancelled;
-        }
-
-        #region Hold
-
-        void Border_Hold(object sender, GestureEventArgs e)
-        {
-            //Debug.WriteLine("Border_Hold");
-            e.Handled = true;
-        }
-
-        #endregion
-
-        #region DoubleTap
-
-        void Border_DoubleTap(object sender, GestureEventArgs e)
-        {
-            //Debug.WriteLine("Border_DoubleTap");
-            e.Handled = true;
-        }
-
-        #endregion
-
-        #region Tap
-
-        void Border_Tap(object sender, GestureEventArgs e)
-        {
-            // prevents generating duplicated mouse events
-            // firstMouseMove == FALSE means we already handled this situation and generated mouse events
-            e.Handled = ! this.firstMouseMove;
-        }
-        #endregion
-
-        #region MouseEvents
-
-        void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
-        {
-            //Debug.WriteLine("Border_MouseLeftButtonDown");
-            border.MouseMove += new MouseEventHandler(Border_MouseMove);
-            border.MouseLeftButtonUp += new MouseButtonEventHandler(Border_MouseLeftButtonUp);
-            
-            this.mouseDownPos = e.GetPosition(_browser);
-            // don't fire the down event until we know if this is a 'move' or not
-            firstMouseMove = true;
-        }
-        //
-        void Border_MouseMove(object sender, MouseEventArgs e)
-        {
-            //Debug.WriteLine("Border_MouseMove");
-            Point pos = e.GetPosition(_browser);
-            // only the return value from the first mouse move event should be used to determine if scrolling is prevented.
-            if (firstMouseMove)
-            {
-                // even for simple tap there are situations where ui control generates move with some little delta value
-                // we should avoid such situations allowing to browser control generate native js mousedown/up/click events
-                if (Math.Abs(pos.X - mouseDownPos.X) + Math.Abs(pos.Y - mouseDownPos.Y) <= MouseMoveDeltaThreshold)
-                {
-                    return;
-                }
-                
-                InvokeSimulatedMouseEvent("mousedown", pos);
-                firstMouseMove = false;
-                ScrollDisabled = InvokeSimulatedMouseEvent("mousemove", pos);
-            }
-            else
-            {
-                InvokeSimulatedMouseEvent("mousemove", pos);
-            }
-
-        }
-
-        void Border_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
-        {
-            //Debug.WriteLine("Border_MouseLeftButtonUp");
-            border.MouseMove -= new MouseEventHandler(Border_MouseMove);
-            border.MouseLeftButtonUp -= new MouseButtonEventHandler(Border_MouseLeftButtonUp);
-            // if firstMouseMove is false, then we have sent our simulated mousedown, so we should also send a matching mouseup 
-            if (!firstMouseMove)
-            {
-                Point pos = e.GetPosition(_browser);
-                e.Handled = InvokeSimulatedMouseEvent("mouseup", pos);
-            }
-            ScrollDisabled = false;
-        }
-
-
-        #endregion
-
-        #region ManipulationEvents
-
-        void Border_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
-        {
-            //Debug.WriteLine("Border_ManipulationStarted");
-            
-            if (ScrollDisabled)
-            {
-                e.Handled = true;
-                e.Complete();
-            }
-        }
-
-        private void Border_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
-        {
-            //Debug.WriteLine("Border_ManipulationDelta");
-            // optionally suppress zoom
-            if ((ScrollDisabled || !userScalable) && (e.DeltaManipulation.Scale.X != 0.0 || e.DeltaManipulation.Scale.Y != 0.0))
-            {
-                e.Handled = true;
-                e.Complete();
-            }
-            // optionally suppress scrolling
-            if (ScrollDisabled && (e.DeltaManipulation.Translation.X != 0.0 || e.DeltaManipulation.Translation.Y != 0.0))
-            {
-                e.Handled = true;
-                e.Complete();
-            }
-        }
-
-        private void Border_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
-        {
-            //Debug.WriteLine("Border_ManipulationCompleted");
-            // suppress zoom
-            if (!userScalable && e.FinalVelocities != null)
-            {
-                if (e.FinalVelocities.ExpansionVelocity.X != 0.0 ||
-                   e.FinalVelocities.ExpansionVelocity.Y != 0.0)
-                {
-                    e.Handled = true;
-                }
-            }
-        }
-
-
-        #endregion
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/62d32605/framework/Cordova/CommandFactory.cs
----------------------------------------------------------------------
diff --git a/framework/Cordova/CommandFactory.cs b/framework/Cordova/CommandFactory.cs
deleted file mode 100644
index 1718816..0000000
--- a/framework/Cordova/CommandFactory.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-/*  
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-	
-	http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-*/
-
-using System;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-using System.Collections.Generic;
-using WP7CordovaClassLib.Cordova.Commands;
-using System.Reflection;
-using System.Diagnostics;
-
-namespace WP7CordovaClassLib.Cordova
-{
-    /// <summary>
-    /// Provides functionality to create phone gap command by name.
-    /// </summary>
-    public static class CommandFactory
-    {
-        /// <summary>
-        /// Represents predefined namespace name for custom plugins
-        /// </summary>
-        private static readonly string CustomPluginNamespacePrefix = "Cordova.Extension.Commands.";
-
-        private static readonly string BaseCommandNamespacePrefix  = "WP7CordovaClassLib.Cordova.Commands.";
-
-        /// <summary>
-        /// Cache instantiated commands in a map.
-        /// </summary>
-
-        private static Dictionary<string, BaseCommand> commandMap = new Dictionary<string, BaseCommand>();
- 
-        /// <summary>
-        /// Creates command using command class name. Returns null for unknown commands.
-        /// </summary>
-        /// <param name="service">Command class name, for example Device or Notification</param>
-        /// <returns>Command class instance or null</returns>
-        public static BaseCommand CreateByServiceName(string service)
-        {
-
-            if (string.IsNullOrEmpty(service))
-            {
-                throw new ArgumentNullException("service", "service to create can't be null");
-            }
-
-            if (!commandMap.ContainsKey(service))
-            {
-
-                Type t = Type.GetType(BaseCommandNamespacePrefix + service);
-
-                // custom plugin could be defined in own namespace and assembly
-                if (t == null)
-                {
-                    string serviceFullName = service.Contains(".") ? service : CustomPluginNamespacePrefix + service;
-                    
-                    foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
-                    {
-                        // in this case service name represents full type name including namespace
-                        t = a.GetType(serviceFullName);
-
-                        if (t == null) // try the Commands Namespace
-                        {
-                            t = a.GetType(BaseCommandNamespacePrefix + service);
-                        }
-
-                        if (t != null)
-                        {
-                            break;
-                        }
-                    }
-
-                }
-
-                // unknown command, still didn't find it
-                if (t == null)
-                {
-                    Debug.WriteLine("Unable to locate command :: " + service);
-                    return null;
-                }
-
-                commandMap[service] = Activator.CreateInstance(t) as BaseCommand;
-            }
-
-            return commandMap[service];
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/62d32605/framework/Cordova/Commands/Accelerometer.cs
----------------------------------------------------------------------
diff --git a/framework/Cordova/Commands/Accelerometer.cs b/framework/Cordova/Commands/Accelerometer.cs
deleted file mode 100644
index ae1e860..0000000
--- a/framework/Cordova/Commands/Accelerometer.cs
+++ /dev/null
@@ -1,195 +0,0 @@
-/*  
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-	
-	http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-*/
-
-
-using System;
-using System.Collections.Generic;
-using System.Runtime.Serialization;
-using System.Threading;
-using Microsoft.Devices.Sensors;
-using System.Globalization;
-
-namespace WP7CordovaClassLib.Cordova.Commands
-{
-    /// <summary>
-    /// Captures device motion in the x, y, and z direction.
-    /// </summary>
-    public class Accelerometer : BaseCommand
-    {
-        #region AccelerometerOptions class
-        /// <summary>
-        /// Represents Accelerometer options.
-        /// </summary>
-        [DataContract]
-        public class AccelerometerOptions
-        {
-            /// <summary>
-            /// How often to retrieve the Acceleration in milliseconds
-            /// </summary>
-            [DataMember(IsRequired = false, Name = "frequency")]
-            public int Frequency { get; set; }
-
-            /// <summary>
-            /// Watcher id
-            /// </summary>
-            [DataMember(IsRequired = false, Name = "id")]
-            public string Id { get; set; }
-
-            /// <summary>
-            /// Creates options object with default parameters
-            /// </summary>
-            public AccelerometerOptions()
-            {
-                this.SetDefaultValues(new StreamingContext());
-            }
-
-            /// <summary>
-            /// Initializes default values for class fields.
-            /// Implemented in separate method because default constructor is not invoked during deserialization.
-            /// </summary>
-            /// <param name="context"></param>
-            [OnDeserializing()]
-            public void SetDefaultValues(StreamingContext context)
-            {
-                this.Frequency = 10000;
-            }
-        }
-
-        #endregion
-
-        #region Status codes and Constants
-
-        public const int Stopped = 0;
-        public const int Starting = 1;
-        public const int Running = 2;
-        public const int ErrorFailedToStart = 3;
-
-        public const double gConstant = -9.81;
-
-        #endregion
-
-        #region Static members
-
-        /// <summary>
-        /// Status of listener
-        /// </summary>
-        private static int currentStatus;
-
-        /// <summary>
-        /// Accelerometer
-        /// </summary>
-        private static Microsoft.Devices.Sensors.Accelerometer accelerometer = new Microsoft.Devices.Sensors.Accelerometer();
-
-        private static DateTime StartOfEpoch = new DateTime(1970, 1, 1, 0, 0, 0);
-
-        #endregion
-
-        /// <summary>
-        /// Sensor listener event
-        /// </summary>        
-        private void accelerometer_CurrentValueChanged(object sender, SensorReadingEventArgs<AccelerometerReading> e)
-        {
-            this.SetStatus(Running);
-
-            PluginResult result = new PluginResult(PluginResult.Status.OK, GetCurrentAccelerationFormatted());
-            result.KeepCallback = true;
-            DispatchCommandResult(result);
-        }
-
-        /// <summary>
-        /// Starts listening for acceleration sensor
-        /// </summary>
-        /// <returns>status of listener</returns>
-        public void start(string options)
-        {
-            if ((currentStatus == Running) || (currentStatus == Starting))
-            {
-                return;
-            }
-            try
-            {
-                lock (accelerometer)
-                {
-                    accelerometer.CurrentValueChanged += accelerometer_CurrentValueChanged;
-                    accelerometer.Start();
-                    this.SetStatus(Starting);
-                }
-
-                long timeout = 2000;
-                while ((currentStatus == Starting) && (timeout > 0))
-                {
-                    timeout = timeout - 100;
-                    Thread.Sleep(100);
-                }
-
-                if (currentStatus != Running)
-                {
-                    this.SetStatus(ErrorFailedToStart);
-                    DispatchCommandResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, ErrorFailedToStart));
-                    return;
-                }
-            }
-            catch (Exception)
-            {
-                this.SetStatus(ErrorFailedToStart);
-                DispatchCommandResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, ErrorFailedToStart));
-                return;
-            }
-            PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
-            result.KeepCallback = true;
-            DispatchCommandResult(result);
-        }
-
-        public void stop(string options)
-        {
-            if (currentStatus == Running)
-            {
-                lock (accelerometer)
-                {
-                    accelerometer.CurrentValueChanged -= accelerometer_CurrentValueChanged;
-                    accelerometer.Stop();
-                    this.SetStatus(Stopped);
-                }
-            }
-            DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
-        }
-
-        /// <summary>
-        /// Formats current coordinates into JSON format
-        /// </summary>
-        /// <returns>Coordinates in JSON format</returns>
-        private string GetCurrentAccelerationFormatted()
-        {
-            // convert to unix timestamp
-            long timestamp = ((accelerometer.CurrentValue.Timestamp.DateTime - StartOfEpoch).Ticks) / 10000;
-            string resultCoordinates = String.Format("\"x\":{0},\"y\":{1},\"z\":{2},\"timestamp\":{3}",
-                            (accelerometer.CurrentValue.Acceleration.X * gConstant).ToString("0.00000", CultureInfo.InvariantCulture),
-                            (accelerometer.CurrentValue.Acceleration.Y * gConstant).ToString("0.00000", CultureInfo.InvariantCulture),
-                            (accelerometer.CurrentValue.Acceleration.Z * gConstant).ToString("0.00000", CultureInfo.InvariantCulture),
-                            timestamp.ToString());
-            resultCoordinates = "{" + resultCoordinates + "}";
-            return resultCoordinates;
-        }
-
-        /// <summary>
-        /// Sets current status
-        /// </summary>
-        /// <param name="status">current status</param>
-        private void SetStatus(int status)
-        {
-            currentStatus = status;
-        }
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/62d32605/framework/Cordova/Commands/AudioPlayer.cs
----------------------------------------------------------------------
diff --git a/framework/Cordova/Commands/AudioPlayer.cs b/framework/Cordova/Commands/AudioPlayer.cs
deleted file mode 100644
index d1fcb52..0000000
--- a/framework/Cordova/Commands/AudioPlayer.cs
+++ /dev/null
@@ -1,601 +0,0 @@
-/*  
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-	
-	http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-*/
-
-using System;
-using System.IO;
-using System.IO.IsolatedStorage;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Threading;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Audio;
-using Microsoft.Xna.Framework.Media;
-using Microsoft.Phone.Controls;
-using System.Diagnostics;
-
-namespace WP7CordovaClassLib.Cordova.Commands
-{    
-    /// <summary>
-    /// Implements audio record and play back functionality.
-    /// </summary>
-    internal class AudioPlayer : IDisposable
-    {
-        #region Constants
-        
-        // AudioPlayer states
-        private const int MediaNone = 0;
-        private const int MediaStarting = 1;
-        private const int MediaRunning = 2;
-        private const int MediaPaused = 3;
-        private const int MediaStopped = 4;
-                           
-        // AudioPlayer messages
-        private const int MediaState = 1;
-        private const int MediaDuration = 2;
-        private const int MediaPosition = 3;
-        private const int MediaError = 9;
-
-        // AudioPlayer errors
-        private const int MediaErrorPlayModeSet = 1;
-        private const int MediaErrorAlreadyRecording = 2;
-        private const int MediaErrorStartingRecording = 3;
-        private const int MediaErrorRecordModeSet = 4;
-        private const int MediaErrorStartingPlayback = 5;
-        private const int MediaErrorResumeState = 6;
-        private const int MediaErrorPauseState = 7;
-        private const int MediaErrorStopState = 8;
-
-        //TODO: get rid of this callback, it should be universal
-        private const string CallbackFunction = "CordovaMediaonStatus";
-
-        #endregion
-
-        /// <summary>
-        /// The AudioHandler object
-        /// </summary>
-        private Media handler;					
-        
-        /// <summary>
-        /// Temporary buffer to store audio chunk
-        /// </summary>
-        private byte[] buffer;
-
-        /// <summary>
-        /// Xna game loop dispatcher
-        /// </summary>
-        DispatcherTimer dtXna;
-
-        /// <summary>
-        /// Output buffer
-        /// </summary>
-        private MemoryStream memoryStream;
-
-        /// <summary>
-        /// The id of this player (used to identify Media object in JavaScript)
-        /// </summary>
-        private String id;								
-        
-        /// <summary>
-        /// State of recording or playback
-        /// </summary>
-        private int state = MediaNone;					
-        
-        /// <summary>
-        /// File name to play or record to
-        /// </summary>
-        private String audioFile = null;				
-        
-        /// <summary>
-        /// Duration of audio
-        /// </summary>
-        private double duration = -1;								
-
-        /// <summary>
-        /// Audio player object
-        /// </summary>
-        private MediaElement player = null;
-
-        /// <summary>
-        /// Audio source
-        /// </summary>
-        private Microphone recorder;
-        
-        /// <summary>
-        /// Internal flag specified that we should only open audio w/o playing it
-        /// </summary>
-        private bool prepareOnly = false;
-
-        /// <summary>
-        /// Creates AudioPlayer instance
-        /// </summary>
-        /// <param name="handler">Media object</param>
-        /// <param name="id">player id</param>
-        public AudioPlayer(Media handler, String id)
-        {
-            this.handler = handler;
-            this.id = id;
-        }	
-
-        /// <summary>
-        /// Destroys player and stop audio playing or recording
-        /// </summary>
-        public void Dispose()
-        {
-            Debug.WriteLine("Dispose :: " + this.audioFile);
-            if (this.player != null)
-            {
-                this.stopPlaying();
-                this.player = null;
-            }
-            if (this.recorder != null)
-            {
-                this.stopRecording();
-                this.recorder = null;
-            }
-
-            this.FinalizeXnaGameLoop();
-        }
-
-        /// <summary>
-        /// Starts recording, data is stored in memory
-        /// </summary>
-        /// <param name="filePath"></param>
-        public void startRecording(string filePath)
-        {
-            if (this.player != null)
-            {
-                this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorPlayModeSet));
-            }
-            else if (this.recorder == null)
-            {
-                try
-                {
-                        this.audioFile = filePath;
-                        this.InitializeXnaGameLoop();
-                        this.recorder = Microphone.Default;
-                        this.recorder.BufferDuration = TimeSpan.FromMilliseconds(500);
-                        this.buffer = new byte[recorder.GetSampleSizeInBytes(this.recorder.BufferDuration)];
-                        this.recorder.BufferReady += new EventHandler<EventArgs>(recorderBufferReady);
-                        this.memoryStream = new MemoryStream();
-                        this.WriteWavHeader(this.memoryStream, this.recorder.SampleRate);
-                        this.recorder.Start();
-                        FrameworkDispatcher.Update();
-                        this.SetState(MediaRunning);
-                }
-                catch (Exception)
-                {
-                        this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorStartingRecording));
-                }
-            } else 
-            {
-
-                this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorAlreadyRecording));
-            }
-        }
-
-        /// <summary>
-        /// Stops recording
-        /// </summary>
-        public void stopRecording()
-        {
-            if (this.recorder != null)
-            { 
-                if (this.state == MediaRunning)
-                {
-                    try
-                    {
-                        this.recorder.Stop();
-                        this.recorder.BufferReady -= recorderBufferReady;
-                        this.recorder = null;
-                        SaveAudioClipToLocalStorage();
-                        this.FinalizeXnaGameLoop();
-                        this.SetState(MediaStopped);
-                    }
-                    catch (Exception)
-                    {                
-                        //TODO 
-                    }
-                }
-            }
-        }
-        
-        /// <summary>
-        /// Starts or resume playing audio file
-        /// </summary>
-        /// <param name="filePath">The name of the audio file</param>
-        /// <summary>
-        /// Starts or resume playing audio file
-        /// </summary>
-        /// <param name="filePath">The name of the audio file</param>
-        public void startPlaying(string filePath)
-        {
-            if (this.recorder != null)
-            {
-                this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorRecordModeSet));
-                return;
-            }
-
-
-            if (this.player == null) 
-            {
-                try
-                {
-                    if (this.player == null)
-                    {
-                        // this.player is a MediaElement, it must be added to the visual tree in order to play
-                        PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
-                        if (frame != null)
-                        {
-                            PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
-                            if (page != null)
-                            {
-                                Grid grid = page.FindName("LayoutRoot") as Grid;
-                                if (grid != null)
-                                {
-                                    
-                                    this.player = new MediaElement();
-                                    this.player.Name = "playerMediaElement";
-                                    grid.Children.Add(this.player);
-                                    this.player.Visibility = Visibility.Collapsed;
-                                    this.player.MediaOpened += MediaOpened;
-                                    this.player.MediaEnded += MediaEnded;
-                                    this.player.MediaFailed += MediaFailed;
-                                }
-                            }
-                        }
-
-                    }
-                    this.audioFile = filePath;
-
-                    Uri uri = new Uri(filePath, UriKind.RelativeOrAbsolute);
-                    if (uri.IsAbsoluteUri)
-                    {
-                        this.player.Source = uri;
-                    }
-                    else
-                    {
-                        using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
-                        {
-                            if (isoFile.FileExists(filePath))
-                            {
-                                using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(filePath, FileMode.Open, isoFile))
-                                {
-                                    this.player.SetSource(stream);
-                                }
-                            }
-                            else
-                            {
-                                Debug.WriteLine("Error: source doesn't exist :: " + filePath);
-                                throw new ArgumentException("Source doesn't exist");
-                            }
-                        }
-                    }
-                    this.SetState(MediaStarting);
-                }
-                catch (Exception e)
-                {
-                    Debug.WriteLine("Error: " + e.Message);
-                    this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorStartingPlayback));
-                }
-            }
-            else
-            {
-                if (this.state != MediaRunning)
-                {
-                    this.player.Play();
-                    this.SetState(MediaRunning);
-                }
-                else
-                {
-                    this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorResumeState));
-                }
-            }
-        }
-        
-        /// <summary>
-        /// Callback to be invoked when the media source is ready for playback
-        /// </summary>
-        private void MediaOpened(object sender, RoutedEventArgs arg)
-        {
-            if (!this.prepareOnly)
-            { 
-                this.player.Play();
-                this.SetState(MediaRunning);                       
-            }
-
-            this.duration = this.player.NaturalDuration.TimeSpan.TotalSeconds;
-            this.prepareOnly = false;
-            this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaDuration, this.duration));
-        }
-
-        /// <summary>
-        /// Callback to be invoked when playback of a media source has completed
-        /// </summary>
-        private void MediaEnded(object sender, RoutedEventArgs arg)
-        {
-            this.SetState(MediaStopped);
-        }
-
-        /// <summary>
-        /// Callback to be invoked when playback of a media source has failed
-        /// </summary>
-        private void MediaFailed(object sender, RoutedEventArgs arg)
-        {
-            player.Stop();
-            this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError.ToString(), "Media failed"));
-        }
-
-        /// <summary>
-        /// Seek or jump to a new time in the track
-        /// </summary>
-        /// <param name="milliseconds">The new track position</param>
-        public void seekToPlaying(int milliseconds)
-        { 
-            if (this.player != null)
-            {
-                TimeSpan tsPos = new TimeSpan(0, 0, 0, 0, milliseconds);
-                this.player.Position = tsPos;
-                this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaPosition, milliseconds / 1000.0f));
-            }
-        }
-
-        /// <summary>
-        /// Pauses playing
-        /// </summary>
-        public void pausePlaying()
-        {
-            if (this.state == MediaRunning)
-            {
-                this.player.Pause();
-                this.SetState(MediaPaused);
-            } else
-            {
-                this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorPauseState));
-            }
-        }
-
-
-        /// <summary>
-        /// Stops playing the audio file
-        /// </summary>
-        public void stopPlaying()
-        {            
-            if ((this.state == MediaRunning) || (this.state == MediaPaused))
-            {
-                this.player.Stop();
-
-                this.player.Position = new TimeSpan(0L);
-                this.SetState(MediaStopped);
-            } else
-            {
-                this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorStopState));
-            }             
-        }
-
-        /// <summary>
-        /// Gets current position of playback
-        /// </summary>
-        /// <returns>current position</returns>
-        public double getCurrentPosition()
-        {
-            if ((this.state == MediaRunning) || (this.state == MediaPaused))
-            {
-                double currentPosition = this.player.Position.TotalSeconds;
-                this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaPosition, currentPosition));                
-                return currentPosition;
-            }
-            else
-            {
-                return -1;
-            }
-        }
-
-        /// <summary>
-        /// Gets the duration of the audio file
-        /// </summary>
-        /// <param name="filePath">The name of the audio file</param>
-        /// <returns>track duration</returns>
-        public double getDuration(string filePath)
-        {
-            if (this.recorder != null)
-            {
-                return (-2);
-            }
-
-            if (this.player != null)
-            {
-                return this.duration;
-
-            } else
-            { 
-                this.prepareOnly = true;
-                this.startPlaying(filePath);
-                return this.duration;
-            }
-        }                
-
-        /// <summary>
-        /// Sets the state and send it to JavaScript
-        /// </summary>
-        /// <param name="state">state</param>
-        private void SetState(int state)
-        {
-            if (this.state != state)
-            {
-                this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaState, state));
-            }
-
-            this.state = state;
-        }
-
-        #region record methods
-
-        /// <summary>
-        /// Copies data from recorder to memory storages and updates recording state
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void recorderBufferReady(object sender, EventArgs e)
-        {
-            this.recorder.GetData(this.buffer);
-            this.memoryStream.Write(this.buffer, 0, this.buffer.Length);         
-        }
-
-        /// <summary>
-        /// Writes audio data from memory to isolated storage
-        /// </summary>
-        /// <returns></returns>
-        private void SaveAudioClipToLocalStorage()
-        {
-            if (this.memoryStream == null || this.memoryStream.Length <= 0)
-            {
-                return;
-            }
-
-            this.UpdateWavHeader(this.memoryStream);
-
-            try
-            {
-                using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
-                {
-                    string directory = Path.GetDirectoryName(audioFile);
-
-                    if (!isoFile.DirectoryExists(directory))
-                    {
-                        isoFile.CreateDirectory(directory);
-                    }
-
-                    this.memoryStream.Seek(0, SeekOrigin.Begin);
-
-                    using (IsolatedStorageFileStream fileStream = isoFile.CreateFile(audioFile))
-                    {
-                        this.memoryStream.CopyTo(fileStream);
-                    }
-                }
-            }
-            catch (Exception)
-            {
-                //TODO: log or do something else
-                throw;
-            }
-        }
-
-        
-
-        #region Wav format
-        // Original source http://damianblog.com/2011/02/07/storing-wp7-recorded-audio-as-wav-format-streams/
-
-        /// <summary>
-        /// Adds wav file format header to the stream
-        /// https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
-        /// </summary>
-        /// <param name="stream">Wav stream</param>
-        /// <param name="sampleRate">Sample Rate</param>
-        private void WriteWavHeader(Stream stream, int sampleRate)
-        {
-            const int bitsPerSample = 16;
-            const int bytesPerSample = bitsPerSample / 8;
-            var encoding = System.Text.Encoding.UTF8;
-
-            // ChunkID Contains the letters "RIFF" in ASCII form (0x52494646 big-endian form).
-            stream.Write(encoding.GetBytes("RIFF"), 0, 4);
-
-            // NOTE this will be filled in later
-            stream.Write(BitConverter.GetBytes(0), 0, 4);
-
-            // Format Contains the letters "WAVE"(0x57415645 big-endian form).
-            stream.Write(encoding.GetBytes("WAVE"), 0, 4);
-
-            // Subchunk1ID Contains the letters "fmt " (0x666d7420 big-endian form).
-            stream.Write(encoding.GetBytes("fmt "), 0, 4);
-
-            // Subchunk1Size 16 for PCM.  This is the size of therest of the Subchunk which follows this number.
-            stream.Write(BitConverter.GetBytes(16), 0, 4);
-
-            // AudioFormat PCM = 1 (i.e. Linear quantization) Values other than 1 indicate some form of compression.
-            stream.Write(BitConverter.GetBytes((short)1), 0, 2);
-
-            // NumChannels Mono = 1, Stereo = 2, etc.
-            stream.Write(BitConverter.GetBytes((short)1), 0, 2);
-
-            // SampleRate 8000, 44100, etc.
-            stream.Write(BitConverter.GetBytes(sampleRate), 0, 4);
-
-            // ByteRate =  SampleRate * NumChannels * BitsPerSample/8
-            stream.Write(BitConverter.GetBytes(sampleRate * bytesPerSample), 0, 4);
-
-            // BlockAlign NumChannels * BitsPerSample/8 The number of bytes for one sample including all channels.
-            stream.Write(BitConverter.GetBytes((short)(bytesPerSample)), 0, 2);
-
-            // BitsPerSample    8 bits = 8, 16 bits = 16, etc.
-            stream.Write(BitConverter.GetBytes((short)(bitsPerSample)), 0, 2);
-
-            // Subchunk2ID Contains the letters "data" (0x64617461 big-endian form).
-            stream.Write(encoding.GetBytes("data"), 0, 4);
-
-            // NOTE to be filled in later
-            stream.Write(BitConverter.GetBytes(0), 0, 4);
-        }
-
-        /// <summary>
-        /// Updates wav file format header
-        /// https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
-        /// </summary>
-        /// <param name="stream">Wav stream</param>
-        private void UpdateWavHeader(Stream stream)
-        {
-            if (!stream.CanSeek) throw new Exception("Can't seek stream to update wav header");
-
-            var oldPos = stream.Position;
-
-            // ChunkSize  36 + SubChunk2Size
-            stream.Seek(4, SeekOrigin.Begin);
-            stream.Write(BitConverter.GetBytes((int)stream.Length - 8), 0, 4);
-
-            // Subchunk2Size == NumSamples * NumChannels * BitsPerSample/8 This is the number of bytes in the data.
-            stream.Seek(40, SeekOrigin.Begin);
-            stream.Write(BitConverter.GetBytes((int)stream.Length - 44), 0, 4);
-
-            stream.Seek(oldPos, SeekOrigin.Begin);
-        }
-
-        #endregion
-
-        #region Xna loop
-        /// <summary>
-        /// Special initialization required for the microphone: XNA game loop
-        /// </summary>
-        private void InitializeXnaGameLoop()
-        {
-            // Timer to simulate the XNA game loop (Microphone is from XNA)
-            this.dtXna = new DispatcherTimer();
-            this.dtXna.Interval = TimeSpan.FromMilliseconds(33);
-            this.dtXna.Tick += delegate { try { FrameworkDispatcher.Update(); } catch { } };
-            this.dtXna.Start();
-        }
-        /// <summary>
-        /// Finalizes XNA game loop for microphone
-        /// </summary>
-        private void FinalizeXnaGameLoop()
-        {
-            // Timer to simulate the XNA game loop (Microphone is from XNA)
-            this.dtXna.Stop();
-            this.dtXna = null;
-        }
-
-        #endregion
-
-        #endregion
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/62d32605/framework/Cordova/Commands/BaseCommand.cs
----------------------------------------------------------------------
diff --git a/framework/Cordova/Commands/BaseCommand.cs b/framework/Cordova/Commands/BaseCommand.cs
deleted file mode 100644
index c2af744..0000000
--- a/framework/Cordova/Commands/BaseCommand.cs
+++ /dev/null
@@ -1,129 +0,0 @@
-/*  
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-	
-	http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-*/
-
-using System;
-using System.Reflection;
-using Microsoft.Phone.Shell;
-using System.Diagnostics;
-
-namespace WP7CordovaClassLib.Cordova.Commands
-{
-    public abstract class BaseCommand : IDisposable
-    {
-        /*
-         *  All commands + plugins must extend BaseCommand, because they are dealt with as BaseCommands in PGView.xaml.cs
-         *  
-         **/
-
-        public event EventHandler<PluginResult> OnCommandResult;
-
-        public event EventHandler<ScriptCallback> OnCustomScript;
-
-        public BaseCommand()
-        {
-                PhoneApplicationService service = PhoneApplicationService.Current;
-                service.Activated += this.OnResume;                
-                service.Deactivated += this.OnPause;                
-        }
-
-        /*
-         *  InvokeMethodNamed will call the named method of a BaseCommand subclass if it exists and pass the variable arguments list along.
-         **/
-
-        public object InvokeMethodNamed(string methodName, params object[] args)
-        {
-            MethodInfo mInfo = this.GetType().GetMethod(methodName);
-
-            if (mInfo != null)
-            {
-                // every function handles DispatchCommandResult by itself
-                return mInfo.Invoke(this, args);
-            }
-
-            // actually methodName could refer to a property
-            if (args == null || args.Length == 0 ||
-               (args.Length == 1 && "undefined".Equals(args[0])))
-            {
-                PropertyInfo pInfo = this.GetType().GetProperty(methodName);
-                if (pInfo != null)
-                {
-                    
-                    object res = pInfo.GetValue(this , null);
-
-                    DispatchCommandResult(new PluginResult(PluginResult.Status.OK, res));
-                    
-                    return res;
-                }
-            }
-
-            throw new MissingMethodException(methodName);            
-
-        }
-
-
-        public void InvokeCustomScript(ScriptCallback script)
-        {
-            if (this.OnCustomScript != null)
-            {
-                this.OnCustomScript(this, script);
-                this.OnCustomScript = null;
-            }
-        }
-
-        public void DispatchCommandResult()
-        {
-            this.DispatchCommandResult(new PluginResult(PluginResult.Status.NO_RESULT));
-        }
-
-        public void DispatchCommandResult(PluginResult result)
-        {
-            if (this.OnCommandResult != null)
-            {
-                this.OnCommandResult(this, result);
-
-                if (!result.KeepCallback)
-                {
-                    this.Dispose();
-                }
-
-            }
-        }
-
-        /// <summary>
-        /// Occurs when the application is being deactivated.
-        /// </summary>        
-        public virtual void OnPause(object sender, DeactivatedEventArgs e)
-        {
-        }
-
-        /// <summary>
-        /// Occurs when the application is being made active after previously being put
-        /// into a dormant state or tombstoned.
-        /// </summary>        
-        public virtual void OnResume(object sender, Microsoft.Phone.Shell.ActivatedEventArgs e)
-        {
-        }
-        
-        public void Dispose()
-        {
-            PhoneApplicationService service = PhoneApplicationService.Current;
-            service.Activated -= this.OnResume;
-            service.Deactivated -= this.OnPause;
-            this.OnCommandResult = null;
-        }
-    }
-
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/62d32605/framework/Cordova/Commands/Battery.cs
----------------------------------------------------------------------
diff --git a/framework/Cordova/Commands/Battery.cs b/framework/Cordova/Commands/Battery.cs
deleted file mode 100644
index f027c0f..0000000
--- a/framework/Cordova/Commands/Battery.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-/*  
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-	
-	http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-*/
-
-using System;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-
-using Microsoft.Phone.Info;
-
-namespace WP7CordovaClassLib.Cordova.Commands
-{
-    /// <summary>
-    /// Listens for changes to the state of the battery on the device.
-    /// Currently only the "isPlugged" parameter available via native APIs.
-    /// </summary>
-    public class Battery : BaseCommand
-    {
-        private bool isPlugged = false;
-        private EventHandler powerChanged;
-
-        public Battery()
-        {
-            powerChanged = new EventHandler(DeviceStatus_PowerSourceChanged);
-            isPlugged = DeviceStatus.PowerSource.ToString().CompareTo("External") == 0;
-        }
-
-        public void start(string options)
-        {
-            // Register power changed event handler
-            DeviceStatus.PowerSourceChanged += powerChanged;
-
-            PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
-            result.KeepCallback = true;
-            DispatchCommandResult(result);
-        }
-        public void stop(string options)
-        {
-            // Unregister power changed event handler
-            DeviceStatus.PowerSourceChanged -= powerChanged;
-        }
-
-        private void DeviceStatus_PowerSourceChanged(object sender, EventArgs e)
-        {
-            isPlugged = DeviceStatus.PowerSource.ToString().CompareTo("External") == 0;
-            PluginResult result = new PluginResult(PluginResult.Status.OK, GetCurrentBatteryStateFormatted());
-            result.KeepCallback = true;
-            DispatchCommandResult(result);
-        }
-
-        private string GetCurrentBatteryStateFormatted()
-        {
-            string batteryState = String.Format("\"level\":{0},\"isPlugged\":{1}",
-                                                    "null",
-                                                    isPlugged ? "true" : "false"
-                            );
-            batteryState = "{" + batteryState + "}";
-            return batteryState;
-        }
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/62d32605/framework/Cordova/Commands/Camera.cs
----------------------------------------------------------------------
diff --git a/framework/Cordova/Commands/Camera.cs b/framework/Cordova/Commands/Camera.cs
deleted file mode 100644
index 6620dd4..0000000
--- a/framework/Cordova/Commands/Camera.cs
+++ /dev/null
@@ -1,435 +0,0 @@
-/*  
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-	
-	http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-*/
-
-using System;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Collections.Generic;
-using Microsoft.Phone.Tasks;
-using System.Runtime.Serialization;
-using System.IO;
-using System.IO.IsolatedStorage;
-using System.Windows.Media.Imaging;
-using Microsoft.Phone;
-using Microsoft.Xna.Framework.Media;
-using System.Diagnostics;
-
-namespace WP7CordovaClassLib.Cordova.Commands
-{
-    public class Camera : BaseCommand
-    {
-
-        /// <summary>
-        /// Return base64 encoded string
-        /// </summary>
-        private const int DATA_URL = 0;
-
-        /// <summary>
-        /// Return file uri
-        /// </summary>
-        private const int FILE_URI = 1;
-
-        /// <summary>
-        /// Choose image from picture library
-        /// </summary>
-        private const int PHOTOLIBRARY = 0;
-
-        /// <summary>
-        /// Take picture from camera
-        /// </summary>
-
-        private const int CAMERA = 1;
-
-        /// <summary>
-        /// Choose image from picture library
-        /// </summary>
-        private const int SAVEDPHOTOALBUM = 2;
-
-        /// <summary>
-        /// Take a picture of type JPEG
-        /// </summary>
-        private const int JPEG = 0;
-
-        /// <summary>
-        /// Take a picture of type PNG
-        /// </summary>
-        private const int PNG = 1;
-
-        /// <summary>
-        /// Folder to store captured images
-        /// </summary>
-        private const string isoFolder = "CapturedImagesCache";
-
-        /// <summary>
-        /// Represents captureImage action options.
-        /// </summary>
-        [DataContract]
-        public class CameraOptions
-        {
-            /// <summary>
-            /// Source to getPicture from.
-            /// </summary>
-            [DataMember(IsRequired = false, Name = "sourceType")]
-            public int PictureSourceType { get; set; }
-
-            /// <summary>
-            /// Format of image that returned from getPicture.
-            /// </summary>
-            [DataMember(IsRequired = false, Name = "destinationType")]
-            public int DestinationType { get; set; }
-
-            /// <summary>
-            /// Quality of saved image
-            /// </summary>
-            [DataMember(IsRequired = false, Name = "quality")]
-            public int Quality { get; set; }
-
-
-            /// <summary>
-            /// Height in pixels to scale image
-            /// </summary>
-            [DataMember(IsRequired = false, Name = "targetHeight")]
-            public int TargetHeight { get; set; }
-
-            /// <summary>
-            /// Width in pixels to scale image
-            /// </summary>
-            [DataMember(IsRequired = false, Name = "targetWidth")]
-            public int TargetWidth { get; set; }
-
-            /// <summary>
-            /// Creates options object with default parameters
-            /// </summary>
-            public CameraOptions()
-            {
-                this.SetDefaultValues(new StreamingContext());
-            }
-
-            /// <summary>
-            /// Initializes default values for class fields.
-            /// Implemented in separate method because default constructor is not invoked during deserialization.
-            /// </summary>
-            /// <param name="context"></param>
-            [OnDeserializing()]
-            public void SetDefaultValues(StreamingContext context)
-            {
-                PictureSourceType = CAMERA;
-                DestinationType = FILE_URI;
-                Quality = 80;
-                TargetHeight = -1;
-                TargetWidth = -1;
-            }
-
-        }
-
-        /// <summary>
-        /// Used to open photo library
-        /// </summary>
-        PhotoChooserTask photoChooserTask;
-
-        /// <summary>
-        /// Used to open camera application
-        /// </summary>
-        CameraCaptureTask cameraTask;
-
-        /// <summary>
-        /// Camera options
-        /// </summary>
-        CameraOptions cameraOptions;
-
-        public void takePicture(string options)
-        {
-            try
-            {
-                this.cameraOptions = String.IsNullOrEmpty(options) ?
-                        new CameraOptions() : JSON.JsonHelper.Deserialize<CameraOptions>(options);
-            }
-            catch (Exception ex)
-            {
-                this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message));
-                return;
-            }
-
-            //TODO Check if all the options are acceptable
-
-
-            if (cameraOptions.PictureSourceType == CAMERA)
-            {
-                cameraTask = new CameraCaptureTask();
-                cameraTask.Completed += onCameraTaskCompleted;
-                cameraTask.Show();
-            }
-            else
-            {
-                if ((cameraOptions.PictureSourceType == PHOTOLIBRARY) || (cameraOptions.PictureSourceType == SAVEDPHOTOALBUM))
-                {
-                    photoChooserTask = new PhotoChooserTask();
-                    photoChooserTask.Completed += onPickerTaskCompleted;
-                    photoChooserTask.Show();
-                }
-                else
-                {
-                    DispatchCommandResult(new PluginResult(PluginResult.Status.NO_RESULT));
-                }
-            }
-
-        }
-
-        public void onCameraTaskCompleted(object sender, PhotoResult e)
-        {
-            if (e.Error != null)
-            {
-                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
-                return;
-            }
-
-            switch (e.TaskResult)
-            {
-                case TaskResult.OK:
-                    try
-                    {
-                        string imagePathOrContent = string.Empty;
-
-                        if (cameraOptions.DestinationType == FILE_URI)
-                        {
-                            // Save image in media library
-                            // MediaLibrary library = new MediaLibrary();
-                            // Picture pict = library.SavePicture(e.OriginalFileName, e.ChosenPhoto); // to save to photo-roll ...
-
-                            int orient = ImageExifHelper.getImageOrientationFromStream(e.ChosenPhoto);
-                            int newAngle = 0;
-                            switch (orient)
-                            {
-                                case ImageExifOrientation.LandscapeLeft:
-                                    newAngle = 90;
-                                    break;
-                                case ImageExifOrientation.PortraitUpsideDown:
-                                    newAngle = 180;
-                                    break;
-                                case ImageExifOrientation.LandscapeRight:
-                                    newAngle = 270;
-                                    break;
-                                case ImageExifOrientation.Portrait:
-                                default: break; // 0 default already set
-                            }
-
-                            Stream rotImageStream = ImageExifHelper.RotateStream(e.ChosenPhoto, newAngle);
-
-                            // we should return stream position back after saving stream to media library
-                            rotImageStream.Seek(0, SeekOrigin.Begin);
-
-                            WriteableBitmap image = PictureDecoder.DecodeJpeg(rotImageStream);
-
-                            imagePathOrContent = this.SaveImageToLocalStorage(image, Path.GetFileName(e.OriginalFileName));
-
-
-                        }
-                        else if (cameraOptions.DestinationType == DATA_URL)
-                        {
-                            imagePathOrContent = this.GetImageContent(e.ChosenPhoto);
-                        }
-                        else
-                        {
-                            // TODO: shouldn't this happen before we launch the camera-picker?
-                            DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Incorrect option: destinationType"));
-                            return;
-                        }
-
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK, imagePathOrContent));
-
-                    }
-                    catch (Exception)
-                    {
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error retrieving image."));
-                    }
-                    break;
-
-                case TaskResult.Cancel:
-                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Selection cancelled."));
-                    break;
-
-                default:
-                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Selection did not complete!"));
-                    break;
-            }
-
-        }
-
-        public void onPickerTaskCompleted(object sender, PhotoResult e)
-        {
-            if (e.Error != null)
-            {
-                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
-                return;
-            }
-
-            switch (e.TaskResult)
-            {
-                case TaskResult.OK:
-                    try
-                    {
-                        string imagePathOrContent = string.Empty;
-
-                        if (cameraOptions.DestinationType == FILE_URI)
-                        {
-                            WriteableBitmap image = PictureDecoder.DecodeJpeg(e.ChosenPhoto);
-                            imagePathOrContent = this.SaveImageToLocalStorage(image, Path.GetFileName(e.OriginalFileName));
-                        }
-                        else if (cameraOptions.DestinationType == DATA_URL)
-                        {
-                            imagePathOrContent = this.GetImageContent(e.ChosenPhoto);
-
-                        }
-                        else
-                        {
-                            // TODO: shouldn't this happen before we launch the camera-picker?
-                            DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Incorrect option: destinationType"));
-                            return;
-                        }
-
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK, imagePathOrContent));
-
-                    }
-                    catch (Exception)
-                    {
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error retrieving image."));
-                    }
-                    break;
-
-                case TaskResult.Cancel:
-                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Selection cancelled."));
-                    break;
-
-                default:
-                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Selection did not complete!"));
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// Returns image content in a form of base64 string
-        /// </summary>
-        /// <param name="stream">Image stream</param>
-        /// <returns>Base64 representation of the image</returns>
-        private string GetImageContent(Stream stream)
-        {
-            int streamLength = (int)stream.Length;
-            byte[] fileData = new byte[streamLength + 1];
-            stream.Read(fileData, 0, streamLength);        
-
-            //use photo's actual width & height if user doesn't provide width & height
-            if (cameraOptions.TargetWidth < 0 && cameraOptions.TargetHeight < 0)
-            {
-                stream.Close();
-                return Convert.ToBase64String(fileData);                
-            }
-            else
-            {
-                // resize photo
-                byte[] resizedFile = ResizePhoto(stream, fileData);
-                stream.Close();
-                return Convert.ToBase64String(resizedFile);
-            }
-        }
-
-        /// <summary>
-        /// Resize image
-        /// </summary>
-        /// <param name="stream">Image stream</param>
-        /// <param name="fileData">File data</param>
-        /// <returns>resized image</returns>
-        private byte[] ResizePhoto(Stream stream, byte[] fileData)
-        {
-            int streamLength = (int)stream.Length;
-            int intResult = 0;
-
-            byte[] resizedFile;
-
-            stream.Read(fileData, 0, streamLength);
-
-            BitmapImage objBitmap = new BitmapImage();
-            MemoryStream objBitmapStream = new MemoryStream(fileData);
-            MemoryStream objBitmapStreamResized = new MemoryStream();
-            WriteableBitmap objWB;
-            objBitmap.SetSource(stream);
-            objWB = new WriteableBitmap(objBitmap);
-
-            // resize the photo with user defined TargetWidth & TargetHeight
-            Extensions.SaveJpeg(objWB, objBitmapStreamResized, cameraOptions.TargetWidth, cameraOptions.TargetHeight, 0, cameraOptions.Quality);
-
-            //Convert the resized stream to a byte array. 
-            streamLength = (int)objBitmapStreamResized.Length;
-            resizedFile = new Byte[streamLength]; //-1 
-            objBitmapStreamResized.Position = 0;
-            //for some reason we have to set Position to zero, but we don't have to earlier when we get the bytes from the chosen photo... 
-            intResult = objBitmapStreamResized.Read(resizedFile, 0, streamLength);
-
-            return resizedFile;
-        }
-        
-        /// <summary>
-        /// Saves captured image in isolated storage
-        /// </summary>
-        /// <param name="imageFileName">image file name</param>
-        /// <returns>Image path</returns>
-        private string SaveImageToLocalStorage(WriteableBitmap image, string imageFileName)
-        {
-
-            if (image == null)
-            {
-                throw new ArgumentNullException("imageBytes");
-            }
-            try
-            {
-
-
-                var isoFile = IsolatedStorageFile.GetUserStoreForApplication();
-
-                if (!isoFile.DirectoryExists(isoFolder))
-                {
-                    isoFile.CreateDirectory(isoFolder);
-                }
-
-                string filePath = System.IO.Path.Combine("/" + isoFolder + "/", imageFileName);
-
-                using (var stream = isoFile.CreateFile(filePath))
-                {
-                    // resize image if Height and Width defined via options 
-                    if (cameraOptions.TargetHeight > 0 && cameraOptions.TargetWidth > 0)
-                    {
-                        image.SaveJpeg(stream, cameraOptions.TargetWidth, cameraOptions.TargetHeight, 0, cameraOptions.Quality);
-                    }
-                    else
-                    {
-                        image.SaveJpeg(stream, image.PixelWidth, image.PixelHeight, 0, cameraOptions.Quality);
-                    }
-                }
-
-                return new Uri(filePath, UriKind.Relative).ToString();
-            }
-            catch (Exception)
-            {
-                //TODO: log or do something else
-                throw;
-            }
-        }
-
-    }
-}


Mime
View raw message