[jitsi-dev] Re: [jitsi~svn:9419] Adds an enumeration for the available transport protocols (UNKNOWN, UDP,


#1

Hey Vincent

Thanks for the change!

But I'm sorry, I have to bother you again :frowning:
Enums should not contain "enum" in their name...

Also, you might want to use equalsIgnoreCase in the parse method.

Regards,
Ingo

路路路

-----Original Message-----
From: vincent_lucas@java.net [mailto:vincent_lucas@java.net]
Sent: Donnerstag, 1. M盲rz 2012 12:35
To: commits@jitsi.java.net
Subject: [jitsi~svn:9419] Adds an enumeration for the available transport
protocols (UNKNOWN, UDP,
Project: jitsi
Repository: svn
Revision: 9419
Author: vincent_lucas
Date: 2012-03-01 11:34:37 UTC
Link:

Log Message:
------------
Adds an enumeration for the available transport protocols (UNKNOWN, UDP, TCP
or TLS) used to carry the control channel of protocol services (SIP, XMPP,
etc.). Updates ProtocolProviderServices getTransportType() function to
getTransportProtocol() which returns a transport protocol enumeration.

Revisions:
----------
9419

Modified Paths: ---------------
trunk/src/net/java/sip/communicator/service/protocol/ProtocolProviderServ
ice. java
trunk/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderSer
vice RssImpl.java
trunk/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProvi
derS erviceGibberishImpl.java
trunk/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderSer
vice IcqImpl.java
trunk/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProvider
Serv iceJabberImpl.java
trunk/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderS
ervi ceYahooImpl.java
trunk/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderSer
vice SSHImpl.java
trunk/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java

trunk/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProvid
erSe rviceZeroconfImpl.java
trunk/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderSer
vice MsnImpl.java
trunk/src/net/java/sip/communicator/impl/protocol/mock/MockProvider.java
trunk/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderSer
vice IrcImpl.java
trunk/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderSer
vice SipImpl.java
trunk/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderSe
rvic eDictImpl.java

Added Paths: ------------
trunk/src/net/java/sip/communicator/service/protocol/TransportProtocolEnu
m.ja va

Diffs: ------ Index:
trunk/src/net/java/sip/communicator/service/protocol/TransportProtocolEnu
m.ja va
=================================================================== ---
trunk/src/net/java/sip/communicator/service/protocol/TransportProtocolEnu
m.ja va (revision 0) +++
trunk/src/net/java/sip/communicator/service/protocol/TransportProtocolEnu
m.ja va (revision 9419) @@ -0,0 +1,53 @@ +/* + * Jitsi, the OpenSource
Java VoIP and Instant Messaging client. + * + * Distributable under LGPL
license. + * See terms of license at gnu.org. + */ +package
net.java.sip.communicator.service.protocol; + +/** + * Enumerates the
"transport" (OSI transport/application) protocols used to + * carry the
control channel for protocol services like xmmp, sip, etc. + * + *
@author Vincent Lucas + */ +public enum TransportProtocolEnum +{ +
/** + * The "transport" protocol is unknown. + */ + UNKNOWN,
+ + /** + * The "transport" protocol is UDP. + */ + UDP, +
+ /** + * The "transport" protocol is TCP. + */ + TCP, + +
聽聽聽/** + * The "transport" protocol is TLS. + */ + TLS; + +
public static TransportProtocolEnum parse(String transportProtocol) +
聽聽聽聽聽throws IllegalArgumentException + { +
if(UNKNOWN.toString().equals(transportProtocol)) + return
UNKNOWN; + else if(UDP.toString().equals(transportProtocol)) +
聽聽聽聽聽聽聽聽return UDP; + else
if(TCP.toString().equals(transportProtocol)) + return TCP; +
聽聽聽聽聽聽else if(TLS.toString().equals(transportProtocol)) +
return TLS; + + throw new IllegalArgumentException( +
聽聽聽transportProtocol + + "is not a currently supported
TransportProtocolEnum"); + } +} Index:
trunk/src/net/java/sip/communicator/service/protocol/ProtocolProviderServ
ice. java
=================================================================== ---
trunk/src/net/java/sip/communicator/service/protocol/ProtocolProviderServ
ice. java (revision 9418) +++
trunk/src/net/java/sip/communicator/service/protocol/ProtocolProviderServ
ice. java (revision 9419) @@ -189,10 +189,11 @@
聽聽聽聽聽public boolean isSignalingTransportSecure();
聽聽聽聽聽
聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽*
- * @return The transport protocol of this instance (UDP, TCP, TLS),
or null - * if the transport protocol is unknown. + * @return
The "transport" protocol of this instance: UDP, TCP, TLS or + *
UNKNOWN.
聽聽聽聽聽聽*/
- public String getTransportType();
+ public TransportProtocolEnum getTransportProtocol();
}
Index:
trunk/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderS
ervi ceYahooImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderS
ervi ceYahooImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderS
ervi ceYahooImpl.java (revision 9419) @@ -344,13 +344,14 @@
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽*
- * @return The transport protocol of this instance (TCP).
+ * @return The "transport" protocol of this instance: TCP.
聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽{
- return "TCP";
+ return TransportProtocolEnum.TCP;
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderSe
rvic eDictImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderSe
rvic eDictImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderSe
rvic eDictImpl.java (revision 9419) @@ -311,13 +311,14 @@
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽*
- * @return The transport protocol of this instance (TCP).
+ * @return The "transport" protocol of this instance: TCP.
聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽{
- return "TCP";
+ return TransportProtocolEnum.TCP;
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProvider
Serv iceJabberImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProvider
Serv iceJabberImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProvider
Serv iceJabberImpl.java (revision 9419) @@ -570,11 +570,12 @@
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽*
- * @return The transport protocol of this instance (TCP, TLS).
+ * @return The "transport" protocol of this instance: TCP, TLS or
UNKNOWN.
聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽// Without a connection, there is no transport available.
聽聽聽聽聽聽聽聽聽if(connection != null && connection.isConnected())
@@ -582,12 +583,12 @@
聽聽聽聽聽聽聽聽聽聽聽聽聽// Transport using a secure connection.
聽聽聽聽聽聽聽聽聽聽聽聽聽if(connection.isUsingTLS()) {
- return "TLS";
+ return TransportProtocolEnum.TLS;
聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽聽// Transport using a unsecure connection.
- return "TCP";
+ return TransportProtocolEnum.TCP;
聽聽聽聽聽聽聽聽聽}
- return null;
+ return TransportProtocolEnum.UNKNOWN;
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProvid
erSe rviceZeroconfImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProvid
erSe rviceZeroconfImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProvid
erSe rviceZeroconfImpl.java (revision 9419) @@ -270,13 +270,14 @@
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽*
- * @return The transport protocol of this instance (TCP).
+ * @return The "transport" protocol of this instance: TCP.
聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽{
- return "TCP";
+ return TransportProtocolEnum.TCP;
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderSer
vice RssImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderSer
vice RssImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderSer
vice RssImpl.java (revision 9419) @@ -243,13 +243,14 @@
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽*
- * @return The transport protocol of this instance (TCP).
+ * @return The "transport" protocol of this instance: TCP.
聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽{
- return "TCP";
+ return TransportProtocolEnum.TCP;
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/mock/MockProvider.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/mock/MockProvider.java
聽聽(revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/mock/MockProvider.java
聽聽(revision 9419) @@ -212,14 +212,14 @@
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽*
- * @return The transport protocol of this instance (null as the
transport - * protocol is unknown). + * @return The "transport"
protocol of this instance: UNKNOWN.
聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽{
- return null;
+ return TransportProtocolEnum.UNKNOWN;
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderSer
vice SipImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderSer
vice SipImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderSer
vice SipImpl.java (revision 9419) @@ -1640,22 +1640,24 @@
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽*
- * @return The transport protocol of this instance (UDP, TCP, TLS),
or null - * if the transport protocol is unknown. + * @return
The "transport" protocol of this instance: UDP, TCP, TLS or + *
UNKNOWN.
聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽// The transport protocol is not set properly when dealing with a
- // RegistrarLess account. This is why we return "null" in this case.
+ // RegistrarLess account. This is why we return "UNKNOWN" in this
case.
聽聽聽聽聽聽聽聽聽if(this.sipRegistrarConnection == null
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽>> this.sipRegistrarConnection instanceof
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽SipRegistrarlessConnection)
聽聽聽聽聽聽聽聽聽{
- return null;
+ return TransportProtocolEnum.UNKNOWN;
聽聽聽聽聽聽聽聽聽}
- return sipRegistrarConnection.getTransport();
+ return TransportProtocolEnum.parse(
+ sipRegistrarConnection.getTransport());
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderSer
vice IcqImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderSer
vice IcqImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderSer
vice IcqImpl.java (revision 9419) @@ -429,13 +429,14 @@
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽*
- * @return The transport protocol of this instance (TCP).
+ * @return The "transport" protocol of this instance: TCP.
聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽{
- return "TCP";
+ return TransportProtocolEnum.TCP;
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderSer
vice IrcImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderSer
vice IrcImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderSer
vice IrcImpl.java (revision 9419) @@ -289,13 +289,14 @@
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽*
- * @return The transport protocol of this instance (TCP).
+ * @return The "transport" protocol of this instance: TCP.
聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽{
- return "TCP";
+ return TransportProtocolEnum.TCP;
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderSer
vice MsnImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderSer
vice MsnImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderSer
vice MsnImpl.java (revision 9419) @@ -261,13 +261,14 @@
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽*
- * @return The transport protocol of this instance (TCP).
+ * @return The "transport" protocol of this instance: TCP.
聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽{
- return "TCP";
+ return TransportProtocolEnum.TCP;
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderSer
vice SSHImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderSer
vice SSHImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderSer
vice SSHImpl.java (revision 9419) @@ -632,13 +632,14 @@
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽*
- * @return The transport protocol of this instance (TCP).
+ * @return The "transport" protocol of this instance: TCP.
聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽{
- return "TCP";
+ return TransportProtocolEnum.TCP;
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProvi
derS erviceGibberishImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProvi
derS erviceGibberishImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProvi
derS erviceGibberishImpl.java (revision 9419) @@ -300,14 +300,14 @@
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽*
- * @return The transport protocol of this instance (null as the
transport - * protocol is unknown). + * @return The "transport"
protocol of this instance: UNKNOWN.
聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽{
- return null;
+ return TransportProtocolEnum.UNKNOWN;
聽聽聽聽聽}
聽聽聽聽聽
聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java
聽聽聽(revision 9418) +++
trunk/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java
聽聽聽(revision 9419) @@ -186,13 +186,13 @@
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"service.gui.callinfo.IS_CONFERENCE_FOCUS"),
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽String.valueOf(isConfFocus)));
- String preferredTransport =
- call.getProtocolProvider().getTransportType();
+ TransportProtocolEnum preferredTransport =
+ call.getProtocolProvider().getTransportProtocol();

- if (preferredTransport != null && preferredTransport.length() > 0)
+ if (preferredTransport != TransportProtocolEnum.UNKNOWN)
聽聽聽聽聽聽聽聽聽聽聽聽聽stringBuffer.append(getLineString(
resources.getI18NString("service.gui.callinfo.CALL_TRANSPORT"),
- preferredTransport));
+ preferredTransport.toString()));

聽聽聽聽聽聽聽聽聽constructCallPeersInfo(stringBuffer);


#2

Hi Ingo,

Hey Vincent

Thanks for the change!

But I'm sorry, I have to bother you again :frowning:

No problem, it is always good to learn from others :slight_smile:

Enums should not contain "enum" in their name...

Also, you might want to use equalsIgnoreCase in the parse method.

The revision #9420 takes your remarks into account.

Thank you for the help,
Vincent

路路路

On 03/01/2012 01:02 PM, Ingo Bauersachs wrote:

Regards,
Ingo

-----Original Message-----
From: vincent_lucas@java.net [mailto:vincent_lucas@java.net]
Sent: Donnerstag, 1. M盲rz 2012 12:35
To: commits@jitsi.java.net
Subject: [jitsi~svn:9419] Adds an enumeration for the available transport
protocols (UNKNOWN, UDP,
Project: jitsi
Repository: svn
Revision: 9419
Author: vincent_lucas
Date: 2012-03-01 11:34:37 UTC
Link:

Log Message:
------------
Adds an enumeration for the available transport protocols (UNKNOWN, UDP, TCP
or TLS) used to carry the control channel of protocol services (SIP, XMPP,
etc.). Updates ProtocolProviderServices getTransportType() function to
getTransportProtocol() which returns a transport protocol enumeration.

Revisions:
----------
9419

Modified Paths: ---------------
trunk/src/net/java/sip/communicator/service/protocol/ProtocolProviderServ
ice. java
trunk/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderSer
vice RssImpl.java
trunk/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProvi
derS erviceGibberishImpl.java
trunk/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderSer
vice IcqImpl.java
trunk/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProvider
Serv iceJabberImpl.java
trunk/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderS
ervi ceYahooImpl.java
trunk/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderSer
vice SSHImpl.java
trunk/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java

trunk/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProvid
erSe rviceZeroconfImpl.java
trunk/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderSer
vice MsnImpl.java
trunk/src/net/java/sip/communicator/impl/protocol/mock/MockProvider.java
trunk/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderSer
vice IrcImpl.java
trunk/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderSer
vice SipImpl.java
trunk/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderSe
rvic eDictImpl.java

Added Paths: ------------
trunk/src/net/java/sip/communicator/service/protocol/TransportProtocolEnu
m.ja va

Diffs: ------ Index:
trunk/src/net/java/sip/communicator/service/protocol/TransportProtocolEnu
m.ja va
=================================================================== ---
trunk/src/net/java/sip/communicator/service/protocol/TransportProtocolEnu
m.ja va (revision 0) +++
trunk/src/net/java/sip/communicator/service/protocol/TransportProtocolEnu
m.ja va (revision 9419) @@ -0,0 +1,53 @@ +/* + * Jitsi, the OpenSource
Java VoIP and Instant Messaging client. + * + * Distributable under LGPL
license. + * See terms of license at gnu.org. + */ +package
net.java.sip.communicator.service.protocol; + +/** + * Enumerates the
"transport" (OSI transport/application) protocols used to + * carry the
control channel for protocol services like xmmp, sip, etc. + * + *
@author Vincent Lucas + */ +public enum TransportProtocolEnum +{ +
/** + * The "transport" protocol is unknown. + */ + UNKNOWN,
+ + /** + * The "transport" protocol is UDP. + */ + UDP, +
+ /** + * The "transport" protocol is TCP. + */ + TCP, + +
聽聽聽聽/** + * The "transport" protocol is TLS. + */ + TLS; + +
聽聽public static TransportProtocolEnum parse(String transportProtocol) +
聽聽聽聽聽聽throws IllegalArgumentException + { +
if(UNKNOWN.toString().equals(transportProtocol)) + return
UNKNOWN; + else if(UDP.toString().equals(transportProtocol)) +
聽聽聽聽聽聽聽聽聽return UDP; + else
if(TCP.toString().equals(transportProtocol)) + return TCP; +
聽聽聽聽聽聽聽else if(TLS.toString().equals(transportProtocol)) +
return TLS; + + throw new IllegalArgumentException( +
聽聽聽聽transportProtocol + + "is not a currently supported
TransportProtocolEnum"); + } +} Index:
trunk/src/net/java/sip/communicator/service/protocol/ProtocolProviderServ
ice. java
=================================================================== ---
trunk/src/net/java/sip/communicator/service/protocol/ProtocolProviderServ
ice. java (revision 9418) +++
trunk/src/net/java/sip/communicator/service/protocol/ProtocolProviderServ
ice. java (revision 9419) @@ -189,10 +189,11 @@
聽聽聽聽聽聽public boolean isSignalingTransportSecure();

聽聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽聽*
- * @return The transport protocol of this instance (UDP, TCP, TLS),
or null - * if the transport protocol is unknown. + * @return
The "transport" protocol of this instance: UDP, TCP, TLS or + *
UNKNOWN.
聽聽聽聽聽聽聽*/
- public String getTransportType();
+ public TransportProtocolEnum getTransportProtocol();
聽聽}
Index:
trunk/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderS
ervi ceYahooImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderS
ervi ceYahooImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderS
ervi ceYahooImpl.java (revision 9419) @@ -344,13 +344,14 @@
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽聽*
- * @return The transport protocol of this instance (TCP).
+ * @return The "transport" protocol of this instance: TCP.
聽聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽聽{
- return "TCP";
+ return TransportProtocolEnum.TCP;
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderSe
rvic eDictImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderSe
rvic eDictImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderSe
rvic eDictImpl.java (revision 9419) @@ -311,13 +311,14 @@
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽聽*
- * @return The transport protocol of this instance (TCP).
+ * @return The "transport" protocol of this instance: TCP.
聽聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽聽{
- return "TCP";
+ return TransportProtocolEnum.TCP;
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProvider
Serv iceJabberImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProvider
Serv iceJabberImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProvider
Serv iceJabberImpl.java (revision 9419) @@ -570,11 +570,12 @@
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽聽*
- * @return The transport protocol of this instance (TCP, TLS).
+ * @return The "transport" protocol of this instance: TCP, TLS or
UNKNOWN.
聽聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽// Without a connection, there is no transport available.
聽聽聽聽聽聽聽聽聽聽if(connection != null&& connection.isConnected())
@@ -582,12 +583,12 @@
聽聽聽聽聽聽聽聽聽聽聽聽聽聽// Transport using a secure connection.
聽聽聽聽聽聽聽聽聽聽聽聽聽聽if(connection.isUsingTLS()) {
- return "TLS";
+ return TransportProtocolEnum.TLS;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽聽聽// Transport using a unsecure connection.
- return "TCP";
+ return TransportProtocolEnum.TCP;
聽聽聽聽聽聽聽聽聽聽}
- return null;
+ return TransportProtocolEnum.UNKNOWN;
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProvid
erSe rviceZeroconfImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProvid
erSe rviceZeroconfImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProvid
erSe rviceZeroconfImpl.java (revision 9419) @@ -270,13 +270,14 @@
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽聽*
- * @return The transport protocol of this instance (TCP).
+ * @return The "transport" protocol of this instance: TCP.
聽聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽聽{
- return "TCP";
+ return TransportProtocolEnum.TCP;
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderSer
vice RssImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderSer
vice RssImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderSer
vice RssImpl.java (revision 9419) @@ -243,13 +243,14 @@
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽聽*
- * @return The transport protocol of this instance (TCP).
+ * @return The "transport" protocol of this instance: TCP.
聽聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽聽{
- return "TCP";
+ return TransportProtocolEnum.TCP;
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/mock/MockProvider.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/mock/MockProvider.java
聽聽(revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/mock/MockProvider.java
聽聽(revision 9419) @@ -212,14 +212,14 @@
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽聽*
- * @return The transport protocol of this instance (null as the
transport - * protocol is unknown). + * @return The "transport"
protocol of this instance: UNKNOWN.
聽聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽聽{
- return null;
+ return TransportProtocolEnum.UNKNOWN;
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderSer
vice SipImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderSer
vice SipImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderSer
vice SipImpl.java (revision 9419) @@ -1640,22 +1640,24 @@
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽聽*
- * @return The transport protocol of this instance (UDP, TCP, TLS),
or null - * if the transport protocol is unknown. + * @return
The "transport" protocol of this instance: UDP, TCP, TLS or + *
UNKNOWN.
聽聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽// The transport protocol is not set properly when dealing with a
- // RegistrarLess account. This is why we return "null" in this case.
+ // RegistrarLess account. This is why we return "UNKNOWN" in this
case.
聽聽聽聽聽聽聽聽聽聽if(this.sipRegistrarConnection == null
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽>> this.sipRegistrarConnection instanceof
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽SipRegistrarlessConnection)
聽聽聽聽聽聽聽聽聽聽{
- return null;
+ return TransportProtocolEnum.UNKNOWN;
聽聽聽聽聽聽聽聽聽聽}
- return sipRegistrarConnection.getTransport();
+ return TransportProtocolEnum.parse(
+ sipRegistrarConnection.getTransport());
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderSer
vice IcqImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderSer
vice IcqImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderSer
vice IcqImpl.java (revision 9419) @@ -429,13 +429,14 @@
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽聽*
- * @return The transport protocol of this instance (TCP).
+ * @return The "transport" protocol of this instance: TCP.
聽聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽聽{
- return "TCP";
+ return TransportProtocolEnum.TCP;
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderSer
vice IrcImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderSer
vice IrcImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderSer
vice IrcImpl.java (revision 9419) @@ -289,13 +289,14 @@
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽聽*
- * @return The transport protocol of this instance (TCP).
+ * @return The "transport" protocol of this instance: TCP.
聽聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽聽{
- return "TCP";
+ return TransportProtocolEnum.TCP;
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderSer
vice MsnImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderSer
vice MsnImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderSer
vice MsnImpl.java (revision 9419) @@ -261,13 +261,14 @@
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽聽*
- * @return The transport protocol of this instance (TCP).
+ * @return The "transport" protocol of this instance: TCP.
聽聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽聽{
- return "TCP";
+ return TransportProtocolEnum.TCP;
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderSer
vice SSHImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderSer
vice SSHImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderSer
vice SSHImpl.java (revision 9419) @@ -632,13 +632,14 @@
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽聽*
- * @return The transport protocol of this instance (TCP).
+ * @return The "transport" protocol of this instance: TCP.
聽聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽聽{
- return "TCP";
+ return TransportProtocolEnum.TCP;
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProvi
derS erviceGibberishImpl.java
=================================================================== ---
trunk/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProvi
derS erviceGibberishImpl.java (revision 9418) +++
trunk/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProvi
derS erviceGibberishImpl.java (revision 9419) @@ -300,14 +300,14 @@
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
- * Returns the transport protocol of this instance.
+ * Returns the "transport" protocol of this instance used to carry the
+ * control channel for the current protocol service.
聽聽聽聽聽聽聽*
- * @return The transport protocol of this instance (null as the
transport - * protocol is unknown). + * @return The "transport"
protocol of this instance: UNKNOWN.
聽聽聽聽聽聽聽*/
- public String getTransportType()
+ public TransportProtocolEnum getTransportProtocol()
聽聽聽聽聽聽{
- return null;
+ return TransportProtocolEnum.UNKNOWN;
聽聽聽聽聽聽}

聽聽聽聽聽聽/**
Index:
trunk/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java
聽聽=================================================================== ---
trunk/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java
聽聽聽聽(revision 9418) +++
trunk/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java
聽聽聽聽(revision 9419) @@ -186,13 +186,13 @@
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"service.gui.callinfo.IS_CONFERENCE_FOCUS"),
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽String.valueOf(isConfFocus)));
- String preferredTransport =
- call.getProtocolProvider().getTransportType();
+ TransportProtocolEnum preferredTransport =
+ call.getProtocolProvider().getTransportProtocol();

- if (preferredTransport != null&& preferredTransport.length()> 0)
+ if (preferredTransport != TransportProtocolEnum.UNKNOWN)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽stringBuffer.append(getLineString(
resources.getI18NString("service.gui.callinfo.CALL_TRANSPORT"),
- preferredTransport));
+ preferredTransport.toString()));

聽聽聽聽聽聽聽聽聽聽constructCallPeersInfo(stringBuffer);

--
Vincent Lucas, Ph.D. Jitsi developer
chenzo@jitsi.org http://jitsi.org