A plugin dynamically extends the features of the Spark instant messaging client.
Use them to customize Spark for your business or organization or to add an innovative twist to instant messaging. The
extensive plugin API allows for complete client flexibility but is still simple and (we hope!) fun to use.
This guide provides a high level overview of the Plugin API and examples of several common client customizations.
Or, jump directly into the JavaDocs.
The Spark client is designed with the idea that most users find the different aspects of a chat client familiar and easy to use.
All components you see below are either accessible from the Workspace or ChatRoom object and can be manipulated based on your
needs.
The Spark API provides a framework for adding extensions on top of the protocol and/or UI of the Spark client. For example, you could write your own message filter or add a button to a chat room and send files using the File Transfer API. The Spark API has the following characteristics:
Several event listeners to either intercept, be informed of, or execute custom code in response to a particular IM event.
Thorough tie-ins to the UI to allow for customization from simple icon changes, to adding buttons, to adding your own menu items.
Ability to add your own XMPP functions using the SMACK API.
Managers - Managers allow for better (lazy) loading of particular areas within the Spark client as well as providing access points to the system. Some of the more relevant managers are:
SparkManager -- Acts as the central manager for all of Spark. You use this manager to get instances of ChatManager, SessionManager, SoundManager, and UserManager.
ChatManager -- Handles registration of most chat listeners and filters, as well as creation and retrieval of chat rooms. It is also used to retrieve the UI of the ChatFrame.
SessionManager -- Contains the information about the current session, such as the server connected to, the handling of connection errors and notification of personal presence changes.
Event Handlers -- Spark contains numerous listeners and handlers to allow more pluggability into the Spark client. Some of the more common listeners and handlers are:
ChatRoomListener -- Allows the plugin to listen for chat rooms being opened, closed and activated. You would generally use this to customize individual chat rooms.
MessageListener -- Allows for notification when a message has been received or sent.
ContextMenuListener -- Allows for the addition or removal of actions or menu items to right-click (context menu) popups.
PresenceListener -- Allows for notification when Spark presence changes.
ContactItemHandler -- Allows the plugin to control the effects of presence changes within a ContactItem and the associated invoke call.
Components -- Spark contains many Swing components that will regularly be used during the creation of your plugin. Some of the more commonly used components are :
MainWindow -- The frame containing the Contact List. You use MainWindow to add new tabs, menu items, or force focus.
ChatRoom -- The base abstract class of all chat rooms within Spark. Known implementations are ChatRoomImpl and GroupChatRoom.
ChatArea -- The base chat viewer for both the TranscriptWindow and ChatInputEditor.
Then execute Maven command mvn package to create /target/myplugin.jar file.
Installing your Plugin
You only need to drop your newly created jar file into the plugins directory of your Spark client install.
Your plugin class must implement the
Plugin
interface from the Spark Client API. The Plugin interface has
methods for initializing and shutting down the plugin.
Retrieve the WorkspacePane which is the Tabbed Pane used by Spark.
Add your own tab.
How do I add a context menu listener to the contact list?
Implement Plugin.
Retrieve the ContactList which is part of Spark's Workspace.
Add a ContactListListener.
How do I add my own ContextMenu Listener to a ChatRoom
Implement Plugin.
Add a ChatRoomListener to the ChatManager.
Get either the TranscriptWindow or ChatInputEditor from the ChatRoom.
Add a ContactMenuListener to the ChatArea.
How do I add my own Menu to Spark?
Implement Plugin.
Retrieve the MainWindow from SparkManager.
Either create a new Menu or add a MenuItem to one of the pre-existing menus.
How do I add a button to a Chat Room?
Implement Plugin.
Add a ChatRoomListener to ChatManager.
When the room is opened, add your ChatRoomButton to the ToolBar of the ChatRoom.
How do I add my own searching feature in Spark like the User Search or Google Search in Firefox?
Implement Plugin.
Create a searchable object by implementing the Searchable interface.
Add the Searchable implementation to the SearchManager.
How can I intercept a File Transfer request?
Implement Plugin.
Implement TransferListener.
Register your TransferListener.
How can I send a file to another user?
Implement Plugin.
Get the full jid of the user via the UserManager.
Get the SparkTransferManager and send the file.
How can I control the UI and event handling of a ContactItem?
Implement Plugin.
Get the ContactList.
Get a ContactItem(s) based on a user's jid.
Add your own ContactItemHandler to the ContactItem.
How can I be notified when the Spark user changes their presence?
Implement Plugin.
Get the SessionManager from SparkManager.
Add your own PresenceListener to SessionManager.
How can I add a message filter?
Implement Plugin.
Get the ChatManager from SparkManager.
Create an instance of Message Filter.
Register with the ChatManager.
How can I create a person-to-person Chat Room
Implement Plugin.
Get the ChatManager from SparkManager.
Create a new ChatRoom using the ChatManager.
Optionally make it the active ChatRoom using the ChatContainer.
How can I create a public Conference room?
Implement Plugin.
Get the ChatManager from SparkManager.
Create a new conference ChatRoom using the ChatManager.
Optionally make it the active ChatRoom using the ChatContainer.
How can I add my own Preferences?
Implement Plugin.
Create a class that implements Preference.
Create a UI to associate with the Preference.
Register your new Preference with the PreferenceManager.
How to show an alert, like when a new message comes in?
Once I Build It, Then What?
After you've built your amazingly cool plugin, it's easy to rollout to your users.
Just have them drop it in the plugins directory of their Spark installation.
If your plugin is generally useful, we hope you'll share it with the whole Spark community!
To make your plugin
available via the public repository, submit it to
on a forum.