Update desktop integration + jingle
This commit is contained in:
parent
8abaef6f04
commit
760af00f05
|
@ -13,6 +13,7 @@ var Router = require('./router');
|
||||||
var Storage = require('./storage');
|
var Storage = require('./storage');
|
||||||
var xmppEventHandlers = require('./helpers/xmppEventHandlers');
|
var xmppEventHandlers = require('./helpers/xmppEventHandlers');
|
||||||
var Notify = require('notify.js');
|
var Notify = require('notify.js');
|
||||||
|
var Desktop = require('./helpers/desktop');
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -33,6 +34,7 @@ module.exports = {
|
||||||
async.series([
|
async.series([
|
||||||
function (cb) {
|
function (cb) {
|
||||||
app.notifications = new Notify();
|
app.notifications = new Notify();
|
||||||
|
app.desktop = new Desktop();
|
||||||
app.storage = new Storage();
|
app.storage = new Storage();
|
||||||
app.storage.open(cb);
|
app.storage.open(cb);
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
var WildEmitter = require('wildemitter');
|
||||||
|
|
||||||
|
|
||||||
|
function DesktopApp(opts) {
|
||||||
|
WildEmitter.call(this);
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
opts = opts || {};
|
||||||
|
|
||||||
|
this.mozAppManifest = opts.manifest || window.location.origin + '/manifest.webapp';
|
||||||
|
|
||||||
|
this.installed = !!window.macgap || !!window.fluid;
|
||||||
|
this.installable = !!window.macgap || !!window.fluid || !!navigator.mozApps;
|
||||||
|
this.uninstallable = false;
|
||||||
|
|
||||||
|
if (window.macgap || this.fluid) {
|
||||||
|
this.installed = true;
|
||||||
|
} else if (navigator.mozApps) {
|
||||||
|
var req = navigator.mozApps.getSelf();
|
||||||
|
req.onsuccess = function (e) {
|
||||||
|
self.mozApp = e.result;
|
||||||
|
if (e.result) {
|
||||||
|
self.installed = true;
|
||||||
|
self.uninstallable = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.macgap) {
|
||||||
|
document.addEventListener('sleep', function () {
|
||||||
|
self.emit('sleep');
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
document.addEventListener('wake', function () {
|
||||||
|
self.emit('wake');
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DesktopApp.prototype = Object.create(WildEmitter.prototype, {
|
||||||
|
constructor: {
|
||||||
|
value: DesktopApp
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
DesktopApp.prototype.isRunning = function () {
|
||||||
|
return !!window.macgap || !!window.fluid || !!this.mozApp;
|
||||||
|
};
|
||||||
|
|
||||||
|
DesktopApp.prototype.install = function (cb) {
|
||||||
|
if (navigator.mozApps) {
|
||||||
|
var req = navigator.mozApps.install(this.mozAppManifest);
|
||||||
|
req.onsuccess = function (e) {
|
||||||
|
cb(null, e);
|
||||||
|
};
|
||||||
|
req.onerror = function (e) {
|
||||||
|
cb(e);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
DesktopApp.prototype.uninstall = function () {
|
||||||
|
if (this.mozApp) {
|
||||||
|
return this.mozApp.uninstall();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
DesktopApp.prototype.updateBadge = function (badge) {
|
||||||
|
if (window.macgap) {
|
||||||
|
window.macgap.dock.badge = badge || '';
|
||||||
|
} else if (window.fluid) {
|
||||||
|
window.fluid.dockBadge = badge || '';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = DesktopApp;
|
|
@ -16,25 +16,12 @@ module.exports = HumanModel.define({
|
||||||
}
|
}
|
||||||
self.markActive();
|
self.markActive();
|
||||||
});
|
});
|
||||||
if (window.macgap) {
|
|
||||||
document.addEventListener('sleep', function () {
|
|
||||||
clearTimeout(this.idleTimer);
|
|
||||||
console.log('went to sleep');
|
|
||||||
self.markInactive();
|
|
||||||
}, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window.navigator.mozApps) {
|
app.desktop.on('sleep', function () {
|
||||||
this.installable = true;
|
clearTimeout(this.idleTimer);
|
||||||
var req = navigator.mozApps.checkInstalled(window.location.origin + '/manifest.webapp');
|
console.log('went to sleep');
|
||||||
req.onsuccess = function (e) {
|
self.markInactive();
|
||||||
if (req.result) {
|
});
|
||||||
self.installedFirefox = true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
//this.allowAlerts = app.notifications.allowed();
|
|
||||||
|
|
||||||
this.markActive();
|
this.markActive();
|
||||||
},
|
},
|
||||||
|
@ -47,9 +34,7 @@ module.exports = HumanModel.define({
|
||||||
idleSince: 'date',
|
idleSince: 'date',
|
||||||
allowAlerts: ['bool', true, false],
|
allowAlerts: ['bool', true, false],
|
||||||
badge: ['string', true, ''],
|
badge: ['string', true, ''],
|
||||||
pageTitle: ['string', true, ''],
|
pageTitle: ['string', true, '']
|
||||||
installable: ['bool', true, false],
|
|
||||||
installedFirefox: ['bool', true, false]
|
|
||||||
},
|
},
|
||||||
derived: {
|
derived: {
|
||||||
title: {
|
title: {
|
||||||
|
|
|
@ -40,7 +40,11 @@ module.exports = BasePage.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
installFirefox: function () {
|
installFirefox: function () {
|
||||||
navigator.mozApps.install(window.location.origin + '/manifest.webapp');
|
if (!app.desktop.installed) {
|
||||||
|
app.desktop.install();
|
||||||
|
} else {
|
||||||
|
app.desktop.uninstall();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
handleAvatarChangeDragOver: function (e) {
|
handleAvatarChangeDragOver: function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
"node-uuid": "1.4.1",
|
"node-uuid": "1.4.1",
|
||||||
"semi-static": "0.0.4",
|
"semi-static": "0.0.4",
|
||||||
"sound-effect-manager": "0.0.5",
|
"sound-effect-manager": "0.0.5",
|
||||||
"human-model": "1.1.3",
|
"human-model": "1.4.0",
|
||||||
"human-view": "1.1.2",
|
"human-view": "1.1.2",
|
||||||
"templatizer": "0.1.2",
|
"templatizer": "0.1.2",
|
||||||
"underscore": "1.5.1",
|
"underscore": "1.5.1",
|
||||||
"raf-component": "1.1.1",
|
"raf-component": "1.1.1",
|
||||||
"stanza.io": "2.5.2",
|
"stanza.io": "2.5.4",
|
||||||
"notify.js": "0.0.1"
|
"notify.js": "0.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
CACHE MANIFEST
|
CACHE MANIFEST
|
||||||
# 0.0.1 1381556294101
|
# 0.0.1 1381729479369
|
||||||
|
|
||||||
CACHE:
|
CACHE:
|
||||||
/app.js
|
/app.js
|
||||||
|
|
|
@ -3,5 +3,13 @@
|
||||||
"description": "Modern XMPP client",
|
"description": "Modern XMPP client",
|
||||||
"icons": {
|
"icons": {
|
||||||
"128": "/images/icon_128x128.png"
|
"128": "/images/icon_128x128.png"
|
||||||
|
},
|
||||||
|
"permissions": {
|
||||||
|
"storage": {
|
||||||
|
"description": "Required for caching contact information and message history."
|
||||||
|
},
|
||||||
|
"desktop-notification": {
|
||||||
|
"description": "Required to show alerts for new messages."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue