summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorNick Hudson <nick.hudson@isode.com>2014-02-07 10:29:11 (GMT)
committerSwift Review <review@swift.im>2014-04-22 08:01:43 (GMT)
commitcafd510a0efc9df985999ceded57efa1d411de2e (patch)
treeaf00a2797062c0eb0ae69db4a6f3fa11047ef5a7 /src/com
parenta511087b1f57f1f6372374f41d0b4b7ebeef9930 (diff)
downloadstroke-cafd510a0efc9df985999ceded57efa1d411de2e.zip
stroke-cafd510a0efc9df985999ceded57efa1d411de2e.tar.bz2
Move hardcoded XMPP SRV information from Connector into CoreClient
The Connector class had "_xmpp-client._tcp." hard-coded in it, which meant that it was not suitable for non XMPP clients. This change means that Connector could now be used by clients who are interested in arbitrary SRV records; the CoreClient class is updated accordingly. Test-information: Built and tested using MLC. Also tested with a client that is interested in IMAP SRV records Change-Id: Ia23c148fd8afdd7b3271c47b1c96d086d57a44bd
Diffstat (limited to 'src/com')
-rw-r--r--src/com/isode/stroke/client/CoreClient.java3
-rw-r--r--src/com/isode/stroke/network/Connector.java16
2 files changed, 10 insertions, 9 deletions
diff --git a/src/com/isode/stroke/client/CoreClient.java b/src/com/isode/stroke/client/CoreClient.java
index 524a05a..646f8fe 100644
--- a/src/com/isode/stroke/client/CoreClient.java
+++ b/src/com/isode/stroke/client/CoreClient.java
@@ -187,7 +187,8 @@ public class CoreClient {
/* FIXME: Port Proxies */
String host = (o.manualHostname == null || o.manualHostname.isEmpty()) ? jid_.getDomain() : o.manualHostname;
int port = o.manualPort;
- connector_ = Connector.create(host, port, o.manualHostname == null || o.manualHostname.isEmpty(), networkFactories.getDomainNameResolver(), networkFactories.getConnectionFactory(), networkFactories.getTimerFactory());
+ String serviceLookupPrefix = (o.manualHostname == null || o.manualHostname.isEmpty() ? "_xmpp-client._tcp." : null);
+ connector_ = Connector.create(host, port, serviceLookupPrefix, networkFactories.getDomainNameResolver(), networkFactories.getConnectionFactory(), networkFactories.getTimerFactory());
connectorConnectFinishedConnection_ = connector_.onConnectFinished.connect(new Slot2<Connection, com.isode.stroke.base.Error>() {
public void call(Connection p1, com.isode.stroke.base.Error p2) {
handleConnectorFinished(p1, p2);
diff --git a/src/com/isode/stroke/network/Connector.java b/src/com/isode/stroke/network/Connector.java
index 983882b..80caf0e 100644
--- a/src/com/isode/stroke/network/Connector.java
+++ b/src/com/isode/stroke/network/Connector.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2012, Isode Limited, London, England.
+ * Copyright (c) 2010-2014, Isode Limited, London, England.
* All rights reserved.
*/
/*
@@ -20,8 +20,8 @@ import java.util.Collection;
public class Connector {
- public static Connector create(String hostname, int port, boolean doServiceLookups, DomainNameResolver resolver, ConnectionFactory connectionFactory, TimerFactory timerFactory) {
- return new Connector(hostname, port, doServiceLookups, resolver, connectionFactory, timerFactory);
+ public static Connector create(String hostname, int port, String serviceLookupPrefix, DomainNameResolver resolver, ConnectionFactory connectionFactory, TimerFactory timerFactory) {
+ return new Connector(hostname, port, serviceLookupPrefix, resolver, connectionFactory, timerFactory);
}
public void setTimeoutMilliseconds(int milliseconds) {
@@ -35,8 +35,8 @@ public class Connector {
queriedAllServices = false;
serviceQueryResults = new ArrayList<Result>();
- if (doServiceLookups) {
- serviceQuery = resolver.createServiceQuery("_xmpp-client._tcp." + hostname);
+ if (serviceLookupPrefix != null) {
+ serviceQuery = resolver.createServiceQuery(serviceLookupPrefix + hostname);
serviceQuery.onResult.connect(new Slot1<Collection<DomainNameServiceQuery.Result>>() {
public void call(Collection<Result> p1) {
handleServiceQueryResult(p1);
@@ -64,13 +64,13 @@ public class Connector {
public final Signal2<Connection, com.isode.stroke.base.Error> onConnectFinished = new Signal2<Connection, com.isode.stroke.base.Error>();
- private Connector(String hostname,int port, boolean doServiceLookups, DomainNameResolver resolver, ConnectionFactory connectionFactory, TimerFactory timerFactory) {
+ private Connector(String hostname,int port, String serviceLookupPrefix, DomainNameResolver resolver, ConnectionFactory connectionFactory, TimerFactory timerFactory) {
this.hostname = hostname;
this.resolver = resolver;
this.connectionFactory = connectionFactory;
this.timerFactory = timerFactory;
this.port = port;
- this.doServiceLookups = doServiceLookups;
+ this.serviceLookupPrefix = serviceLookupPrefix;
}
private void handleServiceQueryResult(Collection<Result> result) {
@@ -231,6 +231,6 @@ public class Connector {
private Connection currentConnection;
private SignalConnection currentConnectionConnectFinishedConnection;
private final int port;
- private final boolean doServiceLookups;
+ private final String serviceLookupPrefix;
private boolean foundSomeDNS = false;
}