incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject bada-wac commit: updating cordova.js with overriden objects
Date Wed, 06 Jun 2012 22:28:23 GMT
Updated Branches:
  refs/heads/master cef76ff1b -> 62c656d9d


updating cordova.js with overriden objects


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

Branch: refs/heads/master
Commit: 62c656d9d3754b2ada74e896209329905d2ea348
Parents: cef76ff
Author: Anis Kadri <anis.kadri@gmail.com>
Authored: Wed Jun 6 15:28:16 2012 -0700
Committer: Anis Kadri <anis.kadri@gmail.com>
Committed: Wed Jun 6 15:28:16 2012 -0700

----------------------------------------------------------------------
 Res/index.html    |    2 +-
 Res/js/cordova.js |  927 +++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 809 insertions(+), 120 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/blob/62c656d9/Res/index.html
----------------------------------------------------------------------
diff --git a/Res/index.html b/Res/index.html
index 7497782..5ce902c 100644
--- a/Res/index.html
+++ b/Res/index.html
@@ -49,7 +49,7 @@
                 /* filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#ffffffff',EndColorStr='#ffeeddaa');
*/ 
               } 
     </style>
-    <link href="osp://webapp/css/style.css" rel="stylesheet" type="text/css" />
+    <link href="osp://webapp/css/style.css" rel="stylesheet" type="text/css" />f
     <script type="text/javascript" src="osp://webapp/js/webapp_core.js"> </script>
     <script type="text/javascript" src="osp://webapp/js/webapp_ui.js"> </script>
     <script>

http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/blob/62c656d9/Res/js/cordova.js
----------------------------------------------------------------------
diff --git a/Res/js/cordova.js b/Res/js/cordova.js
index 507f002..0174c3a 100644
--- a/Res/js/cordova.js
+++ b/Res/js/cordova.js
@@ -1,6 +1,6 @@
-// commit 71d806e61e5240ccf9f6299500741b68ea9c5d3d
+// commit 1d778ae19396ed44a459faa3849f97fa9e13a0fc
 
-// File generated at :: Fri May 11 2012 08:12:45 GMT-0700 (Pacific Daylight Time)
+// File generated at :: Wed Jun 06 2012 15:17:05 GMT-0700 (Pacific Daylight Time)
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one
@@ -77,7 +77,7 @@ var channel = require('cordova/channel');
 document.addEventListener('DOMContentLoaded', function() {
     channel.onDOMContentLoaded.fire();
 }, false);
-if (document.readyState == 'complete') {
+if (document.readyState == 'complete' || document.readyState == 'interactive') {
     channel.onDOMContentLoaded.fire();
 }
 
@@ -98,18 +98,12 @@ var documentEventHandlers = {},
 
 document.addEventListener = function(evt, handler, capture) {
     var e = evt.toLowerCase();
-    if (e == 'deviceready') {
-        channel.onDeviceReady.subscribeOnce(handler);
-    } else if (e == 'resume') {
-        channel.onResume.subscribe(handler);
-        // if subscribing listener after event has already fired, invoke the handler
-        if (channel.onResume.fired && typeof handler == 'function') {
-            handler();
+    if (typeof documentEventHandlers[e] != 'undefined') {
+        if (evt === 'deviceready') {
+            documentEventHandlers[e].subscribeOnce(handler);
+        } else {
+            documentEventHandlers[e].subscribe(handler);
         }
-    } else if (e == 'pause') {
-        channel.onPause.subscribe(handler);
-    } else if (typeof documentEventHandlers[e] != 'undefined') {
-        documentEventHandlers[e].subscribe(handler);
     } else {
         m_document_addEventListener.call(document, evt, handler, capture);
     }
@@ -126,13 +120,8 @@ window.addEventListener = function(evt, handler, capture) {
 
 document.removeEventListener = function(evt, handler, capture) {
     var e = evt.toLowerCase();
-    // Check for pause/resume events first.
-    if (e == 'resume') {
-        channel.onResume.unsubscribe(handler);
-    } else if (e == 'pause') {
-        channel.onPause.unsubscribe(handler);
     // If unsubcribing from an event that is handled by a plugin
-    } else if (typeof documentEventHandlers[e] != "undefined") {
+    if (typeof documentEventHandlers[e] != "undefined") {
         documentEventHandlers[e].unsubscribe(handler);
     } else {
         m_document_removeEventListener.call(document, evt, handler, capture);
@@ -318,6 +307,11 @@ var cordova = {
     }
 };
 
+// Register pause, resume and deviceready channels as events on document.
+channel.onPause = cordova.addDocumentEventHandler('pause');
+channel.onResume = cordova.addDocumentEventHandler('resume');
+channel.onDeviceReady = cordova.addDocumentEventHandler('deviceready');
+
 // Adds deprecation warnings to functions of an object (but only logs a message once)
 function deprecateFunctions(obj, objLabel) {
     var newObj = {};
@@ -514,7 +508,7 @@ var Channel = function(type, opts) {
     this.type = type;
     this.handlers = {};
     this.numHandlers = 0;
-    this.guid = 0;
+    this.guid = 1;
     this.fired = false;
     this.enabled = true;
     this.events = {
@@ -605,12 +599,21 @@ Channel.prototype.subscribe = function(f, c, g) {
     var func = f;
     if (typeof c == "object") { func = utils.close(c, f); }
 
-    g = g || func.observer_guid || f.observer_guid || this.guid++;
+    g = g || func.observer_guid || f.observer_guid;
+    if (!g) {
+        // first time we've seen this subscriber
+        g = this.guid++;
+    }
+    else {
+        // subscriber already handled; dont set it twice
+        return g;
+    }
     func.observer_guid = g;
     f.observer_guid = g;
     this.handlers[g] = func;
     this.numHandlers++;
     if (this.events.onSubscribe) this.events.onSubscribe.call(this);
+    if (this.fired) func.call(this);
     return g;
 };
 
@@ -647,6 +650,7 @@ Channel.prototype.unsubscribe = function(g) {
     if (typeof g == 'function') { g = g.observer_guid; }
     var handler = this.handlers[g];
     if (handler) {
+        if (handler.observer_guid) handler.observer_guid=null;
         this.handlers[g] = null;
         delete this.handlers[g];
         this.numHandlers--;
@@ -721,6 +725,9 @@ module.exports = {
             children: {
                 exec: {
                     path: 'cordova/exec'
+                },
+                logger: {
+                    path: 'cordova/plugin/logger'
                 }
             }
         },
@@ -786,6 +793,9 @@ module.exports = {
         Camera:{
             path: 'cordova/plugin/CameraConstants'
         },
+        CameraPopoverOptions: {
+            path: 'cordova/plugin/CameraPopoverOptions'
+        },
         CaptureError: {
             path: 'cordova/plugin/CaptureError'
         },
@@ -919,7 +929,7 @@ define("cordova/exec", function(require, exports, module) {
 var plugins = {
     "Device": require('cordova/plugin/bada/device'),
     "NetworkStatus": require('cordova/plugin/bada/NetworkStatus'),
-    "Accelerometer": require('cordova/plugin/bada/Accelerometer'),
+//    "Accelerometer": require('cordova/plugin/bada/Accelerometer'),
     "Notification": require('cordova/plugin/bada/Notification'),
     "Compass": require('cordova/plugin/bada/Compass'),
     "Capture": require('cordova/plugin/bada/Capture'),
@@ -949,6 +959,16 @@ module.exports = {
     objects: {
         device: {
             path: 'cordova/plugin/bada/device'
+        },
+        navigator: {
+            children: {
+                accelerometer: {
+                    path: "cordova/plugin/bada/Accelerometer"
+                },
+                notification: {
+                    path: "cordova/plugin/bada/Notification"
+                }
+            }
         }
     },
     merges: {
@@ -957,9 +977,9 @@ module.exports = {
                 device: {
                     path: "cordova/plugin/bada/device"
                 },
-//                camera: {
-//                    path: "cordova/plugin/bada/Camera"
-//                },
+                camera: {
+                    path: "cordova/plugin/bada/Camera"
+                },
                 capture: {
                     path: "cordova/plugin/bada/Capture"
                 }
@@ -973,13 +993,14 @@ module.exports = {
 // file: lib\common\plugin\Acceleration.js
 define("cordova/plugin/Acceleration", function(require, exports, module) {
 var Acceleration = function(x, y, z, timestamp) {
-  this.x = x;
-  this.y = y;
-  this.z = z;
-  this.timestamp = timestamp || (new Date()).getTime();
+    this.x = x;
+    this.y = y;
+    this.z = z;
+    this.timestamp = timestamp || (new Date()).getTime();
 };
 
 module.exports = Acceleration;
+
 });
 
 // file: lib\common\plugin\Camera.js
@@ -998,7 +1019,7 @@ for (var key in Camera) {
  * Gets a picture from source defined by "options.sourceType", and returns the
  * image as defined by the "options.destinationType" option.
 
- * The defaults are sourceType=CAMERA and destinationType=FILE_URL.
+ * The defaults are sourceType=CAMERA and destinationType=FILE_URI.
  *
  * @param {Function} successCallback
  * @param {Function} errorCallback
@@ -1084,8 +1105,12 @@ cameraExport.getPicture = function(successCallback, errorCallback,
options) {
     } else if (typeof options.saveToPhotoAlbum == "number") {
         saveToPhotoAlbum = options.saveToPhotoAlbum <=0 ? false : true;
     }
+    var popoverOptions = null;
+    if (typeof options.popoverOptions == "object") {
+        popoverOptions = options.popoverOptions;
+    }
 
-    exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType,
sourceType, targetWidth, targetHeight, encodingType, mediaType, allowEdit, correctOrientation,
saveToPhotoAlbum]);
+    exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType,
sourceType, targetWidth, targetHeight, encodingType, mediaType, allowEdit, correctOrientation,
saveToPhotoAlbum, popoverOptions]);
 };
 
 module.exports = cameraExport;
@@ -1111,10 +1136,37 @@ module.exports = {
     PHOTOLIBRARY : 0,    // Choose image from picture library (same as SAVEDPHOTOALBUM for
Android)
     CAMERA : 1,          // Take picture from camera
     SAVEDPHOTOALBUM : 2  // Choose image from picture library (same as PHOTOLIBRARY for Android)
+  },
+  PopoverArrowDirection:{
+      ARROW_UP : 1,        // matches iOS UIPopoverArrowDirection constants to specify arrow
location on popover
+      ARROW_DOWN : 2,
+      ARROW_LEFT : 4,
+      ARROW_RIGHT : 8,
+      ARROW_ANY : 15
   }
 };
 });
 
+// file: lib\common\plugin\CameraPopoverOptions.js
+define("cordova/plugin/CameraPopoverOptions", function(require, exports, module) {
+var Camera = require('cordova/plugin/CameraConstants');
+
+/**
+ * Encapsulates options for iOS Popover image picker
+ */
+var CameraPopoverOptions = function(x,y,width,height,arrowDir){
+    // information of rectangle that popover should be anchored to
+    this.x = x || 0;
+    this.y = y || 32;
+    this.width = width || 320;
+    this.height = height || 480;
+    // The direction of the popover arrow
+    this.arrowDir = arrowDir || Camera.PopoverArrowDirection.ARROW_ANY;
+};
+
+module.exports = CameraPopoverOptions;
+});
+
 // file: lib\common\plugin\CaptureAudioOptions.js
 define("cordova/plugin/CaptureAudioOptions", function(require, exports, module) {
 /**
@@ -1944,7 +1996,7 @@ Entry.prototype.toURL = function() {
 Entry.prototype.toURI = function(mimeType) {
     console.log("DEPRECATED: Update your code to use 'toURL'");
     // fullPath attribute contains the full URI
-    return this.fullPath;
+    return this.toURL();
 };
 
 /**
@@ -3113,7 +3165,7 @@ var Position = function(coords, timestamp) {
     } else {
         this.coords = new Coordinates();
     }
-    this.timestamp = (timestamp !== undefined) ? timestamp : new Date().getTime();
+    this.timestamp = (timestamp !== undefined) ? timestamp : new Date();
 };
 
 module.exports = Position;
@@ -3198,11 +3250,60 @@ define("cordova/plugin/accelerometer", function(require, exports,
module) {
  * @constructor
  */
 var utils = require("cordova/utils"),
-    exec = require("cordova/exec");
+    exec = require("cordova/exec"),
+    Acceleration = require('cordova/plugin/Acceleration');
+
+// Is the accel sensor running?
+var running = false;
 
-// Local singleton variables.
+// Keeps reference to watchAcceleration calls.
 var timers = {};
 
+// Array of listeners; used to keep track of when we should call start and stop.
+var listeners = [];
+
+// Last returned acceleration object from native
+var accel = null;
+
+// Tells native to start.
+function start() {
+    exec(function(a) {
+        var tempListeners = listeners.slice(0);
+        accel = new Acceleration(a.x, a.y, a.z, a.timestamp);
+        for (var i = 0, l = tempListeners.length; i < l; i++) {
+            tempListeners[i].win(accel);
+        }
+    }, function(e) {
+        var tempListeners = listeners.slice(0);
+        for (var i = 0, l = tempListeners.length; i < l; i++) {
+            tempListeners[i].fail(e);
+        }
+    }, "Accelerometer", "start", []);
+    running = true;
+}
+
+// Tells native to stop.
+function stop() {
+    exec(null, null, "Accelerometer", "stop", []);
+    running = false;
+}
+
+// Adds a callback pair to the listeners array
+function createCallbackPair(win, fail) {
+    return {win:win, fail:fail};
+}
+
+// Removes a win/fail listener pair from the listeners array
+function removeListeners(l) {
+    var idx = listeners.indexOf(l);
+    if (idx > -1) {
+        listeners.splice(idx, 1);
+        if (listeners.length === 0) {
+            stop();
+        }
+    }
+}
+
 var accelerometer = {
     /**
      * Asynchronously aquires the current acceleration.
@@ -3212,21 +3313,27 @@ var accelerometer = {
      * @param {AccelerationOptions} options The options for getting the accelerometer data
such as timeout. (OPTIONAL)
      */
     getCurrentAcceleration: function(successCallback, errorCallback, options) {
-
         // successCallback required
         if (typeof successCallback !== "function") {
-            console.log("Accelerometer Error: successCallback is not a function");
-            return;
+            throw "getCurrentAcceleration must be called with at least a success callback
function as first parameter.";
         }
 
-        // errorCallback optional
-        if (errorCallback && (typeof errorCallback !== "function")) {
-            console.log("Accelerometer Error: errorCallback is not a function");
-            return;
-        }
+        var p;
+        var win = function(a) {
+            successCallback(a);
+            removeListeners(p);
+        };
+        var fail = function(e) {
+            errorCallback(e);
+            removeListeners(p);
+        };
+
+        p = createCallbackPair(win, fail);
+        listeners.push(p);
 
-        // Get acceleration
-        exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
+        if (!running) {
+            start();
+        }
     },
 
     /**
@@ -3238,36 +3345,38 @@ var accelerometer = {
      * @return String                       The watch id that must be passed to #clearWatch
to stop watching.
      */
     watchAcceleration: function(successCallback, errorCallback, options) {
-
         // Default interval (10 sec)
-        var frequency = (options !== undefined && options.frequency !== undefined)?
options.frequency : 10000;
+        var frequency = (options && options.frequency && typeof options.frequency
== 'number') ? options.frequency : 10000;
 
         // successCallback required
         if (typeof successCallback !== "function") {
-            console.log("Accelerometer Error: successCallback is not a function");
-            return;
+            throw "watchAcceleration must be called with at least a success callback function
as first parameter.";
         }
 
-        // errorCallback optional
-        if (errorCallback && (typeof errorCallback !== "function")) {
-            console.log("Accelerometer Error: errorCallback is not a function");
-            return;
-        }
+        // Keep reference to watch id, and report accel readings as often as defined in frequency
+        var id = utils.createUUID();
 
-        // Make sure accelerometer timeout > frequency + 10 sec
-        exec(
-            function(timeout) {
-                if (timeout < (frequency + 10000)) {
-                    exec(null, null, "Accelerometer", "setTimeout", [frequency + 10000]);
+        var p = createCallbackPair(function(){}, function(e) {
+            errorCallback(e);
+            removeListeners(p);
+        });
+        listeners.push(p);
+
+        timers[id] = {
+            timer:window.setInterval(function() {
+                if (accel) {
+                    successCallback(accel);
                 }
-            },
-            function(e) { }, "Accelerometer", "getTimeout", []);
+            }, frequency),
+            listeners:p
+        };
 
-        // Start watch timer
-        var id = utils.createUUID();
-        timers[id] = window.setInterval(function() {
-            exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
-        }, (frequency ? frequency : 1));
+        if (running) {
+            // If we're already running then immediately invoke the success callback
+            successCallback(accel);
+        } else {
+            start();
+        }
 
         return id;
     },
@@ -3278,16 +3387,17 @@ var accelerometer = {
      * @param {String} id       The id of the watch returned from #watchAcceleration.
      */
     clearWatch: function(id) {
-
         // Stop javascript timer & remove from timer list
-        if (id && timers[id] !== undefined) {
-            window.clearInterval(timers[id]);
+        if (id && timers[id]) {
+            window.clearInterval(timers[id].timer);
+            removeListeners(timers[id].listeners);
             delete timers[id];
         }
     }
 };
 
 module.exports = accelerometer;
+
 });
 
 // file: lib\bada\plugin\bada\Accelerometer.js
@@ -3295,7 +3405,7 @@ define("cordova/plugin/bada/Accelerometer", function(require, exports,
module) {
 var Acceleration = require('cordova/plugin/Acceleration');
 
 module.exports = {
-    getAcceleration: function(successCallback, errorCallback, options) {
+    getCurrentAcceleration: function(successCallback, errorCallback, options) {
         var success = function(acceleration) {
             console.log("Accelermometer:getAcceleration:success");
             var accel = new Acceleration(acceleration.xAxis, acceleration.yAxis, acceleration.zAxis);
@@ -3311,7 +3421,6 @@ module.exports = {
         };
         deviceapis.accelerometer.getCurrentAcceleration(success, error);
     },
-    // XXX: unused with cordovaJS
     watchAcceleration: function(successCallback, errorCallback, options) {
         var success = function(acceleration) {
             console.log("accelerometer:watchAcceleration:success");
@@ -3504,7 +3613,7 @@ var allowedFilters = ["firstName", "lastName", "phoneticName", "nickname",
"phon
 function _pgToWac(contact) {
     var i, j;
     var wacContact = {};
-    
+
     if(contact.id) {
         wacContact.id = contact.id;
     }
@@ -3535,7 +3644,7 @@ function _pgToWac(contact) {
             }
         }
     }
-    
+
     // emails
     if(contact.emails &&  contact.emails.length > 0) {
         wacContact.emails = [];
@@ -3585,11 +3694,11 @@ function _pgToWac(contact) {
 function _wacToPg(contact) {
     var i, j;
     var pgContact = {};
-    
+
     if(contact.id) {
         pgContact.id = contact.id;
     }
-    
+
     // name
     if(contact.firstName || contact.lastName) {
         pgContact.name = {};
@@ -3597,12 +3706,12 @@ function _wacToPg(contact) {
         pgContact.name.familyName = contact.lastName;
         pgContact.displayName = contact.firstName + ' ' + contact.lastName;
     }
-    
+
     // nicknames
     if(contact.nicknames && contact.nicknames.length > 0) {
         pgContact.nickname = contact.nicknames[0];
     }
-    
+
     // phoneNumbers
     if(contact.phoneNumbers && contact.phoneNumbers.length > 0) {
         pgContact.phoneNumbers = [];
@@ -3619,7 +3728,7 @@ function _wacToPg(contact) {
             pgContact.phoneNumbers.push(pgPhoneNumber);
         }
     }
-    
+
     // emails
     if(contact.emails && contact.emails.length > 0) {
         pgContact.emails = [];
@@ -3636,7 +3745,7 @@ function _wacToPg(contact) {
             pgContact.emails.push(pgEmailAddress);
         }
     }
-    
+
     // addresses
     if(contact.addresses && contact.addresses.length > 0) {
         pgContact.addresses = [];
@@ -3657,7 +3766,7 @@ function _wacToPg(contact) {
             pgContact.addresses.push(pgAddress);
         }
     }
-    
+
     // photos
     // can only store one photo URL
     if(contact.photoURL) {
@@ -3702,7 +3811,6 @@ module.exports = {
         deviceapis.pim.contact.getAddressBooks(gotBooks, gotError);
     },
     remove: function(success, fail, params) {
-        console.log("Contacts:remove "+JSON.stringify(params));
         var id = params[0];
         var gotBooks = function(books) {
             var book = books[0];
@@ -3716,7 +3824,7 @@ module.exports = {
                 if(contacts.length === 1) {
                     book.deleteContact(removeSuccess, removeError, contacts[0].id);
                 }
-            }
+            };
             if(id) {
                 book.findContacts(toDelete, removeError, {id: id});
             }
@@ -3754,37 +3862,196 @@ module.exports = {
 
 });
 
+// file: lib\bada\plugin\bada\File.js
+define("cordova/plugin/bada/File", function(require, exports, module) {
+var LocalFileSystem = require('cordova/plugin/LocalFileSystem'),
+    FileSystem = require('cordova/plugin/FileSystem');
+
+module.exports = {
+    /*
+     * @params: [type, size]
+     */
+    requestFileSystem: function(success, fail, params) {
+        console.log("File.requestFileSystem");
+        var type = params[0];
+        var name = "wgt-private";
+
+        if(type === LocalFileSystem.TEMPORARY) {
+            name = "wgt-private-tmp";
+        }
+        var resolveSuccess = function(dir) {
+            success({name: name, root: {name: name, fullPath: dir.fullPath}});
+        };
+        var resolveError = function(e) {
+            fail(e);
+        };
+        deviceapis.filesystem.resolve(resolveSuccess, resolveError, name, 'r');
+    },
+    /*
+     * @params: [fullPath, path, options]
+     */
+    getDirectory: function(success, fail, params) {
+        console.log("File.getDirectory");
+        var fullPath = params[0],
+            path = params[1],
+            options = params[2];
+        var resolveSuccess = function(dir) {
+            dir.createDirectory(path);
+        };
+        var resolveError = function(e) {
+            fail(e);
+        };
+        deviceapis.filesystem.resolve(resolveSuccess, resolveError, fullPath, 'rw');
+    },
+    /*
+     * @params: fullPath
+     */
+    removeRecursively: function(success, fail, params) {
+        console.log("File.removeRecursively");
+
+    },
+    /*
+     * @params: fullPath, path, options
+     */
+    getFile: function(success, fail, params) {
+        console.log("File.getFile");
+
+    },
+    /*
+     * @params: fullPath, path, options
+     */
+    readEntries: function(success, fail, params) {
+        console.log("File.readEntries");
+    },
+    /*
+     * @params: fullPath
+     */
+    getFileMetadata: function(success, fail, params) {
+        console.log("File.getFileMetadata");
+    },
+    /*
+     * @params: fullPath
+     */
+    getMetadata: function(success, fail, params) {
+        console.log("File.getMetadata");
+    },
+    /*
+     * @params: fullPath, metadataObject
+     */
+    setMetadata: function(success, fail, params) {
+        console.log("File.setMetadata");
+    },
+    /*
+     * @params: [fileName, enc]
+     */
+    readAsText: function(success, fail, params) {
+        console.log("File.readAsText");
+    },
+    /*
+     * @params: [srcPath, parent.fullPath, name]
+     */
+    moveTo: function(success, fail, params) {
+        console.log("File.moveTo");
+    },
+    /*
+     * @params: [srcPath, parent.fullPath, name]
+     */
+    copyTo: function(success, fail, params) {
+        console.log("File.copyTo");
+    },
+    /*
+     * @params: [fullPath]
+     */
+    remove: function(success, fail, params) {
+        console.log("File.remove");
+    },
+    /*
+     * @params: [fullPath]
+     */
+    getParent: function(success, fail, params) {
+        console.log("File.getParent");
+    },
+    /*
+     * @params: fileName
+     */
+    readAsDataURL: function(success, fail, params) {
+        console.log("File.readAsDataURL");
+    },
+    /*
+     * @params: fileName, text, position
+     */
+    write: function(success, fail, params) {
+        console.log("File.write");
+    },
+    /*
+     * @params: fileName, size
+     */
+    truncate: function(success, fail, params) {
+        console.log("File.truncate");
+    }
+};
+
+});
+
+// file: lib\bada\plugin\bada\FileTransfer.js
+define("cordova/plugin/bada/FileTransfer", function(require, exports, module) {
+module.exports = {
+    /*
+     * @params: filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode
+     */
+    upload: function(success, fail, params) {
+        console.log("FileTransfer.upload");
+    },
+    /*
+     * @params: source, target
+     */
+    download: function(success, fail, params) {
+        console.log("FileTransfer.download");
+    }
+};
+
+});
+
 // file: lib\bada\plugin\bada\NetworkStatus.js
 define("cordova/plugin/bada/NetworkStatus", function(require, exports, module) {
-var channel = require('cordova/channel');
+var channel = require('cordova/channel'),
+    Connection = require("cordova/plugin/Connection");
 
 // We can't tell if a cell connection is 2,3 or 4G.
 // We just know if it's connected and the signal strength
-// if it's roaming and the network name etc..so unless wifi we default to UNKNOWN
+// if it's roaming and the network name etc..so unless wifi we default to CELL_2G
+// if connected to cellular network
 
 module.exports = {
     getConnectionInfo: function(success, fail) {
-       var Connection = require("cordova/plugin/Connection");
-       var connectionType = Connection.NONE;
-       deviceapis.devicestatus.getPropertyValue(function(value) {
-               //console.log("Device WiFi network status: "+value);
-               if(value == "connected") {
-                   connectionType = Connection.WIFI;
-               }
-               channel.onCordovaConnectionReady.fire();
-               success(connectionType);
-           },
-           function(error) {
-                console.log(JSON.stringify(error));
-                fail();
-           } , {aspect: "WiFiNetwork", property: "networkStatus"}
-       );
-        //info.getPropertyValue(function(value) {
-        //console.log("Device Cellular network status: "+value);
-        //if(signalStrength > 10) {
-        //self.type = Connection.CELL_3G;
-        //}
-        //}, fail, {aspect: "CellularNetwork", property: "signalStrength"});
+        var connectionType = Connection.NONE;
+        var networkInfo = ["cellular", "wifi"]; // might be a better way to do this
+        var gotConnectionInfo = function() {
+            networkInfo.pop();
+            if(networkInfo.length === 0) {
+                channel.onCordovaConnectionReady.fire();
+                success(connectionType);
+            }
+        };
+        var error = function(e) {
+            console.log("Error "+e.message);
+            gotConnectionInfo();
+        };
+        deviceapis.devicestatus.getPropertyValue(function(value) {
+            console.log("Device Cellular network status: "+value);
+            if(connectionType === Connection.NONE) {
+                connectionType = Connection.CELL_2G;
+            }
+            gotConnectionInfo();
+        }, error, {aspect: "CellularNetwork", property: "signalStrength"});
+
+        deviceapis.devicestatus.getPropertyValue(function(value) {
+            console.log("Device WiFi network status: "+value);
+            if(value == "connected") {
+                connectionType = Connection.WIFI;
+            }
+            gotConnectionInfo();
+        }, error, {aspect: "WiFiNetwork", property: "networkStatus"});
     }
 };
 
@@ -3898,7 +4165,7 @@ Device.prototype.getInfo = function(success, fail, args) {
            me.platform = os_vendor + " " + os_name;
            me.version = os_version;
            me.uuid = uuid;
-           me.cordova = "1.7.0";
+           me.cordova = "1.8.0";
            success(me);
        }
    };
@@ -4207,6 +4474,177 @@ var exec = require('cordova/exec'),
 module.exports = compass;
 });
 
+// file: lib\common\plugin\console-via-logger.js
+define("cordova/plugin/console-via-logger", function(require, exports, module) {
+//------------------------------------------------------------------------------
+
+var logger = require("cordova/plugin/logger");
+var utils  = require("cordova/utils");
+
+//------------------------------------------------------------------------------
+// object that we're exporting
+//------------------------------------------------------------------------------
+var console = module.exports;
+
+//------------------------------------------------------------------------------
+// copy of the original console object
+//------------------------------------------------------------------------------
+var WinConsole = window.console;
+
+//------------------------------------------------------------------------------
+// whether to use the logger
+//------------------------------------------------------------------------------
+var UseLogger = false;
+
+//------------------------------------------------------------------------------
+// Timers
+//------------------------------------------------------------------------------
+var Timers = {};
+
+//------------------------------------------------------------------------------
+// used for unimplemented methods
+//------------------------------------------------------------------------------
+function noop() {}
+
+//------------------------------------------------------------------------------
+// used for unimplemented methods
+//------------------------------------------------------------------------------
+console.useLogger = function (value) {
+    if (arguments.length) UseLogger = !!value;
+
+    if (UseLogger) {
+        if (logger.useConsole()) {
+            throw new Error("console and logger are too intertwingly");
+        }
+    }
+
+    return UseLogger;
+};
+
+//------------------------------------------------------------------------------
+console.log = function() {
+    if (logger.useConsole()) return;
+    logger.log.apply(logger, [].slice.call(arguments));
+};
+
+//------------------------------------------------------------------------------
+console.error = function() {
+    if (logger.useConsole()) return;
+    logger.error.apply(logger, [].slice.call(arguments));
+};
+
+//------------------------------------------------------------------------------
+console.warn = function() {
+    if (logger.useConsole()) return;
+    logger.warn.apply(logger, [].slice.call(arguments));
+};
+
+//------------------------------------------------------------------------------
+console.info = function() {
+    if (logger.useConsole()) return;
+    logger.info.apply(logger, [].slice.call(arguments));
+};
+
+//------------------------------------------------------------------------------
+console.debug = function() {
+    if (logger.useConsole()) return;
+    logger.debug.apply(logger, [].slice.call(arguments));
+};
+
+//------------------------------------------------------------------------------
+console.assert = function(expression) {
+    if (expression) return;
+
+    var message = utils.vformat(arguments[1], [].slice.call(arguments, 2));
+    console.log("ASSERT: " + message);
+};
+
+//------------------------------------------------------------------------------
+console.clear = function() {};
+
+//------------------------------------------------------------------------------
+console.dir = function(object) {
+    console.log("%o", object);
+};
+
+//------------------------------------------------------------------------------
+console.dirxml = function(node) {
+    console.log(node.innerHTML);
+};
+
+//------------------------------------------------------------------------------
+console.trace = noop;
+
+//------------------------------------------------------------------------------
+console.group = console.log;
+
+//------------------------------------------------------------------------------
+console.groupCollapsed = console.log;
+
+//------------------------------------------------------------------------------
+console.groupEnd = noop;
+
+//------------------------------------------------------------------------------
+console.time = function(name) {
+    Timers[name] = new Date().valueOf();
+};
+
+//------------------------------------------------------------------------------
+console.timeEnd = function(name) {
+    var timeStart = Timers[name];
+    if (!timeStart) {
+        console.warn("unknown timer: " + name);
+        return;
+    }
+
+    var timeElapsed = new Date().valueOf() - timeStart;
+    console.log(name + ": " + timeElapsed + "ms");
+};
+
+//------------------------------------------------------------------------------
+console.timeStamp = noop;
+
+//------------------------------------------------------------------------------
+console.profile = noop;
+
+//------------------------------------------------------------------------------
+console.profileEnd = noop;
+
+//------------------------------------------------------------------------------
+console.count = noop;
+
+//------------------------------------------------------------------------------
+console.exception = console.log;
+
+//------------------------------------------------------------------------------
+console.table = function(data, columns) {
+    console.log("%o", data);
+};
+
+//------------------------------------------------------------------------------
+// return a new function that calls both functions passed as args
+//------------------------------------------------------------------------------
+function wrapperedOrigCall(orgFunc, newFunc) {
+    return function() {
+        var args = [].slice.call(arguments);
+        try { orgFunc.apply(WinConsole, args); } catch (e) {}
+        try { newFunc.apply(console,    args); } catch (e) {}
+    };
+}
+
+//------------------------------------------------------------------------------
+// For every function that exists in the original console object, that
+// also exists in the new console object, wrap the new console method
+// with one that calls both
+//------------------------------------------------------------------------------
+for (var key in console) {
+    if (typeof WinConsole[key] == "function") {
+        console[key] = wrapperedOrigCall(WinConsole[key], console[key]);
+    }
+}
+
+});
+
 // file: lib\common\plugin\contacts.js
 define("cordova/plugin/contacts", function(require, exports, module) {
 var exec = require('cordova/exec'),
@@ -4356,7 +4794,7 @@ var geolocation = {
                     velocity:p.velocity,
                     altitudeAccuracy:p.altitudeAccuracy
                 },
-                p.timestamp || new Date()
+                (p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date)
? p.timestamp : new Date(p.timestamp)))
             );
             geolocation.lastPosition = pos;
             successCallback(pos);
@@ -4440,7 +4878,7 @@ var geolocation = {
                     velocity:p.velocity,
                     altitudeAccuracy:p.altitudeAccuracy
                 },
-                p.timestamp || new Date()
+                (p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date)
? p.timestamp : new Date(p.timestamp)))
             );
             geolocation.lastPosition = pos;
             successCallback(pos);
@@ -4468,6 +4906,233 @@ module.exports = geolocation;
 
 });
 
+// file: lib\common\plugin\logger.js
+define("cordova/plugin/logger", function(require, exports, module) {
+//------------------------------------------------------------------------------
+// The logger module exports the following properties/functions:
+//
+// LOG                          - constant for the level LOG
+// ERROR                        - constant for the level ERROR
+// WARN                         - constant for the level WARN
+// INFO                         - constant for the level INFO
+// DEBUG                        - constant for the level DEBUG
+// logLevel()                   - returns current log level
+// logLevel(value)              - sets and returns a new log level
+// useConsole()                 - returns whether logger is using console
+// useConsole(value)            - sets and returns whether logger is using console
+// log(message,...)             - logs a message at level LOG
+// error(message,...)           - logs a message at level ERROR
+// warn(message,...)            - logs a message at level WARN
+// info(message,...)            - logs a message at level INFO
+// debug(message,...)           - logs a message at level DEBUG
+// logLevel(level,message,...)  - logs a message specified level
+//
+//------------------------------------------------------------------------------
+
+var logger = exports;
+
+var exec    = require('cordova/exec');
+var utils   = require('cordova/utils');
+
+var UseConsole   = true;
+var Queued       = [];
+var DeviceReady  = false;
+var CurrentLevel;
+
+/**
+ * Logging levels
+ */
+
+var Levels = [
+    "LOG",
+    "ERROR",
+    "WARN",
+    "INFO",
+    "DEBUG"
+];
+
+/*
+ * add the logging levels to the logger object and
+ * to a separate levelsMap object for testing
+ */
+
+var LevelsMap = {};
+for (var i=0; i<Levels.length; i++) {
+    var level = Levels[i];
+    LevelsMap[level] = i;
+    logger[level]    = level;
+}
+
+CurrentLevel = LevelsMap.WARN;
+
+/**
+ * Getter/Setter for the logging level
+ *
+ * Returns the current logging level.
+ *
+ * When a value is passed, sets the logging level to that value.
+ * The values should be one of the following constants:
+ *    logger.LOG
+ *    logger.ERROR
+ *    logger.WARN
+ *    logger.INFO
+ *    logger.DEBUG
+ *
+ * The value used determines which messages get printed.  The logging
+ * values above are in order, and only messages logged at the logging
+ * level or above will actually be displayed to the user.  Eg, the
+ * default level is WARN, so only messages logged with LOG, ERROR, or
+ * WARN will be displayed; INFO and DEBUG messages will be ignored.
+ */
+logger.level = function (value) {
+    if (arguments.length) {
+        if (LevelsMap[value] === null) {
+            throw new Error("invalid logging level: " + value);
+        }
+        CurrentLevel = LevelsMap[value];
+    }
+
+    return Levels[CurrentLevel];
+};
+
+/**
+ * Getter/Setter for the useConsole functionality
+ *
+ * When useConsole is true, the logger will log via the
+ * browser 'console' object.  Otherwise, it will use the
+ * native Logger plugin.
+ */
+logger.useConsole = function (value) {
+    if (arguments.length) UseConsole = !!value;
+
+    if (UseConsole) {
+        if (typeof console == "undefined") {
+            throw new Error("global console object is not defined");
+        }
+
+        if (typeof console.log != "function") {
+            throw new Error("global console object does not have a log function");
+        }
+
+        if (typeof console.useLogger == "function") {
+            if (console.useLogger()) {
+                throw new Error("console and logger are too intertwingly");
+            }
+        }
+    }
+
+    return UseConsole;
+};
+
+/**
+ * Logs a message at the LOG level.
+ *
+ * Parameters passed after message are used applied to
+ * the message with utils.format()
+ */
+logger.log   = function(message) { logWithArgs("LOG",   arguments); };
+
+/**
+ * Logs a message at the ERROR level.
+ *
+ * Parameters passed after message are used applied to
+ * the message with utils.format()
+ */
+logger.error = function(message) { logWithArgs("ERROR", arguments); };
+
+/**
+ * Logs a message at the WARN level.
+ *
+ * Parameters passed after message are used applied to
+ * the message with utils.format()
+ */
+logger.warn  = function(message) { logWithArgs("WARN",  arguments); };
+
+/**
+ * Logs a message at the INFO level.
+ *
+ * Parameters passed after message are used applied to
+ * the message with utils.format()
+ */
+logger.info  = function(message) { logWithArgs("INFO",  arguments); };
+
+/**
+ * Logs a message at the DEBUG level.
+ *
+ * Parameters passed after message are used applied to
+ * the message with utils.format()
+ */
+logger.debug = function(message) { logWithArgs("DEBUG", arguments); };
+
+// log at the specified level with args
+function logWithArgs(level, args) {
+    args = [level].concat([].slice.call(args));
+    logger.logLevel.apply(logger, args);
+}
+
+/**
+ * Logs a message at the specified level.
+ *
+ * Parameters passed after message are used applied to
+ * the message with utils.format()
+ */
+logger.logLevel = function(level, message /* , ... */) {
+    // format the message with the parameters
+    var formatArgs = [].slice.call(arguments, 2);
+    message    = utils.vformat(message, formatArgs);
+
+    if (LevelsMap[level] === null) {
+        throw new Error("invalid logging level: " + level);
+    }
+
+    if (LevelsMap[level] > CurrentLevel) return;
+
+    // queue the message if not yet at deviceready
+    if (!DeviceReady && !UseConsole) {
+        Queued.push([level, message]);
+        return;
+    }
+
+    // if not using the console, use the native logger
+    if (!UseConsole) {
+        exec(null, null, "Logger", "logLevel", [level, message]);
+        return;
+    }
+
+    // make sure console is not using logger
+    if (console.__usingCordovaLogger) {
+        throw new Error("console and logger are too intertwingly");
+    }
+
+    // log to the console
+    switch (level) {
+        case logger.LOG:   console.log(message); break;
+        case logger.ERROR: console.log("ERROR: " + message); break;
+        case logger.WARN:  console.log("WARN: "  + message); break;
+        case logger.INFO:  console.log("INFO: "  + message); break;
+        case logger.DEBUG: console.log("DEBUG: " + message); break;
+    }
+};
+
+// when deviceready fires, log queued messages
+logger.__onDeviceReady = function() {
+    if (DeviceReady) return;
+
+    DeviceReady = true;
+
+    for (var i=0; i<Queued.length; i++) {
+        var messageArgs = Queued[i];
+        logger.logLevel(messageArgs[0], messageArgs[1]);
+    }
+
+    Queued = null;
+};
+
+// add a deviceready event to log queued messages
+document.addEventListener("deviceready", logger.__onDeviceReady, false);
+
+});
+
 // file: lib\common\plugin\network.js
 define("cordova/plugin/network", function(require, exports, module) {
 var exec = require('cordova/exec'),
@@ -4656,10 +5321,16 @@ module.exports = function(uri, successCallback, errorCallback) {
             errorCallback(new FileError(error));
         }
     };
+    // sanity check for 'not:valid:filename'
+    if(!uri || uri.split(":").length > 2) {
+        setTimeout( function() {
+            fail(FileError.ENCODING_ERR);
+        },0);
+        return;
+    }
     // if successful, return either a file or directory entry
     var success = function(entry) {
         var result;
-
         if (entry) {
             if (typeof successCallback === 'function') {
                 // create appropriate Entry object
@@ -4797,6 +5468,16 @@ utils.alert = function(msg) {
 /**
  * Formats a string and arguments following it ala sprintf()
  *
+ * see utils.vformat() for more information
+ */
+utils.format = function(formatString /* ,... */) {
+    var args = [].slice.call(arguments, 1);
+    return utils.vformat(formatString, args);
+};
+
+/**
+ * Formats a string and arguments following it ala vsprintf()
+ *
  * format chars:
  *   %j - format arg as JSON
  *   %o - format arg as JSON
@@ -4808,14 +5489,14 @@ utils.alert = function(msg) {
  * for rationale, see FireBug's Console API:
  *    http://getfirebug.com/wiki/index.php/Console_API
  */
-utils.format = function(formatString /* ,... */) {
+utils.vformat = function(formatString, args) {
     if (formatString === null || formatString === undefined) return "";
     if (arguments.length == 1) return formatString.toString();
+    if (typeof formatString != "string") return formatString.toString();
 
     var pattern = /(.*?)%(.)(.*)/;
-    var rest    = formatString.toString();
+    var rest    = formatString;
     var result  = [];
-    var args    = [].slice.call(arguments,1);
 
     while (args.length) {
         var arg   = args.shift();
@@ -4857,13 +5538,20 @@ function UUIDcreatePart(length) {
 //------------------------------------------------------------------------------
 function formatted(object, formatChar) {
 
-    switch(formatChar) {
-        case 'j':
-        case 'o': return JSON.stringify(object);
-        case 'c': return '';
+    try {
+        switch(formatChar) {
+            case 'j':
+            case 'o': return JSON.stringify(object);
+            case 'c': return '';
+        }
+    }
+    catch (e) {
+        return "error JSON.stringify()ing argument: " + e;
     }
 
-    if (null === object) return Object.prototype.toString.call(object);
+    if ((object === null) || (object === undefined)) {
+        return Object.prototype.toString.call(object);
+    }
 
     return object.toString();
 }
@@ -4908,7 +5596,7 @@ window.cordova = require('cordova');
                     // Fire onDeviceReady event once all constructors have run and
                     // cordova info has been received from native side.
                     channel.join(function() {
-                        channel.onDeviceReady.fire();
+                        require('cordova').fireDocumentEvent('deviceready');
                     }, channel.deviceReadyChannelsArray);
 
                 }, [ channel.onDOMContentLoaded, channel.onNativeReady ]);
@@ -4926,6 +5614,7 @@ window.cordova = require('cordova');
     }
 
 }(window));
+
 // file: lib\scripts\bootstrap-bada.js
 require('cordova/channel').onNativeReady.fire();
 


Mime
View raw message