use of android.database.sqlite.SQLiteDatabase in project Conversations by siacs.
the class DatabaseBackend method storePreVerification.
public void storePreVerification(Account account, String name, String fingerprint, FingerprintStatus status) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(SQLiteAxolotlStore.ACCOUNT, account.getUuid());
values.put(SQLiteAxolotlStore.NAME, name);
values.put(SQLiteAxolotlStore.OWN, 0);
values.put(SQLiteAxolotlStore.FINGERPRINT, fingerprint);
values.putAll(status.toContentValues());
db.insert(SQLiteAxolotlStore.IDENTITIES_TABLENAME, null, values);
}
use of android.database.sqlite.SQLiteDatabase in project Conversations by siacs.
the class DatabaseBackend method numTrustedKeys.
public long numTrustedKeys(Account account, String name) {
SQLiteDatabase db = getReadableDatabase();
String[] args = { account.getUuid(), name, FingerprintStatus.Trust.TRUSTED.toString(), FingerprintStatus.Trust.VERIFIED.toString(), FingerprintStatus.Trust.VERIFIED_X509.toString() };
return DatabaseUtils.queryNumEntries(db, SQLiteAxolotlStore.IDENTITIES_TABLENAME, SQLiteAxolotlStore.ACCOUNT + " = ?" + " AND " + SQLiteAxolotlStore.NAME + " = ?" + " AND (" + SQLiteAxolotlStore.TRUST + " = ? OR " + SQLiteAxolotlStore.TRUST + " = ? OR " + SQLiteAxolotlStore.TRUST + " = ?)" + " AND " + SQLiteAxolotlStore.ACTIVE + " > 0", args);
}
use of android.database.sqlite.SQLiteDatabase in project AsmackService by rtreffer.
the class Database method hasIdentity.
/**
* Check if a xmpp identity is available for a given account.
* @param context The current context.
* @param identity The xmpp identity.
* @param jid The account jid.
* @param factory A cursor factory (may be null).
* @return True if the identity is available.
*/
public static synchronized boolean hasIdentity(Context context, XmppIdentity identity, String jid, CursorFactory factory) {
SQLiteDatabase database = getDatabase(context, factory);
Cursor result = database.query("feature", new String[] { "_id" }, "(jid=? OR (jid IS NULL)) AND " + "category=? AND type=? AND lang=? AND name=?", new String[] { jid, identity.getCategory(), identity.getType(), identity.getLang(), identity.getName() }, null, null, null);
boolean identityAvailable = result.getCount() > 0;
result.close();
return identityAvailable;
}
use of android.database.sqlite.SQLiteDatabase in project AsmackService by rtreffer.
the class Database method addIdentity.
/**
* Add a xmpp identity to a given account.
* @param context The current context.
* @param identity The xmpp identity.
* @param jid The account jid.
* @param factory A cursor factory (may be null).
*/
public static synchronized void addIdentity(Context context, String jid, XmppIdentity identity, CursorFactory factory) {
if (hasIdentity(context, identity, jid, factory)) {
return;
}
SQLiteDatabase database = getDatabase(context, factory);
ContentValues values = new ContentValues();
if (jid != null) {
values.put("jid", jid);
}
values.put("category", identity.getCategory());
values.put("type", identity.getType());
values.put("lang", identity.getLang());
values.put("name", identity.getName());
database.insert("identity", "_id", values);
}
use of android.database.sqlite.SQLiteDatabase in project AsmackService by rtreffer.
the class Database method getFeatures.
/**
* Retrieve a list of all features enabled on a given connection.
* @param context The current context.
* @param jid The user jid.
* @param factory A cursor factory (may be null).
* @return An array of enabled features.
*/
public static synchronized String[] getFeatures(Context context, String jid, CursorFactory factory) {
ArrayList<String> features = new ArrayList<String>();
SQLiteDatabase database = getDatabase(context, factory);
Cursor result = database.query(true, "feature", new String[] { "ver" }, "(jid=? OR (jid IS NULL))", new String[] { jid }, null, null, "ver ASC", null);
features.ensureCapacity(result.getCount() + 1);
if (result.getCount() > 0) {
int verId = result.getColumnIndex("ver");
result.moveToFirst();
do {
features.add(result.getString(verId));
result.moveToNext();
} while (!result.isAfterLast());
}
result.close();
String[] output = new String[features.size()];
return features.toArray(output);
}
Aggregations