Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.jabber
Class UriHandlerJabberImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.protocol.jabber.UriHandlerJabberImpl
All Implemented Interfaces:
EventListener, UriHandler, AccountManagerListener, org.osgi.framework.ServiceListener

public class UriHandlerJabberImpl
extends Object
implements UriHandler, org.osgi.framework.ServiceListener, AccountManagerListener

The jabber implementation of the URI handler. This class handles xmpp URIs by trying to establish a chat with them or add you to a chatroom.

Author:
Emil Ivov, Damian Minkov

Field Summary
 
Fields inherited from interface net.java.sip.communicator.service.argdelegation.UriHandler
PROTOCOL_PROPERTY
 
Constructor Summary
UriHandlerJabberImpl(ProtocolProviderFactory protoFactory)
          Creates an instance of this uri handler, so that it would start handling URIs by passing them to the providers registered by protoFactory .
 
Method Summary
 void dispose()
          Disposes of this UriHandler by, for example, removing the listeners it has added in its constructor (in order to prevent memory leaks, for one).
 String getProtocol()
          Returns the protocol that this handler is responsible for or "xmpp" in other words.
 void handleAccountManagerEvent(AccountManagerEvent event)
          Notifies this listener about an event fired by a specific AccountManager.
 void handleUri(String uri)
          Parses the specified URI and creates a chat with the currently active im operation set.
 void registerHandlerService()
          Registers this UriHandler with the bundle context so that it could start handling URIs
 ProtocolProviderService selectHandlingProvider(String uri)
          Returns the default provider that we are supposed to handle URIs through or null if there aren't any.
 void serviceChanged(org.osgi.framework.ServiceEvent event)
          The point of implementing a service listener here is so that we would only register our own uri handling service and thus only handle URIs while the factory is available as an OSGi service.
 void unregisterHandlerService()
          Unregisters this UriHandler from the bundle context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UriHandlerJabberImpl

public UriHandlerJabberImpl(ProtocolProviderFactory protoFactory)
                     throws NullPointerException
Creates an instance of this uri handler, so that it would start handling URIs by passing them to the providers registered by protoFactory .

Parameters:
protoFactory - the provider that created us.
Throws:
NullPointerException - if protoFactory is null.
Method Detail

dispose

public void dispose()
Disposes of this UriHandler by, for example, removing the listeners it has added in its constructor (in order to prevent memory leaks, for one).


handleAccountManagerEvent

public void handleAccountManagerEvent(AccountManagerEvent event)
Description copied from interface: AccountManagerListener
Notifies this listener about an event fired by a specific AccountManager.

Specified by:
handleAccountManagerEvent in interface AccountManagerListener
Parameters:
event - the AccountManagerEvent describing the AccountManager firing the notification and the other details of the specific notification.

registerHandlerService

public void registerHandlerService()
Registers this UriHandler with the bundle context so that it could start handling URIs


unregisterHandlerService

public void unregisterHandlerService()
Unregisters this UriHandler from the bundle context.


getProtocol

public String getProtocol()
Returns the protocol that this handler is responsible for or "xmpp" in other words.

Specified by:
getProtocol in interface UriHandler
Returns:
the "xmpp" string to indicate that this handler is responsible for handling "xmpp" uris.

handleUri

public void handleUri(String uri)
Parses the specified URI and creates a chat with the currently active im operation set.

Specified by:
handleUri in interface UriHandler
Parameters:
uri - the xmpp URI that we have to handle.

serviceChanged

public void serviceChanged(org.osgi.framework.ServiceEvent event)
The point of implementing a service listener here is so that we would only register our own uri handling service and thus only handle URIs while the factory is available as an OSGi service. We remove ourselves when our factory unregisters its service reference.

Specified by:
serviceChanged in interface org.osgi.framework.ServiceListener
Parameters:
event - the OSGi ServiceEvent

selectHandlingProvider

public ProtocolProviderService selectHandlingProvider(String uri)
                                               throws OperationFailedException
Returns the default provider that we are supposed to handle URIs through or null if there aren't any. Depending on the implementation this method may require user intervention so make sure you don't rely on a quick outcome when chatting it.

Parameters:
uri - the uri that we'd like to handle with the provider that we are about to select.
Returns:
the provider that we should handle URIs through.
Throws:
OperationFailedException - with code OPERATION_CANCELED if the users.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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