chat/components/public/imIAccountsService.idl
author Gervase Markham <gerv@gerv.net>
Wed, 30 May 2012 17:48:24 +0100
changeset 12286 84ac3c71109811da751f0ef2d72108075938f094
parent 11079 8cdfed92867f885fda98664395236b7829947a1d
child 19292 f81a23bfefcd0f6ec6215fbde12f8af2bc7749f1
permissions -rw-r--r--
Bug 757018 - upgrade license to MPL 2.

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"
#include "nsISimpleEnumerator.idl"
#include "imIAccount.idl"

[scriptable, uuid(b3b6459a-5c26-47b8-8e9c-ba838b6f632a)]
interface imIAccountsService: nsISupports {
  void initAccounts();
  void unInitAccounts();

  /* This attribute is set to AUTOLOGIN_ENABLED by default. It can be set to
     any other value before the initialization of this service to prevent
     accounts with autoLogin enabled from being connected when libpurple is
     initialized.
     Any value other than the ones listed below will disable autoLogin and
     display a generic message in the Account Manager. */
  attribute short autoLoginStatus;

  const short AUTOLOGIN_ENABLED = 0;
  const short AUTOLOGIN_USER_DISABLED = 1;
  const short AUTOLOGIN_SAFE_MODE = 2;
  const short AUTOLOGIN_CRASH = 3;
  const short AUTOLOGIN_START_OFFLINE = 4;

  /* The method should be used to connect all accounts with autoLogin enabled.
     Some use cases:
       - if the autologin was disabled at startup
       - after a loss of internet connectivity that disconnected all accounts.
  */
  void processAutoLogin();

  imIAccount getAccountById(in AUTF8String aAccountId);

  /* will throw NS_ERROR_FAILURE if not found */
  imIAccount getAccountByNumericId(in unsigned long aAccountId);

  nsISimpleEnumerator getAccounts();

  /* will fire the event account-added */
  imIAccount createAccount(in AUTF8String aName, in AUTF8String aPrpl);

  /* will fire the event account-removed */
  void deleteAccount(in AUTF8String aAccountId);
};

/*
 account related notifications sent to nsIObserverService:
   - account-added: a new account has been created
   - account-removed: the account has been deleted
   - account-connecting: the account is being connected
   - account-connected: the account is now connected
   - account-connect-error: the account is disconnect with an error.
     (before account-disconnecting)
   - account-disconnecting: the account is being disconnected
   - account-disconnected: the account is now disconnected
   - account-updated: when some settings have changed
   - account-list-updated: when the list of account is reordered.
   These events can be watched using an nsIObserver.
   The associated imIAccount will be given as a parameter
   (except for account-list-updated).
*/