コード例 #1
0
  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();
    }
  }
コード例 #2
0
    private MmsDatabase.Reader getMmsReader() {
      if (mmsReader == null) {
        mmsReader =
            DatabaseFactory.getMmsDatabase(context).readerFor(masterSecret.orNull(), cursor);
      }

      return mmsReader;
    }
コード例 #3
0
 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();
 }
コード例 #4
0
 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();
 }
コード例 #5
0
  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();
  }
コード例 #6
0
ファイル: PartDatabase.java プロジェクト: sky921/SMSSecure
  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));
  }
コード例 #7
0
  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);
      }
    };
  }
コード例 #8
0
ファイル: PartDatabase.java プロジェクト: sky921/SMSSecure
  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));
  }
コード例 #9
0
 public void incrementDeliveryReceiptCount(SyncMessageId syncMessageId) {
   DatabaseFactory.getSmsDatabase(context).incrementDeliveryReceiptCount(syncMessageId);
   DatabaseFactory.getMmsDatabase(context).incrementDeliveryReceiptCount(syncMessageId);
 }
コード例 #10
0
  public int getConversationCount(long threadId) {
    int count = DatabaseFactory.getSmsDatabase(context).getMessageCountForThread(threadId);
    count += DatabaseFactory.getMmsDatabase(context).getMessageCountForThread(threadId);

    return count;
  }
コード例 #11
0
 public void deleteAllConversations() {
   DatabaseFactory.getSmsDatabase(context).deleteAllThreads();
   DatabaseFactory.getMmsDatabase(context).deleteAllThreads();
   DatabaseFactory.getDraftDatabase(context).clearAllDrafts();
   deleteAllThreads();
 }