public class OperationSetPresenceSipImpl extends AbstractOperationSetPersistentPresence<ProtocolProviderServiceSipImpl> implements MethodProcessor, RegistrationStateChangeListener
parentProvider
Constructor and Description |
---|
OperationSetPresenceSipImpl(ProtocolProviderServiceSipImpl provider,
boolean presenceEnabled,
boolean forceP2PMode,
int pollingPeriod,
int subscriptionExpiration)
Creates an instance of this operation set keeping a reference to the
specified parent provider.
|
Modifier and Type | Method and Description |
---|---|
void |
addServerStoredGroupChangeListener(ServerStoredGroupListener listener)
Registers a listener that would receive events upong changes in server
stored groups.
|
(package private) java.lang.String |
convertDocument(org.w3c.dom.Document document)
Convert a xml document
|
(package private) org.w3c.dom.Document |
convertDocument(java.lang.String document)
Convert a xml document
|
(package private) org.w3c.dom.Document |
createDocument()
Returns a new valid xml document.
|
void |
createServerStoredContactGroup(ContactGroup parentGroup,
java.lang.String groupName)
Creates a group with the specified name and parent in the server
stored contact list.
|
Contact |
createUnresolvedContact(java.lang.String address,
java.lang.String persistentData)
Creates and returns a unresolved contact from the specified
address and persistentData.
|
Contact |
createUnresolvedContact(java.lang.String contactId,
java.lang.String persistentData,
ContactGroup parent)
Creates and returns a unresolved contact from the specified
address and persistentData.
|
ContactGroup |
createUnresolvedContactGroup(java.lang.String groupUID,
java.lang.String persistentData,
ContactGroup parentGroup)
Creates and returns a unresolved contact group from the specified
address and persistentData.
|
ContactSipImpl |
createVolatileContact(java.lang.String contactAddress)
Creates a non persistent contact for the specified address.
|
ContactSipImpl |
createVolatileContact(java.lang.String contactAddress,
java.lang.String displayName)
Creates a non persistent contact for the specified address.
|
ContactSipImpl |
findContactByID(java.lang.String contactID)
Returns a
ContactSipImpl with a specific ID in case we have
a subscription for it and null otherwise. |
void |
fireProviderMsgStatusChangeEvent(java.lang.String oldValue)
Notifies all registered listeners of the new event.
|
void |
forcePollContact(ContactSipImpl contact)
Forces the poll of a contact to update its current state.
|
java.lang.String |
getCurrentStatusMessage()
Returns the status message that was confirmed by the server
|
ContactSipImpl |
getLocalContactForDst(javax.sip.address.Address destination)
Returns the protocol specific contact instance representing the local
user.
|
ContactSipImpl |
getLocalContactForDst(ContactSipImpl destination)
Returns the protocol specific contact instance representing the local
user.
|
byte[] |
getPidfPresenceStatus(ContactSipImpl contact)
Converts the PresenceStatus of contact into a PIDF
document.
|
PresenceStatus |
getPresenceStatus()
Returns a PresenceStatus instance representing the state this provider is
currently in.
|
ContactGroup |
getServerStoredContactListRoot()
Returns the root group of the server stored contact list.
|
protected ServerStoredContactList |
getSsContactList()
Return current server-stored contact list implementation.
|
java.util.Iterator<PresenceStatus> |
getSupportedStatusSet()
Returns the set of PresenceStatus objects that a user of this service
may request the provider to enter.
|
static boolean |
isEquals(java.net.URI uri1,
java.net.URI uri2)
Checks whether to URIs are equal with safe null check.
|
void |
moveContactToGroup(Contact contactToMove,
ContactGroup newParent)
Removes the specified contact from its current parent and places it
under newParent.
|
boolean |
processDialogTerminated(javax.sip.DialogTerminatedEvent dialogTerminatedEvent)
Called when a dialog is terminated
|
boolean |
processIOException(javax.sip.IOExceptionEvent exceptionEvent)
Called when an IO error occurs
|
boolean |
processRequest(javax.sip.RequestEvent requestEvent)
Process a request from a distant contact
|
boolean |
processResponse(javax.sip.ResponseEvent responseEvent)
Analyzes the incoming responseEvent and then forwards it to the
proper event handler.
|
boolean |
processTimeout(javax.sip.TimeoutEvent timeoutEvent)
Called when a timeout occur
|
boolean |
processTransactionTerminated(javax.sip.TransactionTerminatedEvent transactionTerminatedEvent)
Called when a transaction is terminated
|
void |
publishPresenceStatus(PresenceStatus status,
java.lang.String statusMsg)
Requests the provider to enter into a status corresponding to the
specified parameters.
|
PresenceStatus |
queryContactStatus(java.lang.String contactIdentifier)
Get the PresenceStatus for a particular contact.
|
void |
registrationStateChanged(RegistrationStateChangeEvent evt)
The method is called by a ProtocolProvider implementation whenever
a change in the registration state of the corresponding provider had
occurred.
|
void |
removeServerStoredContactGroup(ContactGroup group)
Removes the specified group from the server stored contact list.
|
void |
removeServerStoredGroupChangeListener(ServerStoredGroupListener listener)
Removes the specified group change listener so that it won't receive
any further events.
|
void |
renameServerStoredContactGroup(ContactGroup group,
java.lang.String newName)
Renames the specified group from the server stored contact list.
|
(package private) ContactSipImpl |
resolveContactID(java.lang.String contactID)
Tries to find a
ContactSipImpl which is identified either by
a specific contactID or by a derivation of it. |
void |
setAuthorizationHandler(AuthorizationHandler handler)
Handler for incoming authorization requests.
|
void |
setDisplayName(Contact contact,
java.lang.String newName)
Sets the display name for contact to be newName.
|
void |
setPidfPresenceStatus(java.lang.String presenceDoc)
Sets the contact's presence status using the PIDF document provided.
|
void |
setWatcherInfoStatus(net.java.sip.communicator.impl.protocol.sip.OperationSetPresenceSipImpl.WatcherInfoSubscriberSubscription subscriber,
java.lang.String watcherInfoDoc)
Parses watchers info document rfc3858.
|
(package private) void |
shutdown()
Frees allocated resources.
|
void |
subscribe(ContactGroup parentGroup,
java.lang.String contactIdentifier)
Persistently adds a subscription for the presence status of the
contact corresponding to the specified contactIdentifier and indicates
that it should be added to the specified group of the server stored
contact list.
|
(package private) void |
subscribe(ContactGroup parentGroup,
java.lang.String contactIdentifier,
java.lang.String contactType)
Persistently adds a subscription for the presence status of the
contact corresponding to the specified contactIdentifier and indicates
that it should be added to the specified group of the server stored
contact list.
|
void |
subscribe(java.lang.String contactIdentifier)
Adds a subscription for the presence status of the contact
corresponding to the specified contactIdentifier.
|
void |
unsubscribe(Contact contact)
Removes a subscription for the presence status of the specified contact.
|
void |
unsubscribeToAllContact()
Unsubscribe to every contact.
|
addContactPresenceStatusListener, addProviderPresenceStatusListener, addSubscriptionListener, fireContactPresenceStatusChangeEvent, fireContactPresenceStatusChangeEvent, fireContactPresenceStatusChangeEvent, fireContactPropertyChangeEvent, fireProviderStatusChangeEvent, fireProviderStatusChangeEvent, fireProviderStatusMessageChangeEvent, fireServerStoredGroupEvent, fireSubscriptionEvent, fireSubscriptionEvent, fireSubscriptionMovedEvent, getLocalContact, removeContactPresenceStatusListener, removeProviderPresenceStatusListener, removeSubscriptionListener
public OperationSetPresenceSipImpl(ProtocolProviderServiceSipImpl provider, boolean presenceEnabled, boolean forceP2PMode, int pollingPeriod, int subscriptionExpiration)
provider
- the ProtocolProviderServiceSipImpl instance that
created us.presenceEnabled
- if we are activated or if we don't have to
handle the presence informations for contactsforceP2PMode
- if we should start in the p2p mode directlypollingPeriod
- the period between two poll for offline contactssubscriptionExpiration
- the default subscription expiration value
to usepublic void addServerStoredGroupChangeListener(ServerStoredGroupListener listener)
addServerStoredGroupChangeListener
in interface OperationSetPersistentPresence
addServerStoredGroupChangeListener
in class AbstractOperationSetPersistentPresence<ProtocolProviderServiceSipImpl>
listener
- a ServerStoredGroupChangeListener impl that would receive
events upong group changes.public void removeServerStoredGroupChangeListener(ServerStoredGroupListener listener)
removeServerStoredGroupChangeListener
in interface OperationSetPersistentPresence
removeServerStoredGroupChangeListener
in class AbstractOperationSetPersistentPresence<ProtocolProviderServiceSipImpl>
listener
- the ServerStoredGroupChangeListener to removepublic PresenceStatus getPresenceStatus()
getPresenceStatus
in interface OperationSetPresence
public ContactGroup getServerStoredContactListRoot()
getServerStoredContactListRoot
in interface OperationSetPersistentPresence
public void createServerStoredContactGroup(ContactGroup parentGroup, java.lang.String groupName) throws OperationFailedException
createServerStoredContactGroup
in interface OperationSetPersistentPresence
parentGroup
- the group where the new group should be createdgroupName
- the name of the new group to create.OperationFailedException
public ContactGroup createUnresolvedContactGroup(java.lang.String groupUID, java.lang.String persistentData, ContactGroup parentGroup)
createUnresolvedContactGroup
in interface OperationSetPersistentPresence
groupUID
- an identifier, returned by ContactGroup's getGroupUID,
that the protocol provider may use in order to create the group.persistentData
- a String returned ContactGroups's
getPersistentData() method during a previous run and that has been
persistently stored locally.parentGroup
- the group under which the new group is to be created
or null if this is group directly underneath the root.public void renameServerStoredContactGroup(ContactGroup group, java.lang.String newName)
renameServerStoredContactGroup
in interface OperationSetPersistentPresence
group
- the group to rename.newName
- the new name of the group.public void moveContactToGroup(Contact contactToMove, ContactGroup newParent)
moveContactToGroup
in interface OperationSetPersistentPresence
contactToMove
- the Contact to movenewParent
- the ContactGroup where Contact
would be placed.public void removeServerStoredContactGroup(ContactGroup group)
removeServerStoredContactGroup
in interface OperationSetPersistentPresence
group
- the group to remove.java.lang.IllegalArgumentException
- if group was not found in this
protocol's contact list.public void publishPresenceStatus(PresenceStatus status, java.lang.String statusMsg) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, OperationFailedException
publishPresenceStatus
in interface OperationSetPresence
status
- the PresenceStatus as returned by
getRequestableStatusSetstatusMsg
- the message that should be set as the reason to
enter that statusjava.lang.IllegalArgumentException
- if the status requested is not a
valid PresenceStatus supported by this provider.java.lang.IllegalStateException
- if the provider is not currently
registered.OperationFailedException
- with code NETWORK_FAILURE if
publishing the status fails due to a network error.public void fireProviderMsgStatusChangeEvent(java.lang.String oldValue)
oldValue
- the presence status we were in before the change.public java.util.Iterator<PresenceStatus> getSupportedStatusSet()
getSupportedStatusSet
in interface OperationSetPresence
public PresenceStatus queryContactStatus(java.lang.String contactIdentifier) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, OperationFailedException
queryContactStatus
in interface OperationSetPresence
contactIdentifier
- the identifier of the contact whose status
we're interested in.java.lang.IllegalArgumentException
- if contact is not a contact
known to the underlying protocol providerjava.lang.IllegalStateException
- if the underlying protocol provider is
not registered/signed on a public service.OperationFailedException
- with code NETWORK_FAILURE if
retrieving the status fails due to errors experienced during
network communicationpublic void subscribe(java.lang.String contactIdentifier) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, OperationFailedException
subscribe
in interface OperationSetPersistentPresence
subscribe
in interface OperationSetPresence
contactIdentifier
- the identifier of the contact whose status
updates we are subscribing for. java.lang.IllegalArgumentException
- if contact is not a contact
known to the underlying protocol providerjava.lang.IllegalStateException
- if the underlying protocol provider is
not registered/signed on a public service.OperationFailedException
- with code NETWORK_FAILURE if
subscribing fails due to errors experienced during network
communicationpublic void subscribe(ContactGroup parentGroup, java.lang.String contactIdentifier) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, OperationFailedException
subscribe
in interface OperationSetPersistentPresence
parentGroup
- the parent group of the server stored contact list
where the contact should be added. contactIdentifier
- the contact whose status updates we are
subscribing for.java.lang.IllegalArgumentException
- if contact or
parent are not a contact known to the underlying protocol
provider.java.lang.IllegalStateException
- if the underlying protocol provider is
not registered/signed on a public service.OperationFailedException
- with code NETWORK_FAILURE if
subscribing fails due to errors experienced during network
communicationvoid subscribe(ContactGroup parentGroup, java.lang.String contactIdentifier, java.lang.String contactType) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, OperationFailedException
parentGroup
- the parent group of the server stored contact list
where the contact should be added. contactIdentifier
- the contact whose status updates we are
subscribing for.contactType
- the contact type to create, if missing null.java.lang.IllegalArgumentException
- if contact or
parent are not a contact known to the underlying protocol
provider.java.lang.IllegalStateException
- if the underlying protocol provider is
not registered/signed on a public service.OperationFailedException
- with code NETWORK_FAILURE if
subscribing fails due to errors experienced during network
communicationpublic void unsubscribe(Contact contact) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, OperationFailedException
unsubscribe
in interface OperationSetPersistentPresence
unsubscribe
in interface OperationSetPresence
contact
- the contact whose status updates we are unsubscribing
from.OperationFailedException
- with code NETWORK_FAILURE if
unsubscribing fails due to errors experienced during network
communicationjava.lang.IllegalArgumentException
- if contact is not a contact
known to the underlying protocol providerjava.lang.IllegalStateException
- if the underlying protocol provider is not
registered/signed on a public service.public boolean processResponse(javax.sip.ResponseEvent responseEvent)
processResponse
in interface MethodProcessor
responseEvent
- the responseEvent that we received
ProtocolProviderService.public boolean processRequest(javax.sip.RequestEvent requestEvent)
processRequest
in interface MethodProcessor
requestEvent
- the RequestEvent containing the newly
received request.public boolean processDialogTerminated(javax.sip.DialogTerminatedEvent dialogTerminatedEvent)
processDialogTerminated
in interface MethodProcessor
dialogTerminatedEvent
- DialogTerminatedEventpublic boolean processIOException(javax.sip.IOExceptionEvent exceptionEvent)
processIOException
in interface MethodProcessor
exceptionEvent
- IOExceptionEventpublic boolean processTransactionTerminated(javax.sip.TransactionTerminatedEvent transactionTerminatedEvent)
processTransactionTerminated
in interface MethodProcessor
transactionTerminatedEvent
- TransactionTerminatedEventpublic boolean processTimeout(javax.sip.TimeoutEvent timeoutEvent)
processTimeout
in interface MethodProcessor
timeoutEvent
- TimeoutEventpublic ContactSipImpl findContactByID(java.lang.String contactID)
ContactSipImpl
with a specific ID in case we have
a subscription for it and null otherwise.findContactByID
in interface OperationSetPresence
contactID
- a String identifier of the contact which is to be retrievedContactSipImpl
with the specified
contactID
or null if we don't have a
subscription for the specified identifierpublic ContactSipImpl getLocalContactForDst(ContactSipImpl destination)
destination
- the destination that we would be sending our contact
information to.public ContactSipImpl getLocalContactForDst(javax.sip.address.Address destination)
destination
- the destination that we would be sending our contact
information to.public void setAuthorizationHandler(AuthorizationHandler handler)
setAuthorizationHandler
in interface OperationSetPresence
handler
- an instance of an AuthorizationHandler for
authorization requests coming from other users requesting
permission add us to their contact list.public java.lang.String getCurrentStatusMessage()
getCurrentStatusMessage
in interface OperationSetPresence
public Contact createUnresolvedContact(java.lang.String address, java.lang.String persistentData)
createUnresolvedContact
in interface OperationSetPresence
address
- an identifier of the contact that we'll be creating.persistentData
- a String returned Contact's getPersistentData()
method during a previous run and that has been persistently stored
locally.public Contact createUnresolvedContact(java.lang.String contactId, java.lang.String persistentData, ContactGroup parent)
createUnresolvedContact
in interface OperationSetPersistentPresence
contactId
- an identifier of the contact that we'll be creating.persistentData
- a String returned Contact's getPersistentData()
method during a previous run and that has been persistently stored
locally.parent
- the group where the unresolved contact is
supposed to belong to.public ContactSipImpl createVolatileContact(java.lang.String contactAddress, java.lang.String displayName)
contactAddress
- the address of the volatile contact we'd like to
create.displayName
- the Display Name of the volatile contact we'd like to
create.public ContactSipImpl createVolatileContact(java.lang.String contactAddress)
contactAddress
- the address of the volatile contact we'd like to
create.ContactSipImpl resolveContactID(java.lang.String contactID)
ContactSipImpl
which is identified either by
a specific contactID
or by a derivation of it.contactID
- the identifier of the ContactSipImpl
to retrieve
either by directly using it or by deriving itContactSipImpl
which is identified either by the
specified contactID
or by a derivation of itorg.w3c.dom.Document createDocument()
java.lang.String convertDocument(org.w3c.dom.Document document)
document
- the document to convertorg.w3c.dom.Document convertDocument(java.lang.String document)
document
- the document as a Stringpublic byte[] getPidfPresenceStatus(ContactSipImpl contact)
contact
- The contact which interest uspublic void setPidfPresenceStatus(java.lang.String presenceDoc)
presenceDoc
- the pidf document to usepublic void setWatcherInfoStatus(net.java.sip.communicator.impl.protocol.sip.OperationSetPresenceSipImpl.WatcherInfoSubscriberSubscription subscriber, java.lang.String watcherInfoDoc)
watcherInfoDoc
- the doc.subscriber
- the subscriber which receives lists.public static boolean isEquals(java.net.URI uri1, java.net.URI uri2)
uri1
- to be compared.uri2
- to be compared.public void forcePollContact(ContactSipImpl contact)
contact
- the contact to pollpublic void unsubscribeToAllContact()
public void setDisplayName(Contact contact, java.lang.String newName) throws java.lang.IllegalArgumentException
setDisplayName
in interface OperationSetPersistentPresence
setDisplayName
in class AbstractOperationSetPersistentPresence<ProtocolProviderServiceSipImpl>
contact
- the Contact that we are renamingnewName
- a String containing the new display name for
metaContact.java.lang.IllegalArgumentException
- if contact is not an
instance that belongs to the underlying implementation.protected ServerStoredContactList getSsContactList()
public void registrationStateChanged(RegistrationStateChangeEvent evt)
registrationStateChanged
in interface RegistrationStateChangeListener
evt
- ProviderStatusChangeEvent the event describing the status
change.void shutdown()
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.