Changeset 2298
- Timestamp:
- 06/28/07 20:38:07
- Files:
-
- trunk/ChangeLog (modified) (1 diff)
- trunk/libtinymail-camel/camel-lite/camel/camel-service.c (modified) (5 diffs)
- trunk/libtinymail-camel/camel-lite/camel/camel-service.h (modified) (2 diffs)
- trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c (modified) (2 diffs)
- trunk/libtinymail-camel/tny-camel-account-priv.h (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-account.c (modified) (5 diffs)
- trunk/libtinymail-camel/tny-camel-pop-store-account.c (modified) (2 diffs)
- trunk/libtinymail-camel/tny-camel-store-account-priv.h (modified) (2 diffs)
- trunk/libtinymail-camel/tny-camel-store-account.c (modified) (8 diffs)
- trunk/libtinymail-camel/tny-session-camel.c (modified) (3 diffs)
- trunk/libtinymail-gnome-desktop/tny-gnome-device.c (modified) (1 diff)
- trunk/tests/c-demo/tny-demoui-summary-view.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r2297 r2298 4 4 * Detecting connection changes with the connection_status_changed 5 5 signal on TnyAccount 6 * Multiple fixes when reconnecting 7 * Initial folder-list when starting the application offline 6 8 7 9 * This was a major API change trunk/libtinymail-camel/camel-lite/camel/camel-service.c
r2221 r2298 88 88 camel_service_class->get_name = get_name; 89 89 camel_service_class->get_path = get_path; 90 91 camel_object_class_add_event(object_class, "disconnection", NULL);92 camel_object_class_add_event(object_class, "connection", NULL);93 camel_object_class_add_event(object_class, "reconnection", NULL);94 camel_object_class_add_event(object_class, "reconnecting", NULL);95 96 90 } 97 91 … … 101 95 CamelService *service = o; 102 96 97 service->connecting = NULL; 98 service->reconnecter = NULL; 99 service->reconnection = NULL; 100 service->disconnecting = NULL; 103 101 service->reconnecting = FALSE; 102 104 103 service->data = NULL; 105 104 service->priv = g_malloc0(sizeof(*service->priv)); … … 119 118 CSERV_CLASS (service)->disconnect (service, TRUE, &ex); 120 119 121 camel_object_trigger_event (CAMEL_OBJECT (service),122 "disconnection", (gpointer) TRUE);120 if (service->disconnecting) 121 service->disconnecting (service, TRUE, service->data); 123 122 124 123 if (camel_exception_is_set (&ex)) { … … 394 393 } 395 394 396 camel_object_trigger_event (CAMEL_OBJECT (service),397 "connection", (gpointer) ret);395 if (service->disconnecting) 396 service->connecting (service, ret, service->data); 398 397 399 398 CAMEL_SERVICE_UNLOCK (service, connect_op_lock); … … 460 459 service->connect_op = NULL; 461 460 462 camel_object_trigger_event (CAMEL_OBJECT (service),463 "disconnection", (gpointer) clean);461 if (service->disconnecting) 462 service->disconnecting (service, clean, service->data); 464 463 465 464 CAMEL_SERVICE_UNLOCK (service, connect_op_lock); trunk/libtinymail-camel/camel-lite/camel/camel-service.h
r2218 r2298 60 60 } CamelServiceConnectionStatus; 61 61 62 typedef void (*con_op) (CamelService *service, gboolean suc, gpointer data); 63 62 64 struct _CamelService { 63 65 CamelObject parent_object; … … 71 73 gpointer data; 72 74 gboolean reconnecting; 75 76 con_op connecting; 77 con_op disconnecting; 78 con_op reconnecter; 79 con_op reconnection; 73 80 }; 74 81 trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c
r2248 r2298 148 148 camel_imap_recon (CamelImapStore *store, CamelException *mex) 149 149 { 150 CAMEL_SERVICE (store)->reconnecting = TRUE; 151 152 camel_object_trigger_event (CAMEL_OBJECT (store), 153 "reconnecting", (gpointer) FALSE); 154 155 camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); 156 camel_service_connect (CAMEL_SERVICE (store), mex); 150 CamelService *service = CAMEL_SERVICE (store); 151 152 service->reconnecting = TRUE; 153 if (service->reconnecter) 154 service->reconnecter (service, FALSE, service->data); 155 156 camel_service_disconnect (service, FALSE, NULL); 157 camel_service_connect (service, mex); 157 158 158 159 if (mex && camel_exception_is_set (mex)) … … 160 161 camel_exception_clear (mex); 161 162 sleep (1); 162 camel_service_connect (CAMEL_SERVICE (store), mex); 163 } 164 if (!camel_exception_is_set (mex)) 165 camel_object_trigger_event (CAMEL_OBJECT (store), 166 "reconnection", (gpointer) TRUE); 163 camel_service_connect (service, mex); 164 } 165 if (!camel_exception_is_set (mex) && service->reconnection) 166 service->reconnection (service, TRUE, service->data); 167 167 else 168 camel_object_trigger_event (CAMEL_OBJECT (store), 169 "reconnection", (gpointer) FALSE); 170 171 CAMEL_SERVICE (store)->reconnecting = FALSE; 168 service->reconnection (service, FALSE, service->data); 169 170 service->reconnecting = FALSE; 172 171 } 173 172 trunk/libtinymail-camel/tny-camel-account-priv.h
r2250 r2298 83 83 void _tny_camel_account_start_camel_operation_n (TnyCamelAccount *self, CamelOperationStatusFunc func, gpointer user_data, const gchar *what, gboolean cancel); 84 84 void _tny_camel_account_stop_camel_operation (TnyCamelAccount *self); 85 void _tny_camel_account_try_connect (TnyCamelAccount *self, GError **err);85 void _tny_camel_account_try_connect (TnyCamelAccount *self, gboolean for_online, GError **err); 86 86 void _tny_camel_account_clear_hooks (TnyCamelAccount *self); 87 87 void _tny_camel_account_refresh (TnyCamelAccount *self, gboolean recon_if); trunk/libtinymail-camel/tny-camel-account.c
r2250 r2298 56 56 57 57 #include "tny-camel-account-priv.h" 58 59 #include <tny-camel-store-account.h> 60 #include "tny-camel-store-account-priv.h" 58 61 59 62 static GObjectClass *parent_class = NULL; … … 293 296 294 297 void 295 _tny_camel_account_try_connect (TnyCamelAccount *self, GError **err)296 { 297 TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 298 299 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->prepare_func (TNY_CAMEL_ACCOUNT (self), TRUE, TRUE);298 _tny_camel_account_try_connect (TnyCamelAccount *self, gboolean for_online, GError **err) 299 { 300 TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 301 302 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->prepare_func (TNY_CAMEL_ACCOUNT (self), for_online, TRUE); 300 303 301 304 if (camel_exception_is_set (priv->ex)) … … 795 798 796 799 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->prepare_func (TNY_CAMEL_ACCOUNT (self), 797 TRUE, FALSE);800 TRUE, TRUE); 798 801 799 802 g_static_rec_mutex_unlock (priv->service_lock); … … 1140 1143 if (online) { 1141 1144 camel_disco_store_set_status (CAMEL_DISCO_STORE (priv->service), 1142 CAMEL_DISCO_STORE_ONLINE, &ex); 1145 CAMEL_DISCO_STORE_ONLINE, &ex); 1146 1143 1147 if (!camel_exception_is_set (&ex)) 1144 1148 camel_service_connect (CAMEL_SERVICE (priv->service), &ex); 1145 1149 1150 if (TNY_IS_CAMEL_STORE_ACCOUNT (self)) 1151 { 1152 if (!camel_exception_is_set (&ex)) 1153 priv->status = TNY_CONNECTION_STATUS_CONNECTED; 1154 else 1155 priv->status = TNY_CONNECTION_STATUS_CONNECTED_BROKEN; 1156 1157 _tny_camel_store_account_emit_conchg_signal (TNY_CAMEL_STORE_ACCOUNT (self)); 1158 } 1159 1146 1160 goto done; 1161 1147 1162 } else if (camel_disco_store_can_work_offline (CAMEL_DISCO_STORE (priv->service))) { 1148 1163 1149 1164 camel_disco_store_set_status (CAMEL_DISCO_STORE (priv->service), 1150 CAMEL_DISCO_STORE_OFFLINE, 1151 &ex); 1165 CAMEL_DISCO_STORE_OFFLINE, &ex); 1166 1167 if (TNY_IS_CAMEL_STORE_ACCOUNT (self)) 1168 { 1169 if (!camel_exception_is_set (&ex)) 1170 priv->status = TNY_CONNECTION_STATUS_DISCONNECTED; 1171 else 1172 priv->status = TNY_CONNECTION_STATUS_DISCONNECTED_BROKEN; 1173 1174 _tny_camel_store_account_emit_conchg_signal (TNY_CAMEL_STORE_ACCOUNT (self)); 1175 } 1176 1152 1177 goto done; 1153 1178 } … … 1157 1182 1158 1183 camel_offline_store_set_network_state (CAMEL_OFFLINE_STORE (priv->service), 1159 CAMEL_OFFLINE_STORE_NETWORK_AVAIL, 1160 &ex); 1184 CAMEL_OFFLINE_STORE_NETWORK_AVAIL, &ex); 1185 1186 if (TNY_IS_CAMEL_STORE_ACCOUNT (self)) 1187 { 1188 if (!camel_exception_is_set (&ex)) 1189 priv->status = TNY_CONNECTION_STATUS_CONNECTED; 1190 else 1191 priv->status = TNY_CONNECTION_STATUS_CONNECTED_BROKEN; 1192 1193 _tny_camel_store_account_emit_conchg_signal (TNY_CAMEL_STORE_ACCOUNT (self)); 1194 } 1195 1161 1196 goto done; 1162 1197 } else { 1163 1198 camel_offline_store_set_network_state (CAMEL_OFFLINE_STORE (priv->service), 1164 CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL, 1165 &ex); 1199 CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL, &ex); 1200 1201 if (TNY_IS_CAMEL_STORE_ACCOUNT (self)) 1202 { 1203 if (!camel_exception_is_set (&ex)) 1204 priv->status = TNY_CONNECTION_STATUS_DISCONNECTED; 1205 else 1206 priv->status = TNY_CONNECTION_STATUS_DISCONNECTED_BROKEN; 1207 1208 _tny_camel_store_account_emit_conchg_signal (TNY_CAMEL_STORE_ACCOUNT (self)); 1209 } 1210 1166 1211 goto done; 1167 1212 } 1168 1213 } 1169 1214 1170 if (!online) 1215 if (!online) { 1171 1216 camel_service_disconnect (CAMEL_SERVICE (priv->service), 1172 TRUE, &ex); 1217 TRUE, &ex); 1218 1219 if (TNY_IS_CAMEL_STORE_ACCOUNT (self)) 1220 { 1221 if (!camel_exception_is_set (&ex)) 1222 priv->status = TNY_CONNECTION_STATUS_DISCONNECTED; 1223 else 1224 priv->status = TNY_CONNECTION_STATUS_DISCONNECTED_BROKEN; 1225 1226 _tny_camel_store_account_emit_conchg_signal (TNY_CAMEL_STORE_ACCOUNT (self)); 1227 } 1228 1229 } 1173 1230 1174 1231 done: trunk/libtinymail-camel/tny-camel-pop-store-account.c
r2244 r2298 165 165 service->reconnecting = TRUE; 166 166 167 camel_object_trigger_event (CAMEL_OBJECT (service),168 "reconnecting", (gpointer) FALSE);167 if (service->reconnecter) 168 service->reconnecter (service, FALSE, service->data); 169 169 170 170 camel_service_disconnect ((CamelService *) service, TRUE, &ex); … … 180 180 } 181 181 182 if (!camel_exception_is_set (&ex)) 183 camel_object_trigger_event (CAMEL_OBJECT (service), 184 "reconnection", (gpointer) TRUE); 182 if (service->reconnection) 183 service->reconnection (service, TRUE, service->data); 185 184 else 186 camel_object_trigger_event (CAMEL_OBJECT (service), 187 "reconnection", (gpointer) FALSE); 185 service->reconnection (service, FALSE, service->data); 188 186 189 187 service->reconnecting = FALSE; trunk/libtinymail-camel/tny-camel-store-account-priv.h
r2272 r2298 21 21 */ 22 22 23 #include <tny-camel-store-account.h> 24 23 25 typedef struct _TnyCamelStoreAccountPriv TnyCamelStoreAccountPriv; 24 26 … … 36 38 (G_TYPE_INSTANCE_GET_PRIVATE ((o), TNY_TYPE_CAMEL_STORE_ACCOUNT, TnyCamelStoreAccountPriv)) 37 39 40 void _tny_camel_store_account_emit_conchg_signal (TnyCamelStoreAccount *self); 41 38 42 #endif trunk/libtinymail-camel/tny-camel-store-account.c
r2296 r2298 119 119 } 120 120 121 static void 122 tny_camel_store_account_do_emit (TnyCamelStoreAccount *self) 123 { 124 g_idle_add_full (G_PRIORITY_HIGH, 125 connection_status_idle, 126 g_object_ref (self), 127 connection_status_idle_destroy); 128 } 129 121 130 static void 122 disconnection (CamelService *service, g pointer data, TnyAccount *self)131 disconnection (CamelService *service, gboolean suc, TnyAccount *self) 123 132 { 124 133 TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); … … 139 148 140 149 if (emit) 141 g_idle_add_full (G_PRIORITY_HIGH, 142 connection_status_idle, 143 g_object_ref (self), 144 connection_status_idle_destroy); 150 tny_camel_store_account_do_emit (TNY_CAMEL_STORE_ACCOUNT (self)); 145 151 } 146 152 … … 157 163 158 164 static void 159 connection (CamelService *service, g pointer data, TnyAccount *self)165 connection (CamelService *service, gboolean suc, TnyAccount *self) 160 166 { 161 167 TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 162 gboolean suc = (gboolean) data;163 168 TnyCamelStoreAccountPriv *priv = TNY_CAMEL_STORE_ACCOUNT_GET_PRIVATE (self); 164 169 gboolean emit = FALSE; … … 194 199 #endif 195 200 196 } 197 198 if (CAMEL_IS_DISCO_STORE (service)) 201 } else 202 emit = FALSE; 203 204 205 if (CAMEL_IS_DISCO_STORE (service) && !service->reconnecting) 199 206 { 200 207 … … 255 262 256 263 if (emit) 257 g_idle_add_full (G_PRIORITY_HIGH, 258 connection_status_idle, 259 g_object_ref (self), 260 connection_status_idle_destroy); 264 tny_camel_store_account_do_emit (TNY_CAMEL_STORE_ACCOUNT (self)); 265 266 } 267 268 void 269 _tny_camel_store_account_emit_conchg_signal (TnyCamelStoreAccount *self) 270 { 271 /* tny_camel_store_account_do_emit (self); */ 261 272 } 262 273 263 274 static void 264 reconnection (CamelService *service, gpointer data, TnyAccount *self) 265 { 266 gboolean suc = (gboolean) data; 275 reconnection (CamelService *service, gboolean suc, TnyAccount *self) 276 { 267 277 TnyCamelStoreAccountPriv *priv = TNY_CAMEL_STORE_ACCOUNT_GET_PRIVATE (self); 268 278 … … 278 288 279 289 static void 280 reconnecting (CamelService *service, g pointer data, TnyAccount *self)290 reconnecting (CamelService *service, gboolean suc, TnyAccount *self) 281 291 { 282 292 TnyCamelStoreAccountPriv *priv = TNY_CAMEL_STORE_ACCOUNT_GET_PRIVATE (self); … … 324 334 if (apriv->service && !camel_exception_is_set (apriv->ex)) 325 335 { 326 CHookInfo *info1, *info2, *info3, *info4;327 328 336 apriv->service->data = self; 329 330 info1 = g_slice_new0 (CHookInfo); 331 info2 = g_slice_new0 (CHookInfo); 332 info3 = g_slice_new0 (CHookInfo); 333 info4 = g_slice_new0 (CHookInfo); 334 335 camel_object_ref (apriv->service); 336 camel_object_ref (apriv->service); 337 camel_object_ref (apriv->service); 338 camel_object_ref (apriv->service); 339 340 info1->instance = (CamelObject *) apriv->service; 341 info2->instance = (CamelObject *) apriv->service; 342 info3->instance = (CamelObject *) apriv->service; 343 info4->instance = (CamelObject *) apriv->service; 344 345 info1->hook = camel_object_hook_event (apriv->service, 346 "disconnection", (CamelObjectEventHookFunc)disconnection, self); 347 info2->hook = camel_object_hook_event (apriv->service, 348 "connection", (CamelObjectEventHookFunc)connection, self); 349 info3->hook = camel_object_hook_event (apriv->service, 350 "reconnection", (CamelObjectEventHookFunc)reconnection, self); 351 info4->hook = camel_object_hook_event (apriv->service, 352 "reconnecting", (CamelObjectEventHookFunc)reconnecting, self); 353 354 apriv->chooks = g_list_prepend (apriv->chooks, info1); 355 apriv->chooks = g_list_prepend (apriv->chooks, info2); 356 apriv->chooks = g_list_prepend (apriv->chooks, info3); 357 apriv->chooks = g_list_prepend (apriv->chooks, info4); 337 apriv->service->connecting = (con_op) connection; 338 apriv->service->disconnecting = (con_op) disconnection; 339 apriv->service->reconnecter = (con_op) reconnecting; 340 apriv->service->reconnection = (con_op) reconnection; 341 358 342 359 343 } else if (camel_exception_is_set (apriv->ex) && apriv->service) … … 422 406 } else { 423 407 424 g_idle_add_full (G_PRIORITY_HIGH, 425 connection_status_idle, 426 g_object_ref (self), 427 connection_status_idle_destroy); 408 tny_camel_store_account_do_emit (TNY_CAMEL_STORE_ACCOUNT (self)); 428 409 429 410 /* tny_camel_account_set_online (self, apriv->connected); */ trunk/libtinymail-camel/tny-session-camel.c
r2250 r2298 429 429 GError *err = NULL; 430 430 431 _tny_camel_account_try_connect (TNY_CAMEL_ACCOUNT (data), &err);431 _tny_camel_account_try_connect (TNY_CAMEL_ACCOUNT (data), info->online, &err); 432 432 433 433 if (err == NULL) … … 565 565 } 566 566 567 /* 568 static gboolean 569 emit_accounts_reloaded (gpointer user_data) 570 { 571 g_signal_emit (G_OBJECT (user_data), 572 tny_account_store_signals [TNY_ACCOUNT_STORE_ACCOUNTS_RELOADED], 0); 573 return FALSE; 574 } 575 */ 567 576 568 577 /** … … 591 600 G_CALLBACK (connection_changed), self); 592 601 602 if (tny_device_is_online (device) == FALSE) 603 { 604 priv->prev_constat = TRUE; 605 connection_changed (device, FALSE, self); 606 /* 607 g_idle_add_full (G_PRIORITY_HIGH, 608 emit_accounts_reloaded, 609 (gpointer) g_object_ref (priv->account_store), 610 (GDestroyNotify) g_object_unref); 611 */ 612 } 593 613 return; 594 614 } trunk/libtinymail-gnome-desktop/tny-gnome-device.c
r1860 r2298 23 23 24 24 #include <tny-gnome-device.h> 25 26 #ifdef GNOME 27 #undef GNOME 28 #endif 25 29 26 30 #ifdef GNOME trunk/tests/c-demo/tny-demoui-summary-view.c
r2297 r2298 269 269 270 270 static void 271 reload_accounts (TnySummaryView *self)271 reload_accounts_first (TnySummaryView *self, gboolean first_time) 272 272 { 273 273 TnyDemouiSummaryViewPriv *priv = TNY_DEMOUI_SUMMARY_VIEW_GET_PRIVATE (self); … … 275 275 GtkTreeModel *sortable, *maccounts, *mailbox_model; 276 276 TnyFolderStoreQuery *query; 277 TnyIterator *aiter = NULL;278 277 279 278 /* Show only subscribed folders */ … … 311 310 priv->current_accounts = TNY_LIST (g_object_ref (G_OBJECT (accounts))); 312 311 313 aiter = tny_list_create_iterator (accounts); 314 while (!tny_iterator_is_done (aiter)) 315 { 316 GObject *a = tny_iterator_get_current (aiter); 317 318 g_signal_connect (a, "connection-status-changed", 319 G_CALLBACK (on_constatus_changed), self); 320 321 g_object_unref (a); 322 tny_iterator_next (aiter); 323 } 324 325 g_object_unref (aiter); 312 if (first_time) 313 { 314 TnyIterator *aiter = NULL; 315 aiter = tny_list_create_iterator (accounts); 316 while (!tny_iterator_is_done (aiter)) 317 { 318 GObject *a = tny_iterator_get_current (aiter); 319 320 g_signal_connect (a, "connection-status-changed", 321 G_CALLBACK (on_constatus_changed), self); 322 323 g_object_unref (a); 324 tny_iterator_next (aiter); 325 } 326 327 g_object_unref (aiter); 328 } 326 329 327 330 tny_account_store_get_accounts (account_store, TNY_LIST (maccounts), … … 360 363 } 361 364 365 static void 366 reload_accounts (TnySummaryView *self) 367 { 368 reload_accounts_first (self, FALSE); 369 } 370 362 371 static void 363 372 accounts_reloaded (TnyAccountStore *store, gpointer user_data) … … 502 511 G_CALLBACK (accounts_reloaded), self); 503 512 504 reload_accounts ((TnySummaryView *) self);513 reload_accounts_first ((TnySummaryView *) self, TRUE); 505 514 506 515 g_object_unref (G_OBJECT (device));
