Example #1
0
/**
 * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
 * phone, etc.
 * @constructor
 */
function Device() {
    this.available = false;
    this.platform = null;
    this.version = null;
    this.uuid = null;
    this.cordova = null;
    this.model = null;

    var me = this;

    channel.onCordovaReady.subscribe(function() {
        me.getInfo(function(info) {
            var buildLabel = info.cordova;
            if (buildLabel != CORDOVA_JS_BUILD_LABEL) {
                buildLabel += ' JS=' + CORDOVA_JS_BUILD_LABEL;
            }
            me.available = true;
            me.platform = info.platform;
            me.version = info.version;
            me.uuid = info.uuid;
            me.cordova = buildLabel;
            me.model = info.model;
            channel.onCordovaInfoReady.fire();
        },function(e) {
            me.available = false;
            utils.alert("[ERROR] Error initializing Cordova: " + e);
        });
    });
}
Example #2
0
    bootstrap: function() {
        var channel = require('cordova/channel'),
            cordova = require('cordova'),
            exec = require('cordova/exec'),
            modulemapper = require('cordova/modulemapper');

        // Get the shared secret needed to use the bridge.
        exec.init();

        // TODO: Extract this as a proper plugin.
        modulemapper.clobbers('cordova/plugin/android/app', 'navigator.app');

        // Inject a listener for the backbutton on the document.
        var backButtonChannel = cordova.addDocumentEventHandler('backbutton');
        backButtonChannel.onHasSubscribersChange = function() {
            // If we just attached the first handler or detached the last handler,
            // let native know we need to override the back button.
            exec(null, null, "App", "overrideBackbutton", [this.numHandlers == 1]);
        };

        // Add hardware MENU and SEARCH button handlers
        cordova.addDocumentEventHandler('menubutton');
        cordova.addDocumentEventHandler('searchbutton');

        // Let native code know we are all done on the JS side.
        // Native code will then un-hide the WebView.
        channel.onCordovaReady.subscribe(function() {
            exec(null, null, "App", "show", []);
        });
    }
Example #3
0
                channel.join(function() {
                    var builder = require('cordova/builder'),
                        base = require('cordova/common'),
                        platform = require('cordova/platform');

                    // Drop the common globals into the window object, but be nice and don't overwrite anything.
                    builder.buildIntoButDoNotClobber(base.defaults, context);
                    builder.buildIntoAndClobber(base.clobbers, context);
                    builder.buildIntoAndMerge(base.merges, context);

                    builder.buildIntoButDoNotClobber(platform.defaults, context);
                    builder.buildIntoAndClobber(platform.clobbers, context);
                    builder.buildIntoAndMerge(platform.merges, context);

                    // Call the platform-specific initialization
                    platform.initialize();

                    // Fire event to notify that all objects are created
                    channel.onCordovaReady.fire();

                    // Fire onDeviceReady event once all constructors have run and
                    // cordova info has been received from native side.
                    channel.join(function() {
                        require('cordova').fireDocumentEvent('deviceready');
                    }, channel.deviceReadyChannelsArray);

                }, [ channel.onDOMContentLoaded, channel.onNativeReady ]);
Example #4
0
function Device() {

    this.platform = null;
    this.version = null;
    this.name = null;
    this.uuid = null;
    this.cordova = null;

    var me = this;

    channel.onCordovaReady.subscribeOnce(function() {
       me.getInfo(function (device) {
           me.platform = device.platform;
           me.version  = device.version;
           me.name     = device.name;
           me.uuid     = device.uuid;
           me.cordova  = device.cordova;

           channel.onCordovaInfoReady.fire();
           //console.log("CordovaInfoReady "+JSON.stringify(device));
       },
       function (e) {
           me.available = false;
           console.log("error initializing cordova: " + e);
       });
    });
}
cordova.define("cordova-hot-code-push-local-dev-addon.chcpLocalDev", function(require, exports, module) { var exec = require('cordova/exec'),
  channel = require('cordova/channel'),

  // Reference name for the plugin
  PLUGIN_NAME = 'HotCodePushLocalDevMode',

  // Plugin methods on the native side that can be called from JavaScript
  pluginNativeMethod = {
    INITIALIZE: 'jsInitPlugin'
  };

// Called when Cordova is ready for work.
// Here we will send default callback to the native side through which it will send to us different events.
channel.onCordovaReady.subscribe(function() {
  exec(nativeCallback, null, PLUGIN_NAME, pluginNativeMethod.INITIALIZE, []);
});

/**
 * Method is called when native side detects new release and need to trigger the update.
 *
 * @param {String} message from the native side
 */
function nativeCallback(msg) {
  chcp.fetchUpdate();
}

});
/**
 * This represents the app, and provides properties for inspecting the app info.
 * phone, etc.
 * @constructor
 */
function AppInfo() {
    this.available = false;
    this.name = null;
    this.version = null;
    this.build = null;
    this.identifier = null;
    this.compileDate = null;
    this.isHardwareAccelerated = null;
    this.isDebuggable = null;

    var me = this;

    channel.onCordovaReady.subscribe(function() {
        me.getInfo(function(info) {
            me.available = true;
            me.name = info.name;
            me.version = info.version;
            me.identifier = info.identifier;
            me.build = info.build;
            me.compileDate = info.compileDate;
            me.isHardwareAccelerated = info.isHardwareAccelerated;
            me.isDebuggable = info.isDebuggable;
            channel.onAppInfoReady.fire();
        },function(e) {
            me.available = false;
            utils.alert("[ERROR] Error initializing Cordova: " + e);
        });
    });
}
Example #7
0
/**
 * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
 * phone, etc.
 * @constructor
 */
function Device() {

    this.available = false;
    this.platform = null;
    this.version = null;
    this.uuid = null;
    this.cordova = null;
    this.model = null;

    var me = this;
    channel.onCordovaReady.subscribe(function() {
        me.getInfo(function(info) {
            //ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js
            //TODO: CB-5105 native implementations should not return info.cordova
            var buildLabel = cordova.version;
            me.available = true;
            me.platform = info.platform;
            me.version = info.version;
            me.uuid = info.uuid;
            me.cordova = buildLabel;
            me.model = info.model;
            channel.onCordovaInfoReady.fire();
        },function(e) {
            me.available = false;
            utils.alert("[ERROR] Error initializing Cordova: " + e);
        });
    });
}
Example #8
0
                channel.join(function() {
                    var builder = require('cordova/builder'),
                        base = require('cordova/common'),
                        platform = require('cordova/platform');

                    // Drop the common globals into the window object, but be nice and don't overwrite anything.
                    builder.build(base.objects).intoButDontClobber(window);

                    // Drop the platform-specific globals into the window object and do it like a honey badger does it.
                    builder.build(platform.objects).intoAndClobberTheFOutOf(window);

                    // Call the platform-specific initialization
                    platform.initialize();

                    // Fire event to notify that all objects are created
                    channel.onCordovaReady.fire();

                    // Fire onDeviceReady event once all constructors have run and 
                    // cordova info has been received from native side.
                    channel.join(function() {
                        channel.onDeviceReady.fire();
                        
                        // Fire the onresume event, since first one happens before JavaScript is loaded
                        channel.onResume.fire();
                    }, deviceReadyChannelsArray);
                    
                }, [ channel.onDOMContentLoaded, channel.onNativeReady ]);
Example #9
0
function Device() {
    this.platform = null;
    this.version = null;
    this.name = null;
    this.uuid = null;
    this.cordova = null;

    var me = this;

    channel.onCordovaReady.subscribe(function() {
       me.getDeviceInfo(function (device) {
           me.platform = device.platform;
           me.version  = device.version;
           me.name     = device.name;
           me.uuid     = device.uuid;
           me.cordova  = device.cordova;

           channel.onCordovaInfoReady.fire();
       },
       function (e) {
           me.available = false;
           utils.alert("error initializing cordova: " + e);
       });
    });
}
Example #10
0
/**
 * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
 * phone, etc.
 * @constructor
 */
function Device() {
    this.available = false;
    this.platform = null;
    this.version = null;
    this.name = null;
    this.uuid = null;
    this.cordova = null;

    var me = this;

    channel.onCordovaReady.subscribeOnce(function() {
        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;
            channel.onCordovaInfoReady.fire();
        },function(e) {
            me.available = false;
            utils.alert("[ERROR] Error initializing Cordova: " + e);
        });
    });
}
Example #11
0
exports.fgInit = function() {
  // Add a deviceready listener that initializes the Chrome wrapper.
  channel.onCordovaReady.subscribe(function() {
    // Delay bootstrap until all deviceready event dependancies fire, minus DOMContentLoaded, since that one is purposely being blocked by bootstrap
    // We do this delay so that plugins have a chance to initialize using the bridge before we load the chrome app background scripts/event page
    var channelsToWaitFor = channel.deviceReadyChannelsArray.filter(function(c) { return c.type !== 'onDOMContentLoaded'; });
    channel.join(function() {
      // If background app plugin is included, handle event to switch from
      // background execution
      document.addEventListener('resume', function() {
        if (backgroundapp.resumeType == 'normal-launch') {
          fireOnLaunched();
        }
      });

      // Undo the clobber of window.open by InAppBrowser
      restoreWindowOpen(exports.fgWindow);

      // Assigning innerHTML here has the side-effect of removing the
      // chrome-content-loaded script tag. Removing it is required so that the
      // page re-writting logic does not try and re-evaluate it.
      document.body.innerHTML = '<iframe src="chromebgpage.html" style="display:none">';

      exports.eventIframe = document.body.firstChild;
    }, channelsToWaitFor);
  });
};
                channel.join(function() {
                    var builder = require('cordova/builder'),
                        base = require('cordova/common'),
                        platform = require('cordova/platform');

                    // Drop the common globals into the window object, but be nice and don't overwrite anything.
                    builder.build(base.objects).intoButDontClobber(window);

                    // Drop the platform-specific globals into the window object
                    // and clobber any existing object.
                    builder.build(platform.objects).intoAndClobber(window);

                    // Merge the platform-specific overrides/enhancements into
                    // the window object.
                    if (typeof platform.merges !== 'undefined') {
                        builder.build(platform.merges).intoAndMerge(window);
                    }

                    // Call the platform-specific initialization
                    platform.initialize();

                    // Fire event to notify that all objects are created
                    channel.onCordovaReady.fire();

                    // Fire onDeviceReady event once all constructors have run and
                    // cordova info has been received from native side.
                    channel.join(function() {
                        require('cordova').fireDocumentEvent('deviceready');
                    }, channel.deviceReadyChannelsArray);

                }, [ channel.onDOMContentLoaded, channel.onNativeReady ]);
Example #13
0
    it("should fire exec on first-run after CordovaReady fires", function() {
        exec.reset();

        network = require('cordova/plugin/network');
        channel.onCordovaReady.fire();

        expect(exec).toHaveBeenCalledWith(jasmine.any(Function), jasmine.any(Function), "NetworkStatus", "getConnectionInfo", []);
    });
function CordovaPluginPanasonicToughpad() {
    this.available = false;

    var me = this;
    channel.onCordovaReady.subscribe(function() {
        me.available = true;
    });
}
Example #15
0
    bootstrap: function() {
        var channel = require('cordova/channel'),
            cordova = require('cordova'),
            exec = require('cordova/exec'),
            modulemapper = require('cordova/modulemapper');

        // Get the shared secret needed to use the bridge.
        exec.init();

        // TODO: Extract this as a proper plugin.
        modulemapper.clobbers('cordova/plugin/android/app', 'navigator.app');

        var APP_PLUGIN_NAME = Number(cordova.platformVersion.split('.')[0]) >= 4 ? 'CoreAndroid' : 'App';

        // Inject a listener for the backbutton on the document.
        var backButtonChannel = cordova.addDocumentEventHandler('backbutton');
        backButtonChannel.onHasSubscribersChange = function() {
            // If we just attached the first handler or detached the last handler,
            // let native know we need to override the back button.
            exec(null, null, APP_PLUGIN_NAME, "overrideBackbutton", [this.numHandlers == 1]);
        };

        // Add hardware MENU and SEARCH button handlers
        cordova.addDocumentEventHandler('menubutton');
        cordova.addDocumentEventHandler('searchbutton');

        function bindButtonChannel(buttonName) {
            // generic button bind used for volumeup/volumedown buttons
            var volumeButtonChannel = cordova.addDocumentEventHandler(buttonName + 'button');
            volumeButtonChannel.onHasSubscribersChange = function() {
                exec(null, null, APP_PLUGIN_NAME, "overrideButton", [buttonName, this.numHandlers == 1]);
            };
        }
        // Inject a listener for the volume buttons on the document.
        bindButtonChannel('volumeup');
        bindButtonChannel('volumedown');

        // The resume event is not "sticky", but it is possible that the event
        // will contain the result of a plugin call. We need to ensure that the
        // plugin result is delivered even after the event is fired (CB-10498)
        var cordovaAddEventListener = document.addEventListener;

        document.addEventListener = function(evt, handler, capture) {
            cordovaAddEventListener(evt, handler, capture);

            if (evt === 'resume' && lastResumeEvent) {
                handler(lastResumeEvent);
            }
        };

        // Let native code know we are all done on the JS side.
        // Native code will then un-hide the WebView.
        channel.onCordovaReady.subscribe(function() {
            exec(onMessageFromNative, null, APP_PLUGIN_NAME, 'messageChannel', []);
            exec(null, null, APP_PLUGIN_NAME, "show", []);
        });
    }
Example #16
0
 addConstructor: function(func) {
     channel.onCordovaReady.subscribe(function() {
         try {
             func();
         } catch(e) {
             console.log("Failed to run constructor: " + e);
         }
     });
 }
Example #17
0
exports.delayDeviceReadyUntil = function(func) {
  channel.onCordovaReady.subscribe(function() {
    var newChannel = channel.createSticky('cca-delay-device-ready');
    channel.deviceReadyChannelsArray.push(newChannel);
    func(function done() {
      newChannel.fire();
    });
  });
};
Example #18
0
exports.runAtStartUp = function(func) {
  if (isChromeApp) {
    // TODO: Implement done() call back for chrome app case.
    var mobile = require('cordova-plugin-chrome-apps-bootstrap.mobile.impl');
    mobile.onBackgroundPageLoaded.subscribe(func);
  } else {
    channel.onCordovaReady.subscribe(func);
  }
};
function CardFlight() {
  this.cordova = null;
  this.config = null;

  var self = this;

  channel.onCordovaReady.subscribe(function() {
    self.initialize();
  });
}
Example #20
0
qw_msger.prototype.setEventCallback = function(callback) {
    if (typeof callback != "function") {
        console.log("qw_msger.setEventCallback failure: callback parameter not a function");
        return ;
    }

    channel.onCordovaReady.subscribe(function () {
        exec(callback, emptyfunc, "qw_msger", "setEventCallback", []);
    });
};
Example #21
0
/**
 * fire
 *
 * @param {String} event Event name
 * @param {String} data Success or error data
 */
function fire(event, data) {
	var channel = require('cordova/channel');
	var cordova = require('cordova');
	var payload = {};

	channel.onCordovaReady.subscribe(function() {
		var name = 'open.' + event;
		var prop = (event === 'error') ? event : 'data';
		payload[prop] = data;
		cordova.fireDocumentEvent(name, payload);
	});
}
Example #22
0
/**
 * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
 * phone, etc.
 * @constructor
 */
function Hello() {
    var me = this;

    channel.onCordovaReady.subscribe(function() {
        me.getInfo(function(info) {
            me.msg = info.msg;
            me.error = "no error";
        },function(e) {
            me.error = e;
        });
    });
}
Example #23
0
     //   console.log(JSON.stringify(config));
       function CoocaaOSApi(){
            var thiz = this;
             channel.onCordovaReady.subscribe(function(){
                thiz.waitForCoocaaOSInitReady(function(message){
                    console.log('success CoocaaOSInitReady ' +message);
                    channel.onCoocaaOsInitReady.fire();
                 },function(message){
                    console.log('error : ' + message);

                   });
             });
       }
function CardFlight() {
    this.available = false;
    this.platform = null;
    this.cordova = null;
    this.config = null;

    var _this = this;

    channel.onCordovaReady.subscribe(function() {
      // ADD INITIALIZATION HERE
    });
}
Example #25
0
/**
 * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
 * phone, etc.
 * @constructor
 */
function Device() {
    this.available = false;
    this.platform = null;
    this.version = null;
    this.uuid = null;
    this.cordova = null;
    this.model = null;
    this.manufacturer = null;
    this.isVirtual = null;
    this.serial = null;

    this.appversion = null;
    this.appname = null;

    this.isTablet = null;
    this.has3DTouch = null;

    this.accessibility = null;

    var me = this;

    channel.onCordovaReady.subscribe(function() {
        me.getInfo(function(info) {
            //ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js
            //TODO: CB-5105 native implementations should not return info.cordova
            var buildLabel = cordova.version;
            me.available = true;
            me.platform = info.platform;
            me.version = info.version;
            me.uuid = info.uuid;
            me.cordova = buildLabel;
            me.model = info.model;
            me.isVirtual = info.isVirtual;
            me.manufacturer = info.manufacturer || 'unknown';
            me.arePlayservicesAvailable = info.arePlayservicesAvailable || false;
            me.serial = info.serial || 'unknown';

            me.appversion = info.appversion;
            me.appname = info.appname;

            me.isTablet = info.isTablet || false;
            me.has3DTouch = info.has3DTouch || false;
            me.biometricType = info.biometricType || "unknown";

            me.accessibility = info.accessibility || { textSizeAdjustment: 100 };

            channel.onCordovaInfoReady.fire();
        },function(e) {
            me.available = false;
            utils.alert("[ERROR] Error initializing Cordova: " + e);
        });
    });
}
/**
 * Constructor
 **/
function MobilogicsScanner () {
  this.available = false;
  var me = this;

  channel.onCordovaReady.subscribe(function() {
    me.start(function(info) {
               me.available = true;
               channel.onCordovaInfoReady.fire();
             },function(e) {
               me.available = false;
               utils.alert("[ERROR] Error initializing Cordova: " + e);
             });
  });
}
Example #27
0
function ChromeLauncher() {
	
	var self = this;
	this.isInstalled = false;
	
    channel.onCordovaReady.subscribe(function() {
		self.checkInstall(function(result) {
			self.isInstalled = true;
            channel.onCordovaInfoReady.fire();
		}, function() {
			self.isInstalled = false;
            channel.onCordovaInfoReady.fire();
		});
	});
}
Example #28
0
channel.join(function() {
    
    platform.initialize && platform.initialize();

    // Fire event to notify that all objects are created
    channel.onCordovaReady.fire();

    // Fire onDeviceReady event once page has fully loaded, all
    // constructors have run and cordova info has been received from native
    // side.
    channel.join(function() {
        require('cordova').fireDocumentEvent('deviceready');
    }, channel.deviceReadyChannelsArray);

}, platformInitChannelsArray);
Example #29
0
exports.boot = function() {
  // Add a deviceready listener that initializes the Chrome wrapper.
  channel.onCordovaReady.subscribe(function() {
    // Delay bootstrap until all deviceready event dependancies fire, minus DOMContentLoaded, since that one is purposely being blocked by bootstrap
    // We do this delay so that plugins have a chance to initialize using the bridge before we load the chrome app background scripts/event page
    var channelsToWaitFor = channel.deviceReadyChannelsArray.filter(function(c) { return c.type !== 'onDOMContentLoaded'; });
    channel.join(function() {
      // Assigning innerHTML here has the side-effect of removing the
      // chrome-content-loaded script tag. Removing it is required so that the
      // page re-writting logic does not try and re-evaluate it.
      document.body.innerHTML = '<iframe src="chromebgpage.html" style="display:none">';

      exports.eventIframe = document.body.firstChild;
    }, channelsToWaitFor);
  });
};
Example #30
0
(function() {
    var runPlugin =  function() {
      cordova.exec(function(result){
          window.isTablet = !!result;
      }, function(){
          console.error("Error calling IsTablet plugin");
      }, 'IsTablet', 'isTabletDevice', []);
    };
    var exec = require('cordova/exec');
    (function(){
      runPlugin();
    })();
    var channel = require("cordova/channel");
    // have to wait until cordova is ready, because windows proxy js files are not pre-loaded
    channel.onCordovaReady.subscribe(runPlugin);
})();