aboutsummaryrefslogtreecommitdiffstats
path: root/shell/importer/evolution-importer-client.c
diff options
context:
space:
mode:
authorIain Holmes <iain@src.gnome.org>2001-01-23 08:37:44 +0800
committerIain Holmes <iain@src.gnome.org>2001-01-23 08:37:44 +0800
commit9908f0dba12569b2b9fe0b48de9d46ec3f2386bc (patch)
tree70cb90835c03f9f38014008932e5695e63ae47e0 /shell/importer/evolution-importer-client.c
parentff2d16601e0b4b71339b0820f4d2a5e0e92fdb92 (diff)
downloadgsoc2013-evolution-9908f0dba12569b2b9fe0b48de9d46ec3f2386bc.tar
gsoc2013-evolution-9908f0dba12569b2b9fe0b48de9d46ec3f2386bc.tar.gz
gsoc2013-evolution-9908f0dba12569b2b9fe0b48de9d46ec3f2386bc.tar.bz2
gsoc2013-evolution-9908f0dba12569b2b9fe0b48de9d46ec3f2386bc.tar.lz
gsoc2013-evolution-9908f0dba12569b2b9fe0b48de9d46ec3f2386bc.tar.xz
gsoc2013-evolution-9908f0dba12569b2b9fe0b48de9d46ec3f2386bc.tar.zst
gsoc2013-evolution-9908f0dba12569b2b9fe0b48de9d46ec3f2386bc.zip
New listener object. Plus some oneway stuff as well.
svn path=/trunk/; revision=7729
Diffstat (limited to 'shell/importer/evolution-importer-client.c')
-rw-r--r--shell/importer/evolution-importer-client.c230
1 files changed, 11 insertions, 219 deletions
diff --git a/shell/importer/evolution-importer-client.c b/shell/importer/evolution-importer-client.c
index da17cecbfd..f702dd970c 100644
--- a/shell/importer/evolution-importer-client.c
+++ b/shell/importer/evolution-importer-client.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* evolution-importer-client.c
*
- * Copyright (C) 2000 Helix Code, Inc.
+ * Copyright (C) 2000 Ximian, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -18,7 +18,7 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * Author: Iain Holmes <iain@helixcode.com>
+ * Author: Iain Holmes <iain@ximian.com>
* Based on evolution-shell-component-client.c by Ettore Perazzoli
*/
@@ -39,195 +39,10 @@
#define PARENT_TYPE BONOBO_OBJECT_CLIENT_TYPE
static BonoboObjectClass *parent_class = NULL;
-struct _EvolutionImporterClientPrivate {
- EvolutionImporterClientCallback callback;
- void *closure;
-
- GNOME_Evolution_ImporterListener listener_interface;
- PortableServer_Servant listener_servant;
-};
-
-
-static PortableServer_ServantBase__epv Listener_base_epv;
-static POA_GNOME_Evolution_ImporterListener__epv Listener_epv;
-static POA_GNOME_Evolution_ImporterListener__vepv Listener_vepv;
-static gboolean Listener_vepv_initialized = FALSE;
-
-struct _ImporterListenerServant {
- POA_GNOME_Evolution_ImporterListener servant;
- EvolutionImporterClient *component_client;
-};
-typedef struct _ImporterListenerServant ImporterListenerServant;
-
-
static void
-dispatch_callback (EvolutionImporterClient *client,
- EvolutionImporterResult result,
- gboolean more_items)
-{
- EvolutionImporterClientPrivate *priv;
- EvolutionImporterClientCallback callback;
- PortableServer_ObjectId *oid;
- void *closure;
- CORBA_Environment ev;
-
- priv = client->private;
-
- g_return_if_fail (priv->callback != NULL);
- g_return_if_fail (priv->listener_servant != NULL);
-
- CORBA_exception_init (&ev);
-
- oid = PortableServer_POA_servant_to_id (bonobo_poa (), priv->listener_servant, &ev);
- PortableServer_POA_deactivate_object (bonobo_poa (), oid, &ev);
- POA_GNOME_Evolution_ImporterListener__fini (priv->listener_servant, &ev);
- CORBA_free (oid);
-
- CORBA_Object_release (priv->listener_interface, &ev);
- CORBA_exception_free (&ev);
-
- priv->listener_servant = NULL;
- priv->listener_interface = CORBA_OBJECT_NIL;
-
- callback = priv->callback;
- closure = priv->closure;
-
- priv->callback = NULL;
- priv->closure = NULL;
-
- (* callback) (client, result, more_items, closure);
-}
-
-static EvolutionImporterClient *
-component_client_from_ImporterListener_servant (PortableServer_Servant servant)
-{
- ImporterListenerServant *listener_servant;
-
- listener_servant = (ImporterListenerServant *) servant;
- return listener_servant->component_client;
-}
-
-static EvolutionImporterResult
-result_from_async_corba_result (GNOME_Evolution_ImporterListener_ImporterResult corba_result)
-{
- switch (corba_result) {
- case GNOME_Evolution_ImporterListener_OK:
- return EVOLUTION_IMPORTER_OK;
- case GNOME_Evolution_ImporterListener_UNSUPPORTED_OPERATION:
- return EVOLUTION_IMPORTER_UNSUPPORTED_OPERATION;
- case GNOME_Evolution_ImporterListener_UNKNOWN_DATA:
- return EVOLUTION_IMPORTER_UNKNOWN_DATA;
- case GNOME_Evolution_ImporterListener_BAD_DATA:
- return EVOLUTION_IMPORTER_BAD_DATA;
- case GNOME_Evolution_ImporterListener_BAD_FILE:
- return EVOLUTION_IMPORTER_BAD_FILE;
- case GNOME_Evolution_ImporterListener_NOT_READY:
- return EVOLUTION_IMPORTER_NOT_READY;
- default:
- return EVOLUTION_IMPORTER_UNKNOWN_ERROR;
- }
-}
-
-static void
-impl_ImporterListener_notifyResult (PortableServer_Servant servant,
- const GNOME_Evolution_ImporterListener_ImporterResult result,
- const CORBA_boolean more_items,
- CORBA_Environment *ev)
-{
- EvolutionImporterClient *client;
-
- client = component_client_from_ImporterListener_servant (servant);
- dispatch_callback (client, result_from_async_corba_result (result), more_items);
-}
-
-static void
-ImporterListener_vepv_initialize (void)
-{
- Listener_base_epv._private = NULL;
- Listener_base_epv.finalize = NULL;
- Listener_base_epv.default_POA = NULL;
-
- Listener_epv.notifyResult = impl_ImporterListener_notifyResult;
-
- Listener_vepv._base_epv = &Listener_base_epv;
- Listener_vepv.GNOME_Evolution_ImporterListener_epv = &Listener_epv;
-
- Listener_vepv_initialized = TRUE;
-}
-
-static PortableServer_Servant *
-create_listener_servant (EvolutionImporterClient *client)
-{
- ImporterListenerServant *servant;
-
- if (!Listener_vepv_initialized)
- ImporterListener_vepv_initialize ();
-
- servant = g_new0 (ImporterListenerServant, 1);
- servant->servant.vepv = &Listener_vepv;
- servant->component_client = client;
-
- return (PortableServer_Servant) servant;
-}
-
-static void
-free_listener_servant (PortableServer_Servant servant)
-{
- g_free (servant);
-}
-
-static void
-create_listener_interface (EvolutionImporterClient *client)
-{
- EvolutionImporterClientPrivate *priv;
- PortableServer_Servant listener_servant;
- GNOME_Evolution_ImporterListener corba_interface;
- CORBA_Environment ev;
-
- priv = client->private;
-
- listener_servant = create_listener_servant (client);
- CORBA_exception_init (&ev);
-
- POA_GNOME_Evolution_ImporterListener__init (listener_servant, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- free_listener_servant (listener_servant);
- return;
- }
-
- CORBA_free (PortableServer_POA_activate_object (bonobo_poa (),
- listener_servant, &ev));
- corba_interface = PortableServer_POA_servant_to_reference (bonobo_poa (),
- listener_servant, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- corba_interface = CORBA_OBJECT_NIL;
- free_listener_servant (listener_servant);
- }
-
- CORBA_exception_free (&ev);
-
- priv->listener_servant = listener_servant;
- priv->listener_interface = corba_interface;
-}
-
-
-
-static void
destroy (GtkObject *object)
{
- EvolutionImporterClient *client;
- EvolutionImporterClientPrivate *priv;
-
- client = EVOLUTION_IMPORTER_CLIENT (object);
- priv = client->private;
-
- if (priv->callback != NULL)
- dispatch_callback (client, EVOLUTION_IMPORTER_INTERRUPTED, FALSE);
-
- g_free (priv);
-
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
@@ -245,15 +60,6 @@ class_init (EvolutionImporterClientClass *klass)
static void
init (EvolutionImporterClient *client)
{
- EvolutionImporterClientPrivate *priv;
-
- priv = g_new (EvolutionImporterClientPrivate, 1);
- priv->listener_interface = CORBA_OBJECT_NIL;
- priv->listener_servant = NULL;
- priv->callback = NULL;
- priv->closure = NULL;
-
- client->private = priv;
}
static void
@@ -384,42 +190,30 @@ evolution_importer_client_load_file (EvolutionImporterClient *client,
/**
* evolution_importer_client_process_item:
* @client: The EvolutionImporterClient.
- * @callback: The function to be called once the item has been processed.
- * @closure: The data to be passed to this function.
+ * @listener: The EvolutionImporterListener.
*
- * Starts importing the next item in the file and calls @callback when the
- * item has finished importing.
+ * Starts importing the next item in the file. @listener will be notified
+ * when the item has finished.
*/
void
evolution_importer_client_process_item (EvolutionImporterClient *client,
- EvolutionImporterClientCallback callback,
- void *closure)
+ EvolutionImporterListener *listener)
{
- EvolutionImporterClientPrivate *priv;
GNOME_Evolution_Importer corba_importer;
+ GNOME_Evolution_ImporterListener corba_listener;
CORBA_Environment ev;
g_return_if_fail (client != NULL);
g_return_if_fail (EVOLUTION_IS_IMPORTER_CLIENT (client));
- g_return_if_fail (callback != NULL);
-
- priv = client->private;
-
- if (priv->callback != NULL) {
- (* callback) (client, EVOLUTION_IMPORTER_BUSY, FALSE, closure);
- return;
- }
-
- create_listener_interface (client);
+ g_return_if_fail (listener != NULL);
+ g_return_if_fail (EVOLUTION_IS_IMPORTER_LISTENER (listener));
CORBA_exception_init (&ev);
corba_importer = bonobo_object_corba_objref (BONOBO_OBJECT (client));
- priv->callback = callback;
- priv->closure = closure;
-
+ corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener));
GNOME_Evolution_Importer_processItem (corba_importer,
- priv->listener_interface, &ev);
+ corba_listener, &ev);
CORBA_exception_free (&ev);
}
@@ -435,7 +229,6 @@ evolution_importer_client_process_item (EvolutionImporterClient *client,
const char *
evolution_importer_client_get_error (EvolutionImporterClient *client)
{
- EvolutionImporterClientPrivate *priv;
GNOME_Evolution_Importer corba_importer;
CORBA_char *str;
CORBA_Environment ev;
@@ -443,7 +236,6 @@ evolution_importer_client_get_error (EvolutionImporterClient *client)
g_return_val_if_fail (client != NULL, NULL);
g_return_val_if_fail (EVOLUTION_IS_IMPORTER_CLIENT (client), NULL);
- priv = client->private;
corba_importer = bonobo_object_corba_objref (BONOBO_OBJECT (client));
CORBA_exception_init (&ev);