You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2013/03/07 02:15:29 UTC

[1/7] Added plugin support. Core plugins implemented are Device and NetworkConnection.

http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/5bfb9c0c/CordovaMac/www/cordova.osx.js
----------------------------------------------------------------------
diff --git a/CordovaMac/www/cordova.osx.js b/CordovaMac/www/cordova.osx.js
index 52e48ab..4fc904e 100644
--- a/CordovaMac/www/cordova.osx.js
+++ b/CordovaMac/www/cordova.osx.js
@@ -876,11 +876,9 @@ function OSXExec() {
 
 
 OSXExec.nativeCallback = function(callbackId, status, message, keepCallback) {
-    return (function() {
-        var success = status === 0 || status === 1;
-        var args = convertMessageToArgsNativeToJs(message);
-        cordova.callbackFromNative(callbackId, success, status, args, keepCallback);
-    });
+    var success = status === 0 || status === 1;
+    var args = convertMessageToArgsNativeToJs(message);
+    cordova.callbackFromNative(callbackId, success, status, args, keepCallback);
 };
 
 module.exports = OSXExec;
@@ -4203,22 +4201,19 @@ function Device() {
     var me = this;
 
     channel.onCordovaReady.subscribe(function() {
-                                     // TODO: HACK:
-                                     me.available = true;
-                                      channel.onCordovaInfoReady.fire();
-//        me.getInfo(function(info) {
-//            me.available = true;
-//            me.platform = info.platform;
-//            me.version = info.version;
-//            me.name = info.name;
-//            me.uuid = info.uuid;
-//            me.cordova = info.cordova;
-//            me.model = info.model;
-//            channel.onCordovaInfoReady.fire();
-//        },function(e) {
-//            me.available = false;
-//            utils.alert("[ERROR] Error initializing Cordova: " + e);
-//        });
+        me.getInfo(function(info) {
+            me.available = true;
+            me.platform = info.platform;
+            me.version = info.version;
+            me.name = info.name;
+            me.uuid = info.uuid;
+            me.cordova = info.cordova;
+            me.model = info.model;
+            channel.onCordovaInfoReady.fire();
+        },function(e) {
+            me.available = false;
+            utils.alert("[ERROR] Error initializing Cordova: " + e);
+        });
     });
 }
 
@@ -5213,37 +5208,36 @@ var timerId = null;
 var timeout = 500;
 
 channel.onCordovaReady.subscribe(function() {
-    // TODO: HACK:
-//    me.getInfo(function(info) {
-//        me.type = info;
-//        if (info === "none") {
-//            // set a timer if still offline at the end of timer send the offline event
-//            timerId = setTimeout(function(){
-//                cordova.fireDocumentEvent("offline");
-//                timerId = null;
-//            }, timeout);
-//        } else {
-//            // If there is a current offline event pending clear it
-//            if (timerId !== null) {
-//                clearTimeout(timerId);
-//                timerId = null;
-//            }
-//            cordova.fireDocumentEvent("online");
-//        }
-//
-//        // should only fire this once
-//        if (channel.onCordovaConnectionReady.state !== 2) {
-//            channel.onCordovaConnectionReady.fire();
-//        }
-//    },
-//    function (e) {
-//        // If we can't get the network info we should still tell Cordova
-//        // to fire the deviceready event.
-//        if (channel.onCordovaConnectionReady.state !== 2) {
-//            channel.onCordovaConnectionReady.fire();
-//        }
-//        console.log("Error initializing Network Connection: " + e);
-//    });
+    me.getInfo(function(info) {
+        me.type = info;
+        if (info === "none") {
+            // set a timer if still offline at the end of timer send the offline event
+            timerId = setTimeout(function(){
+                cordova.fireDocumentEvent("offline");
+                timerId = null;
+            }, timeout);
+        } else {
+            // If there is a current offline event pending clear it
+            if (timerId !== null) {
+                clearTimeout(timerId);
+                timerId = null;
+            }
+            cordova.fireDocumentEvent("online");
+        }
+
+        // should only fire this once
+        if (channel.onCordovaConnectionReady.state !== 2) {
+            channel.onCordovaConnectionReady.fire();
+        }
+    },
+    function (e) {
+        // If we can't get the network info we should still tell Cordova
+        // to fire the deviceready event.
+        if (channel.onCordovaConnectionReady.state !== 2) {
+            channel.onCordovaConnectionReady.fire();
+        }
+        console.log("Error initializing Network Connection: " + e);
+    });
     channel.onCordovaConnectionReady.fire();
 });
 

http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/5bfb9c0c/CordovaMac/www/js/index.js
----------------------------------------------------------------------
diff --git a/CordovaMac/www/js/index.js b/CordovaMac/www/js/index.js
index 31d9064..5b90364 100644
--- a/CordovaMac/www/js/index.js
+++ b/CordovaMac/www/js/index.js
@@ -34,6 +34,9 @@ var app = {
     // function, we must explicity call 'app.receivedEvent(...);'
     onDeviceReady: function() {
         app.receivedEvent('deviceready');
+        
+//        var exec = cordova.require('cordova/exec');
+//        exec(null, null, 'Device', 'getDeviceInfo', [1, "two", { 'three': 3, 4: 'four'}]);
     },
     // Update DOM on a Received Event
     receivedEvent: function(id) {

http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/5bfb9c0c/CordovaMacScreenShot.png
----------------------------------------------------------------------
diff --git a/CordovaMacScreenShot.png b/CordovaMacScreenShot.png
deleted file mode 100644
index 4488cac..0000000
Binary files a/CordovaMacScreenShot.png and /dev/null differ