cleanup for clear conversation history. small otr fixes
This commit is contained in:
parent
1b62d94093
commit
e4567e7a62
|
@ -332,4 +332,22 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
||||||
cursor.moveToFirst();
|
cursor.moveToFirst();
|
||||||
return Account.fromCursor(cursor);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ import android.util.Base64OutputStream;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
import eu.siacs.conversations.entities.Conversation;
|
|
||||||
import eu.siacs.conversations.entities.DownloadableFile;
|
import eu.siacs.conversations.entities.DownloadableFile;
|
||||||
import eu.siacs.conversations.entities.Message;
|
import eu.siacs.conversations.entities.Message;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService;
|
import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
|
@ -215,27 +214,6 @@ public class FileBackend {
|
||||||
return thumbnail;
|
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() {
|
public Uri getTakePhotoUri() {
|
||||||
StringBuilder pathBuilder = new StringBuilder();
|
StringBuilder pathBuilder = new StringBuilder();
|
||||||
pathBuilder.append(Environment
|
pathBuilder.append(Environment
|
||||||
|
|
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
import eu.siacs.conversations.entities.Bookmark;
|
import eu.siacs.conversations.entities.Bookmark;
|
||||||
import eu.siacs.conversations.entities.Contact;
|
import eu.siacs.conversations.entities.Contact;
|
||||||
|
|
|
@ -567,13 +567,14 @@ public class XmppConnectionService extends Service {
|
||||||
&& conv.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) {
|
&& conv.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) {
|
||||||
mJingleConnectionManager
|
mJingleConnectionManager
|
||||||
.createNewConnection(message);
|
.createNewConnection(message);
|
||||||
} else if (message.getPresence() == null) {
|
|
||||||
message.setStatus(Message.STATUS_WAITING);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mJingleConnectionManager.createNewConnection(message);
|
mJingleConnectionManager.createNewConnection(message);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (message.getEncryption() == Message.ENCRYPTION_OTR) {
|
||||||
|
conv.startOtrIfNeeded();
|
||||||
|
}
|
||||||
message.setStatus(Message.STATUS_WAITING);
|
message.setStatus(Message.STATUS_WAITING);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -590,6 +591,7 @@ public class XmppConnectionService extends Service {
|
||||||
send = true;
|
send = true;
|
||||||
|
|
||||||
} else if (message.getPresence() == null) {
|
} else if (message.getPresence() == null) {
|
||||||
|
conv.startOtrIfNeeded();
|
||||||
message.setStatus(Message.STATUS_WAITING);
|
message.setStatus(Message.STATUS_WAITING);
|
||||||
}
|
}
|
||||||
} else if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
|
} else if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
|
||||||
|
@ -991,7 +993,6 @@ public class XmppConnectionService extends Service {
|
||||||
|
|
||||||
public void clearConversationHistory(Conversation conversation) {
|
public void clearConversationHistory(Conversation conversation) {
|
||||||
this.databaseBackend.deleteMessagesInConversation(conversation);
|
this.databaseBackend.deleteMessagesInConversation(conversation);
|
||||||
this.fileBackend.removeFiles(conversation);
|
|
||||||
conversation.getMessages().clear();
|
conversation.getMessages().clear();
|
||||||
updateConversationUi();
|
updateConversationUi();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue