Skip to content
Browse files

Add Fetching mail with UID or Sequence number Index set.

  • Loading branch information...
1 parent 1e8a68c commit 00d390c35e2caae5a2b23b4634a9217d53cfda20 @pitiphong-p pitiphong-p committed Apr 1, 2013
Showing with 50 additions and 0 deletions.
  1. +29 −0 Source/CTCoreFolder.h
  2. +21 −0 Source/CTCoreFolder.m
View
29 Source/CTCoreFolder.h
@@ -121,6 +121,35 @@
*/
- (NSArray *)messagesFromUID:(NSUInteger)startUID to:(NSUInteger)endUID withFetchAttributes:(CTFetchAttributes)attrs;
+
+/**
+ Use this method to download message lists from the server.
+
+ This method uses sequence numbers indexset to determine which messages to download.
+
+ @param sequenceNumbers The indexset of sequence numbers to load.
+ @param attrs This controls what is fetched.
+ @return Returns a NSArray of CTCoreMessage's. Returns nil on error
+ @see messagesFromSequenceNumber:to:withFetchAttributes:
+ */
+- (NSArray *)messagesWithSequenceNumbers:(NSIndexSet *)sequenceNumbers
+ fetchAttributes:(CTFetchAttributes)attrs;
+
+
+/**
+ Use this method to download message lists from the server.
+
+ This method uses uid numbers indexset to determine which messages to download.
+
+ @param uidNumbers The indexset of uid numbers to load.
+ @param attrs This controls what is fetched.
+ @return Returns a NSArray of CTCoreMessage's. Returns nil on error
+ @see messagesFromSequenceNumber:to:withFetchAttributes:
+ */
+- (NSArray *)messagesWithUIDs:(NSIndexSet *)uidNumbers
+ fetchAttributes:(CTFetchAttributes)attrs;
+
+
/**
Pulls the sequence number for the message with the specified uid.
It does not perform UID validation, and the sequence ID is only
View
21 Source/CTCoreFolder.m
@@ -641,6 +641,27 @@ - (NSArray *)messagesFromUID:(NSUInteger)startUID to:(NSUInteger)endUID withFetc
return results;
}
+- (NSArray *)messagesWithSequenceNumbers:(NSIndexSet *)sequenceNumbers
+ fetchAttributes:(CTFetchAttributes)attrs {
+ struct mailimap_set *set = mailimap_set_new_empty();
+ [sequenceNumbers enumerateRangesUsingBlock:^(NSRange range, BOOL *stop) {
+ mailimap_set_add_interval(set, range.location, range.location + range.length - 1);
+ }];
+
+ return [self messagesForSet:set fetchAttributes:attrs uidFetch:NO];
+
+}
+
+- (NSArray *)messagesWithUIDs:(NSIndexSet *)uidNumbers
+ fetchAttributes:(CTFetchAttributes)attrs {
+ struct mailimap_set *set = mailimap_set_new_empty();
+ [uidNumbers enumerateRangesUsingBlock:^(NSRange range, BOOL *stop) {
+ mailimap_set_add_interval(set, range.location, range.location + range.length - 1);
+ }];
+
+ return [self messagesForSet:set fetchAttributes:attrs uidFetch:YES];
+}
+
- (CTCoreMessage *)messageWithUID:(NSUInteger)uid {
int err;
struct mailmessage *msgStruct;

0 comments on commit 00d390c

Please sign in to comment.
Something went wrong with that request. Please try again.