Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
65
gaia/tools/extensions/desktop-helper/content/data/ffos_runtime.js
Executable file
65
gaia/tools/extensions/desktop-helper/content/data/ffos_runtime.js
Executable file
|
|
@ -0,0 +1,65 @@
|
|||
FFOS_RUNTIME = {
|
||||
|
||||
/**
|
||||
* Emulates a dom request
|
||||
* Returns an object and calls it's onsuccess handler.
|
||||
*/
|
||||
domRequest: function(result, timeout) {
|
||||
timeout = timeout || 1000;
|
||||
|
||||
return function() {
|
||||
var request = { result: result };
|
||||
|
||||
setTimeout(function() {
|
||||
if (request.onsuccess) {
|
||||
request.onsuccess();
|
||||
}
|
||||
}, timeout);
|
||||
|
||||
return request;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* This is so we have a single entry-point for the APP window
|
||||
* This is needed as the interface to window may be changing soon
|
||||
*/
|
||||
getAppWindow: function(callback) {
|
||||
callback(window);
|
||||
},
|
||||
|
||||
/**
|
||||
* Proxies console.log statements to the app window
|
||||
*/
|
||||
debug: function() {
|
||||
var args = Array.slice(arguments);
|
||||
|
||||
this.getAppWindow(function(win) {
|
||||
win.console.log.apply(win.console, args);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a navigator shim on the window
|
||||
* @param {String} property name.
|
||||
* @param {Object} property definition.
|
||||
* @param {Boolean} if true, makes a navigator setter for this object. Useful for testing.
|
||||
*/
|
||||
makeNavigatorShim: function(property, definition, makeSetter) {
|
||||
try {
|
||||
window.navigator.__defineGetter__(property, function() {
|
||||
return definition;
|
||||
});
|
||||
|
||||
if (makeSetter) {
|
||||
window.navigator.__defineSetter__(property, function(prop) {
|
||||
definition = prop;
|
||||
});
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
alert('Error intializing shim (' + property + '): ' + e);
|
||||
}
|
||||
}
|
||||
};
|
||||
var debug = FFOS_RUNTIME.debug;
|
||||
34
gaia/tools/extensions/desktop-helper/content/data/lib/bluetooth.js
Executable file
34
gaia/tools/extensions/desktop-helper/content/data/lib/bluetooth.js
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
!function() {
|
||||
|
||||
function debug(str) {
|
||||
//dump('Bluetooth : ' + str + '\n');
|
||||
}
|
||||
|
||||
function MockBluetoothRequest() {
|
||||
}
|
||||
|
||||
MockBluetoothRequest.prototype = {
|
||||
};
|
||||
|
||||
FFOS_RUNTIME.makeNavigatorShim('mozBluetooth', {
|
||||
enabled: true,
|
||||
addEventListener: function(type, callback, bubble) {},
|
||||
onenabled: function(event) {},
|
||||
ondisabled: function(event) {},
|
||||
onadapteradded: function() {
|
||||
debug('onadapteradded');
|
||||
},
|
||||
getDefaultAdapter: FFOS_RUNTIME.domRequest({
|
||||
ondevicefound: function() {},
|
||||
setDiscoverable: function() {},
|
||||
getPairedDevices: FFOS_RUNTIME.domRequest([]),
|
||||
startDiscovery: FFOS_RUNTIME.domRequest(),
|
||||
name: 'I like blue',
|
||||
setName: FFOS_RUNTIME.domRequest(),
|
||||
getConnectedDevices: FFOS_RUNTIME.domRequest()
|
||||
}),
|
||||
isConnected: function() {
|
||||
debug('isConnected');
|
||||
}
|
||||
});
|
||||
}();
|
||||
88
gaia/tools/extensions/desktop-helper/content/data/lib/cameras.js
Executable file
88
gaia/tools/extensions/desktop-helper/content/data/lib/cameras.js
Executable file
|
|
@ -0,0 +1,88 @@
|
|||
!function() {
|
||||
|
||||
var CameraManager = {
|
||||
|
||||
// The camera stream
|
||||
stream: false,
|
||||
|
||||
capabilities: {
|
||||
focusModes: '',
|
||||
pictureSizes: [{
|
||||
width: 600,
|
||||
height: 600
|
||||
}],
|
||||
previewSizes: [{
|
||||
width: 600,
|
||||
height: 600
|
||||
}],
|
||||
recorderProfiles: {
|
||||
cif: {
|
||||
video: {
|
||||
width: 600,
|
||||
height: 600
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getListOfCameras: function() {
|
||||
console.log('mozCamera.getListOfCameras');
|
||||
return [this];
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets a camera
|
||||
*/
|
||||
getCamera: function(options, callback) {
|
||||
console.log('mozCamera.getCamera');
|
||||
|
||||
navigator.mozGetUserMedia({video: true},
|
||||
function(stream) {
|
||||
this.stream = stream;
|
||||
callback(this);
|
||||
this.onPreviewStateChange('started');
|
||||
}.bind(this),
|
||||
function() {
|
||||
console.log('Could not initialize camera.');
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
getPreviewStream: function(config, callback) {
|
||||
console.log('mozCamera.getPreviewStream');
|
||||
callback(this.stream);
|
||||
},
|
||||
|
||||
getPreviewStreamVideoMode: function(config, callback) {
|
||||
console.log('mozCamera.getPreviewStreamVideoMode');
|
||||
callback(this.stream);
|
||||
},
|
||||
|
||||
resumePreview: function() {
|
||||
console.log('mozCamera.resumePreview');
|
||||
},
|
||||
|
||||
autoFocus: function() {
|
||||
console.log('mozCamera.autoFocus');
|
||||
},
|
||||
|
||||
takePicture: function(config, onSuccess, onError) {
|
||||
console.log('mozCamera.takePicture');
|
||||
var cnvs = document.createElement('canvas');
|
||||
|
||||
cnvs.width = config.pictureSize.width;
|
||||
cnvs.height = config.pictureSize.height;
|
||||
var ctx = cnvs.getContext('2d');
|
||||
ctx.drawImage(window.document.querySelector('video'), 0, 0, cnvs.width, cnvs.height);
|
||||
cnvs.toBlob(function(blob) {
|
||||
onSuccess(blob);
|
||||
}, 'image/jpeg');
|
||||
},
|
||||
|
||||
release: function() {
|
||||
console.log('mozCamera.release');
|
||||
}
|
||||
};
|
||||
|
||||
FFOS_RUNTIME.makeNavigatorShim('mozCameras', CameraManager);
|
||||
}();
|
||||
103
gaia/tools/extensions/desktop-helper/content/data/lib/icc_manager.js
Executable file
103
gaia/tools/extensions/desktop-helper/content/data/lib/icc_manager.js
Executable file
|
|
@ -0,0 +1,103 @@
|
|||
!function() {
|
||||
|
||||
function debug(str) {
|
||||
//dump('mozIccManager: ' + str + '\n');
|
||||
}
|
||||
|
||||
var iccs = {
|
||||
111: {
|
||||
_retryCount: 3,
|
||||
cardState: 'ready',
|
||||
iccInfo: {
|
||||
iccid: true,
|
||||
msisdn: '5555555555'
|
||||
},
|
||||
setCardLock: function() {
|
||||
debug('setCardLock');
|
||||
},
|
||||
getCardLock: FFOS_RUNTIME.domRequest({ enabled: false }),
|
||||
getCardLockRetryCount: function(type) {
|
||||
var request = {};
|
||||
setTimeout(function() {
|
||||
request.result = {
|
||||
retryCount: this._retryCount
|
||||
};
|
||||
request.onsuccess && request.onsuccess();
|
||||
}.bind(this));
|
||||
return request;
|
||||
},
|
||||
unlockCardLock: function() {
|
||||
// simulate invalid input
|
||||
if (this._retryCount > 1) {
|
||||
var request = {};
|
||||
setTimeout(function() {
|
||||
request.error = {
|
||||
retryCount: --this._retryCount,
|
||||
lockType: 'pin'
|
||||
};
|
||||
request.onerror && request.onerror();
|
||||
}.bind(this), 200);
|
||||
return request;
|
||||
}
|
||||
this.cardState = 'ready';
|
||||
return FFOS_RUNTIME.domRequest()();
|
||||
},
|
||||
addEventListener: function() {
|
||||
debug('addEventListener');
|
||||
},
|
||||
removeEventListener: function() {
|
||||
debug('removeEventListener');
|
||||
},
|
||||
},
|
||||
222: {
|
||||
_retryCount: 3,
|
||||
cardState: 'ready',
|
||||
iccInfo: {
|
||||
iccid: true
|
||||
},
|
||||
setCardLock: function() {
|
||||
debug('setCardLock');
|
||||
},
|
||||
getCardLock: FFOS_RUNTIME.domRequest({ enabled: false }),
|
||||
getCardLockRetryCount: function(type) {
|
||||
var request = {};
|
||||
setTimeout(function() {
|
||||
request.result = {
|
||||
retryCount: this._retryCount
|
||||
};
|
||||
request.onsuccess && request.onsuccess();
|
||||
}.bind(this));
|
||||
return request;
|
||||
},
|
||||
unlockCardLock: function() {
|
||||
this.cardState = 'ready';
|
||||
return FFOS_RUNTIME.domRequest()();
|
||||
},
|
||||
addEventListener: function() {
|
||||
debug('addEventListener');
|
||||
},
|
||||
removeEventListener: function() {
|
||||
debug('removeEventListener');
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
var iccManager = {
|
||||
addEventListener: function() {
|
||||
debug('addEventListener');
|
||||
},
|
||||
removeEventListener: function() {
|
||||
debug('removeEventListener');
|
||||
},
|
||||
getIccById: function(iccId) {
|
||||
return iccs[iccId];
|
||||
},
|
||||
iccIds: [111]
|
||||
};
|
||||
|
||||
if (window._shimDualSim) {
|
||||
iccManager.iccIds.push(222);
|
||||
}
|
||||
|
||||
FFOS_RUNTIME.makeNavigatorShim('mozIccManager', iccManager, true);
|
||||
}();
|
||||
96
gaia/tools/extensions/desktop-helper/content/data/lib/mobile_connection.js
Executable file
96
gaia/tools/extensions/desktop-helper/content/data/lib/mobile_connection.js
Executable file
|
|
@ -0,0 +1,96 @@
|
|||
!function() {
|
||||
|
||||
function debug(str) {
|
||||
//dump('mozMobileConnection: ' + str + '\n');
|
||||
}
|
||||
|
||||
var initialized = true;
|
||||
var fakeNetwork = { shortName: 'Fake Orange F', mcc: '208', mnc: '1' };
|
||||
var fakeVoice = {
|
||||
network: fakeNetwork,
|
||||
state: 'notSearching',
|
||||
roaming: true,
|
||||
connected: true,
|
||||
emergencyCallsOnly: false
|
||||
};
|
||||
var fakeNetwork2 = { shortName: 'Verizon Fake', mcc: '208', mnc: '1' };
|
||||
var fakeVoice2 = {
|
||||
network: fakeNetwork2,
|
||||
state: 'notSearching',
|
||||
roaming: true,
|
||||
connected: true,
|
||||
emergencyCallsOnly: false
|
||||
};
|
||||
|
||||
function fakeEventListener(type, callback, bubble) {
|
||||
if (initialized) {
|
||||
if (typeof callback === 'function') {
|
||||
setTimeout(callback.bind(this, { iccId: this.iccId }));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// simulates a connection to a data network;
|
||||
setTimeout(function fakeCallback() {
|
||||
initialized = true;
|
||||
if (typeof callback === 'function') {
|
||||
callback({ iccId: this.iccId });
|
||||
}
|
||||
}.bind(this), 5000);
|
||||
}
|
||||
|
||||
var mobileConnections = [{
|
||||
iccId: 111,
|
||||
addEventListener: fakeEventListener,
|
||||
removeEventListener: function() {},
|
||||
getCallWaitingOption: FFOS_RUNTIME.domRequest(true),
|
||||
getCallForwardingOption: FFOS_RUNTIME.domRequest(1),
|
||||
setCallWaitingOption: FFOS_RUNTIME.domRequest(),
|
||||
getCallingLineIdRestriction: FFOS_RUNTIME.domRequest(),
|
||||
setVoicePrivacyMode: FFOS_RUNTIME.domRequest(),
|
||||
getVoicePrivacyMode: FFOS_RUNTIME.domRequest(),
|
||||
setRadioEnabled: FFOS_RUNTIME.domRequest(),
|
||||
getRadioEnabled: FFOS_RUNTIME.domRequest(),
|
||||
getRoamingPreference: FFOS_RUNTIME.domRequest(),
|
||||
setRoamingPreference: FFOS_RUNTIME.domRequest(),
|
||||
getPreferredNetworkType: FFOS_RUNTIME.domRequest(),
|
||||
setPreferredNetworkType: FFOS_RUNTIME.domRequest(),
|
||||
get data() {
|
||||
return initialized ? { network: fakeNetwork } : null;
|
||||
},
|
||||
get voice() {
|
||||
return initialized ? fakeVoice : null;
|
||||
}
|
||||
}];
|
||||
|
||||
if (window._shimDualSim) {
|
||||
mobileConnections.push({
|
||||
iccId: 222,
|
||||
addEventListener: fakeEventListener,
|
||||
removeEventListener: function() {},
|
||||
getCallWaitingOption: FFOS_RUNTIME.domRequest(true),
|
||||
getCallForwardingOption: FFOS_RUNTIME.domRequest(1),
|
||||
setCallWaitingOption: FFOS_RUNTIME.domRequest(),
|
||||
getCallingLineIdRestriction: FFOS_RUNTIME.domRequest(),
|
||||
setVoicePrivacyMode: FFOS_RUNTIME.domRequest(),
|
||||
getVoicePrivacyMode: FFOS_RUNTIME.domRequest(),
|
||||
setRadioEnabled: FFOS_RUNTIME.domRequest(),
|
||||
getRadioEnabled: FFOS_RUNTIME.domRequest(),
|
||||
getRoamingPreference: FFOS_RUNTIME.domRequest(),
|
||||
setRoamingPreference: FFOS_RUNTIME.domRequest(),
|
||||
getPreferredNetworkType: FFOS_RUNTIME.domRequest(),
|
||||
setPreferredNetworkType: FFOS_RUNTIME.domRequest(),
|
||||
get data() {
|
||||
return initialized ? { network: fakeNetwork2 } : null;
|
||||
},
|
||||
get voice() {
|
||||
return initialized ? fakeVoice2 : null;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
FFOS_RUNTIME.makeNavigatorShim('mozMobileConnections',
|
||||
mobileConnections, true);
|
||||
|
||||
}();
|
||||
16
gaia/tools/extensions/desktop-helper/content/data/lib/telephony.js
Executable file
16
gaia/tools/extensions/desktop-helper/content/data/lib/telephony.js
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
!function() {
|
||||
|
||||
function debug(str) {
|
||||
//dump('mozTelephony: ' + str + '\n');
|
||||
}
|
||||
|
||||
FFOS_RUNTIME.makeNavigatorShim('mozTelephony', {
|
||||
calls: [],
|
||||
addEventListener: function() {
|
||||
debug('addEventListener');
|
||||
},
|
||||
removeEventListener: function() {
|
||||
debug('removeEventListener');
|
||||
}
|
||||
}, true);
|
||||
}();
|
||||
132
gaia/tools/extensions/desktop-helper/content/data/lib/wifi.js
Executable file
132
gaia/tools/extensions/desktop-helper/content/data/lib/wifi.js
Executable file
|
|
@ -0,0 +1,132 @@
|
|||
!function() {
|
||||
function debug(str) {
|
||||
//dump('wifi: ' + str + '\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* fake network list, where each network object looks like:
|
||||
* {
|
||||
* ssid : SSID string (human-readable name)
|
||||
* bssid : network identifier string
|
||||
* security : array of strings (supported authentication methods)
|
||||
* relSignalStrength : 0-100 signal level (integer)
|
||||
* connected : boolean state
|
||||
* }
|
||||
*/
|
||||
|
||||
var fakeNetworks = [
|
||||
{
|
||||
ssid: 'Mozilla-G',
|
||||
bssid: 'xx:xx:xx:xx:xx:xx',
|
||||
security: ['WPA-EAP'],
|
||||
relSignalStrength: 67,
|
||||
connected: false
|
||||
},
|
||||
{
|
||||
ssid: 'Livebox 6752',
|
||||
bssid: 'xx:xx:xx:xx:xx:xx',
|
||||
security: ['WEP'],
|
||||
relSignalStrength: 32,
|
||||
connected: false
|
||||
},
|
||||
{
|
||||
ssid: 'Mozilla Guest',
|
||||
bssid: 'xx:xx:xx:xx:xx:xx',
|
||||
security: [],
|
||||
relSignalStrength: 98,
|
||||
connected: false
|
||||
},
|
||||
{
|
||||
ssid: 'Freebox 8953',
|
||||
bssid: 'xx:xx:xx:xx:xx:xx',
|
||||
security: ['WPA2-PSK'],
|
||||
relSignalStrength: 89,
|
||||
connected: false
|
||||
}
|
||||
];
|
||||
|
||||
FFOS_RUNTIME.makeNavigatorShim('mozWifiManager', {
|
||||
enabled: true,
|
||||
macAddress: 'xx:xx:xx:xx:xx:xx',
|
||||
|
||||
// enables/disables the wifi
|
||||
setEnabled: function fakeSetEnabled(bool) {
|
||||
var self = this;
|
||||
var request = { result: bool };
|
||||
|
||||
setTimeout(function() {
|
||||
if (request.onsuccess) {
|
||||
request.onsuccess();
|
||||
}
|
||||
if (bool) {
|
||||
self.onenabled();
|
||||
} else {
|
||||
self.ondisabled();
|
||||
}
|
||||
});
|
||||
|
||||
self.enabled = bool;
|
||||
return request;
|
||||
},
|
||||
|
||||
// returns a list of visible/known networks
|
||||
getNetworks: FFOS_RUNTIME.domRequest(fakeNetworks),
|
||||
getKnownNetworks: FFOS_RUNTIME.domRequest(fakeNetworks),
|
||||
|
||||
// selects a network
|
||||
associate: function fakeAssociate(network) {
|
||||
var self = this;
|
||||
var connection = { result: network };
|
||||
var networkEvent = { network: network };
|
||||
|
||||
setTimeout(function fakeConnecting() {
|
||||
self.connection.network = network;
|
||||
self.connection.status = 'connecting';
|
||||
self.onstatuschange(networkEvent);
|
||||
}, 0);
|
||||
|
||||
setTimeout(function fakeAssociated() {
|
||||
self.connection.network = network;
|
||||
self.connection.status = 'associated';
|
||||
self.onstatuschange(networkEvent);
|
||||
}, 1000);
|
||||
|
||||
setTimeout(function fakeConnected() {
|
||||
network.connected = true;
|
||||
self.connected = network;
|
||||
self.connection.network = network;
|
||||
self.connection.status = 'connected';
|
||||
self.onstatuschange(networkEvent);
|
||||
}, 2000);
|
||||
|
||||
return connection;
|
||||
},
|
||||
|
||||
// forgets a network (disconnect)
|
||||
forget: function fakeForget(network) {
|
||||
var self = this;
|
||||
var networkEvent = { network: network };
|
||||
|
||||
setTimeout(function() {
|
||||
network.connected = false;
|
||||
self.connected = null;
|
||||
self.connection.network = null;
|
||||
self.connection.status = 'disconnected';
|
||||
self.onstatuschange(networkEvent);
|
||||
}, 0);
|
||||
},
|
||||
|
||||
// event listeners
|
||||
onenabled: function(event) {},
|
||||
ondisabled: function(event) {},
|
||||
onstatuschange: function(event) {},
|
||||
|
||||
// returns a network object for the currently connected network (if any)
|
||||
connected: null,
|
||||
|
||||
connection: {
|
||||
status: 'disconnected',
|
||||
network: null
|
||||
}
|
||||
}, true);
|
||||
}();
|
||||
Loading…
Reference in a new issue