org.olat.instantMessaging
Class SmackInstantMessagingImpl

java.lang.Object
  extended by org.olat.instantMessaging.SmackInstantMessagingImpl
All Implemented Interfaces:
InstantMessaging

public class SmackInstantMessagingImpl
extends java.lang.Object
implements InstantMessaging

Implementation of the InstantMessaging Interface based on the SMACK instant messaging library from jivesoftware.org

Initial Date: 18.01.2005

Author:
guido

Method Summary
 boolean addUserToFriendsRoster(java.lang.String groupOwnerUsername, java.lang.String groupId, java.lang.String groupname, java.lang.String addedUsername)
           
 java.lang.String checkServerPlugin()
          check wheter the server plugin is running and the correct version is
 int countConnectedUsers()
           
 boolean createAccount(java.lang.String username, java.lang.String password, java.lang.String fullname, java.lang.String email)
          creates an account on the instant messaging server
 java.lang.String createChatRoomJID(OLATResourceable ores)
           
 java.lang.String createChatRoomString(OLATResourceable ores)
           
 Controller createClientController(UserRequest ureq, WindowControl wControl)
          This method should only be called once as it creates the main controller and the groupchat controller for a single user
 boolean deleteAccount(java.lang.String username)
          delete an account on the im server
 boolean deleteRosterGroup(java.lang.String groupId)
          Delete roster group from instant messaging server
 void disableChat(java.lang.String username, java.lang.String reason)
          disable the chat and groupchat possibilities
 void enableChat(java.lang.String username)
          enable the chat and groupchat possibilities
 java.util.List<ConnectedUsersListEntry> getAllConnectedUsers(Identity currentUser)
           
 ClientManager getClientManager()
          with the client manager you have access to the IM client for sending messages/presence information
 java.util.Map getClients()
           
 IMConfig getConfig()
          provides access to the IM settings like admin user/password and servername...
 GroupChatManagerController getGroupChatManagerController(UserRequest ureq)
          get the controller for creating and managing groupChats
 java.lang.String getIMPassword(java.lang.String username)
           
 java.lang.String getIMUsername(java.lang.String username)
           
 IMNameHelper getNameHelper()
           
 java.lang.String getUserJid(java.lang.String username)
           
 java.lang.String getUsernameFromJid(java.lang.String jid)
           
 java.util.Set getUsernamesFromConnectedUsers()
           
 boolean hasAccount(java.lang.String username)
          check whether accounts exists on IM server
 boolean removeUserFromFriendsRoster(java.lang.String groupId, java.lang.String username)
           
 boolean renameRosterGroup(java.lang.String groupId, java.lang.String displayName)
          rename roster group on instant messaging server
 void resetAdminConnection()
          reset and reconnect the admin connection to the IM server.
 void sendStatus(java.lang.String username, java.lang.String message)
          send the message to: all members of the VisibilityGroup where 'username' is member.
 void setAccountService(RemoteAccountCreation accountService)
          [used by spring]
 void setActionController(ControllerCreator actionControllerCreator)
          [used by spring]
 void setAdminConnection(AdminUserConnection adminConnection)
          [spring]
 void setBuddyGroupService(InstantMessagingGroupSynchronisation buddyGroupService)
          [used by spring]
 void setClientManager(ClientManager clientManager)
          [used by spring]
 void setClientVersion(java.lang.String clientVersion)
          [spring]
 void setConfig(IMConfig config)
           
 void setNameHelper(IMNameHelper nameHelper)
           
 void setServerPluginVersion(InstantMessagingServerPluginVersion pluginVersion)
           
 void setSessionCountService(InstantMessagingSessionCount sessionCountService)
          [used by spring]
 void setSessionItemsService(InstantMessagingSessionItems sessionItemsService)
          [used by spring]
 boolean synchonizeBuddyRoster(BusinessGroup group)
          called when OLAT server is started and needs to sync the buddygroups with the IM server.
 boolean synchronizeAllBuddyGroupsWithIMServer()
          Synchronize the groups with the IM system To synchronize buddygroups, use the null-context.
 boolean synchronizeLearningGroupsWithIMServer()
          called when OLAT server is started and needs to sync the learinggroups with the IM server.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createClientController

public Controller createClientController(UserRequest ureq,
                                         WindowControl wControl)
Description copied from interface: InstantMessaging
This method should only be called once as it creates the main controller and the groupchat controller for a single user

Specified by:
createClientController in interface InstantMessaging
Returns:
a controller that represents that status changer and the buddy list
See Also:
InstantMessaging.createClientController(org.olat.core.gui.UserRequest, org.olat.core.gui.control.WindowControl)

setActionController

public void setActionController(ControllerCreator actionControllerCreator)
[used by spring]


getGroupChatManagerController

public GroupChatManagerController getGroupChatManagerController(UserRequest ureq)
Description copied from interface: InstantMessaging
get the controller for creating and managing groupChats

Specified by:
getGroupChatManagerController in interface InstantMessaging
Returns:
See Also:
org.olat.instantMessaging.InstantMessaging#getGroupChatManagerController()

addUserToFriendsRoster

public boolean addUserToFriendsRoster(java.lang.String groupOwnerUsername,
                                      java.lang.String groupId,
                                      java.lang.String groupname,
                                      java.lang.String addedUsername)
Specified by:
addUserToFriendsRoster in interface InstantMessaging
See Also:
o_clusterOK by:fj - nodes can access the IM server concurrently but only one thread should add a users to a group at the same time. Sync over whole clazz, not time critical as accessed by backgrounded threads

removeUserFromFriendsRoster

public boolean removeUserFromFriendsRoster(java.lang.String groupId,
                                           java.lang.String username)
Specified by:
removeUserFromFriendsRoster in interface InstantMessaging
username - an OLAT unique username
See Also:
InstantMessaging.removeUserFromFriendsRoster(java.lang.String, java.lang.String)

deleteRosterGroup

public boolean deleteRosterGroup(java.lang.String groupId)
Description copied from interface: InstantMessaging
Delete roster group from instant messaging server

Specified by:
deleteRosterGroup in interface InstantMessaging
See Also:
InstantMessaging.deleteRosterGroup(java.lang.String)

renameRosterGroup

public boolean renameRosterGroup(java.lang.String groupId,
                                 java.lang.String displayName)
Description copied from interface: InstantMessaging
rename roster group on instant messaging server

Specified by:
renameRosterGroup in interface InstantMessaging
Parameters:
groupId -
displayName -

sendStatus

public void sendStatus(java.lang.String username,
                       java.lang.String message)
Description copied from interface: InstantMessaging
send the message to: all members of the VisibilityGroup where 'username' is member.

Specified by:
sendStatus in interface InstantMessaging
Parameters:
username - an OLAT unique username
See Also:
InstantMessaging.sendStatus(java.lang.String, java.lang.String)

createAccount

public boolean createAccount(java.lang.String username,
                             java.lang.String password,
                             java.lang.String fullname,
                             java.lang.String email)
Description copied from interface: InstantMessaging
creates an account on the instant messaging server

Specified by:
createAccount in interface InstantMessaging
Returns:
true if successful
See Also:
org.olat.instantMessaging.InstantMessaging#createAccount(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

deleteAccount

public boolean deleteAccount(java.lang.String username)
Description copied from interface: InstantMessaging
delete an account on the im server

Specified by:
deleteAccount in interface InstantMessaging
See Also:
InstantMessaging.deleteAccount(java.lang.String)

getIMPassword

public java.lang.String getIMPassword(java.lang.String username)
Specified by:
getIMPassword in interface InstantMessaging
Returns:
the instant messaging password (differs form the olat password)
See Also:
InstantMessaging.getIMPassword(java.lang.String)

getUsernamesFromConnectedUsers

public java.util.Set getUsernamesFromConnectedUsers()
Specified by:
getUsernamesFromConnectedUsers in interface InstantMessaging
Returns:
Set containing the usernames

getClients

public java.util.Map getClients()
Specified by:
getClients in interface InstantMessaging
Returns:
Map with client Objects (InstantMessagingClient)
See Also:
InstantMessaging.getClients()

enableChat

public void enableChat(java.lang.String username)
Description copied from interface: InstantMessaging
enable the chat and groupchat possibilities

Specified by:
enableChat in interface InstantMessaging
See Also:
InstantMessaging.enableChat(java.lang.String)

disableChat

public void disableChat(java.lang.String username,
                        java.lang.String reason)
Description copied from interface: InstantMessaging
disable the chat and groupchat possibilities

Specified by:
disableChat in interface InstantMessaging
Parameters:
username -
reason - A resason why the chat is disabled like "Doing test"
See Also:
InstantMessaging.disableChat(java.lang.String, java.lang.String)

countConnectedUsers

public int countConnectedUsers()
Specified by:
countConnectedUsers in interface InstantMessaging
Returns:
number of connected instant messaging users
See Also:
InstantMessaging.countConnectedUsers()

synchonizeBuddyRoster

public boolean synchonizeBuddyRoster(BusinessGroup group)
Description copied from interface: InstantMessaging
called when OLAT server is started and needs to sync the buddygroups with the IM server.

Specified by:
synchonizeBuddyRoster in interface InstantMessaging
See Also:
InstantMessaging.synchonizeBuddyRoster(org.olat.group.BusinessGroup)

synchronizeLearningGroupsWithIMServer

public boolean synchronizeLearningGroupsWithIMServer()
Description copied from interface: InstantMessaging
called when OLAT server is started and needs to sync the learinggroups with the IM server.

Specified by:
synchronizeLearningGroupsWithIMServer in interface InstantMessaging
See Also:
InstantMessaging.synchronizeLearningGroupsWithIMServer()

synchronizeAllBuddyGroupsWithIMServer

public boolean synchronizeAllBuddyGroupsWithIMServer()
Synchronize the groups with the IM system To synchronize buddygroups, use the null-context. Be aware that this action might take some time!

Specified by:
synchronizeAllBuddyGroupsWithIMServer in interface InstantMessaging
Parameters:
groupContext -
Returns:
true if successfull, false if IM server is not running

createChatRoomString

public java.lang.String createChatRoomString(OLATResourceable ores)
Specified by:
createChatRoomString in interface InstantMessaging
Returns:
a String like BusinessGroup-123456
See Also:
org.olat.instantMessaging.InstantMessaging#createChatRoomString(org.olat.core.id.OLATResourceable

createChatRoomJID

public java.lang.String createChatRoomJID(OLATResourceable ores)
Specified by:
createChatRoomJID in interface InstantMessaging
Returns:
a Jabber ID like grouid@conference.jabber.olat.uzh.ch

getAllConnectedUsers

public java.util.List<ConnectedUsersListEntry> getAllConnectedUsers(Identity currentUser)
Specified by:
getAllConnectedUsers in interface InstantMessaging
Returns:
a list with information for each user which is connected to the instant messaging server either locally or clusterwide
See Also:
org.olat.instantMessaging.InstantMessaging#getAllConnectedUsers()

setSessionCountService

public void setSessionCountService(InstantMessagingSessionCount sessionCountService)
[used by spring]

Parameters:
sessionCountService -

setBuddyGroupService

public void setBuddyGroupService(InstantMessagingGroupSynchronisation buddyGroupService)
[used by spring]

Parameters:
sessionCountService -

setSessionItemsService

public void setSessionItemsService(InstantMessagingSessionItems sessionItemsService)
[used by spring]

Parameters:
sessionItemsService -

setAccountService

public void setAccountService(RemoteAccountCreation accountService)
[used by spring]

Parameters:
accountService -

setClientManager

public void setClientManager(ClientManager clientManager)
[used by spring]

Parameters:
clientManager -

getClientManager

public ClientManager getClientManager()
Description copied from interface: InstantMessaging
with the client manager you have access to the IM client for sending messages/presence information

Specified by:
getClientManager in interface InstantMessaging
Returns:
client manager where you have access to the IM client itself

getConfig

public IMConfig getConfig()
Description copied from interface: InstantMessaging
provides access to the IM settings like admin user/password and servername...

Specified by:
getConfig in interface InstantMessaging
Returns:

setConfig

public void setConfig(IMConfig config)

hasAccount

public boolean hasAccount(java.lang.String username)
Description copied from interface: InstantMessaging
check whether accounts exists on IM server

Specified by:
hasAccount in interface InstantMessaging
Returns:
See Also:
InstantMessaging.hasAccount(java.lang.String)

getUserJid

public java.lang.String getUserJid(java.lang.String username)
Specified by:
getUserJid in interface InstantMessaging
Returns:
a jabber id like admin@jabber.olat.uzh.ch
See Also:
InstantMessaging.getUserJid(java.lang.String)

getUsernameFromJid

public java.lang.String getUsernameFromJid(java.lang.String jid)
Specified by:
getUsernameFromJid in interface InstantMessaging
Returns:
only the username part from a jid
See Also:
InstantMessaging.getUsernameFromJid(java.lang.String)

getIMUsername

public java.lang.String getIMUsername(java.lang.String username)
Specified by:
getIMUsername in interface InstantMessaging
Returns:
the username which is save for the IM server and may contains an instance id if IM server is used in a multi domain setup

setNameHelper

public void setNameHelper(IMNameHelper nameHelper)
Specified by:
setNameHelper in interface InstantMessaging

setAdminConnection

public void setAdminConnection(AdminUserConnection adminConnection)
[spring]

Parameters:
adminConnection -

resetAdminConnection

public void resetAdminConnection()
Description copied from interface: InstantMessaging
reset and reconnect the admin connection to the IM server. Upon failures the admin connection reconnects automatically but not on resource conflicts and manual connection close.

Specified by:
resetAdminConnection in interface InstantMessaging
See Also:
InstantMessaging.resetAdminConnection()

setClientVersion

public void setClientVersion(java.lang.String clientVersion)
[spring]

Parameters:
clientVersion -

setServerPluginVersion

public void setServerPluginVersion(InstantMessagingServerPluginVersion pluginVersion)

checkServerPlugin

public java.lang.String checkServerPlugin()
Description copied from interface: InstantMessaging
check wheter the server plugin is running and the correct version is

Specified by:
checkServerPlugin in interface InstantMessaging
Returns:
string with information about the plugin.
See Also:
InstantMessaging.checkServerPlugin()

getNameHelper

public IMNameHelper getNameHelper()
Specified by:
getNameHelper in interface InstantMessaging
Returns:
the IMNameHelper for building multipleinstance-save user/group-names