use of net.sqlcipher.database.SQLiteDatabase in project Signal-Android by signalapp.
the class MediaDatabase method getGalleryMediaForThread.
public Cursor getGalleryMediaForThread(long threadId) {
SQLiteDatabase database = databaseHelper.getReadableDatabase();
Cursor cursor = database.rawQuery(GALLERY_MEDIA_QUERY, new String[] { threadId + "" });
setNotifyConverationListeners(cursor, threadId);
return cursor;
}
use of net.sqlcipher.database.SQLiteDatabase in project Signal-Android by signalapp.
the class MessagingDatabase method setMismatchedIdentity.
public void setMismatchedIdentity(long messageId, final Address address, final IdentityKey identityKey) {
List<IdentityKeyMismatch> items = new ArrayList<IdentityKeyMismatch>() {
{
add(new IdentityKeyMismatch(address, identityKey));
}
};
IdentityKeyMismatchList document = new IdentityKeyMismatchList(items);
SQLiteDatabase database = databaseHelper.getWritableDatabase();
database.beginTransaction();
try {
setDocument(database, messageId, MISMATCHED_IDENTITIES, document);
database.setTransactionSuccessful();
} catch (IOException ioe) {
Log.w(TAG, ioe);
} finally {
database.endTransaction();
}
}
use of net.sqlcipher.database.SQLiteDatabase in project Signal-Android by signalapp.
the class MessagingDatabase method addToDocument.
protected <T extends Document<I>, I> void addToDocument(long messageId, String column, List<I> objects, Class<T> clazz) throws IOException {
SQLiteDatabase database = databaseHelper.getWritableDatabase();
database.beginTransaction();
try {
T document = getDocument(database, messageId, column, clazz);
document.getList().addAll(objects);
setDocument(database, messageId, column, document);
database.setTransactionSuccessful();
} finally {
database.endTransaction();
}
}
use of net.sqlcipher.database.SQLiteDatabase in project Signal-Android by signalapp.
the class MmsDatabase method updateMailboxBitmask.
private void updateMailboxBitmask(long id, long maskOff, long maskOn, Optional<Long> threadId) {
SQLiteDatabase db = databaseHelper.getWritableDatabase();
db.execSQL("UPDATE " + TABLE_NAME + " SET " + MESSAGE_BOX + " = (" + MESSAGE_BOX + " & " + (Types.TOTAL_MASK - maskOff) + " | " + maskOn + " )" + " WHERE " + ID + " = ?", new String[] { id + "" });
if (threadId.isPresent()) {
DatabaseFactory.getThreadDatabase(context).update(threadId.get(), false);
}
}
use of net.sqlcipher.database.SQLiteDatabase in project Signal-Android by signalapp.
the class MmsDatabase method deleteMessagesInThreadBeforeDate.
/*package*/
void deleteMessagesInThreadBeforeDate(long threadId, long date) {
Cursor cursor = null;
try {
SQLiteDatabase db = databaseHelper.getReadableDatabase();
String where = THREAD_ID + " = ? AND (CASE (" + MESSAGE_BOX + " & " + Types.BASE_TYPE_MASK + ") ";
for (long outgoingType : Types.OUTGOING_MESSAGE_TYPES) {
where += " WHEN " + outgoingType + " THEN " + DATE_SENT + " < " + date;
}
where += (" ELSE " + DATE_RECEIVED + " < " + date + " END)");
Log.w("MmsDatabase", "Executing trim query: " + where);
cursor = db.query(TABLE_NAME, new String[] { ID }, where, new String[] { threadId + "" }, null, null, null);
while (cursor != null && cursor.moveToNext()) {
Log.w("MmsDatabase", "Trimming: " + cursor.getLong(0));
delete(cursor.getLong(0));
}
} finally {
if (cursor != null)
cursor.close();
}
}
Aggregations