net.sourceforge.jxa
Class Jxa

java.lang.Object
  extended by java.lang.Thread
      extended by net.sourceforge.jxa.Jxa
All Implemented Interfaces:
java.lang.Runnable

public class Jxa
extends java.lang.Thread

J2ME XMPP API Class

Since:
1.0

Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Jxa(java.lang.String host, java.lang.String port, java.lang.String username, java.lang.String password, java.lang.String resource, int priority)
          If you create this object all variables will be saved and the method run() is started to log in on jabber server and listen to parse incomming xml stanzas.
 
Method Summary
 void addListener(XmppListener xl)
          Add a XmppListener to listen for events.
 void getRoster()
          Sends a roster query.
 void login()
          Opens the connection with a stream-tag, queries authentication type and sends authentication data, which is username, password and resource.
 void logoff()
          Closes the stream-tag and the XmlWriter.
 void removeListener(XmppListener xl)
          Remove a XmppListener from this class.
 void run()
          The run method is called when Jxa object is created.
 void saveContact(java.lang.String jid, java.lang.String name, java.util.Enumeration group, java.lang.String subscription)
          Save a contact to roster.
 void sendMessage(java.lang.String to, java.lang.String msg)
          Sends a message text to a known jid.
 void sendThinkRequest(java.lang.String to, java.lang.String from, java.lang.String pic, java.lang.String thinkword)
          This methods sends a ThinkRequest from the initiator to the recipient
 void sendThinkRespond(java.lang.String to, java.lang.String from, java.lang.String word1, java.lang.String word2, java.lang.String word3)
          This message is used by the recipient to send a response to the initiator of the ThinkRequest
 void setStatus(java.lang.String show, java.lang.String status, int priority)
          Sets your Jabber Status.
 void subscribe(java.lang.String to)
          Requesting a subscription.
 void subscribed(java.lang.String to)
          Approve a subscription request.
 void unsubscribe(java.lang.String to)
          Remove a subscription.
 void unsubscribed(java.lang.String to)
          Refuse/Reject a subscription request.
 
Methods inherited from class java.lang.Thread
activeCount, currentThread, getName, getPriority, interrupt, isAlive, join, setPriority, sleep, start, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Jxa

public Jxa(java.lang.String host,
           java.lang.String port,
           java.lang.String username,
           java.lang.String password,
           java.lang.String resource,
           int priority)
If you create this object all variables will be saved and the method run() is started to log in on jabber server and listen to parse incomming xml stanzas. Use addListener(XmppListener xl) to listen to events of this object.

Parameters:
host - the hostname/ip of the jabber server
port - the port number of the jabber server
username - the username of the jabber account
password - the passwort of the jabber account
resource - a unique identifier of the used resource, for e.g. "mobile"
priority - the priority of the jabber session, defines on which resource the messages arrive
Method Detail

run

public void run()
The run method is called when Jxa object is created. It sets up the reader and writer, calls login() methode and listens on the reader to parse incomming xml stanzas.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

addListener

public void addListener(XmppListener xl)
Add a XmppListener to listen for events.

Parameters:
xl - a XmppListener object

removeListener

public void removeListener(XmppListener xl)
Remove a XmppListener from this class.

Parameters:
xl - a XmppListener object

login

public void login()
           throws java.io.IOException
Opens the connection with a stream-tag, queries authentication type and sends authentication data, which is username, password and resource.

Throws:
java.io.IOException - is thrown if XmlReader or XmlWriter throw an IOException.

logoff

public void logoff()
Closes the stream-tag and the XmlWriter.


sendMessage

public void sendMessage(java.lang.String to,
                        java.lang.String msg)
Sends a message text to a known jid.

Parameters:
to - the JID of the recipient
msg - the message itself

setStatus

public void setStatus(java.lang.String show,
                      java.lang.String status,
                      int priority)
Sets your Jabber Status.

Parameters:
show - is one of the following: null, chat, away, dnd, xa, invisible
status - an extended text describing the actual status
priority - the priority number (5 should be default)

subscribe

public void subscribe(java.lang.String to)
Requesting a subscription.

Parameters:
to - the jid you want to subscribe

unsubscribe

public void unsubscribe(java.lang.String to)
Remove a subscription.

Parameters:
to - the jid you want to remove your subscription

subscribed

public void subscribed(java.lang.String to)
Approve a subscription request.

Parameters:
to - the jid that sent you a subscription request

unsubscribed

public void unsubscribed(java.lang.String to)
Refuse/Reject a subscription request.

Parameters:
to - the jid that sent you a subscription request

saveContact

public void saveContact(java.lang.String jid,
                        java.lang.String name,
                        java.util.Enumeration group,
                        java.lang.String subscription)
Save a contact to roster. This means, a message is send to jabber server (which hosts your roster) to update the roster.

Parameters:
jid - the jid of the contact
name - the nickname of the contact
group - the group of the contact
subscription - the subscription of the contact

getRoster

public void getRoster()
               throws java.io.IOException
Sends a roster query.

Throws:
java.io.IOException - is thrown if XmlReader or XmlWriter throw an IOException.

sendThinkRequest

public void sendThinkRequest(java.lang.String to,
                             java.lang.String from,
                             java.lang.String pic,
                             java.lang.String thinkword)
                      throws java.io.IOException
This methods sends a ThinkRequest from the initiator to the recipient

Parameters:
to - the address of the recipient
from - the address of the initiator
pic - the picture represented as a Base64 encoded string
thinkword - TheWord
Throws:
java.io.IOException - in case of sending failure

sendThinkRespond

public void sendThinkRespond(java.lang.String to,
                             java.lang.String from,
                             java.lang.String word1,
                             java.lang.String word2,
                             java.lang.String word3)
                      throws java.io.IOException
This message is used by the recipient to send a response to the initiator of the ThinkRequest

Parameters:
to - address of initiator
from - address of recipiont
word1 - .
word2 - .
word3 - .
Throws:
java.io.IOException - on problems sending