Search in sources :

Example 41 with FetchProfile

use of com.fsck.k9.mail.FetchProfile in project k-9 by k9mail.

the class ImapFolderTest method fetch_withBodyFetchProfileAndNoMaximumDownloadSize_shouldIssueRespectiveCommand.

@Test
public void fetch_withBodyFetchProfileAndNoMaximumDownloadSize_shouldIssueRespectiveCommand() throws Exception {
    ImapFolder folder = createFolder("Folder");
    prepareImapFolderForOpen(OPEN_MODE_RO);
    folder.open(OPEN_MODE_RO);
    when(imapConnection.readResponse(any(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
    List<ImapMessage> messages = createImapMessages("1");
    FetchProfile fetchProfile = createFetchProfile(Item.BODY);
    folder.fetch(messages, fetchProfile, null);
    verify(imapConnection).sendCommand("UID FETCH 1 (UID BODY.PEEK[])", false);
}
Also used : FetchProfile(com.fsck.k9.mail.FetchProfile) Test(org.junit.Test)

Example 42 with FetchProfile

use of com.fsck.k9.mail.FetchProfile in project k-9 by k9mail.

the class ImapFolderTest method fetch_withNullMessageListArgument_shouldDoNothing.

@Test
public void fetch_withNullMessageListArgument_shouldDoNothing() throws Exception {
    ImapFolder folder = createFolder("Folder");
    FetchProfile fetchProfile = createFetchProfile();
    folder.fetch(null, fetchProfile, null);
    verifyNoMoreInteractions(imapStore);
}
Also used : FetchProfile(com.fsck.k9.mail.FetchProfile) Test(org.junit.Test)

Example 43 with FetchProfile

use of com.fsck.k9.mail.FetchProfile in project k-9 by k9mail.

the class ImapFolderTest method fetch_withEnvelopeFetchProfile_shouldIssueRespectiveCommand.

@Test
public void fetch_withEnvelopeFetchProfile_shouldIssueRespectiveCommand() throws Exception {
    ImapFolder folder = createFolder("Folder");
    prepareImapFolderForOpen(OPEN_MODE_RO);
    folder.open(OPEN_MODE_RO);
    when(imapConnection.readResponse(any(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
    List<ImapMessage> messages = createImapMessages("1");
    FetchProfile fetchProfile = createFetchProfile(Item.ENVELOPE);
    folder.fetch(messages, fetchProfile, null);
    verify(imapConnection).sendCommand("UID FETCH 1 (UID INTERNALDATE RFC822.SIZE BODY.PEEK[HEADER.FIELDS " + "(date subject from content-type to cc reply-to message-id references in-reply-to X-K9mail-Identity)]" + ")", false);
}
Also used : FetchProfile(com.fsck.k9.mail.FetchProfile) Test(org.junit.Test)

Example 44 with FetchProfile

use of com.fsck.k9.mail.FetchProfile in project k-9 by k9mail.

the class ReconstructMessageFromDatabaseTest method readMessageFromDatabase.

protected LocalMessage readMessageFromDatabase(LocalFolder folder, MimeMessage message) throws MessagingException {
    LocalMessage localMessage = folder.getMessage(message.getUid());
    FetchProfile fp = new FetchProfile();
    fp.add(FetchProfile.Item.ENVELOPE);
    fp.add(FetchProfile.Item.BODY);
    folder.fetch(Collections.singletonList(localMessage), fp, null);
    folder.close();
    return localMessage;
}
Also used : FetchProfile(com.fsck.k9.mail.FetchProfile)

Example 45 with FetchProfile

use of com.fsck.k9.mail.FetchProfile in project sms-backup-plus by jberkel.

the class RestoreTask method importMessage.

@SuppressWarnings("unchecked")
private DataType importMessage(Message message) {
    uids.add(message.getUid());
    FetchProfile fp = new FetchProfile();
    fp.add(FetchProfile.Item.BODY);
    DataType dataType = null;
    try {
        if (LOCAL_LOGV)
            Log.v(TAG, "fetching message uid " + message.getUid());
        message.getFolder().fetch(Collections.singletonList(message), fp, null);
        dataType = converter.getDataType(message);
        // only restore sms+call log for now
        switch(dataType) {
            case CALLLOG:
                importCallLog(message);
                break;
            case SMS:
                importSms(message);
                break;
            default:
                if (LOCAL_LOGV)
                    Log.d(TAG, "ignoring restore of type: " + dataType);
        }
    } catch (MessagingException e) {
        Log.e(TAG, ERROR, e);
    } catch (IllegalArgumentException e) {
        // http://code.google.com/p/android/issues/detail?id=2916
        Log.e(TAG, ERROR, e);
    } catch (IOException e) {
        Log.e(TAG, ERROR, e);
    }
    return dataType;
}
Also used : FetchProfile(com.fsck.k9.mail.FetchProfile) MessagingException(com.fsck.k9.mail.MessagingException) DataType(com.zegoggles.smssync.mail.DataType) IOException(java.io.IOException)

Aggregations

FetchProfile (com.fsck.k9.mail.FetchProfile)49 Test (org.junit.Test)27 LocalMessage (com.fsck.k9.mailstore.LocalMessage)15 MessagingException (com.fsck.k9.mail.MessagingException)12 ArrayList (java.util.ArrayList)10 LocalFolder (com.fsck.k9.mailstore.LocalFolder)9 LocalStore (com.fsck.k9.mailstore.LocalStore)9 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)8 Date (java.util.Date)8 Message (com.fsck.k9.mail.Message)7 SuppressLint (android.annotation.SuppressLint)6 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)6 AuthenticationFailedException (com.fsck.k9.mail.AuthenticationFailedException)5 Multipart (com.fsck.k9.mail.Multipart)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 IOException (java.io.IOException)5 WebDavMessage (com.fsck.k9.mail.store.webdav.WebDavMessage)4 LinkedList (java.util.LinkedList)4 HttpResponse (org.apache.http.HttpResponse)4 StatusLine (org.apache.http.StatusLine)4