From 9a796df2a3f022b6c437427ac10360b24e303613 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 11 Dec 2017 15:56:15 +0100 Subject: [PATCH] add getAccountJids to DatabaseBackend --- .../persistance/DatabaseBackend.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java index d61c7f0b6..39b71e849 100644 --- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -28,6 +28,7 @@ import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -745,6 +746,25 @@ public class DatabaseBackend extends SQLiteOpenHelper { return getAccounts(db); } + public Collection getAccountJids() { + SQLiteDatabase db = this.getReadableDatabase(); + final List jids = new ArrayList<>(); + final String[] columns = new String[]{Account.USERNAME, Account.SERVER}; + Cursor cursor = db.query(Account.TABLENAME,columns,null,null,null,null,null); + try { + while(cursor.moveToNext()) { + jids.add(Jid.fromParts(cursor.getString(0),cursor.getString(1),null)); + } + return jids; + } catch (Exception e) { + return jids; + } finally { + if (cursor != null) { + cursor.close(); + } + } + } + private List getAccounts(SQLiteDatabase db) { List list = new ArrayList<>(); Cursor cursor = db.query(Account.TABLENAME, null, null, null, null,