aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/xmpp
diff options
context:
space:
mode:
authorChristian S <christian@pix-art.de>2015-11-29 18:27:22 +0100
committerChristian S <christian@pix-art.de>2015-11-29 18:27:22 +0100
commitd8ec3153655ceb716349fdc3c7d7106b22fd8d8a (patch)
tree98c6a76b4fc02982f85942524aa94180da09c880 /src/main/java/eu/siacs/conversations/xmpp
parent2aebe6e56b4268dddfbd7f1cecf9dcab2de28026 (diff)
parentaeba964a65fce4ac77c908533d25295d44e9d2b5 (diff)
copy commits
Diffstat (limited to 'src/main/java/eu/siacs/conversations/xmpp')
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java38
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/chatstate/ChatState.java2
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/forms/Field.java4
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java8
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java2
5 files changed, 48 insertions, 6 deletions
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index 7092aca10..16b3f78b4 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -170,6 +170,7 @@ public class XmppConnection implements Runnable {
}
}
};
+ private Identity mServerIdentity = Identity.UNKNOWN;
private OnIqPacketReceived createPacketReceiveHandler() {
return new OnIqPacketReceived() {
@@ -224,6 +225,9 @@ public class XmppConnection implements Runnable {
lastConnect = SystemClock.elapsedRealtime();
lastPingSent = SystemClock.elapsedRealtime();
this.attempt++;
+ if (account.getJid().getDomainpart().equals("chat.facebook.com")) {
+ mServerIdentity = Identity.FACEBOOK;
+ }
try {
shouldAuthenticate = needsBinding = !account.isOptionSet(Account.OPTION_REGISTER);
tagReader = new XmlReader(wakeLock);
@@ -461,7 +465,7 @@ public class XmppConnection implements Runnable {
}
nextTag = tagReader.readTag();
}
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": last tag was "+nextTag);
+ Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": last tag was " + nextTag);
if (account.getStatus() == Account.State.ONLINE) {
account. setStatus(Account.State.OFFLINE);
if (statusListener != null) {
@@ -553,7 +557,7 @@ public class XmppConnection implements Runnable {
final Pair<IqPacket, OnIqPacketReceived> packetCallbackDuple = packetCallbacks.get(packet.getId());
// Packets to the server should have responses from the server
if (packetCallbackDuple.first.toServer(account)) {
- if (packet.fromServer(account) || account.getJid().getDomainpart().equals("chat.facebook.com")) {
+ if (packet.fromServer(account) || mServerIdentity == Identity.FACEBOOK) {
callback = packetCallbackDuple.second;
packetCallbacks.remove(packet.getId());
} else {
@@ -940,8 +944,25 @@ public class XmppConnection implements Runnable {
if (element.getName().equals("identity")) {
String type = element.getAttribute("type");
String category = element.getAttribute("category");
+ String name = element.getAttribute("name");
if (type != null && category != null) {
info.identities.add(new Pair<>(category, type));
+ if (type.equals("im") && category.equals("server")) {
+ if (name != null && jid.equals(account.getServer())) {
+ switch (name) {
+ case "Prosody":
+ mServerIdentity = Identity.PROSODY;
+ break;
+ case "ejabberd":
+ mServerIdentity = Identity.EJABBERD;
+ break;
+ case "Slack-XMPP":
+ mServerIdentity = Identity.SLACK;
+ break;
+ }
+ Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": server name: " + name);
+ }
+ }
}
} else if (element.getName().equals("feature")) {
info.features.add(element.getAttribute("var"));
@@ -1274,6 +1295,10 @@ public class XmppConnection implements Runnable {
this.mInteractive = interactive;
}
+ public Identity getServerIdentity() {
+ return mServerIdentity;
+ }
+
private class Info {
public final ArrayList<String> features = new ArrayList<>();
public final ArrayList<Pair<String,String>> identities = new ArrayList<>();
@@ -1294,6 +1319,13 @@ public class XmppConnection implements Runnable {
private class DnsTimeoutException extends IOException {
}
+ public enum Identity {
+ FACEBOOK,
+ SLACK,
+ EJABBERD,
+ PROSODY,
+ UNKNOWN
+ }
public class Features {
XmppConnection connection;
@@ -1369,7 +1401,7 @@ public class XmppConnection implements Runnable {
}
public boolean httpUpload() {
- return findDiscoItemsByFeature(Xmlns.HTTP_UPLOAD).size() > 0;
+ return !Config.DISABLE_HTTP_UPLOAD && findDiscoItemsByFeature(Xmlns.HTTP_UPLOAD).size() > 0;
}
}
diff --git a/src/main/java/eu/siacs/conversations/xmpp/chatstate/ChatState.java b/src/main/java/eu/siacs/conversations/xmpp/chatstate/ChatState.java
index f85efbdb5..3e371562c 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/chatstate/ChatState.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/chatstate/ChatState.java
@@ -4,7 +4,7 @@ import eu.siacs.conversations.xml.Element;
public enum ChatState {
- ACTIVE, INACTIVE, GONE, COMPOSING, PAUSED, mIncomingChatState;
+ ACTIVE, INACTIVE, GONE, COMPOSING, PAUSED;
public static ChatState parse(Element element) {
final String NAMESPACE = "http://jabber.org/protocol/chatstates";
diff --git a/src/main/java/eu/siacs/conversations/xmpp/forms/Field.java b/src/main/java/eu/siacs/conversations/xmpp/forms/Field.java
index c83880005..3ec1f2149 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/forms/Field.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/forms/Field.java
@@ -47,4 +47,8 @@ public class Field extends Element {
field.setChildren(element.getChildren());
return field;
}
+
+ public String getValue() {
+ return findChildContent("value");
+ }
}
diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
index 388c5dec2..59b660c8c 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
@@ -114,6 +114,8 @@ public class JingleConnection implements Transferable {
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(file));
mXmppConnectionService.sendBroadcast(intent);
+ } else {
+ account.getPgpDecryptionService().add(message);
}
}
@@ -219,7 +221,11 @@ public class JingleConnection implements Transferable {
conversation.getAccount().getAxolotlService().prepareKeyTransportMessage(conversation.getContact(), new OnMessageCreatedCallback() {
@Override
public void run(XmppAxolotlMessage xmppAxolotlMessage) {
- init(message, xmppAxolotlMessage);
+ if (xmppAxolotlMessage != null) {
+ init(message, xmppAxolotlMessage);
+ } else {
+ fail();
+ }
}
});
} else {
diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java
index ab564480c..0f0361cd3 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java
@@ -83,7 +83,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
public void getPrimaryCandidate(Account account,
final OnPrimaryCandidateFound listener) {
- if (Config.NO_PROXY_LOOKUP) {
+ if (Config.DISABLE_PROXY_LOOKUP) {
listener.onPrimaryCandidateFound(false, null);
return;
}