/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is the Instantbird messenging client, released
 * 2007.
 *
 * The Initial Developer of the Original Code is
 * Florian QUEZE <florian@instantbird.org>.
 * Portions created by the Initial Developer are Copyright (C) 2007
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

#include "nsISupports.idl"
#include "purpleIProtocol.idl"
#include "purpleIConversation.idl"
#include "purpleIProxy.idl"

/* 
 * This is a proxy to libpurple PurpleAccount
 */

[scriptable, uuid(3c01ec75-6504-40df-af18-b8dc402c75a6)]
interface purpleIAccount: nsISupports {
  void connect();
  void disconnect();

  purpleIConversation createConversation(in AUTF8String aName);

  /*
   * Create a new chat conversation if it doesn't already exist.
   * Returns the conversation if it already existed, null otherwise
   */
  purpleIConversation joinChat(in AUTF8String aName);
  readonly attribute AUTF8String name;
  readonly attribute AUTF8String id;
  readonly attribute purpleIProtocol protocol;

  attribute boolean autoLogin;

  // FIXME password should be in password manager
  attribute AUTF8String password;
  attribute boolean rememberPassword;

  attribute AUTF8String alias;

  attribute purpleIProxyInfo proxyInfo;

  // protocol specific options: those functions set the protocol
  // specific options for the PurpleAccount and save the new values of
  // the preferences
  void setBool(in string aName, in boolean aVal);
  void setInt(in string aName, in long aVal);
  void setString(in string aName, in string aVal);
  void save();

  // returns an enumerator on a purpleIBuddy array
  nsISimpleEnumerator getBuddies();

  /* While an account is connecting, this attribute contains a message
     indicating the current step of the connection */
  readonly attribute AUTF8String connectionStateMsg;

  /* When a connection error occured, this value indicates the type of error */
  readonly attribute short connectionErrorReason;

  /* Time stamp of the next reconnection attempt */
  readonly attribute PRInt64 timeOfNextReconnect;

  const short NO_ERROR = -1;
  const short ERROR_NETWORK_ERROR = 0;
  const short ERROR_INVALID_USERNAME = 1;
  const short ERROR_AUTHENTICATION_FAILED = 2;
  const short ERROR_AUTHENTICATION_IMPOSSIBLE = 3;
  const short ERROR_NO_SSL_SUPPORT = 4;
  const short ERROR_ENCRYPTION_ERROR = 5;
  const short ERROR_NAME_IN_USE = 6;
  const short ERROR_INVALID_SETTINGS = 7;
  const short ERROR_CERT_NOT_PROVIDED = 8;
  const short ERROR_CERT_UNTRUSTED = 9;
  const short ERROR_CERT_EXPIRED = 10;
  const short ERROR_CERT_NOT_ACTIVATED = 11;
  const short ERROR_CERT_HOSTNAME_MISMATCH = 12;
  const short ERROR_CERT_FINGERPRINT_MISMATCH = 13;
  const short ERROR_CERT_SELF_SIGNED = 14;
  const short ERROR_CERT_OTHER_ERROR = 15;
  const short ERROR_OTHER_ERROR = 16;

  // use a big enough number so that it doesn't conflict with error
  // codes added in libpurple later
  const short ERROR_UNKNOWN_PRPL = 42;

  /* A message describing the connection error */
  readonly attribute AUTF8String connectionErrorMessage;

  /* Info about the connection state and flags */

  /* From PurpleAccount */
  readonly attribute boolean disconnecting;

  /* From PurpleConnectionState */

  //   PURPLE_DISCONNECTED 	Disconnected.
  readonly attribute boolean disconnected;

  //   PURPLE_CONNECTED 	Connected.
  readonly attribute boolean connected;

  //   PURPLE_CONNECTING 	Connecting. 
  readonly attribute boolean connecting;

  /* From PurpleConnectionFlags */

  //   PURPLE_CONNECTION_HTML
  //    Connection sends/receives in 'HTML'.
  readonly attribute boolean HTMLEnabled;

  //   PURPLE_CONNECTION_NO_BGCOLOR
  //    Connection does not send/receive background colors.
  readonly attribute boolean noBackgroundColors;

  //   PURPLE_CONNECTION_AUTO_RESP
  //    Send auto responses when away.
  readonly attribute boolean autoResponses;

  //   PURPLE_CONNECTION_FORMATTING_WBFO
  //    The text buffer must be formatted as a whole.
  readonly attribute boolean singleFormatting;

  //   PURPLE_CONNECTION_NO_NEWLINES
  //    No new lines are allowed in outgoing messages.
  readonly attribute boolean noNewlines;

  //   PURPLE_CONNECTION_NO_FONTSIZE
  //    Connection does not send/receive font sizes.
  readonly attribute boolean noFontSizes;

  //   PURPLE_CONNECTION_NO_URLDESC
  //    Connection does not support descriptions with links.
  readonly attribute boolean noUrlDesc;

  //   PURPLE_CONNECTION_NO_IMAGES
  //    Connection does not support sending of images.
  readonly attribute boolean noImages;
};
