Problem with tny_camel_msg_header_set_flags()
- From: Alberto Garcia <agarcia igalia com>
- To: tinymail-devel-list gnome org
- Subject: Problem with tny_camel_msg_header_set_flags()
- Date: Fri, 26 Oct 2007 17:43:15 +0200
This is supposed to set a single flag in a header,
right? Let's take for example this code in
tny_camel_full_msg_receive_strategy_perform_get_msg_default():
/* ... */
tny_header_set_flags (nheader, TNY_HEADER_FLAG_CACHED);
tny_header_unset_flags (nheader, TNY_HEADER_FLAG_PARTIAL);
g_object_unref (nheader);
tny_header_set_flags (header, TNY_HEADER_FLAG_CACHED);
tny_header_unset_flags (header, TNY_HEADER_FLAG_PARTIAL);
/* ... */
The problem with set_flags() is that while it works OK if it needs to
check single bits in the mask ...
/* ... */
if (mask & TNY_HEADER_FLAG_CACHED || mask & TNY_HEADER_FLAG_PARTIAL) {
if (mask & TNY_HEADER_FLAG_PARTIAL)
me->partial = TRUE;
else
me->partial = FALSE;
}
/* ... */
... it fails with priority flags. tny_camel_msg_header_set_flags()
calls set_prio_mask() unconditionally, so calling it always sets the
priority mask. But what's wrong with that?
While the flags for low and high priority are 10<<9 and 01<<9, normal
priority is 00<<9, that is: there is no way for set_prio_mask() to
know whether the caller wants to set normal priority of doesn't want
to change priority flags at all.
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).
tny_camel_msg_header_unset_flags() has a similar problem, in fact
it also calls set_prio_mask() again (it should call something like
unset_prio_mask()), so that explains why I'm receiving e-mails with
"X-Priority: Normal" set twice.
Opinions?
By the way, why are TNY_HEADER_FLAG_* defined in both tny-header.h and
tny-enums.h ??
--
Alberto Garía Gonzlez
http://people.igalia.com/berto/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]