Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Chat Core Protocols

The Chat Core code used by Instantbird and Thunderbird has some abstractions to deal with the differences between protocols (e.g. IRC vs. XMPP).

Protocol Interfaces

Protocols are implemented in the chat core using XPCOM (in any of the languages that supports: C++, JavaScript, etc.). For new implementations, we recommend using JavaScript. Instantbird can also use libpurple protocol plugins that are recompiled for Instantbird (it is API compatible, but not ABI compatible).

Protocols added by extensions or distributed with chat core are treated identically. They must implement the proper interfaces and be registered with the category manager in order to be found. Protocols need to implement the prplI* interfaces (this can mostly be done using jsProtoHelper). The minimum set of interfaces to implement are:

Useful Code

Example Implementations

The code for the JavaScript protocols we ship by default is here.

  • IRC: A full example implementing private chats and MUCs, etc. It is currently used in Instantbird/Thunderbird and includes hooks for other extensions.
  • JavaScript Test Protocol: An extremely simple example meant to serve as test code for the interfaces.
  • Twitter: Implements the Twitter API (link me?), included in Instantbird/Thunderbird.
  • XMPP: Included in Instantbird, but not enabled by default. Used by default in Thunderbird. Since XMPP is extensible, there are also other protocols which inherit and customize XMPP.

Example protocol add-ons

  • LJ Talk
  • Omegle: A simple example using JSON requests, implemented as an extension.

Useful Code Snippets

Using Services.core.getProtocols() to list all protocols

This lists the protocol plugins that the core service knows about. You can copy the code (as it is), paste it in the error console (linebreaks will automatically be ignored) and press "Enter" to run it.

Components.utils.import("resource:///modules/imServices.jsm");
var x = Services.core.getProtocols();
var result = "";
while (x.hasMoreElements()) {
  var y = x.getNext().QueryInterface(Components.interfaces.prplIProtocol);
  result += y.name + "\t\t" +y.id + "\n";
}
Services.console.logStringMessage(result);

Document Tags and Contributors

Tags: 
 Contributors to this page: jswisher, aleth, clokep
 Last updated by: jswisher,