sogo/UI/WebServerResources/js/Mailer.services.js.map
Francis Lachapelle 369060a52f (js/css) Update generated files
With Angular Material 0.11.3
2015-10-13 16:05:39 -04:00

1 line
132 KiB
Plaintext

{"version":3,"file":"Mailer.services.js","sources":["Mailer/Account.service.js","Mailer/Mailbox.service.js","Mailer/Message.service.js","Mailer/VirtualMailbox.service.js","Mailer/MailboxController.js","Mailer/MailboxesController.js","Mailer/MessageController.js","Mailer/MessageEditorController.js","Mailer/sgIMIP.directive.js"],"names":["Account","futureAccountData","then","angular","extend","this","_","each","identities","identity","fullName","full","email","$log","debug","JSON","stringify","undefined","$factory","$q","$timeout","Settings","Resource","Preferences","Mailbox","Message","$$resource","activeUser","$Preferences","$Mailbox","$Message","module","e","factory","$findAll","data","$unwrapCollection","fetch","o","collection","forEach","i","id","prototype","$getMailboxes","options","_this","$mailboxes","reload","$find","ready","expandedFolders","_visit","mailboxes","$expanded","indexOf","children","length","settings","Mail","ExpandedFolders","isString","fromJson","$flattenMailboxes","when","allMailboxes","expandedMailboxes","push","all","$$flattenMailboxes","saveState","reduce","mailbox","post","$getMailboxByType","type","_find","find","console","specialMailboxes","$getMailboxByPath","path","$newMailbox","name","toString","$newMessage","message","accountId","mailboxPath","$absolutePath","asDraft","editable","$addDelegate","user","deferred","defer","param","uid","pluck","delegates","resolve","users","status","reject","l","promise","$removeDelegate","splice","account","futureMailboxData","$account","init","newMailboxData","create","$unwrap","Acl","PRELOAD","$$Acl","$query","sort","asc","selectedFolder","$refreshTimeout","$virtualMode","SortingState","parseInt","constant","LOOKAHEAD","SIZE","createMailboxes","level","index","map","split","component","asCSSIdentifier","join","$isLoading","$messages","uidsMap","$id","$acl","$isEditable","isEditable","isUndefined","$shadowData","$omit","getLength","getItemAtIndex","$loadMessage","$selectedCount","count","filter","selected","isSelectedMessage","messageId","selectedMessage","$filter","sortingAttributes","filters","isDefined","unseenCount","cancel","searchInput","secondFilter","match","searchBy","copy","refreshViewCheck","defaults","SOGoRefreshViewCheck","f","bind","timeInterval","endIndex","uids","futureHeadersData","startIndex","max","loaded","subject","Math","min","loading","$unwrapHeaders","$rename","findParent","parent","parentMailbox","$save","sibling","localeCompare","$compact","$setFolderAs","$emptyTrash","$markAsRead","$flagMessages","flags","operation","msgUIDs","$delete","remove","$deleteMessages","$copyMessages","folder","$moveMessages","$reset","value","key","save","error","$futureMailboxData","headers","invoke","threaded","msgs","msg","object","isError","j","messageHeaders","futureMessageData","lazy","$mailbox","$hasUnsafeContent","$loadUnsafeContent","$showDetailedRecipients","to","cc","bcc","$formatFullAddresses","Gravatar","$gravatar","SOGoMailLabelsColors","$tags","SOGoMailDisplayRemoteInlineImages","$displayRemoteInlineImages","filterTags","query","re","RegExp","results","keys","tag","pair","search","description","color","draftId","$setUID","oldUID","shortname","replace","image","$shortRecipients","result","$shortAddress","address","loadUnsafeContent","showDetailedRecipients","$content","parts","part","msgclass","content","alternatePart","preferredPart","contentType","isArray","mixedPart","safeContent","html","unsafeContent","document","createElement","innerHTML","suffix","element","elements","querySelectorAll","attr","removeAttr","participants","participant","compile","$editableContent","text","addTag","$addOrRemoveTag","removeTag","$imipAction","action","$reload","$sendMDN","shouldAskReceipt","$deleteAttachment","filename","attachmentAttrs","attachment","toggleFlag","isflagged","$reply","$newDraft","$replyAll","$forward","origin","response","$send","startsWith","isanswered","isforwarded","$futureMessageData","isread","VirtualMailbox","setMailboxes","startSearch","params","stopSearch","resetSelectedMessage","len","k","MailboxController","$state","$mdDialog","stateAccounts","stateAccount","stateMailbox","encodeUriFilter","focus","Dialog","selectMessage","go","mailboxId","toggleMessageSelection","$event","preventDefault","stopPropagation","unselectMessages","vm","confirmDeleteSelectedMessages","confirm","selectedMessages","selectedUIDs","difference","alert","copySelectedMessages","saveSelectedMessages","window","location","href","ApplicationBaseURL","selectAll","markSelectedMessagesAsFlagged","d","markSelectedMessagesAsUnread","field","sortedBy","cancelSearch","mode","newMessage","messageDialog","show","body","targetEvent","clickOutsideToClose","escapeToClose","templateUrl","controller","controllerAs","locals","accounts","stateMessage","stateRecipients","service","$inject","MailboxesController","User","showAdvancedSearch","showingAdvancedSearch","hideAdvancedSearch","searchPreviousMailbox","toggleAdvancedSearch","virtualMailbox","root","folders","subfolders","addSearchParam","v","currentSearchParam","newSearchParam","pattern","n","searchParam","substring","trim","negative","newFolder","parentFolder","prompt","delegate","MailboxDelegationController","$scope","userFilter","closeModal","hide","removeUser","addUser","userToAdd","searchText","editFolder","editMode","revertEditing","selectFolder","saveFolder","compactFolder","emptyTrashFolder","exportMails","confirmDelete","markFolderRead","share","$users","usersWithACL","metadataForFolder","icon","setFolderAs","refreshUnseenCount","unseenCountFolders","includes","from","current","MessageController","$window","sgSettings","doDelete","findIndex","showMailEditor","recipients","close","reply","replyAll","forward","edit","openPopup","url","baseURL","wId","popupWindow","open","closePopup","recipient","saveMessage","viewRawSource","MessageRawSourceDialogController","scope","template","tags","$watchCollection","oldTags","newTags","MessageEditorController","$stateParams","FileUploader","AddressBook","autosave","send","contactFilter","$filterAll","addRecipient","$$fullname","$$email","autosaveDrafts","SOGoMailAutoSave","autocomplete","hideCc","hideBcc","flatten","uploader","autoUpload","alias","onProgressItem","item","progress","onSuccessItem","onCancelItem","file","removeFromQueue","onErrorItem","actionName","msgObject","union","localeCode","LocaleCode","sgImip","link","iElement","attrs","ctrl","pathToAttachment","sgImipPath","restrict","sgImipController","delegateInvitation","delegatedTo","iCalendarAction","receiveUpdates","c_email","viewer","directive"],"mappings":"CAEA,WACE,YAOA,SAASA,SAAQC,mBAEuB,kBAA3BA,mBAAkBC,OAC3BC,QAAQC,OAAOC,KAAMJ,mBACrBK,EAAEC,KAAKF,KAAKG,WAAY,SAASC,UAC3BA,SAASC,SACXD,SAASE,KAAOF,SAASC,SAAW,KAAOD,SAASG,MAAQ,IAE5DH,SAASE,KAAO,IAAMF,SAASG,MAAQ,MAE3CZ,QAAQa,KAAKC,MAAM,YAAcC,KAAKC,UAAUf,kBAAmBgB,OAAW,KAalFjB,QAAQkB,UAAY,KAAM,WAA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ACvBrI,GAAG6H,SAAW3b,SAAS8T,GAAGoI,eAAsD,IAAtC/b,YAAYkJ,SAAS8S,iBAAsB,KACvFrI,GAAGwJ,WAAand,YAAYkJ,SAASkU,aAhHzChC,wBAAwBrF,SAAW,eAAgB,YAAa,eAAgB,gBAAiB,eAAgB,kBAAmB,WAAY,UAAW,SAAU,cAAe,eAoHpLnX,QACG4B,OAAO,iBACPgV,WAAW,0BAA2B4F,4BC5H3C,WAEE,YAQA,SAASiC,UAOP,QAASC,MAAKxC,MAAOyC,SAAUC,MAAOC,MACpCA,KAAKC,iBAAmBF,MAAMG,WAPhC,OACEC,SAAU,IACVN,KAAMA,KACN9H,WAAY,oBAYhB,QAASqI,kBAAiBnG,OAAQzB,MAChC,GAAItC,IAAK7U,IAET4Y,QAAOoG,oBAAqB,EAC5BpG,OAAOqG,YAAc,GACrBrG,OAAOO,WAAa,GAEpBP,OAAOC,WAAa,SAAS5R,QAC3B,MAAOkQ,MAAK3N,QAAQvC,SAGtB2R,OAAOsG,gBAAkB,SAASpN,QAChC,GAAIhQ,KAEU,aAAVgQ,SACFhQ,MACEqd,gBAAgB,EAChBF,YAAarG,OAAOqG,YAAYG,UAIpCxG,OAAOyG,OAAOpa,QAAQ4M,YAAYgD,GAAG+J,iBAAkB9M,OAAQhQ,OAtBnEid,iBAAiB9H,SAAW,SAAU,QA0BtCnX,QACG4B,OAAO,iBACPgV,WAAW,mBAAoBqI,kBAC/BO,UAAU,SAAUf","sourcesContent":["/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @name Account\n * @constructor\n * @param {object} futureAccountData\n */\n function Account(futureAccountData) {\n // Data is immediately available\n if (typeof futureAccountData.then !== 'function') {\n angular.extend(this, futureAccountData);\n _.each(this.identities, function(identity) {\n if (identity.fullName)\n identity.full = identity.fullName + ' <' + identity.email + '>';\n else\n identity.full = '<' + identity.email + '>';\n });\n Account.$log.debug('Account: ' + JSON.stringify(futureAccountData, undefined, 2));\n }\n else {\n // The promise will be unwrapped first\n //this.$unwrap(futureAccountData);\n }\n }\n\n /**\n * @memberof Account\n * @desc The factory we'll use to register with Angular\n * @returns the Account constructor\n */\n Account.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'Resource', 'Preferences', 'Mailbox', 'Message', function($q, $timeout, $log, Settings, Resource, Preferences, Mailbox, Message) {\n angular.extend(Account, {\n $q: $q,\n $timeout: $timeout,\n $log: $log,\n $$resource: new Resource(Settings.activeUser('folderURL') + 'Mail', Settings.activeUser()),\n $Preferences: Preferences,\n $Mailbox: Mailbox,\n $Message: Message\n });\n\n return Account; // return constructor\n }];\n\n /**\n * @module SOGo.MailerUI\n * @desc Factory registration of Account in Angular module.\n */\n try {\n angular.module('SOGo.MailerUI');\n }\n catch(e) {\n angular.module('SOGo.MailerUI', ['SOGo.Common']);\n }\n angular.module('SOGo.MailerUI')\n .factory('Account', Account.$factory);\n\n /**\n * @memberof Account\n * @desc Set the list of accounts and instanciate a new Account object for each item.\n * @param {array} [data] - the metadata of the accounts\n * @returns the list of accounts\n */\n Account.$findAll = function(data) {\n if (!data) {\n return Account.$$resource.fetch('', 'mailAccounts').then(function(o) {\n return Account.$unwrapCollection(o);\n });\n }\n return Account.$unwrapCollection(data);\n };\n\n /**\n * @memberof Account\n * @desc Unwrap to a collection of Account instances.\n * @param {object} data - the accounts information\n * @returns a collection of Account objects\n */\n Account.$unwrapCollection = function(data) {\n var collection = [];\n\n angular.forEach(data, function(o, i) {\n o.id = i;\n collection[i] = new Account(o);\n });\n return collection;\n };\n\n /**\n * @function $getMailboxes\n * @memberof Account.prototype\n * @desc Fetch the list of mailboxes for the current account.\n * @param {object} [options] - force a reload by setting 'reload' to true\n * @returns a promise of the HTTP operation\n */\n Account.prototype.$getMailboxes = function(options) {\n var _this = this;\n\n if (this.$mailboxes && !(options && options.reload)) {\n return Account.$q.when(this.$mailboxes);\n }\n else {\n return Account.$Mailbox.$find(this).then(function(data) {\n _this.$mailboxes = data;\n\n // Set expanded folders from user's settings\n Account.$Preferences.ready().then(function() {\n var expandedFolders,\n _visit = function(mailboxes) {\n _.forEach(mailboxes, function(o) {\n o.$expanded = (expandedFolders.indexOf('/' + o.id) >= 0);\n if (o.children && o.children.length > 0) {\n _visit(o.children);\n }\n });\n };\n if (Account.$Preferences.settings.Mail.ExpandedFolders) {\n if (angular.isString(Account.$Preferences.settings.Mail.ExpandedFolders))\n // Backward compatibility support\n expandedFolders = angular.fromJson(Account.$Preferences.settings.Mail.ExpandedFolders);\n else\n expandedFolders = Account.$Preferences.settings.Mail.ExpandedFolders;\n if (expandedFolders.length > 0) {\n _visit(_this.$mailboxes);\n }\n }\n _this.$flattenMailboxes({reload: true});\n });\n\n return _this.$mailboxes;\n });\n }\n };\n\n /**\n * @function $flattenMailboxes\n * @memberof Account.prototype\n * @desc Get a flatten array of the mailboxes.\n * @param {object} [options] - force a reload\n * @returns an array of Mailbox instances\n */\n Account.prototype.$flattenMailboxes = function(options) {\n var _this = this,\n allMailboxes = [],\n expandedMailboxes = [],\n _visit = function(mailboxes) {\n _.each(mailboxes, function(o) {\n allMailboxes.push(o);\n if ((options && options.all || o.$expanded) && o.children && o.children.length > 0) {\n _visit(o.children);\n }\n });\n };\n\n if (this.$$flattenMailboxes && !(options && (options.reload || options.all))) {\n allMailboxes = this.$$flattenMailboxes;\n }\n else {\n _visit(this.$mailboxes);\n _this.$$flattenMailboxes = allMailboxes;\n if (options && options.saveState) {\n _.reduce(allMailboxes, function(expandedFolders, mailbox) {\n if (mailbox.$expanded) {\n expandedFolders.push('/' + mailbox.id);\n }\n return expandedFolders;\n }, expandedMailboxes);\n Account.$$resource.post(null, 'saveFoldersState', expandedMailboxes);\n }\n }\n\n return allMailboxes;\n };\n\n Account.prototype.$getMailboxByType = function(type) {\n var mailbox,\n // Recursive find function\n _find = function(mailboxes) {\n var mailbox = _.find(mailboxes, function(o) {\n return o.type == type;\n });\n if (!mailbox) {\n angular.forEach(mailboxes, function(o) {\n if (!mailbox && o.children && o.children.length > 0) {\n mailbox = _find(o.children);\n }\n });\n }\n return mailbox;\n };\n mailbox = _find(this.$mailboxes);\n\n console.debug(mailbox);\n console.debug(this.specialMailboxes);\n };\n\n /**\n * @function $getMailboxByPath\n * @memberof Account.prototype\n * @desc Recursively find a mailbox using its path\n * @returns a promise of the HTTP operation\n */\n Account.prototype.$getMailboxByPath = function(path) {\n var mailbox = null,\n // Recursive find function\n _find = function(mailboxes) {\n var mailbox = _.find(mailboxes, function(o) {\n return o.path == path;\n });\n if (!mailbox) {\n angular.forEach(mailboxes, function(o) {\n if (!mailbox && o.children && o.children.length > 0) {\n mailbox = _find(o.children);\n }\n });\n }\n return mailbox;\n };\n mailbox = _find(this.$mailboxes);\n\n return mailbox;\n };\n\n /**\n * @function $newMailbox\n * @memberof Account.prototype\n * @desc Create a new mailbox on the server and refresh the list of mailboxes.\n * @returns a promise of the HTTP operations\n */\n Account.prototype.$newMailbox = function(path, name) {\n var _this = this;\n\n return Account.$$resource.post(path.toString(), 'createFolder', {name: name}).then(function() {\n _this.$getMailboxes({reload: true});\n });\n };\n\n /**\n * @function $newMessage\n * @memberof Account.prototype\n * @desc Prepare a new Message object associated to the appropriate mailbox.\n * @returns a promise of the HTTP operations\n */\n Account.prototype.$newMessage = function() {\n var _this = this;\n\n // Query account for draft folder and draft UID\n return Account.$$resource.fetch(this.id.toString(), 'compose').then(function(data) {\n Account.$log.debug('New message (compose): ' + JSON.stringify(data, undefined, 2));\n var message = new Account.$Message(data.accountId, _this.$getMailboxByPath(data.mailboxPath), data);\n return message;\n }).then(function(message) {\n // Fetch draft initial data\n return Account.$$resource.fetch(message.$absolutePath({asDraft: true}), 'edit').then(function(data) {\n Account.$log.debug('New message (edit): ' + JSON.stringify(data, undefined, 2));\n angular.extend(message.editable, data);\n return message;\n });\n });\n };\n\n /**\n * @function $addDelegate\n * @memberof Account.prototype\n * @param {Object} user - a User object with minimal set of attributes (uid, isGroup, cn, c_email)\n * @desc Remove a user from the account's delegates\n * @see {@link User.$filter}\n */\n Account.prototype.$addDelegate = function(user) {\n var _this = this,\n deferred = Account.$q.defer(),\n param = {uid: user.uid};\n if (!user.uid || _.indexOf(_.pluck(this.delegates, 'uid'), user.uid) > -1) {\n // No UID specified or user already in delegates\n deferred.resolve();\n }\n else {\n Account.$$resource.fetch(this.id.toString(), 'addDelegate', param).then(function() {\n _this.delegates.push(user);\n deferred.resolve(_this.users);\n }, function(data, status) {\n deferred.reject(l('An error occured please try again.'));\n });\n }\n return deferred.promise;\n };\n\n /**\n * @function $removeDelegate\n * @memberof Account.prototype\n * @param {Object} user - a User object with minimal set of attributes (uid, isGroup, cn, c_email)\n * @desc Remove a user from the account's delegates\n * @return a promise of the server call to remove the user from the account's delegates\n */\n Account.prototype.$removeDelegate = function(uid) {\n var _this = this,\n param = {uid: uid};\n return Account.$$resource.fetch(this.id.toString(), 'removeDelegate', param).then(function() {\n var i = _.indexOf(_.pluck(_this.delegates, 'uid'), uid);\n if (i >= 0) {\n _this.delegates.splice(i, 1);\n }\n });\n };\n \n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @name Mailbox\n * @constructor\n * @param {object} futureMailboxData - either an object literal or a promise\n */\n function Mailbox(account, futureMailboxData) {\n this.$account = account;\n // Data is immediately available\n if (typeof futureMailboxData.then !== 'function') {\n this.init(futureMailboxData);\n if (this.name && !this.path) {\n // Create a new mailbox on the server\n var newMailboxData = Mailbox.$$resource.create('createFolder', this.name);\n this.$unwrap(newMailboxData);\n }\n }\n else {\n // The promise will be unwrapped first\n // NOTE: this condition never happen for the moment\n this.$unwrap(futureMailboxData);\n }\n }\n\n /**\n * @memberof Mailbox\n * @desc The factory we'll use to register with Angular\n * @returns the Mailbox constructor\n */\n Mailbox.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'Resource', 'Message', 'Acl', 'Preferences', 'sgMailbox_PRELOAD', function($q, $timeout, $log, Settings, Resource, Message, Acl, Preferences, PRELOAD) {\n angular.extend(Mailbox, {\n $q: $q,\n $timeout: $timeout,\n $log: $log,\n $$resource: new Resource(Settings.activeUser('folderURL') + 'Mail', Settings.activeUser()),\n $Message: Message,\n $$Acl: Acl,\n $Preferences: Preferences,\n $query: { sort: 'date', asc: 0 },\n selectedFolder: null,\n $refreshTimeout: null,\n $virtualMode: false,\n PRELOAD: PRELOAD\n });\n // Initialize sort parameters from user's settings\n Preferences.ready().then(function() {\n if (Preferences.settings.Mail.SortingState) {\n Mailbox.$query.sort = Preferences.settings.Mail.SortingState[0];\n Mailbox.$query.asc = parseInt(Preferences.settings.Mail.SortingState[1]);\n }\n });\n\n return Mailbox; // return constructor\n }];\n\n /**\n * @module SOGo.MailerUI\n * @desc Factory registration of Mailbox in Angular module.\n */\n try {\n angular.module('SOGo.MailerUI');\n }\n catch(e) {\n angular.module('SOGo.MailerUI', ['SOGo.Common']);\n }\n angular.module('SOGo.MailerUI')\n .constant('sgMailbox_PRELOAD', {\n LOOKAHEAD: 50,\n SIZE: 100\n })\n .factory('Mailbox', Mailbox.$factory);\n\n /**\n * @memberof Mailbox\n * @desc Fetch list of mailboxes of a specific account\n * @param {string} accountId - the account\n * @return a promise of the HTTP operation\n * @see {@link Account.$getMailboxes}\n */\n Mailbox.$find = function(account) {\n var path, futureMailboxData;\n\n futureMailboxData = this.$$resource.fetch(account.id.toString(), 'view');\n\n return Mailbox.$unwrapCollection(account, futureMailboxData); // a collection of mailboxes\n };\n\n /**\n * @memberof Mailbox\n * @desc Unwrap to a collection of Mailbox instances.\n * @param {string} account - the account\n * @param {promise} futureMailboxData - a promise of the mailboxes metadata\n * @returns a promise of a collection of Mailbox objects\n */\n Mailbox.$unwrapCollection = function(account, futureMailboxData) {\n var collection = [],\n // Local recursive function\n createMailboxes = function(level, mailbox) {\n for (var i = 0; i < mailbox.children.length; i++) {\n mailbox.children[i].level = level;\n mailbox.children[i] = new Mailbox(account, mailbox.children[i]);\n createMailboxes(level+1, mailbox.children[i]);\n }\n };\n //collection.$futureMailboxData = futureMailboxData;\n\n return futureMailboxData.then(function(data) {\n return Mailbox.$timeout(function() {\n // Each entry is spun up as a Mailbox instance\n angular.forEach(data.mailboxes, function(data, index) {\n data.level = 0;\n var mailbox = new Mailbox(account, data);\n createMailboxes(1, mailbox); // recursively create all sub-mailboxes\n collection.push(mailbox);\n });\n return collection;\n });\n });\n };\n\n /**\n * @memberof Mailbox\n * @desc Build the path of the mailbox (or account only).\n * @param {string} accountId - the account ID\n * @param {string} [mailboxPath] - the mailbox path\n * @returns a string representing the path relative to the mail module\n */\n Mailbox.$absolutePath = function(accountId, mailboxPath) {\n var path = [];\n\n if (mailboxPath) {\n path = _.map(mailboxPath.split('/'), function(component) {\n return 'folder' + component.asCSSIdentifier();\n });\n }\n\n path.splice(0, 0, accountId); // insert account ID\n\n return path.join('/');\n };\n\n /**\n * @function init\n * @memberof Mailbox.prototype\n * @desc Extend instance with new data and compute additional attributes.\n * @param {object} data - attributes of mailbox\n */\n Mailbox.prototype.init = function(data) {\n var _this = this;\n this.$isLoading = true;\n this.$messages = [];\n this.uidsMap = {};\n angular.extend(this, data);\n if (this.path) {\n this.id = this.$id();\n this.$acl = new Mailbox.$$Acl('Mail/' + this.id);\n }\n if (this.type) {\n this.$isEditable = this.isEditable();\n }\n if (angular.isUndefined(this.$shadowData)) {\n // Make a copy of the data for an eventual reset\n this.$shadowData = this.$omit();\n }\n };\n\n /**\n * @function getLength\n * @memberof Mailbox.prototype\n * @desc Used by md-virtual-repeat / md-on-demand\n * @returns the number of items in the mailbox\n */\n Mailbox.prototype.getLength = function() {\n return this.$messages.length;\n };\n\n /**\n * @function getItemAtIndex\n * @memberof Mailbox.prototype\n * @desc Used by md-virtual-repeat / md-on-demand\n * @returns the message as the specified index\n */\n Mailbox.prototype.getItemAtIndex = function(index) {\n var message;\n\n if (index >= 0 && index < this.$messages.length) {\n message = this.$messages[index];\n\n if (this.$loadMessage(message.uid))\n return message;\n }\n\n return null;\n };\n\n /**\n * @function $id\n * @memberof Mailbox.prototype\n * @desc Build the unique ID to identified the mailbox.\n * @returns a string representing the path relative to the mail module\n */\n Mailbox.prototype.$id = function() {\n return Mailbox.$absolutePath(this.$account.id, this.path);\n };\n\n /**\n * @function $selectedCount\n * @memberof Mailbox.prototype\n * @desc Return the number of messages selected by the user.\n * @returns the number of selected messages\n */\n Mailbox.prototype.$selectedCount = function() {\n var count;\n\n count = 0;\n if (this.$messages) {\n count = (_.filter(this.$messages, function(message) { return message.selected; })).length;\n }\n return count;\n };\n\n /**\n * @function isSelectedMessage\n * @memberof Mailbox.prototype\n * @desc Check if the specified message is selected.\n * @param {string} messageId\n * @returns true if the specified message is selected\n */\n Mailbox.prototype.isSelectedMessage = function(messageId) {\n return this.selectedMessage == messageId;\n };\n\n /**\n * @function $filter\n * @memberof Mailbox.prototype\n * @desc Fetch the messages metadata of the mailbox\n * @param {object} [sort] - sort preferences. Defaults to descendent by date.\n * @param {string} sort.match - either AND or OR\n * @param {string} sort.sort - either arrival, subject, from, to, date, or size\n * @param {boolean} sort.asc - sort is ascendant if true\n * @param {object[]} [filters] - list of filters for the query\n * @param {string} filters.searchBy - either subject, from, to, cc, or body\n * @param {string} filters.searchInput - the search string to match\n * @param {boolean} filters.negative - negate the condition\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$filter = function(sortingAttributes, filters) {\n var _this = this, options = {};\n\n if (!angular.isDefined(this.unseenCount))\n this.unseenCount = 0;\n\n this.$isLoading = true;\n\n return Mailbox.$Preferences.ready().then(function() {\n\n if (Mailbox.$refreshTimeout)\n Mailbox.$timeout.cancel(Mailbox.$refreshTimeout);\n\n if (sortingAttributes)\n // Sorting preferences are common to all mailboxes\n angular.extend(Mailbox.$query, sortingAttributes);\n\n angular.extend(options, { sortingAttributes: Mailbox.$query });\n if (angular.isDefined(filters)) {\n options.filters = _.reject(filters, function(filter) {\n return angular.isUndefined(filter.searchInput) || filter.searchInput.length === 0;\n });\n _.each(options.filters, function(filter) {\n var secondFilter,\n match = filter.searchBy.match(/(\\w+)_or_(\\w+)/);\n if (match) {\n options.sortingAttributes.match = 'OR';\n filter.searchBy = match[1];\n secondFilter = angular.copy(filter);\n secondFilter.searchBy = match[2];\n options.filters.push(secondFilter);\n }\n });\n }\n\n // Restart the refresh timer, if needed\n if (!Mailbox.$virtualMode) {\n var refreshViewCheck = Mailbox.$Preferences.defaults.SOGoRefreshViewCheck;\n if (refreshViewCheck && refreshViewCheck != 'manually') {\n var f = angular.bind(_this, Mailbox.prototype.$filter);\n Mailbox.$refreshTimeout = Mailbox.$timeout(f, refreshViewCheck.timeInterval()*1000);\n }\n }\n\n var futureMailboxData = Mailbox.$$resource.post(_this.id, 'view', options);\n return _this.$unwrap(futureMailboxData);\n });\n };\n\n /**\n * @function $loadMessage\n * @memberof Mailbox.prototype\n * @desc Check if the message is loaded and in any case, fetch more messages headers from the server.\n * @returns true if the message metadata are already fetched\n */\n Mailbox.prototype.$loadMessage = function(messageId) {\n var startIndex = this.uidsMap[messageId],\n endIndex,\n max = this.$messages.length,\n loaded = false,\n uids,\n futureHeadersData;\n if (angular.isDefined(this.uidsMap[messageId]) && startIndex < this.$messages.length) {\n // Index is valid\n if (angular.isDefined(this.$messages[startIndex].subject)) {// || this.$messages[startIndex].loading) {\n // Message headers are loaded or data is coming\n loaded = true;\n }\n\n // Preload more headers if possible\n endIndex = Math.min(startIndex + Mailbox.PRELOAD.LOOKAHEAD, max - 1);\n if (!angular.isDefined(this.$messages[endIndex].subject) &&\n !angular.isDefined(this.$messages[endIndex].loading)) {\n endIndex = Math.min(startIndex + Mailbox.PRELOAD.SIZE, max);\n for (uids = []; startIndex < endIndex && startIndex < max; startIndex++) {\n if (angular.isDefined(this.$messages[startIndex].subject) || this.$messages[startIndex].loading) {\n // Message at this index is already loaded; increase the end index\n endIndex++;\n }\n else {\n // Message at this index will be loaded\n uids.push(this.$messages[startIndex].uid);\n this.$messages[startIndex].loading = true;\n }\n }\n\n Mailbox.$log.debug('Loading UIDs ' + uids.join(' '));\n futureHeadersData = Mailbox.$$resource.post(this.id, 'headers', {uids: uids});\n this.$unwrapHeaders(futureHeadersData);\n }\n }\n return loaded;\n };\n\n /**\n * @function isEditable\n * @memberof Mailbox.prototype\n * @desc Checks if the mailbox is editable based on its type.\n * @returns true if the mailbox is not a special folder.\n */\n Mailbox.prototype.isEditable = function() {\n return this.type == 'folder';\n };\n\n /**\n * @function $rename\n * @memberof AddressBook.prototype\n * @desc Rename the addressbook and keep the list sorted\n * @param {string} name - the new name\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$rename = function() {\n var _this = this,\n findParent,\n parent,\n children,\n i;\n\n if (this.name == this.$shadowData.name) {\n // Name hasn't changed\n return Mailbox.$q.when();\n }\n\n // Local recursive function\n findParent = function(parent, children) {\n var parentMailbox = null,\n mailbox = _.find(children, function(o) {\n return o.path == _this.path;\n });\n if (mailbox) {\n parentMailbox = parent;\n }\n else {\n angular.forEach(children, function(o) {\n if (!parentMailbox && o.children && o.children.length > 0) {\n parentMailbox = findParent(o, o.children);\n }\n });\n }\n return parentMailbox;\n };\n\n // Find mailbox parent\n parent = findParent(null, this.$account.$mailboxes);\n if (parent === null)\n children = this.$account.$mailboxes;\n else\n children = parent.children;\n\n // Find index of mailbox among siblings\n i = _.indexOf(_.pluck(children, 'id'), this.id);\n\n return this.$save().then(function(data) {\n var sibling;\n angular.extend(_this, data); // update the path attribute\n _this.id = _this.$id();\n\n // Move mailbox among its siblings according to its new name\n children.splice(i, 1);\n sibling = _.find(children, function(o) {\n Mailbox.$log.debug(o.name + ' ? ' + _this.name);\n return (o.type == 'folder' && o.name.localeCompare(_this.name) > 0);\n });\n if (sibling) {\n i = _.indexOf(_.pluck(children, 'id'), sibling.id);\n }\n else {\n i = children.length;\n }\n children.splice(i, 0, _this);\n });\n };\n\n /**\n * @function $compact\n * @memberof Mailbox.prototype\n * @desc Compact the mailbox\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$compact = function() {\n return Mailbox.$$resource.post(this.id, 'expunge');\n };\n\n /**\n * @function $setFolderAs\n * @memberof Mailbox.prototype\n * @desc Set a folder as Drafts/Sent/Trash\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$setFolderAs = function(type) {\n return Mailbox.$$resource.post(this.id, 'setAs' + type + 'Folder');\n };\n\n /**\n * @function $emptyTrash\n * @memberof Mailbox.prototype\n * @desc Empty the Trash folder.\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$emptyTrash = function() {\n var _this = this;\n\n return Mailbox.$$resource.post(this.id, 'emptyTrash').then(function() {\n // Remove all messages from the mailbox\n _this.$messages = [];\n _this.uidsMap = {};\n _this.unseenCount = 0;\n\n // If we had any submailboxes, lets do a refresh of the mailboxes list\n if (angular.isDefined(_this.children) && _this.children.length)\n _this.$account.$getMailboxes({reload: true});\n });\n };\n\n /**\n * @function $markAsRead\n * @memberof Mailbox.prototype\n * @desc Mark all messages from folder as read\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$markAsRead = function() {\n return Mailbox.$$resource.post(this.id, 'markRead');\n };\n\n /**\n * @function $flagMessages\n * @memberof Mailbox.prototype\n * @desc Add or remove a flag on a message set\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$flagMessages = function(uids, flags, operation) {\n var data = {msgUIDs: uids,\n flags: flags,\n operation: operation};\n\n return Mailbox.$$resource.post(this.id, 'addOrRemoveLabel', data);\n };\n\n /**\n * @function $delete\n * @memberof Mailbox.prototype\n * @desc Delete the mailbox from the server\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$delete = function() {\n var _this = this;\n\n return Mailbox.$$resource.remove(this.id)\n .then(function() {\n _this.$account.$getMailboxes({reload: true});\n return true;\n });\n };\n\n /**\n * @function $deleteMessages\n * @memberof Mailbox.prototype\n * @desc Delete multiple messages from mailbox.\n * @return a promise of the HTTP operation\n */\n Mailbox.prototype.$deleteMessages = function(uids) {\n return Mailbox.$$resource.post(this.id, 'batchDelete', {uids: uids});\n };\n\n /**\n * @function $copyMessages\n * @memberof Mailbox.prototype\n * @desc Copy multiple messages from the current mailbox to a target one\n * @return a promise of the HTTP operation\n */\n Mailbox.prototype.$copyMessages = function(uids, folder) {\n return Mailbox.$$resource.post(this.id, 'copyMessages', {uids: uids, folder: folder});\n };\n\n /**\n * @function $moveMessages\n * @memberof Mailbox.prototype\n * @desc Move multiple messages from the current mailbox to a target one\n * @return a promise of the HTTP operation\n */\n Mailbox.prototype.$moveMessages = function(uids, folder) {\n return Mailbox.$$resource.post(this.id, 'moveMessages', {uids: uids, folder: folder});\n };\n \n /**\n * @function $reset\n * @memberof Mailbox.prototype\n * @desc Reset the original state the mailbox's data.\n */\n Mailbox.prototype.$reset = function() {\n var _this = this;\n angular.forEach(this, function(value, key) {\n if (key != 'constructor' && key != 'children' && key[0] != '$') {\n delete _this[key];\n }\n });\n angular.extend(this, this.$shadowData);\n this.$shadowData = this.$omit();\n };\n\n /**\n * @function $save\n * @memberof Mailbox.prototype\n * @desc Save the mailbox to the server. This currently can only affect the name of the mailbox.\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$save = function() {\n var _this = this;\n\n return Mailbox.$$resource.save(this.id, this.$omit()).then(function(data) {\n // Make a copy of the data for an eventual reset\n _this.$shadowData = _this.$omit();\n Mailbox.$log.debug(JSON.stringify(data, undefined, 2));\n return data;\n }, function(data) {\n Mailbox.$log.error(JSON.stringify(data, undefined, 2));\n // Restore previous version\n _this.$reset();\n });\n };\n\n /**\n * @function $newMailbox\n * @memberof Mailbox.prototype\n * @desc Create a new mailbox on the server and refresh the list of mailboxes.\n * @returns a promise of the HTTP operations\n */\n Mailbox.prototype.$newMailbox = function(path, name) {\n return this.$account.$newMailbox(path, name);\n };\n\n /**\n * @function $omit\n * @memberof Mailbox.prototype\n * @desc Return a sanitized object used to send to the server.\n * @return an object literal copy of the Mailbox instance\n */\n Mailbox.prototype.$omit = function() {\n var mailbox = {};\n angular.forEach(this, function(value, key) {\n if (key != 'constructor' &&\n key != 'children' &&\n key[0] != '$') {\n mailbox[key] = value;\n }\n });\n return mailbox;\n };\n\n /**\n * @function $unwrap\n * @memberof Mailbox.prototype\n * @desc Unwrap a promise and instanciate new Message objects using received data.\n * @param {promise} futureMailboxData - a promise of the Mailbox's metadata\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$unwrap = function(futureMailboxData) {\n var _this = this,\n deferred = Mailbox.$q.defer();\n\n this.$futureMailboxData = futureMailboxData;\n this.$futureMailboxData.then(function(data) {\n Mailbox.$timeout(function() {\n var uids, headers;\n\n _this.init(data);\n\n if (_this.uids) {\n Mailbox.$log.debug('unwrapping ' + data.uids.length + ' messages');\n\n // First entry of 'headers' are keys\n headers = _.invoke(_this.headers[0], 'toLowerCase');\n _this.headers.splice(0, 1);\n\n // First entry of 'uids' are keys when threaded view is enabled\n if (_this.threaded) {\n uids = _this.uids[0];\n _this.uids.splice(0, 1);\n }\n\n // Instanciate Message objects\n _.reduce(_this.uids, function(msgs, msg, i) {\n var data;\n if (_this.threaded)\n data = _.object(uids, msg);\n else\n data = {uid: msg.toString()};\n\n // Build map of UID <=> index\n _this.uidsMap[data.uid] = i;\n\n msgs.push(new Mailbox.$Message(_this.$account.id, _this, data, true));\n\n return msgs;\n }, _this.$messages);\n\n // Extend Message objects with received headers\n _.each(_this.headers, function(data) {\n var msg = _.object(headers, data),\n i = _this.uidsMap[msg.uid.toString()];\n _.extend(_this.$messages[i], msg);\n });\n }\n Mailbox.$log.debug('mailbox ' + _this.id + ' ready');\n _this.$isLoading = false;\n deferred.resolve(_this.$messages);\n });\n }, function(data) {\n angular.extend(_this, data);\n _this.isError = true;\n deferred.reject();\n });\n\n return deferred.promise;\n };\n\n /**\n * @function $unwrapHeaders\n * @memberof Mailbox.prototype\n * @desc Unwrap a promise and extend matching Message objects using received data.\n * @param {promise} futureHeadersData - a promise of some messages metadata\n */\n Mailbox.prototype.$unwrapHeaders = function(futureHeadersData) {\n var _this = this;\n\n futureHeadersData.then(function(data) {\n Mailbox.$timeout(function() {\n var headers, j;\n if (data.length > 0) {\n // First entry of 'headers' are keys\n headers = _.invoke(data[0], 'toLowerCase');\n data.splice(0, 1);\n _.each(data, function(messageHeaders) {\n messageHeaders = _.object(headers, messageHeaders);\n j = _this.uidsMap[messageHeaders.uid.toString()];\n if (angular.isDefined(j)) {\n _.extend(_this.$messages[j], messageHeaders);\n }\n });\n }\n });\n });\n };\n\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @name Message\n * @constructor\n * @param {string} accountId - the account ID\n * @param {string} mailboxPath - an array of the mailbox path components\n * @param {object} futureAddressBookData - either an object literal or a promise\n * @param {bool} lazy - do \"lazy loading\" so we are very quick at initializing message instances\n */\n function Message(accountId, mailbox, futureMessageData, lazy) {\n this.accountId = accountId;\n this.$mailbox = mailbox;\n this.$hasUnsafeContent = false;\n this.$loadUnsafeContent = false;\n this.$showDetailedRecipients = false;\n this.editable = {to: [], cc: [], bcc: []};\n this.selected = false;\n\n // Data is immediately available\n if (typeof futureMessageData.then !== 'function') {\n //console.debug(JSON.stringify(futureMessageData, undefined, 2));\n if (angular.isDefined(lazy) && lazy) {\n this.uid = futureMessageData.uid;\n }\n else {\n angular.extend(this, futureMessageData);\n this.$formatFullAddresses();\n }\n }\n else {\n // The promise will be unwrapped first\n this.$unwrap(futureMessageData);\n }\n }\n\n /**\n * @memberof Message\n * @desc The factory we'll use to register with Angular\n * @returns the Message constructor\n */\n Message.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'Gravatar', 'Resource', 'Preferences', function($q, $timeout, $log, Settings, Gravatar, Resource, Preferences) {\n angular.extend(Message, {\n $q: $q,\n $timeout: $timeout,\n $log: $log,\n $gravatar: Gravatar,\n $$resource: new Resource(Settings.activeUser('folderURL') + 'Mail', Settings.activeUser())\n });\n // Initialize tags form user's defaults\n Preferences.ready().then(function() {\n if (Preferences.defaults.SOGoMailLabelsColors) {\n Message.$tags = Preferences.defaults.SOGoMailLabelsColors;\n }\n if (Preferences.defaults.SOGoMailDisplayRemoteInlineImages &&\n Preferences.defaults.SOGoMailDisplayRemoteInlineImages == 'always') {\n Message.$displayRemoteInlineImages = true;\n }\n });\n\n return Message; // return constructor\n }];\n\n /**\n * @module SOGo.MailerUI\n * @desc Factory registration of Message in Angular module.\n */\n try {\n angular.module('SOGo.MailerUI');\n }\n catch(e) {\n angular.module('SOGo.MailerUI', ['SOGo.Common']);\n }\n angular.module('SOGo.MailerUI')\n .factory('Message', Message.$factory);\n\n /**\n * @function filterTags\n * @memberof Message.prototype\n * @desc Search for tags (ie., mail labels) matching some criterias\n * @param {string} search - the search string to match\n * @returns a collection of strings\n */\n Message.filterTags = function(query) {\n var re = new RegExp(query, 'i'),\n results = [];\n\n _.forEach(_.keys(Message.$tags), function(tag) {\n var pair = Message.$tags[tag];\n if (pair[0].search(re) != -1) {\n results.push({ name: tag, description: pair[0], color: pair[1] });\n }\n });\n return results;\n };\n\n /**\n * @function $absolutePath\n * @memberof Message.prototype\n * @desc Build the path of the message\n * @returns a string representing the path relative to the mail module\n */\n Message.prototype.$absolutePath = function(options) {\n if (angular.isUndefined(this.id) || options) {\n var path;\n path = _.map(this.$mailbox.path.split('/'), function(component) {\n return 'folder' + component.asCSSIdentifier();\n });\n path.splice(0, 0, this.accountId); // insert account ID\n if (options && options.asDraft && this.draftId) {\n path.push(this.draftId); // add draft ID\n }\n else {\n path.push(this.uid); // add message UID\n }\n\n this.id = path.join('/');\n }\n\n return this.id;\n };\n\n /**\n * @function $setUID\n * @memberof Message.prototype\n * @desc Change the UID of the message. This happens when saving a draft.\n * @param {number} uid - the new message UID\n */\n Message.prototype.$setUID = function(uid) {\n var oldUID = this.uid || -1;\n\n if (oldUID != uid) {\n this.uid = uid;\n if (oldUID > -1 && this.$mailbox.uidsMap[oldUID]) {\n this.$mailbox.uidsMap[uid] = this.$mailbox.uidsMap[oldUID];\n this.$mailbox.uidsMap[oldUID] = null;\n }\n }\n };\n\n /**\n * @function $formatFullAddresses\n * @memberof Message.prototype\n * @desc Format all sender and recipients addresses with a complete description (name <email>).\n * This function also generates a gravatar for each email address, and a short name\n */\n Message.prototype.$formatFullAddresses = function() {\n var _this = this;\n var identities = _.pluck(_this.$mailbox.$account.identities, 'email');\n\n // Build long representation of email addresses\n _.each(['from', 'to', 'cc', 'bcc', 'reply-to'], function(type) {\n _.each(_this[type], function(data, i) {\n if (data.name && data.name != data.email) {\n data.full = data.name + ' <' + data.email + '>';\n\n // If we have \"Alice Foo\" as name, we grab \"Alice\"\n if (data.name.split(' ').length)\n data.shortname = data.name.split(' ')[0].replace('\\'','');\n }\n else {\n data.full = '<' + data.email + '>';\n data.shortname = data.email.split('@')[0];\n }\n\n // Generate the gravatar\n data.image = Message.$gravatar(data.email, 32);\n\n // If the current user is the recepient, overwrite\n // the short name with 'me'\n if (_.indexOf(identities, data.email) >= 0)\n data.shortname = l('me');\n });\n });\n };\n\n /**\n * @function $shortRecipients\n * @memberof Message.prototype\n * @desc Format all recipients into a very compact string\n * @returns a compacted string of all recipients\n */\n Message.prototype.$shortRecipients = function() {\n var _this = this;\n var result = [];\n\n // Build long representation of email addresses\n _.each(['to', 'cc', 'bcc'], function(type) {\n _.each(_this[type], function(data, i) {\n result.push(data.shortname);\n });\n });\n\n return result.join(', ');\n };\n\n /**\n * @function $shortAddress\n * @memberof Message.prototype\n * @desc Format the first address of a specific type with a short description.\n * @returns a string of the name or the email of the envelope address type\n */\n Message.prototype.$shortAddress = function(type) {\n var address = '';\n if (this[type] && this[type].length > 0) {\n address = this[type][0].name || this[type][0].email || '';\n }\n\n return address;\n };\n\n /**\n * @function loadUnsafeContent\n * @memberof Message.prototype\n * @desc Mark the message to load unsafe resources when calling $content().\n */\n Message.prototype.loadUnsafeContent = function() {\n this.$loadUnsafeContent = true;\n };\n\n /**\n * @function showDetailedRecipients\n * @memberof Message.prototype\n * @desc Mark the message to show all to/cc recipients.\n */\n Message.prototype.showDetailedRecipients = function() {\n this.$showDetailedRecipients = true;\n };\n\n /**\n * @function $content\n * @memberof Message.prototype\n * @desc Get the message body as accepted by SCE (Angular Strict Contextual Escaping).\n * @returns the HTML representation of the body\n */\n Message.prototype.$content = function() {\n var _this = this,\n parts = [],\n _visit = function(part) {\n part.msgclass = 'msg-attachment-other';\n if (part.type == 'UIxMailPartAlternativeViewer') {\n _visit(_.find(part.content, function(alternatePart) {\n return part.preferredPart == alternatePart.contentType;\n }));\n }\n // Can be used for UIxMailPartMixedViewer and UIxMailPartMessageViewer\n else if (angular.isArray(part.content)) {\n _.each(part.content, function(mixedPart) {\n _visit(mixedPart);\n });\n }\n else {\n if (angular.isUndefined(part.safeContent)) {\n // Keep a copy of the original content\n part.safeContent = part.content;\n _this.$hasUnsafeContent |= (part.safeContent.indexOf(' unsafe-') > -1);\n }\n if (part.type == 'UIxMailPartHTMLViewer') {\n part.html = true;\n if (_this.$loadUnsafeContent || Message.$displayRemoteInlineImages) {\n if (angular.isUndefined(part.unsafeContent)) {\n part.unsafeContent = document.createElement('div');\n part.unsafeContent.innerHTML = part.safeContent;\n angular.forEach(['src', 'data', 'classid', 'background', 'style'], function(suffix) {\n var elements = part.unsafeContent.querySelectorAll('[unsafe-' + suffix + ']'),\n element,\n value,\n i;\n for (i = 0; i < elements.length; i++) {\n element = angular.element(elements[i]);\n value = element.attr('unsafe-' + suffix);\n element.attr(suffix, value);\n element.removeAttr('unsafe-' + suffix);\n }\n });\n _this.$hasUnsafeContent = false;\n }\n part.content = part.unsafeContent.innerHTML;\n }\n else {\n part.content = part.safeContent;\n }\n parts.push(part);\n }\n else if (part.type == 'UIxMailPartICalViewer' ||\n part.type == 'UIxMailPartImageViewer' ||\n part.type == 'UIxMailPartLinkViewer') {\n\n // UIxMailPartICalViewer injects 'participants'\n if (part.participants) {\n _.each(part.participants, function(participant) {\n participant.image = Message.$gravatar(participant.email, 32);\n });\n }\n\n if (part.type == 'UIxMailPartImageViewer')\n part.msgclass = 'msg-attachment-image';\n\n // Trusted content that can be compiled (Angularly-speaking)\n part.compile = true;\n parts.push(part);\n }\n else {\n part.html = true;\n part.content = part.safeContent;\n parts.push(part);\n }\n }\n };\n _visit(this.parts);\n\n return parts;\n };\n\n /**\n * @function $editableContent\n * @memberof Message.prototype\n * @desc First, fetch the draft ID that corresponds to the temporary draft object on the SOGo server.\n * Secondly, fetch the editable message body along with other metadata such as the recipients.\n * @returns the HTML representation of the body\n */\n Message.prototype.$editableContent = function() {\n var _this = this;\n\n return Message.$$resource.fetch(this.$absolutePath(), 'edit').then(function(data) {\n angular.extend(_this, data);\n return Message.$$resource.fetch(_this.$absolutePath({asDraft: true}), 'edit').then(function(data) {\n Message.$log.debug('editable = ' + JSON.stringify(data, undefined, 2));\n angular.extend(_this.editable, data);\n return data.text;\n });\n });\n };\n\n /**\n * @function addTag\n * @memberof Message.prototype\n * @desc Add a mail tag on the current message.\n * @param {string} tag - the tag name\n * @returns a promise of the HTTP operation\n */\n Message.prototype.addTag = function(tag) {\n return this.$addOrRemoveTag('add', tag);\n };\n\n /**\n * @function removeTag\n * @memberof Message.prototype\n * @desc Remove a mail tag from the current message.\n * @param {string} tag - the tag name\n * @returns a promise of the HTTP operation\n */\n Message.prototype.removeTag = function(tag) {\n return this.$addOrRemoveTag('remove', tag);\n };\n\n /**\n * @function $addOrRemoveTag\n * @memberof Message.prototype\n * @desc Add or remove a mail tag on the current message.\n * @param {string} operation - the operation name to perform\n * @param {string} tag - the tag name\n * @returns a promise of the HTTP operation\n */\n Message.prototype.$addOrRemoveTag = function(operation, tag) {\n var data = {\n operation: operation,\n msgUIDs: [this.uid],\n flags: tag\n };\n\n if (tag)\n return Message.$$resource.post(this.$mailbox.$id(), 'addOrRemoveLabel', data);\n };\n\n /**\n * @function $imipAction\n * @memberof Message.prototype\n * @desc Perform IMIP actions on the current message.\n * @param {string} path - the path of the IMIP calendar part \n * @param {string} action - the the IMIP action to perform\n * @param {object} data - the delegation info \n */\n Message.prototype.$imipAction = function(path, action, data) {\n var _this = this;\n Message.$$resource.post([this.$absolutePath(), path].join('/'), action, data).then(function(data) {\n Message.$timeout(function() {\n _this.$reload();\n }, function() {\n // TODO: show toast\n });\n });\n };\n\n /**\n * @function $sendMDN\n * @memberof Message.prototype\n * @desc Send MDN response for current email message\n */\n Message.prototype.$sendMDN = function() {\n this.shouldAskReceipt = 0;\n return Message.$$resource.post(this.$absolutePath(), 'sendMDN');\n };\n\n /**\n * @function $deleteAttachment\n * @memberof Message.prototype\n * @desc Delete an attachment from a message being composed\n * @param {string} filename - the filename of the attachment to delete\n */\n Message.prototype.$deleteAttachment = function(filename) {\n var action = 'deleteAttachment?filename=' + filename;\n var _this = this;\n Message.$$resource.post(this.$absolutePath({asDraft: true}), action).then(function(data) {\n Message.$timeout(function() {\n _this.editable.attachmentAttrs = _.filter(_this.editable.attachmentAttrs, function(attachment) {\n return attachment.filename != filename;\n });\n }, function() {\n // TODO: show toast\n });\n });\n };\n\n /**\n * @function $markAsFlaggedOrUnflagged\n * @memberof Message.prototype\n * @desc Add or remove a the \\\\Flagged flag on the current message.\n * @returns a promise of the HTTP operation\n */\n Message.prototype.toggleFlag = function() {\n var _this = this,\n action = 'markMessageFlagged';\n\n if (this.isflagged)\n action = 'markMessageUnflagged';\n\n return Message.$$resource.post(this.$absolutePath(), action).then(function(data) {\n Message.$timeout(function() {\n _this.isflagged = !_this.isflagged;\n });\n });\n };\n\n /**\n * @function $reload\n * @memberof Message.prototype\n * @desc Fetch the viewable message body along with other metadata such as the list of attachments.\n * @returns a promise of the HTTP operation\n */\n Message.prototype.$reload = function(options) {\n var futureMessageData;\n\n futureMessageData = Message.$$resource.fetch(this.$absolutePath(options), 'view');\n\n return this.$unwrap(futureMessageData);\n };\n\n /**\n * @function $reply\n * @memberof Message.prototype\n * @desc Prepare a new Message object as a reply to the sender.\n * @returns a promise of the HTTP operations\n */\n Message.prototype.$reply = function() {\n return this.$newDraft('reply');\n };\n\n /**\n * @function $replyAll\n * @memberof Message.prototype\n * @desc Prepare a new Message object as a reply to the sender and all recipients.\n * @returns a promise of the HTTP operations\n */\n Message.prototype.$replyAll = function() {\n return this.$newDraft('replyall');\n };\n\n /**\n * @function $forward\n * @memberof Message.prototype\n * @desc Prepare a new Message object as a forward.\n * @returns a promise of the HTTP operations\n */\n Message.prototype.$forward = function() {\n return this.$newDraft('forward');\n };\n\n /**\n * @function $newDraft\n * @memberof Message.prototype\n * @desc Prepare a new Message object as a reply or a forward of the current message and associated\n * to the draft mailbox.\n * @see {@link Account.$newMessage}\n * @see {@link Message.$editableContent}\n * @see {@link Message.$reply}\n * @see {@link Message.$replyAll}\n * @see {@link Message.$forwad}\n * @param {string} action - the HTTP action to perform on the message\n * @returns a promise of the HTTP operations\n */\n Message.prototype.$newDraft = function(action) {\n var _this = this;\n\n // Query server for draft folder and draft UID\n return Message.$$resource.fetch(this.$absolutePath(), action).then(function(data) {\n var mailbox, message;\n Message.$log.debug('New ' + action + ': ' + JSON.stringify(data, undefined, 2));\n mailbox = _this.$mailbox.$account.$getMailboxByPath(data.mailboxPath);\n message = new Message(data.accountId, mailbox, data);\n // Fetch draft initial data\n return Message.$$resource.fetch(message.$absolutePath({asDraft: true}), 'edit').then(function(data) {\n Message.$log.debug('New ' + action + ': ' + JSON.stringify(data, undefined, 2) + ' original UID: ' + _this.uid);\n angular.extend(message.editable, data);\n\n // We keep a reference to our original message in order to update the flags\n message.origin = {message: _this, action: action};\n return message;\n });\n });\n };\n\n /**\n * @function $save\n * @memberof Message.prototype\n * @desc Save the message to the server.\n * @returns a promise of the HTTP operation\n */\n Message.prototype.$save = function() {\n var _this = this,\n data = this.editable;\n\n Message.$log.debug('save = ' + JSON.stringify(data, undefined, 2));\n\n return Message.$$resource.save(this.$absolutePath({asDraft: true}), data).then(function(response) {\n Message.$log.debug('save = ' + JSON.stringify(response, undefined, 2));\n _this.$setUID(response.uid);\n _this.$reload({asDraft: false}); // fetch a new viewable version of the message\n });\n };\n\n /**\n * @function $send\n * @memberof Message.prototype\n * @desc Send the message.\n * @returns a promise of the HTTP operation\n */\n Message.prototype.$send = function() {\n var _this = this,\n data = angular.copy(this.editable),\n deferred = Message.$q.defer();\n\n Message.$log.debug('send = ' + JSON.stringify(data, undefined, 2));\n\n Message.$$resource.post(this.$absolutePath({asDraft: true}), 'send', data).then(function(data) {\n if (data.status == 'success') {\n deferred.resolve(data);\n if (angular.isDefined(_this.origin)) {\n if (_this.origin.action.startsWith('reply'))\n _this.origin.message.isanswered = true;\n else if (_this.origin.action == 'forward')\n _this.origin.message.isforwarded = true;\n }\n }\n else {\n deferred.reject(data);\n }\n });\n\n return deferred.promise;\n };\n\n /**\n * @function $unwrap\n * @memberof Message.prototype\n * @desc Unwrap a promise. \n * @param {promise} futureMessageData - a promise of some of the Message's data\n */\n Message.prototype.$unwrap = function(futureMessageData) {\n var _this = this;\n\n // Resolve and expose the promise\n this.$futureMessageData = futureMessageData.then(function(data) {\n // Calling $timeout will force Angular to refresh the view\n if (_this.isread === 0) {\n Message.$$resource.fetch(_this.$absolutePath(), 'markMessageRead').then(function() {\n Message.$timeout(function() {\n _this.isread = true;\n _this.$mailbox.unseenCount--;\n });\n });\n }\n return Message.$timeout(function() {\n angular.extend(_this, data);\n _this.$formatFullAddresses();\n _this.$loadUnsafeContent = false;\n return _this;\n });\n });\n\n return this.$futureMessageData;\n };\n\n /**\n * @function $omit\n * @memberof Message.prototype\n * @desc Return a sanitized object used to send to the server.\n * @return an object literal copy of the Message instance\n */\n Message.prototype.$omit = function() {\n var message = {};\n angular.forEach(this, function(value, key) {\n if (key != 'constructor' && key[0] != '$') {\n message[key] = value;\n }\n });\n\n // Format addresses as arrays\n _.each(['from', 'to', 'cc', 'bcc', 'reply-to'], function(type) {\n if (message[type])\n message[type] = _.invoke(message[type].split(','), 'trim');\n });\n\n //Message.$log.debug(JSON.stringify(message, undefined, 2));\n return message;\n };\n\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @name VirtualMailbox\n * @constructor\n * @param {object} account - the mail account associated with the virtual search\n */\n function VirtualMailbox(account) {\n this.$account = account;\n }\n\n /**\n * @memberof VirtualMailbox\n * @desc The factory we'll use to register with Angular\n * @returns the VirtualMailbox constructor\n */\n VirtualMailbox.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'Message', 'Mailbox', 'sgMailbox_PRELOAD', function($q, $timeout, $log, Settings, Mailbox, Message, PRELOAD) {\n angular.extend(VirtualMailbox, {\n $q: $q,\n $timeout: $timeout,\n $log: $log,\n $Message: Message,\n selectedFolder: null,\n PRELOAD: PRELOAD\n });\n\n return VirtualMailbox; // return constructor\n }];\n\n /**\n * @module SOGo.MailerUI\n * @desc Factory registration of VirtualMailbox in Angular module.\n */\n try {\n angular.module('SOGo.MailerUI');\n }\n catch(e) {\n angular.module('SOGo.MailerUI', ['SOGo.Common']);\n }\n angular.module('SOGo.MailerUI')\n .constant('sgMailbox_PRELOAD', {\n LOOKAHEAD: 50,\n SIZE: 100\n })\n .factory('VirtualMailbox', VirtualMailbox.$factory);\n\n /**\n * @memberof VirtualMailbox\n * @desc Build the path of the virtual mailbox (or account only).\n * @param {string} accountId - the account ID\n * @returns a string representing the path relative to the mail module\n */\n VirtualMailbox.$absolutePath = function(accountId) {\n return [accountId, \"virtual\"].join('/');\n };\n\n /**\n * @function init\n * @memberof VirtualMailbox.prototype\n * @desc Extend instance with new data and compute additional attributes.\n * @param {object} data - attributes of mailbox\n */\n VirtualMailbox.prototype.init = function(data) {\n this.$isLoading = false;\n this.$mailboxes = [];\n this.uidsMap = {};\n angular.extend(this, data);\n this.id = this.$id();\n };\n\n VirtualMailbox.prototype.setMailboxes = function(data) {\n this.$mailboxes = data;\n\n _.each(this.$mailboxes, function(mailbox) {\n mailbox.$messages = [];\n mailbox.uidsMap = {};\n });\n };\n\n VirtualMailbox.prototype.startSearch = function(match, params) {\n var _this = this,\n search = VirtualMailbox.$q.when();\n\n this.$isLoading = true;\n\n _.each(this.$mailboxes, function(mailbox) {\n search = search.then(function() {\n if (_this.$isLoading) {\n VirtualMailbox.$log.debug(\"searching mailbox \" + mailbox.path);\n return mailbox.$filter( {sort: \"date\", asc: false, match: match}, params);\n }\n });\n });\n\n search.finally(function() { _this.$isLoading = false; });\n };\n\n VirtualMailbox.prototype.stopSearch = function() {\n VirtualMailbox.$log.debug(\"stopping search...\");\n this.$isLoading = false;\n };\n\n /**\n * @function resetSelectedMessage\n * @memberof VirtualMailbox.prototype\n * @desc Delete 'selectedMessage' attribute of all submailboxes.\n */\n VirtualMailbox.prototype.resetSelectedMessage = function() {\n _.each(this.$mailboxes, function(mailbox) {\n delete mailbox.selectedMessage;\n });\n };\n\n /**\n * @function isSelectedMessage\n * @memberof VirtualMailbox.prototype\n * @desc Check if the message of the specified mailbox is selected.\n * @param {string} messageId\n * @param {string} mailboxPath\n * @returns true if the specified message is selected\n */\n VirtualMailbox.prototype.isSelectedMessage = function(messageId, mailboxPath) {\n return angular.isDefined(_.find(this.$mailboxes, function(mailbox) {\n return mailbox.path == mailboxPath && mailbox.selectedMessage == messageId;\n }));\n };\n\n /**\n * @function getLength\n * @memberof VirtualMailbox.prototype\n * @desc Used by md-virtual-repeat / md-on-demand\n * @returns the number of items in the mailbox\n */\n VirtualMailbox.prototype.getLength = function() {\n var len = 0;\n\n if (!angular.isDefined(this.$mailboxes))\n return len;\n\n _.each(this.$mailboxes, function(mailbox) {\n len += mailbox.$messages.length;\n });\n\n return len;\n };\n\n /**\n * @function getItemAtIndex\n * @memberof VirtualMailbox.prototype\n * @desc Used by md-virtual-repeat / md-on-demand\n * @returns the message as the specified index\n */\n VirtualMailbox.prototype.getItemAtIndex = function(index) {\n var i, j, k, mailbox, message;\n\n if (angular.isDefined(this.$mailboxes) && index >= 0) {\n i = 0;\n for (j = 0; j < this.$mailboxes.length; j++) {\n mailbox = this.$mailboxes[j];\n for (k = 0; k < mailbox.$messages.length; i++, k++) {\n message = mailbox.$messages[k];\n if (i == index) {\n if (mailbox.$loadMessage(message.uid))\n return message;\n }\n }\n }\n }\n\n return null;\n };\n\n /**\n * @function $id\n * @memberof VirtualMailbox.prototype\n * @desc Build the unique ID to identified the mailbox.\n * @returns a string representing the path relative to the mail module\n */\n VirtualMailbox.prototype.$id = function() {\n return VirtualMailbox.$absolutePath(this.$account.id);\n };\n\n /**\n * @function $selectedCount\n * @memberof VirtualMailbox.prototype\n * @desc Return the number of messages selected by the user.\n * @returns the number of selected messages\n */\n VirtualMailbox.prototype.$selectedCount = function() {\n // TODO\n return 0;\n };\n\n /**\n * @function $flagMessages\n * @memberof VirtualMailbox.prototype\n * @desc Add or remove a flag on a message set\n * @returns a promise of the HTTP operation\n */\n VirtualMailbox.prototype.$flagMessages = function(uids, flags, operation) {\n // TODO\n // var data = {msgUIDs: uids,\n // flags: flags,\n // operation: operation};\n\n // return VirtualMailbox.$$resource.post(this.id, 'addOrRemoveLabel', data);\n };\n\n /**\n * @function $deleteMessages\n * @memberof VirtualMailbox.prototype\n * @desc Delete multiple messages from mailbox.\n * @return a promise of the HTTP operation\n */\n VirtualMailbox.prototype.$deleteMessages = function(uids) {\n // TODO\n //return VirtualMailbox.$$resource.post(this.id, 'batchDelete', {uids: uids});\n };\n\n /**\n * @function $copyMessages\n * @memberof VirtualMailbox.prototype\n * @desc Copy multiple messages from the current mailbox to a target one\n * @return a promise of the HTTP operation\n */\n VirtualMailbox.prototype.$copyMessages = function(uids, folder) {\n // TODO\n //return VirtualMailbox.$$resource.post(this.id, 'copyMessages', {uids: uids, folder: folder});\n };\n\n /**\n * @function $moveMessages\n * @memberof VirtualMailbox.prototype\n * @desc Move multiple messages from the current mailbox to a target one\n * @return a promise of the HTTP operation\n */\n VirtualMailbox.prototype.$moveMessages = function(uids, folder) {\n // TODO\n //return VirtualMailbox.$$resource.post(this.id, 'moveMessages', {uids: uids, folder: folder});\n };\n\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @ngInject\n */\n MailboxController.$inject = ['$state', '$timeout', '$mdDialog', 'stateAccounts', 'stateAccount', 'stateMailbox', 'encodeUriFilter', 'sgFocus', 'Dialog', 'Account', 'Mailbox'];\n function MailboxController($state, $timeout, $mdDialog, stateAccounts, stateAccount, stateMailbox, encodeUriFilter, focus, Dialog, Account, Mailbox) {\n var vm = this, messageDialog = null;\n\n Mailbox.selectedFolder = stateMailbox;\n\n vm.service = Mailbox;\n vm.accounts = stateAccounts;\n vm.account = stateAccount;\n vm.selectedFolder = stateMailbox;\n vm.selectMessage = selectMessage;\n vm.toggleMessageSelection = toggleMessageSelection;\n vm.unselectMessages = unselectMessages;\n vm.confirmDeleteSelectedMessages = confirmDeleteSelectedMessages;\n vm.copySelectedMessages = copySelectedMessages;\n // vm.moveSelectedMessages = moveSelectedMessages;\n vm.saveSelectedMessages = saveSelectedMessages;\n vm.markSelectedMessagesAsFlagged = markSelectedMessagesAsFlagged;\n vm.markSelectedMessagesAsUnread = markSelectedMessagesAsUnread;\n vm.selectAll = selectAll;\n vm.sort = sort;\n vm.sortedBy = sortedBy;\n vm.cancelSearch = cancelSearch;\n vm.newMessage = newMessage;\n vm.mode = { search: false };\n\n function selectMessage(message) {\n if (Mailbox.$virtualMode)\n $state.go('mail.account.virtualMailbox.message', {accountId: stateAccount.id, mailboxId: encodeUriFilter(message.$mailbox.path), messageId: message.uid});\n else\n $state.go('mail.account.mailbox.message', {accountId: stateAccount.id, mailboxId: encodeUriFilter(message.$mailbox.path), messageId: message.uid});\n }\n\n function toggleMessageSelection($event, message) {\n message.selected = !message.selected;\n $event.preventDefault();\n $event.stopPropagation();\n }\n\n function unselectMessages() {\n _.each(vm.selectedFolder.$messages, function(message) { message.selected = false; });\n }\n\n function confirmDeleteSelectedMessages() {\n Dialog.confirm(l('Warning'),\n l('Are you sure you want to delete the selected messages?'))\n .then(function() {\n // User confirmed the deletion\n var selectedMessages = _.filter(vm.selectedFolder.$messages, function(message) { return message.selected; });\n var selectedUIDs = _.pluck(selectedMessages, 'uid');\n vm.selectedFolder.$deleteMessages(selectedUIDs).then(function() {\n // Decrement the unseenCount accordingly\n var unseenCount = _.filter(selectedMessages, function(message) { return !message.isread; });\n vm.selectedFolder.$messages = _.difference(vm.selectedFolder.$messages, selectedMessages);\n vm.selectedFolder.unseenCount =- unseenCount;\n }, function(error) {\n Dialog.alert(l('Error'), error);\n });\n });\n }\n\n function copySelectedMessages(folder) {\n var selectedMessages = _.filter(vm.selectedFolder.$messages, function(message) { return message.selected; });\n var selectedUIDs = _.pluck(selectedMessages, 'uid');\n vm.selectedFolder.$copyMessages(selectedUIDs, '/' + folder).then(function() {\n // TODO: refresh target mailbox?\n }, function(error) {\n Dialog.alert(l('Error'), error);\n });\n }\n\n // function moveSelectedMessages(folder) {\n // var selectedMessages = _.filter(vm.selectedFolder.$messages, function(message) { return message.selected });\n // var selectedUIDs = _.pluck(selectedMessages, 'uid');\n // vm.selectedFolder.$moveMessages(selectedUIDs, '/' + folder).then(function() {\n // // TODO: refresh target mailbox?\n // vm.selectedFolder.$messages = _.difference(vm.selectedFolder.$messages, selectedMessages);\n // });\n // }\n\n function saveSelectedMessages() {\n var selectedMessages = _.filter(vm.selectedFolder.$messages, function(message) { return message.selected; });\n var selectedUIDs = _.pluck(selectedMessages, 'uid');\n window.location.href = ApplicationBaseURL + '/' + vm.selectedFolder.id + '/saveMessages?uid=' + selectedUIDs.join(\",\");\n }\n\n function selectAll() {\n _.each(vm.selectedFolder.$messages, function(message) {\n message.selected = true;\n });\n }\n\n function markSelectedMessagesAsFlagged() {\n var selectedMessages = _.filter(vm.selectedFolder.$messages, function(message) { return message.selected; });\n var selectedUIDs = _.pluck(selectedMessages, 'uid');\n\n vm.selectedFolder.$flagMessages(selectedUIDs, '\\\\Flagged', 'add').then(function(d) {\n // Success\n _.forEach(selectedMessages, function(message) {\n message.isflagged = true;\n });\n });\n }\n\n function markSelectedMessagesAsUnread() {\n var selectedMessages = _.filter(vm.selectedFolder.$messages, function(message) { return message.selected; });\n var selectedUIDs = _.pluck(selectedMessages, 'uid');\n\n vm.selectedFolder.$flagMessages(selectedUIDs, 'seen', 'remove').then(function(d) {\n // Success\n _.forEach(selectedMessages, function(message) {\n message.isread = false;\n vm.selectedFolder.unseenCount++;\n });\n });\n }\n\n function sort(field) {\n vm.selectedFolder.$filter({ sort: field });\n }\n\n function sortedBy(field) {\n return Mailbox.$query.sort == field;\n }\n\n function cancelSearch() {\n vm.mode.search = false;\n vm.selectedFolder.$filter();\n }\n\n function newMessage($event) {\n var message;\n\n if (messageDialog === null) {\n message = vm.account.$newMessage();\n messageDialog = $mdDialog\n .show({\n parent: angular.element(document.body),\n targetEvent: $event,\n clickOutsideToClose: false,\n escapeToClose: false,\n templateUrl: 'UIxMailEditor',\n controller: 'MessageEditorController',\n controllerAs: 'editor',\n locals: {\n stateAccounts: vm.accounts,\n stateMessage: message,\n stateRecipients: []\n }\n })\n .finally(function() {\n messageDialog = null;\n });\n }\n }\n }\n\n angular\n .module('SOGo.MailerUI')\n .controller('MailboxController', MailboxController);\n})();\n\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @ngInject\n */\n MailboxesController.$inject = ['$state', '$timeout', '$mdDialog', 'sgFocus', 'encodeUriFilter', 'Dialog', 'sgSettings', 'Account', 'Mailbox', 'VirtualMailbox', 'User', 'Preferences', 'stateAccounts'];\n function MailboxesController($state, $timeout, $mdDialog, focus, encodeUriFilter, Dialog, Settings, Account, Mailbox, VirtualMailbox, User, Preferences, stateAccounts) {\n var vm = this,\n account,\n mailbox;\n\n vm.service = Mailbox;\n vm.accounts = stateAccounts;\n vm.newFolder = newFolder;\n vm.delegate = delegate;\n vm.editFolder = editFolder;\n vm.revertEditing = revertEditing;\n vm.selectFolder = selectFolder;\n vm.saveFolder = saveFolder;\n vm.compactFolder = compactFolder;\n vm.emptyTrashFolder = emptyTrashFolder;\n vm.exportMails = exportMails;\n vm.confirmDelete = confirmDelete;\n vm.markFolderRead = markFolderRead;\n vm.share = share;\n vm.metadataForFolder = metadataForFolder;\n vm.setFolderAs = setFolderAs;\n vm.refreshUnseenCount = refreshUnseenCount;\n\n // Advanced search options\n vm.showingAdvancedSearch = false;\n vm.currentSearchParam = '';\n vm.addSearchParam = addSearchParam;\n vm.newSearchParam = newSearchParam;\n vm.showAdvancedSearch = showAdvancedSearch;\n vm.hideAdvancedSearch = hideAdvancedSearch;\n vm.toggleAdvancedSearch = toggleAdvancedSearch;\n vm.search = {\n options: {'': l('Select a criteria'),\n subject: l('Enter Subject'),\n from: l('Enter From'),\n to: l('Enter To'),\n cc: l('Enter Cc'),\n body: l('Enter Body')\n },\n mailbox: 'INBOX',\n subfolders: 1,\n match: 'AND',\n params: []\n };\n\n if ($state.current.name == 'mail' && vm.accounts.length > 0 && vm.accounts[0].$mailboxes.length > 0) {\n // Redirect to first mailbox of first account if no mailbox is selected\n account = vm.accounts[0];\n mailbox = account.$mailboxes[0];\n $state.go('mail.account.mailbox', { accountId: account.id, mailboxId: encodeUriFilter(mailbox.path) });\n }\n\n function showAdvancedSearch(path) {\n vm.showingAdvancedSearch = true;\n vm.search.mailbox = path;\n }\n\n function hideAdvancedSearch() {\n vm.showingAdvancedSearch = false;\n vm.service.$virtualMode = false;\n\n account = vm.accounts[0];\n mailbox = vm.searchPreviousMailbox;\n $state.go('mail.account.mailbox', { accountId: account.id, mailboxId: encodeUriFilter(mailbox.path) });\n }\n\n function toggleAdvancedSearch() {\n if (Mailbox.selectedFolder.$isLoading) {\n // Stop search\n vm.virtualMailbox.stopSearch();\n }\n else {\n // Start search\n var root, mailboxes = [],\n _visit = function(folders) {\n _.each(folders, function(o) {\n mailboxes.push(o);\n if (o.children && o.children.length > 0) {\n _visit(o.children);\n }\n });\n };\n\n vm.virtualMailbox = new VirtualMailbox(vm.accounts[0]);\n\n // Don't set the previous selected mailbox if we're in virtual mode\n // That allows users to do multiple advanced search but return\n // correctly to the previously selected mailbox once done.\n if (!Mailbox.$virtualMode)\n vm.searchPreviousMailbox = Mailbox.selectedFolder;\n\n Mailbox.selectedFolder = vm.virtualMailbox;\n Mailbox.$virtualMode = true;\n\n if (angular.isDefined(vm.search.mailbox)) {\n root = vm.accounts[0].$getMailboxByPath(vm.search.mailbox);\n mailboxes.push(root);\n if (vm.search.subfolders && root.children.length)\n _visit(root.children);\n }\n else {\n mailboxes = vm.accounts[0].$flattenMailboxes();\n }\n\n vm.virtualMailbox.setMailboxes(mailboxes);\n vm.virtualMailbox.startSearch(vm.search.match, vm.search.params);\n $state.go('mail.account.virtualMailbox', { accountId: vm.accounts[0].id });\n }\n }\n\n function addSearchParam(v) {\n vm.currentSearchParam = v;\n focus('advancedSearch');\n return false;\n }\n\n function newSearchParam(pattern) {\n if (pattern.length && vm.currentSearchParam.length) {\n var n = 0, searchParam = vm.currentSearchParam;\n if (pattern.startsWith(\"!\")) {\n n = 1;\n pattern = pattern.substring(1).trim();\n }\n vm.currentSearchParam = '';\n return { searchBy: searchParam, searchInput: pattern, negative: n };\n }\n }\n\n function newFolder(parentFolder) {\n Dialog.prompt(l('New folder'),\n l('Enter the new name of your folder :'))\n .then(function(name) {\n parentFolder.$newMailbox(parentFolder.id, name)\n .then(function() {\n // success\n }, function(data, status) {\n Dialog.alert(l('An error occured while creating the mailbox \"%{0}\".', name),\n l(data.error));\n });\n });\n }\n\n function delegate(account) {\n $mdDialog.show({\n templateUrl: account.id + '/delegation', // UI/Templates/MailerUI/UIxMailUserDelegation.wox\n controller: MailboxDelegationController,\n controllerAs: 'delegate',\n clickOutsideToClose: true,\n escapeToClose: true,\n locals: {\n User: User,\n account: account\n }\n });\n\n /**\n * @ngInject\n */\n MailboxDelegationController.$inject = ['$scope', '$mdDialog', 'User', 'account'];\n function MailboxDelegationController($scope, $mdDialog, User, account) {\n var vm = this;\n\n vm.users = account.delegates;\n vm.account = account;\n vm.userToAdd = '';\n vm.searchText = '';\n vm.userFilter = userFilter;\n vm.closeModal = closeModal;\n vm.removeUser = removeUser;\n vm.addUser = addUser;\n\n function userFilter($query) {\n return User.$filter($query, account.delegates);\n }\n\n function closeModal() {\n $mdDialog.hide();\n }\n\n function removeUser(user) {\n account.$removeDelegate(user.uid).catch(function(data, status) {\n Dialog.alert(l('Warning'), l('An error occured please try again.'));\n });\n }\n\n function addUser(data) {\n if (data) {\n account.$addDelegate(data).then(function() {\n vm.userToAdd = '';\n vm.searchText = '';\n }, function(error) {\n Dialog.alert(l('Warning'), error);\n });\n }\n }\n }\n } // delegate\n\n function editFolder(folder) {\n vm.editMode = folder.path;\n focus('mailboxName_' + folder.path);\n }\n\n function revertEditing(folder) {\n folder.$reset();\n vm.editMode = false;\n }\n\n function selectFolder(account, folder) {\n if (vm.editMode == folder.path)\n return;\n vm.editMode = false;\n vm.showingAdvancedSearch = false;\n vm.service.$virtualMode = false;\n $state.go('mail.account.mailbox', { accountId: account.id, mailboxId: encodeUriFilter(folder.path) });\n }\n\n function saveFolder(folder) {\n folder.$rename()\n .then(function(data) {\n vm.editMode = false;\n }, function(data, status) {\n Dialog.alert(l('Warning'), data);\n });\n }\n\n function compactFolder(folder) {\n folder.$compact().then(function() {\n // Success\n }, function(error) {\n Dialog.alert(l('Warning'), error);\n });\n }\n\n function emptyTrashFolder(folder) {\n folder.$emptyTrash().then(function() {\n // Success\n }, function(error) {\n Dialog.alert(l('Warning'), error);\n });\n }\n\n function exportMails(folder) {\n window.location.href = ApplicationBaseURL + '/' + folder.id + '/exportFolder';\n }\n\n function confirmDelete(folder) {\n Dialog.confirm(l('Confirmation'), l('Do you really want to move this folder into the trash ?'))\n .then(function() {\n folder.$delete()\n .then(function() {\n $state.go('mail');\n }, function(data, status) {\n Dialog.alert(l('An error occured while deleting the mailbox \"%{0}\".', folder.name),\n l(data.error));\n });\n });\n }\n\n function markFolderRead(folder) {\n folder.$markAsRead();\n }\n\n function share(folder) {\n // Fetch list of ACL users\n folder.$acl.$users().then(function() {\n // Show ACL editor\n $mdDialog.show({\n templateUrl: folder.id + '/UIxAclEditor', // UI/Templates/UIxAclEditor.wox\n controller: 'AclController', // from the ng module SOGo.Common\n controllerAs: 'acl',\n clickOutsideToClose: true,\n escapeToClose: true,\n locals: {\n usersWithACL: folder.$acl.users,\n User: User,\n folder: folder\n }\n });\n });\n } // share\n\n function metadataForFolder(folder) {\n if (folder.type == 'inbox')\n return {name: folder.name, icon:'inbox'};\n else if (folder.type == 'draft')\n return {name: l('DraftsFolderName'), icon: 'drafts'};\n else if (folder.type == 'sent')\n return {name: l('SentFolderName'), icon: 'send'};\n else if (folder.type == 'trash')\n return {name: l('TrashFolderName'), icon: 'delete'};\n else if (folder.type == 'additional')\n return {name: folder.name, icon: 'folder_shared'};\n\n return {name: folder.name, icon: 'folder_open'};\n }\n\n function setFolderAs(folder, type) {\n folder.$setFolderAs(type).then(function() {\n folder.$account.$getMailboxes({reload: true});\n }, function(error) {\n Dialog.alert(l('Warning'), error);\n });\n }\n\n function refreshUnseenCount() {\n var unseenCountFolders = window.unseenCountFolders;\n\n _.forEach(vm.accounts, function(account) {\n\n // Always include the INBOX\n if (!_.includes(unseenCountFolders, account.id + '/folderINBOX'))\n unseenCountFolders.push(account.id + '/folderINBOX');\n\n _.forEach(account.$$flattenMailboxes, function(mailbox) {\n if (angular.isDefined(mailbox.unseenCount) &&\n !_.includes(unseenCountFolders, mailbox.id))\n unseenCountFolders.push(mailbox.id);\n });\n });\n\n Account.$$resource.post('', 'unseenCount', {mailboxes: unseenCountFolders}).then(function(data) {\n _.forEach(vm.accounts, function(account) {\n _.forEach(account.$$flattenMailboxes, function(mailbox) {\n if (data[mailbox.id])\n mailbox.unseenCount = data[mailbox.id];\n });\n });\n });\n\n Preferences.ready().then(function() {\n var refreshViewCheck = Preferences.defaults.SOGoRefreshViewCheck;\n if (refreshViewCheck && refreshViewCheck != 'manually')\n $timeout(vm.refreshUnseenCount, refreshViewCheck.timeInterval()*1000);\n });\n }\n\n vm.refreshUnseenCount();\n }\n\n angular\n .module('SOGo.MailerUI') \n .controller('MailboxesController', MailboxesController); \n})();\n\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @ngInject\n */\n MessageController.$inject = ['$window', '$scope', '$state', '$mdDialog', 'stateAccounts', 'stateAccount', 'stateMailbox', 'stateMessage', 'encodeUriFilter', 'sgSettings', 'sgFocus', 'Dialog', 'Account', 'Mailbox', 'Message'];\n function MessageController($window, $scope, $state, $mdDialog, stateAccounts, stateAccount, stateMailbox, stateMessage, encodeUriFilter, sgSettings, focus, Dialog, Account, Mailbox, Message) {\n var vm = this, messageDialog = null, popupWindow = null;\n\n vm.accounts = stateAccounts;\n vm.account = stateAccount;\n vm.mailbox = stateMailbox;\n vm.message = stateMessage;\n vm.service = Message;\n vm.tags = { searchText: '', selected: '' };\n vm.doDelete = doDelete;\n vm.close = close;\n vm.reply = reply;\n vm.replyAll = replyAll;\n vm.forward = forward;\n vm.edit = edit;\n vm.openPopup = openPopup;\n vm.closePopup = closePopup;\n vm.newMessage = newMessage;\n vm.saveMessage = saveMessage;\n vm.viewRawSource = viewRawSource;\n\n // Watch the message model \"flags\" attribute to remove on-the-fly a tag from the IMAP message\n // when removed from the message viewer.\n // TODO: this approach should be reviewed once md-chips supports ng-change.\n $scope.$watchCollection('viewer.message.flags', function(oldTags, newTags) {\n _.each(_.difference(newTags, oldTags), function(tag) {\n vm.message.removeTag(tag);\n });\n });\n\n function doDelete() {\n stateMailbox.$deleteMessages([stateMessage.uid]).then(function() {\n // Remove message from list of messages\n var index = _.findIndex(stateMailbox.$messages, function(o) {\n return o.uid == stateMessage.uid;\n });\n if (index != -1)\n stateMailbox.$messages.splice(index, 1);\n // Remove message object from scope\n vm.message = null;\n $state.go('mail.account.mailbox', { accountId: stateAccount.id, mailboxId: encodeUriFilter(stateMailbox.path) });\n });\n }\n\n function showMailEditor($event, message, recipients) {\n if (messageDialog === null) {\n if (!angular.isDefined(recipients))\n recipients = [];\n\n messageDialog = $mdDialog\n .show({\n parent: angular.element(document.body),\n targetEvent: $event,\n clickOutsideToClose: false,\n escapeToClose: false,\n templateUrl: 'UIxMailEditor',\n controller: 'MessageEditorController',\n controllerAs: 'editor',\n locals: {\n stateAccounts: vm.accounts,\n stateMessage: message,\n stateRecipients: recipients\n }\n })\n .finally(function() {\n messageDialog = null;\n });\n }\n }\n\n function close() {\n $state.go('mail.account.mailbox', { accountId: stateAccount.id, mailboxId: encodeUriFilter(stateMailbox.path) }).then(function() {\n vm.message = null;\n delete stateMailbox.selectedMessage;\n });\n }\n\n function reply($event) {\n var message = vm.message.$reply();\n showMailEditor($event, message);\n }\n\n function replyAll($event) {\n var message = vm.message.$replyAll();\n showMailEditor($event, message);\n }\n\n function forward($event) {\n var message = vm.message.$forward();\n showMailEditor($event, message);\n }\n\n function edit($event) {\n vm.message.$editableContent().then(function() {\n showMailEditor($event, vm.message);\n });\n }\n\n function openPopup() {\n var url = [sgSettings.baseURL(),\n 'UIxMailPopupView#/Mail',\n vm.message.accountId,\n // The double-encoding is necessary\n encodeUriFilter(encodeUriFilter(vm.message.$mailbox.path)),\n vm.message.uid]\n .join('/'),\n wId = vm.message.$absolutePath();\n popupWindow = $window.open(url, wId,\n [\"width=680\",\n \"height=520\",\n \"resizable=1\",\n \"scrollbars=1\",\n \"toolbar=0\",\n \"location=0\",\n \"directories=0\",\n \"status=0\",\n \"menubar=0\",\n \"copyhistory=0\"]\n .join(','));\n }\n\n function closePopup() {\n $window.close();\n }\n\n function newMessage($event, recipient) {\n var message = vm.account.$newMessage();\n showMailEditor($event, message, [recipient]);\n }\n\n function saveMessage() {\n window.location.href = ApplicationBaseURL + '/' + vm.mailbox.id + '/saveMessages?uid=' + vm.message.uid;\n }\n\n function viewRawSource($event) {\n Message.$$resource.post(vm.message.id, \"viewsource\").then(function(data) {\n $mdDialog.show({\n parent: angular.element(document.body),\n targetEvent: $event,\n clickOutsideToClose: true,\n escapeToClose: true,\n template: [\n '<md-dialog flex=\"80\" flex-sm=\"100\" aria-label=\"' + l('View Message Source') + '\">',\n ' <md-dialog-content>',\n ' <pre>',\n data,\n ' </pre>',\n ' </md-dialog-content>',\n ' <div class=\"md-actions\">',\n ' <md-button ng-click=\"close()\">' + l('Close') + '</md-button>',\n ' </div>',\n '</md-dialog>'\n ].join(''),\n controller: MessageRawSourceDialogController\n });\n\n /**\n * @ngInject\n */\n MessageRawSourceDialogController.$inject = ['scope', '$mdDialog'];\n function MessageRawSourceDialogController(scope, $mdDialog) {\n scope.close = function() {\n $mdDialog.hide();\n };\n }\n });\n }\n }\n \n angular\n .module('SOGo.MailerUI') \n .controller('MessageController', MessageController); \n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @ngInject\n */\n MessageEditorController.$inject = ['$stateParams', '$mdDialog', 'FileUploader', 'stateAccounts', 'stateMessage', 'stateRecipients', '$timeout', 'sgFocus', 'Dialog', 'AddressBook', 'Preferences'];\n function MessageEditorController($stateParams, $mdDialog, FileUploader, stateAccounts, stateMessage, stateRecipients, $timeout, focus, Dialog, AddressBook, Preferences) {\n var vm = this;\n\n vm.addRecipient = addRecipient;\n vm.autocomplete = {to: {}, cc: {}, bcc: {}};\n vm.autosave = null;\n vm.autosaveDrafts = autosaveDrafts;\n vm.hideCc = true;\n vm.hideBcc = true;\n vm.cancel = cancel;\n vm.send = send;\n vm.contactFilter = contactFilter;\n vm.identities = _.pluck(_.flatten(_.pluck(stateAccounts, 'identities')), 'full');\n vm.uploader = new FileUploader({\n url: stateMessage.$absolutePath({asDraft: true}) + '/save',\n autoUpload: true,\n alias: 'attachments',\n onProgressItem: function(item, progress) {\n console.debug(item); console.debug(progress);\n },\n onSuccessItem: function(item, response, status, headers) {\n stateMessage.$setUID(response.uid);\n stateMessage.$reload();\n console.debug(item); console.debug('success = ' + JSON.stringify(response, undefined, 2));\n },\n onCancelItem: function(item, response, status, headers) {\n console.debug(item); console.debug('cancel = ' + JSON.stringify(response, undefined, 2));\n\n // We remove the attachment\n stateMessage.$deleteAttachment(item.file.name);\n this.removeFromQueue(item);\n },\n onErrorItem: function(item, response, status, headers) {\n console.debug(item); console.debug('error = ' + JSON.stringify(response, undefined, 2));\n }\n });\n\n if ($stateParams.actionName == 'reply') {\n stateMessage.$reply().then(function(msgObject) {\n vm.message = msgObject;\n vm.hideCc = (!msgObject.editable.cc || msgObject.editable.cc.length === 0);\n vm.hideBcc = (!msgObject.editable.bcc || msgObject.editable.bcc.length === 0);\n });\n }\n else if ($stateParams.actionName == 'replyall') {\n stateMessage.$replyAll().then(function(msgObject) {\n vm.message = msgObject;\n vm.hideCc = (!msgObject.editable.cc || msgObject.editable.cc.length === 0);\n vm.hideBcc = (!msgObject.editable.bcc || msgObject.editable.bcc.length === 0);\n });\n }\n else if ($stateParams.actionName == 'forward') {\n stateMessage.$forward().then(function(msgObject) {\n vm.message = msgObject;\n });\n }\n else if (angular.isDefined(stateMessage)) {\n vm.message = stateMessage;\n }\n\n if (angular.isDefined(stateRecipients)) {\n vm.message.editable.to = _.union(vm.message.editable.to, _.pluck(stateRecipients, 'full'));\n }\n\n function cancel() {\n // TODO: delete draft?\n if (vm.autosave)\n $timeout.cancel(vm.autosave);\n\n $mdDialog.cancel();\n }\n\n function send() {\n if (vm.autosave)\n $timeout.cancel(vm.autosave);\n\n vm.message.$send().then(function(data) {\n $mdDialog.hide();\n }, function(data) {\n Dialog.alert(l(data.status), l(data.message));\n });\n }\n\n function contactFilter($query) {\n return AddressBook.$filterAll($query);\n }\n\n function addRecipient(user) {\n var recipient = [];\n\n if (angular.isString(user))\n return user;\n if (user.$$fullname)\n recipient.push(user.$$fullname);\n if (user.$$email)\n recipient.push('<' + user.$$email + '>');\n\n return recipient.join(' ');\n }\n\n // Drafts autosaving\n function autosaveDrafts() {\n vm.message.$save();\n if (Preferences.defaults.SOGoMailAutoSave)\n vm.autosave = $timeout(vm.autosaveDrafts, Preferences.defaults.SOGoMailAutoSave*1000*60);\n }\n\n // Select list based on user's settings\n Preferences.ready().then(function() {\n if (Preferences.defaults.SOGoMailAutoSave)\n vm.autosave = $timeout(vm.autosaveDrafts, Preferences.defaults.SOGoMailAutoSave*1000*60);\n vm.localeCode = Preferences.defaults.LocaleCode;\n });\n }\n\n angular\n .module('SOGo.MailerUI') \n .controller('MessageEditorController', MessageEditorController); \n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n /* jshint validthis: true */\n 'use strict';\n\n /**\n * sgIMIP - A directive to handle IMIP actions on emails\n * @memberof SOGo.MailerUI\n * @example:\n\n */\n function sgImip() {\n return {\n restrict: 'A',\n link: link,\n controller: 'sgImipController'\n };\n\n function link(scope, iElement, attrs, ctrl) {\n ctrl.pathToAttachment = attrs.sgImipPath;\n }\n }\n\n /**\n * @ngInject\n */\n sgImipController.$inject = ['$scope', 'User'];\n function sgImipController($scope, User) {\n var vm = this;\n\n $scope.delegateInvitation = false;\n $scope.delegatedTo = '';\n $scope.searchText = '';\n\n $scope.userFilter = function($query) {\n return User.$filter($query);\n };\n\n $scope.iCalendarAction = function(action) {\n var data;\n\n if (action == 'delegate') {\n data = {\n receiveUpdates: false,\n delegatedTo: $scope.delegatedTo.c_email\n };\n }\n\n $scope.viewer.message.$imipAction(vm.pathToAttachment, action, data);\n };\n }\n\n angular\n .module('SOGo.MailerUI')\n .controller('sgImipController', sgImipController)\n .directive('sgImip', sgImip);\n})();\n\n"]}