Created
March 18, 2014 21:32
-
-
Save Cellane/9630196 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma mark Private methods | |
| - (void)refreshData | |
| { | |
| [self setMessages:[[NSArray alloc] init]]; | |
| for (MVAccount *account in [[self accountManager] allAccounts]) | |
| { | |
| MCOIMAPSession *session = [[MCOIMAPSession alloc] init]; | |
| [session setHostname:[account imapServer]]; | |
| [session setPort:(unsigned int) [account imapPort]]; | |
| [session setUsername:[account username]]; | |
| [session setPassword:[account password]]; | |
| [session setConnectionType:[account tls] ? MCOConnectionTypeTLS : MCOConnectionTypeClear]; | |
| MCOIMAPFetchFoldersOperation *fetchFoldersOperation = [session fetchAllFoldersOperation]; | |
| [fetchFoldersOperation start:^(NSError *foldersError, NSArray *folders) | |
| { | |
| for (MCOIMAPFolder *folder in folders) | |
| { | |
| NSLog(@"FOLDER: %@", [folder path]); | |
| MCOIndexSet *indexSet = [MCOIndexSet indexSetWithRange:MCORangeMake(1, UINT64_MAX)]; | |
| MCOIMAPFetchMessagesOperation *fetchMessagesOperation = [session fetchMessagesByUIDOperationWithFolder:[folder path] requestKind:MCOIMAPMessagesRequestKindFullHeaders uids:indexSet]; | |
| [fetchMessagesOperation start:^(NSError *error, NSArray *messages, MCOIndexSet *vanishedMessages) | |
| { | |
| NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"header.date" ascending:NO]; | |
| NSLog(@"MESSAGE: %@ (IN FOLDER %@)", [messages sortedArrayUsingDescriptors:@[sortDescriptor]], [folder path]); | |
| }]; | |
| } | |
| }]; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment