Changeset 138

Show
Ignore:
Timestamp:
03/07/06 16:26:49
Author:
pvanhoof
Message:

Strange fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libtinymail-camel/Makefile.am

    r96 r138  
    1212        tny-camel-stream.h                      \ 
    1313        tny-stream-camel.h                      \ 
     14        tny-camel-shared.h                      \ 
    1415        tny-session-camel.h 
    1516 
  • trunk/libtinymail-camel/tny-account.c

    r108 r138  
    4040#include "tny-account-priv.h" 
    4141 
     42#include <tny-camel-shared.h> 
     43 
    4244#define TNY_ACCOUNT_GET_PRIVATE(o)      \ 
    4345        (G_TYPE_INSTANCE_GET_PRIVATE ((o), TNY_ACCOUNT_TYPE, TnyAccountPriv)) 
     
    418420{ 
    419421        static GType type = 0; 
     422 
     423        if (!camel_type_init_done) 
     424        { 
     425                camel_type_init (); 
     426                camel_type_init_done = TRUE; 
     427        } 
    420428 
    421429        if (type == 0)  
  • trunk/libtinymail-camel/tny-camel-stream.c

    r109 r138  
    1919 
    2020#include <tny-camel-stream.h> 
     21 
     22#include <tny-camel-shared.h> 
    2123 
    2224static CamelStreamClass *parent_class = NULL; 
     
    154156        static CamelType type = CAMEL_INVALID_TYPE; 
    155157         
     158        if (!camel_type_init_done) 
     159        { 
     160                camel_type_init (); 
     161                camel_type_init_done = TRUE; 
     162        } 
     163 
    156164        if (type == CAMEL_INVALID_TYPE) { 
    157165                parent_class = (CamelStreamClass *)camel_stream_get_type(); 
  • trunk/libtinymail-camel/tny-msg-folder.c

    r109 r138  
    4040#include "tny-account-priv.h" 
    4141#include "tny-msg-folder-priv.h" 
     42 
     43#include <tny-camel-shared.h> 
    4244 
    4345#include <camel/camel.h> 
     
    516518{ 
    517519        static GType type = 0; 
     520 
     521        if (!camel_type_init_done) 
     522        { 
     523                camel_type_init (); 
     524                camel_type_init_done = TRUE; 
     525        } 
    518526 
    519527        if (type == 0)  
  • trunk/libtinymail-camel/tny-msg-header.c

    r135 r138  
    2727#include "tny-msg-header-priv.h" 
    2828 
     29#include <tny-camel-shared.h> 
     30 
    2931#include <camel/camel-folder.h> 
    3032#include <camel/camel.h> 
     
    189191                camel_internet_address_add (target, name, email); 
    190192        } else { 
    191                 camel_internet_address_add (target, NULL, tok); 
     193                 
     194                char *name = (char*)tok; 
     195                char *lname = name; 
     196 
     197                lname += (strlen (name)-1); 
     198 
     199                if (*name == ' ') 
     200                        *name++; 
     201         
     202                if (*lname == ' ') 
     203                        *lname-- = '\0'; 
     204 
     205                camel_internet_address_add (target, NULL, name); 
    192206        } 
    193207} 
     
    277291{ 
    278292        TnyMsgHeader *me = TNY_MSG_HEADER (self); 
     293 
     294        CamelInternetAddress *addr = camel_internet_address_new (); 
     295        camel_object_unref (CAMEL_OBJECT (addr)); 
    279296 
    280297        prepare_for_write (me); 
     
    417434        TnyMsgHeader *me = TNY_MSG_HEADER (self); 
    418435 
    419         load_msg_header (me); 
    420  
    421         /* TODO: write case */ 
    422  
    423         return camel_message_info_subject (me->message_info); 
     436        if (me->uid) 
     437        { 
     438                load_msg_header (me); 
     439 
     440                return camel_message_info_subject (me->message_info); 
     441 
     442        } else if (me->mime_message) 
     443        { 
     444                return camel_mime_message_get_subject (me->mime_message); 
     445        } else  
     446                return NULL; 
    424447} 
    425448 
     
    553576        klass->get_cc_func = tny_msg_header_get_cc; 
    554577        klass->get_bcc_func = tny_msg_header_get_bcc; 
    555  
    556578        klass->get_replyto_func = tny_msg_header_get_replyto; 
    557  
    558         klass->get_uid_func = tny_msg_header_get_uid;    
     579        klass->get_uid_func = tny_msg_header_get_uid; 
     580 
    559581        klass->set_uid_func = tny_msg_header_set_uid; 
    560582         
     
    594616{ 
    595617        static GType type = 0; 
     618 
     619        if (!camel_type_init_done) 
     620        { 
     621                camel_type_init (); 
     622                camel_type_init_done = TRUE; 
     623        } 
    596624 
    597625        if (type == 0)  
  • trunk/libtinymail-camel/tny-msg-mime-part.c

    r108 r138  
    2828#include <camel/camel-data-wrapper.h> 
    2929 
     30#include <tny-camel-shared.h> 
     31 
    3032static GObjectClass *parent_class = NULL; 
    3133 
     
    277279{ 
    278280        static GType type = 0; 
     281 
     282        if (!camel_type_init_done) 
     283        { 
     284                camel_type_init (); 
     285                camel_type_init_done = TRUE; 
     286        } 
    279287 
    280288        if (type == 0)  
  • trunk/libtinymail-camel/tny-msg.c

    r108 r138  
    2828#include <camel/camel-stream-buffer.h> 
    2929 
     30#include <tny-camel-shared.h> 
     31 
    3032static GObjectClass *parent_class = NULL; 
    3133 
     
    267269{ 
    268270        static GType type = 0; 
     271 
     272        if (!camel_type_init_done) 
     273        { 
     274                camel_type_init (); 
     275                camel_type_init_done = TRUE; 
     276        } 
    269277 
    270278        if (type == 0)  
  • trunk/libtinymail-camel/tny-session-camel.c

    r109 r138  
    3737#include <tny-account.h> 
    3838#include "tny-account-priv.h" 
     39 
     40#include <tny-camel-shared.h> 
     41 
     42gboolean camel_type_init_done = FALSE; 
    3943 
    4044static CamelSessionClass *ms_parent_class; 
     
    452456        static CamelType tny_session_camel_type = CAMEL_INVALID_TYPE; 
    453457         
     458        if (!camel_type_init_done) 
     459        { 
     460                camel_type_init (); 
     461                camel_type_init_done = TRUE; 
     462        } 
     463 
    454464        if (tny_session_camel_type == CAMEL_INVALID_TYPE) { 
    455465                ms_parent_class = (CamelSessionClass *)camel_session_get_type(); 
  • trunk/libtinymail-camel/tny-stream-camel.c

    r109 r138  
    3535 
    3636#include <tny-session-camel.h> 
     37 
     38#include <tny-camel-shared.h> 
    3739 
    3840static GObjectClass *parent_class = NULL; 
     
    231233        static GType type = 0; 
    232234 
     235        if (!camel_type_init_done) 
     236        { 
     237                camel_type_init (); 
     238                camel_type_init_done = TRUE; 
     239        } 
     240 
    233241        if (type == 0)  
    234242        { 
  • trunk/libtinymail-test/tny-msg-header-iface-test.c

    r135 r138  
    1717 */ 
    1818 
     19#include <string.h> 
     20 
    1921#include <tny-msg-header-iface-test.h> 
    2022 
     
    2426static TnyMsgHeaderIface *iface = NULL; 
    2527 
    26 void 
     28static void 
    2729tny_msg_header_iface_test_setup (void) 
    2830{ 
    29         g_print ("setup\n"); 
    3031        iface = TNY_MSG_HEADER_IFACE (tny_msg_header_new ()); 
    3132 
     
    3334} 
    3435 
    35 void  
     36static void  
    3637tny_msg_header_iface_test_teardown (void) 
    3738{ 
     
    4445tny_msg_header_iface_test_set_from (void) 
    4546{ 
    46         const gchar *str_in = "1st test string", *str_out; 
     47        const gchar *str_in = "Me myself and I <me.myself@and.i.com>", *str_out; 
    4748         
    4849        tny_msg_header_iface_set_from (iface, str_in); 
    4950        str_out = tny_msg_header_iface_get_from (iface); 
    5051 
    51         gunit_fail_unless(!strcmp (str_in, str_out), "Unable to set from!"); 
     52        gunit_fail_unless(!strcmp (str_in, str_out), "Unable to set from!\n"); 
    5253 
    5354        return; 
    5455} 
    5556 
    56 void 
     57static void 
    5758tny_msg_header_iface_test_set_to (void) 
    5859{ 
    59         const gchar *str_in = "1st test string", *str_out; 
    60          
    61         tny_msg_header_iface_set_to (iface, str_in); 
     60        gchar *str_in = g_strdup ("Myself <this@is.me>, You Do Die Daa <you.doe.die@daa.com>; patrick@test.com"); 
     61        const gchar *str_out; 
     62        int i=0; 
     63 
     64        tny_msg_header_iface_set_to (iface, (const gchar*)str_in); 
    6265        str_out = tny_msg_header_iface_get_to (iface); 
    6366 
    64         gunit_fail_unless(!strcmp (str_in, str_out), "Unable to set to!"); 
     67        /* The implementation will always return a comma separated list 
     68         * but should also accept ; separated lists. Even mixed (both 
     69         * characters have the same meaning). */ 
     70 
     71        for (i=0; i < strlen(str_in); i++) 
     72                if (str_in[i] == ';') 
     73                        str_in[i] = ','; 
     74 
     75        gunit_fail_unless(!strcmp (str_in, str_out), "Unable to set to!\n"); 
     76 
     77        g_free (str_in); 
    6578 
    6679        return; 
    6780} 
    6881 
    69 void 
     82static void 
    7083tny_msg_header_iface_test_set_cc (void) 
    7184{ 
    72         const gchar *str_in = "1st test string", *str_out; 
     85        const gchar *str_in = "First user <first@user.be>, Second user <second@user.com>", *str_out; 
    7386         
    7487        tny_msg_header_iface_set_cc (iface, str_in); 
    7588        str_out = tny_msg_header_iface_get_cc (iface); 
    7689 
    77         g_print ("CC test: %s,%s\n", str_in, str_out); 
     90        g_message ("CC test: %s,%s\n", str_in, str_out); 
    7891 
    79         gunit_fail_unless(!strcmp (str_in, str_out), "Unable to set cc!"); 
     92        gunit_fail_unless(!strcmp (str_in, str_out), "Unable to set cc!\n"); 
     93 
    8094 
    8195        return; 
    8296} 
    8397 
    84 void 
     98static void 
    8599tny_msg_header_iface_test_set_bcc (void) 
    86100{ 
    87         const gchar *str_in = "1st test string", *str_out; 
     101        const gchar *str_in = "The Invisible man <the.invisible@man.com>, mark@here.there.com", *str_out; 
    88102         
    89103        tny_msg_header_iface_set_bcc (iface, str_in); 
    90104        str_out = tny_msg_header_iface_get_bcc (iface); 
    91105 
    92         gunit_fail_unless(!strcmp (str_in, str_out), "Unable to set bcc!"); 
     106        gunit_fail_unless(!strcmp (str_in, str_out), "Unable to set bcc!\n"); 
     107 
     108        return; 
     109
     110 
     111static void 
     112tny_msg_header_iface_test_set_subject (void) 
     113
     114        const gchar *str_in = "I'm the nice subject", *str_out; 
     115         
     116        tny_msg_header_iface_set_subject (iface, str_in); 
     117        str_out = tny_msg_header_iface_get_subject (iface); 
     118 
     119        gunit_fail_unless(!strcmp (str_in, str_out), "Unable to set subject!\n"); 
     120
     121 
     122static void 
     123tny_msg_header_iface_test_set_replyto (void) 
     124
     125 
     126        GUNIT_WARNING ("TODO"); 
    93127 
    94128        return; 
     
    131165                                      tny_msg_header_iface_test_teardown)); 
    132166 
     167 
     168        gunit_test_suite_add_test_case(suite, 
     169               gunit_test_case_new_with_funcs("tny_msg_header_iface_test_set_replyto", 
     170                                      tny_msg_header_iface_test_setup, 
     171                                      tny_msg_header_iface_test_set_replyto, 
     172                                      tny_msg_header_iface_test_teardown)); 
     173 
     174        gunit_test_suite_add_test_case(suite, 
     175               gunit_test_case_new_with_funcs("tny_msg_header_iface_test_set_subject", 
     176                                      tny_msg_header_iface_test_setup, 
     177                                      tny_msg_header_iface_test_set_subject, 
     178                                      tny_msg_header_iface_test_teardown)); 
     179 
    133180        return suite; 
    134181} 
  • trunk/libtinymail-test/tny-msg-header-iface-test.h

    r128 r138  
    2424#include <tny-msg-header-iface.h> 
    2525 
    26 /* Setup & Teardown */ 
    27 void tny_msg_header_iface_test_setup    (void); 
    28 void tny_msg_header_iface_test_teardown (void); 
    29  
    30 /* Test cases */ 
    31 void tny_msg_header_iface_test_set_bcc  (void);           /* Test case 01 */ 
    32 void tny_msg_header_iface_test_set_cc   (void);           /* Test case 02 */ 
    33 void tny_msg_header_iface_test_set_to   (void);           /* Test case 03 */ 
    34 void tny_msg_header_iface_test_set_from (void);           /* Test case 04 */ 
    35  
    3626/* Test suite */ 
    3727GUnitTestSuite *create_tny_msg_header_iface_suite (void); 
    3828 
    39  
    4029#endif 
  • trunk/libtinymail/tny-msg-mime-part-iface.c

    r109 r138  
    124124 *  
    125125 * Inefficiently get a stream from a message part. The entire data of the 
    126  * the part will be kept in memory until the stream in unreferenced. 
     126 * the part will be kept in memory until the stream is unreferenced. 
    127127 * 
    128128 * Return value: An in-memory stream 
  • trunk/tinymail/tny-main.c

    r124 r138  
    5252        window = GTK_WINDOW (tny_summary_window_new ()); 
    5353 
     54TnyMsgHeaderIface *iface = tny_msg_header_new (); 
     55tny_msg_header_iface_set_subject (iface, "test"); 
     56g_print ("%s\n", tny_msg_header_iface_get_subject (iface)); 
     57 
    5458        gtk_widget_show (GTK_WIDGET (window)); 
    5559