aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/xmpp
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-08-31 16:28:21 +0200
committeriNPUTmice <daniel@gultsch.de>2014-08-31 16:28:21 +0200
commit1ac5be485502e7d6d4c117335e083c684739e6af (patch)
tree279c22e269158dde838f31ebcf3daf4272573583 /src/eu/siacs/conversations/xmpp
parent8d456085e57334dc34707a49666006619e2c77c6 (diff)
some code cleanup
Diffstat (limited to 'src/eu/siacs/conversations/xmpp')
-rw-r--r--src/eu/siacs/conversations/xmpp/XmppConnection.java204
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java67
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java72
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java58
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/JingleFile.java35
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java12
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java51
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/JingleTransport.java51
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/OnFileTransmissionStatusChanged.java1
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/OnPrimaryCandidateFound.java3
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/OnTransportConnected.java1
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java64
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java28
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/stanzas/Reason.java2
-rw-r--r--src/eu/siacs/conversations/xmpp/pep/Avatar.java27
-rw-r--r--src/eu/siacs/conversations/xmpp/stanzas/AbstractStanza.java12
-rw-r--r--src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java15
-rw-r--r--src/eu/siacs/conversations/xmpp/stanzas/MessagePacket.java16
-rw-r--r--src/eu/siacs/conversations/xmpp/stanzas/PresencePacket.java3
-rw-r--r--src/eu/siacs/conversations/xmpp/stanzas/streammgmt/AckPacket.java4
-rw-r--r--src/eu/siacs/conversations/xmpp/stanzas/streammgmt/EnablePacket.java2
-rw-r--r--src/eu/siacs/conversations/xmpp/stanzas/streammgmt/RequestPacket.java2
-rw-r--r--src/eu/siacs/conversations/xmpp/stanzas/streammgmt/ResumePacket.java4
23 files changed, 411 insertions, 323 deletions
diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java
index 932b16f2..ae6b6f72 100644
--- a/src/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -32,6 +32,7 @@ import android.os.PowerManager.WakeLock;
import android.os.SystemClock;
import android.util.Log;
import android.util.SparseArray;
+import eu.siacs.conversations.Config;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.utils.CryptoHelper;
@@ -58,7 +59,6 @@ import eu.siacs.conversations.xmpp.stanzas.streammgmt.ResumePacket;
public class XmppConnection implements Runnable {
protected Account account;
- private static final String LOGTAG = "xmppService";
private WakeLock wakeLock;
@@ -67,7 +67,7 @@ public class XmppConnection implements Runnable {
private Socket socket;
private XmlReader tagReader;
private TagWriter tagWriter;
-
+
private Features features = new Features(this);
private boolean shouldBind = true;
@@ -78,7 +78,7 @@ public class XmppConnection implements Runnable {
private String streamId = null;
private int smVersion = 3;
private SparseArray<String> messageReceipts = new SparseArray<String>();
-
+
private boolean usingCompression = false;
private int stanzasReceived = 0;
@@ -109,8 +109,8 @@ public class XmppConnection implements Runnable {
this.mRandom = service.getRNG();
this.mMemorizingTrustManager = service.getMemorizingTrustManager();
this.account = account;
- this.wakeLock = service.getPowerManager().newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
- account.getJid());
+ this.wakeLock = service.getPowerManager().newWakeLock(
+ PowerManager.PARTIAL_WAKE_LOCK, account.getJid());
tagWriter = new TagWriter();
}
@@ -133,7 +133,7 @@ public class XmppConnection implements Runnable {
}
protected void connect() {
- Log.d(LOGTAG, account.getJid() + ": connecting");
+ Log.d(Config.LOGTAG, account.getJid() + ": connecting");
usingCompression = false;
lastConnect = SystemClock.elapsedRealtime();
lastPingSent = SystemClock.elapsedRealtime();
@@ -147,7 +147,7 @@ public class XmppConnection implements Runnable {
this.changeStatus(Account.STATUS_CONNECTING);
Bundle namePort = DNSHelper.getSRVRecord(account.getServer());
if ("timeout".equals(namePort.getString("error"))) {
- Log.d(LOGTAG, account.getJid() + ": dns timeout");
+ Log.d(Config.LOGTAG, account.getJid() + ": dns timeout");
this.changeStatus(Account.STATUS_OFFLINE);
return;
}
@@ -156,13 +156,14 @@ public class XmppConnection implements Runnable {
int srvRecordPort = namePort.getInt("port");
if (srvRecordServer != null) {
if (srvIpServer != null) {
- Log.d(LOGTAG, account.getJid() + ": using values from dns "
- + srvRecordServer + "[" + srvIpServer + "]:"
- + srvRecordPort);
+ Log.d(Config.LOGTAG, account.getJid()
+ + ": using values from dns " + srvRecordServer
+ + "[" + srvIpServer + "]:" + srvRecordPort);
socket = new Socket(srvIpServer, srvRecordPort);
} else {
- Log.d(LOGTAG, account.getJid() + ": using values from dns "
- + srvRecordServer + ":" + srvRecordPort);
+ Log.d(Config.LOGTAG, account.getJid()
+ + ": using values from dns " + srvRecordServer
+ + ":" + srvRecordPort);
socket = new Socket(srvRecordServer, srvRecordPort);
}
} else {
@@ -180,7 +181,8 @@ public class XmppConnection implements Runnable {
processStream(nextTag);
break;
} else {
- Log.d(LOGTAG, "found unexpected tag: " + nextTag.getName());
+ Log.d(Config.LOGTAG,
+ "found unexpected tag: " + nextTag.getName());
return;
}
}
@@ -190,27 +192,39 @@ public class XmppConnection implements Runnable {
} catch (UnknownHostException e) {
this.changeStatus(Account.STATUS_SERVER_NOT_FOUND);
if (wakeLock.isHeld()) {
- try { wakeLock.release();} catch (RuntimeException re) {}
+ try {
+ wakeLock.release();
+ } catch (RuntimeException re) {
+ }
}
return;
} catch (IOException e) {
this.changeStatus(Account.STATUS_OFFLINE);
if (wakeLock.isHeld()) {
- try { wakeLock.release();} catch (RuntimeException re) {}
+ try {
+ wakeLock.release();
+ } catch (RuntimeException re) {
+ }
}
return;
} catch (NoSuchAlgorithmException e) {
this.changeStatus(Account.STATUS_OFFLINE);
- Log.d(LOGTAG, "compression exception " + e.getMessage());
+ Log.d(Config.LOGTAG, "compression exception " + e.getMessage());
if (wakeLock.isHeld()) {
- try { wakeLock.release();} catch (RuntimeException re) {}
+ try {
+ wakeLock.release();
+ } catch (RuntimeException re) {
+ }
}
return;
} catch (XmlPullParserException e) {
this.changeStatus(Account.STATUS_OFFLINE);
- Log.d(LOGTAG, "xml exception " + e.getMessage());
+ Log.d(Config.LOGTAG, "xml exception " + e.getMessage());
if (wakeLock.isHeld()) {
- try { wakeLock.release();} catch (RuntimeException re) {}
+ try {
+ wakeLock.release();
+ } catch (RuntimeException re) {
+ }
}
return;
}
@@ -235,7 +249,7 @@ public class XmppConnection implements Runnable {
} else if (nextTag.isStart("compressed")) {
switchOverToZLib(nextTag);
} else if (nextTag.isStart("success")) {
- Log.d(LOGTAG, account.getJid() + ": logged in");
+ Log.d(Config.LOGTAG, account.getJid() + ": logged in");
tagReader.readTag();
tagReader.reset();
sendStartStream();
@@ -250,17 +264,18 @@ public class XmppConnection implements Runnable {
response.setAttribute("xmlns",
"urn:ietf:params:xml:ns:xmpp-sasl");
response.setContent(CryptoHelper.saslDigestMd5(account,
- challange,mRandom));
+ challange, mRandom));
tagWriter.writeElement(response);
} else if (nextTag.isStart("enabled")) {
Element enabled = tagReader.readElement(nextTag);
if ("true".equals(enabled.getAttribute("resume"))) {
this.streamId = enabled.getAttribute("id");
- Log.d(LOGTAG, account.getJid() + ": stream managment("
- + smVersion + ") enabled (resumable)");
+ Log.d(Config.LOGTAG, account.getJid()
+ + ": stream managment(" + smVersion
+ + ") enabled (resumable)");
} else {
- Log.d(LOGTAG, account.getJid() + ": stream managment("
- + smVersion + ") enabled");
+ Log.d(Config.LOGTAG, account.getJid()
+ + ": stream managment(" + smVersion + ") enabled");
}
this.lastSessionStarted = SystemClock.elapsedRealtime();
this.stanzasReceived = 0;
@@ -272,22 +287,25 @@ public class XmppConnection implements Runnable {
String h = resumed.getAttribute("h");
try {
int serverCount = Integer.parseInt(h);
- if (serverCount!=stanzasSent) {
- Log.d(LOGTAG,account.getJid() + ": session resumed with lost packages");
+ if (serverCount != stanzasSent) {
+ Log.d(Config.LOGTAG, account.getJid()
+ + ": session resumed with lost packages");
stanzasSent = serverCount;
} else {
- Log.d(LOGTAG, account.getJid() + ": session resumed");
+ Log.d(Config.LOGTAG, account.getJid()
+ + ": session resumed");
}
- if (acknowledgedListener!=null) {
- for(int i = 0; i < messageReceipts.size(); ++i) {
- if (serverCount>=messageReceipts.keyAt(i)) {
- acknowledgedListener.onMessageAcknowledged(account, messageReceipts.valueAt(i));
+ if (acknowledgedListener != null) {
+ for (int i = 0; i < messageReceipts.size(); ++i) {
+ if (serverCount >= messageReceipts.keyAt(i)) {
+ acknowledgedListener.onMessageAcknowledged(
+ account, messageReceipts.valueAt(i));
}
}
}
messageReceipts.clear();
} catch (NumberFormatException e) {
-
+
}
changeStatus(Account.STATUS_ONLINE);
} else if (nextTag.isStart("r")) {
@@ -301,13 +319,14 @@ public class XmppConnection implements Runnable {
String msgId = this.messageReceipts.get(serverSequence);
if (msgId != null) {
if (this.acknowledgedListener != null) {
- this.acknowledgedListener.onMessageAcknowledged(account, msgId);
+ this.acknowledgedListener.onMessageAcknowledged(
+ account, msgId);
}
this.messageReceipts.remove(serverSequence);
}
} else if (nextTag.isStart("failed")) {
tagReader.readElement(nextTag);
- Log.d(LOGTAG, account.getJid() + ": resumption failed");
+ Log.d(Config.LOGTAG, account.getJid() + ": resumption failed");
streamId = null;
if (account.getStatus() != Account.STATUS_ONLINE) {
sendBindRequest();
@@ -347,7 +366,7 @@ public class XmppConnection implements Runnable {
}
element.setAttributes(currentTag.getAttributes());
Tag nextTag = tagReader.readTag();
- if (nextTag==null) {
+ if (nextTag == null) {
throw new IOException("interrupted mid tag");
}
while (!nextTag.isEnd(element.getName())) {
@@ -361,7 +380,7 @@ public class XmppConnection implements Runnable {
element.addChild(child);
}
nextTag = tagReader.readTag();
- if (nextTag==null) {
+ if (nextTag == null) {
throw new IOException("interrupted mid tag");
}
}
@@ -446,7 +465,7 @@ public class XmppConnection implements Runnable {
.setInputStream(new ZLibInputStream(tagReader.getInputStream()));
sendStartStream();
- Log.d(LOGTAG, account.getJid() + ": compression enabled");
+ Log.d(Config.LOGTAG, account.getJid() + ": compression enabled");
usingCompression = true;
processStream(tagReader.readTag());
}
@@ -462,23 +481,30 @@ public class XmppConnection implements Runnable {
tagReader.readTag();
try {
SSLContext sc = SSLContext.getInstance("TLS");
- sc.init(null, new X509TrustManager[] { this.mMemorizingTrustManager }, mRandom);
+ sc.init(null,
+ new X509TrustManager[] { this.mMemorizingTrustManager },
+ mRandom);
SSLSocketFactory factory = sc.getSocketFactory();
-
- HostnameVerifier verifier = this.mMemorizingTrustManager.wrapHostnameVerifier(new org.apache.http.conn.ssl.StrictHostnameVerifier());
+
+ HostnameVerifier verifier = this.mMemorizingTrustManager
+ .wrapHostnameVerifier(new org.apache.http.conn.ssl.StrictHostnameVerifier());
SSLSocket sslSocket = (SSLSocket) factory.createSocket(socket,
socket.getInetAddress().getHostAddress(), socket.getPort(),
true);
-
- if (verifier != null && !verifier.verify(account.getServer(), sslSocket.getSession())) {
- Log.d(LOGTAG, account.getJid() + ": host mismatch in TLS connection");
+
+ if (verifier != null
+ && !verifier.verify(account.getServer(),
+ sslSocket.getSession())) {
+ Log.d(Config.LOGTAG, account.getJid()
+ + ": host mismatch in TLS connection");
sslSocket.close();
throw new IOException();
}
tagReader.setInputStream(sslSocket.getInputStream());
tagWriter.setOutputStream(sslSocket.getOutputStream());
sendStartStream();
- Log.d(LOGTAG, account.getJid() + ": TLS connection established");
+ Log.d(Config.LOGTAG, account.getJid()
+ + ": TLS connection established");
processStream(tagReader.readTag());
sslSocket.close();
} catch (NoSuchAlgorithmException e1) {
@@ -604,7 +630,7 @@ public class XmppConnection implements Runnable {
changeStatus(Account.STATUS_REGISTRATION_CONFLICT);
} else {
changeStatus(Account.STATUS_REGISTRATION_FAILED);
- Log.d(LOGTAG, packet.toString());
+ Log.d(Config.LOGTAG, packet.toString());
}
disconnect(true);
}
@@ -612,7 +638,7 @@ public class XmppConnection implements Runnable {
} else {
changeStatus(Account.STATUS_REGISTRATION_FAILED);
disconnect(true);
- Log.d(LOGTAG, account.getJid()
+ Log.d(Config.LOGTAG, account.getJid()
+ ": could not register. instructions are"
+ instructions.getContent());
}
@@ -628,9 +654,9 @@ public class XmppConnection implements Runnable {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
Element bind = packet.findChild("bind");
- if (bind!=null) {
+ if (bind != null) {
Element jid = bind.findChild("jid");
- if (jid!=null) {
+ if (jid != null) {
account.setResource(jid.getContent().split("/")[1]);
if (streamFeatures.hasChild("sm", "urn:xmpp:sm:3")) {
smVersion = 3;
@@ -638,7 +664,8 @@ public class XmppConnection implements Runnable {
tagWriter.writeStanzaAsync(enable);
stanzasSent = 0;
messageReceipts.clear();
- } else if (streamFeatures.hasChild("sm", "urn:xmpp:sm:2")) {
+ } else if (streamFeatures.hasChild("sm",
+ "urn:xmpp:sm:2")) {
smVersion = 2;
EnablePacket enable = new EnablePacket(smVersion);
tagWriter.writeStanzaAsync(enable);
@@ -660,7 +687,8 @@ public class XmppConnection implements Runnable {
}
});
if (this.streamFeatures.hasChild("session")) {
- Log.d(LOGTAG, account.getJid() + ": sending deprecated session");
+ Log.d(Config.LOGTAG, account.getJid()
+ + ": sending deprecated session");
IqPacket startSession = new IqPacket(IqPacket.TYPE_SET);
startSession.addChild("session",
"urn:ietf:params:xml:ns:xmpp-session");
@@ -725,10 +753,10 @@ public class XmppConnection implements Runnable {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
if (!packet.hasChild("error")) {
- Log.d(LOGTAG, account.getJid()
+ Log.d(Config.LOGTAG, account.getJid()
+ ": successfully enabled carbons");
} else {
- Log.d(LOGTAG, account.getJid()
+ Log.d(Config.LOGTAG, account.getJid()
+ ": error enableing carbons " + packet.toString());
}
}
@@ -736,7 +764,7 @@ public class XmppConnection implements Runnable {
}
private void processStreamError(Tag currentTag) {
- Log.d(LOGTAG, "processStreamError");
+ Log.d(Config.LOGTAG, "processStreamError");
}
private void sendStartStream() throws IOException {
@@ -778,15 +806,18 @@ public class XmppConnection implements Runnable {
public void sendPresencePacket(PresencePacket packet) {
this.sendPacket(packet, null);
}
-
+
private synchronized void sendPacket(final AbstractStanza packet,
PacketReceived callback) {
- if (packet.getName().equals("iq") || packet.getName().equals("message") || packet.getName().equals("presence")) {
+ if (packet.getName().equals("iq") || packet.getName().equals("message")
+ || packet.getName().equals("presence")) {
++stanzasSent;
}
tagWriter.writeStanzaAsync(packet);
- if (packet instanceof MessagePacket && packet.getId() != null && this.streamId != null) {
- Log.d(LOGTAG,"request delivery report for stanza "+stanzasSent);
+ if (packet instanceof MessagePacket && packet.getId() != null
+ && this.streamId != null) {
+ Log.d(Config.LOGTAG, "request delivery report for stanza "
+ + stanzasSent);
this.messageReceipts.put(stanzasSent, packet.getId());
tagWriter.writeStanzaAsync(new RequestPacket(this.smVersion));
}
@@ -837,14 +868,14 @@ public class XmppConnection implements Runnable {
public void setOnBindListener(OnBindListener listener) {
this.bindListener = listener;
}
-
+
public void setOnMessageAcknowledgeListener(OnMessageAcknowledged listener) {
this.acknowledgedListener = listener;
}
public void disconnect(boolean force) {
changeStatus(Account.STATUS_OFFLINE);
- Log.d(LOGTAG, "disconnecting");
+ Log.d(Config.LOGTAG, "disconnecting");
try {
if (force) {
socket.close();
@@ -858,20 +889,21 @@ public class XmppConnection implements Runnable {
tagWriter.finish();
try {
while (!tagWriter.finished()) {
- Log.d(LOGTAG, "not yet finished");
+ Log.d(Config.LOGTAG, "not yet finished");
Thread.sleep(100);
}
tagWriter.writeTag(Tag.end("stream:stream"));
} catch (IOException e) {
- Log.d(LOGTAG, "io exception during disconnect");
+ Log.d(Config.LOGTAG,
+ "io exception during disconnect");
} catch (InterruptedException e) {
- Log.d(LOGTAG, "interrupted");
+ Log.d(Config.LOGTAG, "interrupted");
}
}
}
}).start();
} catch (IOException e) {
- Log.d(LOGTAG, "io exception during disconnect");
+ Log.d(Config.LOGTAG, "io exception during disconnect");
}
}
@@ -884,10 +916,10 @@ public class XmppConnection implements Runnable {
}
return items;
}
-
+
public String findDiscoItemByFeature(String feature) {
List<String> items = findDiscoItemsByFeature(feature);
- if (items.size()>=1) {
+ if (items.size() >= 1) {
return items.get(0);
}
return null;
@@ -896,7 +928,7 @@ public class XmppConnection implements Runnable {
public void r() {
this.tagWriter.writeStanzaAsync(new RequestPacket(smVersion));
}
-
+
public String getMucServer() {
return findDiscoItemByFeature("http://jabber.org/protocol/muc");
}
@@ -910,28 +942,29 @@ public class XmppConnection implements Runnable {
public int getAttempt() {
return this.attempt;
}
-
+
public Features getFeatures() {
return this.features;
}
-
+
public class Features {
XmppConnection connection;
+
public Features(XmppConnection connection) {
this.connection = connection;
}
-
+
private boolean hasDiscoFeature(String server, String feature) {
if (!connection.disco.containsKey(server)) {
return false;
}
return connection.disco.get(server).contains(feature);
}
-
+
public boolean carbons() {
return hasDiscoFeature(account.getServer(), "urn:xmpp:carbons:2");
}
-
+
public boolean sm() {
if (connection.streamFeatures == null) {
return false;
@@ -939,19 +972,21 @@ public class XmppConnection implements Runnable {
return connection.streamFeatures.hasChild("sm");
}
}
-
+
public boolean csi() {
if (connection.streamFeatures == null) {
return false;
} else {
- return connection.streamFeatures.hasChild("csi","urn:xmpp:csi:0");
+ return connection.streamFeatures.hasChild("csi",
+ "urn:xmpp:csi:0");
}
}
-
+
public boolean pubsub() {
- return hasDiscoFeature(account.getServer(), "http://jabber.org/protocol/pubsub#publish");
+ return hasDiscoFeature(account.getServer(),
+ "http://jabber.org/protocol/pubsub#publish");
}
-
+
public boolean rosterVersioning() {
if (connection.streamFeatures == null) {
return false;
@@ -959,11 +994,12 @@ public class XmppConnection implements Runnable {
return connection.streamFeatures.hasChild("ver");
}
}
-
+
public boolean streamhost() {
- return connection.findDiscoItemByFeature("http://jabber.org/protocol/bytestreams") != null;
+ return connection
+ .findDiscoItemByFeature("http://jabber.org/protocol/bytestreams") != null;
}
-
+
public boolean compression() {
return connection.usingCompression;
}
@@ -978,15 +1014,15 @@ public class XmppConnection implements Runnable {
}
return System.currentTimeMillis() - diff;
}
-
+
public long getLastConnect() {
return this.lastConnect;
}
-
+
public long getLastPingSent() {
return this.lastPingSent;
}
-
+
public long getLastPacketReceived() {
return this.lastPaketReceived;
}
@@ -994,7 +1030,7 @@ public class XmppConnection implements Runnable {
public void sendActive() {
this.sendPacket(new ActivePacket(), null);
}
-
+
public void sendInactive() {
this.sendPacket(new InactivePacket(), null);
}
diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java b/src/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java
index 80ffeaaa..2874b9a5 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java
@@ -6,11 +6,11 @@ import java.util.List;
import eu.siacs.conversations.xml.Element;
public class JingleCandidate {
-
+
public static int TYPE_UNKNOWN;
public static int TYPE_DIRECT = 0;
public static int TYPE_PROXY = 1;
-
+
private boolean ours;
private boolean usedByCounterpart = false;
private String cid;
@@ -19,12 +19,12 @@ public class JingleCandidate {
private int type;
private String jid;
private int priority;
-
- public JingleCandidate(String cid,boolean ours) {
+
+ public JingleCandidate(String cid, boolean ours) {
this.ours = ours;
this.cid = cid;
}
-
+
public String getCid() {
return cid;
}
@@ -32,15 +32,15 @@ public class JingleCandidate {
public void setHost(String host) {
this.host = host;
}
-
+
public String getHost() {
return this.host;
}
-
+
public void setJid(String jid) {
this.jid = jid;
}
-
+
public String getJid() {
return this.jid;
}
@@ -48,15 +48,15 @@ public class JingleCandidate {
public void setPort(int port) {
this.port = port;
}
-
+
public int getPort() {
return this.port;
}
-
+
public void setType(int type) {
this.type = type;
}
-
+
public void setType(String type) {
if ("proxy".equals(type)) {
this.type = TYPE_PROXY;
@@ -70,42 +70,46 @@ public class JingleCandidate {
public void setPriority(int i) {
this.priority = i;
}
-
+
public int getPriority() {
return this.priority;
}
-
+
public boolean equals(JingleCandidate other) {
return this.getCid().equals(other.getCid());
}
-
+
public boolean equalValues(JingleCandidate other) {
- return other.getHost().equals(this.getHost())&&(other.getPort()==this.getPort());
+ return other.getHost().equals(this.getHost())
+ && (other.getPort() == this.getPort());
}
-
+
public boolean isOurs() {
return ours;
}
-
+
public int getType() {
return this.type;
}
public static List<JingleCandidate> parse(List<Element> canditates) {
List<JingleCandidate> parsedCandidates = new ArrayList<JingleCandidate>();
- for(Element c : canditates) {
+ for (Element c : canditates) {
parsedCandidates.add(JingleCandidate.parse(c));
}
return parsedCandidates;
}
-
+
public static JingleCandidate parse(Element candidate) {
- JingleCandidate parsedCandidate = new JingleCandidate(candidate.getAttribute("cid"), false);
+ JingleCandidate parsedCandidate = new JingleCandidate(
+ candidate.getAttribute("cid"), false);
parsedCandidate.setHost(candidate.getAttribute("host"));
parsedCandidate.setJid(candidate.getAttribute("jid"));
parsedCandidate.setType(candidate.getAttribute("type"));
- parsedCandidate.setPriority(Integer.parseInt(candidate.getAttribute("priority")));
- parsedCandidate.setPort(Integer.parseInt(candidate.getAttribute("port")));
+ parsedCandidate.setPriority(Integer.parseInt(candidate
+ .getAttribute("priority")));
+ parsedCandidate
+ .setPort(Integer.parseInt(candidate.getAttribute("port")));
return parsedCandidate;
}
@@ -113,26 +117,27 @@ public class JingleCandidate {
Element element = new Element("candidate");
element.setAttribute("cid", this.getCid());
element.setAttribute("host", this.getHost());
- element.setAttribute("port", ""+this.getPort());
+ element.setAttribute("port", "" + this.getPort());
element.setAttribute("jid", this.getJid());
- element.setAttribute("priority",""+this.getPriority());
- if (this.getType()==TYPE_DIRECT) {
- element.setAttribute("type","direct");
- } else if (this.getType()==TYPE_PROXY) {
- element.setAttribute("type","proxy");
+ element.setAttribute("priority", "" + this.getPriority());
+ if (this.getType() == TYPE_DIRECT) {
+ element.setAttribute("type", "direct");
+ } else if (this.getType() == TYPE_PROXY) {
+ element.setAttribute("type", "proxy");
}
return element;
}
public void flagAsUsedByCounterpart() {
- this.usedByCounterpart = true;
+ this.usedByCounterpart = true;
}
public boolean isUsedByCounterpart() {
return this.usedByCounterpart;
}
-
+
public String toString() {
- return this.getHost()+":"+this.getPort()+" (prio="+this.getPriority()+")";
+ return this.getHost() + ":" + this.getPort() + " (prio="
+ + this.getPriority() + ")";
}
}
diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
index bfdbb7cc..317838fd 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
@@ -12,6 +12,7 @@ import android.content.Intent;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.util.Log;
+import eu.siacs.conversations.Config;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
@@ -100,10 +101,11 @@ public class JingleConnection {
mXmppConnectionService.markMessage(message,
Message.STATUS_RECEIVED);
}
- Log.d("xmppService",
+ Log.d(Config.LOGTAG,
"sucessfully transmitted file:" + file.getAbsolutePath());
- if (message.getEncryption()!=Message.ENCRYPTION_PGP) {
- Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
+ if (message.getEncryption() != Message.ENCRYPTION_PGP) {
+ Intent intent = new Intent(
+ Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(file));
mXmppConnectionService.sendBroadcast(intent);
}
@@ -121,17 +123,17 @@ public class JingleConnection {
@Override
public void success() {
if (initiator.equals(account.getFullJid())) {
- Log.d("xmppService", "we were initiating. sending file");
+ Log.d(Config.LOGTAG, "we were initiating. sending file");
transport.send(file, onFileTransmissionSatusChanged);
} else {
transport.receive(file, onFileTransmissionSatusChanged);
- Log.d("xmppService", "we were responding. receiving file");
+ Log.d(Config.LOGTAG, "we were responding. receiving file");
}
}
@Override
public void failed() {
- Log.d("xmppService", "proxy activation failed");
+ Log.d(Config.LOGTAG, "proxy activation failed");
}
};
@@ -177,13 +179,13 @@ public class JingleConnection {
returnResult = this.receiveFallbackToIbb(packet);
} else {
returnResult = false;
- Log.d("xmppService", "trying to fallback to something unknown"
+ Log.d(Config.LOGTAG, "trying to fallback to something unknown"
+ packet.toString());
}
} else if (packet.isAction("transport-accept")) {
returnResult = this.receiveTransportAccept(packet);
} else {
- Log.d("xmppService", "packet arrived in connection. action was "
+ Log.d(Config.LOGTAG, "packet arrived in connection. action was "
+ packet.getAction());
returnResult = false;
}
@@ -224,14 +226,14 @@ public class JingleConnection {
@Override
public void failed() {
- Log.d("xmppService",
+ Log.d(Config.LOGTAG,
"connection to our own primary candidete failed");
sendInitRequest();
}
@Override
public void established() {
- Log.d("xmppService",
+ Log.d(Config.LOGTAG,
"succesfully connected to our own primary candidate");
mergeCandidate(candidate);
sendInitRequest();
@@ -239,7 +241,7 @@ public class JingleConnection {
});
mergeCandidate(candidate);
} else {
- Log.d("xmppService",
+ Log.d(Config.LOGTAG,
"no primary candidate of our own was found");
sendInitRequest();
}
@@ -288,7 +290,7 @@ public class JingleConnection {
filename[filename.length - 2])) {
supportedFile = true;
if (filename[filename.length - 1].equals("otr")) {
- Log.d("xmppService", "receiving otr file");
+ Log.d(Config.LOGTAG, "receiving otr file");
this.message
.setEncryption(Message.ENCRYPTION_OTR);
} else {
@@ -304,13 +306,13 @@ public class JingleConnection {
conversation.getMessages().add(message);
if (size <= this.mJingleConnectionManager
.getAutoAcceptFileSize()) {
- Log.d("xmppService", "auto accepting file from "
+ Log.d(Config.LOGTAG, "auto accepting file from "
+ packet.getFrom());
this.acceptedAutomatically = true;
this.sendAccept();
} else {
message.markUnread();
- Log.d("xmppService",
+ Log.d(Config.LOGTAG,
"not auto accepting new file offer with size: "
+ size
+ " allowed size:"
@@ -400,7 +402,7 @@ public class JingleConnection {
@Override
public void failed() {
- Log.d("xmppService",
+ Log.d(Config.LOGTAG,
"connection to our own primary candidate failed");
content.socks5transport().setChildren(
getCandidatesAsElements());
@@ -411,7 +413,7 @@ public class JingleConnection {
@Override
public void established() {
- Log.d("xmppService",
+ Log.d(Config.LOGTAG,
"connected to primary candidate");
mergeCandidate(candidate);
content.socks5transport().setChildren(
@@ -422,7 +424,7 @@ public class JingleConnection {
}
});
} else {
- Log.d("xmppService",
+ Log.d(Config.LOGTAG,
"did not find a primary candidate for ourself");
content.socks5transport().setChildren(
getCandidatesAsElements());
@@ -446,7 +448,7 @@ public class JingleConnection {
}
private void sendJinglePacket(JinglePacket packet) {
- // Log.d("xmppService",packet.toString());
+ // Log.d(Config.LOGTAG,packet.toString());
account.getXmppConnection().sendIqPacket(packet, responseListener);
}
@@ -470,14 +472,14 @@ public class JingleConnection {
} else {
String cid = content.socks5transport()
.findChild("activated").getAttribute("cid");
- Log.d("xmppService", "received proxy activated (" + cid
+ Log.d(Config.LOGTAG, "received proxy activated (" + cid
+ ")prior to choosing our own transport");
JingleSocks5Transport connection = this.connections
.get(cid);
if (connection != null) {
connection.setActivated(true);
} else {
- Log.d("xmppService", "activated connection not found");
+ Log.d(Config.LOGTAG, "activated connection not found");
this.sendCancel();
this.cancel();
}
@@ -487,7 +489,7 @@ public class JingleConnection {
onProxyActivated.failed();
return true;
} else if (content.socks5transport().hasChild("candidate-error")) {
- Log.d("xmppService", "received candidate error");
+ Log.d(Config.LOGTAG, "received candidate error");
this.receivedCandidate = true;
if ((status == STATUS_ACCEPTED) && (this.sentCandidate)) {
this.connect();
@@ -497,14 +499,14 @@ public class JingleConnection {
String cid = content.socks5transport()
.findChild("candidate-used").getAttribute("cid");
if (cid != null) {
- Log.d("xmppService", "candidate used by counterpart:" + cid);
+ Log.d(Config.LOGTAG, "candidate used by counterpart:" + cid);
JingleCandidate candidate = getCandidate(cid);
candidate.flagAsUsedByCounterpart();
this.receivedCandidate = true;
if ((status == STATUS_ACCEPTED) && (this.sentCandidate)) {
this.connect();
} else {
- Log.d("xmppService",
+ Log.d(Config.LOGTAG,
"ignoring because file is already in transmission or we havent sent our candidate yet");
}
return true;
@@ -523,7 +525,7 @@ public class JingleConnection {
final JingleSocks5Transport connection = chooseConnection();
this.transport = connection;
if (connection == null) {
- Log.d("xmppService", "could not find suitable candidate");
+ Log.d(Config.LOGTAG, "could not find suitable candidate");
this.disconnect();
if (this.initiator.equals(account.getFullJid())) {
this.sendFallbackToIbb();
@@ -532,7 +534,7 @@ public class JingleConnection {
this.status = STATUS_TRANSMITTING;
if (connection.needsActivation()) {
if (connection.getCandidate().isOurs()) {
- Log.d("xmppService", "candidate "
+ Log.d(Config.LOGTAG, "candidate "
+ connection.getCandidate().getCid()
+ " was our proxy. going to activate");
IqPacket activation = new IqPacket(IqPacket.TYPE_SET);
@@ -557,17 +559,17 @@ public class JingleConnection {
}
});
} else {
- Log.d("xmppService",
+ Log.d(Config.LOGTAG,
"candidate "
+ connection.getCandidate().getCid()
+ " was a proxy. waiting for other party to activate");
}
} else {
if (initiator.equals(account.getFullJid())) {
- Log.d("xmppService", "we were initiating. sending file");
+ Log.d(Config.LOGTAG, "we were initiating. sending file");
connection.send(file, onFileTransmissionSatusChanged);
} else {
- Log.d("xmppService", "we were responding. receiving file");
+ Log.d(Config.LOGTAG, "we were responding. receiving file");
connection.receive(file, onFileTransmissionSatusChanged);
}
}
@@ -579,11 +581,11 @@ public class JingleConnection {
for (Entry<String, JingleSocks5Transport> cursor : connections
.entrySet()) {
JingleSocks5Transport currentConnection = cursor.getValue();
- // Log.d("xmppService","comparing candidate: "+currentConnection.getCandidate().toString());
+ // Log.d(Config.LOGTAG,"comparing candidate: "+currentConnection.getCandidate().toString());
if (currentConnection.isEstablished()
&& (currentConnection.getCandidate().isUsedByCounterpart() || (!currentConnection
.getCandidate().isOurs()))) {
- // Log.d("xmppService","is usable");
+ // Log.d(Config.LOGTAG,"is usable");
if (connection == null) {
connection = currentConnection;
} else {
@@ -592,7 +594,7 @@ public class JingleConnection {
connection = currentConnection;
} else if (connection.getCandidate().getPriority() == currentConnection
.getCandidate().getPriority()) {
- // Log.d("xmppService","found two candidates with same priority");
+ // Log.d(Config.LOGTAG,"found two candidates with same priority");
if (initiator.equals(account.getFullJid())) {
if (currentConnection.getCandidate().isOurs()) {
connection = currentConnection;
@@ -672,7 +674,7 @@ public class JingleConnection {
@Override
public void failed() {
- Log.d("xmppService", "ibb open failed");
+ Log.d(Config.LOGTAG, "ibb open failed");
}
@Override
@@ -742,7 +744,7 @@ public class JingleConnection {
@Override
public void failed() {
- Log.d("xmppService",
+ Log.d(Config.LOGTAG,
"connection failed with " + candidate.getHost() + ":"
+ candidate.getPort());
connectNextCandidate();
@@ -750,7 +752,7 @@ public class JingleConnection {
@Override
public void established() {
- Log.d("xmppService",
+ Log.d(Config.LOGTAG,
"established connection with " + candidate.getHost()
+ ":" + candidate.getPort());
sendCandidateUsed(candidate.getCid());
@@ -874,7 +876,7 @@ public class JingleConnection {
}
}).start();
} else {
- Log.d("xmppService", "status (" + status + ") was not ok");
+ Log.d(Config.LOGTAG, "status (" + status + ") was not ok");
}
}
}
diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java b/src/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java
index f01d7fa9..79090af6 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java
@@ -7,6 +7,7 @@ import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import android.annotation.SuppressLint;
import android.util.Log;
+import eu.siacs.conversations.Config;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.services.XmppConnectionService;
@@ -33,18 +34,20 @@ public class JingleConnectionManager {
public void deliverPacket(Account account, JinglePacket packet) {
if (packet.isAction("session-initiate")) {
JingleConnection connection = new JingleConnection(this);
- connection.init(account,packet);
+ connection.init(account, packet);
connections.add(connection);
} else {
for (JingleConnection connection : connections) {
- if (connection.getAccountJid().equals(account.getFullJid()) && connection
- .getSessionId().equals(packet.getSessionId()) && connection
- .getCounterPart().equals(packet.getFrom())) {
+ if (connection.getAccountJid().equals(account.getFullJid())
+ && connection.getSessionId().equals(
+ packet.getSessionId())
+ && connection.getCounterPart().equals(packet.getFrom())) {
connection.deliverPacket(packet);
return;
}
}
- account.getXmppConnection().sendIqPacket(packet.generateRespone(IqPacket.TYPE_ERROR), null);
+ account.getXmppConnection().sendIqPacket(
+ packet.generateRespone(IqPacket.TYPE_ERROR), null);
}
}
@@ -60,7 +63,7 @@ public class JingleConnectionManager {
this.connections.add(connection);
return connection;
}
-
+
public void finishConnection(JingleConnection connection) {
this.connections.remove(connection);
}
@@ -90,12 +93,17 @@ public class JingleConnectionManager {
.findChild("streamhost",
"http://jabber.org/protocol/bytestreams");
if (streamhost != null) {
- JingleCandidate candidate = new JingleCandidate(nextRandomId(),true);
- candidate.setHost(streamhost.getAttribute("host"));
- candidate.setPort(Integer.parseInt(streamhost.getAttribute("port")));
- candidate.setType(JingleCandidate.TYPE_PROXY);
+ JingleCandidate candidate = new JingleCandidate(
+ nextRandomId(), true);
+ candidate.setHost(streamhost
+ .getAttribute("host"));
+ candidate.setPort(Integer
+ .parseInt(streamhost
+ .getAttribute("port")));
+ candidate
+ .setType(JingleCandidate.TYPE_PROXY);
candidate.setJid(proxy);
- candidate.setPriority(655360+65535);
+ candidate.setPriority(655360 + 65535);
primaryCandidates.put(account.getJid(),
candidate);
listener.onPrimaryCandidateFound(true,
@@ -119,9 +127,10 @@ public class JingleConnectionManager {
public String nextRandomId() {
return new BigInteger(50, random).toString(32);
}
-
+
public long getAutoAcceptFileSize() {
- String config = this.xmppConnectionService.getPreferences().getString("auto_accept_file_size", "524288");
+ String config = this.xmppConnectionService.getPreferences().getString(
+ "auto_accept_file_size", "524288");
try {
return Long.parseLong(config);
} catch (NumberFormatException e) {
@@ -132,32 +141,35 @@ public class JingleConnectionManager {
public void deliverIbbPacket(Account account, IqPacket packet) {
String sid = null;
Element payload = null;
- if (packet.hasChild("open","http://jabber.org/protocol/ibb")) {
- payload = packet.findChild("open","http://jabber.org/protocol/ibb");
+ if (packet.hasChild("open", "http://jabber.org/protocol/ibb")) {
+ payload = packet
+ .findChild("open", "http://jabber.org/protocol/ibb");
sid = payload.getAttribute("sid");
- } else if (packet.hasChild("data","http://jabber.org/protocol/ibb")) {
- payload = packet.findChild("data","http://jabber.org/protocol/ibb");
+ } else if (packet.hasChild("data", "http://jabber.org/protocol/ibb")) {
+ payload = packet
+ .findChild("data", "http://jabber.org/protocol/ibb");
sid = payload.getAttribute("sid");
}
- if (sid!=null) {
+ if (sid != null) {
for (JingleConnection connection : connections) {
if (connection.hasTransportId(sid)) {
JingleTransport transport = connection.getTransport();
if (transport instanceof JingleInbandTransport) {
JingleInbandTransport inbandTransport = (JingleInbandTransport) transport;
- inbandTransport.deliverPayload(packet,payload);
+ inbandTransport.deliverPayload(packet, payload);
return;
}
}
}
- Log.d("xmppService","couldnt deliver payload: "+payload.toString());
+ Log.d(Config.LOGTAG,
+ "couldnt deliver payload: " + payload.toString());
} else {
- Log.d("xmppService","no sid found in incomming ibb packet");
+ Log.d(Config.LOGTAG, "no sid found in incomming ibb packet");
}
}
-
+
public void cancelInTransmission() {
- for(JingleConnection connection : this.connections) {
+ for (JingleConnection connection : this.connections) {
if (connection.getStatus() == JingleConnection.STATUS_TRANSMITTING) {
connection.cancel();
}
diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleFile.java b/src/eu/siacs/conversations/xmpp/jingle/JingleFile.java
index 3672351b..9253814b 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/JingleFile.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/JingleFile.java
@@ -5,60 +5,63 @@ import java.security.Key;
import javax.crypto.spec.SecretKeySpec;
+import eu.siacs.conversations.Config;
import eu.siacs.conversations.utils.CryptoHelper;
import android.util.Log;
public class JingleFile extends File {
-
+
private static final long serialVersionUID = 2247012619505115863L;
-
+
private long expectedSize = 0;
private String sha1sum;
private Key aeskey;
-
+
public JingleFile(String path) {
super(path);
}
-
+
public long getSize() {
return super.length();
}
-
+
public long getExpectedSize() {
- if (this.aeskey!=null) {
- return (this.expectedSize/16 + 1) * 16;
+ if (this.aeskey != null) {
+ return (this.expectedSize / 16 + 1) * 16;
} else {
return this.expectedSize;
}
}
-
+
public void setExpectedSize(long size) {
this.expectedSize = size;
}
-
+
public String getSha1Sum() {
return this.sha1sum;
}
-
+
public void setSha1Sum(String sum) {
this.sha1sum = sum;
}
-
+
public void setKey(byte[] key) {
- if (key.length>=32) {
+ if (key.length >= 32) {
byte[] secretKey = new byte[32];
System.arraycopy(key, 0, secretKey, 0, 32);
this.aeskey = new SecretKeySpec(secretKey, "AES");
- } else if (key.length>=16) {
+ } else if (key.length >= 16) {
byte[] secretKey = new byte[16];
System.arraycopy(key, 0, secretKey, 0, 16);
this.aeskey = new SecretKeySpec(secretKey, "AES");
} else {
- Log.d("xmppService","weird key");
+ Log.d(Config.LOGTAG, "weird key");
}
- Log.d("xmppService","using aes key "+CryptoHelper.bytesToHex(this.aeskey.getEncoded()));
+ Log.d(Config.LOGTAG,
+ "using aes key "
+ + CryptoHelper.bytesToHex(this.aeskey.getEncoded()));
}
-
+
public Key getKey() {
return this.aeskey;
}
diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java b/src/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java
index b859e7c7..331b53de 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java
@@ -32,7 +32,7 @@ public class JingleInbandTransport extends JingleTransport {
private OutputStream fileOutputStream;
private long remainingSize;
private MessageDigest digest;
-
+
private OnFileTransmissionStatusChanged onFileTransmissionStatusChanged;
private OnIqPacketReceived onAckReceived = new OnIqPacketReceived() {
@@ -77,7 +77,8 @@ public class JingleInbandTransport extends JingleTransport {
}
@Override
- public void receive(JingleFile file, OnFileTransmissionStatusChanged callback) {
+ public void receive(JingleFile file,
+ OnFileTransmissionStatusChanged callback) {
this.onFileTransmissionStatusChanged = callback;
this.file = file;
try {
@@ -86,7 +87,7 @@ public class JingleInbandTransport extends JingleTransport {
file.getParentFile().mkdirs();
file.createNewFile();
this.fileOutputStream = getOutputStream(file);
- if (this.fileOutputStream==null) {
+ if (this.fileOutputStream == null) {
callback.onFileTransferAborted();
return;
}
@@ -106,7 +107,7 @@ public class JingleInbandTransport extends JingleTransport {
this.digest = MessageDigest.getInstance("SHA-1");
this.digest.reset();
fileInputStream = this.getInputStream(file);
- if (fileInputStream==null) {
+ if (fileInputStream == null) {
callback.onFileTransferAborted();
return;
}
@@ -150,7 +151,8 @@ public class JingleInbandTransport extends JingleTransport {
try {
byte[] buffer = Base64.decode(data, Base64.NO_WRAP);
if (this.remainingSize < buffer.length) {
- buffer = Arrays.copyOfRange(buffer, 0, (int) this.remainingSize);
+ buffer = Arrays
+ .copyOfRange(buffer, 0, (int) this.remainingSize);
}
this.remainingSize -= buffer.length;
diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java b/src/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java
index d2c84325..e476decc 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java
@@ -21,7 +21,8 @@ public class JingleSocks5Transport extends JingleTransport {
private boolean activated = false;
protected Socket socket;
- public JingleSocks5Transport(JingleConnection jingleConnection, JingleCandidate candidate) {
+ public JingleSocks5Transport(JingleConnection jingleConnection,
+ JingleCandidate candidate) {
this.candidate = candidate;
try {
MessageDigest mDigest = MessageDigest.getInstance("SHA-1");
@@ -44,11 +45,12 @@ public class JingleSocks5Transport extends JingleTransport {
public void connect(final OnTransportConnected callback) {
new Thread(new Runnable() {
-
+
@Override
public void run() {
try {
- socket = new Socket(candidate.getHost(), candidate.getPort());
+ socket = new Socket(candidate.getHost(),
+ candidate.getPort());
inputStream = socket.getInputStream();
outputStream = socket.getOutputStream();
byte[] login = { 0x05, 0x01, 0x00 };
@@ -57,8 +59,9 @@ public class JingleSocks5Transport extends JingleTransport {
outputStream.write(login);
inputStream.read(reply);
if (Arrays.equals(reply, expectedReply)) {
- String connect = "" + '\u0005' + '\u0001' + '\u0000' + '\u0003'
- + '\u0028' + destination + '\u0000' + '\u0000';
+ String connect = "" + '\u0005' + '\u0001' + '\u0000'
+ + '\u0003' + '\u0028' + destination + '\u0000'
+ + '\u0000';
outputStream.write(connect.getBytes());
byte[] result = new byte[2];
inputStream.read(result);
@@ -80,12 +83,13 @@ public class JingleSocks5Transport extends JingleTransport {
}
}
}).start();
-
+
}
- public void send(final JingleFile file, final OnFileTransmissionStatusChanged callback) {
+ public void send(final JingleFile file,
+ final OnFileTransmissionStatusChanged callback) {
new Thread(new Runnable() {
-
+
@Override
public void run() {
InputStream fileInputStream = null;
@@ -93,7 +97,7 @@ public class JingleSocks5Transport extends JingleTransport {
MessageDigest digest = MessageDigest.getInstance("SHA-1");
digest.reset();
fileInputStream = getInputStream(file);
- if (fileInputStream==null) {
+ if (fileInputStream == null) {
callback.onFileTransferAborted();
return;
}
@@ -105,7 +109,7 @@ public class JingleSocks5Transport extends JingleTransport {
}
outputStream.flush();
file.setSha1Sum(CryptoHelper.bytesToHex(digest.digest()));
- if (callback!=null) {
+ if (callback != null) {
callback.onFileTransmitted(file);
}
} catch (FileNotFoundException e) {
@@ -125,12 +129,13 @@ public class JingleSocks5Transport extends JingleTransport {
}
}
}).start();
-
+
}
-
- public void receive(final JingleFile file, final OnFileTransmissionStatusChanged callback) {
+
+ public void receive(final JingleFile file,
+ final OnFileTransmissionStatusChanged callback) {
new Thread(new Runnable() {
-
+
@Override
public void run() {
try {
@@ -141,22 +146,22 @@ public class JingleSocks5Transport extends JingleTransport {
file.getParentFile().mkdirs();
file.createNewFile();
OutputStream fileOutputStream = getOutputStream(file);
- if (fileOutputStream==null) {
+ if (fileOutputStream == null) {
callback.onFileTransferAborted();
return;
}
long remainingSize = file.getExpectedSize();
byte[] buffer = new byte[8192];
int count = buffer.length;
- while(remainingSize > 0) {
+ while (remainingSize > 0) {
count = inputStream.read(buffer);
- if (count==-1) {
+ if (count == -1) {
callback.onFileTransferAborted();
return;
} else {
fileOutputStream.write(buffer, 0, count);
digest.update(buffer, 0, count);
- remainingSize-=count;
+ remainingSize -= count;
}
}
fileOutputStream.flush();
@@ -177,25 +182,25 @@ public class JingleSocks5Transport extends JingleTransport {
public boolean isProxy() {
return this.candidate.getType() == JingleCandidate.TYPE_PROXY;
}
-
+
public boolean needsActivation() {
return (this.isProxy() && !this.activated);
}
public void disconnect() {
- if (this.socket!=null) {
+ if (this.socket != null) {
try {
this.socket.close();
} catch (IOException e) {
-
+
}
}
}
-
+
public boolean isEstablished() {
return this.isEstablished;
}
-
+
public JingleCandidate getCandidate() {
return this.candidate;
}
diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleTransport.java b/src/eu/siacs/conversations/xmpp/jingle/JingleTransport.java
index 1acdfc39..07dc8ecc 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/JingleTransport.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/JingleTransport.java
@@ -15,61 +15,72 @@ import javax.crypto.CipherInputStream;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
+import eu.siacs.conversations.Config;
+
import android.util.Log;
public abstract class JingleTransport {
public abstract void connect(final OnTransportConnected callback);
- public abstract void receive(final JingleFile file, final OnFileTransmissionStatusChanged callback);
- public abstract void send(final JingleFile file, final OnFileTransmissionStatusChanged callback);
- private byte[] iv = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0xf};
-
- protected InputStream getInputStream(JingleFile file) throws FileNotFoundException {
+
+ public abstract void receive(final JingleFile file,
+ final OnFileTransmissionStatusChanged callback);
+
+ public abstract void send(final JingleFile file,
+ final OnFileTransmissionStatusChanged callback);
+
+ private byte[] iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0xf };
+
+ protected InputStream getInputStream(JingleFile file)
+ throws FileNotFoundException {
if (file.getKey() == null) {
return new FileInputStream(file);
} else {
try {
IvParameterSpec ips = new IvParameterSpec(iv);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
- cipher.init(Cipher.ENCRYPT_MODE, file.getKey(),ips);
- Log.d("xmppService","opening encrypted input stream");
+ cipher.init(Cipher.ENCRYPT_MODE, file.getKey(), ips);
+ Log.d(Config.LOGTAG, "opening encrypted input stream");
return new CipherInputStream(new FileInputStream(file), cipher);
} catch (NoSuchAlgorithmException e) {
- Log.d("xmppService","no such algo: "+e.getMessage());
+ Log.d(Config.LOGTAG, "no such algo: " + e.getMessage());
return null;
} catch (NoSuchPaddingException e) {
- Log.d("xmppService","no such padding: "+e.getMessage());
+ Log.d(Config.LOGTAG, "no such padding: " + e.getMessage());
return null;
} catch (InvalidKeyException e) {
- Log.d("xmppService","invalid key: "+e.getMessage());
+ Log.d(Config.LOGTAG, "invalid key: " + e.getMessage());
return null;
} catch (InvalidAlgorithmParameterException e) {
- Log.d("xmppService","invavid iv:"+e.getMessage());
+ Log.d(Config.LOGTAG, "invavid iv:" + e.getMessage());
return null;
}
}
}
-
- protected OutputStream getOutputStream(JingleFile file) throws FileNotFoundException {
+
+ protected OutputStream getOutputStream(JingleFile file)
+ throws FileNotFoundException {
if (file.getKey() == null) {
return new FileOutputStream(file);
} else {
try {
IvParameterSpec ips = new IvParameterSpec(iv);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
- cipher.init(Cipher.DECRYPT_MODE, file.getKey(),ips);
- Log.d("xmppService","opening encrypted output stream");
- return new CipherOutputStream(new FileOutputStream(file), cipher);
+ cipher.init(Cipher.DECRYPT_MODE, file.getKey(), ips);
+ Log.d(Config.LOGTAG, "opening encrypted output stream");
+ return new CipherOutputStream(new FileOutputStream(file),
+ cipher);
} catch (NoSuchAlgorithmException e) {
- Log.d("xmppService","no such algo: "+e.getMessage());
+ Log.d(Config.LOGTAG, "no such algo: " + e.getMessage());
return null;
} catch (NoSuchPaddingException e) {
- Log.d("xmppService","no such padding: "+e.getMessage());
+ Log.d(Config.LOGTAG, "no such padding: " + e.getMessage());
return null;
} catch (InvalidKeyException e) {
- Log.d("xmppService","invalid key: "+e.getMessage());
+ Log.d(Config.LOGTAG, "invalid key: " + e.getMessage());
return null;
} catch (InvalidAlgorithmParameterException e) {
- Log.d("xmppService","invavid iv:"+e.getMessage());
+ Log.d(Config.LOGTAG, "invavid iv:" + e.getMessage());
return null;
}
}
diff --git a/src/eu/siacs/conversations/xmpp/jingle/OnFileTransmissionStatusChanged.java b/src/eu/siacs/conversations/xmpp/jingle/OnFileTransmissionStatusChanged.java
index 84f10417..19fd4d97 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/OnFileTransmissionStatusChanged.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/OnFileTransmissionStatusChanged.java
@@ -2,5 +2,6 @@ package eu.siacs.conversations.xmpp.jingle;
public interface OnFileTransmissionStatusChanged {
public void onFileTransmitted(JingleFile file);
+
public void onFileTransferAborted();
}
diff --git a/src/eu/siacs/conversations/xmpp/jingle/OnPrimaryCandidateFound.java b/src/eu/siacs/conversations/xmpp/jingle/OnPrimaryCandidateFound.java
index b91a90ff..03a437b2 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/OnPrimaryCandidateFound.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/OnPrimaryCandidateFound.java
@@ -1,5 +1,6 @@
package eu.siacs.conversations.xmpp.jingle;
public interface OnPrimaryCandidateFound {
- public void onPrimaryCandidateFound(boolean success, JingleCandidate canditate);
+ public void onPrimaryCandidateFound(boolean success,
+ JingleCandidate canditate);
}
diff --git a/src/eu/siacs/conversations/xmpp/jingle/OnTransportConnected.java b/src/eu/siacs/conversations/xmpp/jingle/OnTransportConnected.java
index 7d9a084a..38f03c5d 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/OnTransportConnected.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/OnTransportConnected.java
@@ -2,5 +2,6 @@ package eu.siacs.conversations.xmpp.jingle;
public interface OnTransportConnected {
public void failed();
+
public void established();
}
diff --git a/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java b/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java
index 494ff0d6..1e8e3fd6 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java
@@ -4,17 +4,17 @@ import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xmpp.jingle.JingleFile;
public class Content extends Element {
-
+
private String transportId;
-
+
private Content(String name) {
super(name);
}
-
+
public Content() {
super("content");
}
-
+
public Content(String creator, String name) {
super("content");
this.setAttribute("creator", creator);
@@ -24,39 +24,43 @@ public class Content extends Element {
public void setTransportId(String sid) {
this.transportId = sid;
}
-
+
public void setFileOffer(JingleFile actualFile, boolean otr) {
- Element description = this.addChild("description", "urn:xmpp:jingle:apps:file-transfer:3");
+ Element description = this.addChild("description",
+ "urn:xmpp:jingle:apps:file-transfer:3");
Element offer = description.addChild("offer");
Element file = offer.addChild("file");
- file.addChild("size").setContent(""+actualFile.getSize());
+ file.addChild("size").setContent("" + actualFile.getSize());
if (otr) {
- file.addChild("name").setContent(actualFile.getName()+".otr");
+ file.addChild("name").setContent(actualFile.getName() + ".otr");
} else {
file.addChild("name").setContent(actualFile.getName());
}
}
-
+
public Element getFileOffer() {
- Element description = this.findChild("description", "urn:xmpp:jingle:apps:file-transfer:3");
- if (description==null) {
+ Element description = this.findChild("description",
+ "urn:xmpp:jingle:apps:file-transfer:3");
+ if (description == null) {
return null;
}
Element offer = description.findChild("offer");
- if (offer==null) {
+ if (offer == null) {
return null;
}
return offer.findChild("file");
}
-
+
public void setFileOffer(Element fileOffer) {
- Element description = this.findChild("description", "urn:xmpp:jingle:apps:file-transfer:3");
- if (description==null) {
- description = this.addChild("description", "urn:xmpp:jingle:apps:file-transfer:3");
+ Element description = this.findChild("description",
+ "urn:xmpp:jingle:apps:file-transfer:3");
+ if (description == null) {
+ description = this.addChild("description",
+ "urn:xmpp:jingle:apps:file-transfer:3");
}
description.addChild(fileOffer);
}
-
+
public String getTransportId() {
if (hasSocks5Transport()) {
this.transportId = socks5transport().getAttribute("sid");
@@ -65,30 +69,34 @@ public class Content extends Element {
}
return this.transportId;
}
-
+
public Element socks5transport() {
- Element transport = this.findChild("transport", "urn:xmpp:jingle:transports:s5b:1");
- if (transport==null) {
- transport = this.addChild("transport", "urn:xmpp:jingle:transports:s5b:1");
+ Element transport = this.findChild("transport",
+ "urn:xmpp:jingle:transports:s5b:1");
+ if (transport == null) {
+ transport = this.addChild("transport",
+ "urn:xmpp:jingle:transports:s5b:1");
transport.setAttribute("sid", this.transportId);
}
return transport;
}
-
+
public Element ibbTransport() {
- Element transport = this.findChild("transport", "urn:xmpp:jingle:transports:ibb:1");
- if (transport==null) {
- transport = this.addChild("transport", "urn:xmpp:jingle:transports:ibb:1");
+ Element transport = this.findChild("transport",
+ "urn:xmpp:jingle:transports:ibb:1");
+ if (transport == null) {
+ transport = this.addChild("transport",
+ "urn:xmpp:jingle:transports:ibb:1");
transport.setAttribute("sid", this.transportId);
}
return transport;
}
-
+
public boolean hasSocks5Transport() {
return this.hasChild("transport", "urn:xmpp:jingle:transports:s5b:1");
}
-
+
public boolean hasIbbTransport() {
- return this.hasChild("transport","urn:xmpp:jingle:transports:ibb:1");
+ return this.hasChild("transport", "urn:xmpp:jingle:transports:ibb:1");
}
}
diff --git a/src/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java b/src/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java
index 55700609..77a73643 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java
@@ -7,18 +7,18 @@ public class JinglePacket extends IqPacket {
Content content = null;
Reason reason = null;
Element jingle = new Element("jingle");
-
+
@Override
public Element addChild(Element child) {
if ("jingle".equals(child.getName())) {
Element contentElement = child.findChild("content");
- if (contentElement!=null) {
+ if (contentElement != null) {
this.content = new Content();
this.content.setChildren(contentElement.getChildren());
this.content.setAttributes(contentElement.getAttributes());
}
Element reasonElement = child.findChild("reason");
- if (reasonElement!=null) {
+ if (reasonElement != null) {
this.reason = new Reason();
this.reason.setChildren(reasonElement.getChildren());
this.reason.setAttributes(reasonElement.getAttributes());
@@ -27,33 +27,33 @@ public class JinglePacket extends IqPacket {
}
return child;
}
-
+
public JinglePacket setContent(Content content) {
this.content = content;
return this;
}
-
+
public Content getJingleContent() {
- if (this.content==null) {
+ if (this.content == null) {
this.content = new Content();
}
return this.content;
}
-
+
public JinglePacket setReason(Reason reason) {
this.reason = reason;
return this;
}
-
+
public Reason getReason() {
return this.reason;
}
-
+
private void build() {
this.children.clear();
this.jingle.clearChildren();
this.jingle.setAttribute("xmlns", "urn:xmpp:jingle:1");
- if (this.content!=null) {
+ if (this.content != null) {
jingle.addChild(this.content);
}
if (this.reason != null) {
@@ -66,11 +66,11 @@ public class JinglePacket extends IqPacket {
public String getSessionId() {
return this.jingle.getAttribute("sid");
}
-
+
public void setSessionId(String sid) {
this.jingle.setAttribute("sid", sid);
}
-
+
@Override
public String toString() {
this.build();
@@ -80,11 +80,11 @@ public class JinglePacket extends IqPacket {
public void setAction(String action) {
this.jingle.setAttribute("action", action);
}
-
+
public String getAction() {
return this.jingle.getAttribute("action");
}
-
+
public void setInitiator(String initiator) {
this.jingle.setAttribute("initiator", initiator);
}
diff --git a/src/eu/siacs/conversations/xmpp/jingle/stanzas/Reason.java b/src/eu/siacs/conversations/xmpp/jingle/stanzas/Reason.java
index 195e0db7..610d5e76 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/stanzas/Reason.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/stanzas/Reason.java
@@ -6,7 +6,7 @@ public class Reason extends Element {
private Reason(String name) {
super(name);
}
-
+
public Reason() {
super("reason");
}
diff --git a/src/eu/siacs/conversations/xmpp/pep/Avatar.java b/src/eu/siacs/conversations/xmpp/pep/Avatar.java
index 6d5c1431..154fadf6 100644
--- a/src/eu/siacs/conversations/xmpp/pep/Avatar.java
+++ b/src/eu/siacs/conversations/xmpp/pep/Avatar.java
@@ -11,48 +11,51 @@ public class Avatar {
public int width;
public long size;
public String owner;
+
public byte[] getImageAsBytes() {
return Base64.decode(image, Base64.DEFAULT);
}
+
public String getFilename() {
- if (type==null) {
+ if (type == null) {
return sha1sum;
} else if (type.equalsIgnoreCase("image/webp")) {
- return sha1sum+".webp";
+ return sha1sum + ".webp";
} else if (type.equalsIgnoreCase("image/png")) {
- return sha1sum+".png";
+ return sha1sum + ".png";
} else {
return sha1sum;
}
}
-
+
public static Avatar parseMetadata(Element items) {
Element item = items.findChild("item");
- if (item==null) {
+ if (item == null) {
return null;
}
Element metadata = item.findChild("metadata");
- if (metadata==null) {
+ if (metadata == null) {
return null;
}
String primaryId = item.getAttribute("id");
- if (primaryId==null) {
+ if (primaryId == null) {
return null;
}
- for(Element child : metadata.getChildren()) {
- if (child.getName().equals("info") && primaryId.equals(child.getAttribute("id"))) {
+ for (Element child : metadata.getChildren()) {
+ if (child.getName().equals("info")
+ && primaryId.equals(child.getAttribute("id"))) {
Avatar avatar = new Avatar();
String height = child.getAttribute("height");
String width = child.getAttribute("width");
String size = child.getAttribute("bytes");
try {
- if (height!=null) {
+ if (height != null) {
avatar.height = Integer.parseInt(height);
}
- if (width!=null) {
+ if (width != null) {
avatar.width = Integer.parseInt(width);
}
- if (size!=null) {
+ if (size != null) {
avatar.size = Long.parseLong(size);
}
} catch (NumberFormatException e) {
diff --git a/src/eu/siacs/conversations/xmpp/stanzas/AbstractStanza.java b/src/eu/siacs/conversations/xmpp/stanzas/AbstractStanza.java
index 204a6bec..eef41c79 100644
--- a/src/eu/siacs/conversations/xmpp/stanzas/AbstractStanza.java
+++ b/src/eu/siacs/conversations/xmpp/stanzas/AbstractStanza.java
@@ -15,20 +15,20 @@ public class AbstractStanza extends Element {
public String getFrom() {
return getAttribute("from");
}
-
+
public String getId() {
return this.getAttribute("id");
}
-
+
public void setTo(String to) {
setAttribute("to", to);
}
-
+
public void setFrom(String from) {
- setAttribute("from",from);
+ setAttribute("from", from);
}
-
+
public void setId(String id) {
- setAttribute("id",id);
+ setAttribute("id", id);
}
}
diff --git a/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java b/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java
index 1d4e44d1..9df05e67 100644
--- a/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java
+++ b/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java
@@ -2,9 +2,8 @@ package eu.siacs.conversations.xmpp.stanzas;
import eu.siacs.conversations.xml.Element;
-
public class IqPacket extends AbstractStanza {
-
+
public static final int TYPE_ERROR = -1;
public static final int TYPE_SET = 0;
public static final int TYPE_RESULT = 1;
@@ -33,25 +32,25 @@ public class IqPacket extends AbstractStanza {
break;
}
}
-
+
public IqPacket() {
super("iq");
}
-
+
public Element query() {
Element query = findChild("query");
- if (query==null) {
+ if (query == null) {
query = addChild("query");
}
return query;
}
-
+
public Element query(String xmlns) {
Element query = query();
query.setAttribute("xmlns", xmlns);
return query();
}
-
+
public int getType() {
String type = getAttribute("type");
if ("error".equals(type)) {
@@ -66,7 +65,7 @@ public class IqPacket extends AbstractStanza {
return 1000;
}
}
-
+
public IqPacket generateRespone(int type) {
IqPacket packet = new IqPacket(type);
packet.setTo(this.getFrom());
diff --git a/src/eu/siacs/conversations/xmpp/stanzas/MessagePacket.java b/src/eu/siacs/conversations/xmpp/stanzas/MessagePacket.java
index 433b08c9..386d9dc8 100644
--- a/src/eu/siacs/conversations/xmpp/stanzas/MessagePacket.java
+++ b/src/eu/siacs/conversations/xmpp/stanzas/MessagePacket.java
@@ -9,20 +9,20 @@ public class MessagePacket extends AbstractStanza {
public static final int TYPE_GROUPCHAT = 3;
public static final int TYPE_ERROR = 4;
public static final int TYPE_HEADLINE = 5;
-
+
public MessagePacket() {
super("message");
}
-
+
public String getBody() {
Element body = this.findChild("body");
- if (body!=null) {
+ if (body != null) {
return body.getContent();
} else {
return null;
}
}
-
+
public void setBody(String text) {
this.children.remove(findChild("body"));
Element body = new Element("body");
@@ -33,7 +33,7 @@ public class MessagePacket extends AbstractStanza {
public void setType(int type) {
switch (type) {
case TYPE_CHAT:
- this.setAttribute("type","chat");
+ this.setAttribute("type", "chat");
break;
case TYPE_GROUPCHAT:
this.setAttribute("type", "groupchat");
@@ -43,14 +43,14 @@ public class MessagePacket extends AbstractStanza {
case TYPE_NORMAL:
break;
default:
- this.setAttribute("type","chat");
+ this.setAttribute("type", "chat");
break;
}
}
-
+
public int getType() {
String type = getAttribute("type");
- if (type==null) {
+ if (type == null) {
return TYPE_NORMAL;
} else if (type.equals("normal")) {
return TYPE_NORMAL;
diff --git a/src/eu/siacs/conversations/xmpp/stanzas/PresencePacket.java b/src/eu/siacs/conversations/xmpp/stanzas/PresencePacket.java
index dfbab78c..7ea32099 100644
--- a/src/eu/siacs/conversations/xmpp/stanzas/PresencePacket.java
+++ b/src/eu/siacs/conversations/xmpp/stanzas/PresencePacket.java
@@ -1,8 +1,7 @@
package eu.siacs.conversations.xmpp.stanzas;
-
public class PresencePacket extends AbstractStanza {
-
+
public PresencePacket() {
super("presence");
}
diff --git a/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/AckPacket.java b/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/AckPacket.java
index 6fe3ea2b..c936891c 100644
--- a/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/AckPacket.java
+++ b/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/AckPacket.java
@@ -6,8 +6,8 @@ public class AckPacket extends AbstractStanza {
public AckPacket(int sequence, int smVersion) {
super("a");
- this.setAttribute("xmlns","urn:xmpp:sm:"+smVersion);
- this.setAttribute("h", ""+sequence);
+ this.setAttribute("xmlns", "urn:xmpp:sm:" + smVersion);
+ this.setAttribute("h", "" + sequence);
}
}
diff --git a/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/EnablePacket.java b/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/EnablePacket.java
index 0ca7a4fd..78cd81ed 100644
--- a/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/EnablePacket.java
+++ b/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/EnablePacket.java
@@ -6,7 +6,7 @@ public class EnablePacket extends AbstractStanza {
public EnablePacket(int smVersion) {
super("enable");
- this.setAttribute("xmlns","urn:xmpp:sm:"+smVersion);
+ this.setAttribute("xmlns", "urn:xmpp:sm:" + smVersion);
this.setAttribute("resume", "true");
}
diff --git a/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/RequestPacket.java b/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/RequestPacket.java
index d42ae9b0..98cfc748 100644
--- a/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/RequestPacket.java
+++ b/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/RequestPacket.java
@@ -6,7 +6,7 @@ public class RequestPacket extends AbstractStanza {
public RequestPacket(int smVersion) {
super("r");
- this.setAttribute("xmlns","urn:xmpp:sm:"+smVersion);
+ this.setAttribute("xmlns", "urn:xmpp:sm:" + smVersion);
}
}
diff --git a/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/ResumePacket.java b/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/ResumePacket.java
index dcf32101..df039d5a 100644
--- a/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/ResumePacket.java
+++ b/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/ResumePacket.java
@@ -6,9 +6,9 @@ public class ResumePacket extends AbstractStanza {
public ResumePacket(String id, int sequence, int smVersion) {
super("resume");
- this.setAttribute("xmlns","urn:xmpp:sm:"+smVersion);
+ this.setAttribute("xmlns", "urn:xmpp:sm:" + smVersion);
this.setAttribute("previd", id);
- this.setAttribute("h", ""+sequence);
+ this.setAttribute("h", "" + sequence);
}
}