'write': function (sNewValue) { var sCurrentValue = ko.unwrap(oTarget), aList = ko.unwrap(mList) ; if (Utils.isNonEmptyArray(aList)) { if (-1 < Utils.inArray(sNewValue, aList)) { oTarget(sNewValue); } else if (-1 < Utils.inArray(sCurrentValue, aList)) { oTarget(sCurrentValue + ' '); oTarget(sCurrentValue); } else { oTarget(aList[0] + ' '); oTarget(aList[0]); } } else { oTarget(''); } }
return _.compact(_.map(PgpStore.openpgpkeysPublic(), function (oKey) { return -1 < Utils.inArray(oKey, self.encryptKeysView()) ? null : { 'id': oKey.guid, 'name': '(' + oKey.id.substr(-6) + ') ' + oKey.user, 'key': oKey }; }));
$win.on('error', (event) => { if (event && event.originalEvent && event.originalEvent.message && -1 === inArray(event.originalEvent.message, [ 'Script error.', 'Uncaught Error: Error calling method on NPObject.' ])) { const time = timestamp(); if (this.lastErrorTime >= time) { return; } this.lastErrorTime = time; Remote.jsError( noop, event.originalEvent.message, event.originalEvent.filename, event.originalEvent.lineno, window.location && window.location.toString ? window.location.toString() : '', $html.attr('class'), microtime() - startMicrotime ); } });
MessageModel.prototype.initAttachmentsFromJson = function (oJsonAttachments) { var iIndex = 0, iLen = 0, oAttachmentModel = null, aResult = [] ; if (oJsonAttachments && 'Collection/AttachmentCollection' === oJsonAttachments['@Object'] && Utils.isNonEmptyArray(oJsonAttachments['@Collection'])) { for (iIndex = 0, iLen = oJsonAttachments['@Collection'].length; iIndex < iLen; iIndex++) { oAttachmentModel = AttachmentModel.newInstanceFromJson(oJsonAttachments['@Collection'][iIndex]); if (oAttachmentModel) { if ('' !== oAttachmentModel.cidWithOutTags && 0 < this.foundedCIDs.length && 0 <= Utils.inArray(oAttachmentModel.cidWithOutTags, this.foundedCIDs)) { oAttachmentModel.isLinked = true; } aResult.push(oAttachmentModel); } } } return aResult; };
_.each(aItems, function (oItem) { var sUid = self.getItemUid(oItem); aUids.push(sUid); if (null !== mFocused && mFocused === sUid) { self.focusedItem(oItem); mFocused = null; } if (0 < iLen && -1 < Utils.inArray(sUid, aCheckedCache)) { bChecked = true; oItem.checked(true); iLen--; } if (!bChecked && null !== mSelected && mSelected === sUid) { bSelected = true; self.selectedItem(oItem); mSelected = null; } });
/** * @param {(AjaxJsonAttachment|null)} oJsonAttachments * @returns {Array} */ initAttachmentsFromJson(json) { let index = 0, len = 0, attachment = null; const result = []; if (json && 'Collection/AttachmentCollection' === json['@Object'] && isNonEmptyArray(json['@Collection'])) { for (index = 0, len = json['@Collection'].length; index < len; index++) { attachment = AttachmentModel.newInstanceFromJson(json['@Collection'][index]); if (attachment) { if ('' !== attachment.cidWithOutTags && 0 < this.foundedCIDs.length && 0 <= inArray(attachment.cidWithOutTags, this.foundedCIDs)) { attachment.isLinked = true; } result.push(attachment); } } } return result; }
Remote.licensing(function (sResult, oData) { Data.licensingProcess(false); if (Enums.StorageResultType.Success === sResult && oData && oData.Result && Utils.isNormal(oData.Result['Expired'])) { Data.licenseValid(true); Data.licenseExpired(Utils.pInt(oData.Result['Expired'])); Data.licenseError(''); Data.licensing(true); } else { if (oData && oData.ErrorCode && -1 < Utils.inArray(Utils.pInt(oData.ErrorCode), [ Enums.Notification.LicensingServerIsUnavailable, Enums.Notification.LicensingExpired ])) { Data.licenseError(Utils.getNotification(Utils.pInt(oData.ErrorCode))); Data.licensing(true); } else { if (Enums.StorageResultType.Abort === sResult) { Data.licenseError(Utils.getNotification(Enums.Notification.LicensingServerIsUnavailable)); Data.licensing(true); } else { Data.licensing(false); } } } }, bForce);
MessageFullModel.prototype.initByJson = function(oJson) { var bResult = false; if (oJson && 'Object/Message' === oJson['@Object']) { if (MessageSimpleModel.prototype.initByJson.call(this, oJson)) { this.priority = Utils.pInt(oJson.Priority); this.priority = Utils.inArray(this.priority, [Enums.MessagePriority.High, Enums.MessagePriority.Low]) ? this.priority : Enums.MessagePriority.Normal; this.hash = Utils.pString(oJson.Hash); this.requestHash = Utils.pString(oJson.RequestHash); this.proxy = !!oJson.ExternalProxy; this.hasAttachments = !!oJson.HasAttachments; bResult = true; } } return bResult; };
MessageListMailBoxUserView.prototype.flagMessages = function (oCurrentMessage) { var aChecked = this.messageListCheckedOrSelected(), aCheckedUids = [] ; if (oCurrentMessage) { if (0 < aChecked.length) { aCheckedUids = _.map(aChecked, function (oMessage) { return oMessage.uid; }); } if (0 < aCheckedUids.length && -1 < Utils.inArray(oCurrentMessage.uid, aCheckedUids)) { this.setAction(oCurrentMessage.folderFullNameRaw, true, oCurrentMessage.flagged() ? Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, aChecked); } else { this.setAction(oCurrentMessage.folderFullNameRaw, true, oCurrentMessage.flagged() ? Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, [oCurrentMessage]); } } };
Remote.login(_.bind(function(sResult, oData) { if (Enums.StorageResultType.Success === sResult && oData && 'Login' === oData.Action) { if (oData.Result) { if (oData.TwoFactorAuth) { this.additionalCode(''); this.additionalCode.visibility(true); this.submitRequest(false); _.delay(function() { self.additionalCode.focused(true); }, Enums.Magics.Time100ms); } else if (oData.Admin) { require('App/User').default.redirectToAdminPanel(); } else { require('App/User').default.loginAndLogoutReload(false); } } else if (oData.ErrorCode) { this.submitRequest(false); if (-1 < Utils.inArray(oData.ErrorCode, [Enums.Notification.InvalidInputArgument])) { oData.ErrorCode = Enums.Notification.AuthError; } this.submitError(Translator.getNotificationFromResponse(oData)); if ('' === this.submitError()) { this.submitError(Translator.getNotification(Enums.Notification.UnknownError)); } else { if (oData.ErrorMessageAdditional) { this.submitErrorAddidional(oData.ErrorMessageAdditional); } } } else { this.submitRequest(false); } } else { this.submitRequest(false); this.submitError(Translator.getNotification(Enums.Notification.UnknownError)); } }, this), this.email(), '', sLoginPassword, !!this.signMe(),
/** * @param {AjaxJsonMessage} json * @returns {boolean} */ initByJson(json) { let result = false, priority = MessagePriority.Normal; if (json && 'Object/Message' === json['@Object']) { priority = pInt(json.Priority); this.priority(-1 < inArray(priority, [MessagePriority.High, MessagePriority.Low]) ? priority : MessagePriority.Normal); this.folderFullNameRaw = json.Folder; this.uid = json.Uid; this.hash = json.Hash; this.requestHash = json.RequestHash; this.proxy = !!json.ExternalProxy; this.size(pInt(json.Size)); this.from = emailArrayFromJson(json.From); this.to = emailArrayFromJson(json.To); this.cc = emailArrayFromJson(json.Cc); this.bcc = emailArrayFromJson(json.Bcc); this.replyTo = emailArrayFromJson(json.ReplyTo); this.deliveredTo = emailArrayFromJson(json.DeliveredTo); this.unsubsribeLinks = isNonEmptyArray(json.UnsubsribeLinks) ? json.UnsubsribeLinks : []; this.subject(json.Subject); if (isArray(json.SubjectParts)) { this.subjectPrefix(json.SubjectParts[0]); this.subjectSuffix(json.SubjectParts[1]); } else { this.subjectPrefix(''); this.subjectSuffix(this.subject()); } this.dateTimeStampInUTC(pInt(json.DateTimeStampInUTC)); this.hasAttachments(!!json.HasAttachments); this.attachmentsSpecData(isArray(json.AttachmentsSpecData) ? json.AttachmentsSpecData : []); this.fromEmailString(emailArrayToString(this.from, true)); this.fromClearEmailString(emailArrayToStringClear(this.from)); this.toEmailsString(emailArrayToString(this.to, true)); this.toClearEmailsString(emailArrayToStringClear(this.to)); this.threads(isArray(json.Threads) ? json.Threads : []); this.initFlagsByJson(json); this.computeSenderEmail(); result = true; } return result; }
return _.compact(_.flatten(_.map(PgpStore.openpgpkeysPublic(), function(oKey, iIndex) { return -1 < Utils.inArray(oKey, self.encryptKeysView()) ? null : _.map(oKey.users, function(sUser) { return { 'id': oKey.guid, 'name': '(' + oKey.id.substr(-8).toUpperCase() + ') ' + sUser, 'key': oKey, 'class': iIndex % 2 ? 'odd' : 'even' }; }); }), true));
mNextFocused = _.find(aCache, function (sUid) { if (bGetNext && -1 < Utils.inArray(sUid, aUids)) { return sUid; } else if (mNextFocused === sUid) { bGetNext = true; } return false; });
Globals.$win.on('error', function (oEvent) { if (oEvent && oEvent.originalEvent && oEvent.originalEvent.message && -1 === Utils.inArray(oEvent.originalEvent.message, [ 'Script error.', 'Uncaught Error: Error calling method on NPObject.' ])) { Remote.jsError( Utils.emptyFunction, oEvent.originalEvent.message, oEvent.originalEvent.filename, oEvent.originalEvent.lineno, window.location && window.location.toString ? window.location.toString() : '', Globals.$html.attr('class'), Utils.microtime() - Globals.startMicrotime ); } });
verify() { if ('' === this.name()) { this.name.error(true); return false; } if (0 < this.conditions().length) { if (_.find(this.conditions(), (cond) => cond && !cond.verify())) { return false; } } if ('' === this.actionValue()) { if (-1 < inArray(this.actionType(), [ FiltersAction.MoveTo, FiltersAction.Forward, FiltersAction.Reject, FiltersAction.Vacation ])) { this.actionValue.error(true); return false; } } if (FiltersAction.Forward === this.actionType() && -1 === this.actionValue().indexOf('@')) { this.actionValue.error(true); return false; } if (FiltersAction.Vacation === this.actionType() && '' !== this.actionValueFourth() && -1 === this.actionValueFourth().indexOf('@') ) { this.actionValueFourth.error(true); return false; } this.name.error(false); this.actionValue.error(false); return true; }
MessageModel.prototype.initUpdateByMessageJson = function (oJsonMessage) { var bResult = false, iPriority = Enums.MessagePriority.Normal ; if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object']) { iPriority = Utils.pInt(oJsonMessage.Priority); this.priority(-1 < Utils.inArray(iPriority, [Enums.MessagePriority.High, Enums.MessagePriority.Low]) ? iPriority : Enums.MessagePriority.Normal); this.aDraftInfo = oJsonMessage.DraftInfo; this.sMessageId = oJsonMessage.MessageId; this.sInReplyTo = oJsonMessage.InReplyTo; this.sReferences = oJsonMessage.References; this.proxy = !!oJsonMessage.ExternalProxy; if (require('Stores/User/Pgp').capaOpenPGP()) { this.isPgpSigned(!!oJsonMessage.PgpSigned); this.isPgpEncrypted(!!oJsonMessage.PgpEncrypted); } this.hasAttachments(!!oJsonMessage.HasAttachments); this.attachmentsSpecData(Utils.isArray(oJsonMessage.AttachmentsSpecData) ? oJsonMessage.AttachmentsSpecData : []); this.foundedCIDs = Utils.isArray(oJsonMessage.FoundedCIDs) ? oJsonMessage.FoundedCIDs : []; this.attachments(this.initAttachmentsFromJson(oJsonMessage.Attachments)); this.readReceipt(oJsonMessage.ReadReceipt || ''); this.computeSenderEmail(); bResult = true; } return bResult; };
/** * @param {AjaxJsonMessage} json * @returns {boolean} */ initUpdateByMessageJson(json) { let result = false, priority = MessagePriority.Normal; if (json && 'Object/Message' === json['@Object']) { priority = pInt(json.Priority); this.priority(-1 < inArray(priority, [MessagePriority.High, MessagePriority.Low]) ? priority : MessagePriority.Normal); this.aDraftInfo = json.DraftInfo; this.sMessageId = json.MessageId; this.sInReplyTo = json.InReplyTo; this.sReferences = json.References; this.proxy = !!json.ExternalProxy; if (PgpStore.capaOpenPGP()) { this.isPgpSigned(!!json.PgpSigned); this.isPgpEncrypted(!!json.PgpEncrypted); } this.hasAttachments(!!json.HasAttachments); this.attachmentsSpecData(isArray(json.AttachmentsSpecData) ? json.AttachmentsSpecData : []); this.foundedCIDs = isArray(json.FoundedCIDs) ? json.FoundedCIDs : []; this.attachments(this.initAttachmentsFromJson(json.Attachments)); this.readReceipt(json.ReadReceipt || ''); this.computeSenderEmail(); result = true; } return result; }
AppUser.prototype.moveOrDeleteResponseHelper = function (sResult, oData) { if (Enums.StorageResultType.Success === sResult && FolderStore.currentFolder()) { if (oData && Utils.isArray(oData.Result) && 2 === oData.Result.length) { Cache.setFolderHash(oData.Result[0], oData.Result[1]); } else { Cache.setFolderHash(FolderStore.currentFolderFullNameRaw(), ''); if (oData && -1 < Utils.inArray(oData.ErrorCode, [Enums.Notification.CantMoveMessage, Enums.Notification.CantCopyMessage])) { window.alert(Translator.getNotification(oData.ErrorCode)); } } this.reloadMessageList(0 === MessageStore.messageList().length); this.quotaDebounce(); } };
}).always(function(oData, sTextStatus) { var bCached = false, oErrorData = null, sType = Enums.StorageResultType.Error; if (oData && oData.Time) { bCached = Utils.pInt(oData.Time) > Utils.microtime() - iStart; } // backward capability switch (true) { case 'success' === sTextStatus && oData && oData.Result && sAction === oData.Action: sType = Enums.StorageResultType.Success; break; case 'abort' === sTextStatus && (!oData || !oData.__aborted__): sType = Enums.StorageResultType.Abort; break; // no default } Plugins.runHook('ajax-default-response', [sAction, Enums.StorageResultType.Success === sType ? oData : null, sType, bCached, oParameters]); if ('success' === sTextStatus) { if (oData && oData.Result && sAction === oData.Action) { oData.__cached__ = bCached; resolve(oData); } else if (oData && oData.Action) { oErrorData = oData; reject(oData.ErrorCode ? oData.ErrorCode : Enums.Notification.AjaxFalse); } else { oErrorData = oData; reject(Enums.Notification.AjaxParse); } } else if ('timeout' === sTextStatus) { oErrorData = oData; reject(Enums.Notification.AjaxTimeout); } else if ('abort' === sTextStatus) { if (!oData || !oData.__aborted__) { reject(Enums.Notification.AjaxAbort); } } else { oErrorData = oData; reject(Enums.Notification.AjaxParse); } if (self.oRequests[sAction]) { self.oRequests[sAction] = null; delete self.oRequests[sAction]; } self.setTrigger(fTrigger, false); if (oErrorData) { if (-1 < Utils.inArray(oErrorData.ErrorCode, [ Enums.Notification.AuthError, Enums.Notification.AccessError, Enums.Notification.ConnectionError, Enums.Notification.DomainNotAllowed, Enums.Notification.AccountNotAllowed, Enums.Notification.MailServerError, Enums.Notification.UnknownNotification, Enums.Notification.UnknownError ])) { Globals.data.iAjaxErrorCount += 1; } if (Enums.Notification.InvalidToken === oErrorData.ErrorCode) { Globals.data.iTokenErrorCount += 1; } if (Consts.TOKEN_ERROR_LIMIT < Globals.data.iTokenErrorCount) { if (Globals.data.__APP__ && Globals.data.__APP__.loginAndLogoutReload) { Globals.data.__APP__.loginAndLogoutReload(false, true); } } if (oErrorData.ClearAuth || oErrorData.Logout || Consts.AJAX_ERROR_LIMIT < Globals.data.iAjaxErrorCount) { if (Globals.data.__APP__ && Globals.data.__APP__.clearClientSideToken) { Globals.data.__APP__.clearClientSideToken(); } if (Globals.data.__APP__ && !oErrorData.ClearAuth && Globals.data.__APP__.loginAndLogoutReload) { Globals.data.__APP__.loginAndLogoutReload(false, true); } } } });
export const staticFileType = _.memoize((ext, mimeType) => { ext = trim(ext).toLowerCase(); mimeType = trim(mimeType).toLowerCase(); let result = FileType.Unknown; const mimeTypeParts = mimeType.split('/'); switch (true) { case 'image' === mimeTypeParts[0] || -1 < inArray(ext, [ 'png', 'jpg', 'jpeg', 'gif', 'bmp' ]): result = FileType.Image; break; case 'audio' === mimeTypeParts[0] || -1 < inArray(ext, [ 'mp3', 'ogg', 'oga', 'wav' ]): result = FileType.Audio; break; case 'video' === mimeTypeParts[0] || -1 < inArray(ext, [ 'mkv', 'avi' ]): result = FileType.Video; break; case -1 < inArray(ext, [ 'php', 'js', 'css' ]): result = FileType.Code; break; case 'eml' === ext || -1 < inArray(mimeType, [ 'message/delivery-status', 'message/rfc822' ]): result = FileType.Eml; break; case ('text' === mimeTypeParts[0] && 'html' !== mimeTypeParts[1]) || -1 < inArray(ext, [ 'txt', 'log' ]): result = FileType.Text; break; case ('text/html' === mimeType) || -1 < inArray(ext, [ 'html' ]): result = FileType.Html; break; case -1 < inArray(mimeTypeParts[1], [ 'zip', '7z', 'tar', 'rar', 'gzip', 'bzip', 'bzip2', 'x-zip', 'x-7z', 'x-rar', 'x-tar', 'x-gzip', 'x-bzip', 'x-bzip2', 'x-zip-compressed', 'x-7z-compressed', 'x-rar-compressed' ]) || -1 < inArray(ext, [ 'zip', '7z', 'tar', 'rar', 'gzip', 'bzip', 'bzip2' ]): result = FileType.Archive; break; case -1 < inArray(mimeTypeParts[1], ['pdf', 'x-pdf']) || -1 < inArray(ext, [ 'pdf' ]): result = FileType.Pdf; break; case -1 < inArray(mimeType, [ 'application/pgp-signature', 'application/pgp-keys' ]) || -1 < inArray(ext, [ 'asc', 'pem', 'ppk' ]): result = FileType.Certificate; break; case -1 < inArray(mimeType, ['application/pkcs7-signature']) || -1 < inArray(ext, ['p7s']): result = FileType.CertificateBin; break; case -1 < inArray(mimeTypeParts[1], [ 'rtf', 'msword', 'vnd.msword', 'vnd.openxmlformats-officedocument.wordprocessingml.document', 'vnd.openxmlformats-officedocument.wordprocessingml.template', 'vnd.ms-word.document.macroEnabled.12', 'vnd.ms-word.template.macroEnabled.12' ]): result = FileType.WordText; break; case -1 < inArray(mimeTypeParts[1], [ 'excel', 'ms-excel', 'vnd.ms-excel', 'vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'vnd.openxmlformats-officedocument.spreadsheetml.template', 'vnd.ms-excel.sheet.macroEnabled.12', 'vnd.ms-excel.template.macroEnabled.12', 'vnd.ms-excel.addin.macroEnabled.12', 'vnd.ms-excel.sheet.binary.macroEnabled.12' ]): result = FileType.Sheet; break; case -1 < inArray(mimeTypeParts[1], [ 'powerpoint', 'ms-powerpoint', 'vnd.ms-powerpoint', 'vnd.openxmlformats-officedocument.presentationml.presentation', 'vnd.openxmlformats-officedocument.presentationml.template', 'vnd.openxmlformats-officedocument.presentationml.slideshow', 'vnd.ms-powerpoint.addin.macroEnabled.12', 'vnd.ms-powerpoint.presentation.macroEnabled.12', 'vnd.ms-powerpoint.template.macroEnabled.12', 'vnd.ms-powerpoint.slideshow.macroEnabled.12' ]): result = FileType.Presentation; break; // no default } return result; });
MessageModel.prototype.initByJson = function (oJsonMessage) { var bResult = false, iPriority = Enums.MessagePriority.Normal ; if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object']) { iPriority = Utils.pInt(oJsonMessage.Priority); this.priority(-1 < Utils.inArray(iPriority, [Enums.MessagePriority.High, Enums.MessagePriority.Low]) ? iPriority : Enums.MessagePriority.Normal); this.folderFullNameRaw = oJsonMessage.Folder; this.uid = oJsonMessage.Uid; this.hash = oJsonMessage.Hash; this.requestHash = oJsonMessage.RequestHash; this.proxy = !!oJsonMessage.ExternalProxy; this.size(Utils.pInt(oJsonMessage.Size)); this.from = MessageHelper.emailArrayFromJson(oJsonMessage.From); this.to = MessageHelper.emailArrayFromJson(oJsonMessage.To); this.cc = MessageHelper.emailArrayFromJson(oJsonMessage.Cc); this.bcc = MessageHelper.emailArrayFromJson(oJsonMessage.Bcc); this.replyTo = MessageHelper.emailArrayFromJson(oJsonMessage.ReplyTo); this.deliveredTo = MessageHelper.emailArrayFromJson(oJsonMessage.DeliveredTo); this.subject(oJsonMessage.Subject); if (Utils.isArray(oJsonMessage.SubjectParts)) { this.subjectPrefix(oJsonMessage.SubjectParts[0]); this.subjectSuffix(oJsonMessage.SubjectParts[1]); } else { this.subjectPrefix(''); this.subjectSuffix(this.subject()); } this.dateTimeStampInUTC(Utils.pInt(oJsonMessage.DateTimeStampInUTC)); this.hasAttachments(!!oJsonMessage.HasAttachments); this.attachmentsSpecData(Utils.isArray(oJsonMessage.AttachmentsSpecData) ? oJsonMessage.AttachmentsSpecData : []); this.fromEmailString(MessageHelper.emailArrayToString(this.from, true)); this.fromClearEmailString(MessageHelper.emailArrayToStringClear(this.from)); this.toEmailsString(MessageHelper.emailArrayToString(this.to, true)); this.toClearEmailsString(MessageHelper.emailArrayToStringClear(this.to)); this.threads(Utils.isArray(oJsonMessage.Threads) ? oJsonMessage.Threads : []); this.initFlagsByJson(oJsonMessage); this.computeSenderEmail(); bResult = true; } return bResult; };
this.viewPropertiesNames = this.viewProperties.filter(function(oProperty) { return -1 < Utils.inArray(oProperty.type(), [ Enums.ContactPropertyType.FirstName, Enums.ContactPropertyType.LastName ]); });
this.viewPropertiesOther = this.viewProperties.filter(function(oProperty) { return -1 < Utils.inArray(oProperty.type(), [ Enums.ContactPropertyType.Note ]); });
write: function (sValue) { sValue = -1 === Utils.inArray(sValue, [ Enums.ComposeType.Reply, Enums.ComposeType.ReplyAll, Enums.ComposeType.Forward ]) ? Enums.ComposeType.Reply : sValue; this.lastReplyAction_(sValue); },
var aList = _.filter(this.viewProperties(), function (oProperty) { return -1 < Utils.inArray(oProperty.type(), [ Enums.ContactPropertyType.Nick ]); });
this.saveToDropboxAllowed = ko.computed(function () { return -1 < Utils.inArray('dropbox', this.attachmentsActions()) && this.allowAttachmnetControls(); }, this);
this.saveToOwnCloudAllowed = ko.computed(function () { return -1 < Utils.inArray('owncloud', this.attachmentsActions()) && this.allowAttachmnetControls(); }, this);
this.downloadAsZipAllowed = ko.computed(function () { return -1 < Utils.inArray('zip', this.attachmentsActions()) && this.allowAttachmnetControls(); }, this);
aMessages = sCurrentFolderFullNameRaw === sFromFolderFullNameRaw ? _.filter(aMessageList, function (oMessage) { return oMessage && -1 < Utils.inArray(Utils.pInt(oMessage.uid), aUidForRemove); }) : []
MessageUserStore.prototype.setMessage = function (oData, bCached) { var bNew = false, bIsHtml = false, sTag = 'div', bHasExternals = false, bHasInternals = false, oBody = null, oTextBody = null, sId = '', sPlain = '', sResultHtml = '', bPgpSigned = false, bPgpEncrypted = false, oMessagesDom = this.messagesBodiesDom(), oSelectedMessage = this.selectorMessageSelected(), oMessage = this.message(), aThreads = [] ; if (oData && oMessage && oData.Result && 'Object/Message' === oData.Result['@Object'] && oMessage.folderFullNameRaw === oData.Result.Folder) { aThreads = oMessage.threads(); if (oMessage.uid !== oData.Result.Uid && 1 < aThreads.length && -1 < Utils.inArray(oData.Result.Uid, aThreads)) { oMessage = MessageModel.newInstanceFromJson(oData.Result); if (oMessage) { oMessage.threads(aThreads); Cache.initMessageFlagsFromCache(oMessage); this.message(this.staticMessage.populateByMessageListItem(oMessage)); oMessage = this.message(); bNew = true; } } if (oMessage && oMessage.uid === oData.Result.Uid) { this.messageError(''); oMessage.initUpdateByMessageJson(oData.Result); Cache.addRequestedMessage(oMessage.folderFullNameRaw, oMessage.uid); if (!bCached) { oMessage.initFlagsByJson(oData.Result); } oMessagesDom = oMessagesDom && oMessagesDom[0] ? oMessagesDom : null; if (oMessagesDom) { sId = 'rl-mgs-' + oMessage.hash.replace(/[^a-zA-Z0-9]/g, ''); oTextBody = oMessagesDom.find('#' + sId); if (!oTextBody || !oTextBody[0]) { bHasExternals = !!oData.Result.HasExternals; bHasInternals = !!oData.Result.HasInternals; if (Utils.isNormal(oData.Result.Html) && '' !== oData.Result.Html) { bIsHtml = true; sResultHtml = oData.Result.Html.toString(); } else if (Utils.isNormal(oData.Result.Plain) && '' !== oData.Result.Plain) { bIsHtml = false; sResultHtml = Utils.plainToHtml(oData.Result.Plain.toString(), false); if ((oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) && require('Stores/User/Pgp').capaOpenPGP()) { sPlain = Utils.pString(oData.Result.Plain); bPgpEncrypted = /---BEGIN PGP MESSAGE---/.test(sPlain); if (!bPgpEncrypted) { bPgpSigned = /-----BEGIN PGP SIGNED MESSAGE-----/.test(sPlain) && /-----BEGIN PGP SIGNATURE-----/.test(sPlain); } Globals.$div.empty(); if (bPgpSigned && oMessage.isPgpSigned()) { sResultHtml = Globals.$div.append( $('<pre class="b-plain-openpgp signed"></pre>').text(sPlain) ).html() ; } else if (bPgpEncrypted && oMessage.isPgpEncrypted()) { sResultHtml = Globals.$div.append( $('<pre class="b-plain-openpgp encrypted"></pre>').text(sPlain) ).html() ; } else { sResultHtml = '<pre>' + sResultHtml + '</pre>'; } sPlain = ''; Globals.$div.empty(); oMessage.isPgpSigned(bPgpSigned); oMessage.isPgpEncrypted(bPgpEncrypted); } else { sResultHtml = '<pre>' + sResultHtml + '</pre>'; } } else { bIsHtml = false; sResultHtml = '<pre>' + sResultHtml + '</pre>'; } oBody = $('<div id="' + sId + '" ></div>').hide().addClass('rl-cache-class'); oBody.data('rl-cache-count', ++Globals.iMessageBodyCacheCount); oBody .html(Utils.findEmailAndLinks(sResultHtml)) .addClass('b-text-part ' + (bIsHtml ? 'html' : 'plain')) ; oMessage.isHtml(!!bIsHtml); oMessage.hasImages(!!bHasExternals); oMessage.body = oBody; if (oMessage.body) { oMessagesDom.append(oMessage.body); } oMessage.storeDataInDom(); if (bHasInternals) { oMessage.showInternalImages(true); } if (oMessage.hasImages() && SettingsStore.showImages()) { oMessage.showExternalImages(true); } this.purgeMessageBodyCacheThrottle(); } else { oMessage.body = oTextBody; if (oMessage.body) { oMessage.body.data('rl-cache-count', ++Globals.iMessageBodyCacheCount); oMessage.fetchDataFromDom(); } } this.messageActiveDom(oMessage.body); this.hideMessageBodies(); if (oBody) { this.initOpenPgpControls(oBody); this.initBlockquoteSwitcher(oBody); } oMessage.body.show(); } Cache.initMessageFlagsFromCache(oMessage); if (oMessage.unseen() || oMessage.hasUnseenSubMessage()) { require('App/User').messageListAction(oMessage.folderFullNameRaw, oMessage.uid, Enums.MessageSetAction.SetSeen, [oMessage]); } if (bNew) { oMessage = this.message(); if (oSelectedMessage && oMessage && ( oMessage.folderFullNameRaw !== oSelectedMessage.folderFullNameRaw || oMessage.uid !== oSelectedMessage.uid )) { this.selectorMessageSelected(null); if (1 === this.messageList().length) { this.selectorMessageFocused(null); } } else if (!oSelectedMessage && oMessage) { oSelectedMessage = _.find(this.messageList(), function (oSubMessage) { return oSubMessage && oSubMessage.folderFullNameRaw === oMessage.folderFullNameRaw && oSubMessage.uid === oMessage.uid; }); if (oSelectedMessage) { this.selectorMessageSelected(oSelectedMessage); this.selectorMessageFocused(oSelectedMessage); } } } Utils.windowResize(); } } };