aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java11
-rw-r--r--src/main/java/eu/siacs/conversations/persistance/FileBackend.java29
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java144
3 files changed, 90 insertions, 94 deletions
diff --git a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java
index c96d116d..b8454d5e 100644
--- a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java
+++ b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java
@@ -1,5 +1,7 @@
package eu.siacs.conversations.generator;
+import android.util.Base64;
+
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
@@ -8,18 +10,17 @@ import java.util.List;
import eu.siacs.conversations.services.XmppConnectionService;
-import android.util.Base64;
-
public abstract class AbstractGenerator {
- public final String[] FEATURES = { "urn:xmpp:jingle:1",
+ public final String[] FEATURES = {"urn:xmpp:jingle:1",
"urn:xmpp:jingle:apps:file-transfer:3",
"urn:xmpp:jingle:transports:s5b:1",
"urn:xmpp:jingle:transports:ibb:1", "urn:xmpp:receipts",
"urn:xmpp:chat-markers:0", "http://jabber.org/protocol/muc",
"jabber:x:conference", "http://jabber.org/protocol/caps",
"http://jabber.org/protocol/disco#info",
- "urn:xmpp:avatar:metadata+notify" };
- public final String IDENTITY_NAME = "Conversations 0.7";
+ "urn:xmpp:avatar:metadata+notify",
+ "urn:xmpp:ping"};
+ public final String IDENTITY_NAME = "Conversations 0.8.1";
public final String IDENTITY_TYPE = "phone";
protected XmppConnectionService mXmppConnectionService;
diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java
index 13daa27b..0241b77e 100644
--- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java
+++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java
@@ -164,29 +164,12 @@ public class FileBackend {
}
private int getRotation(Uri image) {
- if ("content".equals(image.getScheme())) {
- try {
- Cursor cursor = mXmppConnectionService
- .getContentResolver()
- .query(image,
- new String[] { MediaStore.Images.ImageColumns.ORIENTATION },
- null, null, null);
- if (cursor.getCount() != 1) {
- return -1;
- }
- cursor.moveToFirst();
- return cursor.getInt(0);
- } catch (IllegalArgumentException e) {
- return -1;
- }
- } else {
- try {
- InputStream is = mXmppConnectionService.getContentResolver()
- .openInputStream(image);
- return ExifHelper.getOrientation(is);
- } catch (FileNotFoundException e) {
- return 0;
- }
+ try {
+ InputStream is = mXmppConnectionService.getContentResolver()
+ .openInputStream(image);
+ return ExifHelper.getOrientation(is);
+ } catch (FileNotFoundException e) {
+ return 0;
}
}
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index 39dcb362..b907ea97 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -1,5 +1,19 @@
package eu.siacs.conversations.xmpp;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.os.Parcelable;
+import android.os.PowerManager;
+import android.os.PowerManager.WakeLock;
+import android.os.SystemClock;
+import android.preference.PreferenceManager;
+import android.util.Log;
+import android.util.SparseArray;
+
+import org.apache.http.conn.ssl.StrictHostnameVerifier;
+import org.xmlpull.v1.XmlPullParserException;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -22,31 +36,16 @@ import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
-
import javax.net.ssl.X509TrustManager;
-import org.apache.http.conn.ssl.StrictHostnameVerifier;
-import org.xmlpull.v1.XmlPullParserException;
-
import de.duenndns.ssl.MemorizingTrustManager;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.os.Parcelable;
-import android.os.PowerManager;
-import android.os.PowerManager.WakeLock;
-import android.os.SystemClock;
-import android.preference.PreferenceManager;
-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;
import eu.siacs.conversations.utils.DNSHelper;
-import eu.siacs.conversations.utils.zlib.ZLibOutputStream;
import eu.siacs.conversations.utils.zlib.ZLibInputStream;
+import eu.siacs.conversations.utils.zlib.ZLibOutputStream;
import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xml.Tag;
import eu.siacs.conversations.xml.TagWriter;
@@ -164,38 +163,47 @@ public class XmppConnection implements Runnable {
this.changeStatus(Account.STATUS_OFFLINE);
return;
} else if (values != null) {
- int i = 0;
- boolean socketError = true;
- while (socketError && values.size() > i) {
- Bundle namePort = (Bundle) values.get(i);
- try {
- String srvRecordServer = namePort.getString("name");
- int srvRecordPort = namePort.getInt("port");
- String srvIpServer = namePort.getString("ipv4");
- InetSocketAddress addr;
- if (srvIpServer!=null) {
- addr = new InetSocketAddress(srvIpServer, srvRecordPort);
- Log.d(Config.LOGTAG, account.getJid()
- + ": using values from dns " + srvRecordServer
- + "[" + srvIpServer + "]:" + srvRecordPort);
- } else {
- addr = new InetSocketAddress(srvRecordServer, srvRecordPort);
- Log.d(Config.LOGTAG, account.getJid()
- + ": using values from dns "
- + srvRecordServer + ":" + srvRecordPort);
- }
- socket = new Socket();
- socket.connect(addr, 20000);
- socketError = false;
- } catch (UnknownHostException e) {
- i++;
- } catch (IOException e) {
- i++;
+ int i = 0;
+ boolean socketError = true;
+ while (socketError && values.size() > i) {
+ Bundle namePort = (Bundle) values.get(i);
+ try {
+ String srvRecordServer = namePort.getString("name");
+ int srvRecordPort = namePort.getInt("port");
+ String srvIpServer = namePort.getString("ipv4");
+ InetSocketAddress addr;
+ if (srvIpServer != null) {
+ addr = new InetSocketAddress(srvIpServer, srvRecordPort);
+ Log.d(Config.LOGTAG, account.getJid()
+ + ": using values from dns " + srvRecordServer
+ + "[" + srvIpServer + "]:" + srvRecordPort);
+ } else {
+ addr = new InetSocketAddress(srvRecordServer, srvRecordPort);
+ Log.d(Config.LOGTAG, account.getJid()
+ + ": using values from dns "
+ + srvRecordServer + ":" + srvRecordPort);
}
+ socket = new Socket();
+ socket.connect(addr, 20000);
+ socketError = false;
+ } catch (UnknownHostException e) {
+ Log.d(Config.LOGTAG, account.getJid() + ": " + e.getMessage());
+ i++;
+ } catch (IOException e) {
+ Log.d(Config.LOGTAG, account.getJid() + ": " + e.getMessage());
+ i++;
}
- if (socketError) {
- throw new IOException();
+ }
+ if (socketError) {
+ this.changeStatus(Account.STATUS_SERVER_NOT_FOUND);
+ if (wakeLock.isHeld()) {
+ try {
+ wakeLock.release();
+ } catch (RuntimeException re) {
+ }
}
+ return;
+ }
} else if (result.containsKey("error")
&& "nosrv".equals(result.getString("error", null))) {
socket = new Socket(account.getServer(), 5222);
@@ -235,6 +243,7 @@ public class XmppConnection implements Runnable {
}
return;
} catch (IOException e) {
+ Log.d(Config.LOGTAG, account.getJid() + ": " + e.getMessage());
this.changeStatus(Account.STATUS_OFFLINE);
if (wakeLock.isHeld()) {
try {
@@ -244,6 +253,7 @@ public class XmppConnection implements Runnable {
}
return;
} catch (NoSuchAlgorithmException e) {
+ Log.d(Config.LOGTAG, account.getJid() + ": " + e.getMessage());
this.changeStatus(Account.STATUS_OFFLINE);
Log.d(Config.LOGTAG, "compression exception " + e.getMessage());
if (wakeLock.isHeld()) {
@@ -254,8 +264,8 @@ public class XmppConnection implements Runnable {
}
return;
} catch (XmlPullParserException e) {
+ Log.d(Config.LOGTAG, account.getJid() + ": " + e.getMessage());
this.changeStatus(Account.STATUS_OFFLINE);
- Log.d(Config.LOGTAG, "xml exception " + e.getMessage());
if (wakeLock.isHeld()) {
try {
wakeLock.release();
@@ -405,17 +415,17 @@ public class XmppConnection implements Runnable {
throws XmlPullParserException, IOException {
Element element;
switch (packetType) {
- case PACKET_IQ:
- element = new IqPacket();
- break;
- case PACKET_MESSAGE:
- element = new MessagePacket();
- break;
- case PACKET_PRESENCE:
- element = new PresencePacket();
- break;
- default:
- return null;
+ case PACKET_IQ:
+ element = new IqPacket();
+ break;
+ case PACKET_MESSAGE:
+ element = new MessagePacket();
+ break;
+ case PACKET_PRESENCE:
+ element = new PresencePacket();
+ break;
+ default:
+ return null;
}
element.setAttributes(currentTag.getAttributes());
Tag nextTag = tagReader.readTag();
@@ -429,7 +439,7 @@ public class XmppConnection implements Runnable {
if (packetType == PACKET_IQ
&& "jingle".equals(child.getName())
&& ("set".equalsIgnoreCase(type) || "get"
- .equalsIgnoreCase(type))) {
+ .equalsIgnoreCase(type))) {
element = new JinglePacket();
element.setAttributes(currentTag.getAttributes());
}
@@ -549,10 +559,14 @@ public class XmppConnection implements Runnable {
try {
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(null,
- new X509TrustManager[] { this.mMemorizingTrustManager },
+ new X509TrustManager[]{this.mMemorizingTrustManager},
mRandom);
SSLSocketFactory factory = sc.getSocketFactory();
+ if (factory == null) {
+ throw new IOException("SSLSocketFactory was null");
+ }
+
HostnameVerifier verifier = this.mMemorizingTrustManager
.wrapHostnameVerifier(new StrictHostnameVerifier());
SSLSocket sslSocket = (SSLSocket) factory.createSocket(socket,
@@ -577,11 +591,9 @@ public class XmppConnection implements Runnable {
if (verifier != null
&& !verifier.verify(account.getServer(),
- sslSocket.getSession())) {
- Log.d(Config.LOGTAG, account.getJid()
- + ": host mismatch in TLS connection");
+ sslSocket.getSession())) {
sslSocket.close();
- throw new IOException();
+ throw new IOException("host mismatch in TLS connection");
}
tagReader.setInputStream(sslSocket.getInputStream());
tagWriter.setOutputStream(sslSocket.getOutputStream());
@@ -707,14 +719,14 @@ public class XmppConnection implements Runnable {
@Override
public void onIqPacketReceived(Account account,
- IqPacket packet) {
+ IqPacket packet) {
if (packet.getType() == IqPacket.TYPE_RESULT) {
account.setOption(Account.OPTION_REGISTER,
false);
changeStatus(Account.STATUS_REGISTRATION_SUCCESSFULL);
} else if (packet.hasChild("error")
&& (packet.findChild("error")
- .hasChild("conflict"))) {
+ .hasChild("conflict"))) {
changeStatus(Account.STATUS_REGISTRATION_CONFLICT);
} else {
changeStatus(Account.STATUS_REGISTRATION_FAILED);
@@ -904,7 +916,7 @@ public class XmppConnection implements Runnable {
}
private synchronized void sendPacket(final AbstractStanza packet,
- PacketReceived callback) {
+ PacketReceived callback) {
if (packet.getName().equals("iq") || packet.getName().equals("message")
|| packet.getName().equals("presence")) {
++stanzasSent;