org.eclipse.ecf.provider.xmpp.container
Class XMPPPresenceSharedObject

java.lang.Object
  extended by org.eclipse.ecf.provider.xmpp.container.XMPPPresenceSharedObject
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable, ISharedObject, IEventHandler, IAccountManager

public class XMPPPresenceSharedObject
extends java.lang.Object
implements ISharedObject, IAccountManager


Field Summary
protected  org.jivesoftware.smack.packet.Message.Type[] ALLOWED_MESSAGES
           
static Trace trace
           
 
Constructor Summary
XMPPPresenceSharedObject()
           
 
Method Summary
protected  void addInvitationListener(IInvitationListener listener)
           
protected  void addMessageListener(IMessageListener listener)
           
protected  void addPresenceListener(IPresenceListener listener)
           
protected  void addSharedObjectMessageListener(ISharedObjectMessageListener listener)
           
protected  void addSubscribeListener(ISubscribeListener listener)
           
protected  java.lang.String canonicalizePresenceFrom(java.lang.String from)
           
 boolean changePassword(java.lang.String newpassword)
          Change account password to use new password.
 boolean createAccount(java.lang.String username, java.lang.String password, java.util.Map attributes)
          Create a new account.
protected  ID createIDFromName(java.lang.String name)
           
protected  IRosterEntry.InterestType createInterestType(org.jivesoftware.smack.packet.RosterPacket.ItemType itemType)
           
protected  IPresence createIPresence(org.jivesoftware.smack.packet.Presence xmppPresence)
           
protected  IPresence.Mode createIPresenceMode(org.jivesoftware.smack.packet.Presence xmppPresence)
           
protected  IPresence.Type createIPresenceType(org.jivesoftware.smack.packet.Presence xmppPresence)
           
protected  IMessageListener.Type createMessageType(org.jivesoftware.smack.packet.Message.Type type)
           
protected  org.jivesoftware.smack.packet.Presence createPresence(IPresence ipresence)
           
protected  org.jivesoftware.smack.packet.Presence.Mode createPresenceMode(IPresence ipresence)
           
protected  org.jivesoftware.smack.packet.Presence.Type createPresenceType(IPresence ipresence)
           
protected  ID createRoomIDFromName(java.lang.String from)
           
protected  IRosterEntry createRosterEntry(org.jivesoftware.smack.RosterEntry entry)
           
protected  IRosterEntry createRosterEntry(org.jivesoftware.smack.packet.RosterPacket.Item entry)
           
protected  IRosterGroup createRosterGroup(org.jivesoftware.smack.RosterGroup grp)
           
protected  IRosterGroup createRosterGroup(java.lang.String grp)
           
protected  ID createUserIDFromName(java.lang.String name)
           
protected  void debug(java.lang.String msg)
           
 boolean deleteAccount()
          Delete an account.
protected  void disconnect()
           
 void dispose(ID containerID)
          Method called by the ISharedObjectContainer upon ISharedObject destruction.
protected  void dumpStack(java.lang.String msg, java.lang.Throwable e)
           
protected  org.jivesoftware.smack.packet.Message filterMessageType(org.jivesoftware.smack.packet.Message msg)
           
protected  void fireContainerDeparted(ID departed)
           
protected  void fireContainerJoined(ID containerJoined)
           
protected  void fireInvitationReceived(ID roomID, ID fromID, ID toID, java.lang.String subject, java.lang.String body)
           
protected  void fireMessage(ID from, ID to, IMessageListener.Type type, java.lang.String subject, java.lang.String body)
           
protected  void firePresence(ID fromID, IPresence presence)
           
protected  void fireRosterEntry(IRosterEntry entry)
           
protected  void fireSetRosterEntry(IRosterEntry entry)
           
protected  void fireSharedObjectMessage(ISharedObjectMessageEvent event)
           
protected  void fireSubscribe(ID fromID, IPresence presence)
           
 java.lang.Object getAccountAttribute(java.lang.String name)
          Get the value of given
 java.lang.String[] getAccountAttributeNames()
          Get account attribute names for this account
 java.lang.String getAccountInstructions()
          Get any instructions for account
 java.lang.Object getAdapter(java.lang.Class clazz)
           
protected  org.jivesoftware.smack.XMPPConnection getConnection()
           
protected  ISharedObjectContext getContext()
           
protected  java.lang.String getUserNameFromXMPPAddress(XMPPID userID)
           
protected  void handleContainerDepartedEvent(IContainerDisconnectedEvent event)
           
protected  void handleDeactivatedEvent(ISharedObjectDeactivatedEvent event)
           
 void handleEvent(Event event)
          Handle Event passed to this ISharedObject.
 void handleEvents(Event[] events)
          Handle Events passed to this ISharedObject.
protected  void handleInvitationEvent(InvitationReceivedEvent event)
           
protected  void handleIQEvent(IQEvent evt)
           
protected  void handleJoin(IContainerConnectedEvent event)
           
protected  void handleMessageEvent(MessageEvent evt)
           
protected  void handlePresenceEvent(PresenceEvent evt)
           
protected  void handleRoster(org.jivesoftware.smack.Roster roster)
           
 void init(ISharedObjectConfig initData)
          Initialize this ISharedObject.
 boolean isAccountCreationSupported()
          Determine whether account creation is supported for this account manager
protected  void removeInvitationListener(IInvitationListener listener)
           
protected  void removeMessageListener(IMessageListener listener)
           
protected  void removePresenceListener(IPresenceListener listener)
           
protected  void removeSharedObjectMessageListener(ISharedObjectMessageListener listener)
           
protected  void removeSubscribeListener(ISubscribeListener listener)
           
protected  void setConnection(org.jivesoftware.smack.XMPPConnection connection)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

trace

public static Trace trace

ALLOWED_MESSAGES

protected org.jivesoftware.smack.packet.Message.Type[] ALLOWED_MESSAGES
Constructor Detail

XMPPPresenceSharedObject

public XMPPPresenceSharedObject()
Method Detail

fireInvitationReceived

protected void fireInvitationReceived(ID roomID,
                                      ID fromID,
                                      ID toID,
                                      java.lang.String subject,
                                      java.lang.String body)

addInvitationListener

protected void addInvitationListener(IInvitationListener listener)

removeInvitationListener

protected void removeInvitationListener(IInvitationListener listener)

addPresenceListener

protected void addPresenceListener(IPresenceListener listener)

removePresenceListener

protected void removePresenceListener(IPresenceListener listener)

addMessageListener

protected void addMessageListener(IMessageListener listener)

removeMessageListener

protected void removeMessageListener(IMessageListener listener)

addSharedObjectMessageListener

protected void addSharedObjectMessageListener(ISharedObjectMessageListener listener)

removeSharedObjectMessageListener

protected void removeSharedObjectMessageListener(ISharedObjectMessageListener listener)

addSubscribeListener

protected void addSubscribeListener(ISubscribeListener listener)

removeSubscribeListener

protected void removeSubscribeListener(ISubscribeListener listener)

canonicalizePresenceFrom

protected java.lang.String canonicalizePresenceFrom(java.lang.String from)

debug

protected void debug(java.lang.String msg)

disconnect

protected void disconnect()

dispose

public void dispose(ID containerID)
Description copied from interface: ISharedObject
Method called by the ISharedObjectContainer upon ISharedObject destruction. Once this method is called, no more Events will be passed to a ISharedObject until the init method is called again.

Specified by:
dispose in interface ISharedObject
Parameters:
containerID - the ID of the container that is disposing this ISharedObject

dumpStack

protected void dumpStack(java.lang.String msg,
                         java.lang.Throwable e)

fireContainerDeparted

protected void fireContainerDeparted(ID departed)

fireContainerJoined

protected void fireContainerJoined(ID containerJoined)

fireMessage

protected void fireMessage(ID from,
                           ID to,
                           IMessageListener.Type type,
                           java.lang.String subject,
                           java.lang.String body)

firePresence

protected void firePresence(ID fromID,
                            IPresence presence)

fireSubscribe

protected void fireSubscribe(ID fromID,
                             IPresence presence)

fireSetRosterEntry

protected void fireSetRosterEntry(IRosterEntry entry)

fireRosterEntry

protected void fireRosterEntry(IRosterEntry entry)

fireSharedObjectMessage

protected void fireSharedObjectMessage(ISharedObjectMessageEvent event)

getAdapter

public java.lang.Object getAdapter(java.lang.Class clazz)
Specified by:
getAdapter in interface org.eclipse.core.runtime.IAdaptable

getConnection

protected org.jivesoftware.smack.XMPPConnection getConnection()

getContext

protected ISharedObjectContext getContext()

getUserNameFromXMPPAddress

protected java.lang.String getUserNameFromXMPPAddress(XMPPID userID)

handleContainerDepartedEvent

protected void handleContainerDepartedEvent(IContainerDisconnectedEvent event)

handleDeactivatedEvent

protected void handleDeactivatedEvent(ISharedObjectDeactivatedEvent event)

handleEvent

public void handleEvent(Event event)
Description copied from interface: IEventHandler
Handle Event passed to this ISharedObject. The ISharedObjectContainer will pass events to all SharedObjects via this method and the handleEvents method.

Specified by:
handleEvent in interface IEventHandler
Parameters:
event - the Event for the ISharedObject to handle

createRoomIDFromName

protected ID createRoomIDFromName(java.lang.String from)

createUserIDFromName

protected ID createUserIDFromName(java.lang.String name)

handleInvitationEvent

protected void handleInvitationEvent(InvitationReceivedEvent event)

handleEvents

public void handleEvents(Event[] events)
Description copied from interface: IEventHandler
Handle Events passed to this ISharedObject. The ISharedObjectContainer will pass events to all SharedObjects via this method and the handleEvents method.

Specified by:
handleEvents in interface IEventHandler
Parameters:
events - the Events [] for the ISharedObject to handle

handleIQEvent

protected void handleIQEvent(IQEvent evt)

handleJoin

protected void handleJoin(IContainerConnectedEvent event)

filterMessageType

protected org.jivesoftware.smack.packet.Message filterMessageType(org.jivesoftware.smack.packet.Message msg)

handleMessageEvent

protected void handleMessageEvent(MessageEvent evt)

handlePresenceEvent

protected void handlePresenceEvent(PresenceEvent evt)

handleRoster

protected void handleRoster(org.jivesoftware.smack.Roster roster)

init

public void init(ISharedObjectConfig initData)
          throws SharedObjectInitException
Description copied from interface: ISharedObject
Initialize this ISharedObject. The ISharedObjectContainer for this ISharedObject must call this method with a non-null instance of ISharedObjectConfig. ISharedObject implementations can use this initialization to perform any initialization necessary prior to receiving any events (via handleEvent/s). Note that the ISharedObjectContext provided via the ISharedObjectConfig.getSharedObjectContext() method is not guaranteed to allow any method calls until after this init() method call has completed.

Specified by:
init in interface ISharedObject
Parameters:
initData - the initialization data passed by the ISharedObjectContainer upon initialization
Throws:
SharedObjectInitException - thrown by ISharedObject to halt initialization. ISharedObjectContainers must respond to such an exception by halting the addition of the ISharedObject instance and treating it as not in the container.

createIDFromName

protected ID createIDFromName(java.lang.String name)

createInterestType

protected IRosterEntry.InterestType createInterestType(org.jivesoftware.smack.packet.RosterPacket.ItemType itemType)

createMessageType

protected IMessageListener.Type createMessageType(org.jivesoftware.smack.packet.Message.Type type)

createIPresence

protected IPresence createIPresence(org.jivesoftware.smack.packet.Presence xmppPresence)

createPresence

protected org.jivesoftware.smack.packet.Presence createPresence(IPresence ipresence)

createIPresenceMode

protected IPresence.Mode createIPresenceMode(org.jivesoftware.smack.packet.Presence xmppPresence)

createPresenceMode

protected org.jivesoftware.smack.packet.Presence.Mode createPresenceMode(IPresence ipresence)

createIPresenceType

protected IPresence.Type createIPresenceType(org.jivesoftware.smack.packet.Presence xmppPresence)

createPresenceType

protected org.jivesoftware.smack.packet.Presence.Type createPresenceType(IPresence ipresence)

createRosterEntry

protected IRosterEntry createRosterEntry(org.jivesoftware.smack.RosterEntry entry)

createRosterEntry

protected IRosterEntry createRosterEntry(org.jivesoftware.smack.packet.RosterPacket.Item entry)

createRosterGroup

protected IRosterGroup createRosterGroup(org.jivesoftware.smack.RosterGroup grp)

createRosterGroup

protected IRosterGroup createRosterGroup(java.lang.String grp)

setConnection

protected void setConnection(org.jivesoftware.smack.XMPPConnection connection)

changePassword

public boolean changePassword(java.lang.String newpassword)
                       throws ECFException
Description copied from interface: IAccountManager
Change account password to use new password. Upon next authenticated login, new password will be required for accessing account

Specified by:
changePassword in interface IAccountManager
Parameters:
newpassword - new password to use for this account
Returns:
true if password changed, false if not changed
Throws:
ECFException - thrown if not connected, or if password change fails due to network failure or server failure

createAccount

public boolean createAccount(java.lang.String username,
                             java.lang.String password,
                             java.util.Map attributes)
                      throws ECFException
Description copied from interface: IAccountManager
Create a new account. Create a new account using given username, password, and attributes. If account creation succeeds, the method will return successfully. If fails, or is not supported, ECFException will be thrown

Specified by:
createAccount in interface IAccountManager
Parameters:
username - the fully qualified username to use for the new account
password - the password to use with the new account
attributes - attributes to associate with the new account
Returns:
true if account created, false if not created
Throws:
ECFException - thrown if account creation is not supported, or if fails for some reason (network failure or server failure)

deleteAccount

public boolean deleteAccount()
                      throws ECFException
Description copied from interface: IAccountManager
Delete an account. Deletes this account. If successful deletion, the method will return successfully. If account deletion is not supported, network failure, or some server error then an ECFException will be thrown.

Specified by:
deleteAccount in interface IAccountManager
Returns:
true if account deleted, false if not deleted
Throws:
ECFException - thrown if account deletion is not supported, or if fails for some reason (network failure or server failure)

getAccountInstructions

public java.lang.String getAccountInstructions()
Description copied from interface: IAccountManager
Get any instructions for account

Specified by:
getAccountInstructions in interface IAccountManager
Returns:
instructions for account

getAccountAttributeNames

public java.lang.String[] getAccountAttributeNames()
Description copied from interface: IAccountManager
Get account attribute names for this account

Specified by:
getAccountAttributeNames in interface IAccountManager
Returns:
String[] attribute names. Will return empty array if no attribute names for account.

getAccountAttribute

public java.lang.Object getAccountAttribute(java.lang.String name)
Description copied from interface: IAccountManager
Get the value of given

Specified by:
getAccountAttribute in interface IAccountManager
Parameters:
name - the attribute name to return the value for
Returns:
Object value for the given attribute

isAccountCreationSupported

public boolean isAccountCreationSupported()
Description copied from interface: IAccountManager
Determine whether account creation is supported for this account manager

Specified by:
isAccountCreationSupported in interface IAccountManager
Returns:
true if account creation supported, false otherwise