Changeset 2654

Show
Ignore:
Timestamp:
08/31/07 12:55:08
Author:
djcb
Message:

* fix tny_camel_msg_header_(received|sent)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r2653 r2654  
     12007-08-31 Dirk-Jan C. Binnema <dirk-jan.binnema@nokia.com> 
     2         
     3        * Fix tny_camel_msg_header_date_(sent|received): 
     4                - don't try to normalize to GMT (camel already does that) 
     5                - only use Date: for received if not received date is found 
     6 
    172007-08-29 Dirk-Jan C. Binnema <dirk-jan.binnema@nokia.com> 
    28 
  • trunk/libtinymail-camel/tny-camel-msg-header.c

    r2653 r2654  
    277277        int tzone; 
    278278 
     279        /* first try _received, if that doesn't work, use the Date: header 
     280         * however, Date: is set by the *sender* so will not be totally 
     281         * accurate 
     282         * 
     283         * NOTE: we ignore the timezone, as the camel function already 
     284         * returns a UTC-normalized time_t 
     285         * */ 
     286        retval = camel_mime_message_get_date_received (me->msg, &tzone); 
     287        if (retval == CAMEL_MESSAGE_DATE_CURRENT) 
     288                retval = camel_mime_message_get_date (me->msg, &tzone); 
     289 
     290        /* return 0 if we really cannot find a date */ 
     291        if (retval == CAMEL_MESSAGE_DATE_CURRENT) 
     292                return 0; 
     293        else 
     294                return retval; 
     295} 
     296 
     297static time_t 
     298tny_camel_msg_header_get_date_sent (TnyHeader *self) 
     299{ 
     300        TnyCamelMsgHeader *me = TNY_CAMEL_MSG_HEADER (self); 
     301        time_t retval = 0; 
     302        int tzone; 
     303 
     304        /* first try _date, if that doesn't work, use received instead 
     305         * however, that is set by the *receiver* so will not be totally 
     306         * accurate 
     307         * 
     308         * NOTE: we ignore the timezone, as the camel function already 
     309         * returns a UTC-normalized time_t 
     310         * */ 
    279311        retval = camel_mime_message_get_date (me->msg, &tzone); 
    280312 
     
    282314                retval = camel_mime_message_get_date_received (me->msg, &tzone); 
    283315        if (retval == CAMEL_MESSAGE_DATE_CURRENT) 
    284         { 
    285                 time (&retval); 
    286                 tzone = 0; 
    287         } 
    288  
    289         retval += (tzone / 100) * 60 * 60; 
    290         retval += (tzone % 100) * 60; 
    291  
    292         return retval; 
    293 
    294  
    295 static time_t 
    296 tny_camel_msg_header_get_date_sent (TnyHeader *self) 
    297 
    298         TnyCamelMsgHeader *me = TNY_CAMEL_MSG_HEADER (self); 
    299         time_t retval = 0; 
    300         int tzone; 
    301  
    302         retval = camel_mime_message_get_date (me->msg, &tzone); 
    303  
    304         if (retval == CAMEL_MESSAGE_DATE_CURRENT) 
    305                 retval = camel_mime_message_get_date_received (me->msg, &tzone); 
    306         if (retval == CAMEL_MESSAGE_DATE_CURRENT) 
    307         { 
    308                 time (&retval); 
    309                 tzone = 0; 
    310         } 
    311  
    312         retval += (tzone / 100) * 60 * 60; 
    313         retval += (tzone % 100) * 60; 
    314  
    315         return retval; 
     316                return 0; 
     317        else 
     318                return retval; 
    316319} 
    317320