Changeset 1485
- Timestamp:
- 01/27/07 17:57:13
- Files:
-
- trunk/ChangeLog (modified) (1 diff)
- trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c (modified) (3 diffs)
- trunk/libtinymail-camel/tny-camel-account-priv.h (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-account.c (modified) (15 diffs)
- trunk/libtinymail-camel/tny-camel-account.h (modified) (3 diffs)
- trunk/libtinymail-camel/tny-camel-store-account.c (modified) (4 diffs)
- trunk/libtinymail-camel/tny-camel-transport-account.c (modified) (3 diffs)
- trunk/libtinymail-camel/tny-session-camel.c (modified) (5 diffs)
- trunk/libtinymail-gnome-desktop/tny-gnome-account-store.c (modified) (2 diffs)
- trunk/libtinymail-gpe/tny-gpe-account-store.c (modified) (2 diffs)
- trunk/libtinymail-maemo/tny-maemo-account-store.c (modified) (2 diffs)
- trunk/libtinymail-olpc/tny-olpc-account-store.c (modified) (4 diffs)
- trunk/libtinymail/tny-account.c (modified) (3 diffs)
- trunk/libtinymail/tny-account.h (modified) (4 diffs)
- trunk/libtinymail/tny-error.c (modified) (2 diffs)
- trunk/libtinymail/tny-error.h (modified) (2 diffs)
- trunk/tinymail/tny-demoui-summary-view.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r1484 r1485 9 9 * First LEMONADE feature, implemented support for the CONDSTORE 10 10 capability in camel-lite's IMAP provider (RFC 4551) 11 * Changed some things about connecting, including the introduction of 12 a new api tny_account_try_connect. All this connecting stuff is yet 13 uncertain though. 14 15 * This was a major API change 11 16 12 17 2007-01-26 Philip Van Hoof <pvanhoof@gnome.org> trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c
r1483 r1485 2345 2345 int retry; 2346 2346 2347 /* TNY TODO: Implement partial message retrieval if full==TRUE */2348 2349 2347 mi = (CamelImapMessageInfo *)camel_folder_summary_uid (folder->summary, uid); 2350 2348 if (mi == NULL) { … … 2358 2356 if ( (stream = camel_imap_folder_fetch_data (imap_folder, uid, "", TRUE, type, param, NULL)) 2359 2357 && (msg = get_message_simple(imap_folder, uid, stream, type, param, ex))) 2358 goto done; 2359 2360 2361 if (camel_disco_store_status (CAMEL_DISCO_STORE (folder->parent_store)) == CAMEL_DISCO_STORE_OFFLINE) 2360 2362 goto done; 2361 2363 … … 2446 2448 && camel_exception_get_id(ex) == CAMEL_EXCEPTION_SERVICE_UNAVAILABLE); 2447 2449 2448 done: /* FIXME, this shouldn't be done this way. */ 2449 if (msg) 2450 camel_medium_set_header (CAMEL_MEDIUM (msg), "X-Evolution-Source", store->base_url); 2450 done: 2451 2451 2452 fail: 2452 2453 camel_message_info_free(&mi->info); trunk/libtinymail-camel/tny-camel-account-priv.h
r1478 r1485 40 40 gboolean connected, inuse_spin; 41 41 gchar *name; GList *options; 42 gchar *cache_location; 42 gchar *cache_location; gint port; 43 43 TnyAccountType account_type; 44 44 }; trunk/libtinymail-camel/tny-camel-account.c
r1483 r1485 89 89 priv->options = g_list_prepend (priv->options, g_strdup (option)); 90 90 91 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->reconnect_func (TNY_CAMEL_ACCOUNT (self)); 91 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->prepare_func (self); 92 93 return; 94 } 95 96 static void 97 tny_camel_account_try_connect (TnyAccount *self, GError **err) 98 { 99 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->try_connect_func (self, err); 100 } 101 102 static void 103 tny_camel_account_try_connect_default (TnyAccount *self, GError **err) 104 { 105 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->prepare_func (TNY_CAMEL_ACCOUNT (self)); 92 106 93 107 return; … … 111 125 priv->url_string = g_strdup (url_string); 112 126 113 if (G_UNLIKELY (!TNY_CAMEL_ACCOUNT_GET_CLASS (self)->reconnect_func)) 114 g_error ("This TnyAccount instance isn't a fully implemented type\n"); 115 116 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->reconnect_func ((TnyCamelAccount*)self); 127 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->prepare_func (TNY_CAMEL_ACCOUNT (self)); 117 128 118 129 return; … … 279 290 g_static_rec_mutex_lock (priv->service_lock); 280 291 priv->session = session; 281 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->reconnect_func (self);282 292 _tny_session_camel_add_account (session, self); 293 294 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->prepare_func (self); 295 283 296 g_static_rec_mutex_unlock (priv->service_lock); 284 297 … … 323 336 priv->mech = g_strdup (mech); 324 337 325 TNY_CAMEL_ACCOUNT_GET_CLASS (self)-> reconnect_func (TNY_CAMEL_ACCOUNT (self));326 338 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->prepare_func (TNY_CAMEL_ACCOUNT (self)); 339 327 340 g_static_rec_mutex_unlock (priv->service_lock); 328 341 … … 348 361 priv->proto = g_strdup (proto); 349 362 350 TNY_CAMEL_ACCOUNT_GET_CLASS (self)-> reconnect_func (TNY_CAMEL_ACCOUNT (self));351 363 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->prepare_func (TNY_CAMEL_ACCOUNT (self)); 364 352 365 g_static_rec_mutex_unlock (priv->service_lock); 353 366 … … 373 386 priv->user = g_strdup (user); 374 387 375 TNY_CAMEL_ACCOUNT_GET_CLASS (self)-> reconnect_func (TNY_CAMEL_ACCOUNT (self));388 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->prepare_func (TNY_CAMEL_ACCOUNT (self)); 376 389 377 390 g_static_rec_mutex_unlock (priv->service_lock); … … 398 411 priv->host = g_strdup (host); 399 412 400 TNY_CAMEL_ACCOUNT_GET_CLASS (self)-> reconnect_func (TNY_CAMEL_ACCOUNT (self));413 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->prepare_func (TNY_CAMEL_ACCOUNT (self)); 401 414 402 415 g_static_rec_mutex_unlock (priv->service_lock); … … 404 417 return; 405 418 } 419 420 421 422 static void 423 tny_camel_account_set_port (TnyAccount *self, guint port) 424 { 425 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->set_port_func (self, port); 426 } 427 428 static void 429 tny_camel_account_set_port_default (TnyAccount *self, guint port) 430 { 431 TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 432 433 g_static_rec_mutex_lock (priv->service_lock); 434 435 priv->port = (gint) port; 436 437 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->prepare_func (TNY_CAMEL_ACCOUNT (self)); 438 439 g_static_rec_mutex_unlock (priv->service_lock); 440 441 return; 442 } 443 406 444 407 445 static void … … 422 460 priv->pass_func_set = TRUE; 423 461 424 if (G_UNLIKELY (!TNY_CAMEL_ACCOUNT_GET_CLASS (self)->reconnect_func)) 425 g_error ("This TnyAccount instance isn't a fully implemented type\n"); 426 427 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->reconnect_func ((TnyCamelAccount*)self); 462 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->prepare_func (TNY_CAMEL_ACCOUNT (self)); 428 463 429 464 g_static_rec_mutex_unlock (priv->service_lock); … … 449 484 priv->forget_pass_func_set = TRUE; 450 485 486 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->prepare_func (TNY_CAMEL_ACCOUNT (self)); 487 451 488 g_static_rec_mutex_unlock (priv->service_lock); 452 489 … … 531 568 tny_camel_account_get_hostname_default (TnyAccount *self) 532 569 { 533 TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 570 TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 534 571 const gchar *retval; 535 572 … … 537 574 538 575 return retval; 576 } 577 578 579 580 static guint 581 tny_camel_account_get_port (TnyAccount *self) 582 { 583 return TNY_CAMEL_ACCOUNT_GET_CLASS (self)->get_port_func (self); 584 } 585 586 static guint 587 tny_camel_account_get_port_default (TnyAccount *self) 588 { 589 TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 590 return (guint)priv->port; 539 591 } 540 592 … … 602 654 TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 603 655 656 priv->port = -1; 604 657 priv->cache_location = NULL; 605 658 priv->service = NULL; … … 767 820 TnyAccountIface *klass = (TnyAccountIface *)g; 768 821 822 klass->try_connect_func = tny_camel_account_try_connect; 823 klass->get_port_func = tny_camel_account_get_port; 824 klass->set_port_func = tny_camel_account_set_port; 769 825 klass->get_hostname_func = tny_camel_account_get_hostname; 770 826 klass->set_hostname_func = tny_camel_account_set_hostname; … … 799 855 object_class = (GObjectClass*) class; 800 856 801 857 class->try_connect_func = tny_camel_account_try_connect_default; 858 class->get_port_func = tny_camel_account_get_port_default; 859 class->set_port_func = tny_camel_account_set_port_default; 802 860 class->get_hostname_func = tny_camel_account_get_hostname_default; 803 861 class->set_hostname_func = tny_camel_account_set_hostname_default; trunk/libtinymail-camel/tny-camel-account.h
r1478 r1485 49 49 GObjectClass parent; 50 50 51 /* This is an abstract method (it's not implemented by52 TnyCamelAccount, it's also not virtual) */53 54 void (*reconnect_func) (TnyCamelAccount *self);55 56 51 /* Virtual methods */ 57 58 52 gboolean (*is_connected_func)(TnyAccount *self); 59 53 void (*set_id_func) (TnyAccount *self, const gchar *id); … … 63 57 void (*set_user_func) (TnyAccount *self, const gchar *user); 64 58 void (*set_hostname_func) (TnyAccount *self, const gchar *host); 59 void (*set_port_func) (TnyAccount *self, guint port); 65 60 void (*set_url_string_func) (TnyAccount *self, const gchar *url_string); 66 61 void (*set_pass_func_func) (TnyAccount *self, TnyGetPassFunc get_pass_func); … … 74 69 const gchar* (*get_user_func) (TnyAccount *self); 75 70 const gchar* (*get_hostname_func) (TnyAccount *self); 71 guint (*get_port_func) (TnyAccount *self); 76 72 const gchar* (*get_url_string_func) (TnyAccount *self); 77 73 TnyAccountType (*get_account_type_func) (TnyAccount *self); 74 void (*try_connect_func) (TnyAccount *self, GError **err); 78 75 79 76 void (*add_option_func) (TnyCamelAccount *self, const gchar *option); 80 77 void (*set_online_status_func) (TnyCamelAccount *self, gboolean offline); 81 78 79 /* Abstract methods */ 80 void (*prepare_func) (TnyCamelAccount *self); 82 81 }; 83 82 trunk/libtinymail-camel/tny-camel-store-account.c
r1483 r1485 54 54 static GObjectClass *parent_class = NULL; 55 55 56 static void 57 report_error (TnyCamelAccountPriv *priv) 58 { 59 if (G_UNLIKELY (priv->service == NULL)) 60 { 61 g_error (_("Couldn't get service %s: %s\n"), priv->url_string, 62 camel_exception_get_description (priv->ex)); 63 camel_exception_clear (priv->ex); 56 static void 57 tny_camel_store_account_prepare (TnyCamelAccount *self) 58 { 59 TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 60 61 CamelURL *url = NULL; 62 GList *options = apriv->options; 63 gchar *proto; 64 65 if (apriv->proto == NULL) 64 66 return; 65 } 66 } 67 68 69 static void 70 tny_camel_store_account_reconnect (TnyCamelAccount *self) 71 { 72 TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 73 74 if (G_LIKELY (apriv->session) && G_UNLIKELY (apriv->proto) && 75 G_UNLIKELY (apriv->user) && G_UNLIKELY (apriv->host)) 76 { 77 if (!apriv->url_string) 78 { 79 CamelURL *url = NULL; 80 GList *options = apriv->options; 81 gchar *proto = g_strdup_printf ("%s://", apriv->proto); 82 83 url = camel_url_new (proto, apriv->ex); 84 g_free (proto); 85 86 camel_url_set_protocol (url, apriv->proto); 87 camel_url_set_user (url, apriv->user); 88 camel_url_set_host (url, apriv->host); 89 90 if (apriv->mech) 91 camel_url_set_authmech (url, apriv->mech); 92 93 while (options) 94 { 95 gchar *ptr, *dup = g_strdup (options->data); 96 gchar *option, *value; 97 ptr = strchr (dup, '='); 98 if (ptr) { 99 ptr++; 100 value = g_strdup (ptr); ptr--; 101 *ptr = '\0'; option = dup; 102 } else { 103 option = dup; 104 value = g_strdup ("1"); 105 } 106 camel_url_set_param (url, option, value); 107 g_free (value); 108 g_free (dup); 109 options = g_list_next (options); 110 } 111 112 if (G_LIKELY (apriv->url_string)) 113 g_free (apriv->url_string); 114 115 apriv->url_string = camel_url_to_string (url, 0); 116 camel_url_free (url); 117 118 g_static_rec_mutex_lock (apriv->service_lock); 119 apriv->service = camel_session_get_service 120 ((CamelSession*) apriv->session, apriv->url_string, 121 apriv->type, apriv->ex); 122 if (apriv->service == NULL) 123 report_error (apriv); 124 g_static_rec_mutex_unlock (apriv->service_lock); 125 126 /* TODO: Handle priv->ex using GError */ 67 68 proto = g_strdup_printf ("%s://", apriv->proto); 69 70 url = camel_url_new (proto, apriv->ex); 71 g_free (proto); 72 73 if (!url) 74 return; 75 76 camel_url_set_protocol (url, apriv->proto); 77 camel_url_set_user (url, apriv->user); 78 camel_url_set_host (url, apriv->host); 79 80 if (apriv->port != -1) 81 camel_url_set_port (url, (int)apriv->port); 82 83 if (apriv->mech) 84 camel_url_set_authmech (url, apriv->mech); 85 86 while (options) 87 { 88 gchar *ptr, *dup = g_strdup (options->data); 89 gchar *option, *value; 90 ptr = strchr (dup, '='); 91 if (ptr) { 92 ptr++; 93 value = g_strdup (ptr); ptr--; 94 *ptr = '\0'; option = dup; 95 } else { 96 option = dup; 97 value = g_strdup ("1"); 127 98 } 128 } else if (G_LIKELY (apriv->session) && (apriv->url_string)) 129 { 130 g_static_rec_mutex_lock (apriv->service_lock); 131 /* camel_session_get_service can launch GUI things */ 99 camel_url_set_param (url, option, value); 100 g_free (value); 101 g_free (dup); 102 options = g_list_next (options); 103 } 104 105 if (G_LIKELY (apriv->url_string)) 106 g_free (apriv->url_string); 107 108 apriv->url_string = camel_url_to_string (url, 0); 109 camel_url_free (url); 110 111 /* TODO: check for old instance and clear it */ 112 113 g_static_rec_mutex_lock (apriv->service_lock); 114 if (apriv->session) 132 115 apriv->service = camel_session_get_service 133 116 ((CamelSession*) apriv->session, apriv->url_string, 134 117 apriv->type, apriv->ex); 135 if (apriv->service == NULL) 136 report_error (apriv); 137 g_static_rec_mutex_unlock (apriv->service_lock); 138 139 /* TODO: Handle priv->ex using GError */ 140 } 141 142 if ( G_LIKELY (apriv->service) && G_UNLIKELY (apriv->pass_func_set) 143 && G_UNLIKELY (apriv->forget_pass_func_set) ) 144 { 145 apriv->connected = FALSE; 146 147 g_static_rec_mutex_lock (apriv->service_lock); 148 /* camel_service_connect can launch GUI things */ 149 if (!camel_service_connect (apriv->service, apriv->ex)) 150 { 151 /* TODO: Handle priv->ex using GError */ 152 g_warning (_("Not connected with %s: %s\n"), apriv->url_string, 153 camel_exception_get_description (apriv->ex)); 118 g_static_rec_mutex_unlock (apriv->service_lock); 119 } 120 121 static void 122 tny_camel_store_account_try_connect (TnyAccount *self, GError **err) 123 { 124 TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 125 126 if (!apriv->url_string || !apriv->service) 127 { 128 if (camel_exception_is_set (apriv->ex)) 129 { 130 g_set_error (err, TNY_ACCOUNT_ERROR, 131 TNY_ACCOUNT_ERROR_TRY_CONNECT, 132 camel_exception_get_description (apriv->ex)); 154 133 camel_exception_clear (apriv->ex); 155 134 } else { 135 g_set_error (err, TNY_ACCOUNT_ERROR, 136 TNY_ACCOUNT_ERROR_TRY_CONNECT, 137 _("Account not yet fully configured")); 138 } 139 140 return; 141 } 142 143 if (apriv->pass_func_set && apriv->forget_pass_func_set) 144 { 145 CamelException ex = CAMEL_EXCEPTION_INITIALISER; 146 apriv->connected = FALSE; 147 148 if (camel_exception_is_set (apriv->ex)) 149 camel_exception_clear (apriv->ex); 150 151 g_static_rec_mutex_lock (apriv->service_lock); 152 153 /* camel_service_connect can launch GUI things */ 154 if (!camel_service_connect (apriv->service, &ex)) 155 { 156 if (camel_exception_is_set (&ex)) 157 { 158 g_set_error (err, TNY_ACCOUNT_ERROR, 159 TNY_ACCOUNT_ERROR_TRY_CONNECT, 160 camel_exception_get_description (&ex)); 161 camel_exception_clear (&ex); 162 } else { 163 g_set_error (err, TNY_ACCOUNT_ERROR, 164 TNY_ACCOUNT_ERROR_TRY_CONNECT, 165 _("Unknown error while connecting")); 166 } 167 } else { 156 168 apriv->connected = TRUE; 169 /* tny_camel_account_set_online_status (self, !apriv->connected); */ 157 170 } 171 158 172 g_static_rec_mutex_unlock (apriv->service_lock); 159 160 /* TODO: Handle priv->ex using GError */ 173 174 } else { 175 g_set_error (err, TNY_ACCOUNT_ERROR, 176 TNY_ACCOUNT_ERROR_TRY_CONNECT, 177 _("Get and Forget password functions not yet set")); 161 178 } 162 179 … … 704 721 object_class->finalize = tny_camel_store_account_finalize; 705 722 706 ((TnyCamelAccountClass*)class)->reconnect_func = tny_camel_store_account_reconnect; 723 TNY_CAMEL_ACCOUNT_CLASS (class)->try_connect_func = tny_camel_store_account_try_connect; 724 TNY_CAMEL_ACCOUNT_CLASS (class)->prepare_func = tny_camel_store_account_prepare; 707 725 708 726 class->get_folders_async_func = tny_camel_store_account_get_folders_async_default; … … 710 728 class->create_folder_func = tny_camel_store_account_create_folder_default; 711 729 class->remove_folder_func = tny_camel_store_account_remove_folder_default; 712 730 713 731 g_type_class_add_private (object_class, sizeof (TnyCamelStoreAccountPriv)); 714 732 … … 758 776 NULL /* interface_data */ 759 777 }; 760 778 761 779 type = g_type_register_static (TNY_TYPE_CAMEL_ACCOUNT, 762 780 "TnyCamelStoreAccount", 763 781 &info, 0); 764 782 765 g_type_add_interface_static (type, TNY_TYPE_FOLDER_STORE,783 g_type_add_interface_static (type, TNY_TYPE_FOLDER_STORE, 766 784 &tny_folder_store_info); 767 785 768 786 g_type_add_interface_static (type, TNY_TYPE_STORE_ACCOUNT, 769 787 &tny_store_account_info); 770 771 788 772 789 } 773 790 trunk/libtinymail-camel/tny-camel-transport-account.c
r1480 r1485 55 55 56 56 static void 57 tny_camel_transport_account_reconnect (TnyCamelAccount *self) 57 tny_camel_transport_account_prepare (TnyCamelAccount *self) 58 { 59 TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 60 61 CamelURL *url = NULL; 62 GList *options = apriv->options; 63 gchar *proto; 64 65 if (apriv->proto == NULL) 66 return; 67 68 proto = g_strdup_printf ("%s://", apriv->proto); 69 70 url = camel_url_new (proto, apriv->ex); 71 g_free (proto); 72 73 if (!url) 74 return; 75 76 camel_url_set_protocol (url, apriv->proto); 77 78 if (apriv->user) 79 camel_url_set_user (url, apriv->user); 80 81 camel_url_set_host (url, apriv->host); 82 83 if (apriv->port != -1) 84 camel_url_set_port (url, (int)apriv->port); 85 86 if (apriv->mech) 87 camel_url_set_authmech (url, apriv->mech); 88 89 while (options) 90 { 91 gchar *ptr, *dup = g_strdup (options->data); 92 gchar *option, *value; 93 ptr = strchr (dup, '='); 94 if (ptr) { 95 ptr++; 96 value = g_strdup (ptr); ptr--; 97 *ptr = '\0'; option = dup; 98 } else { 99 option = dup; 100 value = g_strdup ("1"); 101 } 102 camel_url_set_param (url, option, value); 103 g_free (value); 104 g_free (dup); 105 options = g_list_next (options); 106 } 107 108 if (G_LIKELY (apriv->url_string)) 109 g_free (apriv->url_string); 110 111 apriv->url_string = camel_url_to_string (url, 0); 112 camel_url_free (url); 113 114 /* TODO: check for old instance and clear it */ 115 116 g_static_rec_mutex_lock (apriv->service_lock); 117 /* camel_session_get_service can launch GUI things */ 118 if (apriv->session) 119 apriv->service = camel_session_get_service 120 ((CamelSession*) apriv->session, apriv->url_string, 121 apriv->type, apriv->ex); 122 g_static_rec_mutex_unlock (apriv->service_lock); 123 124 return; 125 } 126 127 static void 128 tny_camel_transport_account_try_connect (TnyAccount *self, GError **err) 58 129 { 59 130 TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 60 131 CamelException ex = CAMEL_EXCEPTION_INITIALISER; 61 132 62 if (G_LIKELY (apriv->session) && G_UNLIKELY (apriv->proto) && G_UNLIKELY (apriv->host)) 63 { 64 CamelURL *url = NULL; 65 GList *options = apriv->options; 66 gchar *proto = g_strdup_printf ("%s://", apriv->proto); 67 68 url = camel_url_new (proto, apriv->ex); 69 g_free (proto); 70 71 camel_url_set_protocol (url, apriv->proto); 72 73 if (apriv->user) 74 camel_url_set_user (url, apriv->user); 75 76 camel_url_set_host (url, apriv->host); 77 78 if (apriv->mech) 79 camel_url_set_authmech (url, apriv->mech); 80 81 while (options) 82 { 83 gchar *ptr, *dup = g_strdup (options->data); 84 gchar *option, *value; 85 ptr = strchr (dup, '='); 86 if (ptr) { 87 ptr++; 88 value = g_strdup (ptr); ptr--; 89 *ptr = '\0'; option = dup; 133 if (!apriv->url_string || !apriv->service) 134 { 135 if (camel_exception_is_set (apriv->ex)) 136 { 137 g_set_error (err, TNY_ACCOUNT_ERROR, 138 TNY_ACCOUNT_ERROR_TRY_CONNECT, 139 camel_exception_get_description (apriv->ex)); 140 camel_exception_clear (apriv->ex); 141 } else { 142 g_set_error (err, TNY_ACCOUNT_ERROR, 143 TNY_ACCOUNT_ERROR_TRY_CONNECT, 144 _("Account not yet fully configured")); 145 } 146 147 return; 148 } 149 150 151 if (apriv->pass_func_set && apriv->forget_pass_func_set) 152 { 153 154 CamelException ex = CAMEL_EXCEPTION_INITIALISER; 155 apriv->connected = FALSE; 156 157 if (camel_exception_is_set (apriv->ex)) 158 camel_exception_clear (apriv->ex); 159 160 /* g_static_rec_mutex_lock (apriv->service_lock); 161 162 camel_service_connect can launch GUI things 163 164 if (!camel_service_connect (apriv->service, &ex)) 165 { 166 if (camel_exception_is_set (&ex)) 167 { 168 g_set_error (err, TNY_ACCOUNT_ERROR, 169 TNY_ACCOUNT_ERROR_TRY_CONNECT, 170 camel_exception_get_description (&ex)); 171 camel_exception_clear (apriv->ex); 90 172 } else { 91 option = dup; 92 value = g_strdup ("1"); 173 g_set_error (err, TNY_ACCOUNT_ERROR, 174 TNY_ACCOUNT_ERROR_TRY_CONNECT, 175 _("Unknown error while connecting")); 93 176 } 94 camel_url_set_param (url, option, value); 95 g_free (value); 96 g_free (dup); 97 options = g_list_next (options); 177 } else { 178 apriv->connected = TRUE; 179 tny_camel_account_set_online_status (self, !apriv->connected); 98 180 } 99 181 100 if (G_LIKELY (apriv->url_string))101 g_free (apriv->url_string);102 103 apriv->url_string = camel_url_to_string (url, 0);104 camel_url_free (url);105 106 107 /* TODO: check for old instance and clear it */108 g_static_rec_mutex_lock (apriv->service_lock);109 /* camel_session_get_service can launch GUI things */110 apriv->service = camel_session_get_service111 ((CamelSession*) apriv->session, apriv->url_string,112 apriv->type, &ex);113 /* TODO: check ex and handle it with a GError */114 if (camel_exception_is_set (&ex))115 g_error ("Can't get service for transport account (%s)\n",116 camel_exception_get_description (&ex));117 182 g_static_rec_mutex_unlock (apriv->service_lock); 118 119 } else if (apriv->url_string) 120 { 121 122 /* TODO: check for old instance and clear it */ 123 g_static_rec_mutex_lock (apriv->service_lock); 124 /* camel_session_get_service can launch GUI things */ 125 apriv->service = camel_session_get_service 126 ((CamelSession*) apriv->session, apriv->url_string, 127 apriv->type, &ex); 128 /* TODO: check ex and handle it with a GError */ 129 if (camel_exception_is_set (&ex)) 130 g_error ("Can't get service for transport account (%s)\n", 131 camel_exception_get_description (&ex)); 132 g_static_rec_mutex_unlock (apriv->service_lock); 133 } 183 */ 184 185 } else { 186 g_set_error (err, TNY_ACCOUNT_ERROR, 187 TNY_ACCOUNT_ERROR_TRY_CONNECT, 188 _("Get and Forget password functions not yet set")); 189 } 190 134 191 } 135 192 … … 157 214 transport = (CamelTransport *) apriv->service; 158 215 g_assert (CAMEL_IS_TRANSPORT (transport)); 216 217 /* TODO: Why not simply use tny_account_try_connect here ? */ 159 218 160 219 g_static_rec_mutex_lock (apriv->service_lock); … … 279 338 object_class->finalize = tny_camel_transport_account_finalize; 280 339 281 TNY_CAMEL_ACCOUNT_CLASS (class)-> reconnect_func = tny_camel_transport_account_reconnect;340 TNY_CAMEL_ACCOUNT_CLASS (class)->try_connect_func = tny_camel_transport_account_try_connect; 282 341 283 342 g_type_class_add_private (object_class, sizeof (TnyCamelTransportAccountPriv)); trunk/libtinymail-camel/tny-session-camel.c
r1419 r1485 36 36 37 37 #include <tny-session-camel.h> 38 #include <tny-account.h> 38 39 39 40 #include <tny-device.h> … … 711 712 } 712 713 713 static void714 foreach_account_set_connectivity (gpointer data, gpointer udata)715 {716 gboolean online = (gboolean)udata;717 if (data && TNY_IS_CAMEL_ACCOUNT (data))718 tny_camel_account_set_online_status (TNY_CAMEL_ACCOUNT (data), !online);719 }720 721 722 714 typedef struct 723 715 { … … 727 719 } BackgroundConnectInfo; 728 720 721 static void 722 foreach_account_set_connectivity (gpointer data, gpointer udata) 723 { 724 BackgroundConnectInfo *info = udata; 725 gboolean online = (gboolean)udata; 726 CamelSession *session = info->user_data; 727 728 if (data && TNY_IS_CAMEL_ACCOUNT (data)) 729 { 730 GError *err = NULL; 731 732 tny_account_try_connect (TNY_ACCOUNT (data), &err); 733 if (err == NULL) 734 tny_camel_account_set_online_status (TNY_CAMEL_ACCOUNT (data), !online); 735 else 736 tny_session_camel_alert_user (session, CAMEL_SESSION_ALERT_ERROR, err->message, FALSE); 737 } 738 } 739 729 740 730 741 static void … … 764 775 { 765 776 g_list_foreach (priv->current_accounts, 766 foreach_account_set_connectivity, (gpointer) info->online);777 foreach_account_set_connectivity, info); 767 778 } 768 779 … … 809 820 return; 810 821 } 822 811 823 812 824 /** trunk/libtinymail-gnome-desktop/tny-gnome-account-store.c
r1478 r1485 349 349 { 350 350 TnyGnomeAccountStorePriv *priv = TNY_GNOME_ACCOUNT_STORE_GET_PRIVATE (self); 351 gint i=0, count ;351 gint i=0, count, port; 352 352 353 353 g_assert (TNY_IS_LIST (list)); … … 471 471 tny_account_set_hostname (TNY_ACCOUNT (account), 472 472 hostname); 473 473 474 key = g_strdup_printf ("/apps/tinymail/accounts/%d/port", i); 475 port = gconf_client_get_int (priv->client, 476 (const gchar*) key, NULL); 477 g_free (key); 478 if (port != 0) tny_account_set_port (TNY_ACCOUNT (account), 479 port); 480 474 481 g_free (hostname); g_free (user); 475 482 } else { trunk/libtinymail-gpe/tny-gpe-account-store.c
r1478 r1485 229 229 { 230 230 TnyGpeAccountStorePriv *priv = TNY_GPE_ACCOUNT_STORE_GET_PRIVATE (self); 231 gint i=0, count ;231 gint i=0, count, port; 232 232 233 233 g_assert (TNY_IS_LIST (list)); … … 350 350 tny_account_set_hostname (TNY_ACCOUNT (account), 351 351 hostname); 352 352 353 key = g_strdup_printf ("/apps/tinymail/accounts/%d/port", i); 354 port = gconf_client_get_int (priv->client, 355 (const gchar*) key, NULL); 356 g_free (key); 357 if (port != 0) tny_account_set_port (TNY_ACCOUNT (account), 358 port); 359 353 360 g_free (hostname); g_free (user); 354 361 } else { trunk/libtinymail-maemo/tny-maemo-account-store.c
r1478
