aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/de/pixart/messenger/ui/XmppActivity.java45
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/XmppConnection.java5
2 files changed, 37 insertions, 13 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
index b64b4ae71..28e57396d 100644
--- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
@@ -63,6 +63,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
@@ -964,12 +965,11 @@ public abstract class XmppActivity extends ActionBarActivity {
Account mAccount = xmppConnectionService.getAccounts().get(0);
String user = Jid.of(mAccount.getJid()).getLocal();
String domain = Jid.of(mAccount.getJid()).getDomain();
- String inviteURL = Config.inviteUserURL + user + "/" + domain;
- XmppConnection.Features features = mAccount.getXmppConnection().getFeatures();
- final boolean adhoclink = features.adhocinvite;
- if (adhoclink) {
- inviteURL = features.adhocinviteURI;
+ String inviteURL = AdHocInviteUri(mAccount);
+ if (inviteURL == null) {
+ inviteURL = Config.inviteUserURL + user + "/" + domain;
}
+ Log.d(Config.LOGTAG, "Invite uri = " + inviteURL);
String inviteText = getString(R.string.InviteText, user);
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
@@ -1000,12 +1000,11 @@ public abstract class XmppActivity extends ActionBarActivity {
Account mAccount = xmppConnectionService.findAccountByJid(Jid.of(selection).asBareJid());
String user = Jid.of(selection).getLocal();
String domain = Jid.of(selection).getDomain();
- String inviteURL = Config.inviteUserURL + user + "/" + domain;
- XmppConnection.Features features = mAccount.getXmppConnection().getFeatures();
- final boolean adhoclink = features.adhocinvite;
- if (adhoclink) {
- inviteURL = features.adhocinviteURI;
+ String inviteURL = AdHocInviteUri(mAccount);
+ if (inviteURL == null) {
+ inviteURL = Config.inviteUserURL + user + "/" + domain;
}
+ Log.d(Config.LOGTAG, "Invite uri = " + inviteURL);
String inviteText = getString(R.string.InviteText, user);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
@@ -1019,6 +1018,32 @@ public abstract class XmppActivity extends ActionBarActivity {
}
}
+ private boolean AdHocInvite(Account account) {
+ XmppConnection.Features features = account.getXmppConnection().getFeatures();
+ Log.d(Config.LOGTAG, "Invite available: " + features.adhocinvite);
+ return features.adhocinvite;
+ }
+
+ private String AdHocInviteUri(Account account) {
+ if (AdHocInvite(account)) {
+ int counter = 0;
+ XmppConnection.Features features = account.getXmppConnection().getFeatures();
+ account.getXmppConnection().getAdHocInviteUrl(Jid.ofDomain(account.getJid().getDomain()));
+ while (features.adhocinviteURI == null && counter <= 10) {
+ try {
+ Thread.sleep(500);
+ } catch(InterruptedException e) {
+ // Process exception
+ }
+ counter++;
+ }
+ String uri = features.adhocinviteURI;
+ features.adhocinviteURI = null;
+ return uri;
+ }
+ return null;
+ }
+
private void createIssue() {
String IssueURL = Config.ISSUE_URL;
Intent intent = new Intent(Intent.ACTION_VIEW);
diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
index 0eb5a5dcb..ae95058fa 100644
--- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
+++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
@@ -1327,8 +1327,7 @@ public class XmppConnection implements Runnable {
final String node = element.getAttribute("node");
if (node.equals("invite")) {
features.adhocinvite = true;
- Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": query disco commands of " + server + " was successful");
- getAdHocInviteUrl(server);
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": query disco commands of " + server + " was successful for node " + node);
}
}
}
@@ -1345,7 +1344,7 @@ public class XmppConnection implements Runnable {
});
}
- private void getAdHocInviteUrl(final Jid server) {
+ public void getAdHocInviteUrl(final Jid server) {
IqPacket iqPacket = new IqPacket(IqPacket.TYPE.SET);
iqPacket.setTo(Jid.ofDomain(server.getDomain()));
iqPacket.setFrom(Jid.of(account.getJid().asBareJid()));