Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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

java.lang.Object
  extended by net.java.sip.communicator.service.protocol.AbstractProtocolProviderService
      extended by net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabberImpl
All Implemented Interfaces:
ProtocolProviderService

public class ProtocolProviderServiceJabberImpl
extends AbstractProtocolProviderService

An implementation of the protocol provider service over the Jabber protocol

Author:
Damian Minkov, Symphorien Wanko, Lyubomir Marinov, Yana Stamcheva, Emil Ivov

Nested Class Summary
(package private) static class ProtocolProviderServiceJabberImpl.ConnectState
          State for connect and login state.
 
Field Summary
static String CAPS_GTALK_WEB_CAMERA
          Capabilities name for video call (sender side) in Google Talk web version.
static String CAPS_GTALK_WEB_VIDEO
          Capabilities name for video call (receive side) in Google Talk web version.
static String CAPS_GTALK_WEB_VOICE
          Capabilities name for audio call in Google Talk web version.
static String GOOGLE_VOICE_DOMAIN
          Google voice domain name.
static int SMACK_PACKET_REPLY_TIMEOUT
          Smack packet reply timeout.
static String URN_GOOGLE_CAMERA
          URN for Google camera.
static String URN_GOOGLE_TRANSPORT_P2P
          Google P2P transport URN.
static String URN_GOOGLE_VIDEO
          URN for Google video.
static String URN_GOOGLE_VOICE
          URN for Google voice.
static String URN_XMPP_JINGLE
          Jingle's Discovery Info common URN.
static String URN_XMPP_JINGLE_COIN
          Jingle's Discover Info URN for "XEP-298 :Delivering Conference Information to Jingle Participants (Coin)" support.
static String URN_XMPP_JINGLE_ICE_UDP_1
          Jingle's Discovery Info URN for ICE_UDP transport support.
static String URN_XMPP_JINGLE_NODES
          Jingle's Discovery Info URN for Jingle Nodes support.
static String URN_XMPP_JINGLE_RAW_UDP_0
          Jingle's Discovery Info URN for ICE_UDP transport support.
static String URN_XMPP_JINGLE_RTP
          Jingle's Discovery Info URN for RTP support.
static String URN_XMPP_JINGLE_RTP_AUDIO
          Jingle's Discovery Info URN for RTP support with audio.
static String URN_XMPP_JINGLE_RTP_HDREXT
          Jingle's Discover Info URN for "XEP-0294: Jingle RTP Header Extensions Negotiation" support.
static String URN_XMPP_JINGLE_RTP_VIDEO
          Jingle's Discovery Info URN for RTP support with video.
static String URN_XMPP_JINGLE_RTP_ZRTP
          Jingle's Discovery Info URN for ZRTP support with RTP.
static String URN_XMPP_JINGLE_TRANSFER_0
          Jingle's Discover Info URN for "XEP-0251: Jingle Session Transfer" support.
static String VCARD_REPLY_TIMEOUT_PROPERTY
          Property for vcard reply timeout.
 
Fields inherited from interface net.java.sip.communicator.service.protocol.ProtocolProviderService
BIND_RETRIES_DEFAULT_VALUE, BIND_RETRIES_PROPERTY_NAME
 
Constructor Summary
ProtocolProviderServiceJabberImpl()
           
 
Method Summary
 AccountID getAccountID()
          Returns the AccountID that uniquely identifies the account represented by this instance of the ProtocolProviderService.
 SecurityAuthority getAuthority()
          Used when we need to re-register or someone needs to obtain credentials.
 org.jivesoftware.smack.XMPPConnection getConnection()
          Returns the XMPPConnectionopened by this provider
 ScServiceDiscoveryManager getDiscoveryManager()
          Returns the currently valid ScServiceDiscoveryManager.
 String getFullJid(Contact contact)
          Returns the full jabber id (jid) corresponding to the given contact.
 String getFullJid(String bareJid)
          Returns the full jabber id (jid) corresponding to the given bare jid.
(package private)  JabberStatusEnum getJabberStatusEnum()
          Returns the current instance of JabberStatusEnum.
 org.xmpp.jnodes.smack.SmackServiceNode getJingleNodesServiceNode()
          Get the Jingle Nodes service.
 String getJitsiVideoBridge()
          Gets the entity ID of the first Jitsi VideoBridge associated with connection i.e.
 InetAddress getNextHop()
          Returns the InetAddress that is most likely to be to be used as a next hop when contacting our XMPP server.
 String getOurJID()
          Returns our own Jabber ID.
 ProtocolIcon getProtocolIcon()
          Returns the jabber protocol icon.
 String getProtocolName()
          Returns the short name of the protocol that the implementation of this provider is based upon (like SIP, Jabber, ICQ/AIM, or others for example).
 RegistrationState getRegistrationState()
          Returns the state of the registration of this protocol provider
 TransportProtocol getTransportProtocol()
          Returns the "transport" protocol of this instance used to carry the control channel for the current protocol service.
(package private)  UserCredentials getUserCredentials()
           
protected  void initialize(String screenname, AccountID accountID)
          Initialized the service implementation, and puts it in a sate where it could interoperate with other services.
 boolean isExtFeatureListSupported(String jid, String... extFeatures)
          Determines if the given list of ext features is supported by the specified jabber id.
 boolean isFeatureListSupported(String jid, String... features)
          Determines if the given list of features is supported by the specified jabber id.
 boolean isFeatureSupported(String jid, String feature)
          Determines if the given list of features is supported by the specified jabber id.
 boolean isGmailOrGoogleAppsAccount()
          Returns true if our account is a Gmail or a Google Apps ones.
static boolean isGmailOrGoogleAppsAccount(String domain)
          Returns true if our account is a Gmail or a Google Apps ones.
 boolean isGTalkTesting()
          Returns true if gtalktesting is enabled, false otherwise.
 boolean isInitialized()
          Returns true if the provider service implementation is initialized and ready for use by other services, and false otherwise.
 boolean isSignalingTransportSecure()
          Indicates if the XMPP transport channel is using a TLS secured socket.
 void register(SecurityAuthority authority)
          Starts the registration process.
(package private)  void reregister(int authReasonCode)
          Connects and logins again to the server.
 void shutdown()
          Makes the service implementation close all open sockets and release any resources that it might have taken and prepare for shutdown/garbage collection.
 void startJingleNodesDiscovery()
          Start auto-discovery of JingleNodes tracker/relays.
static void throwOperationFailedException(String message, int errorCode, Throwable cause, Logger logger)
          Logs a specific message and associated Throwable cause as an error using the current Logger and then throws a new OperationFailedException with the message, a specific error code and the cause.
 void unregister()
          Ends the registration of this protocol provider with the service.
 void unregister(boolean fireEvent)
          Unregister and fire the event if requested
 
Methods inherited from class net.java.sip.communicator.service.protocol.AbstractProtocolProviderService
addRegistrationStateChangeListener, addSupportedOperationSet, clearRegistrationStateChangeListener, fireRegistrationStateChanged, getOperationSet, getProtocolDisplayName, getSupportedOperationSets, isRegistered, removeRegistrationStateChangeListener, removeSupportedOperationSet, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.java.sip.communicator.service.protocol.ProtocolProviderService
hashCode
 

Field Detail

URN_XMPP_JINGLE

public static final String URN_XMPP_JINGLE
Jingle's Discovery Info common URN.

See Also:
Constant Field Values

URN_XMPP_JINGLE_RTP

public static final String URN_XMPP_JINGLE_RTP
Jingle's Discovery Info URN for RTP support.

See Also:
Constant Field Values

URN_XMPP_JINGLE_RTP_AUDIO

public static final String URN_XMPP_JINGLE_RTP_AUDIO
Jingle's Discovery Info URN for RTP support with audio.

See Also:
Constant Field Values

URN_XMPP_JINGLE_RTP_VIDEO

public static final String URN_XMPP_JINGLE_RTP_VIDEO
Jingle's Discovery Info URN for RTP support with video.

See Also:
Constant Field Values

URN_XMPP_JINGLE_RTP_ZRTP

public static final String URN_XMPP_JINGLE_RTP_ZRTP
Jingle's Discovery Info URN for ZRTP support with RTP.

See Also:
Constant Field Values

URN_XMPP_JINGLE_RAW_UDP_0

public static final String URN_XMPP_JINGLE_RAW_UDP_0
Jingle's Discovery Info URN for ICE_UDP transport support.

See Also:
Constant Field Values

URN_XMPP_JINGLE_ICE_UDP_1

public static final String URN_XMPP_JINGLE_ICE_UDP_1
Jingle's Discovery Info URN for ICE_UDP transport support.

See Also:
Constant Field Values

URN_XMPP_JINGLE_NODES

public static final String URN_XMPP_JINGLE_NODES
Jingle's Discovery Info URN for Jingle Nodes support.

See Also:
Constant Field Values

URN_XMPP_JINGLE_TRANSFER_0

public static final String URN_XMPP_JINGLE_TRANSFER_0
Jingle's Discover Info URN for "XEP-0251: Jingle Session Transfer" support.

See Also:
Constant Field Values

URN_XMPP_JINGLE_COIN

public static final String URN_XMPP_JINGLE_COIN
Jingle's Discover Info URN for "XEP-298 :Delivering Conference Information to Jingle Participants (Coin)" support.

See Also:
Constant Field Values

URN_XMPP_JINGLE_RTP_HDREXT

public static final String URN_XMPP_JINGLE_RTP_HDREXT
Jingle's Discover Info URN for "XEP-0294: Jingle RTP Header Extensions Negotiation" support.

See Also:
Constant Field Values

CAPS_GTALK_WEB_VOICE

public static final String CAPS_GTALK_WEB_VOICE
Capabilities name for audio call in Google Talk web version.

See Also:
Constant Field Values

CAPS_GTALK_WEB_VIDEO

public static final String CAPS_GTALK_WEB_VIDEO
Capabilities name for video call (receive side) in Google Talk web version.

See Also:
Constant Field Values

CAPS_GTALK_WEB_CAMERA

public static final String CAPS_GTALK_WEB_CAMERA
Capabilities name for video call (sender side) in Google Talk web version.

See Also:
Constant Field Values

URN_GOOGLE_TRANSPORT_P2P

public static final String URN_GOOGLE_TRANSPORT_P2P
Google P2P transport URN.

See Also:
Constant Field Values

URN_GOOGLE_VOICE

public static final String URN_GOOGLE_VOICE
URN for Google voice.

See Also:
Constant Field Values

URN_GOOGLE_CAMERA

public static final String URN_GOOGLE_CAMERA
URN for Google camera.

See Also:
Constant Field Values

URN_GOOGLE_VIDEO

public static final String URN_GOOGLE_VIDEO
URN for Google video.

See Also:
Constant Field Values

SMACK_PACKET_REPLY_TIMEOUT

public static final int SMACK_PACKET_REPLY_TIMEOUT
Smack packet reply timeout.

See Also:
Constant Field Values

VCARD_REPLY_TIMEOUT_PROPERTY

public static final String VCARD_REPLY_TIMEOUT_PROPERTY
Property for vcard reply timeout. Time to wait before we think vcard retrieving has timeouted, default value of smack is 5000 (5 sec.).

See Also:
Constant Field Values

GOOGLE_VOICE_DOMAIN

public static final String GOOGLE_VOICE_DOMAIN
Google voice domain name.

See Also:
Constant Field Values
Constructor Detail

ProtocolProviderServiceJabberImpl

public ProtocolProviderServiceJabberImpl()
Method Detail

getRegistrationState

public RegistrationState getRegistrationState()
Returns the state of the registration of this protocol provider

Returns:
the RegistrationState that this provider is currently in or null in case it is in a unknown state.

register

public void register(SecurityAuthority authority)
              throws OperationFailedException
Starts the registration process. Connection details such as registration server, user name/number are provided through the configuration service through implementation specific properties.

Parameters:
authority - the security authority that will be used for resolving any security challenges that may be returned during the registration or at any moment while we're registered.
Throws:
OperationFailedException - with the corresponding code it the registration fails for some reason (e.g. a networking error or an implementation problem).

reregister

void reregister(int authReasonCode)
Connects and logins again to the server.

Parameters:
authReasonCode - indicates the reason of the re-authentication.

isSignalingTransportSecure

public boolean isSignalingTransportSecure()
Indicates if the XMPP transport channel is using a TLS secured socket.

Returns:
True when TLS is used, false otherwise.

getTransportProtocol

public TransportProtocol getTransportProtocol()
Returns the "transport" protocol of this instance used to carry the control channel for the current protocol service.

Returns:
The "transport" protocol of this instance: TCP, TLS or UNKNOWN.

unregister

public void unregister()
Ends the registration of this protocol provider with the service.


unregister

public void unregister(boolean fireEvent)
Unregister and fire the event if requested

Parameters:
fireEvent - boolean

getProtocolName

public String getProtocolName()
Returns the short name of the protocol that the implementation of this provider is based upon (like SIP, Jabber, ICQ/AIM, or others for example).

Returns:
a String containing the short name of the protocol this service is taking care of.

initialize

protected void initialize(String screenname,
                          AccountID accountID)
Initialized the service implementation, and puts it in a sate where it could interoperate with other services. It is strongly recommended that properties in this Map be mapped to property names as specified by AccountProperties.

Parameters:
screenname - the account id/uin/screenname of the account that we're about to create
accountID - the identifier of the account that this protocol provider represents.
See Also:
AccountID

shutdown

public void shutdown()
Makes the service implementation close all open sockets and release any resources that it might have taken and prepare for shutdown/garbage collection.


isInitialized

public boolean isInitialized()
Returns true if the provider service implementation is initialized and ready for use by other services, and false otherwise.

Returns:
true if the provider is initialized and ready for use and false otherwise

getAccountID

public AccountID getAccountID()
Returns the AccountID that uniquely identifies the account represented by this instance of the ProtocolProviderService.

Returns:
the id of the account represented by this provider.

getConnection

public org.jivesoftware.smack.XMPPConnection getConnection()
Returns the XMPPConnectionopened by this provider

Returns:
a reference to the XMPPConnection last opened by this provider.

getProtocolIcon

public ProtocolIcon getProtocolIcon()
Returns the jabber protocol icon.

Returns:
the jabber protocol icon

getJabberStatusEnum

JabberStatusEnum getJabberStatusEnum()
Returns the current instance of JabberStatusEnum.

Returns:
the current instance of JabberStatusEnum.

isExtFeatureListSupported

public boolean isExtFeatureListSupported(String jid,
                                         String... extFeatures)
Determines if the given list of ext features is supported by the specified jabber id.

Parameters:
jid - the jabber id for which to check
extFeatures - the list of ext features to check for
Returns:
true if the list of ext features is supported; otherwise, false

isFeatureListSupported

public boolean isFeatureListSupported(String jid,
                                      String... features)
Determines if the given list of features is supported by the specified jabber id.

Parameters:
jid - the jabber id for which to check
features - the list of features to check for
Returns:
true if the list of features is supported; otherwise, false

isFeatureSupported

public boolean isFeatureSupported(String jid,
                                  String feature)
Determines if the given list of features is supported by the specified jabber id.

Parameters:
jid - the jabber id that we'd like to get information about
feature - the feature to check for
Returns:
true if the list of features is supported, otherwise returns false

getFullJid

public String getFullJid(Contact contact)
Returns the full jabber id (jid) corresponding to the given contact. If the provider is not connected returns null.

Parameters:
contact - the contact, for which we're looking for a jid
Returns:
the jid of the specified contact or null if the provider is not yet connected;

getFullJid

public String getFullJid(String bareJid)
Returns the full jabber id (jid) corresponding to the given bare jid. If the provider is not connected returns null.

Parameters:
bareJid - the bare contact address (i.e. no resource) whose full jid we are looking for.
Returns:
the jid of the specified contact or null if the provider is not yet connected;

getDiscoveryManager

public ScServiceDiscoveryManager getDiscoveryManager()
Returns the currently valid ScServiceDiscoveryManager.

Returns:
the currently valid ScServiceDiscoveryManager.

getOurJID

public String getOurJID()
Returns our own Jabber ID.

Returns:
our own Jabber ID.

getNextHop

public InetAddress getNextHop()
                       throws IllegalArgumentException
Returns the InetAddress that is most likely to be to be used as a next hop when contacting our XMPP server. This is an utility method that is used whenever we have to choose one of our local addresses (e.g. when trying to pick a best candidate for raw udp). It is based on the assumption that, in absence of any more specific details, chances are that we will be accessing remote destinations via the same interface that we are using to access our jabber server.

Returns:
the InetAddress that is most likely to be to be used as a next hop when contacting our server.
Throws:
IllegalArgumentException - if we don't have a valid server.

startJingleNodesDiscovery

public void startJingleNodesDiscovery()
Start auto-discovery of JingleNodes tracker/relays.


getJingleNodesServiceNode

public org.xmpp.jnodes.smack.SmackServiceNode getJingleNodesServiceNode()
Get the Jingle Nodes service. Note that this method will block until Jingle Nodes auto discovery (if enabled) finished.

Returns:
Jingle Nodes service

throwOperationFailedException

public static void throwOperationFailedException(String message,
                                                 int errorCode,
                                                 Throwable cause,
                                                 Logger logger)
                                          throws OperationFailedException
Logs a specific message and associated Throwable cause as an error using the current Logger and then throws a new OperationFailedException with the message, a specific error code and the cause.

Parameters:
message - the message to be logged and then wrapped in a new OperationFailedException
errorCode - the error code to be assigned to the new OperationFailedException
cause - the Throwable that has caused the necessity to log an error and have a new OperationFailedException thrown
logger - the logger that we'd like to log the error message and cause.
Throws:
OperationFailedException - the exception that we wanted this method to throw.

getAuthority

public SecurityAuthority getAuthority()
Used when we need to re-register or someone needs to obtain credentials.

Returns:
the SecurityAuthority.

isGTalkTesting

public boolean isGTalkTesting()
Returns true if gtalktesting is enabled, false otherwise.

Returns:
true if gtalktesting is enabled, false otherwise.

getUserCredentials

UserCredentials getUserCredentials()

isGmailOrGoogleAppsAccount

public boolean isGmailOrGoogleAppsAccount()
Returns true if our account is a Gmail or a Google Apps ones.

Returns:
true if our account is a Gmail or a Google Apps ones.

isGmailOrGoogleAppsAccount

public static boolean isGmailOrGoogleAppsAccount(String domain)
Returns true if our account is a Gmail or a Google Apps ones.

Parameters:
domain - domain to check
Returns:
true if our account is a Gmail or a Google Apps ones.

getJitsiVideoBridge

public String getJitsiVideoBridge()
Gets the entity ID of the first Jitsi VideoBridge associated with connection i.e. provided by the serviceName of connection.

Returns:
the entity ID of the first Jitsi VideoBridge associated with connection

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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