cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [11/25] js commit: merge platform + deviceproxy
Date Tue, 06 Nov 2012 00:38:28 GMT
merge platform + deviceproxy


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/425ad0b0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/425ad0b0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/425ad0b0

Branch: refs/heads/master
Commit: 425ad0b015b8373565ca859a5a1f820f4416a757
Parents: 8a58735 a45667e
Author: Jesse MacFadyen <purplecabbage@gmail.com>
Authored: Mon Oct 29 16:03:43 2012 -0700
Committer: Jesse MacFadyen <purplecabbage@gmail.com>
Committed: Mon Oct 29 16:03:43 2012 -0700

----------------------------------------------------------------------
 lib/windows8/platform.js                      |    6 +
 lib/windows8/plugin/windows8/CaptureProxy.js  |    2 +-
 lib/windows8/plugin/windows8/ContactsProxy.js |   49 +
 lib/windows8/plugin/windows8/DeviceProxy.js   |   72 +-
 lib/windows8/plugin/windows8/FileProxy.js     |    4 +-
 lib/windows8/plugin/windows8/MediaProxy.js    |    4 +-
 test/window8/README.txt                       |   14 +
 test/window8/accelerometer.tests.js           |  192 ++
 test/window8/camera.tests.js                  |  192 ++
 test/window8/capture.tests.js                 |  262 ++
 test/window8/compass.tests.js                 |   76 +
 test/window8/contacts.tests.js                |  451 +++
 test/window8/device.tests.js                  |   34 +
 test/window8/file.tests.js                    | 3481 ++++++++++++++++++++
 test/window8/filetransfer.tests.js            |   72 +
 test/window8/geolocation.tests.js             |  106 +
 test/window8/media.tests.js                   |  137 +
 test/window8/network.tests.js                 |   25 +
 test/window8/notification.tests.js            |   20 +
 test/window8/storage.tests.js                 |  405 +++
 20 files changed, 5581 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/425ad0b0/lib/windows8/platform.js
----------------------------------------------------------------------
diff --cc lib/windows8/platform.js
index cc107b9,eedd89f..5742dc4
mode 100755,100644..100755
--- a/lib/windows8/platform.js
+++ b/lib/windows8/platform.js
@@@ -33,8 -33,8 +33,9 @@@ require('cordova/plugin/windows8/Accele
  require('cordova/plugin/windows8/CameraProxy');
  require('cordova/plugin/windows8/CaptureProxy');
  require('cordova/plugin/windows8/CompassProxy');
+ require('cordova/plugin/windows8/ContactsProxy');
  require('cordova/plugin/windows8/FileProxy');
 +
  require('cordova/plugin/windows8/FileTransferProxy');
  require('cordova/plugin/windows8/MediaProxy');
  require('cordova/plugin/windows8/NotificationProxy');
@@@ -43,34 -44,19 +45,35 @@@
  module.exports = {
      id: "windows8",
      initialize:function() {
 -        var app = WinJS.Application;
  
 -        app.addEventListener("checkpoint", checkpointHandler);
 -        function checkpointHandler(eventArgs) {
 -            cordova.fireDocumentEvent('pause');
 +        var onWinJSReady = function () {
 +            var app = WinJS.Application;
 +            var checkpointHandler = function checkpointHandler() {
 +                cordova.fireDocumentEvent('pause');
 +            };
 +
 +            var resumingHandler = function resumingHandler() {
 +                cordova.fireDocumentEvent('resume');
 +            };
 +
 +            app.addEventListener("checkpoint", checkpointHandler);
 +            Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", resumingHandler,
false);
 +            app.start();
++
          };
  
 -        Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", resumingHandler,
false);
 -        function resumingHandler() {
 -            cordova.fireDocumentEvent('resume');
 -        }
 +        if (!window.WinJS) {
 +            // <script src="//Microsoft.WinJS.1.0/js/base.js"></script>
 +            var scriptElem = document.createElement("script");
 +            scriptElem.src = "//Microsoft.WinJS.1.0/js/base.js";
 +            scriptElem.addEventListener("load", onWinJSReady);
 +            document.head.appendChild(scriptElem);
  
 -        app.start();
 +            console.log("added WinJS ... ");
 +        }
 +        else {
 +            onWinJSReady();
 +        }
      },
      objects: {
          cordova: {

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/425ad0b0/lib/windows8/plugin/windows8/CaptureProxy.js
----------------------------------------------------------------------
diff --cc lib/windows8/plugin/windows8/CaptureProxy.js
index 6e5f3f0,f367e68..1e76ddb
--- a/lib/windows8/plugin/windows8/CaptureProxy.js
+++ b/lib/windows8/plugin/windows8/CaptureProxy.js
@@@ -128,29 -128,34 +128,29 @@@ module.exports = 
      getFormatData: function (successCallback, errorCallback, args) {
          Windows.Storage.StorageFile.getFileFromPathAsync(args[0]).then(
              function (storageFile) {
-                 var mediaTypeFlag = String(args[1]).split("/")[0].toLowerCase();
+                 var mediaTypeFlag = String(storageFile.contentType).split("/")[0].toLowerCase();
                  if (mediaTypeFlag === "audio") {
 -                    storageFile.properties.getMusicPropertiesAsync().then(
 -                        function (audioProperties) {
 -                            successCallback(new MediaFileData(null, audioProperties.bitrate,
0, 0, audioProperties.duration / 1000));
 -                        }, function () {
 -                            errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
 -                        }
 -                    );
 -                } else if (mediaTypeFlag === "video") {
 -                    storageFile.properties.getVideoPropertiesAsync().then(
 -                        function (videoProperties) {
 -                            successCallback(new MediaFileData(null, videoProperties.bitrate,
videoProperties.height, videoProperties.width, videoProperties.duration / 1000));
 -                        }, function () {
 -                            errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
 -                        }
 -                    );
 -                } else if (mediaTypeFlag === "image") {
 -                    storageFile.properties.getImagePropertiesAsync().then(
 -                        function (imageProperties) {
 -                            successCallback(new MediaFileData(null, 0, imageProperties.height,
imageProperties.width, 0));
 -                        }, function () {
 -                            errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
 -                        }
 -                    );
 -                } else {
 -                    errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
 +                    storageFile.properties.getMusicPropertiesAsync().then(function (audioProperties)
{
 +                        successCallback(new MediaFileData(null, audioProperties.bitrate,
0, 0, audioProperties.duration / 1000));
 +                    }, function () {
 +                        errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
 +                    });
 +                }
 +                else if (mediaTypeFlag === "video") {
 +                    storageFile.properties.getVideoPropertiesAsync().then(function (videoProperties)
{
 +                        successCallback(new MediaFileData(null, videoProperties.bitrate,
videoProperties.height, videoProperties.width, videoProperties.duration / 1000));
 +                    }, function () {
 +                        errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
 +                    });
 +                }
 +                else if (mediaTypeFlag === "image") {
 +                    storageFile.properties.getImagePropertiesAsync().then(function (imageProperties)
{
 +                        successCallback(new MediaFileData(null, 0, imageProperties.height,
imageProperties.width, 0));
 +                    }, function () {
 +                        errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
 +                    });
                  }
 +                else { errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
}
              }, function () {
                  errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
              }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/425ad0b0/lib/windows8/plugin/windows8/DeviceProxy.js
----------------------------------------------------------------------
diff --cc lib/windows8/plugin/windows8/DeviceProxy.js
index 8d5f0b2,9f7bf1b..f6aa79e
--- a/lib/windows8/plugin/windows8/DeviceProxy.js
+++ b/lib/windows8/plugin/windows8/DeviceProxy.js
@@@ -22,34 -22,60 +22,68 @@@
  var cordova = require('cordova');
  var utils = require('cordova/utils');
  
+ 
  module.exports = {
  
-     getDeviceInfo:function(win,fail,args){
-         console.log("NativeProxy::getDeviceInfo");
- 
-         // get the name ( hostName of the machine )
-         var hostNames = Windows.Networking.Connectivity.NetworkInformation.getHostNames();
-         var name = "unknown";
-         hostNames.some(function (nm) {
-             if (nm.displayName.indexOf(".local") > -1) {
-                 name = nm.displayName.split(".local")[0];
-                 return true;
-             }
-         });
- 
-         // deviceId aka uuid
-         var deviceId = localStorage.deviceId;
-         if(!deviceId) {
-             deviceId = utils.createUUID();
-             console.log(deviceId);
-             localStorage.deviceId = deviceId;
+         getDeviceInfo:function(win,fail,args){
+             console.log("NativeProxy::getDeviceInfo");
+ 
+             var hostNames = Windows.Networking.Connectivity.NetworkInformation.getHostNames();
+ 
+             var name = "unknown";
+             hostNames.some(function (nm) {
+                 if (nm.displayName.indexOf(".local") > -1) {
+                     name = nm.displayName.split(".local")[0];
+                     return true;
+                 }
+             });
+ 
+             // deviceId aka uuid
+ 
+             var deviceId = "";
+             Windows.System.UserProfile.UserInformation.getFirstNameAsync().then(function
(fileName) {
+                 var path = "C:\\Users\\" + fileName + "\\Documents";
+                 Windows.Storage.StorageFolder.getFolderFromPathAsync(path).then(function
(storageFolder) {
+                     return storageFolder.createFileAsync("appDeviceIdentifier.txt", Windows.Storage.CreationCollisionOption.openIfExists);
+                 }).then(function (storageFile) {
+                     var value = Windows.Storage.Streams.UnicodeEncoding.utf8;
+                     Windows.Storage.FileIO.readTextAsync(storageFile, value).then(function
(fileContent) {
+                         if (fileContent) {
+                             deviceId = fileContent;
+                             setTimeout(function () {
+                                 win({ platform: "windows8", version: "8", name: name, uuid:
"TODO", cordova: "2.2.0" });
+                             }, 0)
+                         } else {
+                             deviceId = utils.createUUID();
+                             Windows.Storage.FileIO.writeTextAsync(storageFile, deviceId,
Windows.Storage.Streams.UnicodeEncoding.utf8).done(
+                                 function () {
+                                     setTimeout(function () {
+                                         win({ platform: "windows8", version: "8", name:
name, uuid: "TODO", cordova: "2.2.0" });
+                                     }, 0)
+                                 }, function () {
+                                     fail(FileError.INVALID_MODIFICATION_ERR);
+                                 }
+ 
+                             );
+                         }
+                     },
+                     function () {
+                         fail(FileError.ENCODING_ERR);
+                     });
+                 }, function () {
+                     fail(FileError.NOT_FOUND_ERR);
+                 });
+                 
 -            }, fail && fail());
++            }, 
++            fail && fail());
++
          }
 +
 +        setTimeout(function(){
 +            win({platform:"windows8", version:"8", name:name, uuid:deviceId, cordova:"2.2.0"});
 +        },0);
 +    }
 +
  };
  
 -require("cordova/commandProxy").add("Device",module.exports);
 +require("cordova/commandProxy").add("Device",module.exports);

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/425ad0b0/lib/windows8/plugin/windows8/FileProxy.js
----------------------------------------------------------------------
diff --cc lib/windows8/plugin/windows8/FileProxy.js
index 2e6f50c,99c6c95..fba3b83
--- a/lib/windows8/plugin/windows8/FileProxy.js
+++ b/lib/windows8/plugin/windows8/FileProxy.js
@@@ -283,10 -285,10 +283,10 @@@ module.exports = 
  
                                          });
                                      } else {
 -                                        fail(FileError.INVALID_MODIFICATION_ERR);
 +                                        fail && fail(FileError.INVALID_MODIFICATION_ERR);
                                      }
                                  }
-                                 
+ 
                              });
                          };
                          removeEntry();

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/425ad0b0/lib/windows8/plugin/windows8/MediaProxy.js
----------------------------------------------------------------------


Mime
View raw message