From e1581b778571f2b7d52cd2c034b88b7b5d0d9083 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 8 Oct 2001 18:14:59 +0000 Subject: For mailstorage folders, connect to the control's "activate" signal, and * component-factory.c (create_view): For mailstorage folders, connect to the control's "activate" signal, and don't try to connect to the store. (storage_activate): Instead, do it here, so if the connection fails, or the user cancels, or whatever else, he can try again later. svn path=/trunk/; revision=13503 --- mail/ChangeLog | 9 ++++++++ mail/component-factory.c | 55 +++++++++++++++++++++++++++++++++--------------- 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/mail/ChangeLog b/mail/ChangeLog index 562b01c30a..03427d8d12 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,12 @@ +2001-10-08 Dan Winship + + * component-factory.c (create_view): For mailstorage folders, + connect to the control's "activate" signal, and don't try to + connect to the store. + (storage_activate): Instead, do it here, so if the connection + fails, or the user cancels, or whatever else, he can try again + later. + 2001-10-07 Dan Winship * mail-tools.c (mail_tool_do_movemail): Remove #ifndef diff --git a/mail/component-factory.c b/mail/component-factory.c index ab632031ea..f3f1d0d81c 100644 --- a/mail/component-factory.c +++ b/mail/component-factory.c @@ -106,6 +106,38 @@ static const char *schema_types[] = { /* EvolutionShellComponent methods and signals. */ +static void +storage_activate (BonoboControl *control, gboolean activate, + const char *physical_uri) +{ + CamelService *store; + EvolutionStorage *storage; + CamelException ex; + + if (!activate) + return; + + camel_exception_init (&ex); + store = camel_session_get_service (session, physical_uri, + CAMEL_PROVIDER_STORE, &ex); + if (!store) { + e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, + _("Cannot connect to store: %s"), + camel_exception_get_description (&ex)); + camel_exception_clear (&ex); + return; + } + camel_exception_clear (&ex); + + storage = g_hash_table_lookup (storages_hash, store); + if (storage && + !gtk_object_get_data (GTK_OBJECT (storage), "connected")) { + mail_note_store (CAMEL_STORE(store), storage, + CORBA_OBJECT_NIL, NULL, NULL); + } + camel_object_unref (CAMEL_OBJECT (store)); +} + static BonoboControl * create_noselect_control (void) { @@ -143,24 +175,13 @@ create_view (EvolutionShellComponent *shell_component, corba_shell); camel_url_free (url); } else if (!g_strcasecmp (folder_type, "mailstorage")) { - CamelService *store; - EvolutionStorage *storage; - - store = camel_session_get_service (session, physical_uri, - CAMEL_PROVIDER_STORE, NULL); - if (!store) - return EVOLUTION_SHELL_COMPONENT_NOTFOUND; - storage = g_hash_table_lookup (storages_hash, store); - if (!storage) { - camel_object_unref (CAMEL_OBJECT (store)); - return EVOLUTION_SHELL_COMPONENT_NOTFOUND; - } - - if (!gtk_object_get_data (GTK_OBJECT (storage), "connected")) - mail_note_store(CAMEL_STORE(store), storage, CORBA_OBJECT_NIL, NULL, NULL); - camel_object_unref (CAMEL_OBJECT (store)); - + char *uri_dup = g_strdup (physical_uri); + control = create_noselect_control (); + gtk_object_set_data_full (GTK_OBJECT (control), "physical_uri", + uri_dup, g_free); + gtk_signal_connect (GTK_OBJECT (control), "activate", + storage_activate, uri_dup); } else if (!g_strcasecmp (folder_type, "vtrash")) { if (!g_strncasecmp (physical_uri, "file:", 5)) control = folder_browser_factory_new_control ("vtrash:file:/", corba_shell); -- cgit v1.2.3