Changeset 2224

Show
Ignore:
Timestamp:
06/19/07 16:29:37
Author:
jdapena
Message:
        • 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.

        • libtinymail-tests/tny-header-test.c: added unit test for

priority flags in camel msg header.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r2223 r2224  
     12007-06-19  Jose Dapena Paz  <jdapena@igalia.com> 
     2 
     3        * libtinymail-camel/tny-camel-msg-header: 
     4        (tny_camel_msg_header_get_flags): added implementation 
     5        that obtains the priority flags using the headers 
     6        we set in our set/unset methods. 
     7        (tny_camel_msg_header_set_flags, tny_camel_msg_header_set_flags): 
     8        fixed the check for only allowing priority flags to be set or 
     9        unset. 
     10         
     11        * libtinymail-tests/tny-header-test.c: added unit test for 
     12        priority flags in camel msg header. 
     13 
    1142007-06-19  Murray Cumming  <murrayc@murrayc.com> 
    215 
  • trunk/libtinymail-camel/tny-camel-msg-header.c

    r2101 r2224  
    184184tny_camel_msg_header_get_flags (TnyHeader *self) 
    185185{ 
    186         g_warning ("tny_header_get_flags: This is a header instance for a new message. It has no flags.\n"); 
    187         return 0; 
     186   
     187        TnyHeaderPriorityFlags priority_flags; 
     188        TnyCamelMsgHeader *me = TNY_CAMEL_MSG_HEADER (self); 
     189        const gchar *priority_string = NULL; 
     190 
     191        priority_string = camel_medium_get_header (CAMEL_MEDIUM (me->msg), "X-Priority"); 
     192        if (priority_string == NULL) 
     193                return 0; 
     194        if (g_strrstr (priority_string, "1") != NULL) 
     195                return TNY_HEADER_FLAG_HIGH_PRIORITY; 
     196        else if (g_strrstr (priority_string, "3") != NULL) 
     197                return TNY_HEADER_FLAG_LOW_PRIORITY; 
     198        else  
     199                return TNY_HEADER_FLAG_NORMAL_PRIORITY; 
    188200} 
    189201 
     
    194206        TnyCamelMsgHeader *me = TNY_CAMEL_MSG_HEADER (self); 
    195207 
    196         if (mask ^ TNY_HEADER_FLAG_PRIORITY) { 
     208        if (mask & (~TNY_HEADER_FLAG_PRIORITY)) { 
    197209                g_warning ("tny_header_set_flags: This is a header instance for a new message. Non-priority flags are not supported.\n"); 
    198210                return; 
     
    226238        TnyCamelMsgHeader *me = TNY_CAMEL_MSG_HEADER (self); 
    227239 
    228         if (mask ^ TNY_HEADER_FLAG_PRIORITY) { 
     240        if (mask & (~TNY_HEADER_FLAG_PRIORITY)) { 
    229241                g_warning ("tny_header_set_flags: This is a header instance for a new message. Non-priority flags are not supported.\n"); 
    230242                return; 
  • trunk/libtinymail-test/tny-header-test.c

    r2029 r2224  
    143143END_TEST 
    144144 
     145START_TEST (tny_header_test_set_priority_flags) 
     146{ 
     147        TnyHeaderFlags flags; 
     148 
     149        tny_header_set_flags (iface, TNY_HEADER_FLAG_HIGH_PRIORITY); 
     150        flags = tny_header_get_flags (iface); 
     151        fail_unless (flags == TNY_HEADER_FLAG_HIGH_PRIORITY, "Unable to set high priority.\n"); 
     152 
     153        tny_header_unset_flags (iface, TNY_HEADER_FLAG_PRIORITY); 
     154        flags = tny_header_get_flags (iface); 
     155        fail_unless (flags == 0, "Unable to unset priority"); 
     156 
     157        tny_header_set_flags (iface, TNY_HEADER_FLAG_LOW_PRIORITY); 
     158        flags = tny_header_get_flags (iface); 
     159        fail_unless (flags == TNY_HEADER_FLAG_LOW_PRIORITY, "Unable to set low priority.\n"); 
     160 
     161        return; 
     162} 
     163END_TEST 
     164 
    145165Suite * 
    146166create_tny_header_suite (void) 
     
    179199     suite_add_tcase (s, tc); 
    180200 
     201     tc = tcase_create ("Set priority flags"); 
     202     tcase_add_checked_fixture (tc, tny_header_test_setup, tny_header_test_teardown); 
     203     tcase_add_test (tc, tny_header_test_set_priority_flags); 
     204     suite_add_tcase (s, tc); 
     205 
    181206     return s; 
    182207}