public class MetaContactListServiceImpl extends java.lang.Object implements MetaContactListService, org.osgi.framework.ServiceListener, ContactPresenceStatusListener, ContactCapabilitiesListener
Modifier and Type | Field and Description |
---|---|
static int |
CONTACT_LIST_MODIFICATION_TIMEOUT
The number of milliseconds to wait for confirmations of account
modifications before deciding to drop.
|
(package private) MetaContactGroupImpl |
rootMetaGroup
The root of the meta contact list.
|
PROVIDER_MASK_PROPERTY
Constructor and Description |
---|
MetaContactListServiceImpl()
Creates an instance of this class.
|
Modifier and Type | Method and Description |
---|---|
void |
addMetaContactListListener(MetaContactListListener listener)
Adds a listener for MetaContactListChangeEvents posted after
the tree changes.
|
void |
addNewContactToMetaContact(ProtocolProviderService provider,
MetaContact metaContact,
java.lang.String contactID)
First makes the specified protocol provider create the contact as
indicated by contactID, and then associates it to the
_existing_ metaContact given as an argument.
|
void |
addNewContactToMetaContact(ProtocolProviderService provider,
MetaContact metaContact,
java.lang.String contactID,
boolean fireEvent)
First makes the specified protocol provider create the contact as
indicated by contactID, and then associates it to the
_existing_ metaContact given as an argument.
|
void |
changeMetaContactAvatar(MetaContact metaContact,
Contact protoContact,
byte[] newAvatar)
Sets the avatar for metaContact to be newAvatar.
|
void |
clearUserDefinedDisplayName(MetaContact metaContact)
Resets display name of the MetaContact to show the value from
the underlying contacts.
|
void |
contactPresenceStatusChanged(ContactPresenceStatusChangeEvent evt)
Upon each status notification this method finds the corresponding meta
contact and updates the ordering in its parent group.
|
MetaContact |
createMetaContact(ProtocolProviderService provider,
MetaContactGroup metaContactGroup,
java.lang.String contactID)
First makes the specified protocol provider create a contact
corresponding to the specified contactID, then creates a new
MetaContact which will encapsulate the newly created protocol specific
contact.
|
MetaContactGroup |
createMetaContactGroup(MetaContactGroup parent,
java.lang.String groupName)
Creates a MetaContactGroup with the specified group name.
|
java.util.Iterator<MetaContact> |
findAllMetaContactsForAddress(java.lang.String contactAddress)
Returns a list of all MetaContacts containing a protocol contact
corresponding to the given contactAddress string.
|
java.util.Iterator<MetaContact> |
findAllMetaContactsForProvider(ProtocolProviderService protocolProvider)
Returns a list of all MetaContacts containing a protocol contact
from the given ProtocolProviderService.
|
java.util.Iterator<MetaContact> |
findAllMetaContactsForProvider(ProtocolProviderService protocolProvider,
MetaContactGroup metaContactGroup)
Returns a list of all MetaContacts contained in the given group
and containing a protocol contact from the given
ProtocolProviderService.
|
MetaContact |
findMetaContactByContact(Contact contact)
Returns the MetaContact containing the specified contact or null if no
such MetaContact was found.
|
MetaContact |
findMetaContactByContact(java.lang.String contactAddress,
java.lang.String accountID)
Returns the MetaContact containing a contact with an address equal to
contactAddress and with a source provider matching
accountID, or null if no such MetaContact was found.
|
MetaContact |
findMetaContactByMetaUID(java.lang.String metaContactID)
Returns the MetaContact that corresponds to the specified metaContactID.
|
MetaContactGroup |
findMetaContactGroupByContactGroup(ContactGroup contactGroup)
Returns the MetaContactGroup corresponding to the specified contactGroup
or null if no such MetaContactGroup was found.
|
MetaContactGroup |
findMetaContactGroupByMetaUID(java.lang.String metaGroupID)
Returns the MetaContactGroup that corresponds to the specified
metaGroupID.
|
MetaContactGroup |
findParentMetaContactGroup(MetaContact child)
Returns the meta contact group that is a direct parent of the specified
child.
|
MetaContactGroup |
findParentMetaContactGroup(MetaContactGroup child)
Returns the meta contact group that is a direct parent of the specified
child.
|
(package private) void |
fireMetaContactEvent(MetaContactPropertyChangeEvent event)
Creates the corresponding MetaContactPropertyChangeEvent
instance and notifies all MetaContactListListeners that a
MetaContact has been modified.
|
MetaContactGroup |
getRoot()
Returns the root MetaContactGroup in this contact list.
|
(package private) ContactGroup |
loadStoredContactGroup(MetaContactGroupImpl containingMetaGroup,
java.lang.String contactGroupUID,
ContactGroup parentProtoGroup,
java.lang.String persistentData,
java.lang.String accountID)
Creates a unresolved instance of the proto specific contact group
according to the specified arguments and adds it to
containingMetaContactGroup
|
(package private) MetaContactImpl |
loadStoredMetaContact(MetaContactGroupImpl parentGroup,
java.lang.String metaUID,
java.lang.String displayName,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> details,
java.util.List<MclStorageManager.StoredProtoContactDescriptor> protoContacts,
java.lang.String accountID)
The method is called from the storage manager whenever a new contact
has been parsed and it has to be created.
|
(package private) MetaContactGroupImpl |
loadStoredMetaContactGroup(MetaContactGroupImpl parentGroup,
java.lang.String metaContactGroupUID,
java.lang.String displayName)
The method is called from the storage manager whenever a new contact
group has been parsed and it has to be created.
|
void |
moveContact(Contact contact,
MetaContact newParentMetaContact)
Makes the specified contact a child of the newParent
MetaContact.
|
void |
moveContact(Contact contact,
MetaContactGroup newParentMetaGroup)
Makes the specified contact a child of the
newParentMetaGroup MetaContactGroup.
|
void |
moveMetaContact(MetaContact metaContact,
MetaContactGroup newMetaGroup)
Moves the specified MetaContact to newGroup.
|
void |
purgeLocallyStoredContactListCopy()
Removes local resources storing copies of the meta contact list.
|
void |
removeContact(Contact contact)
Deletes the specified contact from both the local contact list and (if
applicable) the server stored contact list if supported by the
corresponding protocol.
|
void |
removeContactGroupFromMetaContactGroup(MetaContactGroupImpl metaContainer,
ContactGroup groupToRemove,
ProtocolProviderService sourceProvider)
Removes the protocol specific group from the specified meta contact group
and removes from meta contacts all proto contacts that belong to the
same provider as the group which is being removed.
|
void |
removeMetaContact(MetaContact metaContact)
Removes the specified metaContact as well as all of its
underlying contacts.
|
void |
removeMetaContactGroup(MetaContactGroup groupToRemove)
Removes the specified meta contact group, all its corresponding protocol
specific groups and all their children.
|
void |
removeMetaContactListListener(MetaContactListListener listener)
Removes a listener previously added with addContactListListener.
|
void |
renameMetaContact(MetaContact metaContact,
java.lang.String newDisplayName)
Sets the display name for metaContact to be newName.
|
void |
renameMetaContactGroup(MetaContactGroup group,
java.lang.String newGroupName)
Renames the specified MetaContactGroup as indicated by the
newName param.
|
void |
serviceChanged(org.osgi.framework.ServiceEvent event)
Implements the ServiceListener method.
|
void |
start(org.osgi.framework.BundleContext bc)
Starts this implementation of the MetaContactListService.
|
void |
stop(org.osgi.framework.BundleContext bc)
Prepares the meta contact list service for shutdown.
|
void |
supportedOperationSetsChanged(ContactCapabilitiesEvent event)
Notifies this listener that the list of the OperationSet
capabilities of a Contact has changed.
|
final MetaContactGroupImpl rootMetaGroup
public static final int CONTACT_LIST_MODIFICATION_TIMEOUT
public MetaContactListServiceImpl()
public void start(org.osgi.framework.BundleContext bc)
2) The only provide non persistent implementations of OperationSetPresence, the meta contact list impl would create subscriptions for all local contacts in the corresponding protocol provider.
This implementation would also start listening for any newly registered protocol provider implementations and perform the same algorithm with them.
bc
- the currently valid OSGI bundle context.public void stop(org.osgi.framework.BundleContext bc)
bc
- the currently active bundle context.public void addMetaContactListListener(MetaContactListListener listener)
addMetaContactListListener
in interface MetaContactListService
listener
- the listener to addpublic void addNewContactToMetaContact(ProtocolProviderService provider, MetaContact metaContact, java.lang.String contactID) throws MetaContactListException
addNewContactToMetaContact
in interface MetaContactListService
provider
- the ProtocolProviderService that should create the contact
indicated by contactID.metaContact
- the meta contact where that the newly created contact should
be associated to.contactID
- the identifier of the contact that the specified providerMetaContactListException
- with an appropriate code if the operation fails for some
reason.public void addNewContactToMetaContact(ProtocolProviderService provider, MetaContact metaContact, java.lang.String contactID, boolean fireEvent) throws MetaContactListException
provider
- the ProtocolProviderService that should create the contact
indicated by contactID.metaContact
- the meta contact where that the newly created contact should
be associated to.contactID
- the identifier of the contact that the specified providerfireEvent
- specifies whether or not an even is to be fire at
the end of the method.Used when this method is called upon creation of a
new meta contact and not only a new contact.MetaContactListException
- with an appropriate code if the operation fails for some
reason.public MetaContactGroup findParentMetaContactGroup(MetaContactGroup child)
findParentMetaContactGroup
in interface MetaContactListService
child
- the MetaContactGroup whose parent group we're
looking for. If no parent is found null is returned.public MetaContactGroup findParentMetaContactGroup(MetaContact child)
findParentMetaContactGroup
in interface MetaContactListService
child
- the MetaContact whose parent group we're looking
for.java.lang.IllegalArgumentException
- if child is not an instance of
MetaContactImplpublic MetaContact createMetaContact(ProtocolProviderService provider, MetaContactGroup metaContactGroup, java.lang.String contactID) throws MetaContactListException
createMetaContact
in interface MetaContactListService
provider
- a ref to ProtocolProviderService instance which
will create the actual protocol specific contact.metaContactGroup
- the MetaContactGroup where the newly created meta contact
should be stored.contactID
- a protocol specific string identifier indicating the contact
the protocol provider should create.MetaContactListException
- with an appropriate code if the operation fails for some
reason.public MetaContactGroup createMetaContactGroup(MetaContactGroup parent, java.lang.String groupName) throws MetaContactListException
createMetaContactGroup
in interface MetaContactListService
parent
- the meta contact group inside which the new child group must
be created.groupName
- the name of the MetaContactGroup to create.MetaContactListException
- with an appropriate code if the operation fails for some
reason.public void renameMetaContactGroup(MetaContactGroup group, java.lang.String newGroupName)
renameMetaContactGroup
in interface MetaContactListService
group
- the group to rename.newGroupName
- the new name of the MetaContactGroup to
rename.public MetaContactGroup getRoot()
getRoot
in interface MetaContactListService
public void renameMetaContact(MetaContact metaContact, java.lang.String newDisplayName) throws java.lang.IllegalArgumentException
renameMetaContact
in interface MetaContactListService
metaContact
- the MetaContact that we are renamingnewDisplayName
- a String containing the new display name
for metaContact.java.lang.IllegalArgumentException
- if metaContact is not an
instance that belongs to the underlying implementation.public void clearUserDefinedDisplayName(MetaContact metaContact) throws java.lang.IllegalArgumentException
clearUserDefinedDisplayName
in interface MetaContactListService
metaContact
- the MetaContact that we are operating onjava.lang.IllegalArgumentException
- if metaContact is not an
instance that belongs to the underlying implementation.public void changeMetaContactAvatar(MetaContact metaContact, Contact protoContact, byte[] newAvatar) throws java.lang.IllegalArgumentException
metaContact
- the MetaContact that change avatarprotoContact
- the Contact> that change avatarnewAvatar
- avatar image bytesjava.lang.IllegalArgumentException
- if metaContact is not an
instance that belongs to the underlying implementation.public void moveContact(Contact contact, MetaContactGroup newParentMetaGroup) throws MetaContactListException
moveContact
in interface MetaContactListService
contact
- the Contact to move to thenewParentMetaGroup
- the MetaContactGroup where we'd like contact to
be moved.MetaContactListException
- with an appropriate code if the
operation fails for some reason.public void moveContact(Contact contact, MetaContact newParentMetaContact) throws MetaContactListException
moveContact
in interface MetaContactListService
contact
- the Contact to move to thenewParentMetaContact
- the MetaContact where we'd like contact to be moved.MetaContactListException
- with an appropriate code if the operation fails for some
reason.public void moveMetaContact(MetaContact metaContact, MetaContactGroup newMetaGroup) throws MetaContactListException, java.lang.IllegalArgumentException
moveMetaContact
in interface MetaContactListService
metaContact
- the MetaContact to move.newMetaGroup
- the MetaContactGroup that should be the new parent
of contact.MetaContactListException
- with an appropriate code if the operation fails for some
reason.java.lang.IllegalArgumentException
- if newMetaGroup or
metaCOntact do not come from this implementation.public void removeContact(Contact contact) throws MetaContactListException
removeContact
in interface MetaContactListService
contact
- the contact to remove.MetaContactListException
- with an appropriate code if the
operation fails for some reason.public void removeMetaContactListListener(MetaContactListListener listener)
removeMetaContactListListener
in interface MetaContactListService
listener
- the listener to removepublic void removeMetaContact(MetaContact metaContact) throws MetaContactListException
removeMetaContact
in interface MetaContactListService
metaContact
- the metaContact to remove.MetaContactListException
- with an appropriate code if the operation fails for some
reason.public void removeMetaContactGroup(MetaContactGroup groupToRemove) throws MetaContactListException
removeMetaContactGroup
in interface MetaContactListService
groupToRemove
- the MetaContactGroup to have removed.MetaContactListException
- with an appropriate code if the operation fails for some
reason.public void removeContactGroupFromMetaContactGroup(MetaContactGroupImpl metaContainer, ContactGroup groupToRemove, ProtocolProviderService sourceProvider)
metaContainer
- the MetaContactGroup that we'd like to remove a
contact group from.groupToRemove
- the ContactGroup that we'd like removed.sourceProvider
- the ProtocolProvider that the contact group belongs
to.public void purgeLocallyStoredContactListCopy()
purgeLocallyStoredContactListCopy
in interface MetaContactListService
public MetaContactGroup findMetaContactGroupByContactGroup(ContactGroup contactGroup)
findMetaContactGroupByContactGroup
in interface MetaContactListService
contactGroup
- the protocol specific contactGroup that we're looking
for.public MetaContact findMetaContactByContact(Contact contact)
findMetaContactByContact
in interface MetaContactListService
contact
- the protocol specific contact that we're looking
for.public MetaContact findMetaContactByContact(java.lang.String contactAddress, java.lang.String accountID)
contactAddress
- the address of the protocol specific
contact that we're looking for.accountID
- the ID of the account that the contact we're looking for
must belong to.public MetaContact findMetaContactByMetaUID(java.lang.String metaContactID)
findMetaContactByMetaUID
in interface MetaContactListService
metaContactID
- a String identifier of a meta contact.public MetaContactGroup findMetaContactGroupByMetaUID(java.lang.String metaGroupID)
findMetaContactGroupByMetaUID
in interface MetaContactListService
metaGroupID
- a String identifier of a meta contact group.public java.util.Iterator<MetaContact> findAllMetaContactsForProvider(ProtocolProviderService protocolProvider)
findAllMetaContactsForProvider
in interface MetaContactListService
protocolProvider
- the ProtocolProviderService whose
contacts we're looking for.public java.util.Iterator<MetaContact> findAllMetaContactsForProvider(ProtocolProviderService protocolProvider, MetaContactGroup metaContactGroup)
findAllMetaContactsForProvider
in interface MetaContactListService
protocolProvider
- the ProtocolProviderService whose
contacts we're looking for.metaContactGroup
- the parent group.public java.util.Iterator<MetaContact> findAllMetaContactsForAddress(java.lang.String contactAddress)
findAllMetaContactsForAddress
in interface MetaContactListService
contactAddress
- the contact address for which we're looking for
a parent MetaContact.public void serviceChanged(org.osgi.framework.ServiceEvent event)
serviceChanged
in interface org.osgi.framework.ServiceListener
event
- The ServiceEvent object.void fireMetaContactEvent(MetaContactPropertyChangeEvent event)
event
- the event to dispatch.public void contactPresenceStatusChanged(ContactPresenceStatusChangeEvent evt)
contactPresenceStatusChanged
in interface ContactPresenceStatusListener
evt
- the ContactPresenceStatusChangeEvent describing the status
change.MetaContactGroupImpl loadStoredMetaContactGroup(MetaContactGroupImpl parentGroup, java.lang.String metaContactGroupUID, java.lang.String displayName)
parentGroup
- the group that contains the meta contact group we're
about to load.metaContactGroupUID
- the unique identifier of the meta contact
group.displayName
- the name of the meta contact group.ContactGroup loadStoredContactGroup(MetaContactGroupImpl containingMetaGroup, java.lang.String contactGroupUID, ContactGroup parentProtoGroup, java.lang.String persistentData, java.lang.String accountID)
containingMetaGroup
- the MetaContactGroupImpl where the
restored contact group should be added.contactGroupUID
- the unique identifier of the group.parentProtoGroup
- the identifier of the parent proto group.persistentData
- the persistent data last returned by the contact
group.accountID
- the ID of the account that the proto group belongs to.MetaContactImpl loadStoredMetaContact(MetaContactGroupImpl parentGroup, java.lang.String metaUID, java.lang.String displayName, java.util.Map<java.lang.String,java.util.List<java.lang.String>> details, java.util.List<MclStorageManager.StoredProtoContactDescriptor> protoContacts, java.lang.String accountID)
parentGroup
- the group that contains the meta contact we're about
to load.metaUID
- the unique identifier of the meta contact.displayName
- the display name of the meta contact.details
- the details for the contact to create.protoContacts
- a list containing descriptors of proto contacts
encapsulated by the meta contact that we're about to create.accountID
- the identifier of the account that the contacts
originate from.public void supportedOperationSetsChanged(ContactCapabilitiesEvent event)
supportedOperationSetsChanged
in interface ContactCapabilitiesListener
event
- a ContactCapabilitiesEvent with ID
ContactCapabilitiesEvent.SUPPORTED_OPERATION_SETS_CHANGED
which
specifies the Contact whose list of OperationSet
capabilities has changed
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.