Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #90 from pitiphong-p/fetch_with_indexset

Add Fetching mail with UID or Sequence number Index set.
  • Loading branch information...
commit 3a5e94af79d8b1b257c0a63a4bbe70b4d74a6a81 2 parents 1e8a68c + 00d390c
@mronge mronge authored
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;
Please sign in to comment.
Something went wrong with that request. Please try again.