incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tim...@apache.org
Subject [6/9] js commit: moved playbook plugins for the manager into their own modules
Date Thu, 07 Jun 2012 20:59:18 GMT
moved playbook plugins for the manager into their own modules


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/d5818e1d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/d5818e1d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/d5818e1d

Branch: refs/heads/master
Commit: d5818e1d9bf9049bcc051fd85e5db08fe34e7a4f
Parents: ce4a05c
Author: Gord Tanner <gtanner@gmail.com>
Authored: Tue May 29 15:33:20 2012 -0400
Committer: Tim Kim <tim.kim@nitobi.com>
Committed: Thu Jun 7 13:50:55 2012 -0700

----------------------------------------------------------------------
 lib/playbook/plugin/manager.js               |  338 +--------------------
 lib/playbook/plugin/playbook/battery.js      |   36 +++
 lib/playbook/plugin/playbook/camera.js       |    8 +
 lib/playbook/plugin/playbook/capture.js      |   40 +++
 lib/playbook/plugin/playbook/device.js       |   31 +--
 lib/playbook/plugin/playbook/logger.js       |    9 +
 lib/playbook/plugin/playbook/media.js        |  167 ++++++++++
 lib/playbook/plugin/playbook/network.js      |   33 ++
 lib/playbook/plugin/playbook/notification.js |   31 ++
 9 files changed, 341 insertions(+), 352 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/d5818e1d/lib/playbook/plugin/manager.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/manager.js b/lib/playbook/plugin/manager.js
index 04d070d..0d951e9 100644
--- a/lib/playbook/plugin/manager.js
+++ b/lib/playbook/plugin/manager.js
@@ -1,334 +1,12 @@
 var cordova = require('cordova'),
-    MediaFile = require('cordova/plugin/MediaFile'),
-    /**
-     * Private list of HTML 5 audio objects, indexed by the Cordova media object ids
-     */
-    audioObjects = {},
-    retInvalidAction = function () {
-        return { "status" : cordova.callbackStatus.INVALID_ACTION, "message" : "Action not
found" };
-    },
-    retAsyncCall = function () {
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On
It" };
-    },
-    batteryAPI = {
-        start: function (args, win, fail) {
-            // Register one listener to each of level and state change
-            // events using WebWorks API.
-            blackberry.system.event.deviceBatteryStateChange(function(state) {
-                var me = navigator.battery;
-                // state is either CHARGING or UNPLUGGED
-                if (state === 2 || state === 3) {
-                    var info = {
-                        "level" : me._level,
-                        "isPlugged" : state === 2
-                    };
-
-                    if (me._isPlugged !== info.isPlugged && typeof win === 'function')
{
-                        win(info);
-                    }
-                }
-            });
-            blackberry.system.event.deviceBatteryLevelChange(function(level) {
-                var me = navigator.battery;
-                if (level != me._level && typeof win === 'function') {
-                    win({'level' : level, 'isPlugged' : me._isPlugged});
-                }
-            });
-
-            return retAsyncCall();
-        },
-        stop: function (args, win, fail) {
-            // Unregister battery listeners.
-            blackberry.system.event.deviceBatteryStateChange(null);
-            blackberry.system.event.deviceBatteryLevelChange(null);
-            return retAsyncCall();
-        }
-    },
-    cameraAPI = {
-        takePicture: function (args, win, fail) {
-            blackberry.media.camera.takePicture(win, fail, fail);
-            return retAsyncCall();
-        }
-    },
-    deviceAPI = {
-        getDeviceInfo: function (args, win, fail) {
-            return {"status" : cordova.callbackStatus.OK,
-                    "message" : {
-                        "version" : blackberry.system.softwareVersion,
-                        "name" : blackberry.system.model,
-                        "uuid" : blackberry.identity.PIN,
-                        "platform" : "PlayBook",
-                        "cordova" : "1.7.0rc1"
-                    }
-            };
-        }
-    },
-    loggerAPI = {
-        log: function (args, win, fail) {
-            console.log(args);
-            return {"status" : cordova.callbackStatus.OK,
-                    "message" : 'Message logged to console: ' + args};
-        }
-    },
-    mediaAPI = {
-        startPlayingAudio: function (args, win, fail) {
-            if (!args.length) {
-                return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
-            }
-
-            var id = args[0],
-                audio = audioObjects[id],
-                result;
-
-            if (args.length === 1) {
-                return {"status" : 9, "message" : "Media source argument not found"};
-            }
-
-            if (audio) {
-                audio.pause();
-                audioObjects[id] = undefined;
-            }
-
-            audio = audioObjects[id] = new Audio(args[1]);
-            audio.play();
-
-            return {"status" : 1, "message" : "Audio play started" };
-        },
-        stopPlayingAudio: function (args, win, fail) {
-            if (!args.length) {
-                return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
-            }
-
-            var id = args[0],
-                audio = audioObjects[id],
-                result;
-
-            if (!audio) {
-                return {"status" : 2, "message" : "Audio Object has not been initialized"};
-            }
-
-            audio.pause();
-            audioObjects[id] = undefined;
-
-            return {"status" : 1, "message" : "Audio play stopped" };
-        },
-        seekToAudio: function (args, win, fail) {
-            if (!args.length) {
-                return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
-            }
-
-            var id = args[0],
-                audio = audioObjects[id],
-                result;
-
-            if (!audio) {
-                result = {"status" : 2, "message" : "Audio Object has not been initialized"};
-            } else if (args.length === 1) {
-                result = {"status" : 9, "message" : "Media seek time argument not found"};
-            } else {
-                try {
-                    audio.currentTime = args[1];
-                } catch (e) {
-                    console.log('Error seeking audio: ' + e);
-                    return {"status" : 3, "message" : "Error seeking audio: " + e};
-                }
-
-                result = {"status" : 1, "message" : "Seek to audio succeeded" };
-            }
-
-            return result;
-        },
-        pausePlayingAudio: function (args, win, fail) {
-            if (!args.length) {
-                return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
-            }
-
-            var id = args[0],
-                audio = audioObjects[id],
-                result;
-
-            if (!audio) {
-                return {"status" : 2, "message" : "Audio Object has not been initialized"};
-            }
-
-            audio.pause();
-
-            return {"status" : 1, "message" : "Audio paused" };
-        },
-        getCurrentPositionAudio: function (args, win, fail) {
-            if (!args.length) {
-                return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
-            }
-
-            var id = args[0],
-                audio = audioObjects[id],
-                result;
-
-            if (!audio) {
-                return {"status" : 2, "message" : "Audio Object has not been initialized"};
-            }
-
-            return {"status" : 1, "message" : audio.currentTime };
-        },
-        getDuration: function (args, win, fail) {
-            if (!args.length) {
-                return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
-            }
-
-            var id = args[0],
-                audio = audioObjects[id],
-                result;
-
-            if (!audio) {
-                return {"status" : 2, "message" : "Audio Object has not been initialized"};
-            }
-
-            return {"status" : 1, "message" : audio.duration };
-        },
-        startRecordingAudio: function (args, win, fail) {
-            if (!args.length) {
-                return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
-            }
-
-            var id = args[0],
-                audio = audioObjects[id],
-                result;
-
-            if (args.length <= 1) {
-                result = {"status" : 9, "message" : "Media start recording, insufficient
arguments"};
-            }
-
-            blackberry.media.microphone.record(args[1], win, fail);
-            return retAsyncCall();
-        },
-        stopRecordingAudio: function (args, win, fail) {
-        },
-        release: function (args, win, fail) {
-            if (!args.length) {
-                return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
-            }
-
-            var id = args[0],
-                audio = audioObjects[id],
-                result;
-
-            if (audio) {
-                audioObjects[id] = undefined;
-                audio.src = undefined;
-                //delete audio;
-            }
-
-            result = {"status" : 1, "message" : "Media resources released"};
-
-            return result;
-        }
-    },
-    mediaCaptureAPI = {
-        getSupportedAudioModes: function (args, win, fail) {
-            return {"status": cordova.callbackStatus.OK, "message": []};
-        },
-        getSupportedImageModes: function (args, win, fail) {
-            return {"status": cordova.callbackStatus.OK, "message": []};
-        },
-        getSupportedVideoModes: function (args, win, fail) {
-            return {"status": cordova.callbackStatus.OK, "message": []};
-        },
-        captureImage: function (args, win, fail) {
-            var limit = args[0];
-
-            if (limit > 0) {
-                blackberry.media.camera.takePicture(win, fail, fail);
-            }
-            else {
-                win([]);
-            }
-
-            return retAsyncCall();
-        },
-        captureVideo: function (args, win, fail) {
-            var limit = args[0];
-
-            if (limit > 0) {
-                blackberry.media.camera.takeVideo(win, fail, fail);
-            }
-            else {
-                win([]);
-            }
-            
-            return retAsyncCall();
-        },
-        captureAudio: function (args, win, fail) {
-            return {"status": cordova.callbackStatus.INVALID_ACTION, "message": "captureAudio
is not currently supported"};
-        }
-    },
-    networkAPI = {
-        getConnectionInfo: function (args, win, fail) {
-            var connectionType = require("cordova/plugin/Connection").NONE,
-                eventType = "offline",
-                callbackID,
-                request;
-
-            /**
-             * For PlayBooks, we currently only have WiFi connections, so
-             * return WiFi if there is any access at all.
-             * TODO: update if/when PlayBook gets other connection types...
-             */
-            if (blackberry.system.hasDataCoverage()) {
-                connectionType = require("cordova/plugin/Connection").WIFI;
-                eventType = "online";
-            }
-
-            //Register an event handler for the networkChange event
-            callbackID = blackberry.events.registerEventHandler("networkChange", function
(status) {
-                win(status.type);
-            });
-
-            //pass our callback id down to our network extension
-            request = new blackberry.transport.RemoteFunctionCall("org/apache/cordova/getConnectionInfo");
-            request.addParam("networkStatusChangedID", callbackID);
-            request.makeSyncCall();
-
-            return { "status": cordova.callbackStatus.OK, "message": connectionType};
-        }
-    },
-    notificationAPI = {
-        alert: function (args, win, fail) {
-            if (args.length !== 3) {
-                return {"status" : 9, "message" : "Notification action - alert arguments
not found"};
-            }
-
-            //Unpack and map the args
-            var msg = args[0],
-                title = args[1],
-                btnLabel = args[2];
-
-            blackberry.ui.dialog.customAskAsync.apply(this, [ msg, [ btnLabel ], win, { "title"
: title } ]);
-            return retAsyncCall();
-        },
-        confirm: function (args, win, fail) {
-            if (args.length !== 3) {
-                return {"status" : 9, "message" : "Notification action - confirm arguments
not found"};
-            }
-
-            //Unpack and map the args
-            var msg = args[0],
-                title = args[1],
-                btnLabel = args[2],
-                btnLabels = btnLabel.split(",");
-
-            blackberry.ui.dialog.customAskAsync.apply(this, [msg, btnLabels, win, {"title"
: title} ]);
-            return retAsyncCall();
-        }
-    },
     plugins = {
-        'Battery' : batteryAPI,
-        'Camera' : cameraAPI,
-        'Device' : deviceAPI,
-        'Logger' : loggerAPI,
-        'Media' : mediaAPI,
-        'Capture' : mediaCaptureAPI,
-        'NetworkStatus' : networkAPI,
-        'Notification' : notificationAPI
+        'Battery' : require('cordova/plugin/playbook/battery'),
+        'Camera' : require('cordova/plugin/playbook/camera'),
+        'Logger' : require('cordova/plugin/playbook/logger'),
+        'Media' : require('cordova/plugin/playbook/media'),
+        'Capture' : require('cordova/plugin/playbook/capture'),
+        'NetworkStatus' : require('cordova/plugin/playbook/network'),
+        'Notification' : require('cordova/plugin/playbook/notification')
     };
 
 module.exports = {
@@ -340,7 +18,7 @@ module.exports = {
                 result = plugins[clazz][action](args, win, fail);
             }
             else {
-                result = retInvalidAction();
+                result = { "status" : cordova.callbackStatus.INVALID_ACTION, "message" :
"Action not found: " + action };
             }
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/d5818e1d/lib/playbook/plugin/playbook/battery.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/battery.js b/lib/playbook/plugin/playbook/battery.js
new file mode 100644
index 0000000..14eb7ce
--- /dev/null
+++ b/lib/playbook/plugin/playbook/battery.js
@@ -0,0 +1,36 @@
+var cordova = require('cordova');
+
+module.exports = {
+    start: function (args, win, fail) {
+        // Register one listener to each of level and state change
+        // events using WebWorks API.
+        blackberry.system.event.deviceBatteryStateChange(function(state) {
+            var me = navigator.battery;
+            // state is either CHARGING or UNPLUGGED
+            if (state === 2 || state === 3) {
+                var info = {
+                    "level" : me._level,
+                    "isPlugged" : state === 2
+                };
+
+                if (me._isPlugged !== info.isPlugged && typeof win === 'function')
{
+                    win(info);
+                }
+            }
+        });
+        blackberry.system.event.deviceBatteryLevelChange(function(level) {
+            var me = navigator.battery;
+            if (level != me._level && typeof win === 'function') {
+                win({'level' : level, 'isPlugged' : me._isPlugged});
+            }
+        });
+
+        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On
It" };
+    },
+    stop: function (args, win, fail) {
+        // Unregister battery listeners.
+        blackberry.system.event.deviceBatteryStateChange(null);
+        blackberry.system.event.deviceBatteryLevelChange(null);
+        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On
It" };
+    }
+};

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/d5818e1d/lib/playbook/plugin/playbook/camera.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/camera.js b/lib/playbook/plugin/playbook/camera.js
new file mode 100644
index 0000000..e8e6af2
--- /dev/null
+++ b/lib/playbook/plugin/playbook/camera.js
@@ -0,0 +1,8 @@
+var cordova = require('cordova');
+
+module.exports = {
+    takePicture: function (args, win, fail) {
+        blackberry.media.camera.takePicture(win, fail, fail);
+        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On
It" };
+    }
+};

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/d5818e1d/lib/playbook/plugin/playbook/capture.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/capture.js b/lib/playbook/plugin/playbook/capture.js
new file mode 100644
index 0000000..d26d5c8
--- /dev/null
+++ b/lib/playbook/plugin/playbook/capture.js
@@ -0,0 +1,40 @@
+var cordova = require('cordova');
+
+module.exports = {
+    getSupportedAudioModes: function (args, win, fail) {
+        return {"status": cordova.callbackStatus.OK, "message": []};
+    },
+    getSupportedImageModes: function (args, win, fail) {
+        return {"status": cordova.callbackStatus.OK, "message": []};
+    },
+    getSupportedVideoModes: function (args, win, fail) {
+        return {"status": cordova.callbackStatus.OK, "message": []};
+    },
+    captureImage: function (args, win, fail) {
+        var limit = args[0].limit;
+
+        if (limit > 0) {
+            blackberry.media.camera.takePicture(win, fail, fail);
+        }
+        else {
+            win([]);
+        }
+
+        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On
It" };
+    },
+    captureVideo: function (args, win, fail) {
+        var limit = args[0];
+
+        if (limit > 0) {
+            blackberry.media.camera.takeVideo(win, fail, fail);
+        }
+        else {
+            win([]);
+        }
+        
+        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On
It" };
+    },
+    captureAudio: function (args, win, fail) {
+        return {"status": cordova.callbackStatus.INVALID_ACTION, "message": "captureAudio
is not currently supported"};
+    }
+};

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/d5818e1d/lib/playbook/plugin/playbook/device.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/device.js b/lib/playbook/plugin/playbook/device.js
index f0e0027..fc49d3a 100644
--- a/lib/playbook/plugin/playbook/device.js
+++ b/lib/playbook/plugin/playbook/device.js
@@ -1,24 +1,11 @@
-var me = {},
-    exec = require('cordova/exec'),
-    channel = require('cordova/channel');
+var channel = require('cordova/channel');
 
-channel.onCordovaReady.subscribeOnce(function() {
-    exec(function (device) {
-        me.platform = device.platform;
-        me.version  = device.version;
-        me.name     = device.name;
-        me.uuid     = device.uuid;
-        me.cordova  = device.cordova;
+module.exports = {
+    platform: "PlayBook",
+    version: blackberry.system.softwareVersion,
+    name: blackberry.system.model,
+    uuid: blackberry.identity.PIN,
+    cordova: "1.7.0rc1"
+};
 
-        channel.onCordovaInfoReady.fire();
-    },
-    function (e) {
-        console.log("error initializing cordova: " + e);
-    },
-    "Device",
-    "getDeviceInfo",
-    []
-    );
-});
-
-module.exports = me;
\ No newline at end of file
+channel.onCordovaInfoReady.fire();

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/d5818e1d/lib/playbook/plugin/playbook/logger.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/logger.js b/lib/playbook/plugin/playbook/logger.js
new file mode 100644
index 0000000..8b8310b
--- /dev/null
+++ b/lib/playbook/plugin/playbook/logger.js
@@ -0,0 +1,9 @@
+var cordova = require('cordova');
+
+module.exports = {
+    log: function (args, win, fail) {
+        console.log(args);
+        return {"status" : cordova.callbackStatus.OK,
+                "message" : 'Message logged to console: ' + args};
+    }
+};

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/d5818e1d/lib/playbook/plugin/playbook/media.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/media.js b/lib/playbook/plugin/playbook/media.js
new file mode 100644
index 0000000..1609238
--- /dev/null
+++ b/lib/playbook/plugin/playbook/media.js
@@ -0,0 +1,167 @@
+var cordova = require('cordova'),
+    audioObjects = {};
+
+module.exports = {
+    create: function (args, win, fail) {
+        if (!args.length) {
+            return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
+        }
+
+        var id = args[0],
+            src = args[1];
+
+        audioObjects[id] = new Audio(src);
+        return {"status" : 1, "message" : "Audio object created" };
+    },
+    startPlayingAudio: function (args, win, fail) {
+        if (!args.length) {
+            return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
+        }
+
+        var id = args[0],
+            audio = audioObjects[id],
+            result;
+
+        if (args.length === 1) {
+            return {"status" : 9, "message" : "Media source argument not found"};
+        }
+
+        if (audio) {
+            audio.pause();
+            audioObjects[id] = undefined;
+        }
+
+        audio = audioObjects[id] = new Audio(args[1]);
+        audio.play();
+
+        return {"status" : 1, "message" : "Audio play started" };
+    },
+    stopPlayingAudio: function (args, win, fail) {
+        if (!args.length) {
+            return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
+        }
+
+        var id = args[0],
+            audio = audioObjects[id],
+            result;
+
+        if (!audio) {
+            return {"status" : 2, "message" : "Audio Object has not been initialized"};
+        }
+
+        audio.pause();
+        audioObjects[id] = undefined;
+
+        return {"status" : 1, "message" : "Audio play stopped" };
+    },
+    seekToAudio: function (args, win, fail) {
+        if (!args.length) {
+            return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
+        }
+
+        var id = args[0],
+            audio = audioObjects[id],
+            result;
+
+        if (!audio) {
+            result = {"status" : 2, "message" : "Audio Object has not been initialized"};
+        } else if (args.length === 1) {
+            result = {"status" : 9, "message" : "Media seek time argument not found"};
+        } else {
+            try {
+                audio.currentTime = args[1];
+            } catch (e) {
+                console.log('Error seeking audio: ' + e);
+                return {"status" : 3, "message" : "Error seeking audio: " + e};
+            }
+
+            result = {"status" : 1, "message" : "Seek to audio succeeded" };
+        }
+
+        return result;
+    },
+    pausePlayingAudio: function (args, win, fail) {
+        if (!args.length) {
+            return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
+        }
+
+        var id = args[0],
+            audio = audioObjects[id],
+            result;
+
+        if (!audio) {
+            return {"status" : 2, "message" : "Audio Object has not been initialized"};
+        }
+
+        audio.pause();
+
+        return {"status" : 1, "message" : "Audio paused" };
+    },
+    getCurrentPositionAudio: function (args, win, fail) {
+        if (!args.length) {
+            return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
+        }
+
+        var id = args[0],
+            audio = audioObjects[id],
+            result;
+
+        if (!audio) {
+            return {"status" : 2, "message" : "Audio Object has not been initialized"};
+        }
+
+        return {"status" : 1, "message" : audio.currentTime };
+    },
+    getDuration: function (args, win, fail) {
+        if (!args.length) {
+            return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
+        }
+
+        var id = args[0],
+            audio = audioObjects[id],
+            result;
+
+        if (!audio) {
+            return {"status" : 2, "message" : "Audio Object has not been initialized"};
+        }
+
+        return {"status" : 1, "message" : audio.duration };
+    },
+    startRecordingAudio: function (args, win, fail) {
+        if (!args.length) {
+            return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
+        }
+
+        var id = args[0],
+            audio = audioObjects[id],
+            result;
+
+        if (args.length <= 1) {
+            result = {"status" : 9, "message" : "Media start recording, insufficient arguments"};
+        }
+
+        blackberry.media.microphone.record(args[1], win, fail);
+        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On
It" };
+    },
+    stopRecordingAudio: function (args, win, fail) {
+    },
+    release: function (args, win, fail) {
+        if (!args.length) {
+            return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
+        }
+
+        var id = args[0],
+            audio = audioObjects[id],
+            result;
+
+        if (audio) {
+            audioObjects[id] = undefined;
+            audio.src = undefined;
+            //delete audio;
+        }
+
+        result = {"status" : 1, "message" : "Media resources released"};
+
+        return result;
+    }
+};

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/d5818e1d/lib/playbook/plugin/playbook/network.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/network.js b/lib/playbook/plugin/playbook/network.js
new file mode 100644
index 0000000..d8e0e91
--- /dev/null
+++ b/lib/playbook/plugin/playbook/network.js
@@ -0,0 +1,33 @@
+var cordova = require('cordova'),
+    connection = require('cordova/plugin/Connection');
+
+module.exports = {
+    getConnectionInfo: function (args, win, fail) {
+        var connectionType = connection.NONE,
+            eventType = "offline",
+            callbackID,
+            request;
+
+        /**
+         * For PlayBooks, we currently only have WiFi connections, so
+         * return WiFi if there is any access at all.
+         * TODO: update if/when PlayBook gets other connection types...
+         */
+        if (blackberry.system.hasDataCoverage()) {
+            connectionType = connection.WIFI;
+            eventType = "online";
+        }
+
+        //Register an event handler for the networkChange event
+        callbackID = blackberry.events.registerEventHandler("networkChange", function (status)
{
+            win(status.type);
+        });
+
+        //pass our callback id down to our network extension
+        request = new blackberry.transport.RemoteFunctionCall("org/apache/cordova/getConnectionInfo");
+        request.addParam("networkStatusChangedID", callbackID);
+        request.makeSyncCall();
+
+        return { "status": cordova.callbackStatus.OK, "message": connectionType};
+    }
+};

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/d5818e1d/lib/playbook/plugin/playbook/notification.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/notification.js b/lib/playbook/plugin/playbook/notification.js
new file mode 100644
index 0000000..fb95527
--- /dev/null
+++ b/lib/playbook/plugin/playbook/notification.js
@@ -0,0 +1,31 @@
+var cordova = require('cordova');
+
+module.exports = {
+    alert: function (args, win, fail) {
+        if (args.length !== 3) {
+            return {"status" : 9, "message" : "Notification action - alert arguments not
found"};
+        }
+
+        //Unpack and map the args
+        var msg = args[0],
+            title = args[1],
+            btnLabel = args[2];
+
+        blackberry.ui.dialog.customAskAsync.apply(this, [ msg, [ btnLabel ], win, { "title"
: title } ]);
+        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On
It" };
+    },
+    confirm: function (args, win, fail) {
+        if (args.length !== 3) {
+            return {"status" : 9, "message" : "Notification action - confirm arguments not
found"};
+        }
+
+        //Unpack and map the args
+        var msg = args[0],
+            title = args[1],
+            btnLabel = args[2],
+            btnLabels = btnLabel.split(",");
+
+        blackberry.ui.dialog.customAskAsync.apply(this, [msg, btnLabels, win, {"title" :
title} ]);
+        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On
It" };
+    }
+};


Mime
View raw message