B2G/gaia/apps/email/js/ext/mailapi/composite/configurator.js
/**
 * Account object, root of all interaction with servers.
 *
 * Passwords are currently held in cleartext with the rest of the data.  Ideally
 * we would like them to be stored in some type of keyring coupled to the TCP
 * API in such a way that we never know the API.  Se a vida e.
 *
 */
Account object, root of all interaction with servers.
Passwords are currently held in cleartext with the rest of the data.  Ideally
we would like them to be stored in some type of keyring coupled to the TCP
API in such a way that we never know the API.  Se a vida e.
Account object root of all interaction with servers . Passwords are currently held in cleartext with the rest of the data . Ideally we would like them to be stored in some type of keyring coupled to the TCP API in such a way that we never know the API . Se a vida e .
function ImapAccount(universe, compositeAccount, accountId, credentials,
                     connInfo, folderInfos,
                     dbConn,
                     _parentLog, existingProtoConn) {
  this.universe = universe;
  this.compositeAccount = compositeAccount;
  this.id = accountId;
  this.accountDef = compositeAccount.accountDef;
  this.enabled = true;
  this._alive = true;
  this._LOG = LOGFAB.ImapAccount(this, _parentLog, this.id);
  this._credentials = credentials;
  this._connInfo = connInfo;
  this._db = dbConn;
  this._maxConnsAllowed = 3;
  this._pendingConn = null;
  this._ownedConns = [];
  this._demandedConns = [];
  this._backoffEndpoint = $errbackoff.createEndpoint('imap:' + this.id, this,
                                                     this._LOG);
  if (existingProtoConn)
    this._reuseConnection(existingProtoConn);
  var folderStorages = this._folderStorages = {};
  var folderPubs = this.folders = [];
  this._deadFolderIds = null;
  this._folderInfos = folderInfos;
  this.meta = this._folderInfos.$meta;
  this.mutations = this._folderInfos.$mutations;
  this.tzOffset = compositeAccount.accountDef.tzOffset;
  for (var folderId in folderInfos) {
    if (folderId[0] === '$')
      continue;
    var folderInfo = folderInfos[folderId];
    folderStorages[folderId] =
      new $mailslice.FolderStorage(this, folderId, folderInfo, this._db,
                                   $imapfolder.ImapFolderSyncer, this._LOG);
    folderPubs.push(folderInfo.$meta);
  }
  this.folders.sort(function(a, b) {
    return a.path.localeCompare(b.path);
  });
  this._jobDriver = new $imapjobs.ImapJobDriver(
                          this, this._folderInfos.$mutationState, this._LOG);
  this._TEST_doNotCloseFolder = false;
  var inboxFolder = this.getFirstFolderWithType('inbox');
  if (!inboxFolder) {
    this._learnAboutFolder('INBOX', 'INBOX', null, 'inbox', '/', 0, true);
  }
}
function ImapAccount ( universe , compositeAccount , accountId , credentials , connInfo , folderInfos , dbConn , _parentLog , existingProtoConn ) { this . universe = universe ; this . compositeAccount = compositeAccount ; this . id = accountId ; this . accountDef = compositeAccount . accountDef ; this . enabled = true ; this . _alive = true ; this . _LOG = LOGFAB . ImapAccount ( this , _parentLog , this . id ) ; this . _credentials = credentials ; this . _connInfo = connInfo ; this . _db = dbConn ; this . _maxConnsAllowed = 3 ; this . _pendingConn = null ; this . _ownedConns = [ ] ; this . _demandedConns = [ ] ; this . _backoffEndpoint = $errbackoff . createEndpoint ( 'imap:' + this . id , this , this . _LOG ) ; if ( existingProtoConn ) this . _reuseConnection ( existingProtoConn ) ; var folderStorages = this . _folderStorages = { } ; var folderPubs = this . folders = [ ] ; this . _deadFolderIds = null ; this . _folderInfos = folderInfos ; this . meta = this . _folderInfos . $meta ; this . mutations = this . _folderInfos . $mutations ; this . tzOffset = compositeAccount . accountDef . tzOffset ; for ( var folderId in folderInfos ) { if ( folderId [ 0 ] === '$' ) continue ; var folderInfo = folderInfos [ folderId ] ; folderStorages [ folderId ] = new $mailslice . FolderStorage ( this , folderId , folderInfo , this . _db , $imapfolder . ImapFolderSyncer , this . _LOG ) ; folderPubs . push ( folderInfo . $meta ) ; } this . folders . sort ( function ( a , b ) { return a . path . localeCompare ( b . path ) ; } ) ; this . _jobDriver = new $imapjobs . ImapJobDriver ( this , this . _folderInfos . $mutationState , this . _LOG ) ; this . _TEST_doNotCloseFolder = false ; var inboxFolder = this . getFirstFolderWithType ( 'inbox' ) ; if ( ! inboxFolder ) { this . _learnAboutFolder ( 'INBOX' , 'INBOX' , null , 'inbox' , '/' , 0 , true ) ; } }
Account object, root of all interaction with servers.
Account object root of all interaction with servers .
/**
   * The maximum number of connections we are allowed to have alive at once.  We
   * want to limit this both because we generally aren't sophisticated enough
   * to need to use many connections at once (unless we have bugs), and because
   * servers may enforce a per-account connection limit which can affect both
   * us and other clients on other devices.
   *
   * Thunderbird's default for this is 5.
   *
   * gmail currently claims to have a limit of 10 connections per account:
   * http://support.google.com/mail/bin/answer.py?hl=en&answer=97150
   *
   * I am picking 3 right now because it should cover the "I just sent a
   * messages from the folder I was in and then switched to another folder",
   * where we could have stuff to do in the old folder, new folder, and sent
   * mail folder.  I have also seem claims of connection limits of 3 for some
   * accounts out there, so this avoids us needing logic to infer a need to
   * lower our connection limit.
   */ /**
   * The `ImapConnection` we are attempting to open, if any.  We only try to
   * open one connection at a time.
   */ /**
   * @listof[@dict[
   *   @key[folderId]
   *   @key[callback]
   * ]]{
   *   The list of requested connections that have not yet been serviced.  An
   * }
   */ // Yes, the pluralization is suspect, but unambiguous. /** @dictof[@key[FolderId] @value[ImapFolderStorage] */ /** @dictof[@key[FolderId] @value[ImapFolderMeta] */ /**
   * The list of dead folder id's that we need to nuke the storage for when
   * we next save our account status to the database.
   */ /**
   * The canonical folderInfo object we persist to the database.
   */ /**
   * @dict[
   *   @param[nextFolderNum Number]{
   *     The next numeric folder number to be allocated.
   *   }
   *   @param[nextMutationNum Number]{
   *     The next mutation id to be allocated.
   *   }
   *   @param[lastFolderSyncAt DateMS]{
   *     When was the last time we ran `syncFolderList`?
   *   }
   *   @param[capability @listof[String]]{
   *     The post-login capabilities from the server.
   *   }
   *   @param[rootDelim String]{
   *     The root hierarchy delimiter.  It is possible for servers to not
   *     support hierarchies, but we just declare that those servers are not
   *     acceptable for use.
   *   }
   * ]{
   *   Meta-information about the account derived from probing the account.
   *   This information gets flushed on database upgrades.
   * }
   */ /**
   * @listof[SerializedMutation]{
   *   The list of recently issued mutations against us.  Mutations are added
   *   as soon as they are requested and remain until evicted based on a hard
   *   numeric limit.  The limit is driven by our unit tests rather than our
   *   UI which currently only allows a maximum of 1 (high-level) undo.  The
   *   status of whether the mutation has been run is tracked on the mutation
   *   but does not affect its presence or position in the list.
   *
   *   Right now, the `MailUniverse` is in charge of this and we just are a
   *   convenient place to stash the data.
   * }
   */ /**
   * Flag to allow us to avoid calling closeBox to close a folder.  This avoids
   * expunging deleted messages.
   */ // Ensure we have an inbox.  This is a folder that must exist with a standard // name, so we can create it without talking to the server. // XXX localized inbox string (bug 805834)