Permalink
Browse files

Merge pull request #37 from jdg/master

Add setInReplyTo, references and setReferences functionality to CTCoreMessage
  • Loading branch information...
2 parents fbd1774 + 163cb86 commit d39296426acca65de8b55a21968002fa23e71402 @mronge mronge committed Sep 8, 2012
Showing with 60 additions and 0 deletions.
  1. +17 −0 Source/CTCoreMessage.h
  2. +43 −0 Source/CTCoreMessage.m
View
17 Source/CTCoreMessage.h
@@ -268,6 +268,23 @@ Return the list of messageIds from the in-reply-to field
- (NSSet *)inReplyTo;
/**
+ Sets the message's in-reply-to messageIds
+ @param messageIds A NSSet containing NSString messageId's
+*/
+- (void)setInReplyTo:(NSSet *)messageIds;
+
+/**
+Return the list of messageIds from the references field
+ */
+- (NSSet *)references;
+
+/**
+ Sets the message's references
+ @param messageIds A NSSet containing NSString messageId's
+*/
+- (void)setReferences:(NSSet *)messageIds;
+
+/**
Returns the list of people the message was cced to, returns an NSSet containing CTAddress's.
*/
- (NSSet *)cc;
View
43 Source/CTCoreMessage.m
@@ -512,6 +512,39 @@ - (NSSet *)inReplyTo {
return [self _stringSetFromClist:myFields->fld_in_reply_to->mid_list];
}
+
+- (void)setInReplyTo:(NSSet *)messageIds {
+ struct mailimf_in_reply_to *imf = mailimf_in_reply_to_new([self _clistFromStringSet:messageIds]);
+
+ if (myFields->fld_in_reply_to != NULL) {
+ mailimf_in_reply_to_free(myFields->fld_in_reply_to);
+ myFields->fld_in_reply_to = imf;
+ }
+ else
+ myFields->fld_in_reply_to = imf;
+}
+
+
+- (NSSet *)references {
+ if (myFields->fld_references == NULL)
+ return nil;
+ else
+ return [self _stringSetFromClist:myFields->fld_references->mid_list];
+}
+
+
+- (void)setReferences:(NSSet *)messageIds {
+ struct mailimf_references *imf = mailimf_references_new([self _clistFromStringSet:messageIds]);
+
+ if (myFields->fld_references != NULL) {
+ mailimf_references_free(myFields->fld_references);
+ myFields->fld_references = imf;
+ }
+ else
+ myFields->fld_references = imf;
+}
+
+
- (NSSet *)cc {
if (myFields->fld_cc == NULL)
return nil;
@@ -775,4 +808,14 @@ - (NSSet *)_stringSetFromClist:(clist *)list {
return stringSet;
}
+- (clist *)_clistFromStringSet:(NSSet *)strings {
+ clist * str_list = clist_new();
+
+ for (NSString *str in [strings allObjects]) {
+ clist_append(str_list, strdup([str UTF8String]));
+ }
+
+ return str_list;
+}
+
@end

0 comments on commit d392964

Please sign in to comment.