Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 00c681e2 authored by Fahim Salam Chowdhury's avatar Fahim Salam Chowdhury 👽
Browse files

Merge branch 'tag 6.305 into 690-Update_to_upstream_6_305

parents d3ddc02c f6d81976
Loading
Loading
Loading
Loading
Loading
+33 −59
Original line number Diff line number Diff line
@@ -642,7 +642,7 @@ public class MessagingController {
        if (commandException != null && !syncListener.syncFailed) {
            String rootMessage = getRootCauseMessage(commandException);
            Timber.e("Root cause failure in %s:%s was '%s'", account, folderServerId, rootMessage);
            updateFolderStatus(account, folderServerId, rootMessage);
            updateFolderStatus(account, folderId, rootMessage);
            listener.synchronizeMailboxFailed(account, folderId, rootMessage);
        }
    }
@@ -657,14 +657,9 @@ public class MessagingController {
                    SYNC_FLAGS);
    }

    private void updateFolderStatus(Account account, String folderServerId, String status) {
        try {
            LocalStore localStore = localStoreProvider.getInstance(account);
            LocalFolder localFolder = localStore.getFolder(folderServerId);
            localFolder.setStatus(status);
        } catch (MessagingException e) {
            Timber.w(e, "Couldn't update folder status for folder %s", folderServerId);
        }
    private void updateFolderStatus(Account account, long folderId, String status) {
        MessageStore messageStore = messageStoreManager.getMessageStore(account);
        messageStore.setStatus(folderId, status);
    }

    public void handleAuthenticationFailure(Account account, boolean incoming) {
@@ -1260,51 +1255,37 @@ public class MessagingController {
        );
    }

    private void loadMessageRemoteSynchronous(Account account, long folderId, String uid,
    private void loadMessageRemoteSynchronous(Account account, long folderId, String messageServerId,
            MessagingListener listener, boolean loadPartialFromSearch) {
        try {
            LocalStore localStore = localStoreProvider.getInstance(account);
            LocalFolder localFolder = localStore.getFolder(folderId);
            localFolder.open();
            String folderServerId = localFolder.getServerId();
            if (messageServerId.startsWith(K9.LOCAL_UID_PREFIX)) {
                throw new IllegalArgumentException("Must not be called with a local UID");
            }

            LocalMessage message = localFolder.getMessage(uid);
            MessageStore messageStore = messageStoreManager.getMessageStore(account);

            String folderServerId = messageStore.getFolderServerId(folderId);
            if (folderServerId == null) {
                throw new IllegalStateException("Folder not found (ID: " + folderId + ")");
            }

            if (uid.startsWith(K9.LOCAL_UID_PREFIX)) {
                Timber.w("Message has local UID so cannot download fully.");
                // ASH move toast
                android.widget.Toast.makeText(context,
                        "Message has local UID so cannot download fully",
                        android.widget.Toast.LENGTH_LONG).show();
                // TODO: Using X_DOWNLOADED_FULL is wrong because it's only a partial message. But
                // one we can't download completely. Maybe add a new flag; X_PARTIAL_MESSAGE ?
                message.setFlag(Flag.X_DOWNLOADED_FULL, true);
                message.setFlag(Flag.X_DOWNLOADED_PARTIAL, false);
            } else {
            Backend backend = getBackend(account);

            if (loadPartialFromSearch) {
                SyncConfig syncConfig = createSyncConfig(account);
                    backend.downloadMessage(syncConfig, folderServerId, uid);
                backend.downloadMessage(syncConfig, folderServerId, messageServerId);
            } else {
                    backend.downloadCompleteMessage(folderServerId, uid);
                backend.downloadCompleteMessage(folderServerId, messageServerId);
            }

                message = localFolder.getMessage(uid);

                if (!loadPartialFromSearch) {
                    message.setFlag(Flag.X_DOWNLOADED_FULL, true);
                }
            }

            // now that we have the full message, refresh the headers
            for (MessagingListener l : getListeners(listener)) {
                l.loadMessageRemoteFinished(account, folderId, uid);
                l.loadMessageRemoteFinished(account, folderId, messageServerId);
            }
        } catch (Exception e) {
            for (MessagingListener l : getListeners(listener)) {
                l.loadMessageRemoteFailed(account, folderId, uid, e);
                l.loadMessageRemoteFailed(account, folderId, messageServerId, e);
            }

            notifyUserIfCertificateProblem(account, e, true);
            Timber.e(e, "Error while loading remote message");
        }
@@ -1959,26 +1940,19 @@ public class MessagingController {
        });
    }

    public void deleteDraft(final Account account, long id) {
        try {
    public void deleteDraft(Account account, long messageId) {
        Long folderId = account.getDraftsFolderId();
        if (folderId == null) {
            Timber.w("No Drafts folder configured. Can't delete draft.");
            return;
        }

            LocalStore localStore = localStoreProvider.getInstance(account);
            LocalFolder localFolder = localStore.getFolder(folderId);
            localFolder.open();
            String uid = localFolder.getMessageUidById(id);
            if (uid != null) {
                MessageReference messageReference = new MessageReference(account.getUuid(), folderId, uid);
        MessageStore messageStore = messageStoreManager.getMessageStore(account);
        String messageServerId = messageStore.getMessageServerId(messageId);
        MessageReference messageReference = new MessageReference(account.getUuid(), folderId, messageServerId);

        deleteMessage(messageReference);
    }
        } catch (MessagingException me) {
            Timber.e(me, "Error deleting draft");
        }
    }

    public void deleteThreads(final List<MessageReference> messages) {
        actOnMessagesGroupedByAccountAndFolder(messages, (account, messageFolder, accountMessages) -> {
+40 −0
Original line number Diff line number Diff line
package com.fsck.k9.helper

/**
 * Returns a [Set] containing the results of applying the given [transform] function to each element in the original
 * collection.
 *
 * If you know the size of the output or can make an educated guess, specify [expectedSize] as an optimization.
 * The initial capacity of the `Set` will be derived from this value.
 */
inline fun <T, R> Iterable<T>.mapToSet(expectedSize: Int? = null, transform: (T) -> R): Set<R> {
    return if (expectedSize != null) {
        mapTo(LinkedHashSet(setCapacity(expectedSize)), transform)
    } else {
        mapTo(mutableSetOf(), transform)
    }
}

/**
 * Returns a [Set] containing the results of applying the given [transform] function to each element in the original
 * collection.
 *
 * The size of the output is expected to be equal to the size of the input. If that's not the case, please use
 * [mapToSet] instead.
 */
inline fun <T, R> Collection<T>.mapCollectionToSet(transform: (T) -> R): Set<R> {
    return mapToSet(expectedSize = size, transform)
}

// A copy of Kotlin's internal mapCapacity() for the JVM
fun setCapacity(expectedSize: Int): Int = when {
    // We are not coercing the value to a valid one and not throwing an exception. It is up to the caller to
    // properly handle negative values.
    expectedSize < 0 -> expectedSize
    expectedSize < 3 -> expectedSize + 1
    expectedSize < INT_MAX_POWER_OF_TWO -> ((expectedSize / 0.75F) + 1.0F).toInt()
    // any large value
    else -> Int.MAX_VALUE
}

private const val INT_MAX_POWER_OF_TWO: Int = 1 shl (Int.SIZE_BITS - 2)
+0 −9
Original line number Diff line number Diff line
@@ -117,10 +117,6 @@ public class LocalFolder {
        return lastChecked;
    }

    public String getStatus() {
        return status;
    }

    public long getDatabaseId() {
        return databaseId;
    }
@@ -297,11 +293,6 @@ public class LocalFolder {
        }
    }

    public void setStatus(final String status) throws MessagingException {
        this.status = status;
        updateFolderColumn("status", status);
    }

    private void updateFolderColumn(final String column, final Object value) throws MessagingException {
        this.localStore.getDatabase().execute(false, new DbCallback<Void>() {
            @Override
+2 −2
Original line number Diff line number Diff line
@@ -49,8 +49,8 @@ android {
        applicationId "foundation.e.mail"
        testApplicationId "foundation.e.mail.tests"

        versionCode 33003
        versionName '6.303'
        versionCode 33005
        versionName '6.305'

        // Keep in sync with the resource string array 'supported_languages'
        resConfigs "in", "br", "ca", "cs", "cy", "da", "de", "et", "en", "en_GB", "es", "eo", "eu", "fr", "gd", "gl",
+0 −14
Original line number Diff line number Diff line
@@ -223,10 +223,6 @@
                <action android:name="org.autocrypt.PEER_ACTION"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>

            <meta-data
                android:name="android.service.chooser.chooser_target_service"
                android:value="com.fsck.k9.directshare.K9ChooserTargetService" />
        </activity>

        <!-- Search Activity - searchable -->
@@ -365,16 +361,6 @@
            android:name=".service.DatabaseUpgradeService"
            android:exported="false"/>


        <service
            android:name="com.fsck.k9.directshare.K9ChooserTargetService"
            android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE"
            android:exported="false">
            <intent-filter>
                <action android:name="android.service.chooser.ChooserTargetService" />
            </intent-filter>
        </service>

        <service
            android:name="com.fsck.k9.account.AccountRemoverService"
            android:permission="android.permission.BIND_JOB_SERVICE"/>
Loading