diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2001-06-28 12:50:02 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2001-06-28 12:50:02 +0800 |
commit | 268c7dbe4254f54f55d2bed8a9c740ee89dd9aed (patch) | |
tree | 8e0d46102300870ed29c743fa29cff4522044dba | |
parent | 764cfb5a6ba195958b1b3b814fdb584d6a5ff63b (diff) | |
download | gsoc2013-evolution-268c7dbe4254f54f55d2bed8a9c740ee89dd9aed.tar.gz gsoc2013-evolution-268c7dbe4254f54f55d2bed8a9c740ee89dd9aed.tar.zst gsoc2013-evolution-268c7dbe4254f54f55d2bed8a9c740ee89dd9aed.zip |
Make the shell to be able to display URIs that the user specified on
the command-line.
svn path=/trunk/; revision=10554
-rw-r--r-- | shell/ChangeLog | 34 | ||||
-rw-r--r-- | shell/Evolution-ShellComponent.idl | 4 | ||||
-rw-r--r-- | shell/e-shell.c | 22 | ||||
-rw-r--r-- | shell/e-uri-schema-registry.c | 7 | ||||
-rw-r--r-- | shell/e-uri-schema-registry.h | 2 | ||||
-rw-r--r-- | shell/evolution-shell-component-client.c | 26 | ||||
-rw-r--r-- | shell/evolution-shell-component-client.h | 4 | ||||
-rw-r--r-- | shell/evolution-shell-component.h | 1 | ||||
-rw-r--r-- | shell/main.c | 106 |
9 files changed, 159 insertions, 47 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index b170ebec6c..880f3c7e09 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,37 @@ +2001-06-28 Ettore Perazzoli <ettore@ximian.com> + + * main.c (idle_cb): Re-implemented to get a GSList of URIs and + open them on a running shell [if any] or on a newly created shell. + If no args are provided [i.e. the list is NULL], it either + restores from settings [if any], or it just opens the Inbox. + (main): Set up the GSList of arguments and have it passed to the + idle callback. + + * e-shell.c (init): Ooops. Init `uri_schema_registry' to NULL as + well. + + * evolution-shell-component-client.c + (evolution_shell_component_client_handle_external_uri): New. + (corba_exception_to_result): Handle the `UnsupportedSchema' + exception too. + + * evolution-shell-component.h: New + EvolutionShellComponentResult value + `EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDSCHEMA'. + + * Evolution-ShellComponent.idl: New exception `UnsupportedSchema'. + (handleExternalURI): This can now raise `NotFound', + `UnsupportedSchema' and `InternalError'. + (createView): This can now raise `UnsupportedSchema' too. + + * e-shell.c (impl_Shell_handleURI): Finish implementation. + (class_init): Install it. + + * e-uri-schema-registry.c + (e_uri_schema_registry_get_handler_for_schema): Ooops. Rename + from `e_uri_schema_get_handler_for_schema'. Also, return NULL if + no handler is found. + 2001-06-27 Ettore Perazzoli <ettore@ximian.com> * e-component-registry.c (register_component): Get the supported diff --git a/shell/Evolution-ShellComponent.idl b/shell/Evolution-ShellComponent.idl index ed62d8812c..f2e7e22ee8 100644 --- a/shell/Evolution-ShellComponent.idl +++ b/shell/Evolution-ShellComponent.idl @@ -48,13 +48,15 @@ module Evolution { /* FIXME: We might want more exceptions here. */ exception NotFound {}; exception UnsupportedType {}; + exception UnsupportedSchema {}; exception InternalError {}; Bonobo::Control createView (in string physical_uri, in string type) raises (NotFound, UnsupportedType, InternalError); - void handleExternalURI (in string external_uri); + void handleExternalURI (in string external_uri) + raises (NotFound, UnsupportedSchema, InternalError); exception Busy {}; diff --git a/shell/e-shell.c b/shell/e-shell.c index 30d48430a3..167e718ed6 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -238,16 +238,17 @@ impl_Shell_handleURI (PortableServer_Servant servant, const CORBA_char *uri, CORBA_Environment *ev) { + EvolutionShellComponentClient *schema_handler; EShell *shell; EShellPrivate *priv; const char *colon_p; - const char *schema; + char *schema; shell = E_SHELL (bonobo_object_from_servant (servant)); priv = shell->priv; if (strncmp (uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) == 0) { - GNOME_Evolution_Shell_createNewView (servant, uri, ev); + GNOME_Evolution_Shell_createNewView (bonobo_object_corba_objref (BONOBO_OBJECT (shell)), uri, ev); return; } @@ -261,6 +262,21 @@ impl_Shell_handleURI (PortableServer_Servant servant, } schema = g_strndup (uri, colon_p - uri); + schema_handler = e_uri_schema_registry_get_handler_for_schema (priv->uri_schema_registry, schema); + g_free (schema); + + if (schema_handler == NULL) { + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_GNOME_Evolution_Shell_UnsupportedSchema, NULL); + return; + } + + if (! evolution_shell_component_client_handle_external_uri (schema_handler, uri)) { + /* FIXME: Just a wild guess here. */ + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_GNOME_Evolution_Shell_NotFound, NULL); + return; + } } static void @@ -697,6 +713,7 @@ class_init (EShellClass *klass) epv = & klass->epv; epv->getComponentByType = impl_Shell_getComponentByType; epv->createNewView = impl_Shell_createNewView; + epv->handleURI = impl_Shell_handleURI; epv->selectUserFolder = impl_Shell_selectUserFolder; epv->getLocalStorage = impl_Shell_getLocalStorage; epv->createStorageSetView = impl_Shell_createStorageSetView; @@ -717,6 +734,7 @@ init (EShell *shell) priv->shortcuts = NULL; priv->component_registry = NULL; priv->folder_type_registry = NULL; + priv->uri_schema_registry = NULL; priv->corba_storage_registry = NULL; priv->activity_handler = NULL; priv->offline_handler = NULL; diff --git a/shell/e-uri-schema-registry.c b/shell/e-uri-schema-registry.c index e27648359f..5646870925 100644 --- a/shell/e-uri-schema-registry.c +++ b/shell/e-uri-schema-registry.c @@ -157,8 +157,8 @@ e_uri_schema_registry_set_handler_for_schema (EUriSchemaRegistry *registry, } EvolutionShellComponentClient * -e_uri_schema_get_handler_for_schema (EUriSchemaRegistry *registry, - const char *schema) +e_uri_schema_registry_get_handler_for_schema (EUriSchemaRegistry *registry, + const char *schema) { EUriSchemaRegistryPrivate *priv; const SchemaHandler *handler; @@ -170,6 +170,9 @@ e_uri_schema_get_handler_for_schema (EUriSchemaRegistry *registry, priv = registry->priv; handler = g_hash_table_lookup (priv->schema_to_handler, schema); + if (handler == NULL) + return NULL; + return handler->component; } diff --git a/shell/e-uri-schema-registry.h b/shell/e-uri-schema-registry.h index 1462c26200..190a0b497f 100644 --- a/shell/e-uri-schema-registry.h +++ b/shell/e-uri-schema-registry.h @@ -61,7 +61,7 @@ EUriSchemaRegistry *e_uri_schema_registry_new (void); gboolean e_uri_schema_registry_set_handler_for_schema (EUriSchemaRegistry *registry, const char *schema, EvolutionShellComponentClient *shell_component); -EvolutionShellComponentClient *e_uri_schema_get_handler_for_schema (EUriSchemaRegistry *registry, +EvolutionShellComponentClient *e_uri_schema_registry_get_handler_for_schema (EUriSchemaRegistry *registry, const char *schema); #ifdef __cplusplus diff --git a/shell/evolution-shell-component-client.c b/shell/evolution-shell-component-client.c index b2ca961685..60b39d9aa2 100644 --- a/shell/evolution-shell-component-client.c +++ b/shell/evolution-shell-component-client.c @@ -82,6 +82,8 @@ corba_exception_to_result (const CORBA_Environment *ev) return EVOLUTION_SHELL_COMPONENT_INTERNALERROR; if (strcmp (ev->_repo_id, ex_GNOME_Evolution_ShellComponent_Busy) == 0) return EVOLUTION_SHELL_COMPONENT_BUSY; + if (strcmp (ev->_repo_id, ex_GNOME_Evolution_ShellComponent_UnsupportedSchema) == 0) + return EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDSCHEMA; return EVOLUTION_SHELL_COMPONENT_UNKNOWNERROR; } else { @@ -594,6 +596,30 @@ evolution_shell_component_client_create_view (EvolutionShellComponentClient *she return result; } +EvolutionShellComponentResult +evolution_shell_component_client_handle_external_uri (EvolutionShellComponentClient *shell_component_client, + const char *uri) +{ + GNOME_Evolution_ShellComponent corba_component; + CORBA_Environment ev; + EvolutionShellComponentResult result; + + RETURN_ERROR_IF_FAIL (shell_component_client != NULL); + RETURN_ERROR_IF_FAIL (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client)); + RETURN_ERROR_IF_FAIL (uri != NULL); + + CORBA_exception_init (&ev); + + corba_component = bonobo_object_corba_objref (BONOBO_OBJECT (shell_component_client)); + GNOME_Evolution_ShellComponent_handleExternalURI (corba_component, uri, &ev); + + result = corba_exception_to_result (&ev); + + CORBA_exception_free (&ev); + + return result; +} + /* Asyncronous operations. */ diff --git a/shell/evolution-shell-component-client.h b/shell/evolution-shell-component-client.h index d7044001b0..9b3a7d0ff0 100644 --- a/shell/evolution-shell-component-client.h +++ b/shell/evolution-shell-component-client.h @@ -80,6 +80,7 @@ GNOME_Evolution_Offline evolution_shell_component_client_get_offline_interface (EvolutionShellComponentClient *shell_component_client); /* Synchronous operations. */ + EvolutionShellComponentResult evolution_shell_component_client_set_owner (EvolutionShellComponentClient *shell_component_client, GNOME_Evolution_Shell shell, const char *evolution_homedir); @@ -91,6 +92,9 @@ EvolutionShellComponentResult evolution_shell_component_client_create_view (Ev const char *type_string, BonoboControl **control_return); +EvolutionShellComponentResult evolution_shell_component_client_handle_external_uri (EvolutionShellComponentClient *shell_component_client, + const char *uri); + /* Asyncronous operations. */ void evolution_shell_component_client_async_create_folder (EvolutionShellComponentClient *shell_component_client, const char *physical_uri, diff --git a/shell/evolution-shell-component.h b/shell/evolution-shell-component.h index c465650f57..190eb57a8d 100644 --- a/shell/evolution-shell-component.h +++ b/shell/evolution-shell-component.h @@ -57,6 +57,7 @@ enum _EvolutionShellComponentResult { EVOLUTION_SHELL_COMPONENT_NOTOWNED, EVOLUTION_SHELL_COMPONENT_NOTFOUND, EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDTYPE, + EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDSCHEMA, EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDOPERATION, EVOLUTION_SHELL_COMPONENT_INTERNALERROR, EVOLUTION_SHELL_COMPONENT_BUSY, diff --git a/shell/main.c b/shell/main.c index 78dfe6573c..8fa4c4a2ef 100644 --- a/shell/main.c +++ b/shell/main.c @@ -129,57 +129,77 @@ development_warning (void) /* This is for doing stuff that requires the GTK+ loop to be running already. */ -static void -new_view_on_running_shell (void) +static gint +idle_cb (void *data) { - CORBA_Object corba_object; - GNOME_Evolution_ShellView shell_view; + GSList *uri_list; + GNOME_Evolution_Shell corba_shell; CORBA_Environment ev; + gboolean restored; CORBA_exception_init (&ev); - corba_object = oaf_activate_from_id (E_SHELL_OAFIID, 0, NULL, &ev); - if (ev._major != CORBA_NO_EXCEPTION - || CORBA_Object_is_nil (corba_object, &ev)) { - e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, - _("Cannot initialize the Evolution shell.")); - return; - } - - shell_view = GNOME_Evolution_Shell_createNewView ((GNOME_Evolution_Shell) corba_object, STARTUP_URI, &ev); - if (ev._major == CORBA_NO_EXCEPTION) { - Bonobo_Unknown_unref ((Bonobo_Unknown) shell_view, &ev); - CORBA_Object_release ((CORBA_Object) shell_view, &ev); - } - - CORBA_exception_free (&ev); -} - -static gint -idle_cb (gpointer data) -{ - EShellView *view; + uri_list = (GSList *) data; shell = e_shell_new (evolution_directory, ! no_splash); g_free (evolution_directory); if (shell == NULL) { - /* A new shell cannot be created, so try to get a new view from - an already running one. */ - new_view_on_running_shell (); - exit (1); + corba_shell = oaf_activate_from_id (E_SHELL_OAFIID, 0, NULL, &ev); + + if (ev._major != CORBA_NO_EXCEPTION || corba_shell == CORBA_OBJECT_NIL) { + e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, + _("Cannot access the Evolution shell.")); + CORBA_exception_free (&ev); + return FALSE; + } + + restored = FALSE; + } else { + gtk_signal_connect (GTK_OBJECT (shell), "no_views_left", + GTK_SIGNAL_FUNC (no_views_left_cb), NULL); + gtk_signal_connect (GTK_OBJECT (shell), "destroy", + GTK_SIGNAL_FUNC (destroy_cb), NULL); + + if (uri_list == NULL) + restored = e_shell_restore_from_settings (shell); + else + restored = NULL; + + if (!getenv ("EVOLVE_ME_HARDER")) + development_warning (); + + corba_shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell)); + corba_shell = CORBA_Object_duplicate (corba_shell, &ev); + Bonobo_Unknown_ref (corba_shell, &ev); } - gtk_signal_connect (GTK_OBJECT (shell), "no_views_left", - GTK_SIGNAL_FUNC (no_views_left_cb), NULL); - gtk_signal_connect (GTK_OBJECT (shell), "destroy", - GTK_SIGNAL_FUNC (destroy_cb), NULL); + if (! restored && uri_list == NULL) { + const char *uri = "evolution:/local/Inbox"; + + GNOME_Evolution_Shell_handleURI (corba_shell, uri, &ev); + if (ev._major != CORBA_NO_EXCEPTION) + g_warning ("CORBA exception %s when requesting URI -- %s", ev._repo_id, uri); + } else { + GSList *p; - if (! e_shell_restore_from_settings (shell)) - view = e_shell_new_view (shell, STARTUP_URI); + for (p = uri_list; p != NULL; p = p->next) { + char *uri; - if (!getenv ("EVOLVE_ME_HARDER")) - development_warning (); + uri = (char *) p->data; + + GNOME_Evolution_Shell_handleURI (corba_shell, uri, &ev); + if (ev._major != CORBA_NO_EXCEPTION) + g_warning ("CORBA exception %s when requesting URI -- %s", ev._repo_id, uri); + } + + g_slist_free (uri_list); + } + + CORBA_exception_free (&ev); + + if (shell == NULL) + gtk_main_quit (); return FALSE; } @@ -194,6 +214,8 @@ main (int argc, char **argv) POPT_AUTOHELP { NULL, '\0', 0, NULL, 0, NULL, NULL } }; + GSList *uri_list; + int i; bindtextdomain (PACKAGE, EVOLUTION_LOCALEDIR); textdomain (PACKAGE); @@ -228,12 +250,14 @@ main (int argc, char **argv) /* FIXME */ evolution_directory = g_concat_dir_and_file (g_get_home_dir (), "evolution"); - if (! e_setup (evolution_directory)) { - g_free (evolution_directory); + if (! e_setup (evolution_directory)) exit (1); - } - gtk_idle_add (idle_cb, evolution_directory); + uri_list = NULL; + for (i = 1; i < argc; i++) + uri_list = g_slist_prepend (uri_list, argv[i]); + + gtk_idle_add (idle_cb, uri_list); bonobo_main (); |