Changeset 550
- Timestamp:
- 07/04/06 11:56:36
- Files:
-
- trunk/libtinymail-camel/tny-account-priv.h (modified) (1 diff)
- trunk/libtinymail-camel/tny-account.c (modified) (2 diffs)
- trunk/libtinymail-camel/tny-account.h (modified) (2 diffs)
- trunk/libtinymail-camel/tny-msg-folder-list-iterator.c (modified) (2 diffs)
- trunk/libtinymail-camel/tny-session-camel.c (modified) (3 diffs)
- trunk/libtinymail-camel/tny-session-camel.h (modified) (2 diffs)
- trunk/libtinymail-camel/tny-store-account.c (modified) (3 diffs)
- trunk/libtinymail-camel/tny-transport-account.c (modified) (2 diffs)
- trunk/libtinymail-gnome-desktop/tny-account-store.c (modified) (18 diffs)
- trunk/libtinymail-gpe/tny-account-store.c (modified) (17 diffs)
- trunk/libtinymail-maemo/tny-account-store.c (modified) (17 diffs)
- trunk/libtinymail-olpc/tny-account-store.c (modified) (17 diffs)
- trunk/libtinymail/tny-account-iface.c (modified) (2 diffs)
- trunk/libtinymail/tny-account-iface.h (modified) (4 diffs)
- trunk/libtinymail/tny-account-store-iface.c (modified) (2 diffs)
- trunk/libtinymail/tny-account-store-iface.h (modified) (2 diffs)
- trunk/libtinymail/tny-iterator-iface.c (modified) (1 diff)
- trunk/libtinymail/tny-iterator-iface.h (modified) (2 diffs)
- trunk/libtinymail/tny-list-iterator.c (modified) (2 diffs)
- trunk/libtinymail/tny-shared.h (modified) (1 diff)
- trunk/libtinymailui-gtk/tny-account-tree-model.c (modified) (3 diffs)
- trunk/libtinymailui-gtk/tny-msg-header-list-iterator.c (modified) (2 diffs)
- trunk/tinymail/tny-summary-window.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libtinymail-camel/tny-account-priv.h
r505 r550 41 41 gboolean connected, inuse_spin; 42 42 gchar *name; GList *options; 43 TnyAccountType account_type; 43 44 }; 44 45 trunk/libtinymail-camel/tny-account.c
r548 r550 50 50 51 51 #include <tny-camel-shared.h> 52 53 54 static void 55 tny_account_set_account_type (TnyAccountIface *self, TnyAccountType type) 56 { 57 TnyAccountPriv *priv = TNY_ACCOUNT_GET_PRIVATE (self); 58 59 priv->account_type = type; 60 } 61 62 static TnyAccountType 63 tny_account_get_account_type (TnyAccountIface *self) 64 { 65 TnyAccountPriv *priv = TNY_ACCOUNT_GET_PRIVATE (self); 66 67 return priv->account_type; 68 } 52 69 53 70 void … … 608 625 klass->get_name_func = tny_account_get_name; 609 626 klass->set_name_func = tny_account_set_name; 627 klass->set_account_type_func = tny_account_set_account_type; 628 klass->get_account_type_func = tny_account_get_account_type; 610 629 611 630 return; trunk/libtinymail-camel/tny-account.h
r485 r550 35 35 #define TNY_ACCOUNT_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), TNY_TYPE_ACCOUNT, TnyAccountClass)) 36 36 37 /* This is an abstract type */37 /* This is an abstract type, you cannot (should not) instantiate it */ 38 38 39 39 typedef struct _TnyAccount TnyAccount; … … 49 49 GObjectClass parent; 50 50 51 /* This is an abstract method */ 51 52 void (*reconnect_func) (TnyAccount *self); 52 53 }; trunk/libtinymail-camel/tny-msg-folder-list-iterator.c
r542 r550 183 183 184 184 g_mutex_lock (me->model->iterator_lock); 185 retval = (G_UNLIKELY (me->current) && me->current->next); 185 retval = (G_LIKELY (me->current) && me->current->next); 186 g_mutex_unlock (me->model->iterator_lock); 187 188 return retval; 189 } 190 191 static gboolean 192 tny_msg_folder_list_iterator_has_first (TnyIteratorIface *self) 193 { 194 TnyMsgFolderListIterator *me = (TnyMsgFolderListIterator*) self; 195 gboolean retval; 196 197 if (G_UNLIKELY (!me || !me->model)) 198 return FALSE; 199 200 /* Return whether or not there's a next node */ 201 202 g_mutex_lock (me->model->iterator_lock); 203 retval = G_LIKELY (me->current); 186 204 g_mutex_unlock (me->model->iterator_lock); 187 205 … … 212 230 klass->current_func = tny_msg_folder_list_iterator_current; 213 231 klass->has_next_func = tny_msg_folder_list_iterator_has_next; 232 klass->has_first_func = tny_msg_folder_list_iterator_has_first; 214 233 klass->get_list_func = tny_msg_folder_list_iterator_get_list; 215 234 trunk/libtinymail-camel/tny-session-camel.c
r518 r550 443 443 } 444 444 445 void 446 tny_session_camel_set_current_accounts (TnySessionCamel *self, TnyListIface *list) 447 { 448 self->current_accounts = list; 449 } 450 445 451 static void 446 452 connection_changed (TnyDeviceIface *device, gboolean online, gpointer user_data) … … 450 456 camel_session_set_online ((CamelSession *) self, online); 451 457 452 if (!self->first_switch && self->prev_constat != online && self->account_store) 453 { 454 GList *copy; 455 456 copy = (GList*) tny_account_store_iface_get_store_accounts (self->account_store);; 457 458 while (G_LIKELY (copy)) 459 { 460 TnyStoreAccountIface *account = copy->data; 458 if (self->current_accounts && TNY_IS_LIST_IFACE (self->current_accounts) && 459 !self->first_switch && self->prev_constat != online 460 && self->account_store) 461 { 462 TnyListIface *accounts = self->current_accounts; 463 gboolean next = FALSE; 464 TnyIteratorIface *iterator; 465 466 iterator = tny_list_iface_create_iterator (accounts); 467 next = tny_iterator_iface_has_first (iterator); 468 469 while (next) 470 { 471 TnyStoreAccountIface *account = tny_iterator_iface_current (iterator); 461 472 462 473 _tny_account_set_online_status (account, !online); 463 474 464 copy = g_list_next (copy); 465 } 466 475 next = tny_iterator_iface_has_next (iterator); 476 if (next) 477 tny_iterator_iface_next (iterator); 478 } 479 480 g_object_unref (G_OBJECT (iterator)); 467 481 } 468 482 … … 471 485 tny_account_store_iface_signals [TNY_ACCOUNT_STORE_IFACE_ACCOUNTS_RELOADED], 0); 472 486 487 473 488 self->first_switch = FALSE; 474 475 489 self->prev_constat = online; 476 490 trunk/libtinymail-camel/tny-session-camel.h
r514 r550 41 41 gboolean interactive, prev_constat, first_switch; 42 42 guint connchanged_signal; 43 TnyListIface *current_accounts; 43 44 }; 44 45 … … 60 61 void tny_session_camel_set_account_store (TnySessionCamel *self, TnyAccountStoreIface *account_store); 61 62 void tny_session_camel_set_device (TnySessionCamel *self, TnyDeviceIface *device); 63 void tny_session_camel_set_current_accounts (TnySessionCamel *self, TnyListIface *list); 62 64 63 65 G_END_DECLS trunk/libtinymail-camel/tny-store-account.c
r547 r550 86 86 { 87 87 TnyIteratorIface *iterator = tny_list_iface_create_iterator (folders); 88 gboolean next = TRUE;88 gboolean next = tny_iterator_iface_has_first (iterator); 89 89 90 90 while (next) … … 333 333 folder = tny_iterator_iface_current (iterator); 334 334 g_signal_emit (folder, tny_msg_folder_iface_signals [TNY_MSG_FOLDER_IFACE_FOLDERS_RELOADED], 0); 335 335 336 g_object_unref (G_OBJECT (iterator)); 336 337 } … … 543 544 apriv->connected = FALSE; 544 545 priv->folders_lock = g_mutex_new (); 546 apriv->account_type = TNY_ACCOUNT_TYPE_STORE; 545 547 546 548 return; trunk/libtinymail-camel/tny-transport-account.c
r385 r550 139 139 tny_transport_account_instance_init (GTypeInstance *instance, gpointer g_class) 140 140 { 141 142 141 TnyTransportAccount *self = (TnyTransportAccount *)instance; 143 142 TnyAccountPriv *apriv = TNY_ACCOUNT_GET_PRIVATE (self); … … 145 144 apriv->connected = FALSE; 146 145 apriv->type = CAMEL_PROVIDER_TRANSPORT; 146 apriv->account_type = TNY_ACCOUNT_TYPE_TRANSPORT; 147 147 148 148 return; trunk/libtinymail-gnome-desktop/tny-account-store.c
r545 r550 57 57 { 58 58 GConfClient *client; 59 60 59 gchar *cache_dir; 61 62 GMutex *store_accounts_lock;63 GList *store_accounts;64 65 GMutex *transport_accounts_lock;66 GList *transport_accounts;67 68 60 TnySessionCamel *session; 69 61 TnyDeviceIface *device; 70 71 62 guint notify; 72 63 }; … … 75 66 (G_TYPE_INSTANCE_GET_PRIVATE ((o), TNY_TYPE_ACCOUNT_STORE, TnyAccountStorePriv)) 76 67 77 static GHashTable *passwords;78 79 80 static const GList* tny_account_store_get_accounts (TnyAccountStoreIface *self);81 82 static void83 destroy_account (gpointer data, gpointer user_data)84 {85 g_object_unref (G_OBJECT (data));86 87 return;88 }89 90 static void91 destroy_these_accounts (GList *accounts)92 {93 g_list_foreach (accounts, destroy_account, NULL);94 g_list_free (accounts);95 accounts = NULL;96 97 return;98 }99 100 static void101 destroy_current_accounts (TnyAccountStorePriv *priv)102 {103 g_mutex_lock (priv->store_accounts_lock);104 g_mutex_lock (priv->transport_accounts_lock);105 106 if (G_LIKELY (priv->store_accounts))107 destroy_these_accounts (priv->store_accounts);108 109 if (G_LIKELY (priv->transport_accounts))110 destroy_these_accounts (priv->transport_accounts);111 112 priv->transport_accounts = NULL;113 priv->store_accounts = NULL;114 115 g_mutex_unlock (priv->transport_accounts_lock);116 g_mutex_unlock (priv->store_accounts_lock);117 118 return;119 }120 68 121 69 #ifdef GNOME 122 123 70 static gchar* 124 71 per_account_get_pass_func (TnyAccountIface *account, const gchar *prompt, gboolean *cancel) … … 234 181 #else 235 182 183 static GHashTable *passwords; 184 236 185 static gchar* 237 186 per_account_get_pass_func (TnyAccountIface *account, const gchar *prompt, gboolean *cancel) … … 307 256 #endif 308 257 309 310 311 static TnyAccountIface *312 find_account_by_gconf_key (GList *accounts, const gchar *key)313 {314 TnyAccountIface *found = NULL;315 316 while (G_LIKELY (accounts))317 {318 TnyAccountIface *account = accounts->data;319 const gchar *aid = tny_account_iface_get_id (account);320 321 if (G_UNLIKELY (strcmp (key, aid) == 0))322 {323 found = account;324 break;325 }326 327 accounts = g_list_next (accounts);328 }329 330 return found;331 }332 258 333 259 static gboolean … … 370 296 TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self); 371 297 298 372 299 gchar *key = g_strdup (entry->key); 373 300 gchar *ptr = strrchr (key, '/'); ptr++; … … 375 302 if (!strcmp (ptr, "count")) 376 303 { 377 destroy_current_accounts (priv);378 379 304 g_signal_emit (self, 380 305 tny_account_store_iface_signals [TNY_ACCOUNT_STORE_IFACE_ACCOUNTS_RELOADED], 0); 381 306 382 } else {383 GList *accounts;384 TnyAccountIface *found = NULL;385 const gchar *val;386 387 /* Whooo, crazy pointer hocus! */388 gchar orig = *ptr--; *ptr = '\0';389 390 g_mutex_lock (priv->transport_accounts_lock);391 accounts = priv->transport_accounts;392 found = find_account_by_gconf_key (accounts, key);393 g_mutex_unlock (priv->transport_accounts_lock);394 395 g_mutex_lock (priv->store_accounts_lock);396 accounts = priv->store_accounts;397 if (!found)398 found = find_account_by_gconf_key (accounts, key);399 g_mutex_unlock (priv->store_accounts_lock);400 401 /* pocus! */402 *ptr = orig; *ptr++;403 404 val = gconf_value_get_string (entry->value);405 406 /* phoef! */407 if (found && strcmp (ptr, "user")==0)408 tny_account_iface_set_user (found, val);409 else if (found && strcmp (ptr, "proto")==0)410 tny_account_iface_set_proto (found, val);411 else if (found && strcmp (ptr, "hostname")==0)412 tny_account_iface_set_hostname (found, val);413 307 } 414 308 … … 449 343 } 450 344 451 static void 452 tny_account_store_get_all_accounts (TnyAccountStoreIface *self) 453 { 454 TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self); 455 345 346 static void 347 tny_account_store_get_accounts (TnyAccountStoreIface *self, TnyListIface *list, TnyGetAccountsRequestType types) 348 { 349 TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self); 456 350 gint i=0, count; 457 458 destroy_current_accounts (priv);459 351 460 352 count = gconf_client_get_int (priv->client, … … 464 356 { 465 357 gchar *proto, *type, *key, *name; 466 TnyAccountIface *account; GSList *options; 358 TnyAccountIface *account = NULL; 359 GSList *options; 467 360 468 361 key = g_strdup_printf ("/apps/tinymail/accounts/%d", i); … … 473 366 continue; 474 367 } 475 476 368 g_free (key); 477 369 … … 483 375 if (type && G_LIKELY (!g_ascii_strncasecmp (type, "transport", 9))) 484 376 { 485 account = TNY_ACCOUNT_IFACE (tny_transport_account_new ()); 486 priv->transport_accounts = 487 g_list_append (priv->transport_accounts, account); 488 } else { 489 account = TNY_ACCOUNT_IFACE (tny_store_account_new ()); 490 priv->store_accounts = 491 g_list_append (priv->store_accounts, account); 377 if (types == TNY_ACCOUNT_STORE_IFACE_BOTH || 378 types == TNY_ACCOUNT_STORE_IFACE_TRANSPORT_ACCOUNTS) 379 { 380 account = TNY_ACCOUNT_IFACE (tny_transport_account_new ()); 381 } 382 383 } else 384 { 385 386 if (types == TNY_ACCOUNT_STORE_IFACE_BOTH || 387 types == TNY_ACCOUNT_STORE_IFACE_STORE_ACCOUNTS) 388 { 389 account = TNY_ACCOUNT_IFACE (tny_store_account_new ()); 390 } 492 391 } 493 392 494 tny_account_iface_set_account_store (account, self); 495 496 if (type) 497 g_free (type); 498 499 key = g_strdup_printf ("/apps/tinymail/accounts/%d/proto", i); 500 proto = gconf_client_get_string (priv->client, 501 (const gchar*) key, NULL); 502 g_free (key); 503 tny_account_iface_set_proto (TNY_ACCOUNT_IFACE (account), proto); 504 505 key = g_strdup_printf ("/apps/tinymail/accounts/%d/name", i); 506 name = gconf_client_get_string (priv->client, 507 (const gchar*) key, NULL); 508 g_free (key); 509 tny_account_iface_set_name (TNY_ACCOUNT_IFACE (account), name); 510 g_free (name); 511 512 513 key = g_strdup_printf ("/apps/tinymail/accounts/%d/options", i); 514 options = gconf_client_get_list (priv->client, 515 (const gchar*) key, GCONF_VALUE_STRING, NULL); 516 g_free (key); 517 518 if (options) 519 { 520 while (options) 393 394 if (account) 395 { 396 tny_account_iface_set_account_store (account, self); 397 398 if (type) 399 g_free (type); 400 401 key = g_strdup_printf ("/apps/tinymail/accounts/%d/proto", i); 402 proto = gconf_client_get_string (priv->client, 403 (const gchar*) key, NULL); 404 g_free (key); 405 tny_account_iface_set_proto (TNY_ACCOUNT_IFACE (account), proto); 406 407 key = g_strdup_printf ("/apps/tinymail/accounts/%d/name", i); 408 name = gconf_client_get_string (priv->client, 409 (const gchar*) key, NULL); 410 g_free (key); 411 tny_account_iface_set_name (TNY_ACCOUNT_IFACE (account), name); 412 g_free (name); 413 414 415 key = g_strdup_printf ("/apps/tinymail/accounts/%d/options", i); 416 options = gconf_client_get_list (priv->client, 417 (const gchar*) key, GCONF_VALUE_STRING, NULL); 418 g_free (key); 419 420 if (options) 521 421 { 522 tny_account_add_option (TNY_ACCOUNT (account), options->data); 523 g_free (options->data); 524 options = g_slist_next (options); 422 while (options) 423 { 424 tny_account_add_option (TNY_ACCOUNT (account), options->data); 425 g_free (options->data); 426 options = g_slist_next (options); 427 } 428 g_slist_free (options); 525 429 } 526 g_slist_free (options); 430 431 /* Because we only check for the n first bytes, the pops, imaps and smtps also work */ 432 if (!g_ascii_strncasecmp (proto, "pop", 3) || 433 !g_ascii_strncasecmp (proto, "imap", 4)|| 434 !g_ascii_strncasecmp (proto, "smtp", 4)) 435 { 436 gchar *user, *hostname; 437 438 /* TODO: Add other supported and tested providers here */ 439 key = g_strdup_printf ("/apps/tinymail/accounts/%d/user", i); 440 user = gconf_client_get_string (priv->client, 441 (const gchar*) key, NULL); 442 443 g_free (key); 444 tny_account_iface_set_user (TNY_ACCOUNT_IFACE (account), user); 445 446 key = g_strdup_printf ("/apps/tinymail/accounts/%d/hostname", i); 447 hostname = gconf_client_get_string (priv->client, 448 (const gchar*) key, NULL); 449 g_free (key); 450 tny_account_iface_set_hostname (TNY_ACCOUNT_IFACE (account), 451 hostname); 452 453 g_free (hostname); g_free (proto); g_free (user); 454 } else { 455 gchar *url_string; 456 457 /* Un officially supported provider */ 458 /* Assuming there's a url_string in this case */ 459 460 key = g_strdup_printf ("/apps/tinymail/accounts/%d/url_string", i); 461 url_string = gconf_client_get_string (priv->client, 462 (const gchar*) key, NULL); 463 464 g_free (key); 465 tny_account_iface_set_url_string (TNY_ACCOUNT_IFACE (account), url_string); 466 g_free (url_string); 467 } 468 469 key = g_strdup_printf ("/apps/tinymail/accounts/%d", i); 470 tny_account_iface_set_id (TNY_ACCOUNT_IFACE (account), key); 471 g_free (key); 472 473 /* 474 * Setting the password function must happen after 475 * setting the host, user and protocol. 476 */ 477 478 tny_account_iface_set_forget_pass_func (TNY_ACCOUNT_IFACE (account), 479 per_account_forget_pass_func); 480 481 tny_account_iface_set_pass_func (TNY_ACCOUNT_IFACE (account), 482 per_account_get_pass_func); 483 484 485 tny_list_iface_prepend (list, account); 527 486 } 528 529 /* Because we only check for the n first bytes, the pops, imaps and smtps also work */ 530 if (!g_ascii_strncasecmp (proto, "pop", 3) || 531 !g_ascii_strncasecmp (proto, "imap", 4)|| 532 !g_ascii_strncasecmp (proto, "smtp", 4)) 533 { 534 gchar *user, *hostname; 535 536 /* TODO: Add other supported and tested providers here */ 537 key = g_strdup_printf ("/apps/tinymail/accounts/%d/user", i); 538 user = gconf_client_get_string (priv->client, 539 (const gchar*) key, NULL); 540 541 g_free (key); 542 tny_account_iface_set_user (TNY_ACCOUNT_IFACE (account), user); 543 544 key = g_strdup_printf ("/apps/tinymail/accounts/%d/hostname", i); 545 hostname = gconf_client_get_string (priv->client, 546 (const gchar*) key, NULL); 547 g_free (key); 548 tny_account_iface_set_hostname (TNY_ACCOUNT_IFACE (account), 549 hostname); 550 551 g_free (hostname); g_free (proto); g_free (user); 552 } else { 553 gchar *url_string; 554 555 /* Un officially supported provider */ 556 /* Assuming there's a url_string in this case */ 557 558 key = g_strdup_printf ("/apps/tinymail/accounts/%d/url_string", i); 559 url_string = gconf_client_get_string (priv->client, 560 (const gchar*) key, NULL); 561 562 g_free (key); 563 tny_account_iface_set_url_string (TNY_ACCOUNT_IFACE (account), url_string); 564 g_free (url_string); 565 } 566 567 key = g_strdup_printf ("/apps/tinymail/accounts/%d", i); 568 tny_account_iface_set_id (TNY_ACCOUNT_IFACE (account), key); 569 g_free (key); 570 571 /* 572 * Setting the password function must happen after 573 * setting the host, user and protocol. 574 */ 575 576 tny_account_iface_set_forget_pass_func (TNY_ACCOUNT_IFACE (account), 577 per_account_forget_pass_func); 578 579 tny_account_iface_set_pass_func (TNY_ACCOUNT_IFACE (account), 580 per_account_get_pass_func); 581 } 582 583 return; 584 } 585 586 /* TODO: 587 588 - Refactor to let this return a TnyListIface 589 590 - No two methods, just add a TnyAccountType parameter? 591 592 - No caching allowed here! (no reason) 593 594 */ 595 596 static const GList* 597 tny_account_store_get_store_accounts (TnyAccountStoreIface *self) 598 { 599 TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self); 600 const GList *retval; 601 602 if (G_UNLIKELY (!priv->store_accounts)) 603 tny_account_store_get_all_accounts (self); 604 605 g_mutex_lock (priv->store_accounts_lock); 606 retval = (const GList*) priv->store_accounts; 607 g_mutex_unlock (priv->store_accounts_lock); 608 609 return retval; 610 } 611 612 /* TODO: 613 614 - Refactor to let this return a TnyListIface 615 616 - No two methods, just add a TnyAccountType parameter? 617 618 - No caching allowed here! (no reason) 619 620 */ 621 622 static const GList* 623 tny_account_store_get_transport_accounts (TnyAccountStoreIface *self) 624 { 625 TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self); 626 const GList *retval; 627 628 if (G_UNLIKELY (!priv->transport_accounts)) 629 tny_account_store_get_all_accounts (self); 630 631 g_mutex_lock (priv->transport_accounts_lock); 632 retval = (const GList*) priv->transport_accounts; 633 g_mutex_unlock (priv->transport_accounts_lock); 634 635 return retval; 636 } 487 } 488 489 tny_session_camel_set_current_accounts (priv->session, list); 490 491 return; 492 } 493 637 494 638 495 static void … … 663 520 gconftool-2 -s /apps/tinymail/accounts/0/user -t string username 664 521 gconftool-2 -s /apps/tinymail/accounts/0/hostname -t string mailserver 665 666 522 or 667 668 523 gconftool-2 -s /apps/tinymail/accounts/0/url_string -t string url_string 669 524 … … 705 560 706 561 707 /* TODO:708 709 - Refactor to let this return a TnyListIface710 711 - No two methods, just add a TnyAccountType parameter?712 713 - No caching allowed here! (no reason)714 715 */716 562 717 563 static void … … 724 570 tny_account_store_notify_add (self); 725 571 726 /* g_object_ref (G_OBJECT (account)); */727 728 g_mutex_lock (priv->store_accounts_lock);729 priv->store_accounts = g_list_append (priv->store_accounts, account);730 g_mutex_unlock (priv->store_accounts_lock);731 732 572 g_signal_emit (self, tny_account_store_iface_signals [TNY_ACCOUNT_STORE_IFACE_ACCOUNT_INSERTED], 0, account); 733 573 … … 739 579 { 740 580 TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self); 741 742 /* g_object_ref (G_OBJECT (account)); */743 581 744 582 tny_account_store_notify_remove (self); 745 583 tny_account_store_add_account (self, TNY_ACCOUNT_IFACE (account), "transport"); 746 584 tny_account_store_notify_add (self); 747 748 g_mutex_lock (priv->transport_accounts_lock);749 priv->transport_accounts = g_list_append (priv->transport_accounts, account);750 g_mutex_unlock (priv->transport_accounts_lock);751 585 752 586 g_signal_emit (self, tny_account_store_iface_signals [TNY_ACCOUNT_STORE_IFACE_ACCOUNT_INSERTED], 0, account); … … 778 612 779 613 priv->device = tny_platform_factory_iface_new_device (platfact); 780 / /tny_device_iface_force_online (priv->device);614 /* tny_device_iface_force_online (priv->device); */ 781 615 priv->session = tny_session_camel_new (TNY_ACCOUNT_STORE_IFACE (self)); 782 616 … … 790 624 TnyAccountStore *self = (TnyAccountStore *)instance; 791 625 TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self); 792 793 priv->store_accounts_lock = g_mutex_new ();794 priv->transport_accounts_lock = g_mutex_new ();795 626 796 627 priv->client = gconf_client_get_default (); … … 813 644 tny_account_store_notify_remove (TNY_ACCOUNT_STORE_IFACE (self)); 814 645 g_object_unref (G_OBJECT (priv->client)); 815 816 destroy_current_accounts (priv);817 818 g_mutex_free (priv->store_accounts_lock);819 g_mutex_free (priv->transport_accounts_lock);820 821 priv->store_accounts_lock = NULL;822 priv->transport_accounts_lock = NULL;823 646 824 647 if (G_LIKELY (priv->cache_dir)) … … 865 688 TnyAccountStoreIfaceClass *klass = (TnyAccountStoreIfaceClass *)g_iface; 866 689 690 klass->get_accounts_func = tny_account_store_get_accounts; 867 691 klass->add_store_account_func = tny_account_store_add_store_account; 868 klass->get_store_accounts_func = tny_account_store_get_store_accounts;869 692 klass->add_transport_account_func = tny_account_store_add_transport_account; 870 klass->get_transport_accounts_func = tny_account_store_get_transport_accounts;871 693 klass->get_cache_dir_func = tny_account_store_get_cache_dir; 872 694 klass->get_device_func = tny_account_store_get_device; trunk/libtinymail-gpe/tny-account-store.c
r529 r550 53 53 { 54 54 GConfClient *client; 55 56 55 gchar *cache_dir; 57 58 GMutex *store_accounts_lock;59 GList *store_accounts;60 61 GMutex *transport_accounts_lock;62 GList *transport_accounts;63 64 56 TnySessionCamel *session; 65 57 TnyDeviceIface *device; 66 67 58 guint notify; 68 59 }; … … 71 62 (G_TYPE_INSTANCE_GET_PRIVATE ((o), TNY_TYPE_ACCOUNT_STORE, TnyAccountStorePriv)) 72 63 64 73 65 static GHashTable *passwords; 74 75 76 static const GList* tny_account_store_get_accounts (TnyAccountStoreIface *self);77 78 static void79 destroy_account (gpointer data, gpointer user_data)80 {81 g_object_unref (G_OBJECT (data));82 83 return;84 }85 86 static void87 destroy_these_accounts (GList *accounts)88 {89 g_list_foreach (accounts, destroy_account, NULL);90 g_list_free (accounts);91 accounts = NULL;92 93 return;94 }95 96 static void97 destroy_current_accounts (TnyAccountStorePriv *priv)98 {99 g_mutex_lock (priv->store_accounts_lock);100 g_mutex_lock (priv->transport_accounts_lock);101 102 if (G_LIKELY (priv->store_accounts))103 destroy_these_accounts (priv->store_accounts);104 105 if (G_LIKELY (priv->transport_accounts))106 destroy_these_accounts (priv->transport_accounts);107 108 priv->transport_accounts = NULL;109 priv->store_accounts = NULL;110 111 g_mutex_unlock (priv->transport_accounts_lock);112 g_mutex_unlock (priv->store_accounts_lock);113 114 return;115 }116 117 66 118 67 static gchar* … … 185 134 186 135 return; 187 }188 189 190 static TnyAccountIface *191 find_account_by_gconf_key (GList *accounts, const gchar *key)192 {193 TnyAccountIface *found = NULL;194 195 while (G_LIKELY (accounts))196 {197 TnyAccountIface *account = accounts->data;198 const gchar *aid = tny_account_iface_get_id (account);199 200 if (G_UNLIKELY (strcmp (key, aid) == 0))201 {202 found = account;203 break;204 }205 206 accounts = g_list_next (accounts);207 }208 209 return found;210 136 } 211 137 … … 249 175 TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self); 250 176 177 251 178 gchar *key = g_strdup (entry->key); 252 179 gchar *ptr = strrchr (key, '/'); ptr++; … … 254 181 if (!strcmp (ptr, "count")) 255 182 { 256 destroy_current_accounts (priv);257 258 183 g_signal_emit (self, 259 184 tny_account_store_iface_signals [TNY_ACCOUNT_STORE_IFACE_ACCOUNTS_RELOADED], 0); 260 185 261 } else {262 GList *accounts;263 TnyAccountIface *found = NULL;264 const gchar *val;265 266 /* Whooo, crazy pointer hocus! */267 gchar orig = *ptr--; *ptr = '\0';268 269 g_mutex_lock (priv->transport_accounts_lock);270 accounts = priv->transport_accounts;271 found = find_account_by_gconf_key (accounts, key);272 g_mutex_unlock (priv->transport_accounts_lock);273 274 g_mutex_lock (priv->store_accounts_lock);275 accounts = priv->store_accounts;276 if (!found)277 found = find_account_by_gconf_key (accounts, key);278 g_mutex_unlock (priv->store_accounts_lock);279 280 /* pocus! */281 *ptr = orig; *ptr++;282 283 val = gconf_value_get_string (entry->value);284 285 /* phoef! */286 if (found && strcmp (ptr, "user")==0)287 tny_account
