mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-04 15:07:02 +03:00
eslint (additional rules)
This commit is contained in:
parent
77a1d3f3df
commit
8e8a041032
150 changed files with 21911 additions and 23106 deletions
|
|
@ -1,71 +1,64 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Settings = require('Storage/Settings');
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Settings = require('Storage/Settings')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AccountUserStore()
|
||||
{
|
||||
this.email = ko.observable('');
|
||||
this.parentEmail = ko.observable('');
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AccountUserStore()
|
||||
{
|
||||
this.email = ko.observable('');
|
||||
this.parentEmail = ko.observable('');
|
||||
// this.incLogin = ko.observable('');
|
||||
// this.outLogin = ko.observable('');
|
||||
|
||||
this.signature = ko.observable('');
|
||||
this.signature = ko.observable('');
|
||||
|
||||
this.accounts = ko.observableArray([]);
|
||||
this.accounts.loading = ko.observable(false).extend({'throttle': 100});
|
||||
this.accounts = ko.observableArray([]);
|
||||
this.accounts.loading = ko.observable(false).extend({'throttle': 100});
|
||||
|
||||
this.computers();
|
||||
}
|
||||
this.computers();
|
||||
}
|
||||
|
||||
AccountUserStore.prototype.computers = function ()
|
||||
{
|
||||
this.accountsEmails = ko.computed(function () {
|
||||
return _.compact(_.map(this.accounts(), function (oItem) {
|
||||
return oItem ? oItem.email : null;
|
||||
}));
|
||||
}, this);
|
||||
AccountUserStore.prototype.computers = function()
|
||||
{
|
||||
this.accountsEmails = ko.computed(function() {
|
||||
return _.compact(_.map(this.accounts(), function(oItem) {
|
||||
return oItem ? oItem.email : null;
|
||||
}));
|
||||
}, this);
|
||||
|
||||
this.accountsUnreadCount = ko.computed(function () {
|
||||
this.accountsUnreadCount = ko.computed(function() {
|
||||
|
||||
var iResult = 0;
|
||||
var iResult = 0;
|
||||
|
||||
// _.each(this.accounts(), function (oItem) {
|
||||
// _.each(this.accounts(), function(oItem) {
|
||||
// if (oItem)
|
||||
// {
|
||||
// iResult += oItem.count();
|
||||
// }
|
||||
// });
|
||||
|
||||
return iResult;
|
||||
return iResult;
|
||||
|
||||
}, this);
|
||||
};
|
||||
}, this);
|
||||
};
|
||||
|
||||
AccountUserStore.prototype.populate = function ()
|
||||
{
|
||||
this.email(Settings.settingsGet('Email'));
|
||||
this.parentEmail(Settings.settingsGet('ParentEmail'));
|
||||
};
|
||||
AccountUserStore.prototype.populate = function()
|
||||
{
|
||||
this.email(Settings.settingsGet('Email'));
|
||||
this.parentEmail(Settings.settingsGet('ParentEmail'));
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
AccountUserStore.prototype.isRootAccount = function ()
|
||||
{
|
||||
return '' === this.parentEmail();
|
||||
};
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
AccountUserStore.prototype.isRootAccount = function()
|
||||
{
|
||||
return '' === this.parentEmail();
|
||||
};
|
||||
|
||||
module.exports = new AccountUserStore();
|
||||
|
||||
}());
|
||||
module.exports = new AccountUserStore();
|
||||
|
|
|
|||
|
|
@ -17,12 +17,10 @@ class AppUserStore extends AbstractAppStore
|
|||
|
||||
this.focusedState = ko.observable(Focused.None);
|
||||
|
||||
this.focusedState.subscribe(function (value) {
|
||||
this.focusedState.subscribe(function(value) {
|
||||
|
||||
switch (value)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case Focused.MessageList:
|
||||
keyScope(KeyState.MessageList);
|
||||
break;
|
||||
|
|
@ -32,6 +30,8 @@ class AppUserStore extends AbstractAppStore
|
|||
case Focused.FolderList:
|
||||
keyScope(KeyState.FolderList);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}, this);
|
||||
|
|
|
|||
|
|
@ -1,43 +1,36 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Settings = require('Storage/Settings');
|
||||
|
||||
var
|
||||
ko = require('ko'),
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function ContactUserStore()
|
||||
{
|
||||
this.contacts = ko.observableArray([]);
|
||||
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.importing = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.syncing = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.exportingVcf = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.exportingCsv = ko.observable(false).extend({'throttle': 200});
|
||||
|
||||
Settings = require('Storage/Settings')
|
||||
;
|
||||
this.allowContactsSync = ko.observable(false);
|
||||
this.enableContactsSync = ko.observable(false);
|
||||
this.contactsSyncUrl = ko.observable('');
|
||||
this.contactsSyncUser = ko.observable('');
|
||||
this.contactsSyncPass = ko.observable('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function ContactUserStore()
|
||||
{
|
||||
this.contacts = ko.observableArray([]);
|
||||
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.importing = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.syncing = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.exportingVcf = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.exportingCsv = ko.observable(false).extend({'throttle': 200});
|
||||
ContactUserStore.prototype.populate = function()
|
||||
{
|
||||
this.allowContactsSync(!!Settings.settingsGet('ContactsSyncIsAllowed'));
|
||||
this.enableContactsSync(!!Settings.settingsGet('EnableContactsSync'));
|
||||
|
||||
this.allowContactsSync = ko.observable(false);
|
||||
this.enableContactsSync = ko.observable(false);
|
||||
this.contactsSyncUrl = ko.observable('');
|
||||
this.contactsSyncUser = ko.observable('');
|
||||
this.contactsSyncPass = ko.observable('');
|
||||
}
|
||||
this.contactsSyncUrl(Settings.settingsGet('ContactsSyncUrl'));
|
||||
this.contactsSyncUser(Settings.settingsGet('ContactsSyncUser'));
|
||||
this.contactsSyncPass(Settings.settingsGet('ContactsSyncPassword'));
|
||||
};
|
||||
|
||||
ContactUserStore.prototype.populate = function ()
|
||||
{
|
||||
this.allowContactsSync(!!Settings.settingsGet('ContactsSyncIsAllowed'));
|
||||
this.enableContactsSync(!!Settings.settingsGet('EnableContactsSync'));
|
||||
|
||||
this.contactsSyncUrl(Settings.settingsGet('ContactsSyncUrl'));
|
||||
this.contactsSyncUser(Settings.settingsGet('ContactsSyncUser'));
|
||||
this.contactsSyncPass(Settings.settingsGet('ContactsSyncPassword'));
|
||||
};
|
||||
|
||||
module.exports = new ContactUserStore();
|
||||
|
||||
}());
|
||||
module.exports = new ContactUserStore();
|
||||
|
|
|
|||
|
|
@ -1,28 +1,20 @@
|
|||
|
||||
(function () {
|
||||
var ko = require('ko');
|
||||
|
||||
'use strict';
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function FilterUserStore()
|
||||
{
|
||||
this.capa = ko.observable('');
|
||||
this.modules = ko.observable({});
|
||||
|
||||
var
|
||||
ko = require('ko')
|
||||
;
|
||||
this.filters = ko.observableArray([]);
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function FilterUserStore()
|
||||
{
|
||||
this.capa = ko.observable('');
|
||||
this.modules = ko.observable({});
|
||||
this.filters.loading = ko.observable(false).extend({throttle: 200});
|
||||
this.filters.saving = ko.observable(false).extend({throttle: 200});
|
||||
|
||||
this.filters = ko.observableArray([]);
|
||||
this.raw = ko.observable('');
|
||||
}
|
||||
|
||||
this.filters.loading = ko.observable(false).extend({throttle: 200});
|
||||
this.filters.saving = ko.observable(false).extend({throttle: 200});
|
||||
|
||||
this.raw = ko.observable('');
|
||||
}
|
||||
|
||||
module.exports = new FilterUserStore();
|
||||
|
||||
}());
|
||||
module.exports = new FilterUserStore();
|
||||
|
|
|
|||
|
|
@ -1,246 +1,247 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Consts = require('Common/Consts'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
Cache = require('Common/Cache');
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Consts = require('Common/Consts'),
|
||||
Utils = require('Common/Utils'),
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function FolderUserStore()
|
||||
{
|
||||
this.displaySpecSetting = ko.observable(true);
|
||||
|
||||
Cache = require('Common/Cache')
|
||||
;
|
||||
this.sentFolder = ko.observable('');
|
||||
this.draftFolder = ko.observable('');
|
||||
this.spamFolder = ko.observable('');
|
||||
this.trashFolder = ko.observable('');
|
||||
this.archiveFolder = ko.observable('');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function FolderUserStore()
|
||||
{
|
||||
this.displaySpecSetting = ko.observable(true);
|
||||
this.namespace = '';
|
||||
|
||||
this.sentFolder = ko.observable('');
|
||||
this.draftFolder = ko.observable('');
|
||||
this.spamFolder = ko.observable('');
|
||||
this.trashFolder = ko.observable('');
|
||||
this.archiveFolder = ko.observable('');
|
||||
this.folderList = ko.observableArray([]);
|
||||
this.folderList.optimized = ko.observable(false);
|
||||
this.folderList.error = ko.observable('');
|
||||
|
||||
this.namespace = '';
|
||||
this.foldersLoading = ko.observable(false);
|
||||
this.foldersCreating = ko.observable(false);
|
||||
this.foldersDeleting = ko.observable(false);
|
||||
this.foldersRenaming = ko.observable(false);
|
||||
|
||||
this.folderList = ko.observableArray([]);
|
||||
this.folderList.optimized = ko.observable(false);
|
||||
this.folderList.error = ko.observable('');
|
||||
this.foldersInboxUnreadCount = ko.observable(0);
|
||||
|
||||
this.foldersLoading = ko.observable(false);
|
||||
this.foldersCreating = ko.observable(false);
|
||||
this.foldersDeleting = ko.observable(false);
|
||||
this.foldersRenaming = ko.observable(false);
|
||||
|
||||
this.foldersInboxUnreadCount = ko.observable(0);
|
||||
|
||||
this.currentFolder = ko.observable(null).extend({'toggleSubscribe': [null,
|
||||
function (oPrev) { if (oPrev) { oPrev.selected(false); }},
|
||||
function (oNext) { if (oNext) { oNext.selected(true); }}
|
||||
]});
|
||||
|
||||
this.computers();
|
||||
this.subscribers();
|
||||
}
|
||||
|
||||
FolderUserStore.prototype.computers = function ()
|
||||
{
|
||||
this.draftFolderNotEnabled = ko.computed(function () {
|
||||
return '' === this.draftFolder() || Consts.UNUSED_OPTION_VALUE === this.draftFolder();
|
||||
}, this);
|
||||
|
||||
this.foldersListWithSingleInboxRootFolder = ko.computed(function () {
|
||||
return !_.find(this.folderList(), function (oFolder) {
|
||||
return oFolder && !oFolder.isSystemFolder() && oFolder.visible();
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.currentFolderFullNameRaw = ko.computed(function () {
|
||||
return this.currentFolder() ? this.currentFolder().fullNameRaw : '';
|
||||
}, this);
|
||||
|
||||
this.currentFolderFullName = ko.computed(function () {
|
||||
return this.currentFolder() ? this.currentFolder().fullName : '';
|
||||
}, this);
|
||||
|
||||
this.currentFolderFullNameHash = ko.computed(function () {
|
||||
return this.currentFolder() ? this.currentFolder().fullNameHash : '';
|
||||
}, this);
|
||||
|
||||
this.foldersChanging = ko.computed(function () {
|
||||
var
|
||||
bLoading = this.foldersLoading(),
|
||||
bCreating = this.foldersCreating(),
|
||||
bDeleting = this.foldersDeleting(),
|
||||
bRenaming = this.foldersRenaming()
|
||||
;
|
||||
return bLoading || bCreating || bDeleting || bRenaming;
|
||||
}, this);
|
||||
|
||||
this.folderListSystemNames = ko.computed(function () {
|
||||
|
||||
var
|
||||
aList = [Cache.getFolderInboxName()],
|
||||
aFolders = this.folderList(),
|
||||
sSentFolder = this.sentFolder(),
|
||||
sDraftFolder = this.draftFolder(),
|
||||
sSpamFolder = this.spamFolder(),
|
||||
sTrashFolder = this.trashFolder(),
|
||||
sArchiveFolder = this.archiveFolder()
|
||||
;
|
||||
|
||||
if (Utils.isArray(aFolders) && 0 < aFolders.length)
|
||||
{
|
||||
if ('' !== sSentFolder && Consts.UNUSED_OPTION_VALUE !== sSentFolder)
|
||||
{
|
||||
aList.push(sSentFolder);
|
||||
}
|
||||
if ('' !== sDraftFolder && Consts.UNUSED_OPTION_VALUE !== sDraftFolder)
|
||||
{
|
||||
aList.push(sDraftFolder);
|
||||
}
|
||||
if ('' !== sSpamFolder && Consts.UNUSED_OPTION_VALUE !== sSpamFolder)
|
||||
{
|
||||
aList.push(sSpamFolder);
|
||||
}
|
||||
if ('' !== sTrashFolder && Consts.UNUSED_OPTION_VALUE !== sTrashFolder)
|
||||
{
|
||||
aList.push(sTrashFolder);
|
||||
}
|
||||
if ('' !== sArchiveFolder && Consts.UNUSED_OPTION_VALUE !== sArchiveFolder)
|
||||
{
|
||||
aList.push(sArchiveFolder);
|
||||
}
|
||||
this.currentFolder = ko.observable(null).extend({toggleSubscribe: [
|
||||
null,
|
||||
function(oPrev) {
|
||||
if (oPrev) {
|
||||
oPrev.selected(false);
|
||||
}
|
||||
},
|
||||
function(oNext) {
|
||||
if (oNext) {
|
||||
oNext.selected(true);
|
||||
}
|
||||
}
|
||||
]});
|
||||
|
||||
return aList;
|
||||
this.computers();
|
||||
this.subscribers();
|
||||
}
|
||||
|
||||
}, this);
|
||||
FolderUserStore.prototype.computers = function()
|
||||
{
|
||||
this.draftFolderNotEnabled = ko.computed(function() {
|
||||
return '' === this.draftFolder() || Consts.UNUSED_OPTION_VALUE === this.draftFolder();
|
||||
}, this);
|
||||
|
||||
this.folderListSystem = ko.computed(function () {
|
||||
return _.compact(_.map(this.folderListSystemNames(), function (sName) {
|
||||
return Cache.getFolderFromCacheList(sName);
|
||||
}));
|
||||
}, this);
|
||||
this.foldersListWithSingleInboxRootFolder = ko.computed(function() {
|
||||
return !_.find(this.folderList(), function(oFolder) {
|
||||
return oFolder && !oFolder.isSystemFolder() && oFolder.visible();
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.folderMenuForMove = ko.computed(function () {
|
||||
return Utils.folderListOptionsBuilder(this.folderListSystem(), this.folderList(), [
|
||||
this.currentFolderFullNameRaw()
|
||||
], null, null, null, null, function (oItem) {
|
||||
this.currentFolderFullNameRaw = ko.computed(function() {
|
||||
return this.currentFolder() ? this.currentFolder().fullNameRaw : '';
|
||||
}, this);
|
||||
|
||||
this.currentFolderFullName = ko.computed(function() {
|
||||
return this.currentFolder() ? this.currentFolder().fullName : '';
|
||||
}, this);
|
||||
|
||||
this.currentFolderFullNameHash = ko.computed(function() {
|
||||
return this.currentFolder() ? this.currentFolder().fullNameHash : '';
|
||||
}, this);
|
||||
|
||||
this.foldersChanging = ko.computed(function() {
|
||||
var
|
||||
bLoading = this.foldersLoading(),
|
||||
bCreating = this.foldersCreating(),
|
||||
bDeleting = this.foldersDeleting(),
|
||||
bRenaming = this.foldersRenaming();
|
||||
return bLoading || bCreating || bDeleting || bRenaming;
|
||||
}, this);
|
||||
|
||||
this.folderListSystemNames = ko.computed(function() {
|
||||
|
||||
var
|
||||
aList = [Cache.getFolderInboxName()],
|
||||
aFolders = this.folderList(),
|
||||
sSentFolder = this.sentFolder(),
|
||||
sDraftFolder = this.draftFolder(),
|
||||
sSpamFolder = this.spamFolder(),
|
||||
sTrashFolder = this.trashFolder(),
|
||||
sArchiveFolder = this.archiveFolder();
|
||||
|
||||
if (Utils.isArray(aFolders) && 0 < aFolders.length)
|
||||
{
|
||||
if ('' !== sSentFolder && Consts.UNUSED_OPTION_VALUE !== sSentFolder)
|
||||
{
|
||||
aList.push(sSentFolder);
|
||||
}
|
||||
if ('' !== sDraftFolder && Consts.UNUSED_OPTION_VALUE !== sDraftFolder)
|
||||
{
|
||||
aList.push(sDraftFolder);
|
||||
}
|
||||
if ('' !== sSpamFolder && Consts.UNUSED_OPTION_VALUE !== sSpamFolder)
|
||||
{
|
||||
aList.push(sSpamFolder);
|
||||
}
|
||||
if ('' !== sTrashFolder && Consts.UNUSED_OPTION_VALUE !== sTrashFolder)
|
||||
{
|
||||
aList.push(sTrashFolder);
|
||||
}
|
||||
if ('' !== sArchiveFolder && Consts.UNUSED_OPTION_VALUE !== sArchiveFolder)
|
||||
{
|
||||
aList.push(sArchiveFolder);
|
||||
}
|
||||
}
|
||||
|
||||
return aList;
|
||||
|
||||
}, this);
|
||||
|
||||
this.folderListSystem = ko.computed(function() {
|
||||
return _.compact(_.map(this.folderListSystemNames(), function(sName) {
|
||||
return Cache.getFolderFromCacheList(sName);
|
||||
}));
|
||||
}, this);
|
||||
|
||||
this.folderMenuForMove = ko.computed(function() {
|
||||
return Utils.folderListOptionsBuilder(this.folderListSystem(), this.folderList(), [
|
||||
this.currentFolderFullNameRaw()
|
||||
], null, null, null, null, function(oItem) {
|
||||
return oItem ? oItem.localName() : '';
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.folderMenuForFilters = ko.computed(function() {
|
||||
return Utils.folderListOptionsBuilder(this.folderListSystem(), this.folderList(),
|
||||
['INBOX'], [['', '']], null, null, null, function(oItem) {
|
||||
return oItem ? oItem.localName() : '';
|
||||
});
|
||||
}, this);
|
||||
}
|
||||
);
|
||||
}, this);
|
||||
};
|
||||
|
||||
this.folderMenuForFilters = ko.computed(function () {
|
||||
return Utils.folderListOptionsBuilder(this.folderListSystem(), this.folderList(),
|
||||
['INBOX'], [['', '']], null, null, null, function (oItem) {
|
||||
return oItem ? oItem.localName() : '';
|
||||
FolderUserStore.prototype.subscribers = function()
|
||||
{
|
||||
var
|
||||
fRemoveSystemFolderType = function(observable) {
|
||||
return function() {
|
||||
var oFolder = Cache.getFolderFromCacheList(observable());
|
||||
if (oFolder)
|
||||
{
|
||||
oFolder.type(Enums.FolderType.User);
|
||||
}
|
||||
);
|
||||
}, this);
|
||||
};
|
||||
};
|
||||
},
|
||||
fSetSystemFolderType = function(iType) {
|
||||
return function(sValue) {
|
||||
var oFolder = Cache.getFolderFromCacheList(sValue);
|
||||
if (oFolder)
|
||||
{
|
||||
oFolder.type(iType);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
FolderUserStore.prototype.subscribers = function ()
|
||||
{
|
||||
var
|
||||
fRemoveSystemFolderType = function (observable) {
|
||||
return function () {
|
||||
var oFolder = Cache.getFolderFromCacheList(observable());
|
||||
if (oFolder)
|
||||
{
|
||||
oFolder.type(Enums.FolderType.User);
|
||||
}
|
||||
};
|
||||
},
|
||||
fSetSystemFolderType = function (iType) {
|
||||
return function (sValue) {
|
||||
var oFolder = Cache.getFolderFromCacheList(sValue);
|
||||
if (oFolder)
|
||||
{
|
||||
oFolder.type(iType);
|
||||
}
|
||||
};
|
||||
}
|
||||
;
|
||||
this.sentFolder.subscribe(fRemoveSystemFolderType(this.sentFolder), this, 'beforeChange');
|
||||
this.draftFolder.subscribe(fRemoveSystemFolderType(this.draftFolder), this, 'beforeChange');
|
||||
this.spamFolder.subscribe(fRemoveSystemFolderType(this.spamFolder), this, 'beforeChange');
|
||||
this.trashFolder.subscribe(fRemoveSystemFolderType(this.trashFolder), this, 'beforeChange');
|
||||
this.archiveFolder.subscribe(fRemoveSystemFolderType(this.archiveFolder), this, 'beforeChange');
|
||||
|
||||
this.sentFolder.subscribe(fRemoveSystemFolderType(this.sentFolder), this, 'beforeChange');
|
||||
this.draftFolder.subscribe(fRemoveSystemFolderType(this.draftFolder), this, 'beforeChange');
|
||||
this.spamFolder.subscribe(fRemoveSystemFolderType(this.spamFolder), this, 'beforeChange');
|
||||
this.trashFolder.subscribe(fRemoveSystemFolderType(this.trashFolder), this, 'beforeChange');
|
||||
this.archiveFolder.subscribe(fRemoveSystemFolderType(this.archiveFolder), this, 'beforeChange');
|
||||
this.sentFolder.subscribe(fSetSystemFolderType(Enums.FolderType.SentItems), this);
|
||||
this.draftFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Draft), this);
|
||||
this.spamFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Spam), this);
|
||||
this.trashFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Trash), this);
|
||||
this.archiveFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Archive), this);
|
||||
};
|
||||
|
||||
this.sentFolder.subscribe(fSetSystemFolderType(Enums.FolderType.SentItems), this);
|
||||
this.draftFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Draft), this);
|
||||
this.spamFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Spam), this);
|
||||
this.trashFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Trash), this);
|
||||
this.archiveFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Archive), this);
|
||||
};
|
||||
/**
|
||||
* @returns {Array}
|
||||
*/
|
||||
FolderUserStore.prototype.getNextFolderNames = function()
|
||||
{
|
||||
var
|
||||
aResult = [],
|
||||
iLimit = 5,
|
||||
iUtc = require('Common/Momentor').momentNowUnix(),
|
||||
iTimeout = iUtc - 60 * 5,
|
||||
aTimeouts = [],
|
||||
sInboxFolderName = Cache.getFolderInboxName(),
|
||||
fSearchFunction = function(aList) {
|
||||
_.each(aList, function(oFolder) {
|
||||
if (oFolder && sInboxFolderName !== oFolder.fullNameRaw &&
|
||||
oFolder.selectable && oFolder.existen &&
|
||||
iTimeout > oFolder.interval &&
|
||||
(oFolder.isSystemFolder() || (oFolder.subScribed() && oFolder.checkable()))
|
||||
)
|
||||
{
|
||||
aTimeouts.push([oFolder.interval, oFolder.fullNameRaw]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Array}
|
||||
*/
|
||||
FolderUserStore.prototype.getNextFolderNames = function ()
|
||||
{
|
||||
var
|
||||
aResult = [],
|
||||
iLimit = 5,
|
||||
iUtc = require('Common/Momentor').momentNowUnix(),
|
||||
iTimeout = iUtc - 60 * 5,
|
||||
aTimeouts = [],
|
||||
sInboxFolderName = Cache.getFolderInboxName(),
|
||||
fSearchFunction = function (aList) {
|
||||
_.each(aList, function (oFolder) {
|
||||
if (oFolder && sInboxFolderName !== oFolder.fullNameRaw &&
|
||||
oFolder.selectable && oFolder.existen &&
|
||||
iTimeout > oFolder.interval &&
|
||||
(oFolder.isSystemFolder() || (oFolder.subScribed() && oFolder.checkable()))
|
||||
)
|
||||
{
|
||||
aTimeouts.push([oFolder.interval, oFolder.fullNameRaw]);
|
||||
}
|
||||
if (oFolder && 0 < oFolder.subFolders().length)
|
||||
{
|
||||
fSearchFunction(oFolder.subFolders());
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (oFolder && 0 < oFolder.subFolders().length)
|
||||
{
|
||||
fSearchFunction(oFolder.subFolders());
|
||||
}
|
||||
});
|
||||
}
|
||||
;
|
||||
fSearchFunction(this.folderList());
|
||||
|
||||
fSearchFunction(this.folderList());
|
||||
aTimeouts.sort(function(a, b) {
|
||||
if (a[0] < b[0])
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (a[0] > b[0])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
aTimeouts.sort(function(a, b) {
|
||||
if (a[0] < b[0]) {
|
||||
return -1;
|
||||
} else if (a[0] > b[0]) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
return 0;
|
||||
});
|
||||
_.find(aTimeouts, function(aItem) {
|
||||
var oFolder = Cache.getFolderFromCacheList(aItem[1]);
|
||||
if (oFolder)
|
||||
{
|
||||
oFolder.interval = iUtc;
|
||||
aResult.push(aItem[1]);
|
||||
}
|
||||
|
||||
_.find(aTimeouts, function (aItem) {
|
||||
var oFolder = Cache.getFolderFromCacheList(aItem[1]);
|
||||
if (oFolder)
|
||||
{
|
||||
oFolder.interval = iUtc;
|
||||
aResult.push(aItem[1]);
|
||||
}
|
||||
return iLimit <= aResult.length;
|
||||
});
|
||||
|
||||
return iLimit <= aResult.length;
|
||||
});
|
||||
aResult = _.uniq(aResult);
|
||||
|
||||
aResult = _.uniq(aResult);
|
||||
return aResult;
|
||||
};
|
||||
|
||||
return aResult;
|
||||
};
|
||||
|
||||
module.exports = new FolderUserStore();
|
||||
|
||||
}());
|
||||
module.exports = new FolderUserStore();
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,229 +1,220 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
window = require('window'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Events = require('Common/Events'),
|
||||
Audio = require('Common/Audio'),
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
ko = require('ko'),
|
||||
Settings = require('Storage/Settings');
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Events = require('Common/Events'),
|
||||
Audio = require('Common/Audio'),
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function NotificationUserStore()
|
||||
{
|
||||
var self = this;
|
||||
|
||||
Settings = require('Storage/Settings')
|
||||
;
|
||||
this.enableSoundNotification = ko.observable(false);
|
||||
this.soundNotificationIsSupported = ko.observable(false);
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function NotificationUserStore()
|
||||
{
|
||||
var self = this;
|
||||
this.allowDesktopNotification = ko.observable(false);
|
||||
|
||||
this.enableSoundNotification = ko.observable(false);
|
||||
this.soundNotificationIsSupported = ko.observable(false);
|
||||
this.desktopNotificationPermissions = ko.computed(function() {
|
||||
|
||||
this.allowDesktopNotification = ko.observable(false);
|
||||
this.allowDesktopNotification();
|
||||
|
||||
this.desktopNotificationPermissions = ko.computed(function () {
|
||||
var
|
||||
NotificationClass = this.notificationClass(),
|
||||
iResult = Enums.DesktopNotification.NotSupported;
|
||||
|
||||
this.allowDesktopNotification();
|
||||
|
||||
var
|
||||
NotificationClass = this.notificationClass(),
|
||||
iResult = Enums.DesktopNotification.NotSupported
|
||||
;
|
||||
|
||||
if (NotificationClass && NotificationClass.permission)
|
||||
if (NotificationClass && NotificationClass.permission)
|
||||
{
|
||||
switch (NotificationClass.permission.toLowerCase())
|
||||
{
|
||||
switch (NotificationClass.permission.toLowerCase())
|
||||
case 'granted':
|
||||
iResult = Enums.DesktopNotification.Allowed;
|
||||
break;
|
||||
case 'denied':
|
||||
iResult = Enums.DesktopNotification.Denied;
|
||||
break;
|
||||
case 'default':
|
||||
iResult = Enums.DesktopNotification.NotAllowed;
|
||||
break;
|
||||
// no default
|
||||
}
|
||||
}
|
||||
else if (window.webkitNotifications && window.webkitNotifications.checkPermission)
|
||||
{
|
||||
iResult = window.webkitNotifications.checkPermission();
|
||||
}
|
||||
|
||||
return iResult;
|
||||
|
||||
}, this).extend({'notify': 'always'});
|
||||
|
||||
this.enableDesktopNotification = ko.computed({
|
||||
'owner': this,
|
||||
'read': function() {
|
||||
return this.allowDesktopNotification() &&
|
||||
Enums.DesktopNotification.Allowed === this.desktopNotificationPermissions();
|
||||
},
|
||||
'write': function(bValue) {
|
||||
if (bValue)
|
||||
{
|
||||
var
|
||||
NotificationClass = this.notificationClass(),
|
||||
iPermission = this.desktopNotificationPermissions();
|
||||
|
||||
if (NotificationClass && Enums.DesktopNotification.Allowed === iPermission)
|
||||
{
|
||||
case 'granted':
|
||||
iResult = Enums.DesktopNotification.Allowed;
|
||||
break;
|
||||
case 'denied':
|
||||
iResult = Enums.DesktopNotification.Denied;
|
||||
break;
|
||||
case 'default':
|
||||
iResult = Enums.DesktopNotification.NotAllowed;
|
||||
break;
|
||||
this.allowDesktopNotification(true);
|
||||
}
|
||||
}
|
||||
else if (window.webkitNotifications && window.webkitNotifications.checkPermission)
|
||||
{
|
||||
iResult = window.webkitNotifications.checkPermission();
|
||||
}
|
||||
|
||||
return iResult;
|
||||
|
||||
}, this).extend({'notify': 'always'});
|
||||
|
||||
this.enableDesktopNotification = ko.computed({
|
||||
'owner': this,
|
||||
'read': function () {
|
||||
return this.allowDesktopNotification() &&
|
||||
Enums.DesktopNotification.Allowed === this.desktopNotificationPermissions();
|
||||
},
|
||||
'write': function (bValue) {
|
||||
if (bValue)
|
||||
else if (NotificationClass && Enums.DesktopNotification.NotAllowed === iPermission)
|
||||
{
|
||||
var
|
||||
NotificationClass = this.notificationClass(),
|
||||
iPermission = this.desktopNotificationPermissions()
|
||||
;
|
||||
|
||||
if (NotificationClass && Enums.DesktopNotification.Allowed === iPermission)
|
||||
{
|
||||
this.allowDesktopNotification(true);
|
||||
}
|
||||
else if (NotificationClass && Enums.DesktopNotification.NotAllowed === iPermission)
|
||||
{
|
||||
NotificationClass.requestPermission(function () {
|
||||
self.allowDesktopNotification.valueHasMutated();
|
||||
if (Enums.DesktopNotification.Allowed === self.desktopNotificationPermissions())
|
||||
NotificationClass.requestPermission(function() {
|
||||
self.allowDesktopNotification.valueHasMutated();
|
||||
if (Enums.DesktopNotification.Allowed === self.desktopNotificationPermissions())
|
||||
{
|
||||
if (self.allowDesktopNotification())
|
||||
{
|
||||
if (self.allowDesktopNotification())
|
||||
{
|
||||
self.allowDesktopNotification.valueHasMutated();
|
||||
}
|
||||
else
|
||||
{
|
||||
self.allowDesktopNotification(true);
|
||||
}
|
||||
self.allowDesktopNotification.valueHasMutated();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (self.allowDesktopNotification())
|
||||
{
|
||||
self.allowDesktopNotification(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.allowDesktopNotification.valueHasMutated();
|
||||
}
|
||||
self.allowDesktopNotification(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
this.allowDesktopNotification(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (self.allowDesktopNotification())
|
||||
{
|
||||
self.allowDesktopNotification(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.allowDesktopNotification.valueHasMutated();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
this.allowDesktopNotification(false);
|
||||
}
|
||||
}
|
||||
}).extend({'notify': 'always'});
|
||||
|
||||
if (!this.enableDesktopNotification.valueHasMutated)
|
||||
{
|
||||
this.enableDesktopNotification.valueHasMutated = function () {
|
||||
self.allowDesktopNotification.valueHasMutated();
|
||||
};
|
||||
}
|
||||
|
||||
this.computers();
|
||||
|
||||
this.initNotificationPlayer();
|
||||
}
|
||||
|
||||
NotificationUserStore.prototype.computers = function ()
|
||||
{
|
||||
this.isDesktopNotificationSupported = ko.computed(function () {
|
||||
return Enums.DesktopNotification.NotSupported !== this.desktopNotificationPermissions();
|
||||
}, this);
|
||||
|
||||
this.isDesktopNotificationDenied = ko.computed(function () {
|
||||
return Enums.DesktopNotification.NotSupported === this.desktopNotificationPermissions() ||
|
||||
Enums.DesktopNotification.Denied === this.desktopNotificationPermissions();
|
||||
}, this);
|
||||
};
|
||||
|
||||
NotificationUserStore.prototype.initNotificationPlayer = function ()
|
||||
{
|
||||
if (Audio && Audio.supportedNotification)
|
||||
{
|
||||
this.soundNotificationIsSupported(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.enableSoundNotification(false);
|
||||
this.soundNotificationIsSupported(false);
|
||||
}
|
||||
};
|
||||
|
||||
NotificationUserStore.prototype.playSoundNotification = function (bSkipSetting)
|
||||
{
|
||||
if (Audio && Audio.supportedNotification && (bSkipSetting ? true : this.enableSoundNotification()))
|
||||
{
|
||||
Audio.playNotification();
|
||||
}
|
||||
};
|
||||
|
||||
NotificationUserStore.prototype.displayDesktopNotification = function (sImageSrc, sTitle, sText, oMessageData)
|
||||
{
|
||||
if (this.enableDesktopNotification())
|
||||
{
|
||||
var
|
||||
NotificationClass = this.notificationClass(),
|
||||
oNotification = NotificationClass ? new NotificationClass(sTitle, {
|
||||
'body': sText,
|
||||
'icon': sImageSrc
|
||||
}) : null
|
||||
;
|
||||
|
||||
if (oNotification)
|
||||
else
|
||||
{
|
||||
if (oNotification.show)
|
||||
{
|
||||
oNotification.show();
|
||||
}
|
||||
|
||||
if (oMessageData)
|
||||
{
|
||||
oNotification.onclick = function () {
|
||||
|
||||
window.focus();
|
||||
|
||||
if (oMessageData.Folder && oMessageData.Uid)
|
||||
{
|
||||
Events.pub('mailbox.message.show', [oMessageData.Folder, oMessageData.Uid]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
window.setTimeout((function (oLocalNotifications) {
|
||||
return function () {
|
||||
if (oLocalNotifications.cancel)
|
||||
{
|
||||
oLocalNotifications.cancel();
|
||||
}
|
||||
else if (oLocalNotifications.close)
|
||||
{
|
||||
oLocalNotifications.close();
|
||||
}
|
||||
};
|
||||
}(oNotification)), 7000);
|
||||
this.allowDesktopNotification(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
}).extend({'notify': 'always'});
|
||||
|
||||
NotificationUserStore.prototype.populate = function ()
|
||||
if (!this.enableDesktopNotification.valueHasMutated)
|
||||
{
|
||||
this.enableSoundNotification(!!Settings.settingsGet('SoundNotification'));
|
||||
this.enableDesktopNotification(!!Settings.settingsGet('DesktopNotifications'));
|
||||
};
|
||||
this.enableDesktopNotification.valueHasMutated = function() {
|
||||
self.allowDesktopNotification.valueHasMutated();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {*|null}
|
||||
*/
|
||||
NotificationUserStore.prototype.notificationClass = function ()
|
||||
this.computers();
|
||||
|
||||
this.initNotificationPlayer();
|
||||
}
|
||||
|
||||
NotificationUserStore.prototype.computers = function()
|
||||
{
|
||||
this.isDesktopNotificationSupported = ko.computed(function() {
|
||||
return Enums.DesktopNotification.NotSupported !== this.desktopNotificationPermissions();
|
||||
}, this);
|
||||
|
||||
this.isDesktopNotificationDenied = ko.computed(function() {
|
||||
return Enums.DesktopNotification.NotSupported === this.desktopNotificationPermissions() ||
|
||||
Enums.DesktopNotification.Denied === this.desktopNotificationPermissions();
|
||||
}, this);
|
||||
};
|
||||
|
||||
NotificationUserStore.prototype.initNotificationPlayer = function()
|
||||
{
|
||||
if (Audio && Audio.supportedNotification)
|
||||
{
|
||||
return window.Notification && window.Notification.requestPermission ? window.Notification : null;
|
||||
};
|
||||
this.soundNotificationIsSupported(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.enableSoundNotification(false);
|
||||
this.soundNotificationIsSupported(false);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = new NotificationUserStore();
|
||||
NotificationUserStore.prototype.playSoundNotification = function(bSkipSetting)
|
||||
{
|
||||
if (Audio && Audio.supportedNotification && (bSkipSetting ? true : this.enableSoundNotification()))
|
||||
{
|
||||
Audio.playNotification();
|
||||
}
|
||||
};
|
||||
|
||||
}());
|
||||
NotificationUserStore.prototype.displayDesktopNotification = function(sImageSrc, sTitle, sText, oMessageData)
|
||||
{
|
||||
if (this.enableDesktopNotification())
|
||||
{
|
||||
var
|
||||
NotificationClass = this.notificationClass(),
|
||||
oNotification = NotificationClass ? new NotificationClass(sTitle, {
|
||||
'body': sText,
|
||||
'icon': sImageSrc
|
||||
}) : null;
|
||||
|
||||
if (oNotification)
|
||||
{
|
||||
if (oNotification.show)
|
||||
{
|
||||
oNotification.show();
|
||||
}
|
||||
|
||||
if (oMessageData)
|
||||
{
|
||||
oNotification.onclick = function() {
|
||||
|
||||
window.focus();
|
||||
|
||||
if (oMessageData.Folder && oMessageData.Uid)
|
||||
{
|
||||
Events.pub('mailbox.message.show', [oMessageData.Folder, oMessageData.Uid]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
window.setTimeout((function(oLocalNotifications) {
|
||||
return function() {
|
||||
if (oLocalNotifications.cancel)
|
||||
{
|
||||
oLocalNotifications.cancel();
|
||||
}
|
||||
else if (oLocalNotifications.close)
|
||||
{
|
||||
oLocalNotifications.close();
|
||||
}
|
||||
};
|
||||
}(oNotification)), 7000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
NotificationUserStore.prototype.populate = function()
|
||||
{
|
||||
this.enableSoundNotification(!!Settings.settingsGet('SoundNotification'));
|
||||
this.enableDesktopNotification(!!Settings.settingsGet('DesktopNotifications'));
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {*|null}
|
||||
*/
|
||||
NotificationUserStore.prototype.notificationClass = function()
|
||||
{
|
||||
return window.Notification && window.Notification.requestPermission ? window.Notification : null;
|
||||
};
|
||||
|
||||
module.exports = new NotificationUserStore();
|
||||
|
|
|
|||
|
|
@ -1,495 +1,483 @@
|
|||
(function () {
|
||||
|
||||
'use strict';
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
$ = require('$'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
$ = require('$'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
Translator = require('Common/Translator'),
|
||||
Settings = require('Storage/Settings'),
|
||||
|
||||
Translator = require('Common/Translator'),
|
||||
Settings = require('Storage/Settings'),
|
||||
Utils = require('Common/Utils');
|
||||
|
||||
Utils = require('Common/Utils')
|
||||
;
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function PgpUserStore()
|
||||
{
|
||||
this.capaOpenPGP = ko.observable(false);
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function PgpUserStore()
|
||||
this.openpgp = null;
|
||||
|
||||
this.openpgpkeys = ko.observableArray([]);
|
||||
this.openpgpKeyring = null;
|
||||
|
||||
this.openpgpkeysPublic = this.openpgpkeys.filter(function(oItem) {
|
||||
return !!(oItem && !oItem.isPrivate);
|
||||
});
|
||||
|
||||
this.openpgpkeysPrivate = this.openpgpkeys.filter(function(oItem) {
|
||||
return !!(oItem && oItem.isPrivate);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
PgpUserStore.prototype.isSupported = function()
|
||||
{
|
||||
return !!this.openpgp;
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findKeyByHex = function(aKeys, sHash)
|
||||
{
|
||||
return _.find(aKeys, function(oItem) {
|
||||
return sHash && oItem && (sHash === oItem.id || -1 < oItem.ids.indexOf(sHash));
|
||||
});
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findPublicKeyByHex = function(sHash)
|
||||
{
|
||||
return this.findKeyByHex(this.openpgpkeysPublic(), sHash);
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findPrivateKeyByHex = function(sHash)
|
||||
{
|
||||
return this.findKeyByHex(this.openpgpkeysPrivate(), sHash);
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findPublicKeysByEmail = function(sEmail)
|
||||
{
|
||||
return _.compact(_.flatten(_.map(this.openpgpkeysPublic(), function(oItem) {
|
||||
var oKey = oItem && -1 < oItem.emails.indexOf(sEmail) ? oItem : null;
|
||||
return oKey ? oKey.getNativeKeys() : [null];
|
||||
}), true));
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findPublicKeysBySigningKeyIds = function(aSigningKeyIds)
|
||||
{
|
||||
var self = this;
|
||||
return _.compact(_.flatten(_.map(aSigningKeyIds, function(oId) {
|
||||
var oKey = oId && oId.toHex ? self.findPublicKeyByHex(oId.toHex()) : null;
|
||||
return oKey ? oKey.getNativeKeys() : [null];
|
||||
}), true));
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findPrivateKeysByEncryptionKeyIds = function(aEncryptionKeyIds, aRecipients, bReturnWrapKeys)
|
||||
{
|
||||
var self = this, aResult = [];
|
||||
aResult = Utils.isArray(aEncryptionKeyIds) ? _.compact(_.flatten(_.map(aEncryptionKeyIds, function(oId) {
|
||||
var oKey = oId && oId.toHex ? self.findPrivateKeyByHex(oId.toHex()) : null;
|
||||
return oKey ? (bReturnWrapKeys ? [oKey] : oKey.getNativeKeys()) : [null];
|
||||
}), true)) : [];
|
||||
|
||||
if (0 === aResult.length && Utils.isNonEmptyArray(aRecipients))
|
||||
{
|
||||
this.capaOpenPGP = ko.observable(false);
|
||||
|
||||
this.openpgp = null;
|
||||
|
||||
this.openpgpkeys = ko.observableArray([]);
|
||||
this.openpgpKeyring = null;
|
||||
|
||||
this.openpgpkeysPublic = this.openpgpkeys.filter(function (oItem) {
|
||||
return !!(oItem && !oItem.isPrivate);
|
||||
});
|
||||
|
||||
this.openpgpkeysPrivate = this.openpgpkeys.filter(function (oItem) {
|
||||
return !!(oItem && oItem.isPrivate);
|
||||
});
|
||||
aResult = _.uniq(_.compact(_.flatten(_.map(aRecipients, function(sEmail) {
|
||||
var aKeys = sEmail ? self.findAllPrivateKeysByEmailNotNative(sEmail) : null;
|
||||
return aKeys ? (bReturnWrapKeys ? aKeys : _.flatten(_.map(aKeys, function(oKey) {return oKey.getNativeKeys();}), true)) : [null];
|
||||
}), true)), function(oKey) {return oKey.id;});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
PgpUserStore.prototype.isSupported = function ()
|
||||
{
|
||||
return !!this.openpgp;
|
||||
};
|
||||
return aResult;
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findKeyByHex = function (aKeys, sHash)
|
||||
{
|
||||
return _.find(aKeys, function (oItem) {
|
||||
return sHash && oItem && (sHash === oItem.id || -1 < oItem.ids.indexOf(sHash));
|
||||
/**
|
||||
* @param {string} sEmail
|
||||
* @returns {?}
|
||||
*/
|
||||
PgpUserStore.prototype.findPublicKeyByEmailNotNative = function(sEmail)
|
||||
{
|
||||
return _.find(this.openpgpkeysPublic(), function(oItem) {
|
||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
||||
}) || null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sEmail
|
||||
* @returns {?}
|
||||
*/
|
||||
PgpUserStore.prototype.findPrivateKeyByEmailNotNative = function(sEmail)
|
||||
{
|
||||
return _.find(this.openpgpkeysPrivate(), function(oItem) {
|
||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
||||
}) || null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sEmail
|
||||
* @returns {?}
|
||||
*/
|
||||
PgpUserStore.prototype.findAllPublicKeysByEmailNotNative = function(sEmail)
|
||||
{
|
||||
return _.filter(this.openpgpkeysPublic(), function(oItem) {
|
||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
||||
}) || null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sEmail
|
||||
* @returns {?}
|
||||
*/
|
||||
PgpUserStore.prototype.findAllPrivateKeysByEmailNotNative = function(sEmail)
|
||||
{
|
||||
return _.filter(this.openpgpkeysPrivate(), function(oItem) {
|
||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
||||
}) || null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sEmail
|
||||
* @param {string=} sPassword
|
||||
* @returns {?}
|
||||
*/
|
||||
PgpUserStore.prototype.findPrivateKeyByEmail = function(sEmail, sPassword)
|
||||
{
|
||||
var
|
||||
oPrivateKeys = [],
|
||||
oPrivateKey = null,
|
||||
oKey = _.find(this.openpgpkeysPrivate(), function(oItem) {
|
||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
||||
});
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findPublicKeyByHex = function (sHash)
|
||||
if (oKey)
|
||||
{
|
||||
return this.findKeyByHex(this.openpgpkeysPublic(), sHash);
|
||||
};
|
||||
oPrivateKeys = oKey.getNativeKeys();
|
||||
oPrivateKey = oPrivateKeys[0] || null;
|
||||
|
||||
PgpUserStore.prototype.findPrivateKeyByHex = function (sHash)
|
||||
{
|
||||
return this.findKeyByHex(this.openpgpkeysPrivate(), sHash);
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findPublicKeysByEmail = function (sEmail)
|
||||
{
|
||||
return _.compact(_.flatten(_.map(this.openpgpkeysPublic(), function (oItem) {
|
||||
var oKey = oItem && -1 < oItem.emails.indexOf(sEmail) ? oItem : null;
|
||||
return oKey ? oKey.getNativeKeys() : [null];
|
||||
}), true));
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findPublicKeysBySigningKeyIds = function (aSigningKeyIds)
|
||||
{
|
||||
var self = this;
|
||||
return _.compact(_.flatten(_.map(aSigningKeyIds, function (oId) {
|
||||
var oKey = oId && oId.toHex ? self.findPublicKeyByHex(oId.toHex()) : null;
|
||||
return oKey ? oKey.getNativeKeys() : [null];
|
||||
}), true));
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findPrivateKeysByEncryptionKeyIds = function (aEncryptionKeyIds, aRecipients, bReturnWrapKeys)
|
||||
{
|
||||
var self = this, aResult = [];
|
||||
aResult = Utils.isArray(aEncryptionKeyIds) ? _.compact(_.flatten(_.map(aEncryptionKeyIds, function (oId) {
|
||||
var oKey = oId && oId.toHex ? self.findPrivateKeyByHex(oId.toHex()) : null;
|
||||
return oKey ? (bReturnWrapKeys ? [oKey] : oKey.getNativeKeys()) : [null];
|
||||
}), true)) : [];
|
||||
|
||||
if (0 === aResult.length && Utils.isNonEmptyArray(aRecipients))
|
||||
try
|
||||
{
|
||||
aResult = _.uniq(_.compact(_.flatten(_.map(aRecipients, function (sEmail) {
|
||||
var aKeys = sEmail ? self.findAllPrivateKeysByEmailNotNative(sEmail) : null;
|
||||
return aKeys ? (bReturnWrapKeys ? aKeys : _.flatten(_.map(aKeys, function (oKey) { return oKey.getNativeKeys(); }), true)) : [null];
|
||||
}), true)), function (oKey) { return oKey.id; });
|
||||
}
|
||||
|
||||
return aResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sEmail
|
||||
* @return {?}
|
||||
*/
|
||||
PgpUserStore.prototype.findPublicKeyByEmailNotNative = function (sEmail)
|
||||
{
|
||||
return _.find(this.openpgpkeysPublic(), function (oItem) {
|
||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
||||
}) || null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sEmail
|
||||
* @return {?}
|
||||
*/
|
||||
PgpUserStore.prototype.findPrivateKeyByEmailNotNative = function (sEmail)
|
||||
{
|
||||
return _.find(this.openpgpkeysPrivate(), function (oItem) {
|
||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
||||
}) || null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sEmail
|
||||
* @return {?}
|
||||
*/
|
||||
PgpUserStore.prototype.findAllPublicKeysByEmailNotNative = function (sEmail)
|
||||
{
|
||||
return _.filter(this.openpgpkeysPublic(), function (oItem) {
|
||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
||||
}) || null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sEmail
|
||||
* @return {?}
|
||||
*/
|
||||
PgpUserStore.prototype.findAllPrivateKeysByEmailNotNative = function (sEmail)
|
||||
{
|
||||
return _.filter(this.openpgpkeysPrivate(), function (oItem) {
|
||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
||||
}) || null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sEmail
|
||||
* @param {string=} sPassword
|
||||
* @return {?}
|
||||
*/
|
||||
PgpUserStore.prototype.findPrivateKeyByEmail = function (sEmail, sPassword)
|
||||
{
|
||||
var
|
||||
oPrivateKeys = [],
|
||||
oPrivateKey = null,
|
||||
oKey = _.find(this.openpgpkeysPrivate(), function (oItem) {
|
||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
||||
})
|
||||
;
|
||||
|
||||
if (oKey)
|
||||
{
|
||||
oPrivateKeys = oKey.getNativeKeys();
|
||||
oPrivateKey = oPrivateKeys[0] || null;
|
||||
|
||||
try
|
||||
if (oPrivateKey)
|
||||
{
|
||||
if (oPrivateKey)
|
||||
oPrivateKey.decrypt(Utils.pString(sPassword));
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
oPrivateKey = null;
|
||||
}
|
||||
}
|
||||
|
||||
return oPrivateKey;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string=} sPassword
|
||||
* @returns {?}
|
||||
*/
|
||||
PgpUserStore.prototype.findSelfPrivateKey = function(sPassword)
|
||||
{
|
||||
return this.findPrivateKeyByEmail(require('Stores/User/Account').email(), sPassword);
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.decryptMessage = function(oMessage, aRecipients, fCallback)
|
||||
{
|
||||
var self = this, aPrivateKeys = [];
|
||||
if (oMessage && oMessage.getEncryptionKeyIds)
|
||||
{
|
||||
aPrivateKeys = this.findPrivateKeysByEncryptionKeyIds(oMessage.getEncryptionKeyIds(), aRecipients, true);
|
||||
if (aPrivateKeys && 0 < aPrivateKeys.length)
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/MessageOpenPgp'), [function(oDecryptedKey) {
|
||||
|
||||
if (oDecryptedKey)
|
||||
{
|
||||
oPrivateKey.decrypt(Utils.pString(sPassword));
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
oPrivateKey = null;
|
||||
}
|
||||
}
|
||||
|
||||
return oPrivateKey;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string=} sPassword
|
||||
* @return {?}
|
||||
*/
|
||||
PgpUserStore.prototype.findSelfPrivateKey = function (sPassword)
|
||||
{
|
||||
return this.findPrivateKeyByEmail(require('Stores/User/Account').email(), sPassword);
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.decryptMessage = function (oMessage, aRecipients, fCallback)
|
||||
{
|
||||
var self = this, aPrivateKeys = [];
|
||||
if (oMessage && oMessage.getEncryptionKeyIds)
|
||||
{
|
||||
aPrivateKeys = this.findPrivateKeysByEncryptionKeyIds(oMessage.getEncryptionKeyIds(), aRecipients, true);
|
||||
if (aPrivateKeys && 0 < aPrivateKeys.length)
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/MessageOpenPgp'), [function (oDecryptedKey) {
|
||||
|
||||
if (oDecryptedKey)
|
||||
{
|
||||
oMessage.decrypt(oDecryptedKey).then(function(oDecryptedMessage) {
|
||||
var oPrivateKey = null;
|
||||
if (oDecryptedMessage)
|
||||
oMessage.decrypt(oDecryptedKey).then(function(oDecryptedMessage) {
|
||||
var oPrivateKey = null;
|
||||
if (oDecryptedMessage)
|
||||
{
|
||||
oPrivateKey = self.findPrivateKeyByHex(oDecryptedKey.primaryKey.keyid.toHex());
|
||||
if (oPrivateKey)
|
||||
{
|
||||
oPrivateKey = self.findPrivateKeyByHex(oDecryptedKey.primaryKey.keyid.toHex());
|
||||
if (oPrivateKey)
|
||||
{
|
||||
self.verifyMessage(oDecryptedMessage, function (oValidKey, aSigningKeyIds) {
|
||||
fCallback(oPrivateKey, oDecryptedMessage, oValidKey || null, aSigningKeyIds || null);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
fCallback(oPrivateKey, oDecryptedMessage);
|
||||
}
|
||||
self.verifyMessage(oDecryptedMessage, function(oValidKey, aSigningKeyIds) {
|
||||
fCallback(oPrivateKey, oDecryptedMessage, oValidKey || null, aSigningKeyIds || null);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
fCallback(oPrivateKey, oDecryptedMessage);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fCallback(oPrivateKey, oDecryptedMessage);
|
||||
}
|
||||
|
||||
}, function() {
|
||||
fCallback(null, null);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
}, function() {
|
||||
fCallback(null, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
fCallback(null, null);
|
||||
}
|
||||
|
||||
}, aPrivateKeys]);
|
||||
}, aPrivateKeys]);
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
fCallback(null, null);
|
||||
fCallback(null, null);
|
||||
|
||||
return false;
|
||||
};
|
||||
return false;
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findKeyExternal = function (sEmail, fCallback)
|
||||
PgpUserStore.prototype.findKeyExternal = function(sEmail, fCallback)
|
||||
{
|
||||
if (this.openpgp.HKP && Settings.appSettingsGet('openpgpPublicKeyServer'))
|
||||
{
|
||||
if (this.openpgp.HKP && Settings.appSettingsGet('openpgpPublicKeyServer'))
|
||||
{
|
||||
var oHkp = new this.openpgp.HKP(Settings.appSettingsGet('openpgpPublicKeyServer').replace(/\/$/, ''));
|
||||
oHkp.lookup({query: sEmail}).then(function(sKey) {
|
||||
fCallback(sKey);
|
||||
}, function() {
|
||||
fCallback(null);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var oHkp = new this.openpgp.HKP(Settings.appSettingsGet('openpgpPublicKeyServer').replace(/\/$/, ''));
|
||||
oHkp.lookup({query: sEmail}).then(function(sKey) {
|
||||
fCallback(sKey);
|
||||
}, function() {
|
||||
fCallback(null);
|
||||
}
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.verifyMessage = function (oMessage, fCallback)
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var oValid = null, aResult = [], aPublicKeys = [], aSigningKeyIds = [];
|
||||
if (oMessage && oMessage.getSigningKeyIds)
|
||||
fCallback(null);
|
||||
}
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.verifyMessage = function(oMessage, fCallback)
|
||||
{
|
||||
var oValid = null, aResult = [], aPublicKeys = [], aSigningKeyIds = [];
|
||||
if (oMessage && oMessage.getSigningKeyIds)
|
||||
{
|
||||
aSigningKeyIds = oMessage.getSigningKeyIds();
|
||||
if (aSigningKeyIds && 0 < aSigningKeyIds.length)
|
||||
{
|
||||
aSigningKeyIds = oMessage.getSigningKeyIds();
|
||||
if (aSigningKeyIds && 0 < aSigningKeyIds.length)
|
||||
{
|
||||
// this.findKeyExternal('support@rainloop.net', function(key) {
|
||||
// console.log(key);
|
||||
// });
|
||||
|
||||
aPublicKeys = this.findPublicKeysBySigningKeyIds(aSigningKeyIds);
|
||||
if (aPublicKeys && 0 < aPublicKeys.length)
|
||||
aPublicKeys = this.findPublicKeysBySigningKeyIds(aSigningKeyIds);
|
||||
if (aPublicKeys && 0 < aPublicKeys.length)
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
aResult = oMessage.verify(aPublicKeys);
|
||||
oValid = _.find(_.isArray(aResult) ? aResult : [], function (oItem) {
|
||||
return oItem && oItem.valid && oItem.keyid;
|
||||
});
|
||||
aResult = oMessage.verify(aPublicKeys);
|
||||
oValid = _.find(_.isArray(aResult) ? aResult : [], function(oItem) {
|
||||
return oItem && oItem.valid && oItem.keyid;
|
||||
});
|
||||
|
||||
if (oValid && oValid.keyid && oValid.keyid && oValid.keyid.toHex)
|
||||
{
|
||||
fCallback(this.findPublicKeyByHex(oValid.keyid.toHex()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
if (oValid && oValid.keyid && oValid.keyid && oValid.keyid.toHex)
|
||||
{
|
||||
Utils.log(e);
|
||||
fCallback(this.findPublicKeyByHex(oValid.keyid.toHex()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
fCallback(null, aSigningKeyIds);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
fCallback(null);
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {*} mDom
|
||||
*/
|
||||
PgpUserStore.prototype.controlsHelper = function (mDom, oVerControl, bSuccess, sTitle, sText)
|
||||
{
|
||||
if (bSuccess)
|
||||
{
|
||||
mDom.removeClass('error').addClass('success').attr('title', sTitle);
|
||||
oVerControl.removeClass('error').addClass('success').attr('title', sTitle);
|
||||
}
|
||||
else
|
||||
{
|
||||
mDom.removeClass('success').addClass('error').attr('title', sTitle);
|
||||
oVerControl.removeClass('success').addClass('error').attr('title', sTitle);
|
||||
}
|
||||
|
||||
if (!Utils.isUnd(sText))
|
||||
{
|
||||
mDom.text(Utils.trim(sText.replace(/(\u200C|\u0002)/g, '')));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @static
|
||||
*/
|
||||
PgpUserStore.domControlEncryptedClickHelper = function (self, mDom, sArmoredMessage, aRecipients)
|
||||
{
|
||||
return function () {
|
||||
|
||||
var oMessage = null, $this = $(this);
|
||||
if ($this.hasClass('success'))
|
||||
{
|
||||
return false;
|
||||
catch (e)
|
||||
{
|
||||
Utils.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
oMessage = self.openpgp.message.readArmored(sArmoredMessage);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
Utils.log(e);
|
||||
}
|
||||
|
||||
if (oMessage && oMessage.getText && oMessage.verify && oMessage.decrypt)
|
||||
{
|
||||
self.decryptMessage(oMessage, aRecipients, function (oValidPrivateKey, oDecryptedMessage, oValidPublicKey, aSigningKeyIds) {
|
||||
|
||||
if (oDecryptedMessage)
|
||||
{
|
||||
if (oValidPublicKey)
|
||||
{
|
||||
self.controlsHelper(mDom, $this, true, Translator.i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||
'USER': oValidPublicKey.user + ' (' + oValidPublicKey.id + ')'
|
||||
}), oDecryptedMessage.getText());
|
||||
}
|
||||
else if (oValidPrivateKey)
|
||||
{
|
||||
var
|
||||
aKeyIds = Utils.isNonEmptyArray(aSigningKeyIds) ? aSigningKeyIds : null,
|
||||
sAdditional = aKeyIds ? _.compact(_.map(aKeyIds, function (oItem) {
|
||||
return oItem && oItem.toHex ? oItem.toHex() : null;
|
||||
})).join(', ') : ''
|
||||
;
|
||||
|
||||
self.controlsHelper(mDom, $this, false,
|
||||
Translator.i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') +
|
||||
(sAdditional ? ' (' + sAdditional + ')' : ''),
|
||||
oDecryptedMessage.getText());
|
||||
}
|
||||
else
|
||||
{
|
||||
self.controlsHelper(mDom, $this, false,
|
||||
Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
self.controlsHelper(mDom, $this, false,
|
||||
Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
self.controlsHelper(mDom, $this, false, Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
fCallback(null, aSigningKeyIds);
|
||||
return false;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @static
|
||||
*/
|
||||
PgpUserStore.domControlSignedClickHelper = function (self, mDom, sArmoredMessage)
|
||||
fCallback(null);
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {*} mDom
|
||||
*/
|
||||
PgpUserStore.prototype.controlsHelper = function(mDom, oVerControl, bSuccess, sTitle, sText)
|
||||
{
|
||||
if (bSuccess)
|
||||
{
|
||||
return function () {
|
||||
mDom.removeClass('error').addClass('success').attr('title', sTitle);
|
||||
oVerControl.removeClass('error').addClass('success').attr('title', sTitle);
|
||||
}
|
||||
else
|
||||
{
|
||||
mDom.removeClass('success').addClass('error').attr('title', sTitle);
|
||||
oVerControl.removeClass('success').addClass('error').attr('title', sTitle);
|
||||
}
|
||||
|
||||
var oMessage = null, $this = $(this);
|
||||
if ($this.hasClass('success') || $this.hasClass('error'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!Utils.isUnd(sText))
|
||||
{
|
||||
mDom.text(Utils.trim(sText.replace(/(\u200C|\u0002)/g, '')));
|
||||
}
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
oMessage = self.openpgp.cleartext.readArmored(sArmoredMessage);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
Utils.log(e);
|
||||
}
|
||||
/**
|
||||
* @static
|
||||
*/
|
||||
PgpUserStore.domControlEncryptedClickHelper = function(store, mDom, sArmoredMessage, aRecipients)
|
||||
{
|
||||
return function() {
|
||||
|
||||
if (oMessage && oMessage.getText && oMessage.verify)
|
||||
{
|
||||
self.verifyMessage(oMessage, function (oValidKey, aSigningKeyIds) {
|
||||
if (oValidKey)
|
||||
var oMessage = null, $this = $(this);
|
||||
|
||||
if ($this.hasClass('success'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
oMessage = store.openpgp.message.readArmored(sArmoredMessage);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
Utils.log(e);
|
||||
}
|
||||
|
||||
if (oMessage && oMessage.getText && oMessage.verify && oMessage.decrypt)
|
||||
{
|
||||
store.decryptMessage(oMessage, aRecipients, function(oValidPrivateKey, oDecryptedMessage, oValidPublicKey, aSigningKeyIds) {
|
||||
|
||||
if (oDecryptedMessage)
|
||||
{
|
||||
if (oValidPublicKey)
|
||||
{
|
||||
self.controlsHelper(mDom, $this, true, Translator.i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||
'USER': oValidKey.user + ' (' + oValidKey.id + ')'
|
||||
}), oMessage.getText());
|
||||
store.controlsHelper(mDom, $this, true, Translator.i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||
'USER': oValidPublicKey.user + ' (' + oValidPublicKey.id + ')'
|
||||
}), oDecryptedMessage.getText());
|
||||
}
|
||||
else
|
||||
else if (oValidPrivateKey)
|
||||
{
|
||||
var
|
||||
aKeyIds = Utils.isNonEmptyArray(aSigningKeyIds) ? aSigningKeyIds : null,
|
||||
sAdditional = aKeyIds ? _.compact(_.map(aKeyIds, function (oItem) {
|
||||
sAdditional = aKeyIds ? _.compact(_.map(aKeyIds, function(oItem) {
|
||||
return oItem && oItem.toHex ? oItem.toHex() : null;
|
||||
})).join(', ') : ''
|
||||
;
|
||||
})).join(', ') : '';
|
||||
|
||||
self.controlsHelper(mDom, $this, false,
|
||||
store.controlsHelper(mDom, $this, false,
|
||||
Translator.i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') +
|
||||
(sAdditional ? ' (' + sAdditional + ')' : ''));
|
||||
(sAdditional ? ' (' + sAdditional + ')' : ''),
|
||||
oDecryptedMessage.getText());
|
||||
}
|
||||
});
|
||||
else
|
||||
{
|
||||
store.controlsHelper(mDom, $this, false,
|
||||
Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
store.controlsHelper(mDom, $this, false,
|
||||
Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
store.controlsHelper(mDom, $this, false, Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @static
|
||||
*/
|
||||
PgpUserStore.domControlSignedClickHelper = function(store, mDom, sArmoredMessage)
|
||||
{
|
||||
return function() {
|
||||
|
||||
var oMessage = null, $this = $(this);
|
||||
if ($this.hasClass('success') || $this.hasClass('error'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
oMessage = store.openpgp.cleartext.readArmored(sArmoredMessage);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
Utils.log(e);
|
||||
}
|
||||
|
||||
if (oMessage && oMessage.getText && oMessage.verify)
|
||||
{
|
||||
store.verifyMessage(oMessage, function(oValidKey, aSigningKeyIds) {
|
||||
if (oValidKey)
|
||||
{
|
||||
store.controlsHelper(mDom, $this, true, Translator.i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||
'USER': oValidKey.user + ' (' + oValidKey.id + ')'
|
||||
}), oMessage.getText());
|
||||
}
|
||||
else
|
||||
{
|
||||
var
|
||||
aKeyIds = Utils.isNonEmptyArray(aSigningKeyIds) ? aSigningKeyIds : null,
|
||||
sAdditional = aKeyIds ? _.compact(_.map(aKeyIds, function(oItem) {
|
||||
return oItem && oItem.toHex ? oItem.toHex() : null;
|
||||
})).join(', ') : '';
|
||||
|
||||
store.controlsHelper(mDom, $this, false,
|
||||
Translator.i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') +
|
||||
(sAdditional ? ' (' + sAdditional + ')' : ''));
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
store.controlsHelper(mDom, $this, false, Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {*} mDom
|
||||
* @param {MessageModel} oRainLoopMessage
|
||||
*/
|
||||
PgpUserStore.prototype.initMessageBodyControls = function(mDom, oRainLoopMessage)
|
||||
{
|
||||
if (mDom && !mDom.hasClass('inited'))
|
||||
{
|
||||
mDom.addClass('inited');
|
||||
|
||||
var
|
||||
bEncrypted = mDom.hasClass('encrypted'),
|
||||
bSigned = mDom.hasClass('signed'),
|
||||
oVerControl = null,
|
||||
aRecipients = oRainLoopMessage ? oRainLoopMessage.getEmails(['from', 'to', 'cc']) : [],
|
||||
sData = '';
|
||||
|
||||
if (bEncrypted || bSigned)
|
||||
{
|
||||
sData = mDom.text();
|
||||
mDom.data('openpgp-original', sData);
|
||||
|
||||
if (bEncrypted)
|
||||
{
|
||||
oVerControl = $('<div class="b-openpgp-control"><i class="icon-lock"></i></div>')
|
||||
.attr('title', Translator.i18n('MESSAGE/PGP_ENCRYPTED_MESSAGE_DESC'))
|
||||
.on('click', PgpUserStore.domControlEncryptedClickHelper(this, mDom, sData, aRecipients));
|
||||
}
|
||||
else if (bSigned)
|
||||
{
|
||||
oVerControl = $('<div class="b-openpgp-control"><i class="icon-lock"></i></div>')
|
||||
.attr('title', Translator.i18n('MESSAGE/PGP_SIGNED_MESSAGE_DESC'))
|
||||
.on('click', PgpUserStore.domControlSignedClickHelper(this, mDom, sData));
|
||||
}
|
||||
|
||||
self.controlsHelper(mDom, $this, false, Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {*} mDom
|
||||
* @param {MessageModel} oRainLoopMessage
|
||||
*/
|
||||
PgpUserStore.prototype.initMessageBodyControls = function (mDom, oRainLoopMessage)
|
||||
{
|
||||
if (mDom && !mDom.hasClass('inited'))
|
||||
{
|
||||
mDom.addClass('inited');
|
||||
|
||||
var
|
||||
bEncrypted = mDom.hasClass('encrypted'),
|
||||
bSigned = mDom.hasClass('signed'),
|
||||
oVerControl = null,
|
||||
aRecipients = oRainLoopMessage ? oRainLoopMessage.getEmails(['from', 'to', 'cc']) : [],
|
||||
sData = ''
|
||||
;
|
||||
|
||||
if (bEncrypted || bSigned)
|
||||
if (oVerControl)
|
||||
{
|
||||
sData = mDom.text();
|
||||
mDom.data('openpgp-original', sData);
|
||||
|
||||
if (bEncrypted)
|
||||
{
|
||||
oVerControl = $('<div class="b-openpgp-control"><i class="icon-lock"></i></div>')
|
||||
.attr('title', Translator.i18n('MESSAGE/PGP_ENCRYPTED_MESSAGE_DESC'))
|
||||
.on('click', PgpUserStore.domControlEncryptedClickHelper(this, mDom, sData, aRecipients))
|
||||
;
|
||||
}
|
||||
else if (bSigned)
|
||||
{
|
||||
oVerControl = $('<div class="b-openpgp-control"><i class="icon-lock"></i></div>')
|
||||
.attr('title', Translator.i18n('MESSAGE/PGP_SIGNED_MESSAGE_DESC'))
|
||||
.on('click', PgpUserStore.domControlSignedClickHelper(this, mDom, sData))
|
||||
;
|
||||
}
|
||||
|
||||
if (oVerControl)
|
||||
{
|
||||
mDom.before(oVerControl).before('<div></div>');
|
||||
}
|
||||
mDom.before(oVerControl).before('<div></div>');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = new PgpUserStore();
|
||||
|
||||
}());
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = new PgpUserStore();
|
||||
|
|
|
|||
|
|
@ -1,43 +1,35 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
window = require('window'),
|
||||
ko = require('ko');
|
||||
|
||||
'use strict';
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function QuotaUserStore()
|
||||
{
|
||||
this.quota = ko.observable(0);
|
||||
this.usage = ko.observable(0);
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
ko = require('ko')
|
||||
;
|
||||
this.percentage = ko.computed(function() {
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function QuotaUserStore()
|
||||
{
|
||||
this.quota = ko.observable(0);
|
||||
this.usage = ko.observable(0);
|
||||
var
|
||||
iQuota = this.quota(),
|
||||
iUsed = this.usage();
|
||||
|
||||
this.percentage = ko.computed(function () {
|
||||
return 0 < iQuota ? window.Math.ceil((iUsed / iQuota) * 100) : 0;
|
||||
|
||||
var
|
||||
iQuota = this.quota(),
|
||||
iUsed = this.usage()
|
||||
;
|
||||
}, this);
|
||||
}
|
||||
|
||||
return 0 < iQuota ? window.Math.ceil((iUsed / iQuota) * 100) : 0;
|
||||
/**
|
||||
* @param {number} iQuota
|
||||
* @param {number} iUsage
|
||||
*/
|
||||
QuotaUserStore.prototype.populateData = function(iQuota, iUsage)
|
||||
{
|
||||
this.quota(iQuota * 1024);
|
||||
this.usage(iUsage * 1024);
|
||||
};
|
||||
|
||||
}, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} iQuota
|
||||
* @param {number} iUsage
|
||||
*/
|
||||
QuotaUserStore.prototype.populateData = function(iQuota, iUsage)
|
||||
{
|
||||
this.quota(iQuota * 1024);
|
||||
this.usage(iUsage * 1024);
|
||||
};
|
||||
|
||||
module.exports = new QuotaUserStore();
|
||||
|
||||
}());
|
||||
module.exports = new QuotaUserStore();
|
||||
|
|
|
|||
|
|
@ -1,100 +1,93 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
window = require('window'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Consts = require('Common/Consts'),
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
Events = require('Common/Events'),
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
ko = require('ko'),
|
||||
Settings = require('Storage/Settings');
|
||||
|
||||
Consts = require('Common/Consts'),
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
Events = require('Common/Events'),
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function SettingsUserStore()
|
||||
{
|
||||
this.iAutoLogoutTimer = 0;
|
||||
|
||||
Settings = require('Storage/Settings')
|
||||
;
|
||||
this.layout = ko.observable(Enums.Layout.SidePreview)
|
||||
.extend({'limitedList': [
|
||||
Enums.Layout.SidePreview, Enums.Layout.BottomPreview, Enums.Layout.NoPreview
|
||||
]});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function SettingsUserStore()
|
||||
{
|
||||
this.iAutoLogoutTimer = 0;
|
||||
this.editorDefaultType = ko.observable(Enums.EditorDefaultType.Html)
|
||||
.extend({'limitedList': [
|
||||
Enums.EditorDefaultType.Html, Enums.EditorDefaultType.Plain,
|
||||
Enums.EditorDefaultType.HtmlForced, Enums.EditorDefaultType.PlainForced
|
||||
]});
|
||||
|
||||
this.layout = ko.observable(Enums.Layout.SidePreview)
|
||||
.extend({'limitedList': [
|
||||
Enums.Layout.SidePreview, Enums.Layout.BottomPreview, Enums.Layout.NoPreview
|
||||
]});
|
||||
this.messagesPerPage = ko.observable(Consts.MESSAGES_PER_PAGE)
|
||||
.extend({'limitedList': Consts.MESSAGES_PER_PAGE_VALUES});
|
||||
|
||||
this.editorDefaultType = ko.observable(Enums.EditorDefaultType.Html)
|
||||
.extend({'limitedList': [
|
||||
Enums.EditorDefaultType.Html, Enums.EditorDefaultType.Plain,
|
||||
Enums.EditorDefaultType.HtmlForced, Enums.EditorDefaultType.PlainForced
|
||||
]});
|
||||
this.showImages = ko.observable(false);
|
||||
this.useCheckboxesInList = ko.observable(true);
|
||||
this.useThreads = ko.observable(false);
|
||||
this.replySameFolder = ko.observable(false);
|
||||
|
||||
this.messagesPerPage = ko.observable(Consts.MESSAGES_PER_PAGE)
|
||||
.extend({'limitedList': Consts.MESSAGES_PER_PAGE_VALUES});
|
||||
this.autoLogout = ko.observable(30);
|
||||
|
||||
this.showImages = ko.observable(false);
|
||||
this.useCheckboxesInList = ko.observable(true);
|
||||
this.useThreads = ko.observable(false);
|
||||
this.replySameFolder = ko.observable(false);
|
||||
this.computers();
|
||||
this.subscribers();
|
||||
}
|
||||
|
||||
this.autoLogout = ko.observable(30);
|
||||
SettingsUserStore.prototype.computers = function()
|
||||
{
|
||||
this.usePreviewPane = ko.computed(function() {
|
||||
return Enums.Layout.NoPreview !== this.layout();
|
||||
}, this);
|
||||
};
|
||||
|
||||
this.computers();
|
||||
this.subscribers();
|
||||
}
|
||||
SettingsUserStore.prototype.subscribers = function()
|
||||
{
|
||||
this.layout.subscribe(function(nValue) {
|
||||
|
||||
SettingsUserStore.prototype.computers = function ()
|
||||
{
|
||||
this.usePreviewPane = ko.computed(function () {
|
||||
return Enums.Layout.NoPreview !== this.layout();
|
||||
}, this);
|
||||
};
|
||||
Globals.$html.toggleClass('rl-no-preview-pane', Enums.Layout.NoPreview === nValue);
|
||||
Globals.$html.toggleClass('rl-side-preview-pane', Enums.Layout.SidePreview === nValue);
|
||||
Globals.$html.toggleClass('rl-bottom-preview-pane', Enums.Layout.BottomPreview === nValue);
|
||||
|
||||
SettingsUserStore.prototype.subscribers = function ()
|
||||
{
|
||||
this.layout.subscribe(function (nValue) {
|
||||
Events.pub('layout', [nValue]);
|
||||
});
|
||||
};
|
||||
|
||||
Globals.$html.toggleClass('rl-no-preview-pane', Enums.Layout.NoPreview === nValue);
|
||||
Globals.$html.toggleClass('rl-side-preview-pane', Enums.Layout.SidePreview === nValue);
|
||||
Globals.$html.toggleClass('rl-bottom-preview-pane', Enums.Layout.BottomPreview === nValue);
|
||||
SettingsUserStore.prototype.populate = function()
|
||||
{
|
||||
this.layout(Utils.pInt(Settings.settingsGet('Layout')));
|
||||
this.editorDefaultType(Settings.settingsGet('EditorDefaultType'));
|
||||
|
||||
Events.pub('layout', [nValue]);
|
||||
});
|
||||
};
|
||||
this.autoLogout(Utils.pInt(Settings.settingsGet('AutoLogout')));
|
||||
this.messagesPerPage(Settings.settingsGet('MPP'));
|
||||
|
||||
SettingsUserStore.prototype.populate = function ()
|
||||
{
|
||||
this.layout(Utils.pInt(Settings.settingsGet('Layout')));
|
||||
this.editorDefaultType(Settings.settingsGet('EditorDefaultType'));
|
||||
this.showImages(!!Settings.settingsGet('ShowImages'));
|
||||
this.useCheckboxesInList(!!Settings.settingsGet('UseCheckboxesInList'));
|
||||
this.useThreads(!!Settings.settingsGet('UseThreads'));
|
||||
this.replySameFolder(!!Settings.settingsGet('ReplySameFolder'));
|
||||
|
||||
this.autoLogout(Utils.pInt(Settings.settingsGet('AutoLogout')));
|
||||
this.messagesPerPage(Settings.settingsGet('MPP'));
|
||||
var self = this;
|
||||
|
||||
this.showImages(!!Settings.settingsGet('ShowImages'));
|
||||
this.useCheckboxesInList(!!Settings.settingsGet('UseCheckboxesInList'));
|
||||
this.useThreads(!!Settings.settingsGet('UseThreads'));
|
||||
this.replySameFolder(!!Settings.settingsGet('ReplySameFolder'));
|
||||
Events.sub('rl.auto-logout-refresh', function() {
|
||||
window.clearTimeout(self.iAutoLogoutTimer);
|
||||
if (0 < self.autoLogout() && !Settings.settingsGet('AccountSignMe'))
|
||||
{
|
||||
self.iAutoLogoutTimer = window.setTimeout(function() {
|
||||
Events.pub('rl.auto-logout');
|
||||
}, self.autoLogout() * 1000 * 60);
|
||||
}
|
||||
});
|
||||
|
||||
var self = this;
|
||||
Events.pub('rl.auto-logout-refresh');
|
||||
};
|
||||
|
||||
Events.sub('rl.auto-logout-refresh', function () {
|
||||
window.clearTimeout(self.iAutoLogoutTimer);
|
||||
if (0 < self.autoLogout() && !Settings.settingsGet('AccountSignMe'))
|
||||
{
|
||||
self.iAutoLogoutTimer = window.setTimeout(function () {
|
||||
Events.pub('rl.auto-logout');
|
||||
}, self.autoLogout() * 1000 * 60);
|
||||
}
|
||||
});
|
||||
|
||||
Events.pub('rl.auto-logout-refresh');
|
||||
};
|
||||
|
||||
module.exports = new SettingsUserStore();
|
||||
|
||||
}());
|
||||
module.exports = new SettingsUserStore();
|
||||
|
|
|
|||
|
|
@ -1,49 +1,42 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko');
|
||||
|
||||
'use strict';
|
||||
// Remote = require('Remote/User/Ajax');
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko')
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function TemplateUserStore()
|
||||
{
|
||||
this.templates = ko.observableArray([]);
|
||||
this.templates.loading = ko.observable(false).extend({'throttle': 100});
|
||||
|
||||
// Remote = require('Remote/User/Ajax')
|
||||
;
|
||||
this.templatesNames = ko.observableArray([]).extend({'throttle': 1000});
|
||||
this.templatesNames.skipFirst = true;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function TemplateUserStore()
|
||||
{
|
||||
this.templates = ko.observableArray([]);
|
||||
this.templates.loading = ko.observable(false).extend({'throttle': 100});
|
||||
this.subscribers();
|
||||
}
|
||||
|
||||
this.templatesNames = ko.observableArray([]).extend({'throttle': 1000});
|
||||
this.templatesNames.skipFirst = true;
|
||||
TemplateUserStore.prototype.subscribers = function()
|
||||
{
|
||||
this.templates.subscribe(function(aList) {
|
||||
this.templatesNames(_.compact(_.map(aList, function(oItem) {
|
||||
return oItem ? oItem.name : null;
|
||||
})));
|
||||
}, this);
|
||||
|
||||
this.subscribers();
|
||||
}
|
||||
// this.templatesNames.subscribe(function(aList) {
|
||||
// if (this.templatesNames.skipFirst)
|
||||
// {
|
||||
// this.templatesNames.skipFirst = false;
|
||||
// }
|
||||
// else if (aList && 1 < aList.length)
|
||||
// {
|
||||
// Remote.templatesSortOrder(null, aList);
|
||||
// }
|
||||
// }, this);
|
||||
};
|
||||
|
||||
TemplateUserStore.prototype.subscribers = function ()
|
||||
{
|
||||
this.templates.subscribe(function (aList) {
|
||||
this.templatesNames(_.compact(_.map(aList, function (oItem) {
|
||||
return oItem ? oItem.name : null;
|
||||
})));
|
||||
}, this);
|
||||
|
||||
// this.templatesNames.subscribe(function (aList) {
|
||||
// if (this.templatesNames.skipFirst)
|
||||
// {
|
||||
// this.templatesNames.skipFirst = false;
|
||||
// }
|
||||
// else if (aList && 1 < aList.length)
|
||||
// {
|
||||
// Remote.templatesSortOrder(null, aList);
|
||||
// }
|
||||
// }, this);
|
||||
};
|
||||
|
||||
module.exports = new TemplateUserStore();
|
||||
|
||||
}());
|
||||
module.exports = new TemplateUserStore();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue