Changeset 1305
- Timestamp:
- 12/08/06 13:52:19
- Files:
-
- trunk/libtinymail-camel/tny-camel-account.c (modified) (5 diffs)
- trunk/libtinymail-camel/tny-camel-store-account.c (modified) (2 diffs)
- trunk/libtinymail-camel/tny-camel-transport-account.c (modified) (2 diffs)
- trunk/libtinymail-camel/tny-session-camel.c (modified) (3 diffs)
- trunk/tinymail/tny-demoui-summary-view.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libtinymail-camel/tny-camel-account.c
r1304 r1305 160 160 GThread *thread; 161 161 162 g_mutex_lock (priv->cancel_lock); 162 g_mutex_lock (priv->cancel_lock); 163 163 164 164 /* I know this isn't polite. But it works ;-) */ … … 260 260 { 261 261 TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 262 262 263 263 g_static_rec_mutex_lock (priv->service_lock); 264 264 … … 499 499 if (!priv->service) 500 500 return; 501 501 502 502 _tny_camel_account_start_camel_operation (self, NULL, NULL, NULL); 503 503 504 g_static_rec_mutex_lock (priv->service_lock); 505 504 506 if (offline) 505 507 camel_service_cancel_connect (priv->service); … … 537 539 TRUE, priv->ex); 538 540 done: 539 541 g_static_rec_mutex_unlock (priv->service_lock); 540 542 _tny_camel_account_stop_camel_operation (self); 541 543 … … 546 548 tny_camel_account_finalize (GObject *object) 547 549 { 548 TnyCamelAccount *self = (TnyCamelAccount *)object; 550 TnyCamelAccount *self = (TnyCamelAccount *)object; 549 551 TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 550 552 trunk/libtinymail-camel/tny-camel-store-account.c
r1304 r1305 74 74 tny_camel_store_account_reconnect (TnyCamelAccount *self) 75 75 { 76 TnyCamelAccountPriv * priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self);77 78 if (G_LIKELY ( priv->session) && G_UNLIKELY (priv->proto) &&79 G_UNLIKELY ( priv->user) && G_UNLIKELY (priv->host))80 { 81 if (! priv->url_string)76 TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 77 78 if (G_LIKELY (apriv->session) && G_UNLIKELY (apriv->proto) && 79 G_UNLIKELY (apriv->user) && G_UNLIKELY (apriv->host)) 80 { 81 if (!apriv->url_string) 82 82 { 83 83 CamelURL *url = NULL; 84 GList *options = priv->options; 85 86 gchar *proto = g_strdup_printf ("%s://", priv->proto); 87 88 url = camel_url_new (proto, priv->ex); 84 GList *options = apriv->options; 85 gchar *proto = g_strdup_printf ("%s://", apriv->proto); 86 87 url = camel_url_new (proto, apriv->ex); 89 88 g_free (proto); 90 91 camel_url_set_protocol (url, priv->proto);92 camel_url_set_user (url, priv->user);93 camel_url_set_host (url, priv->host);94 89 90 camel_url_set_protocol (url, apriv->proto); 91 camel_url_set_user (url, apriv->user); 92 camel_url_set_host (url, apriv->host); 93 95 94 while (options) 96 95 { 97 96 gchar *ptr, *dup = g_strdup (options->data); 98 97 gchar *option, *value; 99 100 98 ptr = strchr (dup, '='); 101 102 if (ptr) 103 { 99 if (ptr) { 104 100 ptr++; 105 101 value = g_strdup (ptr); ptr--; … … 109 105 value = g_strdup ("1"); 110 106 } 111 112 107 camel_url_set_param (url, option, value); 113 114 108 g_free (value); 115 116 109 g_free (dup); 117 118 110 options = g_list_next (options); 119 111 } 120 112 121 if (G_LIKELY (priv->url_string)) 122 g_free (priv->url_string); 123 124 priv->url_string = camel_url_to_string (url, 0); 125 113 if (G_LIKELY (apriv->url_string)) 114 g_free (apriv->url_string); 115 116 apriv->url_string = camel_url_to_string (url, 0); 126 117 camel_url_free (url); 127 118 128 /* TODO: lock ->service */ 129 priv->service = camel_session_get_service 130 ((CamelSession*) priv->session, priv->url_string, 131 priv->type, priv->ex); 132 133 /* TODO: lock ->service */ 134 if (priv->service == NULL) 135 report_error (priv); 119 g_static_rec_mutex_lock (apriv->service_lock); 120 apriv->service = camel_session_get_service 121 ((CamelSession*) apriv->session, apriv->url_string, 122 apriv->type, apriv->ex); 123 if (apriv->service == NULL) 124 report_error (apriv); 125 g_static_rec_mutex_unlock (apriv->service_lock); 126 127 /* TODO: Handle priv->ex using GError */ 136 128 } 137 } else if (G_LIKELY (priv->session) && (priv->url_string)) 138 { 139 /* un officially supported provider */ 140 141 /* TODO: lock ->service */ 142 priv->service = camel_session_get_service 143 ((CamelSession*) priv->session, priv->url_string, 144 priv->type, priv->ex); 145 146 /* TODO: lock ->service */ 147 if (priv->service == NULL) 148 report_error (priv); 149 } 150 151 if ( G_LIKELY (priv->service) && G_UNLIKELY (priv->pass_func_set) 152 && G_UNLIKELY (priv->forget_pass_func_set) ) 153 { 154 priv->connected = FALSE; 155 156 if (!camel_service_connect (priv->service, priv->ex)) 157 { 158 g_warning (_("Not connected with %s: %s\n"), priv->url_string, 159 camel_exception_get_description (priv->ex)); 160 camel_exception_clear (priv->ex); 161 /* camel_service_cancel_connect (priv->service); 162 camel_service_disconnect (priv->service, FALSE, priv->ex); */ 129 } else if (G_LIKELY (apriv->session) && (apriv->url_string)) 130 { 131 g_static_rec_mutex_lock (apriv->service_lock); 132 /* camel_session_get_service can launch GUI things */ 133 apriv->service = camel_session_get_service 134 ((CamelSession*) apriv->session, apriv->url_string, 135 apriv->type, apriv->ex); 136 if (apriv->service == NULL) 137 report_error (apriv); 138 g_static_rec_mutex_unlock (apriv->service_lock); 139 140 /* TODO: Handle priv->ex using GError */ 141 } 142 143 if ( G_LIKELY (apriv->service) && G_UNLIKELY (apriv->pass_func_set) 144 && G_UNLIKELY (apriv->forget_pass_func_set) ) 145 { 146 apriv->connected = FALSE; 147 148 g_static_rec_mutex_lock (apriv->service_lock); 149 /* camel_service_connect can launch GUI things */ 150 if (!camel_service_connect (apriv->service, apriv->ex)) 151 { 152 /* TODO: Handle priv->ex using GError */ 153 g_warning (_("Not connected with %s: %s\n"), apriv->url_string, 154 camel_exception_get_description (apriv->ex)); 155 camel_exception_clear (apriv->ex); 163 156 } else { 164 priv->connected = TRUE;157 apriv->connected = TRUE; 165 158 } 159 g_static_rec_mutex_unlock (apriv->service_lock); 160 161 /* TODO: Handle priv->ex using GError */ 166 162 } 167 163 trunk/libtinymail-camel/tny-camel-transport-account.c
r1304 r1305 57 57 tny_camel_transport_account_reconnect (TnyCamelAccount *self) 58 58 { 59 TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 60 61 printf ("recon\n"); 62 63 if (G_LIKELY (priv->session) && G_UNLIKELY (priv->proto) && G_UNLIKELY (priv->host)) 59 TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 60 CamelException ex = CAMEL_EXCEPTION_INITIALISER; 61 62 if (G_LIKELY (apriv->session) && G_UNLIKELY (apriv->proto) && G_UNLIKELY (apriv->host)) 64 63 { 65 64 GString *urlstr = g_string_new (""); 66 65 67 if ( priv->url_string)68 g_free ( priv->url_string);69 70 urlstr = g_string_append (urlstr, priv->proto);66 if (apriv->url_string) 67 g_free (apriv->url_string); 68 69 urlstr = g_string_append (urlstr, apriv->proto); 71 70 urlstr = g_string_append (urlstr, "://"); 72 71 73 if ( priv->user)72 if (apriv->user) 74 73 { 75 urlstr = g_string_append (urlstr, priv->user);74 urlstr = g_string_append (urlstr, apriv->user); 76 75 urlstr = g_string_append (urlstr, "@"); 77 76 } 78 77 79 urlstr = g_string_append (urlstr, priv->host); 80 81 priv->url_string = urlstr->str; 82 83 /* TODO: lock ->service */ 84 priv->service = camel_session_get_service 85 ((CamelSession*) priv->session, priv->url_string, 86 priv->type, priv->ex); 78 urlstr = g_string_append (urlstr, apriv->host); 79 80 apriv->url_string = urlstr->str; 81 82 /* TODO: check for old instance and clear it */ 83 g_static_rec_mutex_lock (apriv->service_lock); 84 /* camel_session_get_service can launch GUI things */ 85 apriv->service = camel_session_get_service 86 ((CamelSession*) apriv->session, apriv->url_string, 87 apriv->type, &ex); 87 88 /* TODO: check ex and handle it with a GError */ 88 if (camel_exception_is_set ( priv->ex))89 if (camel_exception_is_set (&ex)) 89 90 g_error ("Can't get service for transport account (%s)\n", 90 camel_exception_get_description (priv->ex)); 91 92 if (!camel_service_connect (priv->service, priv->ex)) 93 { 94 g_warning (_("Not connected with %s: %s\n"), priv->url_string, 95 camel_exception_get_description (priv->ex)); 96 camel_exception_clear (priv->ex); 97 } 98 91 camel_exception_get_description (&ex)); 92 g_static_rec_mutex_unlock (apriv->service_lock); 93 99 94 g_string_free (urlstr, FALSE); 100 } else if (priv->url_string) 101 { 102 103 /* TODO: lock ->service */ 95 } else if (apriv->url_string) 96 { 97 104 98 /* TODO: check for old instance and clear it */ 105 106 priv->service = camel_session_get_service 107 ((CamelSession*) priv->session, priv->url_string, 108 priv->type, priv->ex); 109 110 if (camel_exception_is_set (priv->ex)) 99 g_static_rec_mutex_lock (apriv->service_lock); 100 /* camel_session_get_service can launch GUI things */ 101 apriv->service = camel_session_get_service 102 ((CamelSession*) apriv->session, apriv->url_string, 103 apriv->type, &ex); 104 /* TODO: check ex and handle it with a GError */ 105 if (camel_exception_is_set (&ex)) 111 106 g_error ("Can't get service for transport account (%s)\n", 112 camel_exception_get_description (priv->ex)); 113 /* TODO: check ex and handle it with a GError */ 114 115 if (!camel_service_connect (priv->service, priv->ex)) 116 { 117 g_warning (_("Not connected with %s: %s\n"), priv->url_string, 118 camel_exception_get_description (priv->ex)); 119 camel_exception_clear (priv->ex); 120 } 107 camel_exception_get_description (&ex)); 108 g_static_rec_mutex_unlock (apriv->service_lock); 121 109 } 122 110 } … … 137 125 TnyHeader *header; CamelMimeMessage *message; 138 126 CamelException ex = CAMEL_EXCEPTION_INITIALISER; 139 CamelTransport *transport; 140 const gchar *str = NULL; 127 CamelTransport *transport; const gchar *str = NULL; 141 128 CamelInternetAddress *from, *recipients; 142 129 143 130 g_assert (TNY_IS_CAMEL_MSG (msg)); 144 131 g_assert (CAMEL_IS_SESSION (apriv->session)); 145 146 /* TODO: lock ->service */ 147 if (!apriv->service) 148 { /* TODO do some more checking on ->service */ 149 g_critical ("No service, going to try getting a forced online one"); 150 transport = camel_session_get_transport ((CamelSession*) apriv->session, 151 apriv->url_string, &ex); 132 g_assert (CAMEL_IS_SERVICE (apriv->service)); 133 transport = (CamelTransport *) apriv->service; 134 g_assert (CAMEL_IS_TRANSPORT (transport)); 135 136 g_static_rec_mutex_lock (apriv->service_lock); 137 /* camel_service_connect can launch GUI things */ 138 if (!apriv->connected && !camel_service_connect (apriv->service, &ex)) 139 { 152 140 if (camel_exception_is_set (&ex)) 153 g_critical ("Didn't work (%s)", 141 { 142 g_set_error (err, TNY_TRANSPORT_ACCOUNT_ERROR, 143 TNY_TRANSPORT_ACCOUNT_ERROR_SEND, 154 144 camel_exception_get_description (&ex)); 155 apriv->service = (CamelService*) transport; 156 } else 157 { 158 if (!camel_service_connect (apriv->service, apriv->ex)) 159 { 160 g_warning (_("Not connected with %s: %s\n"), apriv->url_string, 161 camel_exception_get_description (apriv->ex)); 162 camel_exception_clear (apriv->ex); 145 g_static_rec_mutex_unlock (apriv->service_lock); 146 return; 163 147 } 164 } 165 166 if (camel_exception_is_set (&ex) || !transport) 167 { 168 g_set_error (err, TNY_TRANSPORT_ACCOUNT_ERROR, 169 TNY_TRANSPORT_ACCOUNT_ERROR_SEND, 170 camel_exception_get_description (&ex)); 171 172 if (transport && CAMEL_IS_OBJECT (transport)) 173 camel_object_unref (CAMEL_OBJECT (transport)); 174 175 return; 176 } 177 178 g_assert (CAMEL_IS_TRANSPORT (transport)); 148 } else { 149 apriv->connected = TRUE; 150 } 151 g_static_rec_mutex_unlock (apriv->service_lock); 179 152 180 153 header = tny_msg_get_header (msg); trunk/libtinymail-camel/tny-session-camel.c
r1304 r1305 203 203 } 204 204 205 206 /* Will be called at camel_service_connect in case the account needs a password. 207 its implementation can contani GUI things. */ 205 208 static char * 206 209 tny_session_camel_get_password (CamelSession *session, CamelService *service, const char *domain, … … 256 259 } 257 260 261 262 /* Will be called at camel_service_connect in case the entered password was wrong */ 258 263 static void 259 264 tny_session_camel_forget_password (CamelSession *session, CamelService *service, const char *domain, const char *item, CamelException *ex) … … 283 288 return; 284 289 } 290 291 /* tny_session_camel_alert_user will for example be called when SSL is on and 292 camel_session_get_service is issued (for example TnyCamelTransportAccount and 293 TnyCamelStore account issue this function). Its implementation is often done 294 with GUI components (it should therefore not be called from a thread). This 295 is a known issue (and the person who fixed this, please remove this warning) */ 285 296 286 297 static gboolean trunk/tinymail/tny-demoui-summary-view.c
r1304 r1305 556 556 { 557 557 558 /* DEBUG */558 /* DEBUG 559 559 TnyAccountStore *astore = priv->account_store; 560 560 TnyList *accs = tny_simple_list_new (); … … 573 573 g_object_unref (G_OBJECT (iter)); 574 574 g_object_unref (G_OBJECT (accs)); 575 575 */ 576 576 577 577 msgwin = tny_gtk_msg_window_new (
