GLib/GTK+ functions, except for a couple of places were we use
GtkCList.]
* Makefile.am (INCLUDES): Add `-DG_DISABLE_DEPRECATED
-DGTK_DISABLE_DEPRECATED'.
* evolution-test-component.c (create_new_folder_selector): No
gtk_window_set_policy().
* main.c (quit_box_new): gtk_window_set_resizable() instead of
gtk_window_set_policy().
(view_map_callback): g_signal_handlers_disconnect_by_func()
instead of gtk_signal_disconnect_by_func().
(main): No need to push the GdkRGB visual/cmap anymore.
(new_view_created_callback): Likewise.
* e-task-widget.c: Renamed member pixmap of ETaskWidgetPrivate to
`image'.
(init): Updated accordingly.
(e_task_widget_construct): Use GtkImage, not GtkPixmap.
* e-storage.c (class_init): Converted from gtk_signal_new() to
g_signal_new().
* e-storage-set.c (class_init): Converted from gtk_signal_new() to
g_signal_new().
* e-storage-set-view.c
(setup_folder_properties_items_if_corba_storage_clicked):
g_string_append_printf() instead of g_string_sprintfa().
(class_init): Converted from gtk_signal_new() to g_signal_new().
(setup_folder_changed_callbacks): Use
e_signal_connect_while_alive() and
e_signal_connect_full_while_alive().
* e-splash.c (e_splash_construct): gtk_window_set_resizable()
instead of gtk_window_set_policy().
* e-shortcuts.c: Do not #include e-unicode.h.
(shortcut_item_update): Use g_path_get_basename() instead of
g_basename().
(e_shortcuts_add_default_shortcuts): No need to de-utfize strings.
(e_shortcuts_add_default_group): Same here.
* e-shortcuts-view.c: Do not #include <e-unicode.h>.
(class_init): Converted from gtk_signal_new() to g_signal_new().
(destroy_group_cb): No need to convert the text from UTF8.
* e-shell.c (impl_dispose): g_signal_handlers_disconnect_by_func()
instead of gtk_signal_disconnect_by_func().
(class_init): Use g_signal_new() instead of gtk_signal_new().
* e-shell-view.c: Do not #include e-unicode.h. Renamed member
offline_toggle_pixmap to offline_toggle_image in
EShellViewPrivate.
(update_folder_title_bar): No need to de-UTF8-ize the title.
(cleanup_delayed_selection):
g_signal_handlers_disconnect_by_func() instead of
gtk_signal_disconnect_by_func().
(ui_engine_add_hint_callback): gtk_label_set_text(), not
gtk_label_set().
(class_init): Use g_signal_new() instead of gtk_signal_new().
(update_for_current_uri): No need to convert the title from UTF8.
(setup_offline_toggle): Changed to set up a GtkImage, not a
GtkPixmap.
(update_offline_toggle_status): Accordingly (gtk_image* instead of
gtk_pixmap*).
(set_current_notebook_page): gtk_notebook_set_current_page(), not
gtk_notebook_set_page().
(get_storage_set_path_from_uri): g_ascii_strncasecmp() instead of
g_strncasecmp().
(folder_bar_popup_map_callback): Use
e_signal_connect_while_alive() instead of
gtk_signal_connect_while_alive().
(e_shell_view_construct): Likewise.
(display_uri): g_signal_connect_after() instead of
gtk_signal_connect_full().
(update_for_current_uri):
g_signal_handlers_{block,unblock}_by_func() instead of
gtk_signal_handler_{block,unblock}_by_func().
* e-shell-view-menu.c (command_about_box):
gtk_window_set_resizable() instead of gtk_window_set_policy().
* e-shell-utils.c (get_mini_name): g_path_get_basename() instead
of g_basename().
* e-shell-user-creatable-items-handler.c
(append_xml_for_menu_item): g_string_append_printf() instead of
g_string_sprintfa().
(create_menu_xml): Likewise.
* e-shell-shared-folder-picker-dialog.c: Do not #include
e-unicode.h.
(progress_bar_timeout_callback): Expect a GtkProgressBar data and
just use gtk_progress_bar_pulse().
(create_progress_dialog): gtk_window_set_resizable() instead of
gtk_window_set_policy(). No gtk_progress_set_activity_mode().
(setup_server_option_menu): Just use
gtk_menu_item_new_with_label() instead of
e_utf8_gtk_menu_item_new_with_label().
* e-shell-settings-dialog.c (set_dialog_size): Ported to Pango.
* e-shell-offline-sync.c
(impl_SyncFolderProgressListener_updateProgress):
gtk_progress_set_fraction() instead of
gtk_progress_bar_set_percentage().
(sync_folder): Likewise.
(setup_dialog): gtk_window_set_resizable() instead of
gtk_window_set_policy().
(sync_folder): No gtk_progress_set_activity_mode().
* e-shell-offline-handler.c: #undef {G,GTK}_DISABLE_DEPRECATED
here for now (need to port from GtkCList).
(class_init): Use g_signal_new()
* e-shell-importer.c: #undef {G,GTK}_DISABLE_DEPRECATED here for
now (need to port from GtkCList).
* e-shell-folder-title-bar.c (create_image_widget_from_xpm):
Renamed from create_pixmap_widget_from_xpm(); handle GtkImage
instead of GtkPixmap.
(new_empty_image_widget): Renamed from new_empty_pixmap_widget();
return a GtkImage instead of a GtkPixmap.
(add_navigation_buttons): Updated accordingly; so use GtkImages
instead of GtkPixmaps.
(e_shell_folder_title_bar_construct): Likewise.
(e_shell_folder_title_bar_set_icon): Use gtk_image_* instead of
gtk_pixmap_* on the image widgets.
(class_init): Converted to use g_signal_new() instead of
gtk_signal_new().
(e_shell_folder_title_bar_new): No need for pushing the GdkRGB
visual/cmap anymore.
* e-shell-folder-selection-dialog.c (check_folder_type_valid):
Just use strcmp instead of strcasecmp().
(class_init): g_signal_new() instead of gtk_signal_new().
(e_shell_folder_selection_dialog_construct): Removed call to
gtk_window_set_policy().
* e-shell-folder-creation-dialog.c
(type_with_display_name_compare_func): Changed to use
g_utf8_casefold().
* e-shell-folder-commands.c: Do not #include e-unicode.h.
(e_shell_command_rename_folder): g_path_get_dirname() instead of
g_dirname().
(folder_selection_dialog_folder_selected_callback):
g_path_get_basename() instead of g_basename().
(rename_cb): Likewise.
(delete_dialog): Do not convert from UTF8 for display purposes.
(e_shell_command_rename_folder): Likewise.
* e-shell-about-box.c (timeout_callback): Ported to Pango and use
gdk_window_invalidate_rect() instead of gtk_widget_draw().
* e-setup.c (check_evolution_directory): Use
gtk_window_set_resizable() instead of gtk_window_set_policy().
* e-local-storage.c: Do not include e-unicode.h.
(create_folder): Use g_path_get_basename() instead of
g_basename().
(create_folder_directory): Likewise.
(remove_folder_directory): Likewise.
(append_xfer_item_list): Likewise.
* e-local-folder.c (construct_loading_metadata): Use
g_path_get_basename() instead of g_basename().
* e-folder-dnd-bridge.c (handle_evolution_path_drag_motion): Use
g_path_get_basename() instead of g_basename().
* e-corba-storage-registry.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* e-corba-shortcuts.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* e-component-registry.c
(sleep_with_g_main_loop_timeout_callback): g_main_loop_* instead
of g_main_*.
(sleep_with_g_main_loop): Likewise.
* e-activity-handler.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* evolution-wizard.c (evolution_wizard_class_init): g_signal_new()
instead of gtk_signal_new().
* evolution-storage-listener.c (class_init): g_signal_new()
instead of gtk_signal_new().
* evolution-shell-view.c (class_init): g_signal_new() instead of
gtk_signal_new().
* evolution-shell-component-dnd.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* evolution-shell-component.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* evolution-session.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* evolution-folder-selector-button.c: Do not include e-unicode.h.
(set_folder): No need to convert from UTF8 to locale encoding
anymore. Removed unused variable.
* evolution-config-control.c (class_init): Use g_signal_new()
instead of gtk_signal_new().
* evolution-activity-client.c (class_init): Use g_signal_new()
instead of gtk_signal_new().
* e-folder-list.c: Do not include e-unicode.h. Use E_MAKE_TYPE().
(e_folder_list_get_type): Removed explicit implementation of this.
(e_folder_list_set_arg): Removed.
(e_folder_list_get_arg): Removed.
(e_folder_list_set_property): New.
(e_folder_list_get_property): New.
(e_folder_list_destroy): Removed.
(e_folder_list_dispose): New.
(e_folder_list_class_init): Updated accordingly.
* e-folder.c (impl_save_info): Use G_OBJECT_TYPE_NAME() instead of
gtk_type_name().
(impl_load_info): Likewise.
(impl_remove): Likewise.
(class_init): Use g_signal_new() instead of gtk_signal_new().
svn path=/trunk/; revision=19170
526 lines
13 KiB
C
526 lines
13 KiB
C
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||
/* e-component-registry.c
|
||
*
|
||
* Copyright (C) 2000, 2001, 2002 Ximian, Inc.
|
||
*
|
||
* This program is free software; you can redistribute it and/or
|
||
* modify it under the terms of version 2 of the GNU General Public
|
||
* License as published by the Free Software Foundation.
|
||
*
|
||
* This program is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
* General Public License for more details.
|
||
*
|
||
* You should have received a copy of the GNU General Public
|
||
* License along with this program; if not, write to the
|
||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||
* Boston, MA 02111-1307, USA.
|
||
*
|
||
* Author: Ettore Perazzoli
|
||
*/
|
||
|
||
#ifdef HAVE_CONFIG_H
|
||
#include <config.h>
|
||
#endif
|
||
|
||
#include "e-component-registry.h"
|
||
|
||
#include <glib.h>
|
||
#include <gtk/gtktypeutils.h>
|
||
|
||
#include <gal/util/e-util.h>
|
||
|
||
#include <bonobo-activation/bonobo-activation.h>
|
||
|
||
#include "Evolution.h"
|
||
|
||
#include "e-shell-utils.h"
|
||
#include "evolution-shell-component-client.h"
|
||
|
||
|
||
#define PARENT_TYPE G_TYPE_OBJECT
|
||
static GObjectClass *parent_class = NULL;
|
||
|
||
typedef struct _Component Component;
|
||
|
||
struct _Component {
|
||
char *id;
|
||
|
||
EvolutionShellComponentClient *client;
|
||
|
||
/* Names of the folder types we support (normal ASCII strings). */
|
||
GList *folder_type_names;
|
||
};
|
||
|
||
struct _EComponentRegistryPrivate {
|
||
EShell *shell;
|
||
|
||
GHashTable *component_id_to_component;
|
||
};
|
||
|
||
|
||
/* Utility functions. */
|
||
|
||
static int
|
||
sleep_with_g_main_loop_timeout_callback (void *data)
|
||
{
|
||
GMainLoop *loop;
|
||
|
||
loop = (GMainLoop *) data;
|
||
g_main_loop_quit (loop);
|
||
|
||
return FALSE;
|
||
}
|
||
|
||
/* This function is like `sleep()', but it uses the GMainLoop so CORBA
|
||
invocations can get through. */
|
||
static void
|
||
sleep_with_g_main_loop (int num_seconds)
|
||
{
|
||
GMainLoop *loop;
|
||
|
||
loop = g_main_loop_new (NULL, TRUE);
|
||
g_timeout_add (1000 * num_seconds, sleep_with_g_main_loop_timeout_callback, loop);
|
||
g_main_loop_run (loop);
|
||
g_main_loop_unref (loop);
|
||
}
|
||
|
||
static void
|
||
wait_for_corba_object_to_die (Bonobo_Unknown corba_objref,
|
||
const char *id)
|
||
{
|
||
gboolean alive;
|
||
int count;
|
||
|
||
count = 1;
|
||
while (1) {
|
||
alive = bonobo_unknown_ping (corba_objref, NULL);
|
||
if (! alive)
|
||
break;
|
||
|
||
g_print ("Waiting for component to die -- %s (%d)\n", id, count);
|
||
sleep_with_g_main_loop (1);
|
||
count ++;
|
||
}
|
||
}
|
||
|
||
|
||
/* Component information handling. */
|
||
|
||
static Component *
|
||
component_new (const char *id,
|
||
EvolutionShellComponentClient *client)
|
||
{
|
||
Component *new;
|
||
|
||
g_object_ref (client);
|
||
|
||
new = g_new (Component, 1);
|
||
new->id = g_strdup (id);
|
||
new->folder_type_names = NULL;
|
||
new->client = client;
|
||
|
||
return new;
|
||
}
|
||
|
||
static gboolean
|
||
component_free (Component *component)
|
||
{
|
||
GNOME_Evolution_ShellComponent corba_shell_component;
|
||
CORBA_Environment ev;
|
||
gboolean retval;
|
||
|
||
CORBA_exception_init (&ev);
|
||
|
||
corba_shell_component = evolution_shell_component_client_corba_objref (component->client);
|
||
corba_shell_component = CORBA_Object_duplicate (corba_shell_component, &ev);
|
||
|
||
GNOME_Evolution_ShellComponent_unsetOwner (corba_shell_component, &ev);
|
||
if (ev._major == CORBA_NO_EXCEPTION)
|
||
retval = TRUE;
|
||
else
|
||
retval = FALSE;
|
||
CORBA_exception_free (&ev);
|
||
|
||
g_object_unref (component->client);
|
||
|
||
/* If the component is out-of-proc, wait for the process to die first. */
|
||
if (bonobo_object (ORBit_small_get_servant (corba_shell_component)) == NULL)
|
||
wait_for_corba_object_to_die ((Bonobo_Unknown) corba_shell_component, component->id);
|
||
|
||
CORBA_Object_release (corba_shell_component, &ev);
|
||
|
||
e_free_string_list (component->folder_type_names);
|
||
g_free (component->id);
|
||
|
||
g_free (component);
|
||
|
||
return retval;
|
||
}
|
||
|
||
static gboolean
|
||
register_type (EComponentRegistry *component_registry,
|
||
const char *name,
|
||
const char *icon_name,
|
||
const char *display_name,
|
||
const char *description,
|
||
gboolean user_creatable,
|
||
int num_exported_dnd_types,
|
||
const char **exported_dnd_types,
|
||
int num_accepted_dnd_types,
|
||
const char **accepted_dnd_types,
|
||
Component *handler,
|
||
gboolean override_duplicate)
|
||
{
|
||
EComponentRegistryPrivate *priv;
|
||
EFolderTypeRegistry *folder_type_registry;
|
||
|
||
priv = component_registry->priv;
|
||
|
||
folder_type_registry = e_shell_get_folder_type_registry (priv->shell);
|
||
g_assert (folder_type_registry != NULL);
|
||
|
||
if (override_duplicate
|
||
&& e_folder_type_registry_type_registered (folder_type_registry, name))
|
||
e_folder_type_registry_unregister_type (folder_type_registry, name);
|
||
|
||
if (! e_folder_type_registry_register_type (folder_type_registry,
|
||
name, icon_name,
|
||
display_name, description,
|
||
user_creatable,
|
||
num_exported_dnd_types,
|
||
exported_dnd_types,
|
||
num_accepted_dnd_types,
|
||
accepted_dnd_types)) {
|
||
g_warning ("Trying to register duplicate folder type -- %s", name);
|
||
return FALSE;
|
||
}
|
||
|
||
e_folder_type_registry_set_handler_for_type (folder_type_registry, name, handler->client);
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
static gboolean
|
||
register_component (EComponentRegistry *component_registry,
|
||
const char *id,
|
||
gboolean override_duplicate,
|
||
CORBA_Environment *ev)
|
||
{
|
||
EComponentRegistryPrivate *priv;
|
||
GNOME_Evolution_ShellComponent component_corba_interface;
|
||
GNOME_Evolution_Shell shell_corba_interface;
|
||
GNOME_Evolution_FolderTypeList *supported_types;
|
||
GNOME_Evolution_URISchemaList *supported_schemas;
|
||
Component *component;
|
||
EvolutionShellComponentClient *client;
|
||
CORBA_Environment my_ev;
|
||
CORBA_unsigned_long i;
|
||
|
||
priv = component_registry->priv;
|
||
|
||
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;
|
||
}
|
||
|
||
client = evolution_shell_component_client_new (id, ev);
|
||
if (client == NULL)
|
||
return FALSE;
|
||
|
||
/* FIXME we could use the EvolutionShellComponentClient API here instead, but for
|
||
now we don't care. */
|
||
|
||
component_corba_interface = evolution_shell_component_client_corba_objref (client);
|
||
shell_corba_interface = BONOBO_OBJREF (priv->shell);
|
||
|
||
CORBA_exception_init (&my_ev);
|
||
|
||
/* Register the supported folder types. */
|
||
|
||
supported_types = GNOME_Evolution_ShellComponent__get_supportedTypes (component_corba_interface, &my_ev);
|
||
if (my_ev._major != CORBA_NO_EXCEPTION || supported_types->_length == 0) {
|
||
g_object_unref (client);
|
||
CORBA_exception_free (&my_ev);
|
||
return FALSE;
|
||
}
|
||
|
||
CORBA_exception_free (&my_ev);
|
||
|
||
component = component_new (id, client);
|
||
g_hash_table_insert (priv->component_id_to_component, component->id, component);
|
||
g_object_unref (client);
|
||
|
||
for (i = 0; i < supported_types->_length; i++) {
|
||
const GNOME_Evolution_FolderType *type;
|
||
|
||
type = supported_types->_buffer + i;
|
||
|
||
if (! register_type (component_registry,
|
||
type->name, type->iconName,
|
||
type->displayName, type->description,
|
||
type->userCreatable,
|
||
type->exportedDndTypes._length,
|
||
(const char **) type->exportedDndTypes._buffer,
|
||
type->acceptedDndTypes._length,
|
||
(const char **) type->acceptedDndTypes._buffer,
|
||
component,
|
||
override_duplicate)) {
|
||
g_warning ("Cannot register type `%s' for component %s",
|
||
type->name, component->id);
|
||
}
|
||
}
|
||
|
||
CORBA_free (supported_types);
|
||
|
||
/* Register the supported external URI schemas. */
|
||
|
||
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);
|
||
|
||
for (i = 0; i < supported_schemas->_length; i++) {
|
||
const CORBA_char *schema;
|
||
|
||
schema = supported_schemas->_buffer[i];
|
||
e_uri_schema_registry_set_handler_for_schema (uri_schema_registry, schema, component->client);
|
||
}
|
||
|
||
CORBA_free (supported_schemas);
|
||
}
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
|
||
/* GObject methods. */
|
||
|
||
static void
|
||
component_id_foreach_free (void *key,
|
||
void *value,
|
||
void *user_data)
|
||
{
|
||
Component *component;
|
||
|
||
component = (Component *) value;
|
||
component_free (component);
|
||
}
|
||
|
||
static void
|
||
impl_dispose (GObject *object)
|
||
{
|
||
EComponentRegistry *component_registry;
|
||
EComponentRegistryPrivate *priv;
|
||
|
||
component_registry = E_COMPONENT_REGISTRY (object);
|
||
priv = component_registry->priv;
|
||
|
||
if (priv->component_id_to_component != NULL) {
|
||
g_hash_table_foreach (priv->component_id_to_component, component_id_foreach_free, NULL);
|
||
g_hash_table_destroy (priv->component_id_to_component);
|
||
priv->component_id_to_component = NULL;
|
||
}
|
||
|
||
(* G_OBJECT_CLASS (parent_class)->dispose) (object);
|
||
}
|
||
|
||
static void
|
||
impl_finalize (GObject *object)
|
||
{
|
||
EComponentRegistry *component_registry;
|
||
EComponentRegistryPrivate *priv;
|
||
|
||
component_registry = E_COMPONENT_REGISTRY (object);
|
||
priv = component_registry->priv;
|
||
|
||
g_free (priv);
|
||
|
||
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
|
||
}
|
||
|
||
|
||
static void
|
||
class_init (EComponentRegistryClass *klass)
|
||
{
|
||
GObjectClass *object_class;
|
||
|
||
object_class = G_OBJECT_CLASS (klass);
|
||
object_class->dispose = impl_dispose;
|
||
object_class->finalize = impl_finalize;
|
||
|
||
parent_class = g_type_class_ref(PARENT_TYPE);
|
||
}
|
||
|
||
|
||
static void
|
||
init (EComponentRegistry *component_registry)
|
||
{
|
||
EComponentRegistryPrivate *priv;
|
||
|
||
priv = g_new (EComponentRegistryPrivate, 1);
|
||
priv->shell = NULL;
|
||
priv->component_id_to_component = g_hash_table_new (g_str_hash, g_str_equal);
|
||
|
||
component_registry->priv = priv;
|
||
}
|
||
|
||
|
||
void
|
||
e_component_registry_construct (EComponentRegistry *component_registry,
|
||
EShell *shell)
|
||
{
|
||
EComponentRegistryPrivate *priv;
|
||
|
||
g_return_if_fail (component_registry != NULL);
|
||
g_return_if_fail (E_IS_COMPONENT_REGISTRY (component_registry));
|
||
g_return_if_fail (shell != NULL);
|
||
g_return_if_fail (E_IS_SHELL (shell));
|
||
|
||
priv = component_registry->priv;
|
||
priv->shell = shell;
|
||
}
|
||
|
||
EComponentRegistry *
|
||
e_component_registry_new (EShell *shell)
|
||
{
|
||
EComponentRegistry *component_registry;
|
||
|
||
g_return_val_if_fail (shell != NULL, NULL);
|
||
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
|
||
|
||
component_registry = g_object_new (e_component_registry_get_type (), NULL);
|
||
e_component_registry_construct (component_registry, shell);
|
||
|
||
return component_registry;
|
||
}
|
||
|
||
|
||
gboolean
|
||
e_component_registry_register_component (EComponentRegistry *component_registry,
|
||
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, ev);
|
||
}
|
||
|
||
|
||
static void
|
||
compose_id_list_foreach (void *key,
|
||
void *value,
|
||
void *data)
|
||
{
|
||
GList **listp;
|
||
const char *id;
|
||
|
||
listp = (GList **) data;
|
||
id = (const char *) key;
|
||
|
||
*listp = g_list_prepend (*listp, g_strdup (id));
|
||
}
|
||
|
||
/**
|
||
* e_component_registry_get_id_list:
|
||
* @component_registry:
|
||
*
|
||
* Get the list of components registered.
|
||
*
|
||
* Return value: A GList of strings containining the IDs for all the registered
|
||
* components. The list must be freed by the caller when not used anymore.
|
||
**/
|
||
GList *
|
||
e_component_registry_get_id_list (EComponentRegistry *component_registry)
|
||
{
|
||
EComponentRegistryPrivate *priv;
|
||
GList *list;
|
||
|
||
g_return_val_if_fail (component_registry != NULL, NULL);
|
||
g_return_val_if_fail (E_IS_COMPONENT_REGISTRY (component_registry), NULL);
|
||
|
||
priv = component_registry->priv;
|
||
list = NULL;
|
||
|
||
g_hash_table_foreach (priv->component_id_to_component, compose_id_list_foreach, &list);
|
||
|
||
return list;
|
||
}
|
||
|
||
/**
|
||
* e_component_registry_get_component_by_id:
|
||
* @component_registry:
|
||
* @id: The component's OAF ID
|
||
*
|
||
* Get the registered component client for the specified ID. If that component
|
||
* is not registered, return NULL.
|
||
*
|
||
* Return value: A pointer to the ShellComponentClient for that component.
|
||
**/
|
||
EvolutionShellComponentClient *
|
||
e_component_registry_get_component_by_id (EComponentRegistry *component_registry,
|
||
const char *id)
|
||
{
|
||
EComponentRegistryPrivate *priv;
|
||
const Component *component;
|
||
|
||
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;
|
||
|
||
return component->client;
|
||
}
|
||
|
||
|
||
EvolutionShellComponentClient *
|
||
e_component_registry_restart_component (EComponentRegistry *component_registry,
|
||
const char *id,
|
||
CORBA_Environment *ev)
|
||
{
|
||
EComponentRegistryPrivate *priv;
|
||
Component *component;
|
||
CORBA_Environment my_ev;
|
||
CORBA_Object corba_objref;
|
||
|
||
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 (&my_ev);
|
||
|
||
g_hash_table_remove (priv->component_id_to_component, id);
|
||
|
||
corba_objref = CORBA_Object_duplicate (evolution_shell_component_client_corba_objref (component->client), &my_ev);
|
||
|
||
component_free (component);
|
||
|
||
wait_for_corba_object_to_die (corba_objref, id);
|
||
|
||
CORBA_exception_free (&my_ev);
|
||
|
||
if (! register_component (component_registry, id, TRUE, ev))
|
||
return NULL;
|
||
|
||
return e_component_registry_get_component_by_id (component_registry, id);
|
||
}
|
||
|
||
|
||
E_MAKE_TYPE (e_component_registry, "EComponentRegistry", EComponentRegistry,
|
||
class_init, init, PARENT_TYPE)
|