X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-runtime.c;h=aa41989482aa1f35bac82f3a092735136f515f86;hp=9e843c0cd0a9b209165eb057e7309105af5aa8fa;hb=78dfa46b5c70991558efdd83b867a792b4b55677;hpb=bf831b6566516e6b57de7a64afb732eb8686e792 diff --git a/src/modest-runtime.c b/src/modest-runtime.c index 9e843c0..aa41989 100644 --- a/src/modest-runtime.c +++ b/src/modest-runtime.c @@ -45,8 +45,17 @@ #include #include #include +#include +#include -static ModestSingletons *_singletons = NULL; +static ModestSingletons *_singletons = NULL; + +// we get the account store here instead of in Singletons +// as it leads to various chicken & problems with initialization +static ModestTnyAccountStore *_account_store = NULL; + +/* Signal handlers for the send queues */ +static GSList *_sig_handlers = NULL; /* * private functions declared in modest-runtime-priv.h - @@ -66,7 +75,7 @@ modest_runtime_init (void) g_printerr ("modest: failed to create singletons\n"); return FALSE; } - + return TRUE; } @@ -77,10 +86,22 @@ modest_runtime_uninit (void) return TRUE; /* uninit maybe called if runtime_init failed */ g_return_val_if_fail (MODEST_IS_SINGLETONS(_singletons), FALSE); - modest_runtime_verify_object_last_ref(_singletons,""); - g_object_unref(G_OBJECT(_singletons)); + + MODEST_DEBUG_VERIFY_OBJECT_LAST_REF(_singletons,""); + g_object_unref(_singletons); _singletons = NULL; - + + if (_account_store) { + MODEST_DEBUG_VERIFY_OBJECT_LAST_REF(_account_store,""); + g_object_unref(_account_store); + _account_store = NULL; + } + + if (_sig_handlers) { + modest_signal_mgr_disconnect_all_and_destroy (_sig_handlers); + _sig_handlers = NULL; + } + return TRUE; } /*-----------------------------------------------------------------------------*/ @@ -103,9 +124,18 @@ modest_runtime_get_email_clipboard (void) ModestTnyAccountStore* modest_runtime_get_account_store (void) { - g_return_val_if_fail (_singletons, NULL); - return modest_singletons_get_account_store (_singletons); - + // we get the account store here instead of in Singletons + // as it leads to various chicken & problems with initialization + g_return_val_if_fail (_singletons, NULL); + if (!_account_store) { + _account_store = modest_tny_account_store_new (modest_runtime_get_account_mgr(), + modest_runtime_get_device()); + if (!_account_store) { + g_printerr ("modest: cannot create modest tny account store instance\n"); + return NULL; + } + } + return _account_store; } ModestConf* @@ -171,8 +201,24 @@ modest_runtime_get_send_queue (TnyTransportAccount *account) * as soon as it is instantiated: */ send_queue = (gpointer)modest_tny_send_queue_new (TNY_CAMEL_TRANSPORT_ACCOUNT(account)); - g_hash_table_insert (send_queue_cache, account, send_queue); - g_object_ref (send_queue); + _sig_handlers = + modest_signal_mgr_connect (_sig_handlers, + send_queue, + "error_happened", + G_CALLBACK (modest_ui_actions_on_send_queue_error_happened), + NULL); + + _sig_handlers = + modest_signal_mgr_connect (_sig_handlers, + send_queue, + "status_changed", + G_CALLBACK (modest_ui_actions_on_send_queue_status_changed), + NULL); + + + g_hash_table_insert (send_queue_cache, + g_object_ref (account), + g_object_ref (send_queue)); } return MODEST_TNY_SEND_QUEUE(send_queue); @@ -199,9 +245,10 @@ modest_runtime_get_debug_flags () static const GDebugKey debug_keys[] = { { "abort-on-warning", MODEST_RUNTIME_DEBUG_ABORT_ON_WARNING }, { "log-actions", MODEST_RUNTIME_DEBUG_LOG_ACTIONS }, - { "debug-objects", MODEST_RUNTIME_DEBUG_DEBUG_OBJECTS }, - { "debug-signals", MODEST_RUNTIME_DEBUG_DEBUG_SIGNALS }, - { "factory-settings", MODEST_RUNTIME_DEBUG_FACTORY_SETTINGS} + { "debug-objects", MODEST_RUNTIME_DEBUG_OBJECTS }, + { "debug-signals", MODEST_RUNTIME_DEBUG_SIGNALS }, + { "factory-settings", MODEST_RUNTIME_DEBUG_FACTORY_SETTINGS}, + { "debug-code", MODEST_RUNTIME_DEBUG_CODE} }; const gchar *str; static ModestRuntimeDebugFlags debug_flags = -1;