public void trimThread(long threadId, int length) { Log.w("ThreadDatabase", "Trimming thread: " + threadId + " to: " + length); Cursor cursor = null; try { cursor = DatabaseFactory.getMmsSmsDatabase(context).getConversation(threadId); if (cursor != null && length > 0 && cursor.getCount() > length) { Log.w("ThreadDatabase", "Cursor count is greater than length!"); cursor.moveToPosition(length - 1); long lastTweetDate = cursor.getLong(cursor.getColumnIndexOrThrow(MmsSmsColumns.NORMALIZED_DATE_RECEIVED)); Log.w("ThreadDatabase", "Cut off tweet date: " + lastTweetDate); DatabaseFactory.getSmsDatabase(context) .deleteMessagesInThreadBeforeDate(threadId, lastTweetDate); DatabaseFactory.getMmsDatabase(context) .deleteMessagesInThreadBeforeDate(threadId, lastTweetDate); update(threadId, false); notifyConversationListeners(threadId); } } finally { if (cursor != null) cursor.close(); } }
private MmsDatabase.Reader getMmsReader() { if (mmsReader == null) { mmsReader = DatabaseFactory.getMmsDatabase(context).readerFor(masterSecret.orNull(), cursor); } return mmsReader; }
public void deleteConversations(Set<Long> selectedConversations) { DatabaseFactory.getSmsDatabase(context).deleteThreads(selectedConversations); DatabaseFactory.getMmsDatabase(context).deleteThreads(selectedConversations); DatabaseFactory.getDraftDatabase(context).clearDrafts(selectedConversations); deleteThreads(selectedConversations); notifyConversationListeners(selectedConversations); notifyConversationListListeners(); }
public void deleteConversation(long threadId) { DatabaseFactory.getSmsDatabase(context).deleteThread(threadId); DatabaseFactory.getMmsDatabase(context).deleteThread(threadId); DatabaseFactory.getDraftDatabase(context).clearDrafts(threadId); deleteThread(threadId); notifyConversationListeners(threadId); notifyConversationListListeners(); }
public void setAllThreadsRead() { SQLiteDatabase db = databaseHelper.getWritableDatabase(); ContentValues contentValues = new ContentValues(1); contentValues.put(READ, 1); db.update(TABLE_NAME, contentValues, null, null); DatabaseFactory.getSmsDatabase(context).setAllMessagesRead(); DatabaseFactory.getMmsDatabase(context).setAllMessagesRead(); notifyConversationListListeners(); }
public void updateFailedDownloadedPart(long messageId, PartId partId, PduPart part) throws MmsException { SQLiteDatabase database = databaseHelper.getWritableDatabase(); part.setContentDisposition(new byte[0]); part.setPendingPush(false); ContentValues values = getContentValuesForPart(part); values.put(DATA, (String) null); database.update(TABLE_NAME, values, PART_ID_WHERE, partId.toStrings()); notifyConversationListeners( DatabaseFactory.getMmsDatabase(context).getThreadIdForMessage(messageId)); }
public List<SyncMessageId> setRead(long threadId) { ContentValues contentValues = new ContentValues(1); contentValues.put(READ, 1); SQLiteDatabase db = databaseHelper.getWritableDatabase(); db.update(TABLE_NAME, contentValues, ID_WHERE, new String[] {threadId + ""}); final List<SyncMessageId> smsRecords = DatabaseFactory.getSmsDatabase(context).setMessagesRead(threadId); final List<SyncMessageId> mmsRecords = DatabaseFactory.getMmsDatabase(context).setMessagesRead(threadId); notifyConversationListListeners(); return new LinkedList<SyncMessageId>() { { addAll(smsRecords); addAll(mmsRecords); } }; }
public void updateDownloadedPart( MasterSecret masterSecret, long messageId, PartId partId, PduPart part, InputStream data) throws MmsException { SQLiteDatabase database = databaseHelper.getWritableDatabase(); Pair<File, Long> partData = writePartData(masterSecret, part, data); part.setContentDisposition(new byte[0]); part.setPendingPush(false); ContentValues values = getContentValuesForPart(part); if (partData != null) { values.put(DATA, partData.first.getAbsolutePath()); values.put(SIZE, partData.second); } database.update(TABLE_NAME, values, PART_ID_WHERE, partId.toStrings()); thumbnailExecutor.submit(new ThumbnailFetchCallable(masterSecret, partId)); notifyConversationListeners( DatabaseFactory.getMmsDatabase(context).getThreadIdForMessage(messageId)); }
public void incrementDeliveryReceiptCount(SyncMessageId syncMessageId) { DatabaseFactory.getSmsDatabase(context).incrementDeliveryReceiptCount(syncMessageId); DatabaseFactory.getMmsDatabase(context).incrementDeliveryReceiptCount(syncMessageId); }
public int getConversationCount(long threadId) { int count = DatabaseFactory.getSmsDatabase(context).getMessageCountForThread(threadId); count += DatabaseFactory.getMmsDatabase(context).getMessageCountForThread(threadId); return count; }
public void deleteAllConversations() { DatabaseFactory.getSmsDatabase(context).deleteAllThreads(); DatabaseFactory.getMmsDatabase(context).deleteAllThreads(); DatabaseFactory.getDraftDatabase(context).clearAllDrafts(); deleteAllThreads(); }