Search in sources :

Example 6 with MessagingController

use of com.fsck.k9.controller.MessagingController in project k-9 by k9mail.

the class NotificationActionService method markMessagesAsRead.

private void markMessagesAsRead(Intent intent, Account account, MessagingController controller) {
    Timber.i("NotificationActionService marking messages as read");
    List<String> messageReferenceStrings = intent.getStringArrayListExtra(EXTRA_MESSAGE_REFERENCES);
    List<MessageReference> messageReferences = toMessageReferenceList(messageReferenceStrings);
    for (MessageReference messageReference : messageReferences) {
        String folderName = messageReference.getFolderName();
        String uid = messageReference.getUid();
        controller.setFlag(account, folderName, uid, Flag.SEEN, true);
    }
}
Also used : MessageReference(com.fsck.k9.activity.MessageReference)

Example 7 with MessagingController

use of com.fsck.k9.controller.MessagingController in project k-9 by k9mail.

the class NotificationActionService method archiveMessages.

private void archiveMessages(Intent intent, Account account, MessagingController controller) {
    Timber.i("NotificationActionService archiving messages");
    String archiveFolderName = account.getArchiveFolderName();
    if (archiveFolderName == null || (archiveFolderName.equals(account.getSpamFolderName()) && K9.confirmSpam()) || !isMovePossible(controller, account, archiveFolderName)) {
        Timber.w("Can not archive messages");
        return;
    }
    List<String> messageReferenceStrings = intent.getStringArrayListExtra(EXTRA_MESSAGE_REFERENCES);
    List<MessageReference> messageReferences = toMessageReferenceList(messageReferenceStrings);
    for (MessageReference messageReference : messageReferences) {
        if (controller.isMoveCapable(messageReference)) {
            String sourceFolderName = messageReference.getFolderName();
            controller.moveMessage(account, sourceFolderName, messageReference, archiveFolderName);
        }
    }
}
Also used : MessageReference(com.fsck.k9.activity.MessageReference)

Example 8 with MessagingController

use of com.fsck.k9.controller.MessagingController in project k-9 by k9mail.

the class MessagingController method getInstance.

public static synchronized MessagingController getInstance(Context context) {
    if (inst == null) {
        Context appContext = context.getApplicationContext();
        NotificationController notificationController = NotificationController.newInstance(appContext);
        Contacts contacts = Contacts.getInstance(context);
        TransportProvider transportProvider = TransportProvider.getInstance();
        inst = new MessagingController(appContext, notificationController, contacts, transportProvider);
    }
    return inst;
}
Also used : Context(android.content.Context) Contacts(com.fsck.k9.helper.Contacts) NotificationController(com.fsck.k9.notification.NotificationController) TransportProvider(com.fsck.k9.mail.TransportProvider)

Example 9 with MessagingController

use of com.fsck.k9.controller.MessagingController in project k-9 by k9mail.

the class SaveMessageTask method doInBackground.

@Override
protected Void doInBackground(Void... params) {
    final MessagingController messagingController = MessagingController.getInstance(context);
    Message draftMessage = messagingController.saveDraft(account, message, draftId, saveRemotely);
    draftId = messagingController.getId(draftMessage);
    android.os.Message msg = android.os.Message.obtain(handler, MessageCompose.MSG_SAVED_DRAFT, draftId);
    handler.sendMessage(msg);
    return null;
}
Also used : Message(com.fsck.k9.mail.Message) MessagingController(com.fsck.k9.controller.MessagingController)

Example 10 with MessagingController

use of com.fsck.k9.controller.MessagingController in project k-9 by k9mail.

the class Accounts method refresh.

private void refresh() {
    accounts.clear();
    accounts.addAll(Preferences.getPreferences(this).getAccounts());
    // see if we should show the welcome message
    //        if (accounts.length < 1) {
    //            WelcomeMessage.showWelcomeMessage(this);
    //            finish();
    //        }
    List<BaseAccount> newAccounts;
    if (!K9.isHideSpecialAccounts() && accounts.size() > 0) {
        if (mUnifiedInboxAccount == null || mAllMessagesAccount == null) {
            createSpecialAccounts();
        }
        newAccounts = new ArrayList<BaseAccount>(accounts.size() + SPECIAL_ACCOUNTS_COUNT);
        newAccounts.add(mUnifiedInboxAccount);
        newAccounts.add(mAllMessagesAccount);
    } else {
        newAccounts = new ArrayList<BaseAccount>(accounts.size());
    }
    newAccounts.addAll(accounts);
    mAdapter = new AccountsAdapter(newAccounts);
    getListView().setAdapter(mAdapter);
    if (!newAccounts.isEmpty()) {
        mHandler.progress(Window.PROGRESS_START);
    }
    pendingWork.clear();
    mHandler.refreshTitle();
    MessagingController controller = MessagingController.getInstance(getApplication());
    for (BaseAccount account : newAccounts) {
        pendingWork.put(account, "true");
        if (account instanceof Account) {
            Account realAccount = (Account) account;
            controller.getAccountStats(this, realAccount, mListener);
        } else if (K9.countSearchMessages() && account instanceof SearchAccount) {
            final SearchAccount searchAccount = (SearchAccount) account;
            controller.getSearchAccountStats(searchAccount, mListener);
        }
    }
}
Also used : SearchAccount(com.fsck.k9.search.SearchAccount) Account(com.fsck.k9.Account) BaseAccount(com.fsck.k9.BaseAccount) BaseAccount(com.fsck.k9.BaseAccount) MessagingController(com.fsck.k9.controller.MessagingController) SearchAccount(com.fsck.k9.search.SearchAccount)

Aggregations

MessagingController (com.fsck.k9.controller.MessagingController)8 MessageReference (com.fsck.k9.activity.MessageReference)5 Account (com.fsck.k9.Account)4 SearchAccount (com.fsck.k9.search.SearchAccount)3 BaseAccount (com.fsck.k9.BaseAccount)2 PendingIntent (android.app.PendingIntent)1 Context (android.content.Context)1 Intent (android.content.Intent)1 RemoteViews (android.widget.RemoteViews)1 AccountStats (com.fsck.k9.AccountStats)1 Preferences (com.fsck.k9.Preferences)1 MessageReferenceHelper.toMessageReferenceList (com.fsck.k9.activity.MessageReferenceHelper.toMessageReferenceList)1 MessageReferenceHelper.toMessageReferenceStringList (com.fsck.k9.activity.MessageReferenceHelper.toMessageReferenceStringList)1 UnreadWidgetConfiguration (com.fsck.k9.activity.UnreadWidgetConfiguration)1 SimpleMessagingListener (com.fsck.k9.controller.SimpleMessagingListener)1 Contacts (com.fsck.k9.helper.Contacts)1 Message (com.fsck.k9.mail.Message)1 TransportProvider (com.fsck.k9.mail.TransportProvider)1 TracingWakeLock (com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock)1 NotificationController (com.fsck.k9.notification.NotificationController)1