com.realtime.xmpp.dom
Class DomXmppTool

java.lang.Object
  |
  +--com.realtime.xmpp.dom.DomXmppTool
All Implemented Interfaces:
AccountTool, PresenceTool, RosterTool, XmppTool

public class DomXmppTool
extends java.lang.Object
implements XmppTool

Helper methods for DOM Jabber components.

Version:
1.0 Copyright © 2002 Real Time Entertainment Group, LLC - All rights reserved.
Author:
Mike Prince

Nested Class Summary
protected  class DomXmppTool.RosterUpdater
          Callback object to update rosters.
 
Field Summary
protected  DomComponent m_component
          The component to use to communicate with Jabber.
 
Constructor Summary
DomXmppTool(DomComponent component)
          Create a set of tools to work with the named component.
 
Method Summary
 void conveyPresence(JID principal, JID contact)
          Convey the presence information of the principal JID by sending info to the contact.
 XmppError createAccount(JID account, java.lang.String sPassword)
          Create a new account with the given account name and password.
 void forceSubscribed(JID principal, JID contact)
          Convey the presence information of the principal JID by sending info to the contact.
protected  boolean hasContact(org.dom4j.Element roster, JID contact, java.lang.String sGroupTail, java.lang.String sSubscription)
          Check to see if a roster contains a contact in a group.
protected static XmppError interpretResult(org.dom4j.Element response)
          Figure out the result from an XMPP packet.
 XmppError rosterAdd(JID account, JID contact, java.lang.String sContactNick, java.lang.String sSubscription, java.lang.String sGroup, java.lang.String sGroupTail)
          Insert a new contact into a roster.
 XmppError rosterRemove(JID principal, JID contact, java.lang.String sGroup, boolean bTail)
          Remove a contact from an accounts roster.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_component

protected DomComponent m_component
The component to use to communicate with Jabber.

Constructor Detail

DomXmppTool

public DomXmppTool(DomComponent component)

Create a set of tools to work with the named component.

Parameters:
component - The component to use to communicate with the jabber server.
Method Detail

conveyPresence

public void conveyPresence(JID principal,
                           JID contact)
                    throws java.io.IOException

Convey the presence information of the principal JID by sending info to the contact.

Specified by:
conveyPresence in interface PresenceTool
Parameters:
principal - The user with presence info to send.
contact - The recipient of the presence info.
java.io.IOException

forceSubscribed

public void forceSubscribed(JID principal,
                            JID contact)
                     throws java.io.IOException

Convey the presence information of the principal JID by sending info to the contact.

Parameters:
principal - The user with presence info to send.
contact - The recipient of the presence info.
java.io.IOException

rosterAdd

public XmppError rosterAdd(JID account,
                           JID contact,
                           java.lang.String sContactNick,
                           java.lang.String sSubscription,
                           java.lang.String sGroup,
                           java.lang.String sGroupTail)
                    throws java.io.IOException

Insert a new contact into a roster.

Specified by:
rosterAdd in interface RosterTool
Parameters:
account - The account to add the roster item to. * @param contact The Jabber id of the new contact. * @param sContactNick The contacts nick name.
sSubscription - The type of subscription. If this is 'none', then no subscription has been agreed to. If this is 'both', then both parties are assumed to have agreed to a subscription.
sGroup - If this is not null, then the contact will be assigned to a group. NOTE that if a group tail is provided, it will be added to the finished group name.
sGroupTail - If this is not null, then it will be used to locate the matching group. * @return An XmppError, or null for success.
contact - The Jabber id of the new contact.
sContactNick - The contacts nick name.
Returns:
An XmppError, or null for success.
Throws:
java.io.IOException - Generated when the session fails.

hasContact

protected boolean hasContact(org.dom4j.Element roster,
                             JID contact,
                             java.lang.String sGroupTail,
                             java.lang.String sSubscription)

Check to see if a roster contains a contact in a group.

Parameters:
roster - The roster to evaluate. * @param contact The contact to look for. * @param sGroupTail The ending of the group name.
sSubscription - The subscription type that must be there. * @return True if the contact is already in the list, false otherwise.

rosterRemove

public XmppError rosterRemove(JID principal,
                              JID contact,
                              java.lang.String sGroup,
                              boolean bTail)
                       throws java.io.IOException

Remove a contact from an accounts roster.

* @param principal The account to remove the contact from. * @param contact The contact to remove. * @param sGroup The full, or tail portion of the group name.

Specified by:
rosterRemove in interface RosterTool
Parameters:
bTail - If true, the group name is just the tail. * @return An XmppError, or null for success.
principal - The account to remove the contact from.
contact - The contact to remove.
sGroup - The full, or tail portion of the group name.
Returns:
An XmppError, or null for success.
Throws:
java.io.IOException - Generated when the session fails.

createAccount

public XmppError createAccount(JID account,
                               java.lang.String sPassword)
                        throws java.io.IOException

Create a new account with the given account name and password.

* @param comp The component to create the account with. * @param account The full account name, including the name of this host. * @param sPassword the new password. * @return An XmppError code, or null for success. * @throws IOException Generated by problems communicating with the Jabber server.

Specified by:
createAccount in interface AccountTool
Parameters:
account - The full account name, including the name of this host.
sPassword - the new password.
Returns:
An XmppError code, or null for success.
Throws:
java.io.IOException - Generated by problems communicating with the Jabber server.

interpretResult

protected static XmppError interpretResult(org.dom4j.Element response)

Figure out the result from an XMPP packet. Was there an error code?

* @param response The packet to interpret. * @return An XMPP error code, or null for no error.



Copyright © 2002,2003 Real Time Entertainment Group, LLC. All Rights Reserved.