aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-12-16 22:42:54 +0100
committerChristian Schneppe <christian@pix-art.de>2017-12-16 22:42:54 +0100
commit06e5a94225232198657015824f0f6b436b22c010 (patch)
treefb5449ce9bdcb18cda0cac5239cd87ece171157b /src/main/java/de
parentb435a6656ced1c395caf6f74ba459409bbdb2b72 (diff)
add getAccountJids to DatabaseBackend
Diffstat (limited to 'src/main/java/de')
-rw-r--r--src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
index 1af09a621..ea7f00c87 100644
--- a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
+++ b/src/main/java/de/pixart/messenger/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;
@@ -756,6 +757,25 @@ public class DatabaseBackend extends SQLiteOpenHelper {
return getAccounts(db);
}
+ public Collection<Jid> getAccountJids() {
+ SQLiteDatabase db = this.getReadableDatabase();
+ final List<Jid> 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<Account> getAccounts(SQLiteDatabase db) {
List<Account> list = new ArrayList<>();
Cursor cursor = db.query(Account.TABLENAME, null, null, null, null,