Class IMTemplate

  extended by sunlabs.brazil.template.Template
      extended by sunlabs.brazil.xmpp.IMTemplate (view source)
All Implemented Interfaces:

public class IMTemplate
extends Template

XMPP client template. (Incomplete - still under construction.) This uses the SMACK library at: It has been tested with version 3.0.4.

Nested Class Summary
 class IMTemplate.MessageRelay
          Listen for XMP packets, turn the results into name/value pairs, and forward the "map" to the proper Queue.
Field Summary
static String[] vcardFields
Constructor Summary
Method Summary
static void main(String[] args)
          command line interface?.
 void tag_im(RewriteContext hr)
           <im command=login id=xx server=xx user=xx pass=xx [host=xx port=nn prepend=xxx] [subscribe=reject|decide] [qid=xx] > Log into an XMPP server.
Methods inherited from class sunlabs.brazil.template.Template
done, init
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


public static final String[] vcardFields
Constructor Detail


public IMTemplate()
Method Detail


public void tag_im(RewriteContext hr)
<im command=login id=xx server=xx user=xx pass=xx [host=xx port=nn prepend=xxx] [subscribe=reject|decide] [qid=xx] >
Log into an XMPP server. "host" and "port" are only required when the values implied by the "server" attribute are not correct. "id" is an arbirary identifier used to identify this session. It must be used with all other "im" commands, and is also the name of the Queue used to receive messages from. If "subscribe" is specified, it indicates the buddy subscription mode, which defaults to automatic. If "decide" is used, then it is up to the client to accept or reject subscriptions. (The default is to accept all subscriptions).

The value of "qid" can be used to override the Q name, allowing multiple accounts (id) to be used with the same Q (qid).

<im command=logout id=xx>
Log out of this session. Any entries in the Queue remain.
<im command=message id=xx to=xxx body=xxx [thread=xxx]>
Send a message to another user (e.g.
<im command=presence id=xx [mode=available|away|chat|dnd|xa type=available|unavailable|subscribe|subscribed|unsubscribe|unsubscribed body=xxx to=xxx]>
Send presence information.
If type is "available", meaning the client is accepting messages, the mode specifies the client's presence status. (defaults to "available")
This sets the message type. "available", and "unavailable" are used to indicate the client state, which is "available" if the client is connected (even if the "mode" is unavailable), and "unavailable" if they are disconnected. "available" is the default.

The other types are for managing subscriptions:
- subscribe: request a subscription ("to" is required)
- subscribed: grant a subscription request
- unsubscribe: request subscription removal ("to" is required)
- unsubscribed: grant a subscription removal request, or reject a subscription request.

The presence message (for type=available)
<im command=getroster id=xx [prepend=xx]>
Retrieve your buddy list (roster in smack-speak).
<im command=addroster id=xx user=xx [name=xx groups="g1 g2..."]>
Add a buddy to the buddy list, in the specified groups. Groups are created as-needed.
<im command=deluser id=xx user=xx>
Remove a buddy from the buddy list.
<im command=vcard id=xx [user=xx prepend=xx]>
Retrieve VCARD information. If "user" isn' specified, then the currently logged-in user's vCard is returned.
<dequeue name=[qid] .....>
This is used to retrieve messages from the XMPP system, using the QueueTemplate. "name" is should be the value of "qid", if specified, or "id" otherwise. Each dequeued item is a dictionary of name/value pairs describing the event.

The following entries are always present:

  • host: The host this connection is connected to
  • conID: The internal connection id
  • id: The "id" identifier for this connection
  • user: The user connected to this host
  • sender: The sender of this packet
  • xml: The raw XMPP XML markup for this packet.
  • category: presence|message|roster
Other entries may be present, depending on the "category", including: "type", "body", "thread", and "subject" for Message packets, lists of "type", "status", "name", and "user" entries for roster packets, and lists of "body", "priority", "type", and "state" entries for presence packets. Inspect the set of dequeued properties for a complete list.


public static void main(String[] args)
                 throws Exception
command line interface?. user pass server [host port]


Version Kenai-svn-r24, Generated 08/18/09
Copyright (c) 2001-2009, Sun Microsystems.