aboutsummaryrefslogtreecommitdiffstats
path: root/shell/importer/evolution-importer-client.c
diff options
context:
space:
mode:
authorIain Holmes <iain@src.gnome.org>2001-01-18 02:28:39 +0800
committerIain Holmes <iain@src.gnome.org>2001-01-18 02:28:39 +0800
commit59bd12b76388b33ccde74bc151fabda14a763924 (patch)
tree7eacadebe9ff5ca37ea51e144378604b55926407 /shell/importer/evolution-importer-client.c
parentb77c7192f536108e07ffaf19a58e6bff9b011a93 (diff)
downloadgsoc2013-evolution-59bd12b76388b33ccde74bc151fabda14a763924.tar
gsoc2013-evolution-59bd12b76388b33ccde74bc151fabda14a763924.tar.gz
gsoc2013-evolution-59bd12b76388b33ccde74bc151fabda14a763924.tar.bz2
gsoc2013-evolution-59bd12b76388b33ccde74bc151fabda14a763924.tar.lz
gsoc2013-evolution-59bd12b76388b33ccde74bc151fabda14a763924.tar.xz
gsoc2013-evolution-59bd12b76388b33ccde74bc151fabda14a763924.tar.zst
gsoc2013-evolution-59bd12b76388b33ccde74bc151fabda14a763924.zip
Removed the factory and updated the interfaces and objects
svn path=/trunk/; revision=7590
Diffstat (limited to 'shell/importer/evolution-importer-client.c')
-rw-r--r--shell/importer/evolution-importer-client.c124
1 files changed, 122 insertions, 2 deletions
diff --git a/shell/importer/evolution-importer-client.c b/shell/importer/evolution-importer-client.c
index 1687679cc4..da17cecbfd 100644
--- a/shell/importer/evolution-importer-client.c
+++ b/shell/importer/evolution-importer-client.c
@@ -1,5 +1,5 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* evolution-importer-listener.c
+/* evolution-importer-client.c
*
* Copyright (C) 2000 Helix Code, Inc.
*
@@ -30,6 +30,8 @@
#include <bonobo/bonobo-main.h>
#include <gal/util/e-util.h>
+#include <liboaf/liboaf.h>
+
#include "GNOME_Evolution_Importer.h"
#include "evolution-importer-client.h"
@@ -254,7 +256,7 @@ init (EvolutionImporterClient *client)
client->private = priv;
}
-void
+static void
evolution_importer_client_construct (EvolutionImporterClient *client,
CORBA_Object corba_object)
{
@@ -265,6 +267,14 @@ evolution_importer_client_construct (EvolutionImporterClient *client,
bonobo_object_client_construct (BONOBO_OBJECT_CLIENT (client), corba_object);
}
+/**
+ * evolution_importer_client_new:
+ * @objref: The CORBA_Object to make a client for.
+ *
+ * Makes a client for @objref. @objref should be an Evolution_Importer.
+ *
+ * Returns: A newly created EvolutionImporterClient.
+ */
EvolutionImporterClient *
evolution_importer_client_new (const CORBA_Object objref)
{
@@ -278,7 +288,108 @@ evolution_importer_client_new (const CORBA_Object objref)
return client;
}
+/**
+ * evolution_importer_client_new_from_id:
+ * @id: The oafiid of the component to make a client for.
+ *
+ * Makes a client for the object returned by activating @id.
+ *
+ * Returns: A newly created EvolutionImporterClient.
+ */
+EvolutionImporterClient *
+evolution_importer_client_new_from_id (const char *id)
+{
+ CORBA_Environment ev;
+ CORBA_Object objref;
+
+ g_return_val_if_fail (id != NULL, NULL);
+
+ CORBA_exception_init (&ev);
+ objref = oaf_activate_from_id ((char *) id, 0, NULL, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ CORBA_exception_free (&ev);
+ g_warning ("Could not start %s.", id);
+ return NULL;
+ }
+
+ if (objref == CORBA_OBJECT_NIL) {
+ g_warning ("Could not activate component %s", id);
+ return NULL;
+ }
+
+ return evolution_importer_client_new (objref);
+}
+
/* API */
+/**
+ * evolution_importer_client_support_format:
+ * @client: The EvolutionImporterClient.
+ * @filename: Name of the file to check.
+ *
+ * Checks whether @client is able to import @filename.
+ *
+ * Returns: TRUE if @client can import @filename, FALSE otherwise.
+ */
+gboolean
+evolution_importer_client_support_format (EvolutionImporterClient *client,
+ const char *filename)
+{
+ GNOME_Evolution_Importer corba_importer;
+ gboolean result;
+ CORBA_Environment ev;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (EVOLUTION_IS_IMPORTER_CLIENT (client), FALSE);
+ g_return_val_if_fail (filename != NULL, FALSE);
+
+ CORBA_exception_init (&ev);
+ corba_importer = bonobo_object_corba_objref (BONOBO_OBJECT (client));
+ result = GNOME_Evolution_Importer_supportFormat (corba_importer,
+ filename, &ev);
+ CORBA_exception_free (&ev);
+
+ return result;
+}
+
+/**
+ * evolution_importer_client_load_file:
+ * @client: The EvolutionImporterClient.
+ * @filename: The file to load.
+ *
+ * Loads and initialises the importer.
+ *
+ * Returns: TRUE on sucess, FALSE on failure.
+ */
+gboolean
+evolution_importer_client_load_file (EvolutionImporterClient *client,
+ const char *filename)
+{
+ GNOME_Evolution_Importer corba_importer;
+ gboolean result;
+ CORBA_Environment ev;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (EVOLUTION_IS_IMPORTER_CLIENT (client), FALSE);
+ g_return_val_if_fail (filename != NULL, FALSE);
+
+ CORBA_exception_init (&ev);
+ corba_importer = bonobo_object_corba_objref (BONOBO_OBJECT (client));
+ result = GNOME_Evolution_Importer_loadFile (corba_importer,
+ filename, &ev);
+ CORBA_exception_free (&ev);
+
+ return result;
+}
+
+/**
+ * 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.
+ *
+ * Starts importing the next item in the file and calls @callback when the
+ * item has finished importing.
+ */
void
evolution_importer_client_process_item (EvolutionImporterClient *client,
EvolutionImporterClientCallback callback,
@@ -312,6 +423,15 @@ evolution_importer_client_process_item (EvolutionImporterClient *client,
CORBA_exception_free (&ev);
}
+/**
+ * evolution_importer_client_get_error:
+ * @client: The EvolutionImporterClient.
+ *
+ * Gets the error as a string.
+ *
+ * Returns: The error as a string. If there is no error NULL is returned.
+ * Importers need not support this method and if so, NULL is also returned.
+ */
const char *
evolution_importer_client_get_error (EvolutionImporterClient *client)
{