Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.sip
Class ServerStoredContactList

java.lang.Object
  extended by net.java.sip.communicator.impl.protocol.sip.ServerStoredContactList
Direct Known Subclasses:
ServerStoredContactListSipImpl, ServerStoredContactListXivoImpl

public abstract class ServerStoredContactList
extends Object

The parent server stored contact list used in OperationSetPresenceSipImpl the underling implementation like xcap one extend it with actual contact list modifications.

Author:
Damian Minkov

Field Summary
protected  OperationSetPresenceSipImpl parentOperationSet
          The operation set that created us and that we could use when dispatching subscription events.
protected static String ROOT_GROUP_NAME
          Root group name.
protected  ContactGroupSipImpl rootGroup
          The root contact group.
protected  ProtocolProviderServiceSipImpl sipProvider
          The provider that is on top of us.
 
Constructor Summary
ServerStoredContactList(ProtocolProviderServiceSipImpl sipProvider, OperationSetPresenceSipImpl parentOperationSet)
          Creates a ServerStoredContactList wrapper for the specified BuddyList.
 
Method Summary
 void addGroupListener(ServerStoredGroupListener listener)
          Registers the specified group listener so that it would receive events on group modification/creation/destruction.
abstract  void authorizationAccepted(ContactSipImpl contact)
          The user accepted authorization request for contact
abstract  void authorizationIgnored(ContactSipImpl contact)
          The user ignored authorization request for contact
abstract  void authorizationRejected(ContactSipImpl contact)
          The user rejected authorization request for contact
 ContactSipImpl createContact(ContactGroupSipImpl parentGroup, String contactId, boolean persistent, String contactType)
          Creates contact for the specified address and inside the specified group .
abstract  ContactSipImpl createContact(ContactGroupSipImpl parentGroup, String contactId, String displayName, boolean persistent, String contactType)
          Creates contact for the specified address and inside the specified group .
abstract  ContactGroupSipImpl createGroup(ContactGroupSipImpl parentGroup, String groupName, boolean persistent)
          Creates a group with the specified name and parent in the server stored contact list.
 ContactSipImpl createUnresolvedContact(ContactGroupSipImpl parentGroup, String contactId, String persistentData)
          Creates a non resolved contact for the specified address and inside the specified group.
 ContactGroupSipImpl createUnresolvedContactGroup(ContactGroupSipImpl parentGroup, String groupName)
          Creates a non resolved contact group for the specified name.
abstract  void deleteAccountImage()
          Deletes current account image from server.
abstract  void destroy()
          Destroys the server stored list.
protected  void fireContactAdded(ContactGroupSipImpl parentGroup, ContactSipImpl contact)
          Make the parent persistent presence operation set dispatch a contact added event.
protected  void fireContactMoved(ContactGroupSipImpl oldParentGroup, ContactGroupSipImpl newParentGroup, ContactSipImpl contact)
          Make the parent persistent presence operation set dispatch a subscription moved event.
protected  void fireContactRemoved(ContactGroupSipImpl parentGroup, ContactSipImpl contact)
          Make the parent persistent presence operation set dispatch a contact removed event.
protected  void fireContactResolved(ContactGroupSipImpl parentGroup, ContactSipImpl contact)
          Make the parent persistent presence operation set dispatch a contact resolved event.
protected  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.
abstract  ServerStoredDetails.ImageDetail getAccountImage()
          Get current account image from server if any.
 List<ContactSipImpl> getAllContacts(ContactGroupSipImpl group)
          Returns all avaliable contacts from group and all subgroups.
 List<ContactGroupSipImpl> getAllGroups(ContactGroupSipImpl group)
          Returns all avaliable groups from group and all subgroups.
abstract  byte[] getImage(URI imageUri)
          Gets image from the specified uri.
abstract  URI getImageUri()
          Gets the pres-content image uri.
 ContactGroupSipImpl getRootGroup()
          Returns the root group of the contact list.
 List<ContactSipImpl> getUniqueContacts(ContactGroupSipImpl group)
          Gets all unique contacts from group and all subgroups.
abstract  void init()
          Initializes the server stored list.
abstract  boolean isAccountImageSupported()
          Whether current contact list supports account image.
abstract  void moveContactToGroup(ContactSipImpl contact, ContactGroupSipImpl newParentGroup)
          Removes the specified contact from its current parent and places it under newParent.
abstract  void removeContact(ContactSipImpl contact)
          Removes a contact.
abstract  void removeGroup(ContactGroupSipImpl group)
          Removes the specified group from the server stored contact list.
 void removeGroupListener(ServerStoredGroupListener listener)
          Removes the specified group listener so that it won't receive further events on group modification/creation/destruction.
abstract  void renameContact(ContactSipImpl contact, String newName)
          Renames the specified contact.
abstract  void renameGroup(ContactGroupSipImpl group, String newName)
          Renames the specified group from the server stored contact list.
abstract  void setAccountImage(byte[] newImageBytes)
          Change the image of the account on server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROOT_GROUP_NAME

protected static final String ROOT_GROUP_NAME
Root group name.

See Also:
Constant Field Values

sipProvider

protected final ProtocolProviderServiceSipImpl sipProvider
The provider that is on top of us.


parentOperationSet

protected final OperationSetPresenceSipImpl parentOperationSet
The operation set that created us and that we could use when dispatching subscription events.


rootGroup

protected final ContactGroupSipImpl rootGroup
The root contact group. The container for all SIP contacts and groups.

Constructor Detail

ServerStoredContactList

ServerStoredContactList(ProtocolProviderServiceSipImpl sipProvider,
                        OperationSetPresenceSipImpl parentOperationSet)
Creates a ServerStoredContactList wrapper for the specified BuddyList.

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

getRootGroup

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

Returns:
the root ContactGroup for the ContactList.

addGroupListener

public 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

public 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

protected 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.

createUnresolvedContact

public ContactSipImpl createUnresolvedContact(ContactGroupSipImpl parentGroup,
                                              String contactId,
                                              String persistentData)
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. If creation is successfull event will be fired.

Parameters:
parentGroup - the group where the unersolved contact is to be created.
contactId - the sip id of the contact to create.
persistentData - a String returned Contact's getPersistentData() method during a previous run and that has been persistently stored locally.
Returns:
the newly created unresolved ContactSipImpl.

createUnresolvedContactGroup

public ContactGroupSipImpl createUnresolvedContactGroup(ContactGroupSipImpl parentGroup,
                                                        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:
parentGroup - the group under which the new group is to be created.
groupName - the name of the group to create.
Returns:
the newly created unresolved ContactGroupSipImpl.

fireContactAdded

protected void fireContactAdded(ContactGroupSipImpl parentGroup,
                                ContactSipImpl contact)
Make the parent persistent presence operation set dispatch a contact added event.

Parameters:
parentGroup - the group where the new contact was added.
contact - the contact that was added.

fireContactMoved

protected void fireContactMoved(ContactGroupSipImpl oldParentGroup,
                                ContactGroupSipImpl newParentGroup,
                                ContactSipImpl contact)
Make the parent persistent presence operation set dispatch a subscription moved event.

Parameters:
oldParentGroup - the group where the source contact was located before being moved.
newParentGroup - the group that the source contact is currently in.
contact - the contact that was added.

fireContactRemoved

protected void fireContactRemoved(ContactGroupSipImpl parentGroup,
                                  ContactSipImpl contact)
Make the parent persistent presence operation set dispatch a contact removed event.

Parameters:
parentGroup - the group where that the removed contact belonged to.
contact - the contact that was removed.

fireContactResolved

protected void fireContactResolved(ContactGroupSipImpl parentGroup,
                                   ContactSipImpl contact)
Make the parent persistent presence operation set dispatch a contact resolved event.

Parameters:
parentGroup - the group that the resolved contact belongs to.
contact - the contact that was resolved.

getUniqueContacts

public List<ContactSipImpl> getUniqueContacts(ContactGroupSipImpl group)
Gets all unique contacts from group and all subgroups.

Parameters:
group - the parent of the contacts.
Returns:
List of available contacts

getAllContacts

public List<ContactSipImpl> getAllContacts(ContactGroupSipImpl group)
Returns all avaliable contacts from group and all subgroups.

Parameters:
group - the parent of the contacts.
Returns:
the list of availcable contacts.

getAllGroups

public List<ContactGroupSipImpl> getAllGroups(ContactGroupSipImpl group)
Returns all avaliable groups from group and all subgroups.

Parameters:
group - the parent of the contacts.
Returns:
the list of availcable groups.

init

public abstract void init()
Initializes the server stored list. Synchronize server stored groups and contacts with the local groups and contacts.


destroy

public abstract void destroy()
Destroys the server stored list.


getImageUri

public abstract URI getImageUri()
Gets the pres-content image uri.

Returns:
the pres-content image uri.
Throws:
IllegalStateException - if the user has not been connected.

getImage

public abstract byte[] getImage(URI imageUri)
Gets image from the specified uri.

Parameters:
imageUri - the image uri.
Returns:
the image.

createGroup

public abstract ContactGroupSipImpl createGroup(ContactGroupSipImpl parentGroup,
                                                String groupName,
                                                boolean persistent)
                                         throws OperationFailedException
Creates a group with the specified name and parent in the server stored contact list.

Parameters:
parentGroup - the group where the new group should be created.
groupName - the name of the new group to create.
persistent - specify whether created contact is persistent ot not.
Returns:
the newly created ContactGroupSipImpl.
Throws:
OperationFailedException - with code NETWORK_FAILURE if creating the group fails because of XCAP server error or with code CONTACT_GROUP_ALREADY_EXISTS if contact group with such name already exists.

renameGroup

public abstract void renameGroup(ContactGroupSipImpl group,
                                 String newName)
Renames the specified group from the server stored contact list.

Parameters:
group - the group to rename.
newName - the new name of the group.

moveContactToGroup

public abstract void moveContactToGroup(ContactSipImpl contact,
                                        ContactGroupSipImpl newParentGroup)
                                 throws OperationFailedException
Removes the specified contact from its current parent and places it under newParent.

Parameters:
contact - the Contact to move
newParentGroup - the ContactGroup where Contact would be placed.
Throws:
OperationFailedException - with code NETWORK_FAILURE if the operation if failed during network communication.

removeGroup

public abstract void removeGroup(ContactGroupSipImpl group)
Removes the specified group from the server stored contact list.

Parameters:
group - the group to delete.

createContact

public ContactSipImpl createContact(ContactGroupSipImpl parentGroup,
                                    String contactId,
                                    boolean persistent,
                                    String contactType)
                             throws OperationFailedException
Creates contact for the specified address and inside the specified group . If creation is successfull event will be fired.

Parameters:
parentGroup - the group where the unersolved contact is to be created.
contactId - the sip id of the contact to create.
persistent - specify whether created contact is persistent ot not.
contactType - the contact type to create, if missing null.
Returns:
the newly created ContactSipImpl.
Throws:
OperationFailedException - with code NETWORK_FAILURE if the operation if failed during network communication.

createContact

public abstract ContactSipImpl createContact(ContactGroupSipImpl parentGroup,
                                             String contactId,
                                             String displayName,
                                             boolean persistent,
                                             String contactType)
                                      throws OperationFailedException
Creates contact for the specified address and inside the specified group . If creation is successfull event will be fired.

Parameters:
parentGroup - the group where the unersolved contact is to be created.
contactId - the sip id of the contact to create.
displayName - the display name of the contact to create
persistent - specify whether created contact is persistent ot not.
contactType - the contact type to create, if missing null.
Returns:
the newly created ContactSipImpl.
Throws:
OperationFailedException - with code NETWORK_FAILURE if the operation if failed during network communication.

removeContact

public abstract void removeContact(ContactSipImpl contact)
                            throws OperationFailedException
Removes a contact. If creation is successful event will be fired.

Parameters:
contact - contact to be removed.
Throws:
OperationFailedException - with code NETWORK_FAILURE if the operation if failed during network communication.

renameContact

public abstract void renameContact(ContactSipImpl contact,
                                   String newName)
Renames the specified contact.

Parameters:
contact - the contact to be renamed.
newName - the new contact name.
Throws:
OperationFailedException - with code NETWORK_FAILURE if the operation if failed during network communication.

authorizationAccepted

public abstract void authorizationAccepted(ContactSipImpl contact)
The user accepted authorization request for contact

Parameters:
contact - the user has accepted.

authorizationRejected

public abstract void authorizationRejected(ContactSipImpl contact)
The user rejected authorization request for contact

Parameters:
contact - the user has rejected.

authorizationIgnored

public abstract void authorizationIgnored(ContactSipImpl contact)
The user ignored authorization request for contact

Parameters:
contact - the user has ignored.

isAccountImageSupported

public abstract boolean isAccountImageSupported()
Whether current contact list supports account image.

Returns:
does current contact list supports account image.

getAccountImage

public abstract ServerStoredDetails.ImageDetail getAccountImage()
                                                         throws OperationFailedException
Get current account image from server if any.

Returns:
the account image.
Throws:
OperationFailedException

deleteAccountImage

public abstract void deleteAccountImage()
                                 throws OperationFailedException
Deletes current account image from server.

Throws:
OperationFailedException

setAccountImage

public abstract void setAccountImage(byte[] newImageBytes)
                              throws OperationFailedException
Change the image of the account on server.

Parameters:
newImageBytes - the new image.
Throws:
OperationFailedException

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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