aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/eu/siacs/conversations/persistance/DatabaseBackend.java18
-rw-r--r--src/eu/siacs/conversations/persistance/FileBackend.java22
-rw-r--r--src/eu/siacs/conversations/services/AvatarService.java1
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java7
4 files changed, 22 insertions, 26 deletions
diff --git a/src/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/eu/siacs/conversations/persistance/DatabaseBackend.java
index b49cf4e6..12e5e251 100644
--- a/src/eu/siacs/conversations/persistance/DatabaseBackend.java
+++ b/src/eu/siacs/conversations/persistance/DatabaseBackend.java
@@ -332,4 +332,22 @@ public class DatabaseBackend extends SQLiteOpenHelper {
cursor.moveToFirst();
return Account.fromCursor(cursor);
}
+
+ public List<Message> getImageMessages(Conversation conversation) {
+ ArrayList<Message> list = new ArrayList<Message>();
+ SQLiteDatabase db = this.getReadableDatabase();
+ Cursor cursor;
+ String[] selectionArgs = { conversation.getUuid(), String.valueOf(Message.TYPE_IMAGE) };
+ cursor = db.query(Message.TABLENAME, null, Message.CONVERSATION
+ + "=? AND "+Message.TYPE+"=?", selectionArgs, null, null,null);
+ if (cursor.getCount() > 0) {
+ cursor.moveToLast();
+ do {
+ Message message = Message.fromCursor(cursor);
+ message.setConversation(conversation);
+ list.add(message);
+ } while (cursor.moveToPrevious());
+ }
+ return list;
+ }
}
diff --git a/src/eu/siacs/conversations/persistance/FileBackend.java b/src/eu/siacs/conversations/persistance/FileBackend.java
index 5eccf15c..13daa27b 100644
--- a/src/eu/siacs/conversations/persistance/FileBackend.java
+++ b/src/eu/siacs/conversations/persistance/FileBackend.java
@@ -28,7 +28,6 @@ import android.util.Base64OutputStream;
import android.util.Log;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
-import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.DownloadableFile;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.services.XmppConnectionService;
@@ -215,27 +214,6 @@ public class FileBackend {
return thumbnail;
}
- public void removeFiles(Conversation conversation) {
- String prefix = mXmppConnectionService.getFilesDir().getAbsolutePath();
- String path = prefix + "/" + conversation.getAccount().getJid() + "/"
- + conversation.getContactJid();
- File file = new File(path);
- try {
- this.deleteFile(file);
- } catch (IOException e) {
- Log.d(Config.LOGTAG,
- "error deleting file: " + file.getAbsolutePath());
- }
- }
-
- private void deleteFile(File f) throws IOException {
- if (f.isDirectory()) {
- for (File c : f.listFiles())
- deleteFile(c);
- }
- f.delete();
- }
-
public Uri getTakePhotoUri() {
StringBuilder pathBuilder = new StringBuilder();
pathBuilder.append(Environment
diff --git a/src/eu/siacs/conversations/services/AvatarService.java b/src/eu/siacs/conversations/services/AvatarService.java
index c5bdd101..bd27b555 100644
--- a/src/eu/siacs/conversations/services/AvatarService.java
+++ b/src/eu/siacs/conversations/services/AvatarService.java
@@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
-import eu.siacs.conversations.Config;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Bookmark;
import eu.siacs.conversations.entities.Contact;
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 25ca48f2..ece110e5 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -567,13 +567,14 @@ public class XmppConnectionService extends Service {
&& conv.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) {
mJingleConnectionManager
.createNewConnection(message);
- } else if (message.getPresence() == null) {
- message.setStatus(Message.STATUS_WAITING);
}
} else {
mJingleConnectionManager.createNewConnection(message);
}
} else {
+ if (message.getEncryption() == Message.ENCRYPTION_OTR) {
+ conv.startOtrIfNeeded();
+ }
message.setStatus(Message.STATUS_WAITING);
}
} else {
@@ -590,6 +591,7 @@ public class XmppConnectionService extends Service {
send = true;
} else if (message.getPresence() == null) {
+ conv.startOtrIfNeeded();
message.setStatus(Message.STATUS_WAITING);
}
} else if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
@@ -991,7 +993,6 @@ public class XmppConnectionService extends Service {
public void clearConversationHistory(Conversation conversation) {
this.databaseBackend.deleteMessagesInConversation(conversation);
- this.fileBackend.removeFiles(conversation);
conversation.getMessages().clear();
updateConversationUi();
}