private Cursor getUnarchivedConversationList() { List<Cursor> cursorList = new LinkedList<>(); cursorList.add(DatabaseFactory.getThreadDatabase(context).getConversationList()); int archivedCount = DatabaseFactory.getThreadDatabase(context).getArchivedConversationListCount(); if (archivedCount > 0) { MatrixCursor switchToArchiveCursor = new MatrixCursor( new String[] { ThreadDatabase.ID, ThreadDatabase.DATE, ThreadDatabase.MESSAGE_COUNT, ThreadDatabase.RECIPIENT_IDS, ThreadDatabase.SNIPPET, ThreadDatabase.READ, ThreadDatabase.TYPE, ThreadDatabase.SNIPPET_TYPE, ThreadDatabase.SNIPPET_URI, ThreadDatabase.ARCHIVED, ThreadDatabase.STATUS, ThreadDatabase.RECEIPT_COUNT, ThreadDatabase.EXPIRES_IN }, 1); switchToArchiveCursor.addRow( new Object[] { -1L, System.currentTimeMillis(), archivedCount, "-1", null, 1, ThreadDatabase.DistributionTypes.ARCHIVE, 0, null, 0, -1, 0, 0 }); cursorList.add(switchToArchiveCursor); } return new MergeCursor(cursorList.toArray(new Cursor[0])); }
private void handleSentMessage(Intent intent) { long messageId = intent.getLongExtra("message_id", -1); int result = intent.getIntExtra("ResultCode", -31337); boolean upgraded = intent.getBooleanExtra("upgraded", false); boolean push = intent.getBooleanExtra("push", false); Log.w("SMSReceiverService", "Intent resultcode: " + result); Log.w("SMSReceiverService", "Running sent callback: " + messageId); if (result == Activity.RESULT_OK) { SmsDatabase database = DatabaseFactory.getSmsDatabase(context); Cursor cursor = database.getMessage(messageId); SmsDatabase.Reader reader = database.readerFor(cursor); database.markAsSent(messageId); if (upgraded) database.markAsSecure(messageId); if (push) database.markAsPush(messageId); SmsMessageRecord record = reader.getNext(); if (record != null && record.isEndSession()) { Log.w("SmsSender", "Ending session..."); Session.abortSessionFor(context, record.getIndividualRecipient()); KeyExchangeProcessor.broadcastSecurityUpdateEvent(context, record.getThreadId()); } unregisterForRadioChanges(); } else if (result == SmsManager.RESULT_ERROR_NO_SERVICE || result == SmsManager.RESULT_ERROR_RADIO_OFF) { DatabaseFactory.getSmsDatabase(context).markAsOutbox(messageId); toastHandler .obtainMessage( 0, context.getString(R.string.SmsReceiver_currently_unable_to_send_your_sms_message)) .sendToTarget(); registerForRadioChanges(); } else { long threadId = DatabaseFactory.getSmsDatabase(context).getThreadIdForMessage(messageId); Recipients recipients = DatabaseFactory.getThreadDatabase(context).getRecipientsForThreadId(threadId); DatabaseFactory.getSmsDatabase(context).markAsSentFailed(messageId); MessageNotifier.notifyMessageDeliveryFailed(context, recipients, threadId); unregisterForRadioChanges(); } }
private void createConversationIfNecessary(Intent intent) { long thread = intent.getLongExtra("thread_id", -1L); Recipients recipients = null; if (intent.getAction() != null && intent.getAction().equals("android.intent.action.SENDTO")) { try { recipients = RecipientFactory.getRecipientsFromString( this, intent.getData().getSchemeSpecificPart()); thread = DatabaseFactory.getThreadDatabase(this).getThreadIdIfExistsFor(recipients); } catch (RecipientFormattingException rfe) { recipients = null; } } else { recipients = intent.getParcelableExtra("recipients"); } if (recipients != null) { createConversation(thread, recipients); intent.putExtra("thread_id", -1L); intent.putExtra("recipients", (Parcelable) null); intent.setAction(null); } }
private Cursor getFilteredConversationList(String filter) { List<String> numbers = ContactAccessor.getInstance().getNumbersForThreadSearchFilter(context, filter); return DatabaseFactory.getThreadDatabase(context).getFilteredConversationList(numbers); }
private Cursor getArchivedConversationList() { return DatabaseFactory.getThreadDatabase(context).getArchivedConversationList(); }