diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2001-10-06 01:49:35 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2001-10-06 01:49:35 +0800 |
commit | fc1e5673bb9d91f89a851262cf5c66b50c31c18d (patch) | |
tree | 042f340229e4ee6f196cc21fbb94a90ec16601b2 /shell/e-component-registry.c | |
parent | a1750a292eb31a113a22c0278fb6517d56f78f75 (diff) | |
download | gsoc2013-evolution-fc1e5673bb9d91f89a851262cf5c66b50c31c18d.tar.gz gsoc2013-evolution-fc1e5673bb9d91f89a851262cf5c66b50c31c18d.tar.zst gsoc2013-evolution-fc1e5673bb9d91f89a851262cf5c66b50c31c18d.zip |
If setting the owner fails, print the a warning message out. Then restart
* e-shell.c (set_owner_on_components): If setting the owner fails,
print the a warning message out. Then restart the component.
* e-component-registry.c (component_free): Return a boolean value.
%FALSE if ::unsetOwner raises an exception.
(register_type): New arg @override_duplicate, to avoid complaining
if a component gets re-registered.
(register_component): Likewise.
(e_component_registry_restart_component): New.
* e-uri-schema-registry.c
(e_uri_schema_registry_set_handler_for_schema): Changed return
type to `void'. Just remove the old handler and set up the new
one.
* evolution-shell-component-client.c (corba_exception_to_result):
Translate ::OldOwnerHasDied into
EVOLUTION_SHELL_COMPONENT_OLDOWNERHASDIED.
* evolution-shell-component.h: New enum value
`EVOLUTION_SHELL_COMPONENT_OLDOWNERHASDIED'.
* evolution-shell-component.c (impl_setOwner): If the old owner is
not alive anymore [use CORBA_Object_non_existent() to figure this
out], emit OWNER_UNSET and raise `OldOwnerHasDied'.
(evolution_shell_component_result_to_string): New.
* Evolution-ShellComponent.idl: New exception `OldOwnerHasDied'.
(ShellComponent::setOwner): Can raise it.
* e-folder-type-registry.c
(e_folder_type_register_type_registered): New.
(e_folder_type_register_unregister_type): New.
svn path=/trunk/; revision=13446
Diffstat (limited to 'shell/e-component-registry.c')
-rw-r--r-- | shell/e-component-registry.c | 95 |
1 files changed, 84 insertions, 11 deletions
diff --git a/shell/e-component-registry.c b/shell/e-component-registry.c index 3851821741..ffa3769000 100644 --- a/shell/e-component-registry.c +++ b/shell/e-component-registry.c @@ -77,17 +77,21 @@ component_new (const char *id, return new; } -static void +static gboolean component_free (Component *component) { GNOME_Evolution_ShellComponent corba_shell_component; CORBA_Environment ev; + gboolean retval; - CORBA_exception_init (&ev); corba_shell_component = bonobo_object_corba_objref (BONOBO_OBJECT (component->client)); + + CORBA_exception_init (&ev); GNOME_Evolution_ShellComponent_unsetOwner (corba_shell_component, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - g_warning ("Cannot unregister component -- %s", component->id); + if (ev._major == CORBA_NO_EXCEPTION) + retval = TRUE; + else + retval = FALSE; CORBA_exception_free (&ev); g_free (component->id); @@ -97,6 +101,8 @@ component_free (Component *component) e_free_string_list (component->folder_type_names); g_free (component); + + return retval; } static gboolean @@ -110,7 +116,8 @@ register_type (EComponentRegistry *component_registry, const char **exported_dnd_types, int num_accepted_dnd_types, const char **accepted_dnd_types, - Component *handler) + Component *handler, + gboolean override_duplicate) { EComponentRegistryPrivate *priv; EFolderTypeRegistry *folder_type_registry; @@ -120,6 +127,10 @@ register_type (EComponentRegistry *component_registry, folder_type_registry = e_shell_get_folder_type_registry (priv->shell); g_assert (folder_type_registry != NULL); + if (override_duplicate + && e_folder_type_register_type_registered (folder_type_registry, name)) + e_folder_type_register_unregister_type (folder_type_registry, name); + if (! e_folder_type_registry_register_type (folder_type_registry, name, icon_name, display_name, description, @@ -139,7 +150,8 @@ register_type (EComponentRegistry *component_registry, static gboolean register_component (EComponentRegistry *component_registry, - const char *id) + const char *id, + gboolean override_duplicate) { EComponentRegistryPrivate *priv; GNOME_Evolution_ShellComponent component_corba_interface; @@ -153,7 +165,7 @@ register_component (EComponentRegistry *component_registry, priv = component_registry->priv; - if (g_hash_table_lookup (priv->component_id_to_component, id) != NULL) { + if (! override_duplicate && g_hash_table_lookup (priv->component_id_to_component, id) != NULL) { g_warning ("Trying to register component twice -- %s", id); return FALSE; } @@ -198,7 +210,8 @@ register_component (EComponentRegistry *component_registry, (const char **) type->exportedDndTypes._buffer, type->acceptedDndTypes._length, (const char **) type->acceptedDndTypes._buffer, - component)) { + component, + override_duplicate)) { g_warning ("Cannot register type `%s' for component %s", type->name, component->id); } @@ -218,8 +231,7 @@ register_component (EComponentRegistry *component_registry, const CORBA_char *schema; schema = supported_schemas->_buffer[i]; - if (! e_uri_schema_registry_set_handler_for_schema (uri_schema_registry, schema, component->client)) - g_warning ("Cannot register schema `%s' for component %s", schema, component->id); + e_uri_schema_registry_set_handler_for_schema (uri_schema_registry, schema, component->client); } CORBA_free (supported_schemas); @@ -324,7 +336,7 @@ e_component_registry_register_component (EComponentRegistry *component_registry, g_return_val_if_fail (E_IS_COMPONENT_REGISTRY (component_registry), FALSE); g_return_val_if_fail (id != NULL, FALSE); - return register_component (component_registry, id); + return register_component (component_registry, id, FALSE); } @@ -399,5 +411,66 @@ e_component_registry_get_component_by_id (EComponentRegistry *component_registr } +EvolutionShellComponentClient * +e_component_registry_restart_component (EComponentRegistry *component_registry, + const char *id) +{ + EComponentRegistryPrivate *priv; + Component *component; + CORBA_Environment ev; + CORBA_Object corba_objref; + gboolean alive; + int count; + + g_return_val_if_fail (component_registry != NULL, NULL); + g_return_val_if_fail (E_IS_COMPONENT_REGISTRY (component_registry), NULL); + g_return_val_if_fail (id != NULL, NULL); + + priv = component_registry->priv; + + component = g_hash_table_lookup (priv->component_id_to_component, id); + if (component == NULL) + return NULL; + + CORBA_exception_init (&ev); + + g_hash_table_remove (priv->component_id_to_component, id); + + corba_objref = CORBA_Object_duplicate (bonobo_object_corba_objref (BONOBO_OBJECT (component->client)), &ev); + + component_free (component); + + count = 1; + while (1) { + alive = bonobo_unknown_ping (corba_objref); + if (! alive) + break; + + g_print ("Waiting for component to die -- %s (%d)\n", id, count); + sleep (1); + count ++; + } + + CORBA_exception_free (&ev); + +#if 1 + if (! register_component (component_registry, id, TRUE)) + return NULL; + + return e_component_registry_get_component_by_id (component_registry, id); +#else + client = evolution_shell_component_client_new (id); + if (client == NULL) + return NULL; + + component = component_new (id, client); + g_hash_table_insert (priv->component_id_to_component, component->id, component); + bonobo_object_unref (BONOBO_OBJECT (client)); +#endif + + return component->client; +} + + E_MAKE_TYPE (e_component_registry, "EComponentRegistry", EComponentRegistry, class_init, init, PARENT_TYPE) |