Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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

java.lang.Object
  extended by net.java.sip.communicator.impl.protocol.sip.ServerStoredContactList
      extended by net.java.sip.communicator.impl.protocol.sip.ServerStoredContactListSipImpl

public class ServerStoredContactListSipImpl
extends ServerStoredContactList

Encapsulates XCapClient, it's responsible for generate corresponding events to all action that are made with XCAP contacts and groups.

Author:
Grigorii Balutsel

Field Summary
static String PRES_CONTENT_IMAGE_NAME
          Presence content for image.
static String XCAP_ENABLE
          The name of the property under which the user may specify whether to use or not XCAP.
static String XCAP_PASSWORD
          The name of the property under which the user may specify the XCAP user password.
static String XCAP_SERVER_URI
          The name of the property under which the user may specify the XCAP server uri.
static String XCAP_USE_SIP_CREDETIALS
          The name of the property under which the user may specify whether to use original sip credentials for the XCAP.
static String XCAP_USER
          The name of the property under which the user may specify the XCAP user.
 
Fields inherited from class net.java.sip.communicator.impl.protocol.sip.ServerStoredContactList
parentOperationSet, ROOT_GROUP_NAME, rootGroup, sipProvider
 
Constructor Summary
ServerStoredContactListSipImpl(ProtocolProviderServiceSipImpl sipProvider, OperationSetPresenceSipImpl parentOperationSet)
          Creates a ServerStoredContactList wrapper for the specified BuddyList.
 
Method Summary
(package private)  boolean addContactToBlockList(ContactSipImpl contact)
          Adds contact to the "block" rule.
(package private)  boolean addContactToPoliteBlockList(ContactSipImpl contact)
          Adds contact to the "polite block" rule.
(package private)  boolean addContactToWhiteList(ContactSipImpl contact)
          Adds contact to the "white" rule.
 void authorizationAccepted(ContactSipImpl contact)
          The user accepted authorization request for contact
 void authorizationIgnored(ContactSipImpl contact)
          The user ignored authorization request for contact
 void authorizationRejected(ContactSipImpl contact)
          The user rejected authorization request for contact
 ContactSipImpl createContact(ContactGroupSipImpl parentGroup, String contactId, String displayName, boolean persistent, String contactType)
          Creates contact for the specified address and inside the specified group .
 ContactGroupSipImpl createGroup(ContactGroupSipImpl parentGroup, String groupName, boolean persistent)
          Creates a group with the specified name and parent in the server stored contact list.
 void deleteAccountImage()
          Deletes current account image from server.
 void destroy()
          Destroys the server stored list.
 ServerStoredDetails.ImageDetail getAccountImage()
          Get current account image from server if any.
 String getContactType(Contact contact)
          Access the contact type.
 byte[] getImage(URI imageUri)
          Gets image from the specified uri.
 URI getImageUri()
          Gets the pres-content image uri.
 void init()
          Initializes the server stored list.
 boolean isAccountImageSupported()
          Whether current contact list supports account image.
 void moveContactToGroup(ContactSipImpl contact, ContactGroupSipImpl newParentGroup)
          Removes the specified contact from its current parent and places it under newParent.
 void removeContact(ContactSipImpl contact)
          Removes a contact.
(package private)  boolean removeContactFromBlockList(ContactSipImpl contact)
          Removes contact from the "block" rule.
(package private)  boolean removeContactFromPoliteBlockList(ContactSipImpl contact)
          Removes contact from the "polite block" rule.
(package private)  boolean removeContactFromWhiteList(ContactSipImpl contact)
          Removes contact from the "white" rule.
 void removeGroup(ContactGroupSipImpl group)
          Removes the specified group from the server stored contact list.
 void renameContact(ContactSipImpl contact, String newName)
          Renames the specified contact.
 void renameGroup(ContactGroupSipImpl group, String newName)
          Renames the specified group from the server stored contact list.
 void setAccountImage(byte[] newImageBytes)
          Change the image of the account on server.
 void setContactType(Contact contact, String contactType)
          Sets the contact type of the contact.
(package private)  void updatePresRules()
          Puts pres-rules to the server.
(package private)  void updateResourceLists()
          Puts resource-lists to the server.
 
Methods inherited from class net.java.sip.communicator.impl.protocol.sip.ServerStoredContactList
addGroupListener, createContact, createUnresolvedContact, createUnresolvedContactGroup, fireContactAdded, fireContactMoved, fireContactRemoved, fireContactResolved, fireGroupEvent, getAllContacts, getAllGroups, getRootGroup, getUniqueContacts, removeGroupListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XCAP_ENABLE

public static final String XCAP_ENABLE
The name of the property under which the user may specify whether to use or not XCAP.

See Also:
Constant Field Values

XCAP_USE_SIP_CREDETIALS

public static final String XCAP_USE_SIP_CREDETIALS
The name of the property under which the user may specify whether to use original sip credentials for the XCAP.

See Also:
Constant Field Values

XCAP_SERVER_URI

public static final String XCAP_SERVER_URI
The name of the property under which the user may specify the XCAP server uri.

See Also:
Constant Field Values

XCAP_USER

public static final String XCAP_USER
The name of the property under which the user may specify the XCAP user.

See Also:
Constant Field Values

XCAP_PASSWORD

public static final String XCAP_PASSWORD
The name of the property under which the user may specify the XCAP user password.

See Also:
Constant Field Values

PRES_CONTENT_IMAGE_NAME

public static final String PRES_CONTENT_IMAGE_NAME
Presence content for image.

See Also:
Constant Field Values
Constructor Detail

ServerStoredContactListSipImpl

ServerStoredContactListSipImpl(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

createContact

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

Specified by:
createContact in class ServerStoredContactList
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 void removeContact(ContactSipImpl contact)
                   throws OperationFailedException
Removes a contact. If creation is successfull event will be fired.

Specified by:
removeContact in class ServerStoredContactList
Parameters:
contact - contact to be removed.
Throws:
OperationFailedException - with code NETWORK_FAILURE if the operation if failed during network communication.

moveContactToGroup

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

Specified by:
moveContactToGroup in class ServerStoredContactList
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.

renameContact

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

Specified by:
renameContact in class ServerStoredContactList
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.

createGroup

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

Specified by:
createGroup in class ServerStoredContactList
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.

removeGroup

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

Specified by:
removeGroup in class ServerStoredContactList
Parameters:
group - the group to delete.

renameGroup

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

Specified by:
renameGroup in class ServerStoredContactList
Parameters:
group - the group to rename.
newName - the new name of the group.

init

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

Specified by:
init in class ServerStoredContactList

getImageUri

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

Specified by:
getImageUri in class ServerStoredContactList
Returns:
the pres-content image uri.
Throws:
IllegalStateException - if the user has not been connected.

getImage

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

Specified by:
getImage in class ServerStoredContactList
Parameters:
imageUri - the image uri.
Returns:
the image.

destroy

public void destroy()
Destroys the server stored list.

Specified by:
destroy in class ServerStoredContactList

addContactToWhiteList

boolean addContactToWhiteList(ContactSipImpl contact)
                        throws XCapException
Adds contact to the "white" rule.

Parameters:
contact - the contact to add.
Returns:
true if present rules were updated, false otherwise.
Throws:
XCapException

addContactToBlockList

boolean addContactToBlockList(ContactSipImpl contact)
                        throws XCapException
Adds contact to the "block" rule.

Parameters:
contact - the contact to add.
Throws:
XCapException

addContactToPoliteBlockList

boolean addContactToPoliteBlockList(ContactSipImpl contact)
                              throws XCapException
Adds contact to the "polite block" rule.

Parameters:
contact - the contact to add.
Throws:
XCapException

removeContactFromWhiteList

boolean removeContactFromWhiteList(ContactSipImpl contact)
                             throws XCapException
Removes contact from the "white" rule.

Parameters:
contact - the contact to remove.
Returns:
true if present rules were updated, false otherwise.
Throws:
XCapException

removeContactFromBlockList

boolean removeContactFromBlockList(ContactSipImpl contact)
                             throws XCapException
Removes contact from the "block" rule.

Parameters:
contact - the contact to remove.
Returns:
true if present rules were updated, false otherwise.
Throws:
XCapException

removeContactFromPoliteBlockList

boolean removeContactFromPoliteBlockList(ContactSipImpl contact)
                                   throws XCapException
Removes contact from the "polite block" rule.

Parameters:
contact - the contact to remove.
Returns:
true if present rules were updated, false otherwise.
Throws:
XCapException

updateResourceLists

void updateResourceLists()
                   throws XCapException
Puts resource-lists to the server.

Throws:
XCapException - if there is some error during operation.

updatePresRules

void updatePresRules()
               throws XCapException
Puts pres-rules to the server.

Throws:
XCapException - if there is some error during operation.

authorizationAccepted

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

Specified by:
authorizationAccepted in class ServerStoredContactList
Parameters:
contact - the user has accepted.

authorizationRejected

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

Specified by:
authorizationRejected in class ServerStoredContactList
Parameters:
contact - the user has rejected.

authorizationIgnored

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

Specified by:
authorizationIgnored in class ServerStoredContactList
Parameters:
contact - the user has ignored.

getAccountImage

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

Specified by:
getAccountImage in class ServerStoredContactList
Returns:
the account image content.
Throws:
OperationFailedException

deleteAccountImage

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

Specified by:
deleteAccountImage in class ServerStoredContactList
Throws:
OperationFailedException

isAccountImageSupported

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

Specified by:
isAccountImageSupported in class ServerStoredContactList
Returns:
does current contact list supports account image.

setAccountImage

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

Specified by:
setAccountImage in class ServerStoredContactList
Parameters:
newImageBytes - the new image.
Throws:
OperationFailedException

getContactType

public String getContactType(Contact contact)
Access the contact type. If none specified null is returned.

Parameters:
contact - the contact to be queried for type.
Returns:
the contact type or null if missing.

setContactType

public void setContactType(Contact contact,
                           String contactType)
Sets the contact type of the contact.

Parameters:
contact - the contact to be changed.
contactType - the type set to the contact.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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