Nitido Mail Controller

MailController  1.0.0

Nitido Mail Controller > MailController > CachedMailController
Search:
 
Filters

Class CachedMailController - extends BaseMailController

CachedMailController provides methods to access all server-side mail-related functions and data. The Mail Controller provides an out-of-the-box caching mechanism that caches the currently selected/ opened folder.

Constructor

CachedMailController ( )

Methods

addFolder

void addFolder ( options , options.fn , options.pfid )
Add a new mail folder
Parameters:
options <Object> Object literal of parameter values containing:
options.fn <String> Folder name
options.pfid <String> Folder's Parent id (if folder being added is a sub-folder)
Returns: void

deleteFolder

void deleteFolder ( options , options.fid )
Delete the specified mail folder
Parameters:
options <Object> Object literal of parameter values containing:
options.fid <String> Folder id
Returns: void

deleteMessages

void deleteMessages ( options , options.fid , options.mid )
Delete the given messages for the specified folder id
Parameters:
options <Object> Object literal of parameter values containing:
options.fid <String> Folder id
options.mid <String []> Message id(s)
Returns: void

emptyFolder

void emptyFolder ( options , options.fid )
Empty the specified mail folder
Parameters:
options <Object> Object literal of parameter values containing:
options.fid <String> Folder id
Returns: void

getAttachmentURI

object getAttachmentURI ( options , attachment )
Takes an attachment object (property of a Message object) and returns a URI to the attachment.
Parameters:
options <Object> Object literal of parameter values containing:
attachment <Object> An Attachment object to generate a URL for
Returns: object
Returns an attachment

getExternalEmail

void getExternalEmail ( )
POP Account Aggregation. Initiates a POP account aggregation request.
Returns: void

getFolderList

Array getFolderList ( )
Returns a list of mail Folder objects belonging to the currently logged-in user.
Returns: Array
Array of folder objects

getFolderObject

Object | Boolean getFolderObject ( options , options.fid )
Returns a Folder object for the specified folder id
Parameters:
options <Object> Object literal of parameter values containing:
options.fid <String> Folder id
Returns: Object | Boolean
specified folder (Folder) or false if none found.

getMessage

object getMessage ( options )
Returns the specified message from the controller's cache
Parameters:
options <Object> Object literal of parameter values. NB: This is the same configuration object passed into loadMessage.
Returns: object
A Message object with the following properties: attachments, bcc, bodyhtml, cc, date, fn, mid, msgheaders, sender, subject, timezone, to, etc.

getMessageIds

Array getMessageIds ( )
Returns a list of message IDs for the current folder
Returns: Array
Array of folder objects

getMessages

void getMessages ( options )
Returns a list of Mail Messages (from start to end index) for the specified folder.
Parameters:
options <Object> Object literal of parameter values. NB: This is the same configuration object passed into loadMessages.
Returns: void

getSelectedFolder

Object getSelectedFolder ( )
Returns the currently selected/opened Folder object
Returns: Object
The selected Folder object

getUsage

object getUsage ( )
Get the mail quota for the currently logged-in user
Returns: object
Mail Quota object. The object's properties are: percentage, total

loadFolderCount

void loadFolderCount ( options , options.ignoreError )
Loads the folder count (total/unread messages) of user's mail folders into the cache.
Parameters:
options <Object> Object literal of parameter values containing:
options.ignoreError <Boolean> (Optional) indicates whether to ignore the server response containing an error code.
Returns: void

loadFolderList

void loadFolderList ( options , options.ignoreError )
Load the currently logged-in user's mail folders into the cache.
Parameters:
options <Object> Object literal of parameter values containing:
options.ignoreError <Boolean> (Optional) indicates whether to ignore the server response containing an error code.
Returns: void

loadMessage

void loadMessage ( options , options.fid , options.mid )
Load the specified message. If the specified message exists in the controller cache, it is returned instead of re-requesting it from the server.
Parameters:
options <Object> Object literal of parameter values containing:
options.fid <String> Folder id
options.mid <String> Message id
Returns: void

loadMessages

void loadMessages ( options , options.fid , options.start , options.end , options.sc , options.so , options.sk , options.check , options.pop , options.invalidateCache )
Load messages for the given folder from start to end indices. However, if invalidateCache is true, a request to load the messages from the server is made regardless of whether the specified messages exist in the cache.
Parameters:
options <Object> Object literal of parameter values containing:
options.fid <String> Folder id
options.start <Number> Start position/index of the messages to load
options.end <Number> End position/index of the messages to load
options.sc <String> Sort column
options.so <String> Sort order (one of 2 values: asc or desc)
options.sk <Object> (Optional) Search keyword(s). Uses the following format:

Example:

subject:"test", 
sender: "wau@nitido.com"

options.check <Boolean> (Optional) Indicates whether to just perform a "check mail" operation
options.pop <Boolean> (Optional) Indicates whether to perform a POP account check/download
options.invalidateCache <Boolean> (Optional) Tells the controller to bypass the cache and request messages from the server
Returns: void

loadUsage

void loadUsage ( options , options.ignoreError )
Load the mail quota from the server for the currently active user
Parameters:
options <Object> Object literal of parameter values containing:
options.ignoreError <Boolean> (Optional) indicates whether to ignore the server response containing an error code.
Returns: void

markAsSpam

void markAsSpam ( options , options.fid , options.mid )
Mark the given message as spam/not spam
Parameters:
options <Object> Object literal of parameter values containing:
options.fid <String> Folder id the message(s) belong to
options.mid <String []> Message id(s)
Returns: void

moveMessages

void moveMessages ( options , options.sfid , options.tfid , options.mid )
Move the specified messages from the source folder to the target folder
Parameters:
options <Object> Object literal of parameter values containing:
options.sfid <String> Source folder id
options.tfid <String> Target folder id
options.mid <String []> Message id(s)
Returns: void

renameFolder

void renameFolder ( options , options.nfn , options.ofid , options.pfid )
Rename the given (existing) folder
Parameters:
options <Object> Object literal of parameter values containing:
options.nfn <String> New folder name
options.ofid <String> Folder id
options.pfid <String> (Optional) Folder's Parent id (if folder being renamed is a sub-folder)
Returns: void

saveAsDraft

void saveAsDraft ( options , options.msg )
Save the given message as a draft.
Parameters:
options <Object> Object literal of parameter values containing:
options.msg <Object> Message object
Returns: void

sendMessage

void sendMessage ( options , options.msg , options.action , options.omid , options.fid )
Send a message. At least one recipient must be specified in order to successfully send the message.
Parameters:
options <Object> Object literal of parameter values containing:
options.msg <Object> Message object
options.action <String> (Optional) Indicates if email being sent is a reply or a forward to an original email. Can have one of the following two values:
  • f - Indicates this is a forward action
  • r - Indicates this is a reply action
options.omid <String> (Optional) The original message id (when replying to, or forwarding, a message)
options.fid <String> (Optional) The original folder id (when replying to, or forwarding, a message)
Returns: void

setMessageFlag

void setMessageFlag ( options , options.mid , options.fid , options.flag )
Set a flag for the given messages
Parameters:
options <Object> Object literal of parameter values containing:
options.mid <String []> Message's ID(s)
options.fid <String> Folder id
options.flag <Number> The following flags are available:
  • 0 - mark messages as unread
  • 1 - mark messages as read
  • 2 - mark messages as "flagged"
  • 3 - unmark messages as "flagged"
  • on|<tagname> - Adds a user-defined tag to the message. <tagname> is a custom user- defined tag. | is the Unix pipe character.
  • off|<tagname> - Removes a user-defined tag from the message. <tagname> is a custom user-defined tag. | is the Unix pipe character.
Returns: void

subscribe

void subscribe ( options , options.name , options.callback )
Subscribe to a custom event from the Mail Controller
Parameters:
options <Object> Object literal of parameter values containing:
options.name <String> The event name to subscribe to
options.callback <Function> The callback method to call when the event fires
Returns: void

unsubscribe

void unsubscribe ( options , options.name , options.callback )
Subscribe to a custom event from the Mail Controller
Parameters:
options <Object> Object literal of parameter values containing:
options.name <String> The event name to unsubscribe from
options.callback <Function> The callback method associated to the original subscription
Returns: void


Copyright © 2010 Nitido Inc. All rights reserved.