Re: Problem with tny_camel_msg_header_set_flags()



O Venres 26/10/2007 ás 17:43, Alberto Garcia dicía...

> Possible solutions?
> 
>    * Define a new bit for normal priority, that is, 3 different bits
>      for low, high and normal
> 
>    * Make set_prio_mask() a different (and public) function and
>      prevent tny_headers_set_flags() from calling it.
> 
>    * Always call set_flags with something like (current_flags &
>      NEW_FLAG). (this doesn't seem a good one).

Actually there's another one, although I don't like it very much: set
the priority flags only if all other flags are set to 0. I'm attaching
a sample patch.

> By the way, why are TNY_HEADER_FLAG_* defined in both tny-header.h
> and tny-enums.h ??

...and with different values:

TNY_HEADER_FLAG_HIGH_PRIORITY = 0<<9|1<<10,
TNY_HEADER_FLAG_NORMAL_PRIORITY = 0<<9|0<<10,
TNY_HEADER_FLAG_LOW_PRIORITY = 1<<9|0<<10,

vs.

TNY_HEADER_FLAG_HIGH_PRIORITY = 1<<9|1<<10,
TNY_HEADER_FLAG_NORMAL_PRIORITY = 0<<9|0<<10,
TNY_HEADER_FLAG_LOW_PRIORITY = 0<<9|1<<10,

--
Alberto Garía Gonzlez
http://people.igalia.com/berto/
Index: libtinymail-camel/tny-camel-msg-header.c
===================================================================
--- libtinymail-camel/tny-camel-msg-header.c	(revision 2886)
+++ libtinymail-camel/tny-camel-msg-header.c	(working copy)
@@ -225,6 +225,9 @@
 	TnyHeaderFlags prio_mask = mask;
 	prio_mask &= TNY_HEADER_FLAG_PRIORITY_MASK;
 
+	camel_medium_remove_header (CAMEL_MEDIUM (me->msg), "X-MSMail-Priority");
+	camel_medium_remove_header (CAMEL_MEDIUM (me->msg), "X-Priority");
+
 	if (prio_mask == TNY_HEADER_FLAG_HIGH_PRIORITY) {
 		camel_medium_add_header (CAMEL_MEDIUM (me->msg), "X-MSMail-Priority", "High");
 		camel_medium_add_header (CAMEL_MEDIUM (me->msg), "X-Priority", "1");
@@ -255,11 +258,12 @@
 			me->partial = FALSE;
 	}
 
-	camel_medium_remove_header (CAMEL_MEDIUM (me->msg), "X-MSMail-Priority");
-	camel_medium_remove_header (CAMEL_MEDIUM (me->msg), "X-Priority");
+	/* Set priority mask only if it has no bits other than
+	   priority bits */
+	if (!(mask & ~TNY_HEADER_FLAG_PRIORITY_MASK)) {
+		set_prio_mask (me, mask);
+	}
 
-	set_prio_mask (me, mask);
-
 	if (mask & TNY_HEADER_FLAG_ATTACHMENTS) {
 		camel_medium_remove_header (CAMEL_MEDIUM (me->msg), "X-MS-Has-Attach");
 		camel_medium_add_header (CAMEL_MEDIUM (me->msg), "X-MS-Has-Attach", "Yes");
@@ -277,8 +281,6 @@
 		tny_header_set_flags (me->decorated, mask);
 	}
 
-	set_prio_mask (me, mask);
-
 	if (mask & TNY_HEADER_FLAG_ATTACHMENTS)
 		camel_medium_remove_header (CAMEL_MEDIUM (me->msg), "X-MS-Has-Attach");
 


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