aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/xmpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/siacs/conversations/xmpp')
-rw-r--r--src/eu/siacs/conversations/xmpp/XmppConnection.java85
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java6
2 files changed, 75 insertions, 16 deletions
diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java
index 8e93a91d..65d8a425 100644
--- a/src/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -74,14 +74,16 @@ public class XmppConnection implements Runnable {
private String streamId = null;
private int smVersion = 3;
+
+ private boolean usingCompression = false;
private int stanzasReceived = 0;
private int stanzasSent = 0;
- public long lastPaketReceived = 0;
- public long lastPingSent = 0;
- public long lastConnect = 0;
- public long lastSessionStarted = 0;
+ private long lastPaketReceived = 0;
+ private long lastPingSent = 0;
+ private long lastConnect = 0;
+ private long lastSessionStarted = 0;
private int attempt = 0;
@@ -127,7 +129,9 @@ public class XmppConnection implements Runnable {
protected void connect() {
Log.d(LOGTAG, account.getJid() + ": connecting");
+ usingCompression = false;
lastConnect = SystemClock.elapsedRealtime();
+ lastPingSent = SystemClock.elapsedRealtime();
this.attempt++;
try {
shouldAuthenticate = shouldBind = !account
@@ -417,6 +421,7 @@ public class XmppConnection implements Runnable {
sendStartStream();
Log.d(LOGTAG, account.getJid() + ": compression enabled");
+ usingCompression = true;
processStream(tagReader.readTag());
}
@@ -766,6 +771,7 @@ public class XmppConnection implements Runnable {
iq.addChild("ping", "urn:xmpp:ping");
this.sendIqPacket(iq, null);
}
+ this.lastPingSent = SystemClock.elapsedRealtime();
}
public void setOnMessagePacketReceivedListener(
@@ -850,15 +856,7 @@ public class XmppConnection implements Runnable {
public void r() {
this.tagWriter.writeStanzaAsync(new RequestPacket(smVersion));
}
-
- public int getReceivedStanzas() {
- return this.stanzasReceived;
- }
-
- public int getSentStanzas() {
- return this.stanzasSent;
- }
-
+
public String getMucServer() {
return findDiscoItemByFeature("http://jabber.org/protocol/muc");
}
@@ -913,5 +911,66 @@ public class XmppConnection implements Runnable {
return connection.streamFeatures.hasChild("ver");
}
}
+
+ public boolean streamhost() {
+ return connection.findDiscoItemByFeature("http://jabber.org/protocol/bytestreams") != null;
+ }
+
+ public boolean compression() {
+ return connection.usingCompression;
+ }
+
+ public int getCompatibility() {
+ int hit = 0;
+ int miss = 0;
+ if (carbons()) {
+ ++hit;
+ } else {
+ ++miss;
+ }
+ if (sm()) {
+ ++hit;
+ } else {
+ ++miss;
+ }
+ if (pubsub()) {
+ ++hit;
+ } else {
+ ++miss;
+ }
+ if (streamhost()) {
+ ++hit;
+ } else {
+ ++miss;
+ }
+ if (compression()) {
+ ++hit;
+ } else {
+ ++miss;
+ }
+ return (int) (((float) hit) / (hit + miss) * 100);
+ }
+ }
+
+ public long getLastSessionEstablished() {
+ long diff;
+ if (this.lastSessionStarted == 0) {
+ diff = SystemClock.elapsedRealtime() - this.lastConnect;
+ } else {
+ diff = SystemClock.elapsedRealtime() - this.lastSessionStarted;
+ }
+ return System.currentTimeMillis() - diff;
+ }
+
+ public long getLastConnect() {
+ return this.lastConnect;
+ }
+
+ public long getLastPingSent() {
+ return this.lastPingSent;
+ }
+
+ public long getLastPacketReceived() {
+ return this.lastPaketReceived;
}
}
diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
index dafb2639..44d6b9f0 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
@@ -2,11 +2,11 @@ package eu.siacs.conversations.xmpp.jingle;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
import android.content.Intent;
import android.graphics.BitmapFactory;
@@ -48,7 +48,7 @@ public class JingleConnection {
private String initiator;
private String responder;
private List<JingleCandidate> candidates = new ArrayList<JingleCandidate>();
- private HashMap<String, JingleSocks5Transport> connections = new HashMap<String, JingleSocks5Transport>();
+ private ConcurrentHashMap<String, JingleSocks5Transport> connections = new ConcurrentHashMap<String, JingleSocks5Transport>();
private String transportId;
private Element fileOffer;
@@ -696,6 +696,7 @@ public class JingleConnection {
}
public void cancel() {
+ this.status = STATUS_CANCELED;
this.disconnect();
if (this.message != null) {
if (this.responder.equals(account.getFullJid())) {
@@ -711,7 +712,6 @@ public class JingleConnection {
}
}
}
- this.status = STATUS_CANCELED;
this.mJingleConnectionManager.finishConnection(this);
}