aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2010-12-22 13:18:35 +0000
committerDamian Minkov <damencho@jitsi.org>2010-12-22 13:18:35 +0000
commitbbcce197673d13169ac7adcfbbf936fb328ecca5 (patch)
tree05b75dea7e783d54ad59d22b8a96cc53e7638057 /src/net/java/sip/communicator
parent4e132f0db4530b0cd85923068a1b880400b4cb1c (diff)
downloadjitsi-bbcce197673d13169ac7adcfbbf936fb328ecca5.zip
jitsi-bbcce197673d13169ac7adcfbbf936fb328ecca5.tar.gz
jitsi-bbcce197673d13169ac7adcfbbf936fb328ecca5.tar.bz2
Remove some unnecessary resolves.
Fix NAPTR queries, getting SRV query string from NAPTR results. Fix NPE when there is no SERVER_ADDRESS saved. Process SIP 423 Interval Too Brief to update our expiration time value. Disable Jabber user id field when editing jabber accounts.
Diffstat (limited to 'src/net/java/sip/communicator')
-rw-r--r--src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java32
-rw-r--r--src/net/java/sip/communicator/impl/protocol/sip/SipMessageFactory.java5
-rw-r--r--src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java64
-rw-r--r--src/net/java/sip/communicator/plugin/jabberaccregwizz/AccountPanel.java1
-rw-r--r--src/net/java/sip/communicator/util/NetworkUtils.java2
5 files changed, 89 insertions, 15 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java
index 6b37ecc..001f286 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java
@@ -2027,8 +2027,6 @@ public class ProtocolProviderServiceSipImpl
proxyAddress = proxySocketAddress.getAddress();
proxyPort = proxySocketAddress.getPort();
- proxyAddressStr = proxyAddress.getHostName();
-
if (logger.isTraceEnabled())
logger.trace("Setting proxy address = " + proxyAddressStr);
@@ -2069,9 +2067,7 @@ public class ProtocolProviderServiceSipImpl
}
// Return if no proxy is specified or if the proxyAddress is null.
- if(proxyAddressStr == null
- || proxyAddressStr.length() == 0
- || proxyAddress == null)
+ if(proxyAddress == null)
{
return;
}
@@ -2692,17 +2688,22 @@ public class ProtocolProviderServiceSipImpl
for(String[] rec : naptrRecords)
{
resolveSRV(
- address,
+ rec[2],
rec[1],
resultAddresses,
resultTransports,
- preferIPv6Addresses);
+ preferIPv6Addresses,
+ true);
}
// NAPTR found use only it
if(logger.isInfoEnabled())
logger.info("Found NAPRT record and using it:"
+ resultAddresses);
+
+ // return only if found something
+ if(resultAddresses.size() > 0
+ && resultTransports.size() > 0)
return;
}
}
@@ -2720,7 +2721,8 @@ public class ProtocolProviderServiceSipImpl
transport,
resultAddresses,
resultTransports,
- preferIPv6Addresses);
+ preferIPv6Addresses,
+ false);
}
catch (ParseException e)
{
@@ -2871,17 +2873,25 @@ public class ProtocolProviderServiceSipImpl
* @param resultAddresses the result address after resolve.
* @param resultTransports and the addresses transports.
* @param preferIPv6Addresses is ipv6 addresses are preferred over ipv4.
+ * @param srvQueryString is the supplied address is of type
+ * _sip(s)._protocol.address, a string ready for srv queries, used
+ * when we have a NAPTR returned records with value <tt>true</tt>.
* @throws ParseException exception when parsing dns address
*/
private void resolveSRV(String address,
String transport,
List<InetSocketAddress> resultAddresses,
List<String> resultTransports,
- boolean preferIPv6Addresses)
+ boolean preferIPv6Addresses,
+ boolean srvQueryString)
throws ParseException
{
- InetSocketAddress[] socketAddresses =
- NetworkUtils.getSRVRecords(
+ InetSocketAddress[] socketAddresses;
+
+ if(srvQueryString)
+ socketAddresses = NetworkUtils.getSRVRecords(address);
+ else
+ socketAddresses = NetworkUtils.getSRVRecords(
transport.equalsIgnoreCase(ListeningPoint.TLS)
? "sips" : "sip",
transport.equalsIgnoreCase(ListeningPoint.UDP)
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/SipMessageFactory.java b/src/net/java/sip/communicator/impl/protocol/sip/SipMessageFactory.java
index c7ebf0d..2ac3962 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/SipMessageFactory.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/SipMessageFactory.java
@@ -1039,6 +1039,11 @@ public class SipMessageFactory
String domain = protocolProvider.getAccountID().
getAccountPropertyString(ProtocolProviderFactory.SERVER_ADDRESS);
+ // we used to take domain from toHeader, if there is no such
+ // account property back to previous behaviour
+ if(domain == null)
+ domain = ((SipURI) toHeader.getAddress().getURI()).getHost();
+
//Request URI
SipURI requestURI = protocolProvider.getAddressFactory()
.createSipURI(null, domain);
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java b/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java
index da14cfb..771c445 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java
@@ -163,7 +163,8 @@ public class SipRegistrarConnection
this.sipProvider = sipProviderCallback;
this.currentRegistrarAddress = registrarAddresses[0];
registrarURI = sipProvider.getAddressFactory().createSipURI(
- null, this.currentRegistrarAddress.getHostName());
+ null,
+ this.currentRegistrarAddress.getAddress().getHostAddress());
if(this.currentRegistrarAddress.getPort() != ListeningPoint.PORT_5060)
registrarURI.setPort(this.currentRegistrarAddress.getPort());
@@ -313,9 +314,11 @@ public class SipRegistrarConnection
try
{
registrarURI = sipProvider.getAddressFactory().createSipURI(
- null, this.currentRegistrarAddress.getHostName());
+ null,
+ this.currentRegistrarAddress.getAddress().getHostAddress());
- if(this.currentRegistrarAddress.getPort() != ListeningPoint.PORT_5060)
+ if(this.currentRegistrarAddress.getPort()
+ != ListeningPoint.PORT_5060)
registrarURI.setPort(this.currentRegistrarAddress.getPort());
// as the transport may change NAPTR records provides
@@ -867,6 +870,11 @@ public class SipRegistrarConnection
clientTransaction, response, sourceProvider);
processed = true;
}
+ else if (response.getStatusCode() == Response.INTERVAL_TOO_BRIEF)
+ {
+ processIntervalTooBrief(response);
+ processed = true;
+ }
else if ( response.getStatusCode() >= 400 )
{
logger.error("Received an error response.");
@@ -1034,6 +1042,56 @@ public class SipRegistrarConnection
}
/**
+ * Process error 423 Interval Too Brief. If there is minimum interval
+ * specified use it. Check the specified interval is greater than the one
+ * we used in our register.
+ * @param response the response containing the min expires header.
+ */
+ private void processIntervalTooBrief(Response response)
+ {
+ // interval is too brief, if we have specified correct interval
+ // in the response use it and re-register
+ MinExpiresHeader header =
+ (MinExpiresHeader)response.getHeader(MinExpiresHeader.NAME);
+
+ if(header != null)
+ {
+ int expires = header.getExpires();
+ if(expires > registrationsExpiration)
+ {
+ registrationsExpiration = expires;
+
+ try
+ {
+ register();
+
+ return;
+ }
+ catch (Throwable e)
+ {
+ logger.error("Cannot send register!", e);
+
+ setRegistrationState(
+ RegistrationState.CONNECTION_FAILED,
+ RegistrationStateChangeEvent.REASON_NOT_SPECIFIED,
+ "A timeout occurred while trying to " +
+ "connect to the server.");
+
+ return;
+ }
+ }
+ }
+
+ //tell the others we couldn't register
+ this.setRegistrationState(
+ RegistrationState.CONNECTION_FAILED
+ , RegistrationStateChangeEvent.REASON_NOT_SPECIFIED
+ , "Received an error while trying to register. "
+ + "Server returned error:" + response.getReasonPhrase()
+ );
+ }
+
+ /**
* Returns a string representation of this connection instance
* instance including information that would permit to distinguish it among
* other sip listeners when reading a log file.
diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/AccountPanel.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/AccountPanel.java
index d271c95..87461b6 100644
--- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/AccountPanel.java
+++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/AccountPanel.java
@@ -208,6 +208,7 @@ public class AccountPanel
void setUsername(String username)
{
userIDField.setText(username);
+ userIDField.setEnabled(false);
}
/**
diff --git a/src/net/java/sip/communicator/util/NetworkUtils.java b/src/net/java/sip/communicator/util/NetworkUtils.java
index 8289920..97ef277 100644
--- a/src/net/java/sip/communicator/util/NetworkUtils.java
+++ b/src/net/java/sip/communicator/util/NetworkUtils.java
@@ -1019,7 +1019,7 @@ public class NetworkUtils
private static Lookup createLookup(String domain, int type)
throws TextParseException
{
- Lookup lookup = new Lookup(domain, Type.SRV);
+ Lookup lookup = new Lookup(domain, type);
//initiate our global parallel resolver if this is our first ever
//DNS query.