Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.icq
Class ServerStoredContactListIcqImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.protocol.icq.ServerStoredContactListIcqImpl
All Implemented Interfaces:
net.kano.joustsim.oscar.BuddyInfoTrackerListener

public class ServerStoredContactListIcqImpl
extends Object
implements net.kano.joustsim.oscar.BuddyInfoTrackerListener

This class encapsulates the net.kano BuddyList class. Once created, it will register itself as a listener to the encapsulated BuddyList and modify it's local copy of Contacts and ContactGroups every time an event is generated by the underlying joustsim framework. The class would also generate corresponding sip-communicator events to all events coming from joustsim.

Author:
Emil Ivov, Damian Minkov

Constructor Summary
ServerStoredContactListIcqImpl(OperationSetPersistentPresenceIcqImpl parentOperationSet, ProtocolProviderServiceIcqImpl icqProvider)
          Creates a ServerStoredContactList wrapper for the specified BuddyList.
 
Method Summary
 void addContact(ContactGroupIcqImpl parent, String screenname)
          Adds a new contact with the specified screenname to the list under the specified group.
 void addContact(String screenname)
          Adds a new contact with the specified screenname to the list under a default location.
protected  void addContactForUpdate(ContactIcqImpl c)
          when there is no alias for contact we must retreive its nickname from server but when the contact list is loaded the client is not yet registered to server we wait this and then retreive the nicknames
(package private)  void addGroupListener(ServerStoredGroupListener listener)
          Registers the specified group listener so that it would receive events on group modification/creation/destruction.
 void createGroup(String groupName)
          Creates the specified group on the server stored contact list.
(package private)  ContactIcqImpl createUnresolvedContact(ContactGroupIcqImpl parentGroup, net.kano.joustsim.Screenname screenname)
          Creates a non resolved contact for the specified address and inside the specified group.
(package private)  ContactGroupIcqImpl createUnresolvedContactGroup(String groupName)
          Creates a non resolved contact group for the specified name.
(package private)  ContactIcqImpl createVolatileContact(net.kano.joustsim.Screenname screenname)
          Creates a non persistent contact for the specified address.
 ContactIcqImpl findContactByJoustSimBuddy(net.kano.joustsim.oscar.oscar.service.ssi.Buddy buddy)
          Returns the Contact with the specified screenname (or icq UIN) or null if no such screenname was found.
 ContactIcqImpl findContactByScreenName(String screenName)
          Returns the Contact with the specified screenname (or icq UIN) or null if no such screenname was found.
 ContactGroupIcqImpl findContactGroup(ContactIcqImpl child)
          Returns the ContactGroup containing the specified contact or null if no such group or contact exist.
 ContactGroupIcqImpl findContactGroup(net.kano.joustsim.oscar.oscar.service.ssi.Group joustSimGroup)
          Returns the ContactGroup corresponding to the specified joust sim group.
 ContactGroupIcqImpl findContactGroup(String name)
          Returns the ConntactGroup with the specified name or null if no such group was found.
 int findContactGroupIndex(net.kano.joustsim.oscar.oscar.service.ssi.Group joustSimGroup)
          Returns the index of the ContactGroup containing the specified joust sim group.
(package private)  ContactGroupIcqImpl findGroup(net.kano.joustsim.oscar.oscar.service.ssi.Buddy buddy)
           
(package private)  void fireGroupEvent(ContactGroup group, int eventID)
          Creates the corresponding event and notifies all ServerStoredGroupListeners that the source group has been removed, changed, renamed or whatever happened to it.
(package private)  ProtocolProviderServiceIcqImpl getParentProvider()
          Retrns a reference to the provider that created us.
 ContactGroup getRootGroup()
          Returns the root group of the contact list.
(package private)  void init(net.kano.joustsim.oscar.oscar.service.ssi.SsiService joustSimSsiService)
          Sets a reference to the currently active and valid instance of the JoustSIM SsiService that this list is to use for retrieving server stored information
 void moveContact(ContactIcqImpl contact, ContactGroupIcqImpl newParent)
          Moves the specified contact to the group indicated by newParent.
 void removeGroup(ContactGroupIcqImpl groupToRemove)
          Removes the specified group from the icq buddy list.
(package private)  void removeGroupListener(ServerStoredGroupListener listener)
          Removes the specified group listener so that it won't receive further events on group modification/creation/destruction.
 void renameGroup(ContactGroupIcqImpl groupToRename, String newName)
          Renames the specified group according to the specified new name..
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerStoredContactListIcqImpl

ServerStoredContactListIcqImpl(OperationSetPersistentPresenceIcqImpl parentOperationSet,
                               ProtocolProviderServiceIcqImpl icqProvider)
Creates a ServerStoredContactList wrapper for the specified BuddyList.

Parameters:
parentOperationSet - the operation set that created us and that we could use for dispatching subscription events
icqProvider - the icqProvider that has instantiated us.
Method Detail

getRootGroup

public ContactGroup getRootGroup()
Returns the root group of the contact list.

Returns:
the root ContactGroup for the ContactList

addGroupListener

void addGroupListener(ServerStoredGroupListener listener)
Registers the specified group listener so that it would receive events on group modification/creation/destruction.

Parameters:
listener - the ServerStoredGroupListener to register for group events

removeGroupListener

void removeGroupListener(ServerStoredGroupListener listener)
Removes the specified group listener so that it won't receive further events on group modification/creation/destruction.

Parameters:
listener - the ServerStoredGroupListener to unregister

fireGroupEvent

void fireGroupEvent(ContactGroup group,
                    int eventID)
Creates the corresponding event and notifies all ServerStoredGroupListeners that the source group has been removed, changed, renamed or whatever happened to it.

Parameters:
group - the ContactGroup that has been created/modified/removed
eventID - the id of the event to generate.

getParentProvider

ProtocolProviderServiceIcqImpl getParentProvider()
Retrns a reference to the provider that created us.

Returns:
a reference to a ProtocolProviderServiceIcqImpl instance.

findContactGroupIndex

public int findContactGroupIndex(net.kano.joustsim.oscar.oscar.service.ssi.Group joustSimGroup)
Returns the index of the ContactGroup containing the specified joust sim group.

Parameters:
joustSimGroup - the joust sim group we're looking for.
Returns:
the index of the ContactGroup containing the specified joustSimGroup or -1 if no containing ContactGroup exists.

findContactGroup

public ContactGroupIcqImpl findContactGroup(String name)
Returns the ConntactGroup with the specified name or null if no such group was found.

Parameters:
name - the name of the group we're looking for.
Returns:
a reference to the ContactGroupIcqImpl instance we're looking for or null if no such group was found.

findContactGroup

public ContactGroupIcqImpl findContactGroup(net.kano.joustsim.oscar.oscar.service.ssi.Group joustSimGroup)
Returns the ContactGroup corresponding to the specified joust sim group.

Parameters:
joustSimGroup - the joust sim group we're looking for.
Returns:
the ContactGroup corresponding to the specified joustSimGroup null if no containing ContactGroup exists.

findContactByScreenName

public ContactIcqImpl findContactByScreenName(String screenName)
Returns the Contact with the specified screenname (or icq UIN) or null if no such screenname was found.

Parameters:
screenName - the screen name (or ICQ UIN) of the contact to find.
Returns:
the Contact carrying the specified screenName or null if no such contact exits.

findContactByJoustSimBuddy

public ContactIcqImpl findContactByJoustSimBuddy(net.kano.joustsim.oscar.oscar.service.ssi.Buddy buddy)
Returns the Contact with the specified screenname (or icq UIN) or null if no such screenname was found.

Parameters:
buddy - the buddy (or ICQ UIN) of the contact to find.
Returns:
the Contact carrying the specified screenName or null if no such contact exits.

findContactGroup

public ContactGroupIcqImpl findContactGroup(ContactIcqImpl child)
Returns the ContactGroup containing the specified contact or null if no such group or contact exist.

Parameters:
child - the contact whose parent group we're looking for.
Returns:
the ContactGroup containing the specified contact or null if no such groupo or contact exist.

addContact

public void addContact(String screenname)
Adds a new contact with the specified screenname to the list under a default location.

Parameters:
screenname - the screenname or icq uin of the contact to add.

createVolatileContact

ContactIcqImpl createVolatileContact(net.kano.joustsim.Screenname screenname)
Creates a non persistent contact for the specified address. This would also create (if necessary) a group for volatile contacts that would not be added to the server stored contact list. This method would have no effect on the server stored contact list.

Parameters:
screenname - the UIN/Screenname of the contact to create.
Returns:
the newly created volatile ContactIcqImpl

createUnresolvedContact

ContactIcqImpl createUnresolvedContact(ContactGroupIcqImpl parentGroup,
                                       net.kano.joustsim.Screenname screenname)
Creates a non resolved contact for the specified address and inside the specified group. The newly created contact would be added to the local contact list as a standard contact but when an event is received from the server concerning this contact, then it will be reused and only its isResolved field would be updated instead of creating the whole contact again.

Parameters:
parentGroup - the group where the unersolved contact is to be created
screenname - the UIN/Screenname of the contact to create.
Returns:
the newly created unresolved ContactIcqImpl

createUnresolvedContactGroup

ContactGroupIcqImpl createUnresolvedContactGroup(String groupName)
Creates a non resolved contact group for the specified name. The newly created group would be added to the local contact list as any other group but when an event is received from the server concerning this group, then it will be reused and only its isResolved field would be updated instead of creating the whole group again.

Parameters:
groupName - the name of the group to create.
Returns:
the newly created unresolved ContactGroupIcqImpl

addContact

public void addContact(ContactGroupIcqImpl parent,
                       String screenname)
Adds a new contact with the specified screenname to the list under the specified group.

Parameters:
screenname - the screenname or icq uin of the contact to add.
parent - the group under which we want the new contact placed.

createGroup

public void createGroup(String groupName)
Creates the specified group on the server stored contact list.

Parameters:
groupName - a String containing the name of the new group.

removeGroup

public void removeGroup(ContactGroupIcqImpl groupToRemove)
Removes the specified group from the icq buddy list.

Parameters:
groupToRemove - the group that we'd like removed.

renameGroup

public void renameGroup(ContactGroupIcqImpl groupToRename,
                        String newName)
Renames the specified group according to the specified new name..

Parameters:
groupToRename - the group that we'd like removed.
newName - the new name of the group

moveContact

public void moveContact(ContactIcqImpl contact,
                        ContactGroupIcqImpl newParent)
Moves the specified contact to the group indicated by newParent.

Parameters:
contact - the contact that we'd like moved under the new group.
newParent - the group where we'd like the parent placed.

init

void init(net.kano.joustsim.oscar.oscar.service.ssi.SsiService joustSimSsiService)
Sets a reference to the currently active and valid instance of the JoustSIM SsiService that this list is to use for retrieving server stored information

Parameters:
joustSimSsiService - a valid reference to the currently active JoustSIM SsiService.

addContactForUpdate

protected void addContactForUpdate(ContactIcqImpl c)
when there is no alias for contact we must retreive its nickname from server but when the contact list is loaded the client is not yet registered to server we wait this and then retreive the nicknames

Parameters:
c - ContactIcqImpl

findGroup

ContactGroupIcqImpl findGroup(net.kano.joustsim.oscar.oscar.service.ssi.Buddy buddy)

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.