/* ***** 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 "nsISimpleEnumerator.idl"

/*
 * This is the libpurple protocol
 */

%{C++
#pragma GCC visibility push(default)
#include <libpurple/prpl.h>
#pragma GCC visibility pop
%}

[ptr] native PurpleNativePluginProtocolInfo(PurplePluginProtocolInfo);
interface purpleIAccount;

[scriptable, uuid(0a51b511-4ce7-4f4c-a109-43023b72fc5a)]
interface purpleIProtocol: nsISupports {
  readonly attribute AUTF8String name;
  readonly attribute AUTF8String id;
  readonly attribute AUTF8String normalizedName;

  // returns a chrome URI pointing to a folder that contains the files:
  // icon.png icon32.png and icon48.png
  readonly attribute AUTF8String iconBaseURI;

  // returns an enumerator of purpleIPref
  nsISimpleEnumerator getOptions();

  // returns an enumerator of purpleIUsernameSplit
  nsISimpleEnumerator getUsernameSplit();

  // descriptive text to put in the username input box when it is empty
  readonly attribute AUTF8String usernameEmptyText;

  // Use this function to avoid attempting to create duplicate accounts
  boolean accountExists(in AUTF8String aName);

  // These should all be stuff that some plugins can do and others can't.

  // OPT_PROTO_UNIQUE_CHATNAME Use a unique name, not an alias, for
  // chat rooms.
  //  XMPP lets you choose what name you want for chat. So it
  //  shouldn't be pulling the alias for when you're in chat; it gets
  //  annoying.
  readonly attribute boolean uniqueChatName;

  // OPT_PROTO_CHAT_TOPIC Chat rooms have topics.
  //  IRC and XMPP support this.
  readonly attribute boolean chatHasTopic;

  // OPT_PROTO_NO_PASSWORD Don't require passwords for sign-in.
  //  Zephyr doesn't require passwords, so there's no need for a
  //  password prompt.
  readonly attribute boolean noPassword;

  // OPT_PROTO_MAIL_CHECK Notify on new mail.
  //  MSN and Yahoo notify you when you have new mail.
  readonly attribute boolean newMailNotification;

  // OPT_PROTO_IM_IMAGE Images in IMs.
  //  Oscar lets you send images in direct IMs.
  readonly attribute boolean imagesInIM;

  // OPT_PROTO_PASSWORD_OPTIONAL Allow passwords to be optional.
  //  Passwords in IRC are optional, and are needed for certain
  //  functionality.
  readonly attribute boolean passwordOptional;

  // OPT_PROTO_USE_POINTSIZE Allows font size to be specified in sane
  // point size.
  //  Probably just XMPP and Y!M
  readonly attribute boolean usePointSize;

  // OPT_PROTO_REGISTER_NOSCREENNAME Set the Register button active
  // when screenname is not given.
  //  Gadu-Gadu doesn't need a screenname to register new account.
  readonly attribute boolean registerNoScreenName;

  // OPT_PROTO_SLASH_COMMANDS_NATIVE  Indicates that slash commands
  // are native to this protocol.
  // Used as a hint that unknown commands should not be sent as messages.
  readonly attribute boolean slashCommandsNative;

  // Indicates if the protocol plugin can use a purpleIProxy for the
  // account, or uses the Mozilla proxy settings for all accounts.
  readonly attribute boolean usePurpleProxy;

  // The key is the unique identifier needed to get account data
  // stored in the preferences.
  purpleIAccount getAccount(in AUTF8String aKey, in AUTF8String aName);
};

[scriptable, uuid(20c4971a-f7c2-4781-8e85-69fee7b83a3d)]
interface purpleIUsernameSplit: nsISupports {
  readonly attribute AUTF8String label;
  readonly attribute AUTF8String defaultValue;
  readonly attribute char separator;

  /* reverse is PR_TRUE if the separator should be found starting at
     the end of the string, PR_FALSE otherwise. */
  readonly attribute PRBool reverse;
};

/* purpleIOverrideProtocol provides a way to override some properties
   of a protocol plugin.

   It takes a base protocol plugin and an override.  For each method
   of purpleIProtocol, it will call the same method of the override if
   it implements it, otherwise it will fallback to the method of the
   base.
 */
[scriptable, uuid(766ae941-9fb6-49e2-9762-8494b288333c)]
interface purpleIOverrideProtocol: purpleIProtocol {
  void init(in purpleIProtocol aBase, in purpleIProtocol aOverride);

  readonly attribute purpleIProtocol basePrpl;
  readonly attribute purpleIProtocol override;
};

%{C++
#define JS_PROTOCOL_PLUGIN_CATEGORY "js-protocol-plugin"
%}
