aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/eu/siacs/conversations/crypto/PgpEngine.java16
-rw-r--r--src/eu/siacs/conversations/entities/Message.java37
-rw-r--r--src/eu/siacs/conversations/http/HttpConnection.java4
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java4
4 files changed, 53 insertions, 8 deletions
diff --git a/src/eu/siacs/conversations/crypto/PgpEngine.java b/src/eu/siacs/conversations/crypto/PgpEngine.java
index 2696c7d2..c3935ff5 100644
--- a/src/eu/siacs/conversations/crypto/PgpEngine.java
+++ b/src/eu/siacs/conversations/crypto/PgpEngine.java
@@ -8,6 +8,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.net.URL;
import org.openintents.openpgp.OpenPgpError;
import org.openintents.openpgp.OpenPgpSignatureResult;
@@ -101,14 +102,25 @@ public class PgpEngine {
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
+ URL url = message.getImageParams().url;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(
outputFile.getAbsolutePath(), options);
int imageHeight = options.outHeight;
int imageWidth = options.outWidth;
- message.setBody(Long.toString(outputFile.getSize())
- + ',' + imageWidth + ',' + imageHeight);
+ if (url == null) {
+ message.setBody(Long.toString(outputFile
+ .getSize())
+ + '|'
+ + imageWidth
+ + '|'
+ + imageHeight);
+ } else {
+ message.setBody(url.toString() + "|"
+ + Long.toString(outputFile.getSize())
+ + '|' + imageWidth + '|' + imageHeight);
+ }
message.setEncryption(Message.ENCRYPTION_DECRYPTED);
PgpEngine.this.mXmppConnectionService
.updateMessage(message);
diff --git a/src/eu/siacs/conversations/entities/Message.java b/src/eu/siacs/conversations/entities/Message.java
index 212eb049..79b9b5ba 100644
--- a/src/eu/siacs/conversations/entities/Message.java
+++ b/src/eu/siacs/conversations/entities/Message.java
@@ -7,6 +7,7 @@ import java.util.Arrays;
import eu.siacs.conversations.Config;
import android.content.ContentValues;
import android.database.Cursor;
+import android.util.Log;
public class Message extends AbstractEntity {
@@ -405,14 +406,18 @@ public class Message extends AbstractEntity {
}
public ImageParams getImageParams() {
- ImageParams params = new ImageParams();
+ ImageParams params = getLegacyImageParams();
+ if (params!=null) {
+ return params;
+ }
+ params = new ImageParams();
if (this.downloadable != null) {
params.size = this.downloadable.getFileSize();
}
if (body == null) {
return params;
}
- String parts[] = body.split(",");
+ String parts[] = body.split("\\|");
if (parts.length == 1) {
try {
params.size = Long.parseLong(parts[0]);
@@ -465,6 +470,34 @@ public class Message extends AbstractEntity {
}
return params;
}
+
+ public ImageParams getLegacyImageParams() {
+ ImageParams params = new ImageParams();
+ if (body == null) {
+ return params;
+ }
+ String parts[] = body.split(",");
+ if (parts.length == 3) {
+ try {
+ params.size = Long.parseLong(parts[0]);
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ try {
+ params.width = Integer.parseInt(parts[1]);
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ try {
+ params.height = Integer.parseInt(parts[2]);
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ return params;
+ } else {
+ return null;
+ }
+ }
public class ImageParams {
public URL url;
diff --git a/src/eu/siacs/conversations/http/HttpConnection.java b/src/eu/siacs/conversations/http/HttpConnection.java
index 9b04decc..29837880 100644
--- a/src/eu/siacs/conversations/http/HttpConnection.java
+++ b/src/eu/siacs/conversations/http/HttpConnection.java
@@ -244,8 +244,8 @@ public class HttpConnection implements Downloadable {
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
int imageHeight = options.outHeight;
int imageWidth = options.outWidth;
- message.setBody(mUrl.toString() + "," + file.getSize() + ','
- + imageWidth + ',' + imageHeight);
+ message.setBody(mUrl.toString() + "|" + file.getSize() + '|'
+ + imageWidth + '|' + imageHeight);
message.setType(Message.TYPE_IMAGE);
mXmppConnectionService.updateMessage(message);
}
diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
index a0b2feb2..7e803f0b 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
@@ -98,8 +98,8 @@ public class JingleConnection implements Downloadable {
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
int imageHeight = options.outHeight;
int imageWidth = options.outWidth;
- message.setBody(Long.toString(file.getSize()) + ','
- + imageWidth + ',' + imageHeight);
+ message.setBody(Long.toString(file.getSize()) + '|'
+ + imageWidth + '|' + imageHeight);
mXmppConnectionService.databaseBackend.createMessage(message);
mXmppConnectionService.markMessage(message,
Message.STATUS_RECEIVED);