Changeset 3609

Show
Ignore:
Timestamp:
04/22/08 12:26:13
Author:
pvanhoof
Message:

2008-04-22 Philip Van Hoof <pvanhoof@gnome.org>

        • tny_camel_account_add_option changed !!
        • tny_camel_account_clear_options added
        • tny_camel_account_get_options added
        • This was a major API change in libtinymail-camel
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r3601 r3609  
     12008-04-22  Philip Van Hoof <pvanhoof@gnome.org> 
     2 
     3        * tny_camel_account_add_option changed !! 
     4        * tny_camel_account_clear_options added 
     5        * tny_camel_account_get_options added 
     6 
     7        * This was a major API change in libtinymail-camel 
     8 
    192008-04-20  Philip Van Hoof <pvanhoof@gnome.org> 
    210 
  • trunk/bindings/python/tinymail-camel-base.defs

    r3275 r3609  
    191191  (return-type "none") 
    192192  (parameters 
    193     '("const-gchar*" "option") 
     193    '("TnyPair" "option") 
    194194  ) 
    195195) 
  • trunk/docs/devel/reference/tmpl/tny-account-store.sgml

    r3606 r3609  
    4949 
    5050</para> 
    51  
    52 @: 
    5351 
    5452@tnyaccountstore: the object which received the signal. 
  • trunk/docs/devel/reference/tmpl/tny-account.sgml

    r3606 r3609  
    2828 
    2929</para> 
     30 
     31@: 
    3032 
    3133@tnyaccount: the object which received the signal. 
  • trunk/docs/devel/reference/tmpl/tny-device.sgml

    r3606 r3609  
    3636 
    3737</para> 
    38  
    39 @:  
    40 @: 
    4138 
    4239@tnydevice: the object which received the signal. 
  • trunk/docs/devel/reference/tmpl/tny-send-queue.sgml

    r3606 r3609  
    4040</para> 
    4141 
     42@:  
     43@:  
     44@:  
     45@: 
     46 
    4247@tnysendqueue: the object which received the signal. 
    4348@arg1:  
     
    4954 
    5055</para> 
     56 
     57@:  
     58@:  
     59@:  
     60@:  
     61@: 
    5162 
    5263@tnysendqueue: the object which received the signal. 
     
    6172</para> 
    6273 
     74@:  
     75@:  
     76@:  
     77@:  
     78@: 
     79 
    6380@tnysendqueue: the object which received the signal. 
    6481@arg1:  
     
    7289</para> 
    7390 
    74 @: 
    75  
    7691@tnysendqueue: the object which received the signal. 
    7792 
     
    8095 
    8196</para> 
    82  
    83 @: 
    8497 
    8598@tnysendqueue: the object which received the signal. 
  • trunk/docs/devel/reference/tmpl/tny-shared.sgml

    r3606 r3609  
    5454</para> 
    5555 
    56 @tnyaccountstore: the object which received the signal. 
     56@:  
    5757 
    5858<!-- ##### STRUCT TnyAccountStoreIface ##### --> 
     
    263263</para> 
    264264 
    265 @:  
     265@tnyaccount: the object which received the signal. 
    266266 
    267267<!-- ##### SIGNAL TnyAccount::connection-status-changed ##### --> 
     
    322322</para> 
    323323 
    324 @tnydevice: the object which received the signal. 
    325 @arg1:  
     324@:  
     325@:  
    326326 
    327327<!-- ##### STRUCT TnyDeviceIface ##### --> 
     
    494494</para> 
    495495 
     496@tnysendqueue: the object which received the signal. 
     497@arg1:  
     498@arg2:  
     499@arg3:  
     500 
     501<!-- ##### SIGNAL TnySendQueue::msg-sending ##### --> 
     502<para> 
     503 
     504</para> 
     505 
     506@tnysendqueue: the object which received the signal. 
     507@arg1:  
     508@arg2:  
     509@arg3:  
     510@arg4:  
     511 
     512<!-- ##### SIGNAL TnySendQueue::msg-sent ##### --> 
     513<para> 
     514 
     515</para> 
     516 
     517@tnysendqueue: the object which received the signal. 
     518@arg1:  
     519@arg2:  
     520@arg3:  
     521@arg4:  
     522 
     523<!-- ##### SIGNAL TnySendQueue::queue-start ##### --> 
     524<para> 
     525 
     526</para> 
     527 
    496528@:  
     529 
     530<!-- ##### SIGNAL TnySendQueue::queue-stop ##### --> 
     531<para> 
     532 
     533</para> 
     534 
    497535@:  
    498 @:  
    499 @:  
    500  
    501 <!-- ##### SIGNAL TnySendQueue::msg-sending ##### --> 
    502 <para> 
    503  
    504 </para> 
    505  
    506 @:  
    507 @:  
    508 @:  
    509 @:  
    510 @:  
    511  
    512 <!-- ##### SIGNAL TnySendQueue::msg-sent ##### --> 
    513 <para> 
    514  
    515 </para> 
    516  
    517 @:  
    518 @:  
    519 @:  
    520 @:  
    521 @:  
    522  
    523 <!-- ##### SIGNAL TnySendQueue::queue-start ##### --> 
    524 <para> 
    525  
    526 </para> 
    527  
    528 @tnysendqueue: the object which received the signal. 
    529  
    530 <!-- ##### SIGNAL TnySendQueue::queue-stop ##### --> 
    531 <para> 
    532  
    533 </para> 
    534  
    535 @tnysendqueue: the object which received the signal. 
    536536 
    537537<!-- ##### STRUCT TnySendQueueIface ##### --> 
  • trunk/libtinymail-camel/tny-camel-account.c

    r3590 r3609  
    156156        g_object_unref (info->self); 
    157157        return; 
     158} 
     159 
     160static void 
     161output_param (GQuark key_id, gpointer data, gpointer user_data) 
     162{ 
     163        TnyCamelAccountPriv *apriv = user_data; 
     164 
     165        if (*(char *)data) { 
     166                apriv->options = g_list_prepend (apriv->options,  
     167                        g_strdup_printf ("%s=%s",  
     168                                g_quark_to_string (key_id),  
     169                                (const gchar*) data)); 
     170        } 
    158171} 
    159172 
     
    231244 
    232245                if (url) { 
     246                        if (url->params) 
     247                                g_datalist_foreach (&url->params, output_param, apriv); 
     248 
    233249                        if (apriv->proto) 
    234250                                g_free (apriv->proto); 
     
    418434 * tny_camel_account_add_option: 
    419435 * @self: a #TnyCamelAccount object 
    420  * @option: a "key=value" Camel option 
     436 * @option: a #TnyPair Camel option 
    421437 * 
    422438 * Add a Camel option to this #TnyCamelAccount instance.  
    423  
     439 * 
    424440 * An often used option is the use_ssl one. For example "use_ssl=wrapped" or  
    425441 * "use_ssl=tls" are the typical options added. Other possibilities for the  
    426442 * "use_ssl" option are "never" and "when-possible": 
     443 * 
     444 * <informalexample><programlisting> 
     445 * tny_camel_account_add_option (account, tny_pair_new ("use_ssl", "tls")) 
     446 * </programlisting></informalexample> 
    427447 * 
    428448 * use_ssl=wrapped will wrap the connection on default port 993 with IMAP and 
     
    458478 **/ 
    459479void  
    460 tny_camel_account_add_option (TnyCamelAccount *self, const gchar *option) 
     480tny_camel_account_add_option (TnyCamelAccount *self, TnyPair *option) 
    461481{ 
    462482        TNY_CAMEL_ACCOUNT_GET_CLASS (self)->add_option(self, option); 
    463483} 
    464484 
    465 void  
    466 tny_camel_account_add_option_default (TnyCamelAccount *self, const gchar *option) 
     485static void  
     486tny_camel_account_add_option_default (TnyCamelAccount *self, TnyPair *option) 
    467487{ 
    468488        TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
    469489        GList *copy = priv->options; 
    470490        gboolean found = FALSE; 
     491        gchar *option_str; 
    471492 
    472493        if (!option) 
    473494                return; 
    474495 
    475         while (copy)  
    476         { 
     496        if (!TNY_IS_PAIR (option)) { 
     497                g_critical ("The tny_camel_account_add_option API has changed. " 
     498                "Instead of a string you must now pass a TnyPair instance"); 
     499        } 
     500 
     501        g_assert (TNY_IS_PAIR (option)); 
     502 
     503        option_str = g_strdup_printf ("%s=%s", 
     504                tny_pair_get_name (option),  
     505                tny_pair_get_value (option)); 
     506 
     507        while (copy)  { 
    477508                gchar *str = (gchar *) copy->data; 
    478509 
    479                 if (str && !strcmp (option, str)) 
    480                 { 
     510                if (str && !strcmp (option_str, str)) { 
    481511                        found = TRUE; 
    482512                        break; 
     
    485515        } 
    486516 
    487         if (!found) 
    488         { 
    489                 priv->options = g_list_prepend (priv->options, g_strdup (option)); 
     517        if (!found) { 
     518                priv->options = g_list_prepend (priv->options, g_strdup (option_str)); 
     519                TNY_CAMEL_ACCOUNT_GET_CLASS (self)->prepare(self, TRUE, FALSE); 
     520                _tny_camel_account_emit_changed (self); 
     521        } 
     522 
     523        g_free (option_str); 
     524 
     525        return; 
     526
     527 
     528 
     529/** 
     530 * tny_camel_account_get_options: 
     531 * @self: a #TnyCamelAccount object 
     532 * @options: a #TnyList  
     533 * 
     534 * Get options of this #TnyCamelAccount instance. @options will be filled with 
     535 * #TnyPair instances. 
     536 **/ 
     537void  
     538tny_camel_account_get_options (TnyCamelAccount *self, TnyList *options) 
     539
     540        TNY_CAMEL_ACCOUNT_GET_CLASS (self)->get_options (self, options); 
     541
     542 
     543 
     544 
     545static void  
     546tny_camel_account_get_options_default (TnyCamelAccount *self, TnyList *options) 
     547
     548        TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
     549        GList *copy = priv->options; 
     550 
     551        if (!options) 
     552                return; 
     553 
     554        while (copy)  { 
     555                gchar *str = g_strdup (copy->data); 
     556                gchar *key = str; 
     557                gchar *value = strchr (str, '='); 
     558                TnyPair *pair; 
     559 
     560                *value = '\0'; 
     561                value++; 
     562 
     563                pair = tny_pair_new (key, value); 
     564                g_free (str); 
     565 
     566                tny_list_prepend (options, (GObject *) pair); 
     567 
     568                copy = g_list_next (copy); 
     569        } 
     570 
     571        return; 
     572
     573 
     574 
     575/** 
     576 * tny_camel_account_clear_options: 
     577 * @self: a #TnyCamelAccount object 
     578 * 
     579 * Clear options of this #TnyCamelAccount instance. 
     580 **/ 
     581void  
     582tny_camel_account_clear_options (TnyCamelAccount *self) 
     583
     584        TNY_CAMEL_ACCOUNT_GET_CLASS (self)->clear_options (self); 
     585
     586 
     587 
     588static void  
     589tny_camel_account_clear_options_default (TnyCamelAccount *self) 
     590
     591        TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
     592 
     593        if (priv->options) { 
     594                g_list_foreach (priv->options, (GFunc)g_free, NULL); 
     595                g_list_free (priv->options); 
     596                priv->options = NULL; 
     597 
    490598                TNY_CAMEL_ACCOUNT_GET_CLASS (self)->prepare(self, TRUE, FALSE); 
    491599                _tny_camel_account_emit_changed (self); 
     
    624732tny_camel_account_stop_camel_operation_priv (TnyCamelAccountPriv *priv) 
    625733{ 
    626         if (priv->cancel) 
    627         { 
     734        if (priv->cancel) { 
    628735                camel_operation_unregister (priv->cancel); 
    629736                camel_operation_end (priv->cancel); 
     
    680787        TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
    681788 
    682         if (priv->cancel) 
    683         { 
     789        if (priv->cancel) { 
    684790                g_static_rec_mutex_lock (priv->cancel_lock); 
    685791                tny_camel_account_stop_camel_operation_priv (priv); 
     
    20282134        priv->inuse_spin = FALSE; 
    20292135 
    2030         if (priv->options) 
    2031         { 
     2136        if (priv->options) { 
    20322137                g_list_foreach (priv->options, (GFunc)g_free, NULL); 
    20332138                g_list_free (priv->options); 
     
    21922297 
    21932298        class->add_option= tny_camel_account_add_option_default; 
     2299        class->clear_options= tny_camel_account_clear_options_default; 
     2300        class->get_options= tny_camel_account_get_options_default; 
     2301 
    21942302        class->set_online= tny_camel_account_set_online_default; 
    21952303 
  • trunk/libtinymail-camel/tny-camel-account.h

    r3304 r3609  
    8989        void (*stop_operation) (TnyAccount *self, gboolean *canceled); 
    9090 
    91         void (*add_option) (TnyCamelAccount *self, const gchar *option); 
     91        void (*add_option) (TnyCamelAccount *self, TnyPair *option); 
     92        void (*clear_options) (TnyCamelAccount *self); 
     93        void (*get_options) (TnyCamelAccount *self, TnyList *options); 
     94 
    9295        void (*set_online) (TnyCamelAccount *self, gboolean online, TnyCamelSetOnlineCallback callback, gpointer user_data); 
    9396 
     
    102105GType tny_camel_account_get_type (void); 
    103106 
    104 void tny_camel_account_add_option (TnyCamelAccount *self, const gchar *option); 
     107void tny_camel_account_get_options (TnyCamelAccount *self, TnyList *options); 
     108void tny_camel_account_clear_options (TnyCamelAccount *self); 
     109void tny_camel_account_add_option (TnyCamelAccount *self, TnyPair *option); 
    105110void tny_camel_account_set_session (TnyCamelAccount *self, TnySessionCamel *session); 
    106111void tny_camel_account_set_online (TnyCamelAccount *self, gboolean online, TnyCamelSetOnlineCallback callback, gpointer user_data); 
  • trunk/libtinymail-gnome-desktop/tny-gnome-account-store.c

    r3592 r3609  
    247247                        g_free (key); 
    248248 
    249                         if (options) 
    250                         { 
     249                        if (options) { 
    251250                                GSList *tmp = options; 
    252                                 while (options) 
    253                                 { 
    254                                         tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (account), options->data); 
     251                                while (options) { 
     252                                        gchar *key = options->data; 
     253                                        gchar *value = strchr (options->data, '='); 
     254                                        *value = '\0'; 
     255                                        value++; 
     256 
     257                                        tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (account),  
     258                                                tny_pair_new (key, value)); 
     259 
    255260                                        g_free (options->data); 
    256261                                        options = g_slist_next (options); 
  • trunk/libtinymail-gpe/tny-gpe-account-store.c

    r3592 r3609  
    248248                        g_free (key); 
    249249 
    250                         if (options) 
    251                         { 
    252                                 while (options) 
    253                                 { 
    254                                         tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (account), options->data); 
     250                        if (options) { 
     251                                while (options) { 
     252                                        gchar *key = options->data; 
     253                                        gchar *value = strchr (options->data, '='); 
     254                                        *value = '\0'; 
     255                                        value++; 
     256 
     257                                        tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (account),  
     258                                                tny_pair_new (key, value)); 
    255259                                        g_free (options->data); 
    256260                                        options = g_slist_next (options); 
  • trunk/libtinymail-maemo/tny-maemo-account-store.c

    r3592 r3609  
    255255                        g_free (key); 
    256256 
    257                         if (options) 
    258                         { 
    259                                 while (options) 
    260                                 { 
    261                                         tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (account), options->data); 
     257                        if (options) { 
     258                                while (options) { 
     259                                        gchar *key = options->data; 
     260                                        gchar *value = strchr (options->data, '='); 
     261                                        *value = '\0'; 
     262                                        value++; 
     263 
     264                                        tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (account),  
     265                                                tny_pair_new (key, value)); 
    262266                                        g_free (options->data); 
    263267                                        options = g_slist_next (options); 
  • trunk/libtinymail-olpc/tny-olpc-account-store.c

    r3592 r3609  
    219219 
    220220                        options = g_key_file_get_string_list (keyfile, "tinymail", "options", &options_len, NULL); 
    221                         if (options) 
    222                         { 
    223                                 for (i=0; i<options_len; i++) 
    224                                         tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (account), options[i]); 
     221                        if (options) { 
     222                                for (i=0; i < options_len; i++) { 
     223                                        gchar *key = options[i]; 
     224                                        gchar *value = strchr (options[i], '='); 
     225                                        *value = '\0'; 
     226                                        value++; 
     227                                        tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (account),  
     228                                                tny_pair_new (key, value)); 
     229                                } 
    225230                                g_strfreev (options); 
    226231                        } 
  • trunk/tests/shared/account-store.c

    r3422 r3609  
    6666 
    6767static gboolean 
    68 tny_test_account_store_alert (TnyAccountStore *self, TnyAccount *account, TnyAlertType type, gboolean question, const GError *error) 
     68tny_test_account_store_alert (TnyAccountStore *self, TnyAccount *account, TnyAlertType type, gboolean question, GError *error) 
    6969{ 
    7070        return TRUE; 
     
    296296        klass->alert= tny_test_account_store_alert; 
    297297        klass->get_device= tny_test_account_store_get_device; 
    298      
     298 
    299299        return; 
    300300}