Instant Messaging in LinuxMCE

From LinuxMCE
Jump to: navigation, search


This set of pages will comprise my notes for bringing an Instant Messaging UI and associated back-end to LinuxMCE, as well as the design considerations taken.



Goals

  • Provide an instant messaging system to send messages between users of the house
  • Provide an instant messaging system to send messages between users of the house and other instant messaging networks such as AIM, Yahoo, ICQ, MSN, Jabber, and

others.

It was started by --Tschak909 12:22, 21 September 2008 (PDT) , but may be continued by other people during the course of its development.



Architecture

The Instant Messaging system follows the pattern for other house-wide devices in pluto, namely:

The Devices

  • Instant_Messaging_Plugin - This plugin provides the high level functions for the Orbiter UI and basic interactions for the different instant messaging transports. It runs within the router.
  • Instant Messaging Devices - These individual devices provide wrappers to DCE for the different instant messaging transports. Initially there will be two of them, one for in-house communications (a very thin wrapper basically echoing messages), these devices provide the actual instant messaging logic, sending events whenever things happen, that the Instant Messaging Plugin catches, and uses to update the UI.



Why is the functionality split like this?

You may have noticed this sort of split in other aspects of the system, where you have for example the Telecom_Plugin, and Asterisk, or the Media Plugin, and its associated players. The question you may be asking yourself is, why?

The Plug-ins run as part of the DCE Router, in the same memory space. This means that the data structures of the router, and any of the other plugins are accessible. This is necessary because when we register events and data grid generators, we need to be able to have direct access to data types emitted by the other plugins, such as the Orbiter Plugin (which manages pushing events to the orbiters), and the Datagrid Plugin (which manages populating data grids on the orbiters).

So while the plugin acts as the high level house-wide logic, the Instant Messaging Devices provide the "workers" needed to connect to these instant messaging frameworks and do the actual work. The devices themselves emit events, and recieve commands from the Instant Messaging Plugin when something needs to be done on a particular transport. The events that are sent from the DCE devices are described below, and form the necessary notification when the plugin needs to alter data grids etc to change the UI as needed.

The Instant_Messaging_Plugin uses the above two mentioned plugins to provide the user interface to all the orbiters in the house.

The Two Instant Messaging Devices

The following two Instant Messaging Devices will be developed alongside the Instant Messaging Plugin:

  • Local House Messaging - This device, will be a thin wrapper around DCE, that allows for instant messaging to work inside the house. Its buddy list will come directly from the in-house user list, and presence will be determined by which people have been selected as users on orbiters.
  • libPurple - This device, will be a DCE wrapper around the Pidgin Project's excellent libPurple multi-protocol Instant Messaging wrapper. Buddy lists will come from the accounts defined, and presence will be passed through from the respective protocols.



Example Walk-Through of Architecture

This is all well and good, but how does it actually work?

When the DCE Router is started, it immediately loads all of the router plugins, such as General Info Plugin, Climate Plugin, Lighting Plugin, Telecom Plugin, all the way down to our Instant Messaging Plugin.

Once this plugin is loaded, it will register its event handlers and data grid generators so that by the time the orbiter is loaded, these screens will work.

The Launch Manager will eventually load, as it loads the rest of the devices on the core, the Local House Messaging and libPurple devices.

Once these devices are loaded, they will attempt to do their GetConfig() routines, which, after they've done any connection/housekeeping routines that they need to do, will send events for when a new person is added, and their presence information. These events will be captured by the Instant Messaging Plugin (which registered an Event Interceptor in its Register() function.) which will act upon them, and alter data structures, etc. that will be used by the respective DataGridGenerator functions. This will be used by Orbiter, any time that the data grids are on screen.



Things to implement for Instant Messaging Plugin

The Instant Messaging plugin has commands of its own. These commands are typically sent from the Orbiters, however, they can be sent from anywhere within the system.

Instant Messaging Plugin Commands

  • Send Message - Sending a message to another person.
  • Set Presence - Set presence for all accounts (Online/Offline/Away/DND)

No events need to be registered from the plugin. It doesn't send events as such, but it does intercept events from the Instant Messaging Devices.

Notice that there are no log on/log off... this is done by set presence.



Things to implement for the Instant Messaging Devices

Instant Messaging Device Commands

  • Send Message - Send a message to someone on this transport.
  • Set Presence - Set presence for this transport (online/away/dnd/etc)



Instant Messaging Events

  • Message Recieved - When a message is recieved from this transport
  • Message Transmitted - When a message is transmitted to this transport
  • Buddy Added - Fired when a transport mentions that a buddy has been added, typically at logon.
  • Buddy Deleted - Fired when a transport mentions that a buddy has been removed.
  • Presence Changed - Fired when a buddy's presence changes

More to be written.



Step 2. Filling in the database

Before any code can be generated, the database needs to be filled in and prepared so that the system can potentially know what to expect for the plugin and their appropriate devices.