From 286ab567af0cca8f762f8c15f51225baf8d6a237 Mon Sep 17 00:00:00 2001 From: RainLoop Team Date: Tue, 3 Feb 2015 03:58:58 +0400 Subject: [PATCH] Code refactoring --- dev/App/Admin.js | 20 +- dev/App/User.js | 125 +++++++------ dev/Common/Enums.js | 19 +- dev/Model/Message.js | 21 +-- dev/Screen/User/MailBox.js | 6 +- dev/Settings/Admin/Domains.js | 2 +- dev/Settings/Admin/Packages.js | 4 +- dev/Settings/Admin/Plugins.js | 12 +- dev/Settings/User/ChangePassword.js | 2 +- dev/Settings/User/Filters.js | 2 +- dev/Settings/User/General.js | 2 +- dev/Settings/User/Identities.js | 30 +-- dev/Settings/User/Identity.js | 22 ++- dev/Settings/User/OpenPgp.js | 18 +- dev/Settings/User/Security.js | 8 +- dev/Storage/User/Data.js | 140 ++------------ dev/Storage/User/Remote.js | 19 +- dev/Storage/User/Spooler.js | 20 -- dev/Stores/Admin/App.js | 12 +- dev/Stores/Admin/Domain.js | 4 +- dev/Stores/Admin/Package.js | 8 +- dev/Stores/Admin/Plugin.js | 6 +- dev/Stores/App.js | 42 +++++ dev/Stores/User/Account.js | 35 +++- dev/Stores/User/App.js | 39 ++-- dev/Stores/User/Filter.js | 6 +- dev/Stores/User/Folder.js | 75 ++++++++ dev/Stores/User/Pgp.js | 174 ++++++++++-------- dev/Styles/Animations.less | 14 +- dev/Styles/_BootstrapFix.less | 3 +- dev/View/Admin/Settings/Pane.js | 6 +- dev/View/Popup/AddOpenPgpKey.js | 4 +- dev/View/Popup/Compose.js | 41 +++-- dev/View/Popup/ComposeOpenPgp.js | 6 +- dev/View/Popup/Contacts.js | 4 +- dev/View/Popup/FolderSystem.js | 53 +++--- dev/View/Popup/Identity.js | 4 +- dev/View/Popup/NewOpenPgpKey.js | 6 +- dev/View/User/AbstractSystemDropDown.js | 4 +- dev/View/User/Login.js | 4 +- dev/View/User/MailBox/FolderList.js | 4 +- dev/View/User/MailBox/MessageList.js | 25 +-- dev/View/User/MailBox/MessageView.js | 26 +-- package.json | 4 +- .../0.0.0/app/libraries/RainLoop/Actions.php | 82 ++++++--- .../Views/Admin/AdminSettingsLicensing.html | 4 +- .../0.0.0/app/templates/Views/User/Login.html | 2 +- .../templates/Views/User/SettingsGeneral.html | 2 +- .../Views/User/SettingsSecurity.html | 13 +- .../templates/Views/User/SystemDropDown.html | 8 +- rainloop/v/0.0.0/include.php | 1 + rainloop/v/0.0.0/themes/RainDrops/styles.less | 4 +- vendors/bootstrap/js/bootstrap.min.js | 2 +- 53 files changed, 618 insertions(+), 581 deletions(-) delete mode 100644 dev/Storage/User/Spooler.js create mode 100644 dev/Stores/App.js create mode 100644 dev/Stores/User/Folder.js diff --git a/dev/App/Admin.js b/dev/App/Admin.js index e937e5631..952bc5987 100644 --- a/dev/App/Admin.js +++ b/dev/App/Admin.js @@ -44,10 +44,10 @@ AdminApp.prototype.reloadDomainList = function () { - DomainStore.collection.loading(true); + DomainStore.domains.loading(true); Remote.domainList(function (sResult, oData) { - DomainStore.collection.loading(false); + DomainStore.domains.loading(false); if (Enums.StorageResultType.Success === sResult && oData && oData.Result) { var aList = _.map(oData.Result, function (bEnabled, sName) { @@ -58,18 +58,18 @@ }; }, this); - DomainStore.collection(aList); + DomainStore.domains(aList); } }); }; AdminApp.prototype.reloadPluginList = function () { - PluginStore.collection.loading(true); + PluginStore.plugins.loading(true); Remote.pluginList(function (sResult, oData) { - PluginStore.collection.loading(false); + PluginStore.plugins.loading(false); if (Enums.StorageResultType.Success === sResult && oData && oData.Result) { @@ -81,19 +81,19 @@ }; }, this); - PluginStore.collection(aList); + PluginStore.plugins(aList); } }); }; AdminApp.prototype.reloadPackagesList = function () { - PackageStore.collection.loading(true); + PackageStore.packages.loading(true); PackageStore.packagesReal(true); Remote.packagesList(function (sResult, oData) { - PackageStore.collection.loading(false); + PackageStore.packages.loading(false); if (Enums.StorageResultType.Success === sResult && oData && oData.Result) { @@ -105,7 +105,7 @@ aLoading = {} ; - _.each(PackageStore.collection(), function (oItem) { + _.each(PackageStore.packages(), function (oItem) { if (oItem && oItem['loading']()) { aLoading[oItem['file']] = oItem; @@ -124,7 +124,7 @@ })); } - PackageStore.collection(aList); + PackageStore.packages(aList); } else { diff --git a/dev/App/User.js b/dev/App/User.js index ace9abbc6..ace3b45f5 100644 --- a/dev/App/User.js +++ b/dev/App/User.js @@ -22,9 +22,12 @@ kn = require('Knoin/Knoin'), SocialStore = require('Stores/Social'), + AppStore = require('Stores/User/App'), SettingsStore = require('Stores/User/Settings'), AccountStore = require('Stores/User/Account'), IdentityStore = require('Stores/User/Identity'), + FolderStore = require('Stores/User/Folder'), + PgpStore = require('Stores/User/Pgp'), Local = require('Storage/Client'), Settings = require('Storage/Settings'), @@ -237,7 +240,7 @@ { var self = this, - sSpamFolder = Data.spamFolder() + sSpamFolder = FolderStore.spamFolder() ; _.each(this.oMoveCache, function (oItem) { @@ -340,18 +343,18 @@ switch (iDeleteType) { case Enums.FolderType.Spam: - oMoveFolder = Cache.getFolderFromCacheList(Data.spamFolder()); + oMoveFolder = Cache.getFolderFromCacheList(FolderStore.spamFolder()); nSetSystemFoldersNotification = Enums.SetSystemFoldersNotification.Spam; break; case Enums.FolderType.NotSpam: oMoveFolder = Cache.getFolderFromCacheList(Cache.getFolderInboxName()); break; case Enums.FolderType.Trash: - oMoveFolder = Cache.getFolderFromCacheList(Data.trashFolder()); + oMoveFolder = Cache.getFolderFromCacheList(FolderStore.trashFolder()); nSetSystemFoldersNotification = Enums.SetSystemFoldersNotification.Trash; break; case Enums.FolderType.Archive: - oMoveFolder = Cache.getFolderFromCacheList(Data.archiveFolder()); + oMoveFolder = Cache.getFolderFromCacheList(FolderStore.archiveFolder()); nSetSystemFoldersNotification = Enums.SetSystemFoldersNotification.Archive; break; } @@ -359,9 +362,9 @@ bUseFolder = Utils.isUnd(bUseFolder) ? true : !!bUseFolder; if (bUseFolder) { - if ((Enums.FolderType.Spam === iDeleteType && Consts.Values.UnuseOptionValue === Data.spamFolder()) || - (Enums.FolderType.Trash === iDeleteType && Consts.Values.UnuseOptionValue === Data.trashFolder()) || - (Enums.FolderType.Archive === iDeleteType && Consts.Values.UnuseOptionValue === Data.archiveFolder())) + if ((Enums.FolderType.Spam === iDeleteType && Consts.Values.UnuseOptionValue === FolderStore.spamFolder()) || + (Enums.FolderType.Trash === iDeleteType && Consts.Values.UnuseOptionValue === FolderStore.trashFolder()) || + (Enums.FolderType.Archive === iDeleteType && Consts.Values.UnuseOptionValue === FolderStore.archiveFolder())) { bUseFolder = false; } @@ -372,7 +375,7 @@ kn.showScreenPopup(require('View/Popup/FolderSystem'), [nSetSystemFoldersNotification]); } else if (!bUseFolder || (Enums.FolderType.Trash === iDeleteType && - (sFromFolderFullNameRaw === Data.spamFolder() || sFromFolderFullNameRaw === Data.trashFolder()))) + (sFromFolderFullNameRaw === FolderStore.spamFolder() || sFromFolderFullNameRaw === FolderStore.trashFolder()))) { kn.showScreenPopup(require('View/Popup/Ask'), [Translator.i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'), function () { @@ -450,12 +453,12 @@ AppUser.prototype.reloadOpenPgpKeys = function () { - if (Data.capaOpenPGP()) + if (PgpStore.capaOpenPGP()) { var aKeys = [], oEmail = new EmailModel(), - oOpenpgpKeyring = Data.openpgpKeyring, + oOpenpgpKeyring = PgpStore.openpgpKeyring, oOpenpgpKeys = oOpenpgpKeyring ? oOpenpgpKeyring.getAllKeys() : [] ; @@ -487,39 +490,40 @@ } }); - Utils.delegateRunOnDestroy(Data.openpgpkeys()); - Data.openpgpkeys(aKeys); + Utils.delegateRunOnDestroy(PgpStore.openpgpkeys()); + PgpStore.openpgpkeys(aKeys); } }; AppUser.prototype.accountsCounts = function () { - AccountStore.accounts.loading(true); - - Remote.accountsCounts(function (sResult, oData) { - - AccountStore.accounts.loading(false); - - if (Enums.StorageResultType.Success === sResult && oData.Result && oData.Result['Counts']) - { - var - sEmail = Data.accountEmail(), - aAcounts = AccountStore.accounts() - ; - - _.each(oData.Result['Counts'], function (oItem) { - - var oAccount = _.find(aAcounts, function (oAccount) { - return oAccount && oItem[0] === oAccount.email && sEmail !== oAccount.email; - }); - - if (oAccount) - { - oAccount.count(Utils.pInt(oItem[1])); - } - }); - } - }); + return false; +// AccountStore.accounts.loading(true); +// +// Remote.accountsCounts(function (sResult, oData) { +// +// AccountStore.accounts.loading(false); +// +// if (Enums.StorageResultType.Success === sResult && oData.Result && oData.Result['Counts']) +// { +// var +// sEmail = AccountStore.email(), +// aAcounts = AccountStore.accounts() +// ; +// +// _.each(oData.Result['Counts'], function (oItem) { +// +// var oAccount = _.find(aAcounts, function (oAccount) { +// return oAccount && oItem[0] === oAccount.email && sEmail !== oAccount.email; +// }); +// +// if (oAccount) +// { +// oAccount.count(Utils.pInt(oItem[1])); +// } +// }); +// } +// }); }; AppUser.prototype.accountsAndIdentities = function (bBoot) @@ -539,7 +543,7 @@ var aCounts = {}, sParentEmail = Settings.settingsGet('ParentEmail'), - sAccountEmail = Data.accountEmail() + sAccountEmail = AccountStore.email() ; sParentEmail = '' === sParentEmail ? sAccountEmail : sParentEmail; @@ -1138,14 +1142,18 @@ Data.namespace = oData.Result.Namespace; } - Data.threading(!!Settings.settingsGet('UseImapThread') && oData.Result.IsThreadsSupported && true); + AppStore.threadsAllowed(!!Settings.settingsGet('UseImapThread') && + oData.Result.IsThreadsSupported && true); aList = this.folderResponseParseRec(Data.namespace, oData.Result['@Collection']); Data.folderList(aList); - if (oData.Result['SystemFolders'] && - '' === '' + Settings.settingsGet('SentFolder') + Settings.settingsGet('DraftFolder') + - Settings.settingsGet('SpamFolder') + Settings.settingsGet('TrashFolder') + Settings.settingsGet('ArchiveFolder') + + if (oData.Result['SystemFolders'] && '' === '' + + Settings.settingsGet('SentFolder') + + Settings.settingsGet('DraftFolder') + + Settings.settingsGet('SpamFolder') + + Settings.settingsGet('TrashFolder') + + Settings.settingsGet('ArchiveFolder') + Settings.settingsGet('NullFolder')) { // TODO Magic Numbers @@ -1158,20 +1166,20 @@ bUpdate = true; } - Data.sentFolder(fNormalizeFolder(Settings.settingsGet('SentFolder'))); - Data.draftFolder(fNormalizeFolder(Settings.settingsGet('DraftFolder'))); - Data.spamFolder(fNormalizeFolder(Settings.settingsGet('SpamFolder'))); - Data.trashFolder(fNormalizeFolder(Settings.settingsGet('TrashFolder'))); - Data.archiveFolder(fNormalizeFolder(Settings.settingsGet('ArchiveFolder'))); + FolderStore.sentFolder(fNormalizeFolder(Settings.settingsGet('SentFolder'))); + FolderStore.draftFolder(fNormalizeFolder(Settings.settingsGet('DraftFolder'))); + FolderStore.spamFolder(fNormalizeFolder(Settings.settingsGet('SpamFolder'))); + FolderStore.trashFolder(fNormalizeFolder(Settings.settingsGet('TrashFolder'))); + FolderStore.archiveFolder(fNormalizeFolder(Settings.settingsGet('ArchiveFolder'))); if (bUpdate) { Remote.saveSystemFolders(Utils.emptyFunction, { - 'SentFolder': Data.sentFolder(), - 'DraftFolder': Data.draftFolder(), - 'SpamFolder': Data.spamFolder(), - 'TrashFolder': Data.trashFolder(), - 'ArchiveFolder': Data.archiveFolder(), + 'SentFolder': FolderStore.sentFolder(), + 'DraftFolder': FolderStore.draftFolder(), + 'SpamFolder': FolderStore.spamFolder(), + 'TrashFolder': FolderStore.trashFolder(), + 'ArchiveFolder': FolderStore.archiveFolder(), 'NullFolder': 'NullFolder' }); } @@ -1403,8 +1411,7 @@ require('Stores/User/Settings').populate(); require('Stores/User/Notification').populate(); require('Stores/User/Identity').populate(); - - Data.populateDataOnStart(); + require('Stores/User/Account').populate(); var self = this, @@ -1443,9 +1450,9 @@ if ($LAB && window.crypto && window.crypto.getRandomValues && Settings.capa(Enums.Capa.OpenPGP)) { var fOpenpgpCallback = function (openpgp) { - Data.openpgp = openpgp; - Data.openpgpKeyring = new openpgp.Keyring(); - Data.capaOpenPGP(true); + PgpStore.openpgp = openpgp; + PgpStore.openpgpKeyring = new openpgp.Keyring(); + PgpStore.capaOpenPGP(true); Events.pub('openpgp.init'); @@ -1468,7 +1475,7 @@ } else { - Data.capaOpenPGP(false); + PgpStore.capaOpenPGP(false); } kn.startScreens([ diff --git a/dev/Common/Enums.js b/dev/Common/Enums.js index 91196e5a9..61bd73765 100644 --- a/dev/Common/Enums.js +++ b/dev/Common/Enums.js @@ -15,15 +15,6 @@ 'Unload': 'unload' }; - /** - * @enum {number} - */ - Enums.SpoolerType = { - 'Delay': 0, - 'MessageList': 1, - 'Move': 2 - }; - /** * @enum {number} */ @@ -233,15 +224,7 @@ 'HtmlForced': 'HtmlForced', 'PlainForced': 'PlainForced' }; - - /** - * @enum {string} - */ - Enums.CustomThemeType = { - 'Light': 'Light', - 'Dark': 'Dark' - }; - + /** * @enum {number} */ diff --git a/dev/Model/Message.js b/dev/Model/Message.js index fe03a455a..46df26957 100644 --- a/dev/Model/Message.js +++ b/dev/Model/Message.js @@ -369,9 +369,8 @@ MessageModel.prototype.computeSenderEmail = function () { var - Data = require('Storage/User/Data'), - sSent = Data.sentFolder(), - sDraft = Data.draftFolder() + sSent = require('Stores/User/Folder').sentFolder(), + sDraft = require('Stores/User/Folder').draftFolder() ; this.senderEmailsString(this.folderFullNameRaw === sSent || this.folderFullNameRaw === sDraft ? @@ -456,7 +455,6 @@ { var bResult = false, - Data = require('Storage/User/Data'), iPriority = Enums.MessagePriority.Normal ; @@ -474,7 +472,7 @@ this.proxy = !!oJsonMessage.ExternalProxy; - if (Data.capaOpenPGP()) + if (require('Stores/User/Pgp').capaOpenPGP()) { this.isPgpSigned(!!oJsonMessage.PgpSigned); this.isPgpEncrypted(!!oJsonMessage.PgpEncrypted); @@ -1134,8 +1132,7 @@ this.body.data('rl-plain-raw', this.plainRaw); - var Data = require('Storage/User/Data'); - if (Data.capaOpenPGP()) + if (require('Stores/User/Pgp').capaOpenPGP()) { this.body.data('rl-plain-pgp-signed', !!this.isPgpSigned()); this.body.data('rl-plain-pgp-encrypted', !!this.isPgpEncrypted()); @@ -1147,8 +1144,7 @@ MessageModel.prototype.storePgpVerifyDataToDom = function () { - var Data = require('Storage/User/Data'); - if (this.body && Data.capaOpenPGP()) + if (this.body && require('Stores/User/Pgp').capaOpenPGP()) { this.body.data('rl-pgp-verify-status', this.pgpSignedVerifyStatus()); this.body.data('rl-pgp-verify-user', this.pgpSignedVerifyUser()); @@ -1164,8 +1160,7 @@ this.plainRaw = Utils.pString(this.body.data('rl-plain-raw')); - var Data = require('Storage/User/Data'); - if (Data.capaOpenPGP()) + if (require('Stores/User/Pgp').capaOpenPGP()) { this.isPgpSigned(!!this.body.data('rl-plain-pgp-signed')); this.isPgpEncrypted(!!this.body.data('rl-plain-pgp-encrypted')); @@ -1202,7 +1197,7 @@ try { - mPgpMessage = Data.openpgp.cleartext.readArmored(this.plainRaw); + mPgpMessage = PgpStore.openpgp.cleartext.readArmored(this.plainRaw); if (mPgpMessage && mPgpMessage.getText) { this.pgpSignedVerifyStatus( @@ -1272,7 +1267,7 @@ try { - mPgpMessage = Data.openpgp.message.readArmored(this.plainRaw); + mPgpMessage = PgpStore.openpgp.message.readArmored(this.plainRaw); if (mPgpMessage && oPrivateKey && mPgpMessage.decrypt) { this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.Unverified); diff --git a/dev/Screen/User/MailBox.js b/dev/Screen/User/MailBox.js index 28a3ad9e0..7a8d073c5 100644 --- a/dev/Screen/User/MailBox.js +++ b/dev/Screen/User/MailBox.js @@ -47,7 +47,7 @@ MailBoxUserScreen.prototype.setNewTitle = function () { var - sEmail = Data.accountEmail(), + sEmail = AccountStore.email(), nFoldersInboxUnreadCount = Data.foldersInboxUnreadCount() ; @@ -113,10 +113,10 @@ }, 50); Events.sub('mailbox.inbox-unread-count', function (iCount) { - + Data.foldersInboxUnreadCount(iCount); - var sEmail = Data.accountEmail(); + var sEmail = AccountStore.email(); _.each(AccountStore.accounts(), function (oItem) { if (oItem && sEmail === oItem.email) diff --git a/dev/Settings/Admin/Domains.js b/dev/Settings/Admin/Domains.js index 93bd3e3bb..5511a33eb 100644 --- a/dev/Settings/Admin/Domains.js +++ b/dev/Settings/Admin/Domains.js @@ -19,7 +19,7 @@ */ function DomainsAdminSettings() { - this.domains = DomainStore.collection; + this.domains = DomainStore.domains; this.iDomainForDeletionTimeout = 0; diff --git a/dev/Settings/Admin/Packages.js b/dev/Settings/Admin/Packages.js index af5205cf8..8947f357b 100644 --- a/dev/Settings/Admin/Packages.js +++ b/dev/Settings/Admin/Packages.js @@ -22,7 +22,7 @@ { this.packagesError = ko.observable(''); - this.packages = PackageStore.collection; + this.packages = PackageStore.packages; this.packagesReal = PackageStore.packagesReal; this.packagesMainUpdatable = PackageStore.packagesMainUpdatable; @@ -39,7 +39,7 @@ }); this.visibility = ko.computed(function () { - return PackageStore.collection.loading() ? 'visible' : 'hidden'; + return PackageStore.packages.loading() ? 'visible' : 'hidden'; }, this); } diff --git a/dev/Settings/Admin/Plugins.js b/dev/Settings/Admin/Plugins.js index 27e9e9269..a83db3c9c 100644 --- a/dev/Settings/Admin/Plugins.js +++ b/dev/Settings/Admin/Plugins.js @@ -23,11 +23,11 @@ { this.enabledPlugins = ko.observable(!!Settings.settingsGet('EnabledPlugins')); - this.plugins = PluginStore.collection; - this.pluginsError = PluginStore.collection.error; + this.plugins = PluginStore.plugins; + this.pluginsError = PluginStore.plugins.error; this.visibility = ko.computed(function () { - return PluginStore.collection.loading() ? 'visible' : 'hidden'; + return PluginStore.plugins.loading() ? 'visible' : 'hidden'; }, this); this.onPluginLoadRequest = _.bind(this.onPluginLoadRequest, this); @@ -75,7 +75,7 @@ PluginsAdminSettings.prototype.onShow = function () { - PluginStore.collection.error(''); + PluginStore.plugins.error(''); require('App/Admin').reloadPluginList(); }; @@ -95,11 +95,11 @@ { if (Enums.Notification.UnsupportedPluginPackage === oData.ErrorCode && oData.ErrorMessage && '' !== oData.ErrorMessage) { - PluginStore.collection.error(oData.ErrorMessage); + PluginStore.plugins.error(oData.ErrorMessage); } else { - PluginStore.collection.error(Translator.getNotification(oData.ErrorCode)); + PluginStore.plugins.error(Translator.getNotification(oData.ErrorCode)); } } } diff --git a/dev/Settings/User/ChangePassword.js b/dev/Settings/User/ChangePassword.js index 23cba9fe2..7d011015d 100644 --- a/dev/Settings/User/ChangePassword.js +++ b/dev/Settings/User/ChangePassword.js @@ -112,7 +112,7 @@ } this.passwordUpdateError(true); - this.errorDescription(oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : + this.errorDescription(oData && oData.ErrorCode ? Translator.getNotification(oData.ErrorCode) : Translator.getNotification(Enums.Notification.CouldNotSaveNewPassword)); } }; diff --git a/dev/Settings/User/Filters.js b/dev/Settings/User/Filters.js index 864e7764b..c79516764 100644 --- a/dev/Settings/User/Filters.js +++ b/dev/Settings/User/Filters.js @@ -24,7 +24,7 @@ var self = this; this.modules = FilterStore.modules; - this.filters = FilterStore.collection; + this.filters = FilterStore.filters; this.inited = ko.observable(false); this.serverError = ko.observable(false); diff --git a/dev/Settings/User/General.js b/dev/Settings/User/General.js index f34ea92a4..9739a2679 100644 --- a/dev/Settings/User/General.js +++ b/dev/Settings/User/General.js @@ -44,7 +44,7 @@ this.showImages = SettingsStore.showImages; this.useCheckboxesInList = SettingsStore.useCheckboxesInList; - this.threading = Data.threading; + this.threadsAllowed = AppStore.threadsAllowed; this.useThreads = SettingsStore.useThreads; this.replySameFolder = SettingsStore.replySameFolder; this.allowLanguagesOnSettings = AppStore.allowLanguagesOnSettings; diff --git a/dev/Settings/User/Identities.js b/dev/Settings/User/Identities.js index ea8df843a..08635534a 100644 --- a/dev/Settings/User/Identities.js +++ b/dev/Settings/User/Identities.js @@ -12,6 +12,7 @@ HtmlEditor = require('Common/HtmlEditor'), Translator = require('Common/Translator'), + AccountStore = require('Stores/User/Account'), IdentityStore = require('Stores/User/Identity'), Data = require('Storage/User/Data'), @@ -26,11 +27,12 @@ this.editor = null; this.defautOptionsAfterRender = Utils.defautOptionsAfterRender; - this.accountEmail = Data.accountEmail; - this.displayName = Data.displayName; - this.signature = Data.signature; - this.signatureToAll = Data.signatureToAll; - this.replyTo = Data.replyTo; + this.accountEmail = AccountStore.email; + + this.displayName = AccountStore.displayName; + this.signature = AccountStore.signature; + this.signatureToAll = AccountStore.signatureToAll; + this.replyTo = AccountStore.replyTo; this.signatureDom = ko.observable(null); @@ -52,7 +54,7 @@ if (0 < aList.length) { aResult.push({ - 'id': this.accountEmail.peek(), + 'id': AccountStore.email.peek(), 'name': this.formattedAccountIdentity(), 'seporator': false }); @@ -106,8 +108,8 @@ IdentitiesUserSettings.prototype.formattedAccountIdentity = function () { var - sDisplayName = this.displayName.peek(), - sEmail = this.accountEmail.peek() + sDisplayName = AccountStore.displayName.peek(), + sEmail = AccountStore.email.peek() ; return '' === sDisplayName ? sEmail : '"' + Utils.quoteName(sDisplayName) + '" <' + sEmail + '>'; @@ -151,11 +153,11 @@ { var self = this, - sSignature = Data.signature() + sSignature = AccountStore.signature() ; this.editor = new HtmlEditor(self.signatureDom(), function () { - Data.signature( + AccountStore.signature( (self.editor.isHtml() ? ':HTML:' : '') + self.editor.getData() ); }, function () { @@ -200,25 +202,25 @@ }); }); - Data.displayName.subscribe(function (sValue) { + AccountStore.displayName.subscribe(function (sValue) { Remote.saveSettings(f1, { 'DisplayName': sValue }); }); - Data.replyTo.subscribe(function (sValue) { + AccountStore.replyTo.subscribe(function (sValue) { Remote.saveSettings(f2, { 'ReplyTo': sValue }); }); - Data.signature.subscribe(function (sValue) { + AccountStore.signature.subscribe(function (sValue) { Remote.saveSettings(f3, { 'Signature': sValue }); }); - Data.signatureToAll.subscribe(function (bValue) { + AccountStore.signatureToAll.subscribe(function (bValue) { Remote.saveSettings(null, { 'SignatureToAll': bValue ? '1' : '0' }); diff --git a/dev/Settings/User/Identity.js b/dev/Settings/User/Identity.js index 9ff94b808..f4b15e6bc 100644 --- a/dev/Settings/User/Identity.js +++ b/dev/Settings/User/Identity.js @@ -11,6 +11,8 @@ Utils = require('Common/Utils'), HtmlEditor = require('Common/HtmlEditor'), + AccountStore = require('Stores/User/Account'), + Data = require('Storage/User/Data'), Remote = require('Storage/User/Remote') ; @@ -22,10 +24,10 @@ { this.editor = null; - this.displayName = Data.displayName; - this.signature = Data.signature; - this.signatureToAll = Data.signatureToAll; - this.replyTo = Data.replyTo; + this.displayName = AccountStore.displayName; + this.signature = AccountStore.signature; + this.signatureToAll = AccountStore.signatureToAll; + this.replyTo = AccountStore.replyTo; this.signatureDom = ko.observable(null); @@ -40,11 +42,11 @@ { var self = this, - sSignature = Data.signature() + sSignature = AccountStore.signature() ; this.editor = new HtmlEditor(self.signatureDom(), function () { - Data.signature( + AccountStore.signature( (self.editor.isHtml() ? ':HTML:' : '') + self.editor.getData() ); }, function () { @@ -71,25 +73,25 @@ f3 = Utils.settingsSaveHelperSimpleFunction(self.signatureTrigger, self) ; - Data.displayName.subscribe(function (sValue) { + AccountStore.displayName.subscribe(function (sValue) { Remote.saveSettings(f1, { 'DisplayName': sValue }); }); - Data.replyTo.subscribe(function (sValue) { + AccountStore.replyTo.subscribe(function (sValue) { Remote.saveSettings(f2, { 'ReplyTo': sValue }); }); - Data.signature.subscribe(function (sValue) { + AccountStore.signature.subscribe(function (sValue) { Remote.saveSettings(f3, { 'Signature': sValue }); }); - Data.signatureToAll.subscribe(function (bValue) { + AccountStore.signatureToAll.subscribe(function (bValue) { Remote.saveSettings(null, { 'SignatureToAll': bValue ? '1' : '0' }); diff --git a/dev/Settings/User/OpenPgp.js b/dev/Settings/User/OpenPgp.js index 2cffa532e..12deac0fa 100644 --- a/dev/Settings/User/OpenPgp.js +++ b/dev/Settings/User/OpenPgp.js @@ -11,7 +11,7 @@ kn = require('Knoin/Knoin'), - Data = require('Storage/User/Data') + PgpStore = require('Stores/User/Pgp') ; /** @@ -19,9 +19,9 @@ */ function OpenPgpUserSettings() { - this.openpgpkeys = Data.openpgpkeys; - this.openpgpkeysPublic = Data.openpgpkeysPublic; - this.openpgpkeysPrivate = Data.openpgpkeysPrivate; + this.openpgpkeys = PgpStore.openpgpkeys; + this.openpgpkeysPublic = PgpStore.openpgpkeysPublic; + this.openpgpkeysPrivate = PgpStore.openpgpkeysPrivate; this.openPgpKeyForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this, function (oPrev) { @@ -65,21 +65,21 @@ { this.openPgpKeyForDeletion(null); - if (oOpenPgpKeyToRemove && Data.openpgpKeyring) + if (oOpenPgpKeyToRemove && PgpStore.openpgpKeyring) { - var oFindedItem = _.find(this.openpgpkeys(), function (oOpenPgpKey) { + var oFindedItem = _.find(PgpStore.openpgpkeys(), function (oOpenPgpKey) { return oOpenPgpKeyToRemove === oOpenPgpKey; }); if (oFindedItem) { - this.openpgpkeys.remove(oFindedItem); + PgpStore.openpgpkeys.remove(oFindedItem); Utils.delegateRunOnDestroy(oFindedItem); - Data.openpgpKeyring[oFindedItem.isPrivate ? 'privateKeys' : 'publicKeys'] + PgpStore.openpgpKeyring[oFindedItem.isPrivate ? 'privateKeys' : 'publicKeys'] .removeForId(oFindedItem.guid); - Data.openpgpKeyring.store(); + PgpStore.openpgpKeyring.store(); } require('App/User').reloadOpenPgpKeys(); diff --git a/dev/Settings/User/Security.js b/dev/Settings/User/Security.js index b571c3599..6658fde85 100644 --- a/dev/Settings/User/Security.js +++ b/dev/Settings/User/Security.js @@ -4,6 +4,7 @@ 'use strict'; var + _ = require('_'), ko = require('ko'), Enums = require('Common/Enums'), @@ -65,12 +66,6 @@ Remote.createTwoFactor(this.onResult); }; - SecurityUserSettings.prototype.enableTwoFactor = function () - { - this.processing(true); - Remote.enableTwoFactor(this.onResult, this.viewEnable()); - }; - SecurityUserSettings.prototype.testTwoFactor = function () { require('Knoin/Knoin').showScreenPopup(require('View/Popup/TwoFactorTest')); @@ -122,6 +117,7 @@ if (this.bFirst) { this.bFirst = false; + var self = this; this.viewEnable.subscribe(function (bValue) { if (this.viewEnable.subs) diff --git a/dev/Storage/User/Data.js b/dev/Storage/User/Data.js index 4ce9af4a2..db6bf7a0a 100644 --- a/dev/Storage/User/Data.js +++ b/dev/Storage/User/Data.js @@ -17,16 +17,14 @@ Links = require('Common/Links'), Translator = require('Common/Translator'), - SettingsUserStore = require('Stores/User/Settings'), + SettingsStore = require('Stores/User/Settings'), Settings = require('Storage/Settings'), Cache = require('Storage/User/Cache'), kn = require('Knoin/Knoin'), - MessageModel = require('Model/Message'), - - Local = require('Storage/Client') + MessageModel = require('Model/Message') ; /** @@ -34,71 +32,6 @@ */ function DataUserStorage() { - 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.devEmail = ''; - this.devPassword = ''; - - this.accountEmail = ko.observable(''); - this.accountIncLogin = ko.observable(''); - this.accountOutLogin = ko.observable(''); - this.projectHash = ko.observable(''); - this.threading = ko.observable(false); - - this.lastFoldersHash = ''; - this.remoteSuggestions = false; - - // system folders - this.sentFolder = ko.observable(''); - this.draftFolder = ko.observable(''); - this.spamFolder = ko.observable(''); - this.trashFolder = ko.observable(''); - this.archiveFolder = ko.observable(''); - - 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.draftFolderNotEnabled = ko.computed(function () { - return '' === this.draftFolder() || Consts.Values.UnuseOptionValue === this.draftFolder(); - }, this); - - // personal - this.displayName = ko.observable(''); - this.signature = ko.observable(''); - this.signatureToAll = ko.observable(false); - this.replyTo = ko.observable(''); - - // security - this.enableTwoFactor = ko.observable(false); - // contacts this.contacts = ko.observableArray([]); this.contacts.loading = ko.observable(false).extend({'throttle': 200}); @@ -176,13 +109,15 @@ this.folderListSystemNames = ko.computed(function () { var + FolderStore = require('Stores/User/Folder'), + aList = [Cache.getFolderInboxName()], aFolders = this.folderList(), - sSentFolder = this.sentFolder(), - sDraftFolder = this.draftFolder(), - sSpamFolder = this.spamFolder(), - sTrashFolder = this.trashFolder(), - sArchiveFolder = this.archiveFolder() + sSentFolder = FolderStore.sentFolder(), + sDraftFolder = FolderStore.draftFolder(), + sSpamFolder = FolderStore.spamFolder(), + sTrashFolder = FolderStore.trashFolder(), + sArchiveFolder = FolderStore.archiveFolder() ; if (Utils.isArray(aFolders) && 0 < aFolders.length) @@ -261,7 +196,7 @@ this.messageListPageCount = ko.computed(function () { var iPage = window.Math.ceil(this.messageListCount() / - SettingsUserStore.messagesPerPage()); + SettingsStore.messagesPerPage()); return 0 >= iPage ? 1 : iPage; }, this); @@ -317,13 +252,13 @@ this.messageFullScreenMode(false); this.hideMessageBodies(); - if (Enums.Layout.NoPreview === SettingsUserStore.layout() && + if (Enums.Layout.NoPreview === SettingsStore.layout() && -1 < window.location.hash.indexOf('message-preview')) { require('App/User').historyBack(); } } - else if (Enums.Layout.NoPreview === SettingsUserStore.layout()) + else if (Enums.Layout.NoPreview === SettingsStore.layout()) { this.message.focused(true); } @@ -337,7 +272,7 @@ } else if (Enums.KeyState.MessageView === Globals.keyScope()) { - if (Enums.Layout.NoPreview === SettingsUserStore.layout() && this.message()) + if (Enums.Layout.NoPreview === SettingsStore.layout() && this.message()) { Globals.keyScope(Enums.KeyState.MessageView); } @@ -422,20 +357,6 @@ // other this.composeInEdit = ko.observable(false); - this.capaOpenPGP = ko.observable(false); - this.openpgpkeys = ko.observableArray([]); - this.openpgp = null; - 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); - }); - - this.customThemeType = ko.observable(Enums.CustomThemeType.Light); this.purgeMessageBodyCacheThrottle = _.throttle(this.purgeMessageBodyCache, 1000 * 30); } @@ -472,27 +393,6 @@ } }; - DataUserStorage.prototype.populateDataOnStart = function() - { - this.accountEmail(Settings.settingsGet('Email')); - this.accountIncLogin(Settings.settingsGet('IncLogin')); - this.accountOutLogin(Settings.settingsGet('OutLogin')); - this.projectHash(Settings.settingsGet('ProjectHash')); - - this.displayName(Settings.settingsGet('DisplayName')); - this.replyTo(Settings.settingsGet('ReplyTo')); - this.signature(Settings.settingsGet('Signature')); - this.signatureToAll(!!Settings.settingsGet('SignatureToAll')); - this.enableTwoFactor(!!Settings.settingsGet('EnableTwoFactor')); - - this.lastFoldersHash = Local.get(Enums.ClientSideKeyName.FoldersLashHash) || ''; - - this.remoteSuggestions = !!Settings.settingsGet('RemoteSuggestions'); - - this.devEmail = Settings.settingsGet('DevEmail'); - this.devPassword = Settings.settingsGet('DevPassword'); - }; - DataUserStorage.prototype.initUidNextAndNewMessages = function (sFolder, sUidNext, aNewMessages) { if (Cache.getFolderInboxName() === sFolder && Utils.isNormal(sUidNext) && sUidNext !== '') @@ -515,7 +415,7 @@ { NotificationStore.displayDesktopNotification( Links.notificationMailIcon(), - this.accountEmail(), + require('Stores/User/Account').email(), Translator.i18n('MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION', { 'COUNT': iLen }) @@ -793,7 +693,7 @@ bIsHtml = false; sResultHtml = Utils.plainToHtml(oData.Result.Plain.toString(), false); - if ((oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) && this.capaOpenPGP()) + if ((oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) && require('Stores/User/Pgp').capaOpenPGP()) { oMessage.plainRaw = Utils.pString(oData.Result.Plain); @@ -856,7 +756,7 @@ oMessage.showInternalImages(true); } - if (oMessage.hasImages() && SettingsUserStore.showImages()) + if (oMessage.hasImages() && SettingsStore.showImages()) { oMessage.showExternalImages(true); } @@ -907,7 +807,7 @@ DataUserStorage.prototype.findPublicKeyByHex = function (sHash) { - return _.find(this.openpgpkeysPublic(), function (oItem) { + return _.find(require('Stores/User/Pgp').openpgpkeysPublic(), function (oItem) { return oItem && sHash === oItem.id; }); }; @@ -915,7 +815,7 @@ DataUserStorage.prototype.findPublicKeysByEmail = function (sEmail) { var self = this; - return _.compact(_.map(this.openpgpkeysPublic(), function (oItem) { + return _.compact(_.map(require('Stores/User/Pgp').openpgpkeysPublic(), function (oItem) { var oKey = null; if (oItem && sEmail === oItem.email) @@ -946,7 +846,7 @@ var self = this, oPrivateKey = null, - oKey = _.find(this.openpgpkeysPrivate(), function (oItem) { + oKey = _.find(require('Stores/User/Pgp').openpgpkeysPrivate(), function (oItem) { return oItem && sEmail === oItem.email; }) ; @@ -981,7 +881,7 @@ */ DataUserStorage.prototype.findSelfPrivateKey = function (sPassword) { - return this.findPrivateKeyByEmail(this.accountEmail(), sPassword); + return this.findPrivateKeyByEmail(require('Stores/User/Account').email(), sPassword); }; module.exports = new DataUserStorage(); diff --git a/dev/Storage/User/Remote.js b/dev/Storage/User/Remote.js index 8eb8a66f5..437338ac8 100644 --- a/dev/Storage/User/Remote.js +++ b/dev/Storage/User/Remote.js @@ -10,7 +10,8 @@ Consts = require('Common/Consts'), Base64 = require('Common/Base64'), - SettingsUserStore = require('Stores/User/Settings'), + AppStore = require('Stores/User/App'), + SettingsStore = require('Stores/User/Settings'), Settings = require('Storage/Settings'), Cache = require('Storage/User/Cache'), @@ -294,11 +295,11 @@ iOffset, iLimit, sSearch, - Data.projectHash(), + AppStore.projectHash(), sFolderHash, Cache.getFolderInboxName() === sFolderFullNameRaw ? Cache.getFolderUidNext(sFolderFullNameRaw) : '', - Data.threading() && SettingsUserStore.useThreads() ? '1' : '0', - Data.threading() && sFolderFullNameRaw === Data.messageListThreadFolder() ? Data.messageListThreadUids().join(',') : '' + AppStore.threadsAllowed() && SettingsStore.useThreads() ? '1' : '0', + AppStore.threadsAllowed() && sFolderFullNameRaw === Data.messageListThreadFolder() ? Data.messageListThreadUids().join(',') : '' ].join(String.fromCharCode(0))), bSilent ? [] : ['MessageList']); } else @@ -309,8 +310,8 @@ 'Limit': iLimit, 'Search': sSearch, 'UidNext': Cache.getFolderInboxName() === sFolderFullNameRaw ? Cache.getFolderUidNext(sFolderFullNameRaw) : '', - 'UseThreads': Data.threading() && SettingsUserStore.useThreads() ? '1' : '0', - 'ExpandedThreadUid': Data.threading() && sFolderFullNameRaw === Data.messageListThreadFolder() ? Data.messageListThreadUids().join(',') : '' + 'UseThreads': AppStore.threadsAllowed() && SettingsStore.useThreads() ? '1' : '0', + 'ExpandedThreadUid': AppStore.threadsAllowed() && sFolderFullNameRaw === Data.messageListThreadFolder() ? Data.messageListThreadUids().join(',') : '' }, '' === sSearch ? Consts.Defaults.DefaultAjaxTimeout : Consts.Defaults.SearchAjaxTimeout, '', bSilent ? [] : ['MessageList']); } }; @@ -343,8 +344,8 @@ 'Message/' + Base64.urlsafe_encode([ sFolderFullNameRaw, iUid, - Data.projectHash(), - Data.threading() && SettingsUserStore.useThreads() ? '1' : '0' + AppStore.projectHash(), + AppStore.threadsAllowed() && SettingsStore.useThreads() ? '1' : '0' ].join(String.fromCharCode(0))), ['Message']); return true; @@ -423,7 +424,7 @@ 'UidNext': Cache.getFolderInboxName() === sFolder ? Cache.getFolderUidNext(sFolder) : '' }); } - else if (SettingsUserStore.useThreads()) + else if (SettingsStore.useThreads()) { require('App/User').reloadFlagsCurrentMessageListAndMessageFromCache(); } diff --git a/dev/Storage/User/Spooler.js b/dev/Storage/User/Spooler.js deleted file mode 100644 index f052b02e7..000000000 --- a/dev/Storage/User/Spooler.js +++ /dev/null @@ -1,20 +0,0 @@ - -(function () { - - 'use strict'; - - var - queue = require('queue') - ; - - /** - * @constructor - */ - function Spooler() - { - this.queue = queue(1); - } - - module.exports = new Spooler(); - -}()); diff --git a/dev/Stores/Admin/App.js b/dev/Stores/Admin/App.js index 2249918a8..75782bc0c 100644 --- a/dev/Stores/Admin/App.js +++ b/dev/Stores/Admin/App.js @@ -6,7 +6,9 @@ var ko = require('ko'), - Settings = require('Storage/Settings') + Settings = require('Storage/Settings'), + + AppStore = require('Stores/App') ; /** @@ -14,10 +16,7 @@ */ function AppAdminStore() { - // same - this.allowLanguagesOnSettings = ko.observable(true); - this.allowLanguagesOnLogin = ko.observable(true); - // ---- + AppStore.call(this); this.determineUserLanguage = ko.observable(false); this.determineUserDomain = ko.observable(false); @@ -28,8 +27,7 @@ AppAdminStore.prototype.populate = function() { - this.allowLanguagesOnLogin(!!Settings.settingsGet('AllowLanguagesOnLogin')); - this.allowLanguagesOnSettings(!!Settings.settingsGet('AllowLanguagesOnSettings')); + AppStore.prototype.populate.call(this); this.determineUserLanguage(!!Settings.settingsGet('DetermineUserLanguage')); this.determineUserDomain(!!Settings.settingsGet('DetermineUserDomain')); diff --git a/dev/Stores/Admin/Domain.js b/dev/Stores/Admin/Domain.js index 2fee09cc2..9ac93ef21 100644 --- a/dev/Stores/Admin/Domain.js +++ b/dev/Stores/Admin/Domain.js @@ -12,8 +12,8 @@ */ function DomainAdminStore() { - this.collection = ko.observableArray([]); - this.collection.loading = ko.observable(false).extend({'throttle': 100}); + this.domains = ko.observableArray([]); + this.domains.loading = ko.observable(false).extend({'throttle': 100}); } module.exports = new DomainAdminStore(); diff --git a/dev/Stores/Admin/Package.js b/dev/Stores/Admin/Package.js index 791b660dd..8c593d5d4 100644 --- a/dev/Stores/Admin/Package.js +++ b/dev/Stores/Admin/Package.js @@ -10,15 +10,15 @@ /** * @constructor */ - function PluginAdminStore() + function PackageAdminStore() { - this.collection = ko.observableArray([]); - this.collection.loading = ko.observable(false).extend({'throttle': 100}); + this.packages = ko.observableArray([]); + this.packages.loading = ko.observable(false).extend({'throttle': 100}); this.packagesReal = ko.observable(true); this.packagesMainUpdatable = ko.observable(true); } - module.exports = new PluginAdminStore(); + module.exports = new PackageAdminStore(); }()); diff --git a/dev/Stores/Admin/Plugin.js b/dev/Stores/Admin/Plugin.js index c29ee2ea3..6bda31676 100644 --- a/dev/Stores/Admin/Plugin.js +++ b/dev/Stores/Admin/Plugin.js @@ -12,9 +12,9 @@ */ function PluginAdminStore() { - this.collection = ko.observableArray([]); - this.collection.loading = ko.observable(false).extend({'throttle': 100}); - this.collection.error = ko.observable(''); + this.plugins = ko.observableArray([]); + this.plugins.loading = ko.observable(false).extend({'throttle': 100}); + this.plugins.error = ko.observable(''); } module.exports = new PluginAdminStore(); diff --git a/dev/Stores/App.js b/dev/Stores/App.js new file mode 100644 index 000000000..04ec64bab --- /dev/null +++ b/dev/Stores/App.js @@ -0,0 +1,42 @@ + +(function () { + + 'use strict'; + + var + ko = require('ko'), + + Globals = require('Common/Globals'), + + Settings = require('Storage/Settings') + ; + + /** + * @constructor + */ + function AppStore() + { + this.allowLanguagesOnSettings = ko.observable(true); + this.allowLanguagesOnLogin = ko.observable(true); + + this.interfaceAnimation = ko.observable(true); + + this.interfaceAnimation.subscribe(function (bValue) { + var bAnim = Globals.bMobileDevice || !bValue; + Globals.$html.toggleClass('rl-anim', !bAnim).toggleClass('no-rl-anim', bAnim); + }); + + this.interfaceAnimation.valueHasMutated(); + } + + AppStore.prototype.populate = function() + { + this.allowLanguagesOnLogin(!!Settings.settingsGet('AllowLanguagesOnLogin')); + this.allowLanguagesOnSettings(!!Settings.settingsGet('AllowLanguagesOnSettings')); + + this.interfaceAnimation(!!Settings.settingsGet('InterfaceAnimation')); + }; + + module.exports = AppStore; + +}()); diff --git a/dev/Stores/User/Account.js b/dev/Stores/User/Account.js index 4eb62f1ba..1bc763522 100644 --- a/dev/Stores/User/Account.js +++ b/dev/Stores/User/Account.js @@ -7,6 +7,8 @@ _ = require('_'), ko = require('ko'), + Settings = require('Storage/Settings'), + Remote = require('Storage/User/Remote') ; @@ -15,6 +17,15 @@ */ function AccountUserStore() { + this.email = ko.observable(''); +// this.incLogin = ko.observable(''); +// this.outLogin = ko.observable(''); + + this.displayName = ko.observable(''); + this.replyTo = ko.observable(''); + this.signature = ko.observable(''); + this.signatureToAll = ko.observable(false); + this.accounts = ko.observableArray([]); this.accounts.loading = ko.observable(false).extend({'throttle': 100}); @@ -42,18 +53,30 @@ var iResult = 0; - _.each(this.accounts(), function (oItem) { - if (oItem) - { - iResult += oItem.count(); - } - }); +// _.each(this.accounts(), function (oItem) { +// if (oItem) +// { +// iResult += oItem.count(); +// } +// }); return iResult; }, this); } + AccountUserStore.prototype.populate = function () + { + this.email(Settings.settingsGet('Email')); +// this.incLogin(Settings.settingsGet('IncLogin')); +// this.outLogin(Settings.settingsGet('OutLogin')); + + this.displayName(Settings.settingsGet('DisplayName')); + this.replyTo(Settings.settingsGet('ReplyTo')); + this.signature(Settings.settingsGet('Signature')); + this.signatureToAll(!!Settings.settingsGet('SignatureToAll')); + }; + module.exports = new AccountUserStore(); }()); diff --git a/dev/Stores/User/App.js b/dev/Stores/User/App.js index 7df00e1d8..e21817cdb 100644 --- a/dev/Stores/User/App.js +++ b/dev/Stores/User/App.js @@ -6,9 +6,9 @@ var ko = require('ko'), - Globals = require('Common/Globals'), - - Settings = require('Storage/Settings') + Settings = require('Storage/Settings'), + + AppStore = require('Stores/App') ; /** @@ -16,40 +16,31 @@ */ function AppUserStore() { - // same - this.allowLanguagesOnSettings = ko.observable(true); - this.allowLanguagesOnLogin = ko.observable(true); - // ---- + AppStore.call(this); + + this.projectHash = ko.observable(''); + this.threadsAllowed = ko.observable(false); this.contactsAutosave = ko.observable(false); this.useLocalProxyForExternalImages = ko.observable(false); this.contactsIsAllowed = ko.observable(false); - this.interfaceAnimation = ko.observable(true); - - this.interfaceAnimation.subscribe(function (bValue) { - if (Globals.bMobileDevice || !bValue) - { - Globals.$html.removeClass('rl-anim').addClass('no-rl-anim'); - } - else - { - Globals.$html.removeClass('no-rl-anim').addClass('rl-anim'); - } - }); - - this.interfaceAnimation.valueHasMutated(); + this.devEmail = ''; + this.devPassword = ''; } AppUserStore.prototype.populate = function() { - this.allowLanguagesOnLogin(!!Settings.settingsGet('AllowLanguagesOnLogin')); - this.allowLanguagesOnSettings(!!Settings.settingsGet('AllowLanguagesOnSettings')); + AppStore.prototype.populate.call(this); + + this.projectHash(Settings.settingsGet('ProjectHash')); this.useLocalProxyForExternalImages(!!Settings.settingsGet('UseLocalProxyForExternalImages')); this.contactsIsAllowed(!!Settings.settingsGet('ContactsIsAllowed')); - this.interfaceAnimation(!!Settings.settingsGet('InterfaceAnimation')); + + this.devEmail = Settings.settingsGet('DevEmail'); + this.devPassword = Settings.settingsGet('DevPassword'); }; module.exports = new AppUserStore(); diff --git a/dev/Stores/User/Filter.js b/dev/Stores/User/Filter.js index 7357142c1..c2a8d7a3b 100644 --- a/dev/Stores/User/Filter.js +++ b/dev/Stores/User/Filter.js @@ -15,10 +15,10 @@ this.capa = ko.observable(''); this.modules = ko.observable({}); - this.collection = ko.observableArray([]); + this.filters = ko.observableArray([]); - this.collection.loading = ko.observable(false).extend({'throttle': 200}); - this.collection.saving = ko.observable(false).extend({'throttle': 200}); + this.filters.loading = ko.observable(false).extend({'throttle': 200}); + this.filters.saving = ko.observable(false).extend({'throttle': 200}); this.raw = ko.observable(''); } diff --git a/dev/Stores/User/Folder.js b/dev/Stores/User/Folder.js new file mode 100644 index 000000000..55fc3f117 --- /dev/null +++ b/dev/Stores/User/Folder.js @@ -0,0 +1,75 @@ + +(function () { + + 'use strict'; + + var + ko = require('ko'), + + Enums = require('Common/Enums'), + Consts = require('Common/Consts'), + + Cache = require('Storage/User/Cache') + ; + + /** + * @constructor + */ + function FolderUserStore() + { + this.sentFolder = ko.observable(''); + this.draftFolder = ko.observable(''); + this.spamFolder = ko.observable(''); + this.trashFolder = ko.observable(''); + this.archiveFolder = ko.observable(''); + + this.computed(); + this.subscribe(); + } + + FolderUserStore.prototype.computed = function () + { + this.draftFolderNotEnabled = ko.computed(function () { + return '' === this.draftFolder() || Consts.Values.UnuseOptionValue === this.draftFolder(); + }, this); + }; + + FolderUserStore.prototype.subscribe = 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(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); + }; + + module.exports = new FolderUserStore(); + +}()); diff --git a/dev/Stores/User/Pgp.js b/dev/Stores/User/Pgp.js index 315d656d2..6e7a682ea 100644 --- a/dev/Stores/User/Pgp.js +++ b/dev/Stores/User/Pgp.js @@ -2,96 +2,108 @@ 'use strict'; -// var -// window = require('window') -// ; + var + ko = require('ko') + ; /** * @constructor */ function PgpUserStore() { + this.capaOpenPGP = ko.observable(false); + this.openpgp = null; - this.keyring = []; + + 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); + }); } - PgpUserStore.prototype.sign = function (sText, oPrivateKey) - { - try - { - return this.openpgp.signClearMessage([oPrivateKey], sText); - } - catch (oExc) {} - - return sText; - }; - - PgpUserStore.prototype.encrypt = function (sText, aPublicKeys) - { - try - { - return this.openpgp.encryptMessage(aPublicKeys, sText); - } - catch (oExc) {} - - return sText; - }; - - PgpUserStore.prototype.signAndEncrypt = function (sText, aPublicKeys, oPrivateKey) - { - try - { - return this.openpgp.signAndEncryptMessage(aPublicKeys, oPrivateKey, sText); - } - catch (oExc) {} - - return sText; - }; - - /**/ - - PgpUserStore.prototype.verify = function (sText, aPublicKeys) - { - var - mPgpMessage = null - ; - - try - { - mPgpMessage = this.openpgp.cleartext.readArmored(sText); - if (mPgpMessage && mPgpMessage.getText) - { - mPgpMessage.verify(aPublicKeys); - } - } - catch (oExc) {} - - return false; - }; - - PgpUserStore.prototype.decryptAndVerify = function (sEnctyptedText, aPublicKeys, oPivateKey) - { - var - mPgpMessageDecrypted = null, - mPgpMessage = null - ; - - try - { - mPgpMessage = this.openpgp.message.readArmored(sEnctyptedText); - if (mPgpMessage && oPivateKey && mPgpMessage.decrypt) - { - mPgpMessageDecrypted = mPgpMessage.decrypt(oPivateKey); - if (mPgpMessageDecrypted) - { - mPgpMessageDecrypted.verify(aPublicKeys); - } - } - } - catch (oExc) {} - - return false; - }; +// PgpUserStore.prototype.sign = function (sText, oPrivateKey) +// { +// try +// { +// return this.openpgp.signClearMessage([oPrivateKey], sText); +// } +// catch (oExc) {} +// +// return sText; +// }; +// +// PgpUserStore.prototype.encrypt = function (sText, aPublicKeys) +// { +// try +// { +// return this.openpgp.encryptMessage(aPublicKeys, sText); +// } +// catch (oExc) {} +// +// return sText; +// }; +// +// PgpUserStore.prototype.signAndEncrypt = function (sText, aPublicKeys, oPrivateKey) +// { +// try +// { +// return this.openpgp.signAndEncryptMessage(aPublicKeys, oPrivateKey, sText); +// } +// catch (oExc) {} +// +// return sText; +// }; +// +// /**/ +// +// PgpUserStore.prototype.verify = function (sText, aPublicKeys) +// { +// var +// mPgpMessage = null +// ; +// +// try +// { +// mPgpMessage = this.openpgp.cleartext.readArmored(sText); +// if (mPgpMessage && mPgpMessage.getText) +// { +// mPgpMessage.verify(aPublicKeys); +// } +// } +// catch (oExc) {} +// +// return false; +// }; +// +// PgpUserStore.prototype.decryptAndVerify = function (sEnctyptedText, aPublicKeys, oPivateKey) +// { +// var +// mPgpMessageDecrypted = null, +// mPgpMessage = null +// ; +// +// try +// { +// mPgpMessage = this.openpgp.message.readArmored(sEnctyptedText); +// if (mPgpMessage && oPivateKey && mPgpMessage.decrypt) +// { +// mPgpMessageDecrypted = mPgpMessage.decrypt(oPivateKey); +// if (mPgpMessageDecrypted) +// { +// mPgpMessageDecrypted.verify(aPublicKeys); +// } +// } +// } +// catch (oExc) {} +// +// return false; +// }; /** * @return {boolean} diff --git a/dev/Styles/Animations.less b/dev/Styles/Animations.less index b83d61e49..fa2131264 100644 --- a/dev/Styles/Animations.less +++ b/dev/Styles/Animations.less @@ -18,12 +18,12 @@ } html.rl-started-trigger.no-mobile .b-login-content .loginFormWrapper { - transform: translateY(-30px); + transform: translateY(-20px); } -html.rl-started-trigger.no-mobile #rl-content { +/*html.rl-started-trigger.no-mobile #rl-content { opacity: 0.7; -} +}*/ #rl-loading { .transition(opacity 0.5s linear); @@ -50,9 +50,9 @@ html.rl-started-trigger.no-mobile #rl-content { } } - &.csstransitions.no-mobile #rl-content { +/* &.csstransitions.no-mobile #rl-content { .transition(opacity 0.3s ease-out); - } + }*/ &.csstransitions.no-mobile .b-login-content .loginFormWrapper { .transition(all 0.3s ease-out); @@ -103,8 +103,8 @@ html.rl-started-trigger.no-mobile #rl-content { &.csstransitions .modal.fade { - .transition(all 0.2s ease-out); - transform: translateY(-20px); + .transition(all 200ms ease-out); + transform: scale(.9); &.in { transform: none; diff --git a/dev/Styles/_BootstrapFix.less b/dev/Styles/_BootstrapFix.less index fb5e4f67a..492118778 100644 --- a/dev/Styles/_BootstrapFix.less +++ b/dev/Styles/_BootstrapFix.less @@ -237,7 +237,8 @@ html.no-rgba .modal { } .modal-backdrop, .modal-backdrop.fade.in { - .opacity(10); + .opacity(20); + transform: none; } .popups { diff --git a/dev/View/Admin/Settings/Pane.js b/dev/View/Admin/Settings/Pane.js index 56e4f50c2..d40a156f0 100644 --- a/dev/View/Admin/Settings/Pane.js +++ b/dev/View/Admin/Settings/Pane.js @@ -29,9 +29,9 @@ this.adminManLoading = ko.computed(function () { return '000' !== [ - require('Stores/Admin/Domain').collection.loading() ? '1' : '0', - require('Stores/Admin/Plugin').collection.loading() ? '1' : '0', - require('Stores/Admin/Package').collection.loading() ? '1' : '0' + require('Stores/Admin/Domain').domains.loading() ? '1' : '0', + require('Stores/Admin/Plugin').plugins.loading() ? '1' : '0', + require('Stores/Admin/Package').packages.loading() ? '1' : '0' ].join(''); }, this); diff --git a/dev/View/Popup/AddOpenPgpKey.js b/dev/View/Popup/AddOpenPgpKey.js index 69116ef20..6422b7f75 100644 --- a/dev/View/Popup/AddOpenPgpKey.js +++ b/dev/View/Popup/AddOpenPgpKey.js @@ -9,7 +9,7 @@ Utils = require('Common/Utils'), - Data = require('Storage/User/Data'), + PgpStore = require('Stores/User/Pgp'), kn = require('Knoin/Knoin'), AbstractView = require('Knoin/AbstractView') @@ -38,7 +38,7 @@ aMatch = null, sKey = Utils.trim(this.key()), oReg = /[\-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}[\s\S]+?[\-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}/gi, - oOpenpgpKeyring = Data.openpgpKeyring + oOpenpgpKeyring = PgpStore.openpgpKeyring ; sKey = sKey.replace(/[\r\n]([a-zA-Z0-9]{2,}:[^\r\n]+)[\r\n]+([a-zA-Z0-9\/\\+=]{10,})/g, '\n$1!-!N!-!$2') diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index a628358c3..57f2bcda3 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -24,6 +24,9 @@ AppStore = require('Stores/User/App'), SettingsStore = require('Stores/User/Settings'), IdentityStore = require('Stores/User/Identity'), + AccountStore = require('Stores/User/Account'), + FolderStore = require('Stores/User/Folder'), + PgpStore = require('Stores/User/Pgp'), SocialStore = require('Stores/Social'), Settings = require('Storage/Settings'), @@ -63,7 +66,7 @@ this.composeInEdit = Data.composeInEdit; this.editorDefaultType = SettingsStore.editorDefaultType; - this.capaOpenPGP = Data.capaOpenPGP; + this.capaOpenPGP = PgpStore.capaOpenPGP; this.resizer = ko.observable(false).extend({'throttle': 50}); @@ -175,7 +178,7 @@ this.identitiesOptions = ko.computed(function () { var aList = [{ - 'optValue': Data.accountEmail(), + 'optValue': AccountStore.email(), 'optText': this.formattedFrom(false) }]; @@ -200,7 +203,7 @@ sID = this.currentIdentityID() ; - if (this.bCapaAdditionalIdentities && sID && sID !== Data.accountEmail()) + if (this.bCapaAdditionalIdentities && sID && sID !== AccountStore.email()) { oItem = _.find(aList, function (oItem) { return oItem && sID === oItem['id']; @@ -269,7 +272,7 @@ var sTo = Utils.trim(this.to()), - sSentFolder = Data.sentFolder(), + sSentFolder = FolderStore.sentFolder(), aFlagsCache = [] ; @@ -356,7 +359,7 @@ this.saveCommand = Utils.createCommand(this, function () { - if (Data.draftFolderNotEnabled()) + if (FolderStore.draftFolderNotEnabled()) { kn.showScreenPopup(require('View/Popup/FolderSystem'), [Enums.SetSystemFoldersNotification.Draft]); } @@ -367,13 +370,13 @@ this.autosaveStart(); - Cache.setFolderHash(Data.draftFolder(), ''); + Cache.setFolderHash(FolderStore.draftFolder(), ''); Remote.saveMessage( this.saveMessageResponse, this.draftFolder(), this.draftUid(), - Data.draftFolder(), + FolderStore.draftFolder(), this.currentIdentityResultEmail(), this.to(), this.cc(), @@ -396,7 +399,7 @@ this.bSkipNextHide = true; if (this.modalVisibility() && !this.saving() && !this.sending() && - !Data.draftFolderNotEnabled()) + !FolderStore.draftFolderNotEnabled()) { this.saveCommand(); } @@ -422,7 +425,7 @@ Events.sub('interval.2m', function () { - if (this.modalVisibility() && !Data.draftFolderNotEnabled() && !this.isEmptyForm(false) && + if (this.modalVisibility() && !FolderStore.draftFolderNotEnabled() && !this.isEmptyForm(false) && !this.saving() && !this.sending() && !this.savedError()) { this.saveCommand(); @@ -494,7 +497,7 @@ ComposePopupView.prototype.autosaveFunction = function () { - if (this.modalVisibility() && !Data.draftFolderNotEnabled() && !this.isEmptyForm(false) && + if (this.modalVisibility() && !FolderStore.draftFolderNotEnabled() && !this.isEmptyForm(false) && !this.saving() && !this.sending() && !this.savedError()) { this.saveCommand(); @@ -525,7 +528,7 @@ ComposePopupView.prototype.openOpenPgpPopup = function () { - if (this.capaOpenPGP() && this.oEditor && !this.oEditor.isHtml()) + if (PgpStore.capaOpenPGP() && this.oEditor && !this.oEditor.isHtml()) { var self = this; kn.showScreenPopup(require('View/Popup/ComposeOpenPgp'), [ @@ -546,7 +549,7 @@ ComposePopupView.prototype.reloadDraftFolder = function () { var - sDraftFolder = Data.draftFolder() + sDraftFolder = FolderStore.draftFolder() ; if ('' !== sDraftFolder) @@ -589,7 +592,7 @@ }); } - oIDs[Data.accountEmail()] = Data.accountEmail(); + oIDs[AccountStore.email()] = AccountStore.email(); if (oMessage) { @@ -616,7 +619,7 @@ if ('' === sResult) { - sResult = Data.accountEmail(); + sResult = AccountStore.email(); sEmail = sResult; } @@ -639,8 +642,8 @@ ComposePopupView.prototype.formattedFrom = function (bHeaderResult) { var - sDisplayName = Data.displayName(), - sEmail = Data.accountEmail() + sDisplayName = AccountStore.displayName(), + sEmail = AccountStore.email() ; return '' === sDisplayName ? sEmail : @@ -946,9 +949,9 @@ aResplyAllParts = [], oExcludeEmail = {}, oIdResult = null, - mEmail = Data.accountEmail(), - sSignature = Data.signature(), - bSignatureToAll = Data.signatureToAll(), + mEmail = AccountStore.email(), + sSignature = AccountStore.signature(), + bSignatureToAll = AccountStore.signatureToAll(), aDownloads = [], aDraftInfo = null, oMessage = null, diff --git a/dev/View/Popup/ComposeOpenPgp.js b/dev/View/Popup/ComposeOpenPgp.js index 90c47435e..72e8e01a7 100644 --- a/dev/View/Popup/ComposeOpenPgp.js +++ b/dev/View/Popup/ComposeOpenPgp.js @@ -114,19 +114,19 @@ if (oPrivateKey && 0 === aPublicKeys.length) { self.resultCallback( - Data.openpgp.signClearMessage([oPrivateKey], self.text()) + PgpStore.openpgp.signClearMessage([oPrivateKey], self.text()) ); } else if (oPrivateKey && 0 < aPublicKeys.length) { self.resultCallback( - Data.openpgp.signAndEncryptMessage(aPublicKeys, oPrivateKey, self.text()) + PgpStore.openpgp.signAndEncryptMessage(aPublicKeys, oPrivateKey, self.text()) ); } else if (!oPrivateKey && 0 < aPublicKeys.length) { self.resultCallback( - Data.openpgp.encryptMessage(aPublicKeys, self.text()) + PgpStore.openpgp.encryptMessage(aPublicKeys, self.text()) ); } } diff --git a/dev/View/Popup/Contacts.js b/dev/View/Popup/Contacts.js index 7f0c23c6a..815cc7979 100644 --- a/dev/View/Popup/Contacts.js +++ b/dev/View/Popup/Contacts.js @@ -18,7 +18,7 @@ Links = require('Common/Links'), Translator = require('Common/Translator'), - SettingsUserStore = require('Stores/User/Settings'), + SettingsStore = require('Stores/User/Settings'), Data = require('Storage/User/Data'), Remote = require('Storage/User/Remote'), @@ -175,7 +175,7 @@ this.viewSaving = ko.observable(false); - this.useCheckboxesInList = SettingsUserStore.useCheckboxesInList; + this.useCheckboxesInList = SettingsStore.useCheckboxesInList; this.search.subscribe(function () { this.reloadContactList(); diff --git a/dev/View/Popup/FolderSystem.js b/dev/View/Popup/FolderSystem.js index 27c0d5a79..b39f806a5 100644 --- a/dev/View/Popup/FolderSystem.js +++ b/dev/View/Popup/FolderSystem.js @@ -12,6 +12,8 @@ Utils = require('Common/Utils'), Translator = require('Common/Translator'), + FolderStore = require('Stores/User/Folder'), + Settings = require('Storage/Settings'), Data = require('Storage/User/Data'), Remote = require('Storage/User/Remote'), @@ -43,31 +45,30 @@ }, this); var - self = this, fSaveSystemFolders = null, fCallback = null ; - this.sentFolder = Data.sentFolder; - this.draftFolder = Data.draftFolder; - this.spamFolder = Data.spamFolder; - this.trashFolder = Data.trashFolder; - this.archiveFolder = Data.archiveFolder; + this.sentFolder = FolderStore.sentFolder; + this.draftFolder = FolderStore.draftFolder; + this.spamFolder = FolderStore.spamFolder; + this.trashFolder = FolderStore.trashFolder; + this.archiveFolder = FolderStore.archiveFolder; fSaveSystemFolders = _.debounce(function () { - Settings.settingsSet('SentFolder', self.sentFolder()); - Settings.settingsSet('DraftFolder', self.draftFolder()); - Settings.settingsSet('SpamFolder', self.spamFolder()); - Settings.settingsSet('TrashFolder', self.trashFolder()); - Settings.settingsSet('ArchiveFolder', self.archiveFolder()); + Settings.settingsSet('SentFolder', FolderStore.sentFolder()); + Settings.settingsSet('DraftFolder', FolderStore.draftFolder()); + Settings.settingsSet('SpamFolder', FolderStore.spamFolder()); + Settings.settingsSet('TrashFolder', FolderStore.trashFolder()); + Settings.settingsSet('ArchiveFolder', FolderStore.archiveFolder()); Remote.saveSystemFolders(Utils.emptyFunction, { - 'SentFolder': self.sentFolder(), - 'DraftFolder': self.draftFolder(), - 'SpamFolder': self.spamFolder(), - 'TrashFolder': self.trashFolder(), - 'ArchiveFolder': self.archiveFolder(), + 'SentFolder': FolderStore.sentFolder(), + 'DraftFolder': FolderStore.draftFolder(), + 'SpamFolder': FolderStore.spamFolder(), + 'TrashFolder': FolderStore.trashFolder(), + 'ArchiveFolder': FolderStore.archiveFolder(), 'NullFolder': 'NullFolder' }); @@ -75,20 +76,20 @@ fCallback = function () { - Settings.settingsSet('SentFolder', self.sentFolder()); - Settings.settingsSet('DraftFolder', self.draftFolder()); - Settings.settingsSet('SpamFolder', self.spamFolder()); - Settings.settingsSet('TrashFolder', self.trashFolder()); - Settings.settingsSet('ArchiveFolder', self.archiveFolder()); + Settings.settingsSet('SentFolder', FolderStore.sentFolder()); + Settings.settingsSet('DraftFolder', FolderStore.draftFolder()); + Settings.settingsSet('SpamFolder', FolderStore.spamFolder()); + Settings.settingsSet('TrashFolder', FolderStore.trashFolder()); + Settings.settingsSet('ArchiveFolder', FolderStore.archiveFolder()); fSaveSystemFolders(); }; - this.sentFolder.subscribe(fCallback); - this.draftFolder.subscribe(fCallback); - this.spamFolder.subscribe(fCallback); - this.trashFolder.subscribe(fCallback); - this.archiveFolder.subscribe(fCallback); + FolderStore.sentFolder.subscribe(fCallback); + FolderStore.draftFolder.subscribe(fCallback); + FolderStore.spamFolder.subscribe(fCallback); + FolderStore.trashFolder.subscribe(fCallback); + FolderStore.archiveFolder.subscribe(fCallback); this.defautOptionsAfterRender = Utils.defautOptionsAfterRender; diff --git a/dev/View/Popup/Identity.js b/dev/View/Popup/Identity.js index 8f0484cde..f4ee392a7 100644 --- a/dev/View/Popup/Identity.js +++ b/dev/View/Popup/Identity.js @@ -12,7 +12,7 @@ Translator = require('Common/Translator'), Remote = require('Storage/User/Remote'), - Data = require('Storage/User/Data'), + AccountStore = require('Stores/User/Account'), kn = require('Knoin/Knoin'), AbstractView = require('Knoin/AbstractView') @@ -147,7 +147,7 @@ this.replyTo(oIdentity.replyTo()); this.bcc(oIdentity.bcc()); - this.owner(this.id === Data.accountEmail()); + this.owner(this.id === AccountStore.email()); } }; diff --git a/dev/View/Popup/NewOpenPgpKey.js b/dev/View/Popup/NewOpenPgpKey.js index fdcafe16a..0847a3c53 100644 --- a/dev/View/Popup/NewOpenPgpKey.js +++ b/dev/View/Popup/NewOpenPgpKey.js @@ -10,6 +10,7 @@ Utils = require('Common/Utils'), Data = require('Storage/User/Data'), + PgpStore = require('Stores/User/Pgp'), kn = require('Knoin/Knoin'), AbstractView = require('Knoin/AbstractView') @@ -43,7 +44,7 @@ self = this, sUserID = '', mKeyPair = null, - oOpenpgpKeyring = Data.openpgpKeyring + oOpenpgpKeyring = PgpStore.openpgpKeyring ; this.email.error('' === Utils.trim(this.email())); @@ -61,8 +62,7 @@ this.submitRequest(true); _.delay(function () { - // mKeyPair = Data.openpgp.generateKeyPair(1, Utils.pInt(self.keyBitLength()), sUserID, Utils.trim(self.password())); - mKeyPair = Data.openpgp.generateKeyPair({ + mKeyPair = PgpStore.openpgp.generateKeyPair({ 'userId': sUserID, 'numBits': Utils.pInt(self.keyBitLength()), 'passphrase': Utils.trim(self.password()) diff --git a/dev/View/User/AbstractSystemDropDown.js b/dev/View/User/AbstractSystemDropDown.js index 6a91c0f3d..8e5655f48 100644 --- a/dev/View/User/AbstractSystemDropDown.js +++ b/dev/View/User/AbstractSystemDropDown.js @@ -29,7 +29,7 @@ { AbstractView.call(this, 'Right', 'SystemDropDown'); - this.accountEmail = Data.accountEmail; + this.accountEmail = AccountStore.email; this.accounts = AccountStore.accounts; this.accountsUnreadCount = AccountStore.accountsUnreadCount; @@ -58,7 +58,7 @@ AbstractSystemDropDownUserView.prototype.emailTitle = function () { - return Data.accountEmail(); + return AccountStore.email(); }; AbstractSystemDropDownUserView.prototype.settingsClick = function () diff --git a/dev/View/User/Login.js b/dev/View/User/Login.js index e40aea8e6..1a44fdf4b 100644 --- a/dev/View/User/Login.js +++ b/dev/View/User/Login.js @@ -357,8 +357,8 @@ break; } - this.email(Data.devEmail); - this.password(Data.devPassword); + this.email(AppStore.devEmail); + this.password(AppStore.devPassword); if (this.googleLoginEnabled()) { diff --git a/dev/View/User/MailBox/FolderList.js b/dev/View/User/MailBox/FolderList.js index f686cf7c4..2c86ff306 100644 --- a/dev/View/User/MailBox/FolderList.js +++ b/dev/View/User/MailBox/FolderList.js @@ -16,7 +16,7 @@ Links = require('Common/Links'), AppStore = require('Stores/User/App'), - SettingsUserStore = require('Stores/User/Settings'), + SettingsStore = require('Stores/User/Settings'), Cache = require('Storage/User/Cache'), Data = require('Storage/User/Data'), @@ -90,7 +90,7 @@ if (oFolder) { - if (Enums.Layout.NoPreview === SettingsUserStore.layout()) + if (Enums.Layout.NoPreview === SettingsStore.layout()) { Data.message(null); } diff --git a/dev/View/User/MailBox/MessageList.js b/dev/View/User/MailBox/MessageList.js index 4f14d0132..9f313f809 100644 --- a/dev/View/User/MailBox/MessageList.js +++ b/dev/View/User/MailBox/MessageList.js @@ -22,6 +22,7 @@ QuotaStore = require('Stores/User/Quota'), SettingsStore = require('Stores/User/Settings'), + FolderStore = require('Stores/User/Folder'), Settings = require('Storage/Settings'), Cache = require('Storage/User/Cache'), @@ -137,36 +138,36 @@ }, this); this.isSpamFolder = ko.computed(function () { - return Data.spamFolder() === this.messageListEndFolder() && - '' !== Data.spamFolder(); + return FolderStore.spamFolder() === this.messageListEndFolder() && + '' !== FolderStore.spamFolder(); }, this); this.isSpamDisabled = ko.computed(function () { - return Consts.Values.UnuseOptionValue === Data.spamFolder(); + return Consts.Values.UnuseOptionValue === FolderStore.spamFolder(); }, this); this.isTrashFolder = ko.computed(function () { - return Data.trashFolder() === this.messageListEndFolder() && - '' !== Data.trashFolder(); + return FolderStore.trashFolder() === this.messageListEndFolder() && + '' !== FolderStore.trashFolder(); }, this); this.isDraftFolder = ko.computed(function () { - return Data.draftFolder() === this.messageListEndFolder() && - '' !== Data.draftFolder(); + return FolderStore.draftFolder() === this.messageListEndFolder() && + '' !== FolderStore.draftFolder(); }, this); this.isSentFolder = ko.computed(function () { - return Data.sentFolder() === this.messageListEndFolder() && - '' !== Data.sentFolder(); + return FolderStore.sentFolder() === this.messageListEndFolder() && + '' !== FolderStore.sentFolder(); }, this); this.isArchiveFolder = ko.computed(function () { - return Data.archiveFolder() === this.messageListEndFolder() && - '' !== Data.archiveFolder(); + return FolderStore.archiveFolder() === this.messageListEndFolder() && + '' !== FolderStore.archiveFolder(); }, this); this.isArchiveDisabled = ko.computed(function () { - return Consts.Values.UnuseOptionValue === Data.archiveFolder(); + return Consts.Values.UnuseOptionValue === FolderStore.archiveFolder(); }, this); this.canBeMoved = this.hasCheckedOrSelectedLines; diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index 3a4ed2db7..bc4a3cbf4 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -19,7 +19,9 @@ Events = require('Common/Events'), Translator = require('Common/Translator'), - SettingsUserStore = require('Stores/User/Settings'), + SettingsStore = require('Stores/User/Settings'), + AccountStore = require('Stores/User/Account'), + FolderStore = require('Stores/User/Folder'), Local = require('Storage/Client'), Cache = require('Storage/User/Cache'), @@ -62,10 +64,10 @@ this.messageLoading = Data.messageLoading; this.messageLoadingThrottle = Data.messageLoadingThrottle; this.messagesBodiesDom = Data.messagesBodiesDom; - this.useThreads = SettingsUserStore.useThreads; - this.replySameFolder = SettingsUserStore.replySameFolder; - this.layout = SettingsUserStore.layout; - this.usePreviewPane = SettingsUserStore.usePreviewPane; + this.useThreads = SettingsStore.useThreads; + this.replySameFolder = SettingsStore.replySameFolder; + this.layout = SettingsStore.layout; + this.usePreviewPane = SettingsStore.usePreviewPane; this.isMessageSelected = Data.isMessageSelected; this.messageActiveDom = Data.messageActiveDom; this.messageError = Data.messageError; @@ -727,7 +729,7 @@ */ MessageViewMailBoxUserView.prototype.isDraftFolder = function () { - return Data.message() && Data.draftFolder() === Data.message().folderFullNameRaw; + return Data.message() && FolderStore.draftFolder() === Data.message().folderFullNameRaw; }; /** @@ -735,7 +737,7 @@ */ MessageViewMailBoxUserView.prototype.isSentFolder = function () { - return Data.message() && Data.sentFolder() === Data.message().folderFullNameRaw; + return Data.message() && FolderStore.sentFolder() === Data.message().folderFullNameRaw; }; /** @@ -743,7 +745,7 @@ */ MessageViewMailBoxUserView.prototype.isSpamFolder = function () { - return Data.message() && Data.spamFolder() === Data.message().folderFullNameRaw; + return Data.message() && FolderStore.spamFolder() === Data.message().folderFullNameRaw; }; /** @@ -751,7 +753,7 @@ */ MessageViewMailBoxUserView.prototype.isSpamDisabled = function () { - return Data.message() && Data.spamFolder() === Consts.Values.UnuseOptionValue; + return Data.message() && FolderStore.spamFolder() === Consts.Values.UnuseOptionValue; }; /** @@ -759,7 +761,7 @@ */ MessageViewMailBoxUserView.prototype.isArchiveFolder = function () { - return Data.message() && Data.archiveFolder() === Data.message().folderFullNameRaw; + return Data.message() && FolderStore.archiveFolder() === Data.message().folderFullNameRaw; }; /** @@ -767,7 +769,7 @@ */ MessageViewMailBoxUserView.prototype.isArchiveDisabled = function () { - return Data.message() && Data.archiveFolder() === Consts.Values.UnuseOptionValue; + return Data.message() && FolderStore.archiveFolder() === Consts.Values.UnuseOptionValue; }; /** @@ -873,7 +875,7 @@ Remote.sendReadReceiptMessage(Utils.emptyFunction, oMessage.folderFullNameRaw, oMessage.uid, oMessage.readReceipt(), Translator.i18n('READ_RECEIPT/SUBJECT', {'SUBJECT': oMessage.subject()}), - Translator.i18n('READ_RECEIPT/BODY', {'READ-RECEIPT': Data.accountEmail()})); + Translator.i18n('READ_RECEIPT/BODY', {'READ-RECEIPT': AccountStore.email()})); oMessage.isReadReceipt(true); diff --git a/package.json b/package.json index 39ee22038..fed5b3588 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "RainLoop", "title": "RainLoop Webmail", - "version": "1.7.3", - "release": "243", + "version": "1.8.0", + "release": "244", "description": "Simple, modern & fast web-based email client", "homepage": "http://rainloop.net", "main": "gulpfile.js", diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php index 59f889549..766d16924 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -2527,7 +2527,7 @@ class Actions $bComplete = true; $aCounts = array(); - + if ($this->Config()->Get('webmail', 'allow_additional_accounts', true)) { $iLimit = 7; @@ -3006,6 +3006,21 @@ class Actions )); } + /** + * @param string $sDomain + * + * @return string + */ + public function domainPathHelper($sDomain) + { + $sDomain = \strtolower(\trim($sDomain)); + + $sDomainPrefix = \substr(\preg_replace('/[^a-z0-9]+/', '', $sDomain), 0, 2); + $sDomainPrefix = \str_pad($sDomainPrefix, 2, '_'); + + return 'domains/'.$sDomainPrefix.'/'.\urlencode($sDomain); + } + /** * @return string */ @@ -3062,13 +3077,23 @@ class Actions $iCode = 0; $sContentType = ''; - $sValue = $oHttp->GetUrlAsString(APP_API_PATH.'status/'.\urlencode($sDomain), + $sValue = $oHttp->GetUrlAsString(APP_STATUS_PATH.$this->domainPathHelper($sDomain), 'RainLoop/'.APP_VERSION, $sContentType, $iCode, $this->Logger(), 10, $this->Config()->Get('labs', 'curl_proxy', ''), $this->Config()->Get('labs', 'curl_proxy_auth', ''), array(), false ); - if (200 !== $iCode) +// $sValue = $oHttp->GetUrlAsString(APP_API_PATH.'status/'.\urlencode($sDomain), +// 'RainLoop/'.APP_VERSION, $sContentType, $iCode, $this->Logger(), 10, +// $this->Config()->Get('labs', 'curl_proxy', ''), $this->Config()->Get('labs', 'curl_proxy_auth', ''), +// array(), false +// ); + + if (404 === $iCode) + { + $sValue = 'NO'; + } + else if (200 !== $iCode) { $sValue = ''; } @@ -3425,34 +3450,41 @@ class Actions } } - try + if ($oDomain->UseSieve()) { - $oSieveClient = \MailSo\Sieve\ManageSieveClient::NewInstance()->SetLogger($this->Logger()); - $oSieveClient->SetTimeOuts($iConnectionTimeout); - - $iTime = \microtime(true); - $oSieveClient->Connect($oDomain->SieveHost(), $oDomain->SievePort(), $oDomain->SieveSecure(), - !!$this->Config()->Get('ssl', 'verify_certificate', false), - !!$this->Config()->Get('ssl', 'allow_self_signed', true) - ); - - $iSieveTime = \microtime(true) - $iTime; - $oSieveClient->Disconnect(); - $bSieveResult = true; - } - catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException) - { - $this->Logger()->WriteException($oException, \MailSo\Log\Enumerations\Type::ERROR); - $sSieveErrorDesc = $oException->getSocketMessage(); - if (empty($sSieveErrorDesc)) + try { + $oSieveClient = \MailSo\Sieve\ManageSieveClient::NewInstance()->SetLogger($this->Logger()); + $oSieveClient->SetTimeOuts($iConnectionTimeout); + + $iTime = \microtime(true); + $oSieveClient->Connect($oDomain->SieveHost(), $oDomain->SievePort(), $oDomain->SieveSecure(), + !!$this->Config()->Get('ssl', 'verify_certificate', false), + !!$this->Config()->Get('ssl', 'allow_self_signed', true) + ); + + $iSieveTime = \microtime(true) - $iTime; + $oSieveClient->Disconnect(); + $bSieveResult = true; + } + catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException) + { + $this->Logger()->WriteException($oException, \MailSo\Log\Enumerations\Type::ERROR); + $sSieveErrorDesc = $oException->getSocketMessage(); + if (empty($sSieveErrorDesc)) + { + $sSieveErrorDesc = $oException->getMessage(); + } + } + catch (\Exception $oException) + { + $this->Logger()->WriteException($oException, \MailSo\Log\Enumerations\Type::ERROR); $sSieveErrorDesc = $oException->getMessage(); } } - catch (\Exception $oException) + else { - $this->Logger()->WriteException($oException, \MailSo\Log\Enumerations\Type::ERROR); - $sSieveErrorDesc = $oException->getMessage(); + $bSieveResult = true; } } diff --git a/rainloop/v/0.0.0/app/templates/Views/Admin/AdminSettingsLicensing.html b/rainloop/v/0.0.0/app/templates/Views/Admin/AdminSettingsLicensing.html index 8c7b89320..2b8b21ed4 100644 --- a/rainloop/v/0.0.0/app/templates/Views/Admin/AdminSettingsLicensing.html +++ b/rainloop/v/0.0.0/app/templates/Views/Admin/AdminSettingsLicensing.html @@ -63,7 +63,7 @@

-
+

Premium (Lifetime) @@ -74,7 +74,7 @@

-
+
diff --git a/rainloop/v/0.0.0/app/templates/Views/User/Login.html b/rainloop/v/0.0.0/app/templates/Views/User/Login.html index 2f0b2f705..64ba702f6 100644 --- a/rainloop/v/0.0.0/app/templates/Views/User/Login.html +++ b/rainloop/v/0.0.0/app/templates/Views/User/Login.html @@ -104,7 +104,7 @@
diff --git a/rainloop/v/0.0.0/app/templates/Views/User/SettingsGeneral.html b/rainloop/v/0.0.0/app/templates/Views/User/SettingsGeneral.html index 076882a01..82e7de3c6 100644 --- a/rainloop/v/0.0.0/app/templates/Views/User/SettingsGeneral.html +++ b/rainloop/v/0.0.0/app/templates/Views/User/SettingsGeneral.html @@ -90,7 +90,7 @@ } }">
-
-
diff --git a/rainloop/v/0.0.0/app/templates/Views/User/SystemDropDown.html b/rainloop/v/0.0.0/app/templates/Views/User/SystemDropDown.html index a2f30328c..6e36041b6 100644 --- a/rainloop/v/0.0.0/app/templates/Views/User/SystemDropDown.html +++ b/rainloop/v/0.0.0/app/templates/Views/User/SystemDropDown.html @@ -6,9 +6,9 @@   - +