aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--shell/ChangeLog25
-rw-r--r--shell/e-component-registry.c53
-rw-r--r--shell/e-component-registry.h6
-rw-r--r--shell/e-shell.c60
-rw-r--r--shell/evolution-shell-component-client.c28
-rw-r--r--shell/evolution-shell-component-client.h3
-rw-r--r--shell/evolution-shell-component-utils.c26
-rw-r--r--shell/evolution-shell-component-utils.h7
-rw-r--r--shell/evolution-shell-component.c4
9 files changed, 148 insertions, 64 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index dded99cdf0..0229f33dc3 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,28 @@
+2002-04-04 Ettore Perazzoli <ettore@ximian.com>
+
+ * evolution-shell-component.c: Change type of parent_class to
+ BonoboXObjectClass.
+
+ * e-shell.c (pop_up_activation_error_dialog): New helper function
+ to pop up a dialog if one of the components couldn't be activated,
+ getting the description for the error from
+ e_get_activation_failure_msg().
+ (setup_components): Use this function in case of activation error.
+ (set_owner_on_components): Likewise, when the component gets
+ restarted. Also get a @splash arg so we can set the parent for
+ this dialog correctly.
+
+ * e-component-registry.c (register_component): New arg @ev.
+ (e_component_registry_register_component): Likewise.
+ (e_component_registry_restart_component): Likewise. Also, remove
+ some bogus code that was #if'ed out.
+
+ * evolution-shell-component-client.c
+ (evolution_shell_component_client_new): New arg @ev.
+
+ * evolution-shell-component-utils.c
+ (e_get_activation_failure_msg): New.
+
2002-04-03 Dan Winship <danw@ximian.com>
* e-storage.c (get_path_for_physical_uri_foreach): Deal with
diff --git a/shell/e-component-registry.c b/shell/e-component-registry.c
index 77e2df95eb..e1ef250eaa 100644
--- a/shell/e-component-registry.c
+++ b/shell/e-component-registry.c
@@ -200,7 +200,8 @@ register_type (EComponentRegistry *component_registry,
static gboolean
register_component (EComponentRegistry *component_registry,
const char *id,
- gboolean override_duplicate)
+ gboolean override_duplicate,
+ CORBA_Environment *ev)
{
EComponentRegistryPrivate *priv;
GNOME_Evolution_ShellComponent component_corba_interface;
@@ -209,7 +210,7 @@ register_component (EComponentRegistry *component_registry,
GNOME_Evolution_URISchemaList *supported_schemas;
Component *component;
EvolutionShellComponentClient *client;
- CORBA_Environment ev;
+ CORBA_Environment my_ev;
CORBA_unsigned_long i;
priv = component_registry->priv;
@@ -219,28 +220,28 @@ register_component (EComponentRegistry *component_registry,
return FALSE;
}
- client = evolution_shell_component_client_new (id);
+ client = evolution_shell_component_client_new (id, ev);
if (client == NULL)
return FALSE;
- CORBA_exception_init (&ev);
-
/* FIXME we could use the EvolutionShellComponentClient API here instead, but for
now we don't care. */
component_corba_interface = bonobo_object_corba_objref (BONOBO_OBJECT (client));
shell_corba_interface = bonobo_object_corba_objref (BONOBO_OBJECT (priv->shell));
+ CORBA_exception_init (&my_ev);
+
/* Register the supported folder types. */
- supported_types = GNOME_Evolution_ShellComponent__get_supportedTypes (component_corba_interface, &ev);
- if (ev._major != CORBA_NO_EXCEPTION || supported_types->_length == 0) {
+ supported_types = GNOME_Evolution_ShellComponent__get_supportedTypes (component_corba_interface, &my_ev);
+ if (my_ev._major != CORBA_NO_EXCEPTION || supported_types->_length == 0) {
bonobo_object_unref (BONOBO_OBJECT (client));
- CORBA_exception_free (&ev);
+ CORBA_exception_free (&my_ev);
return FALSE;
}
- CORBA_exception_free (&ev);
+ CORBA_exception_free (&my_ev);
component = component_new (id, client);
g_hash_table_insert (priv->component_id_to_component, component->id, component);
@@ -270,8 +271,8 @@ register_component (EComponentRegistry *component_registry,
/* Register the supported external URI schemas. */
- supported_schemas = GNOME_Evolution_ShellComponent__get_externalUriSchemas (component_corba_interface, &ev);
- if (ev._major == CORBA_NO_EXCEPTION) {
+ supported_schemas = GNOME_Evolution_ShellComponent__get_externalUriSchemas (component_corba_interface, &my_ev);
+ if (my_ev._major == CORBA_NO_EXCEPTION) {
EUriSchemaRegistry *uri_schema_registry;
uri_schema_registry = e_shell_get_uri_schema_registry (priv->shell);
@@ -379,13 +380,14 @@ e_component_registry_new (EShell *shell)
gboolean
e_component_registry_register_component (EComponentRegistry *component_registry,
- const char *id)
+ const char *id,
+ CORBA_Environment *ev)
{
g_return_val_if_fail (component_registry != NULL, FALSE);
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, FALSE);
+ return register_component (component_registry, id, FALSE, ev);
}
@@ -462,11 +464,12 @@ e_component_registry_get_component_by_id (EComponentRegistry *component_registr
EvolutionShellComponentClient *
e_component_registry_restart_component (EComponentRegistry *component_registry,
- const char *id)
+ const char *id,
+ CORBA_Environment *ev)
{
EComponentRegistryPrivate *priv;
Component *component;
- CORBA_Environment ev;
+ CORBA_Environment my_ev;
CORBA_Object corba_objref;
g_return_val_if_fail (component_registry != NULL, NULL);
@@ -479,34 +482,22 @@ e_component_registry_restart_component (EComponentRegistry *component_registry,
if (component == NULL)
return NULL;
- CORBA_exception_init (&ev);
+ CORBA_exception_init (&my_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);
+ corba_objref = CORBA_Object_duplicate (bonobo_object_corba_objref (BONOBO_OBJECT (component->client)), &my_ev);
component_free (component);
wait_for_corba_object_to_die (corba_objref, id);
- CORBA_exception_free (&ev);
+ CORBA_exception_free (&my_ev);
-#if 1
- if (! register_component (component_registry, id, TRUE))
+ if (! register_component (component_registry, id, TRUE, ev))
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;
}
diff --git a/shell/e-component-registry.h b/shell/e-component-registry.h
index f5193d8be7..84e802bf3b 100644
--- a/shell/e-component-registry.h
+++ b/shell/e-component-registry.h
@@ -61,7 +61,8 @@ void e_component_registry_construct (ECompo
EComponentRegistry *e_component_registry_new (EShell *shell);
gboolean e_component_registry_register_component (EComponentRegistry *component_registry,
- const char *id);
+ const char *id,
+ CORBA_Environment *ev);
GList *e_component_registry_get_id_list (EComponentRegistry *component_registry);
@@ -69,7 +70,8 @@ EvolutionShellComponentClient *e_component_registry_get_component_by_id (ECompo
const char *id);
EvolutionShellComponentClient *e_component_registry_restart_component (EComponentRegistry *component_registry,
- const char *id);
+ const char *id,
+ CORBA_Environment *ev);
#ifdef __cplusplus
}
diff --git a/shell/e-shell.c b/shell/e-shell.c
index 8b1763f437..d16ff306b3 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -67,6 +67,7 @@
#include "e-splash.h"
#include "e-uri-schema-registry.h"
+#include "evolution-shell-component-utils.h"
#include "evolution-storage-set-view-factory.h"
#include "e-shell.h"
@@ -148,6 +149,25 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
+/* Utility functions. */
+
+static void
+pop_up_activation_error_dialog (ESplash *splash,
+ const char *id,
+ CORBA_Environment *ev)
+{
+ char *error_message;
+
+ error_message = e_get_activation_failure_msg (ev);
+ e_notice (GTK_WINDOW (splash), GNOME_MESSAGE_BOX_ERROR,
+ _("Cannot activate component %s :\n"
+ "The error from the activation system is:\n"
+ "%s"),
+ id, error_message);
+ g_free (error_message);
+}
+
+
/* Interactivity handling. */
static void
@@ -738,11 +758,14 @@ setup_components (EShell *shell,
for (i = 0; i < info_list->_length; i++) {
const OAF_ServerInfo *info;
+ CORBA_Environment ev;
info = info_list->_buffer + i;
- if (! e_component_registry_register_component (priv->component_registry, info->iid)) {
- g_warning ("Cannot activate Evolution component -- %s", info->iid);
+ CORBA_exception_init (&ev);
+
+ if (! e_component_registry_register_component (priv->component_registry, info->iid, &ev)) {
+ pop_up_activation_error_dialog (splash, info->iid, &ev);
} else {
e_shell_user_creatable_items_handler_add_component
(priv->user_creatable_items_handler,
@@ -750,6 +773,8 @@ setup_components (EShell *shell,
e_component_registry_get_component_by_id (priv->component_registry, info->iid));
}
+ CORBA_exception_free (&ev);
+
if (splash != NULL)
e_splash_set_icon_highlight (splash, i, TRUE);
@@ -764,7 +789,8 @@ setup_components (EShell *shell,
/* FIXME what if anything fails here? */
static void
-set_owner_on_components (EShell *shell)
+set_owner_on_components (EShell *shell,
+ ESplash *splash)
{
GNOME_Evolution_Shell corba_shell;
EShellPrivate *priv;
@@ -792,14 +818,26 @@ set_owner_on_components (EShell *shell)
id, evolution_shell_component_result_to_string (result));
if (result == EVOLUTION_SHELL_COMPONENT_OLDOWNERHASDIED) {
- component_client = e_component_registry_restart_component (priv->component_registry, id);
- result = evolution_shell_component_client_set_owner (component_client, corba_shell,
- local_directory);
- if (result != EVOLUTION_SHELL_COMPONENT_OK) {
- g_warning ("Error re-setting owner on component %s -- %s",
- id, evolution_shell_component_result_to_string (result));
- /* (At this point, we give up.) */
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ component_client = e_component_registry_restart_component (priv->component_registry,
+ id, &ev);
+
+ if (component_client == NULL) {
+ pop_up_activation_error_dialog (splash, id, &ev);
+ } else {
+ result = evolution_shell_component_client_set_owner (component_client, corba_shell,
+ local_directory);
+ if (result != EVOLUTION_SHELL_COMPONENT_OK) {
+ g_warning ("Error re-setting owner on component %s -- %s",
+ id, evolution_shell_component_result_to_string (result));
+ /* (At this point, we give up.) */
+ }
}
+
+ CORBA_exception_free (&ev);
}
}
}
@@ -1184,7 +1222,7 @@ e_shell_construct (EShell *shell,
/* Now that we have a local storage and all the interfaces set up, we
can tell the components we are here. */
- set_owner_on_components (shell);
+ set_owner_on_components (shell, E_SPLASH (splash));
if (show_splash) {
gtk_widget_destroy (splash);
diff --git a/shell/evolution-shell-component-client.c b/shell/evolution-shell-component-client.c
index 574b75ecc8..9f570cf6da 100644
--- a/shell/evolution-shell-component-client.c
+++ b/shell/evolution-shell-component-client.c
@@ -388,31 +388,31 @@ evolution_shell_component_client_construct (EvolutionShellComponentClient *shell
}
EvolutionShellComponentClient *
-evolution_shell_component_client_new (const char *id)
+evolution_shell_component_client_new (const char *id,
+ CORBA_Environment *ev)
{
EvolutionShellComponentClient *new;
- CORBA_Environment ev;
CORBA_Object corba_object;
+ CORBA_Environment *local_ev;
+ CORBA_Environment static_ev;
g_return_val_if_fail (id != NULL, NULL);
- CORBA_exception_init (&ev);
-
- corba_object = oaf_activate_from_id ((char *) id, 0, NULL, &ev); /* Yuck. */
- if (ev._major != CORBA_NO_EXCEPTION) {
- CORBA_exception_free (&ev);
- g_warning ("Could not start up component for %s.", id);
- return NULL;
- }
+ CORBA_exception_init (&static_ev);
- CORBA_exception_free (&ev);
+ if (ev == NULL)
+ local_ev = &static_ev;
+ else
+ local_ev = ev;
- if (corba_object == CORBA_OBJECT_NIL) {
- g_warning ("Could not activate component %s. "
- "(Maybe you need to set OAF_INFO_PATH?)", id);
+ corba_object = oaf_activate_from_id ((char *) id, 0, NULL, ev);
+ if (ev->_major != CORBA_NO_EXCEPTION || corba_object == NULL) {
+ CORBA_exception_free (&static_ev);
return NULL;
}
+ CORBA_exception_free (&static_ev);
+
new = gtk_type_new (evolution_shell_component_client_get_type ());
evolution_shell_component_client_construct (new, id, corba_object);
diff --git a/shell/evolution-shell-component-client.h b/shell/evolution-shell-component-client.h
index 33b8cd92d3..19e79f8dbe 100644
--- a/shell/evolution-shell-component-client.h
+++ b/shell/evolution-shell-component-client.h
@@ -65,7 +65,8 @@ GtkType evolution_shell_component_client_get_type (void
void evolution_shell_component_client_construct (EvolutionShellComponentClient *shell_component_client,
const char *id,
CORBA_Object corba_object);
-EvolutionShellComponentClient *evolution_shell_component_client_new (const char *id);
+EvolutionShellComponentClient *evolution_shell_component_client_new (const char *id,
+ CORBA_Environment *optional_ev);
/* Properties. */
diff --git a/shell/evolution-shell-component-utils.c b/shell/evolution-shell-component-utils.c
index f7e3ebdf54..b3e806d296 100644
--- a/shell/evolution-shell-component-utils.c
+++ b/shell/evolution-shell-component-utils.c
@@ -94,7 +94,7 @@ free_pixmaps (void)
g_slist_free (inited_arrays);
}
-
+
/**
* e_activation_failure_dialog:
* @parent: parent window of the dialog, or %NULL
@@ -140,3 +140,27 @@ e_activation_failure_dialog (GtkWindow *parent, const char *msg,
e_notice (parent, GNOME_MESSAGE_BOX_ERROR, errmsg);
g_free (errmsg);
}
+
+
+/**
+ * e_get_activation_failure_msg:
+ * @ev: An exception returned by an oaf_activate call.
+ *
+ * Get a descriptive error message from @ev.
+ *
+ * Return value: A newly allocated string with the printable error message.
+ **/
+char *
+e_get_activation_failure_msg (CORBA_Environment *ev)
+{
+ g_return_val_if_fail (ev != NULL, NULL);
+
+ if (strcmp (CORBA_exception_id (ev), ex_OAF_GeneralError) != 0) {
+ return bonobo_exception_get_text (ev);
+ } else {
+ const OAF_GeneralError *oaf_general_error;
+
+ oaf_general_error = CORBA_exception_value (ev);
+ return g_strdup (oaf_general_error->description);
+ }
+}
diff --git a/shell/evolution-shell-component-utils.h b/shell/evolution-shell-component-utils.h
index 4d2eb9e7d6..5aceab64c7 100644
--- a/shell/evolution-shell-component-utils.h
+++ b/shell/evolution-shell-component-utils.h
@@ -41,8 +41,11 @@ typedef struct _EPixmap {
/* Takes an array of pixmaps, terminated by E_PIXMAP_END, and loads into uic */
void e_pixmaps_update (BonoboUIComponent *uic, EPixmap *pixcache);
-void e_activation_failure_dialog (GtkWindow *parent, const char *msg,
- const char *oafiid, const char *repo_id);
+void e_activation_failure_dialog (GtkWindow *parent,
+ const char *msg,
+ const char *oafiid,
+ const char *repo_id);
+char *e_get_activation_failure_msg (CORBA_Environment *ev);
#ifdef __cplusplus
}
diff --git a/shell/evolution-shell-component.c b/shell/evolution-shell-component.c
index 072ff580b1..e552073c97 100644
--- a/shell/evolution-shell-component.c
+++ b/shell/evolution-shell-component.c
@@ -43,7 +43,7 @@
#define PARENT_TYPE BONOBO_X_OBJECT_TYPE
-static GtkObjectClass *parent_class = NULL;
+static BonoboXObjectClass *parent_class = NULL;
struct _UserCreatableItemType {
char *id;
@@ -724,7 +724,7 @@ destroy (GtkObject *object)
g_free (priv);
- parent_class->destroy (object);
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}