Make the shell to be able to display URIs that the user specified on

the command-line.

svn path=/trunk/; revision=10554
This commit is contained in:
Ettore Perazzoli
2001-06-28 04:50:02 +00:00
parent 764cfb5a6b
commit 268c7dbe42
9 changed files with 159 additions and 47 deletions

View File

@ -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

View File

@ -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 {};

View File

@ -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;

View File

@ -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;
}

View File

@ -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

View File

@ -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. */

View File

@ -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,

View File

@ -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,

View File

@ -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";
if (! e_shell_restore_from_settings (shell))
view = e_shell_new_view (shell, STARTUP_URI);
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 (!getenv ("EVOLVE_ME_HARDER"))
development_warning ();
for (p = uri_list; p != NULL; p = p->next) {
char *uri;
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 ();