Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add support for outgoing mail priority header. #91

Merged
merged 2 commits into from

2 participants

@pitiphong-p

Mail priority header is defined in IMAP RFC 4021. This pull request add support for setting the mail priority header in the outgoing message.

Source/CTCoreMessage.m
@@ -700,6 +735,10 @@ - (NSString *)rfc822Header {
return [nsresult autorelease];
}
+- (void)setMailPriority:(CTCoreMessagePriority)priority {
+ self->mailPriority = priority;
@mronge Owner
mronge added a note

The self-> here isn't necessary, but otherwise looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Source/CTCoreMessage.m
((21 lines not shown))
+ xPriorityValue = "5";
+ rfcPriorityValue = "non-urgent";
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ struct mailimf_optional_field * priority = mailimf_optional_field_new("X-Priority", xPriorityValue);
+
+ struct mailimf_field * priorityField = mailimf_field_new(MAILIMF_FIELD_OPTIONAL_FIELD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, priority);
+ mailimf_fields_add(fields, priorityField);
+
+ priority = mailimf_optional_field_new("Priority", rfcPriorityValue);
+ priorityField = mailimf_field_new(MAILIMF_FIELD_OPTIONAL_FIELD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, priority);
@mronge Owner
mronge added a note

Add a line breaks because this line is so long

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Source/CTCoreMessage.m
((17 lines not shown))
+ rfcPriorityValue = "normal";
+ break;
+ }
+ case CTCoreMessageNonUrgentPriority: {
+ xPriorityValue = "5";
+ rfcPriorityValue = "non-urgent";
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ struct mailimf_optional_field * priority = mailimf_optional_field_new("X-Priority", xPriorityValue);
+
+ struct mailimf_field * priorityField = mailimf_field_new(MAILIMF_FIELD_OPTIONAL_FIELD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, priority);
@mronge Owner
mronge added a note

Add a line breaks because this line is so long

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mronge mronge merged commit d716226 into from
@mronge
Owner

Thanks again! You are a machine :)

@pitiphong-p pitiphong-p deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 2, 2013
  1. @pitiphong-p
Commits on Apr 4, 2013
  1. @pitiphong-p
This page is out of date. Refresh to see the latest.
Showing with 60 additions and 1 deletion.
  1. +15 −0 Source/CTCoreMessage.h
  2. +45 −1 Source/CTCoreMessage.m
View
15 Source/CTCoreMessage.h
@@ -42,6 +42,13 @@
@class CTCoreFolder, CTCoreAddress, CTCoreAttachment, CTMIME;
+typedef enum {
+ CTCoreMessageUrgentPriority = 1,
+ CTCoreMessageNormalPriority = 2,
+ CTCoreMessageNonUrgentPriority
+} CTCoreMessagePriority;
+
+
@interface CTCoreMessage : NSObject {
struct mailmessage *myMessage;
struct mailimf_single_fields *myFields;
@@ -49,6 +56,7 @@
NSUInteger mySequenceNumber;
NSError *lastError;
CTCoreFolder *parentFolder;
+ CTCoreMessagePriority mailPriority;
}
/**
If an error occurred (nil or return of NO) call this method to get the error
@@ -326,6 +334,13 @@
*/
- (NSString *)rfc822Header;
+
+/**
+ Sets the outgoing message's priority header value.
+ Support for Mail Prioirty header defined in IMAP 4021 and X-Prioirty header.
+ */
+- (void)setMailPriority:(CTCoreMessagePriority)priority;
+
/* Intended for advanced use only */
- (struct mailmessage *)messageStruct;
- (mailimap *)imapSession;
View
46 Source/CTCoreMessage.m
@@ -629,9 +629,49 @@ - (NSString *)render {
clist *references = (myFields->fld_references != NULL) ? (myFields->fld_references->mid_list) : NULL;
char *subject = (myFields->fld_subject != NULL) ? (myFields->fld_subject->sbj_value) : NULL;
+ fields = mailimf_fields_new_with_data(from, sender, replyTo, to, cc, bcc, inReplyTo, references, subject);
+
+ if (self->mailPriority != 0) {
+ char * xPriorityValue;
+ char * rfcPriorityValue;
+ switch (self->mailPriority) {
+ case CTCoreMessageUrgentPriority: {
+ xPriorityValue = "1";
+ rfcPriorityValue = "urgent";
+ break;
+ }
+ case CTCoreMessageNormalPriority: {
+ xPriorityValue = "3";
+ rfcPriorityValue = "normal";
+ break;
+ }
+ case CTCoreMessageNonUrgentPriority: {
+ xPriorityValue = "5";
+ rfcPriorityValue = "non-urgent";
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ struct mailimf_optional_field * priority = mailimf_optional_field_new("X-Priority", xPriorityValue);
+
+ struct mailimf_field * priorityField = mailimf_field_new(MAILIMF_FIELD_OPTIONAL_FIELD, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, priority);
+ mailimf_fields_add(fields, priorityField);
+
+ priority = mailimf_optional_field_new("Priority", rfcPriorityValue);
+ priorityField = mailimf_field_new(MAILIMF_FIELD_OPTIONAL_FIELD, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, priority);
+
+ mailimf_fields_add(fields, priorityField);
+ }
//TODO uh oh, when this get freed it frees stuff in the CTCoreMessage
//TODO Need to make sure that fields gets freed somewhere
- fields = mailimf_fields_new_with_data(from, sender, replyTo, to, cc, bcc, inReplyTo, references, subject);
[(CTMIME_MessagePart *)msgPart setIMFFields:fields];
}
return [myParsedMIME render];
@@ -700,6 +740,10 @@ - (NSString *)rfc822Header {
return [nsresult autorelease];
}
+- (void)setMailPriority:(CTCoreMessagePriority)priority {
+ mailPriority = priority;
+}
+
- (struct mailmessage *)messageStruct {
return myMessage;
}
Something went wrong with that request. Please try again.