Base Class

class Base()

Base class for the TbSync provider interface.

Base.abAutoComplete(accountData, query)

Implement this method, if this provider should add additional entries to the autocomplete list while typing something into the address field of the message composer.

The return value is an Array of Objects and each Object needs the following attributes:

  • value : An email address written like DisplayName <EmailAddress>.
  • comment : Optional A comment displayed to the right of the value in the autocomplete list.
  • icon : Optional A chrome uri to a 16x16 icon.
  • style : Optional A CSS class name.

When creating directories, you can set:

directory.setBoolValue("enable_autocomplete", false);

to disable the default autocomplete for this directory and have full control over the autocomplete.

Arguments:
  • accountData (AccountData) – The AccountData instance of the account being queried.
  • query (string) – The search query.
Returns:

Array of Objects.

Base.getApiVersion()

Returns the version identifier of the TbSync API this provider is using. If it is not matching the version identifier of the TbSync add-on the user has currently installed, this provider add-on is not loaded.

Returns:string – The API version identifier.
Base.getConnectionTimeout(accountData)

Returns the connection timeout for an active server request, so TbSync can append a countdown to the connection timeout, while waiting for an answer from the server. Only syncstates which start with send. will trigger this, see SyncData.setSyncState().

Arguments:
  • accountData (AccountData) – The AccountData instance for the account for which the timeout is being requested.
Returns:

integer – The timeout in milliseconds.

Base.getCreateAccountWindowUrl()

Returns URL of the new account window.

The URL will be opened via openDialog(), when the user wants to create a new account of this provider.

Returns:string – Chrome uri to file to be used in create account dialog.
Base.getDefaultAccountEntries()

Returns an Object which contains all possible account properties of accounts of this provider, with its default value if not yet stored in the database.

The returned Object uses the properties names as key and its default values as their value:

return {
 "username" : "",
 "host" : "",
 "https" : true,
 "someOtherOption" : false,
}

Please also check the standard account properties added by TbSync.

    defaults.provider = provider;
    defaults.accountID = "";
    defaults.lastsynctime = 0;
    defaults.status = "disabled";
    defaults.autosync = 0;
    defaults.accountname = "";
Returns:Object – List of properties with default values.
Base.getDefaultFolderEntries()

Returns an Object which contains all possible folder properties of folders of this provider, with its default value if not yet stored in the database.

The returned Object uses the properties names as key and its default values as their value:

return {
  "someSetting" : "none",
}

Please also check the standard folder properties added by TbSync:

    defaults.accountID = accountID;
    defaults.targetType = "";
    defaults.cached = false;
    defaults.selected = false;
    defaults.lastsynctime = 0;
    defaults.status = "";
    defaults.foldername = "";
    defaults.downloadonly = false;
Returns:Object – List of properties with default values.
Base.getEditAccountOverlayUrl()

Returns uri to the overlay for the edit account dialog (chrome://tbsync/content/manager/editAccount.xul)

The overlay must (!) implement:

tbSyncEditAccountOverlay.onload(window, accountData)

which is called each time an account of this provider is viewed/selected in the manager and gets passed the AccountData of the corresponding account.

Returns:string – Chrome uri to overlay for edit account dialog.
Base.getMaintainerEmail()

Returns the email address of the maintainer (used for bug reports).

Returns:string – An email address.
Base.getProviderIcon(size, accountData=null)

Returns location of a provider icon.

Arguments:
  • size (integer) – Size of the requested icon.
  • accountData (AccountData) – The AccountData instance of the account, which is requesting the icon. Optional.
Base.getProviderName()

Returns name of this provider for the Add account menu of tbe TbSync account manager.

Returns:string – A name.
Base.getSortedFolders(accountData)

Returns all folders of the account, sorted in the desired order.

The order will be used in the folder list and also as the order to sync the resources of the account identified by the passed AccountData.

Arguments:
  • accountData (AccountData) – The AccountData instance for the account for which the sorted list of folders should be returned.
Returns:

Array of FolderData() instances in the desired order.

Base.getSponsors()

Returns a list of sponsors, they will be sorted by sortIndex.

return {
  "sortIndex" : {name       : "Name",
                 description: "Something",
                 icon: chrome://path/or/empty,
                 link: "url://or/empty"
                },
}
Returns:Object – List of sponsors.
Base.getStringBundleUrl()

Returns the URL of the string bundle file of this provider, it can be accessed by getString().

Returns:string – Chrome uri to the string bundle file.
Base.load()

Called during load of this provider add-on.

Base.onDisableAccount(accountData)

Is called everytime an account of this provider is disabled in the manager UI.

Arguments:
  • accountData (AccountData) – The AccountData instance of the account being disabled.
Base.onEnableAccount(accountData)

Is called everytime an account of this provider is enabled in the manager UI.

Arguments:
  • accountData (AccountData) – The AccountData instance of the account being enabled.
Base.syncFolder(syncData, syncJob, syncRunNr)

Is called to synchronize a folder.

Never call this method directly, but use AccountData.sync() or FolderData.sync().

Arguments:
  • syncData (SyncData) – The SyncData instance with information regarding the requested sync
  • syncJob (string) – A specific sync job, defaults to “sync”, but can be set via the syncDescription. (see AccountData.sync or FolderData.sync).
  • syncRunNr (integer) – Indicates the n-th number the account is being (re-)synced due to enforced retries. It starts with 1 and is limited by syncDescription.maxAccountReruns.
Returns:

A StatusData() instance with information of the sync (failed/success).

Base.syncFolderList(syncData, syncJob, syncRunNr)

Is called to synchronize the folder list.

Never call this method directly, but use AccountData.sync().

Arguments:
  • syncData (SyncData) – The SyncData instance with information regarding the requested sync
  • syncJob (string) – A specific sync job, defaults to “sync”, but can be set via the syncDescription. (see AccountData.sync or FolderData.sync).
  • syncRunNr (integer) – Indicates the n-th number the account is being (re-)synced due to enforced retries. It starts with 1 and is limited by syncDescription.maxAccountReruns.
Returns:

A StatusData() instance with information of the sync (failed/success).

Base.unload()

Called during unload of this provider add-on.