Changeset 1478

Show
Ignore:
Timestamp:
01/26/07 11:48:24
Author:
pvanhoof
Message:

Added an AIP

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r1477 r1478  
     12007-01-26  Philip Van Hoof  <pvanhoof@gnome.org> 
     2 
     3        * Added the tny_account_set/get_mech API 
     4 
     5        * This was a major API change 
     6 
    172007-01-26  Sergio Villar Senin <svillar@igalia.com> 
    28 
  • trunk/libtinymail-camel/tny-camel-account-priv.h

    r1383 r1478  
    3131        CamelService *service; 
    3232        CamelException *ex; 
    33         gchar *url_string, *id, *user, *host, *proto
     33        gchar *url_string, *id, *user, *host, *proto, *mech
    3434        TnyGetPassFunc get_pass_func; 
    3535        TnyForgetPassFunc forget_pass_func; 
  • trunk/libtinymail-camel/tny-camel-account.c

    r1470 r1478  
    7474 * The "always" means that normal SSL is used whereas "when-possible" means  
    7575 * that TLS is tried (the STARTTLS capability of IMAP servers). 
     76 * 
    7677 **/ 
    7778void  
     
    305306 
    306307static void 
    307 tny_camel_account_set_proto (TnyAccount *self, const gchar *proto
    308 { 
    309         TNY_CAMEL_ACCOUNT_GET_CLASS (self)->set_proto_func (self, proto); 
    310 } 
    311  
    312 static void 
    313 tny_camel_account_set_proto_default (TnyAccount *self, const gchar *proto
     308tny_camel_account_set_mech (TnyAccount *self, const gchar *mech
     309{ 
     310        TNY_CAMEL_ACCOUNT_GET_CLASS (self)->set_mech_func (self, mech); 
     311} 
     312 
     313static void 
     314tny_camel_account_set_mech_default (TnyAccount *self, const gchar *mech
    314315{ 
    315316        TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
     
    317318        g_static_rec_mutex_lock (priv->service_lock); 
    318319 
    319         if (G_UNLIKELY (priv->proto)) 
    320                 g_free (priv->proto); 
    321  
    322         priv->proto = g_strdup (proto); 
     320        if (G_UNLIKELY (priv->mech)) 
     321                g_free (priv->mech); 
     322 
     323        priv->mech = g_strdup (mech); 
    323324 
    324325        TNY_CAMEL_ACCOUNT_GET_CLASS (self)->reconnect_func (TNY_CAMEL_ACCOUNT (self)); 
     
    330331 
    331332static void 
     333tny_camel_account_set_proto (TnyAccount *self, const gchar *proto) 
     334{ 
     335        TNY_CAMEL_ACCOUNT_GET_CLASS (self)->set_proto_func (self, proto); 
     336} 
     337 
     338static void 
     339tny_camel_account_set_proto_default (TnyAccount *self, const gchar *proto) 
     340{ 
     341        TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
     342 
     343        g_static_rec_mutex_lock (priv->service_lock); 
     344 
     345        if (G_UNLIKELY (priv->proto)) 
     346                g_free (priv->proto); 
     347 
     348        priv->proto = g_strdup (proto); 
     349 
     350        TNY_CAMEL_ACCOUNT_GET_CLASS (self)->reconnect_func (TNY_CAMEL_ACCOUNT (self)); 
     351         
     352        g_static_rec_mutex_unlock (priv->service_lock); 
     353 
     354        return; 
     355} 
     356 
     357static void 
    332358tny_camel_account_set_user (TnyAccount *self, const gchar *user) 
    333359{ 
     
    441467 
    442468        retval = (const gchar*)priv->id; 
     469 
     470        return retval; 
     471} 
     472 
     473static const gchar* 
     474tny_camel_account_get_mech (TnyAccount *self) 
     475{ 
     476        return TNY_CAMEL_ACCOUNT_GET_CLASS (self)->get_mech_func (self); 
     477} 
     478 
     479static const gchar* 
     480tny_camel_account_get_mech_default (TnyAccount *self) 
     481{ 
     482        TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
     483        const gchar *retval; 
     484 
     485        retval = (const gchar*)priv->mech; 
    443486 
    444487        return retval; 
     
    575618        priv->host = NULL; 
    576619        priv->proto = NULL; 
     620        priv->mech = g_strdup ("PLAIN"); 
    577621        priv->forget_pass_func_set = FALSE; 
    578622        priv->pass_func_set = FALSE; 
     
    697741                g_free (priv->host); 
    698742 
     743        if (G_LIKELY (priv->mech)) 
     744                g_free (priv->mech); 
     745 
    699746        if (G_LIKELY (priv->proto)) 
    700747                g_free (priv->proto); 
     
    724771        klass->get_proto_func = tny_camel_account_get_proto; 
    725772        klass->set_proto_func = tny_camel_account_set_proto; 
     773        klass->get_mech_func = tny_camel_account_get_mech; 
     774        klass->set_mech_func = tny_camel_account_set_mech; 
    726775        klass->get_user_func = tny_camel_account_get_user; 
    727776        klass->set_user_func = tny_camel_account_set_user; 
     
    755804        class->get_proto_func = tny_camel_account_get_proto_default; 
    756805        class->set_proto_func = tny_camel_account_set_proto_default; 
     806        class->get_mech_func = tny_camel_account_get_mech_default; 
     807        class->set_mech_func = tny_camel_account_set_mech_default; 
    757808        class->get_user_func = tny_camel_account_get_user_default; 
    758809        class->set_user_func = tny_camel_account_set_user_default; 
  • trunk/libtinymail-camel/tny-camel-account.h

    r1368 r1478  
    5959        void (*set_id_func) (TnyAccount *self, const gchar *id); 
    6060        void (*set_name_func) (TnyAccount *self, const gchar *name); 
     61        void (*set_mech_func) (TnyAccount *self, const gchar *name); 
    6162        void (*set_proto_func) (TnyAccount *self, const gchar *proto); 
    6263        void (*set_user_func) (TnyAccount *self, const gchar *user); 
     
    6970        const gchar* (*get_id_func) (TnyAccount *self); 
    7071        const gchar* (*get_name_func) (TnyAccount *self); 
     72        const gchar* (*get_mech_func) (TnyAccount *self); 
    7173        const gchar* (*get_proto_func) (TnyAccount *self); 
    7274        const gchar* (*get_user_func) (TnyAccount *self); 
  • trunk/libtinymail-camel/tny-camel-store-account.c

    r1418 r1478  
    8080                        GList *options = apriv->options; 
    8181                        gchar *proto = g_strdup_printf ("%s://", apriv->proto);  
    82  
     82                         
    8383                        url = camel_url_new (proto, apriv->ex); 
    8484                        g_free (proto); 
     
    8787                        camel_url_set_user (url, apriv->user); 
    8888                        camel_url_set_host (url, apriv->host); 
     89                        camel_url_set_authmech (url, apriv->mech); 
    8990 
    9091                        while (options) 
  • trunk/libtinymail-gnome-desktop/tny-gnome-account-store.c

    r1417 r1478  
    358358        for (i=0; i < count; i++) 
    359359        { 
    360                 gchar *proto, *type, *key, *name
     360                gchar *proto, *type, *key, *name, *mech
    361361                TnyAccount *account = NULL; 
    362362                GSList *options; 
     
    389389                        (const gchar*) key, NULL); 
    390390                g_free (key); 
    391              
     391 
     392                key = g_strdup_printf ("/apps/tinymail/accounts/%d/mech", i); 
     393                mech = gconf_client_get_string (priv->client,  
     394                        (const gchar*) key, NULL); 
     395                g_free (key); 
     396   
    392397                if (type && G_LIKELY (!g_ascii_strncasecmp (type, "transport", 9))) 
    393398                { 
     
    418423                                (const gchar*) key, NULL); 
    419424                        g_free (key); 
    420                         tny_account_set_name (TNY_ACCOUNT (account), name); 
    421                         g_free (name); 
    422  
     425 
     426 
     427                        if (name) 
     428                        { 
     429                                tny_account_set_name (TNY_ACCOUNT (account), name); 
     430                                g_free (name); 
     431                        } 
     432 
     433                        if (mech) 
     434                                tny_account_set_mech (TNY_ACCOUNT (account), mech); 
    423435 
    424436                        key = g_strdup_printf ("/apps/tinymail/accounts/%d/options", i); 
     
    496508                } 
    497509 
     510                if (mech) 
     511                        g_free (mech); 
     512 
    498513                if (proto) 
    499514                        g_free (proto); 
  • trunk/libtinymail-gpe/tny-gpe-account-store.c

    r1398 r1478  
    238238        for (i=0; i < count; i++) 
    239239        { 
    240                 gchar *proto, *type, *key, *name
     240                gchar *proto, *type, *key, *name, *mech
    241241                TnyAccount *account = NULL; 
    242242                GSList *options; 
     
    266266                key = g_strdup_printf ("/apps/tinymail/accounts/%d/proto", i); 
    267267                proto = gconf_client_get_string (priv->client,  
     268                        (const gchar*) key, NULL); 
     269                g_free (key); 
     270 
     271                key = g_strdup_printf ("/apps/tinymail/accounts/%d/mech", i); 
     272                mech = gconf_client_get_string (priv->client,  
    268273                        (const gchar*) key, NULL); 
    269274                g_free (key); 
     
    298303                                (const gchar*) key, NULL); 
    299304                        g_free (key); 
    300                         tny_account_set_name (TNY_ACCOUNT (account), name); 
    301                         g_free (name); 
     305                 
     306                        if (name) 
     307                        { 
     308                                tny_account_set_name (TNY_ACCOUNT (account), name); 
     309                                g_free (name); 
     310                        } 
     311 
     312                        if (mech) 
     313                                tny_account_set_mech (TNY_ACCOUNT (account), mech); 
    302314 
    303315 
     
    378390                if (proto) 
    379391                        g_free (proto); 
     392 
     393                if (mech) 
     394                        g_free (mech); 
     395 
    380396        } 
    381397 
  • trunk/libtinymail-maemo/tny-maemo-account-store.c

    r1398 r1478  
    239239        for (i=0; i < count; i++) 
    240240        { 
    241                 gchar *proto, *type, *key, *name
     241                gchar *proto, *type, *key, *name, *mech
    242242                TnyAccount *account = NULL; 
    243243                GSList *options; 
     
    267267                key = g_strdup_printf ("/apps/tinymail/accounts/%d/proto", i); 
    268268                proto = gconf_client_get_string (priv->client,  
     269                        (const gchar*) key, NULL); 
     270                g_free (key); 
     271 
     272                key = g_strdup_printf ("/apps/tinymail/accounts/%d/mech", i); 
     273                mech = gconf_client_get_string (priv->client,  
    269274                        (const gchar*) key, NULL); 
    270275                g_free (key); 
     
    300305                        g_free (key); 
    301306                        tny_account_set_name (TNY_ACCOUNT (account), name); 
    302                         g_free (name); 
    303  
     307                        if (name) 
     308                        { 
     309                                tny_account_set_name (TNY_ACCOUNT (account), name); 
     310                                g_free (name); 
     311                        } 
     312 
     313                        if (mech) 
     314                                tny_account_set_mech (TNY_ACCOUNT (account), mech); 
    304315 
    305316                        key = g_strdup_printf ("/apps/tinymail/accounts/%d/options", i); 
     
    380391                        g_free (proto); 
    381392 
     393                if (mech) 
     394                        g_free (mech); 
     395 
     396 
    382397        } 
    383398 
  • trunk/libtinymail-olpc/tny-olpc-account-store.c

    r1398 r1478  
    202202        { 
    203203                GKeyFile *keyfile; 
    204                 gchar *proto, *type, *key, *name
     204                gchar *proto, *type, *key, *name, *mech
    205205                TnyAccount *account = NULL; 
    206206                gchar *fullfilen = g_build_filename (g_get_home_dir(),  
     
    222222                type = g_key_file_get_value (keyfile, "tinymail", "type", NULL); 
    223223                proto = g_key_file_get_value (keyfile, "tinymail", "proto", NULL); 
     224                mech = g_key_file_get_value (keyfile, "tinymail", "mech", NULL); 
    224225             
    225226                if (type && G_LIKELY (!g_ascii_strncasecmp (type, "transport", 9))) 
     
    251252 
    252253                        name = g_key_file_get_value (keyfile, "tinymail", "name", NULL); 
    253                         tny_account_set_name (TNY_ACCOUNT (account), name); 
    254                         g_free (name); 
     254 
     255                        if (name)  
     256                        { 
     257                                tny_account_set_name (TNY_ACCOUNT (account), name); 
     258                                g_free (name); 
     259                        } 
     260 
     261                        if (mech) 
     262                                tny_account_set_mech (TNY_ACCOUNT (account), mech); 
    255263 
    256264                        options = g_key_file_get_string_list (keyfile, "tinymail", "options", &options_len, NULL); 
     
    308316                if (proto) 
    309317                        g_free (proto); 
     318                if (mech) 
     319                        g_free (mech); 
    310320 
    311321                g_key_file_free (keyfile); 
  • trunk/libtinymail/tny-account.c

    r1290 r1478  
    110110 
    111111        TNY_ACCOUNT_GET_IFACE (self)->set_name_func (self, name); 
     112        return; 
     113} 
     114 
     115/** 
     116 * tny_account_set_mech: 
     117 * @self: a #TnyAccount object 
     118 * @mech: the authentication mechanism 
     119 *  
     120 * Set the account's authentication mechanism 
     121 *  
     122 **/ 
     123void 
     124tny_account_set_mech (TnyAccount *self, const gchar *mech) 
     125{ 
     126#ifdef DEBUG 
     127        if (!TNY_ACCOUNT_GET_IFACE (self)->set_mech_func) 
     128                g_critical ("You must implement tny_account_set_mech\n"); 
     129#endif 
     130 
     131        TNY_ACCOUNT_GET_IFACE (self)->set_mech_func (self, mech); 
    112132        return; 
    113133} 
     
    456476} 
    457477 
     478 
     479/** 
     480 * tny_account_get_mech: 
     481 * @self: a #TnyAccount object 
     482 *  
     483 * Get the authentication mechanism for this account. Default is "PLAIN". 
     484 *  
     485 * Return value: the authentication mechanism as a read-only string 
     486 * 
     487 **/ 
     488const gchar* 
     489tny_account_get_mech (TnyAccount *self) 
     490{ 
     491#ifdef DEBUG 
     492        if (!TNY_ACCOUNT_GET_IFACE (self)->get_mech_func) 
     493                g_critical ("You must implement tny_account_get_mech\n"); 
     494#endif 
     495 
     496        return TNY_ACCOUNT_GET_IFACE (self)->get_mech_func (self); 
     497} 
     498 
     499 
    458500/** 
    459501 * tny_account_get_hostname: 
  • trunk/libtinymail/tny-account.h

    r1138 r1478  
    5353        void (*set_id_func) (TnyAccount *self, const gchar *id); 
    5454        void (*set_name_func) (TnyAccount *self, const gchar *name); 
     55        void (*set_mech_func) (TnyAccount *self, const gchar *name); 
    5556        void (*set_proto_func) (TnyAccount *self, const gchar *proto); 
    5657        void (*set_user_func) (TnyAccount *self, const gchar *user); 
     
    6364        const gchar* (*get_id_func) (TnyAccount *self); 
    6465        const gchar* (*get_name_func) (TnyAccount *self); 
     66        const gchar* (*get_mech_func) (TnyAccount *self); 
    6567        const gchar* (*get_proto_func) (TnyAccount *self); 
    6668        const gchar* (*get_user_func) (TnyAccount *self); 
     
    7678void tny_account_set_id (TnyAccount *self, const gchar *id); 
    7779void tny_account_set_name (TnyAccount *self, const gchar *name); 
     80void tny_account_set_mech (TnyAccount *self, const gchar *name); 
    7881void tny_account_set_proto (TnyAccount *self, const gchar *proto); 
    7982void tny_account_set_user (TnyAccount *self, const gchar *user); 
     
    8487const gchar* tny_account_get_id (TnyAccount *self); 
    8588const gchar* tny_account_get_name (TnyAccount *self); 
     89const gchar* tny_account_get_mech (TnyAccount *self); 
    8690const gchar* tny_account_get_proto (TnyAccount *self); 
    8791const gchar* tny_account_get_user (TnyAccount *self);