librelist archives

« back to archive

How to work with flags in MailCore?

How to work with flags in MailCore?

From:
Denis Kutlubaev
Date:
2012-09-21 @ 13:07
There are flags, available in MailCore:
#define CTFlagNew		MAIL_FLAG_NEW 
#define CTFlagSeen		MAIL_FLAG_SEEN
#define CTFlagFlagged		MAIL_FLAG_FLAGGED
#define CTFlagDeleted		MAIL_FLAG_DELETED
#define CTFlagAnswered		MAIL_FLAG_ANSWERED
#define CTFlagForwarded		MAIL_FLAG_FORWARDED
#define CTFlagCancelled		MAIL_FLAG_CANCELLED

In RFC of IMAP4 (http://tools.ietf.org/html/rfc3501#section-2.3.2) in 
section (Flags Message Attribute) there are other flags: 
\Seen
           Message has been read

        \Answered
           Message has been answered

        \Flagged
           Message is "flagged" for urgent/special attention

        \Deleted
           Message is "deleted" for removal by later EXPUNGE

        \Draft
           Message has not completed composition (marked as a draft).

        \Recent

Is MailCore working with old IMAP version? I tried to get flags from gmail
server for messages with reply status and forwarded status, but I got only
flags 2 and 18. What does 18 mean? 

This is a part of my code: 

NSArray *temp = [mcFolder.coreFolder messagesFromSequenceNumber:1 to:0 
withFetchAttributes:CTFetchAttrDefaultsOnly];   
    for (CTCoreMessage *coreMessage in temp) {
        // Test
        if (coreMessage.flags != 2) {
            NSLog(@"Flags:%d", coreMessage.flags);
        }
    }

What does status cancelled mean? It is not described in docs. Thanks. 

Re: [mailcore] How to work with flags in MailCore?

From:
Jonathan Willing
Date:
2012-09-21 @ 13:47
Hi there,

The flags are stored as bitwise operations. If you want to check to see if
a message is deleted, for example, you can do the following bitwise 
operation:

if (coreMessage.flags & CTFlagDeleted) {
            NSLog(@"Message has been deleted.");
}

That's why you're getting 18 as the flags sometimes, due to the bitwise 
combination of different flags.

-Jonathan

On Sep 21, 2012, at 8:07 AM, Denis Kutlubaev <kutlubaev.denis@gmail.com> wrote:

> There are flags, available in MailCore:
> #define CTFlagNew		MAIL_FLAG_NEW 
> #define CTFlagSeen		MAIL_FLAG_SEEN
> #define CTFlagFlagged		MAIL_FLAG_FLAGGED
> #define CTFlagDeleted		MAIL_FLAG_DELETED
> #define CTFlagAnswered		MAIL_FLAG_ANSWERED
> #define CTFlagForwarded		MAIL_FLAG_FORWARDED
> #define CTFlagCancelled		MAIL_FLAG_CANCELLED
> 
> In RFC of IMAP4 (http://tools.ietf.org/html/rfc3501#section-2.3.2) in 
section (Flags Message Attribute) there are other flags: 
> \Seen
>            Message has been read
> 
>         \Answered
>            Message has been answered
> 
>         \Flagged
>            Message is "flagged" for urgent/special attention
> 
>         \Deleted
>            Message is "deleted" for removal by later EXPUNGE
> 
>         \Draft
>            Message has not completed composition (marked as a draft).
> 
>         \Recent
> 
> Is MailCore working with old IMAP version? I tried to get flags from 
gmail server for messages with reply status and forwarded status, but I 
got only flags 2 and 18. What does 18 mean? 
> 
> This is a part of my code: 
> 
> NSArray *temp = [mcFolder.coreFolder messagesFromSequenceNumber:1 to:0 
withFetchAttributes:CTFetchAttrDefaultsOnly];   
>     for (CTCoreMessage *coreMessag
>  e in temp) {
>         // Test
>         if (coreMessage.flags != 2) {
>             NSLog(@"Flags:%d", coreMessage.flags);
>         }
>     }
> 
> What does status cancelled m ean? It is not described in docs. Thanks.