Changeset 1498
- Timestamp:
- 01/29/07 01:49:11
- Files:
-
- trunk/libtinymail-camel/tny-camel-account-priv.h (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-account.c (modified) (7 diffs)
- trunk/libtinymail-camel/tny-camel-account.h (modified) (2 diffs)
- trunk/libtinymail-camel/tny-session-camel.c (modified) (1 diff)
- trunk/libtinymail-olpc/tny-olpc-account-store.c (modified) (1 diff)
- trunk/libtinymail/tny-account.c (modified) (1 diff)
- trunk/libtinymail/tny-account.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libtinymail-camel/tny-camel-account-priv.h
r1490 r1498 49 49 void _tny_camel_account_start_camel_operation (TnyCamelAccount *self, CamelOperationStatusFunc func, gpointer user_data, const gchar *what); 50 50 void _tny_camel_account_stop_camel_operation (TnyCamelAccount *self); 51 void _tny_camel_account_try_connect (TnyCamelAccount *self, GError **err); 51 52 52 53 #define TNY_CAMEL_ACCOUNT_GET_PRIVATE(o) \ trunk/libtinymail-camel/tny-camel-account.c
r1490 r1498 29 29 #include <tny-folder.h> 30 30 #include <tny-camel-folder.h> 31 #include <tny-error.h> 31 32 32 33 #include <camel/camel.h> … … 94 95 } 95 96 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 { 97 void 98 _tny_camel_account_try_connect (TnyCamelAccount *self, GError **err) 99 { 100 TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 101 105 102 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->prepare_func (TNY_CAMEL_ACCOUNT (self)); 106 103 107 return; 108 } 104 if (camel_exception_is_set (priv->ex)) 105 { 106 g_set_error (err, TNY_ACCOUNT_ERROR, 107 TNY_ACCOUNT_ERROR_TRY_CONNECT, 108 camel_exception_get_description (priv->ex)); 109 } 110 111 return; 112 } 113 114 109 115 110 116 … … 703 709 **/ 704 710 void 705 tny_camel_account_set_online_status (TnyCamelAccount *self, gboolean offline )706 { 707 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->set_online_status_func (self, offline );711 tny_camel_account_set_online_status (TnyCamelAccount *self, gboolean offline, GError **err) 712 { 713 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->set_online_status_func (self, offline, err); 708 714 } 709 715 710 716 void 711 tny_camel_account_set_online_status_default (TnyCamelAccount *self, gboolean offline) 712 { 713 TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 714 715 /* TODO locking & error handling */ 717 tny_camel_account_set_online_status_default (TnyCamelAccount *self, gboolean offline, GError **err) 718 { 719 TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 720 CamelException ex = CAMEL_EXCEPTION_INITIALISER; 716 721 717 722 if (!priv->service || !CAMEL_IS_SERVICE (priv->service)) 723 { 724 if (camel_exception_is_set (priv->ex)) 725 { 726 g_set_error (err, TNY_ACCOUNT_ERROR, 727 TNY_ACCOUNT_ERROR_TRY_CONNECT, 728 camel_exception_get_description (priv->ex)); 729 } else { 730 g_set_error (err, TNY_ACCOUNT_ERROR, 731 TNY_ACCOUNT_ERROR_TRY_CONNECT, 732 _("Account not yet fully configured")); 733 } 734 718 735 return; 719 720 /* _tny_camel_account_start_camel_operation (self, NULL, NULL, NULL); */ 721 722 /* g_static_rec_mutex_lock (priv->service_lock); */ 736 } 723 737 724 738 if (offline) 725 739 camel_service_cancel_connect (priv->service); 726 740 727 741 if (CAMEL_IS_DISCO_STORE (priv->service)) { 728 742 if (!offline) { 729 743 camel_disco_store_set_status (CAMEL_DISCO_STORE (priv->service), 730 CAMEL_DISCO_STORE_ONLINE, priv->ex);744 CAMEL_DISCO_STORE_ONLINE, &ex); 731 745 goto done; 732 746 } else if (camel_disco_store_can_work_offline (CAMEL_DISCO_STORE (priv->service))) { … … 734 748 camel_disco_store_set_status (CAMEL_DISCO_STORE (priv->service), 735 749 CAMEL_DISCO_STORE_OFFLINE, 736 priv->ex);750 &ex); 737 751 goto done; 738 752 } … … 743 757 camel_offline_store_set_network_state (CAMEL_OFFLINE_STORE (priv->service), 744 758 CAMEL_OFFLINE_STORE_NETWORK_AVAIL, 745 priv->ex);759 &ex); 746 760 goto done; 747 761 } else { 748 762 camel_offline_store_set_network_state (CAMEL_OFFLINE_STORE (priv->service), 749 763 CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL, 750 priv->ex);764 &ex); 751 765 goto done; 752 766 } 753 767 } 754 768 755 769 if (offline) 756 770 camel_service_disconnect (CAMEL_SERVICE (priv->service), 757 TRUE, priv->ex);771 TRUE, &ex); 758 772 759 773 done: 760 /* g_static_rec_mutex_unlock (priv->service_lock); */ 761 /* _tny_camel_account_stop_camel_operation (self); */ 774 775 if (camel_exception_is_set (&ex)) 776 { 777 g_set_error (err, TNY_ACCOUNT_ERROR, 778 TNY_ACCOUNT_ERROR_TRY_CONNECT, 779 camel_exception_get_description (&ex)); 780 } 762 781 763 782 return; … … 835 854 TnyAccountIface *klass = (TnyAccountIface *)g; 836 855 837 klass->try_connect_func = tny_camel_account_try_connect;838 856 klass->get_port_func = tny_camel_account_get_port; 839 857 klass->set_port_func = tny_camel_account_set_port; … … 870 888 object_class = (GObjectClass*) class; 871 889 872 class->try_connect_func = tny_camel_account_try_connect_default;873 890 class->get_port_func = tny_camel_account_get_port_default; 874 891 class->set_port_func = tny_camel_account_set_port_default; trunk/libtinymail-camel/tny-camel-account.h
r1485 r1498 75 75 76 76 void (*add_option_func) (TnyCamelAccount *self, const gchar *option); 77 void (*set_online_status_func) (TnyCamelAccount *self, gboolean offline );77 void (*set_online_status_func) (TnyCamelAccount *self, gboolean offline, GError **err); 78 78 79 79 /* Abstract methods */ … … 85 85 void tny_camel_account_add_option (TnyCamelAccount *self, const gchar *option); 86 86 void tny_camel_account_set_session (TnyCamelAccount *self, TnySessionCamel *session); 87 void tny_camel_account_set_online_status (TnyCamelAccount *self, gboolean offline );87 void tny_camel_account_set_online_status (TnyCamelAccount *self, gboolean offline, GError **err); 88 88 89 89 G_END_DECLS trunk/libtinymail-camel/tny-session-camel.c
r1496 r1498 559 559 GError *err = NULL; 560 560 561 tny_account_try_connect (TNY_ACCOUNT (data), &err); 561 _tny_camel_account_try_connect (TNY_CAMEL_ACCOUNT (data), &err); 562 562 563 if (err == NULL) 563 tny_camel_account_set_online_status (TNY_CAMEL_ACCOUNT (data), !online); 564 else 564 tny_camel_account_set_online_status (TNY_CAMEL_ACCOUNT (data), !online, &err); 565 566 if (err != NULL) 567 { 565 568 tny_session_camel_alert_user (session, CAMEL_SESSION_ALERT_ERROR, err->message, FALSE); 569 g_error_free (err); 570 } 566 571 } 567 572 } trunk/libtinymail-olpc/tny-olpc-account-store.c
r1485 r1498 288 288 tny_account_set_port (TNY_ACCOUNT (account), port); 289 289 290 if (err != NULL) 291 g_error_free (err); 292 290 293 g_free (hostname); g_free (user); 291 294 } else { trunk/libtinymail/tny-account.c
r1485 r1498 22 22 #include <tny-account.h> 23 23 24 25 /**26 * tny_account_try_connect:27 * @self: a #TnyAccount object28 * @err: a #GError instance or NULL29 *30 * Try to connect. This can put a reason why connecting failed in @err.31 **/32 void33 tny_account_try_connect (TnyAccount *self, GError **err)34 {35 #ifdef DEBUG36 if (!TNY_ACCOUNT_GET_IFACE (self)->try_connect_func)37 g_critical ("You must implement tny_account_get_id\n");38 #endif39 40 return TNY_ACCOUNT_GET_IFACE (self)->try_connect_func (self, err);41 }42 24 43 25 /** trunk/libtinymail/tny-account.h
r1485 r1498 72 72 const gchar* (*get_url_string_func) (TnyAccount *self); 73 73 TnyAccountType (*get_account_type_func) (TnyAccount *self); 74 void (*try_connect_func) (TnyAccount *self, GError **err);75 74 }; 76 75 … … 100 99 void tny_account_set_forget_pass_func (TnyAccount *self, TnyForgetPassFunc forget_pass_func); 101 100 TnyForgetPassFunc tny_account_get_forget_pass_func (TnyAccount *self); 102 void tny_account_try_connect (TnyAccount *self, GError **err);103 101 104 102 G_END_DECLS
