use of eu.siacs.conversations.xmpp.InvalidJid in project Conversations by siacs.
the class DatabaseBackend method getConversations.
public CopyOnWriteArrayList<Conversation> getConversations(int status) {
CopyOnWriteArrayList<Conversation> list = new CopyOnWriteArrayList<>();
SQLiteDatabase db = this.getReadableDatabase();
String[] selectionArgs = { Integer.toString(status) };
Cursor cursor = db.rawQuery("select * from " + Conversation.TABLENAME + " where " + Conversation.STATUS + " = ? and " + Conversation.CONTACTJID + " is not null order by " + Conversation.CREATED + " desc", selectionArgs);
while (cursor.moveToNext()) {
final Conversation conversation = Conversation.fromCursor(cursor);
if (conversation.getJid() instanceof InvalidJid) {
continue;
}
list.add(conversation);
}
cursor.close();
return list;
}
use of eu.siacs.conversations.xmpp.InvalidJid in project Conversations by siacs.
the class DatabaseBackend method findConversation.
public Conversation findConversation(final Account account, final Jid contactJid) {
SQLiteDatabase db = this.getReadableDatabase();
String[] selectionArgs = { account.getUuid(), contactJid.asBareJid().toString() + "/%", contactJid.asBareJid().toString() };
Cursor cursor = db.query(Conversation.TABLENAME, null, Conversation.ACCOUNT + "=? AND (" + Conversation.CONTACTJID + " like ? OR " + Conversation.CONTACTJID + "=?)", selectionArgs, null, null, null);
if (cursor.getCount() == 0) {
cursor.close();
return null;
}
cursor.moveToFirst();
Conversation conversation = Conversation.fromCursor(cursor);
cursor.close();
if (conversation.getJid() instanceof InvalidJid) {
return null;
}
return conversation;
}
Aggregations