Patch: support for getting priority flags in TnyCamelMsgHeader, and fix for set operations



	Hi,

	It seems the patch I sent to add support for setting priority flags in
TnyCamelMsgHeader was wrong (the check I added to only allow priority
flags was wrong). I fixed this.

	I also added support for getting these flags with the method
tny_header_get_flags. This method checks the X-Priority field (one of
the fields we change with set/unset methods).

-- 
Jose Dapena Paz <jdapena igalia com>
Igalia
Index: libtinymail-camel/tny-camel-msg-header.c
===================================================================
--- libtinymail-camel/tny-camel-msg-header.c	(revision 2214)
+++ libtinymail-camel/tny-camel-msg-header.c	(working copy)
@@ -183,8 +183,20 @@
 static TnyHeaderFlags
 tny_camel_msg_header_get_flags (TnyHeader *self)
 {
-	g_warning ("tny_header_get_flags: This is a header instance for a new message. It has no flags.\n");
-	return 0;
+  
+	TnyHeaderPriorityFlags priority_flags;
+	TnyCamelMsgHeader *me = TNY_CAMEL_MSG_HEADER (self);
+	const gchar *priority_string = NULL;
+
+	priority_string = camel_medium_get_header (CAMEL_MEDIUM (me->msg), "X-Priority");
+	if (priority_string == NULL)
+		return 0;
+	if (g_strrstr (priority_string, "1") != NULL)
+		return TNY_HEADER_FLAG_HIGH_PRIORITY;
+	else if (g_strrstr (priority_string, "3") != NULL)
+		return TNY_HEADER_FLAG_LOW_PRIORITY;
+	else 
+		return TNY_HEADER_FLAG_NORMAL_PRIORITY;
 }
 
 static void
@@ -193,7 +205,7 @@
 	TnyHeaderPriorityFlags priority_flags;
 	TnyCamelMsgHeader *me = TNY_CAMEL_MSG_HEADER (self);
 
-	if (mask ^ TNY_HEADER_FLAG_PRIORITY) {
+	if (mask & (~TNY_HEADER_FLAG_PRIORITY)) {
 		g_warning ("tny_header_set_flags: This is a header instance for a new message. Non-priority flags are not supported.\n");
 		return;
 	}
@@ -225,7 +237,7 @@
 	TnyHeaderPriorityFlags priority_flags;
 	TnyCamelMsgHeader *me = TNY_CAMEL_MSG_HEADER (self);
 
-	if (mask ^ TNY_HEADER_FLAG_PRIORITY) {
+	if (mask & (~TNY_HEADER_FLAG_PRIORITY)) {
 		g_warning ("tny_header_set_flags: This is a header instance for a new message. Non-priority flags are not supported.\n");
 		return;
 	}
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 2214)
+++ ChangeLog	(working copy)
@@ -1,3 +1,13 @@
+2007-06-19  Jose Dapena Paz  <jdapena igalia com>
+
+	* libtinymail-camel/tny-camel-msg-header:
+	(tny_camel_msg_header_get_flags): added implementation
+	that obtains the priority flags using the headers
+	we set in our set/unset methods.
+	(tny_camel_msg_header_set_flags, tny_camel_msg_header_set_flags):
+	fixed the check for only allowing priority flags to be set or
+	unset.
+
 2007-06-19  Dirk-Jan C. Binnema <dirk-jan binnema nokia com>
 
 	* Compiler warning fixes


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]