aboutsummaryrefslogtreecommitdiffstats
path: root/shell/importer
diff options
context:
space:
mode:
authorIain Holmes <iain@src.gnome.org>2001-03-13 10:26:18 +0800
committerIain Holmes <iain@src.gnome.org>2001-03-13 10:26:18 +0800
commit8c2f3a00ef98717e4203630c8119f2e84d2bb796 (patch)
treef4ec43d8f0e79adffebcfe80de345981a3dbf556 /shell/importer
parentc807d96e58f7a4c6c2c306f6da26a63b608f840b (diff)
downloadgsoc2013-evolution-8c2f3a00ef98717e4203630c8119f2e84d2bb796.tar
gsoc2013-evolution-8c2f3a00ef98717e4203630c8119f2e84d2bb796.tar.gz
gsoc2013-evolution-8c2f3a00ef98717e4203630c8119f2e84d2bb796.tar.bz2
gsoc2013-evolution-8c2f3a00ef98717e4203630c8119f2e84d2bb796.tar.lz
gsoc2013-evolution-8c2f3a00ef98717e4203630c8119f2e84d2bb796.tar.xz
gsoc2013-evolution-8c2f3a00ef98717e4203630c8119f2e84d2bb796.tar.zst
gsoc2013-evolution-8c2f3a00ef98717e4203630c8119f2e84d2bb796.zip
All my changes to get the folder creation working, and the magic Netscape
importer. svn path=/trunk/; revision=8661
Diffstat (limited to 'shell/importer')
-rw-r--r--shell/importer/GNOME_Evolution_Importer.idl10
-rw-r--r--shell/importer/Makefile.am3
-rw-r--r--shell/importer/evolution-importer-listener.c52
-rw-r--r--shell/importer/evolution-importer-listener.h14
-rw-r--r--shell/importer/evolution-importer.c112
-rw-r--r--shell/importer/evolution-importer.h13
-rw-r--r--shell/importer/evolution-intelligent-importer.c198
-rw-r--r--shell/importer/evolution-intelligent-importer.h74
-rw-r--r--shell/importer/intelligent.c174
-rw-r--r--shell/importer/intelligent.h0
10 files changed, 531 insertions, 119 deletions
diff --git a/shell/importer/GNOME_Evolution_Importer.idl b/shell/importer/GNOME_Evolution_Importer.idl
index fe49ab82c5..7dec5e7e0c 100644
--- a/shell/importer/GNOME_Evolution_Importer.idl
+++ b/shell/importer/GNOME_Evolution_Importer.idl
@@ -79,5 +79,15 @@ module Evolution {
*/
boolean loadFile (in string filename);
};
+
+ interface IntelligentImporter : Bonobo::Unknown {
+
+ readonly attribute string importername;
+ readonly attribute string message;
+
+ boolean canImport ();
+
+ void importData ();
+ };
};
};
diff --git a/shell/importer/Makefile.am b/shell/importer/Makefile.am
index 96bbbafd5c..975d5a372a 100644
--- a/shell/importer/Makefile.am
+++ b/shell/importer/Makefile.am
@@ -27,14 +27,17 @@ idl_DATA = $(IDLS)
libevolution_importerincludedir = $(includedir)/evolution/importer
libevolution_importer_la_SOURCES = \
$(IDL_GENERATED) \
+ evolution-intelligent-importer.c \
evolution-importer-client.c \
evolution-importer-listener.c \
evolution-importer.c \
+ intelligent.c \
importer.c \
importer.h
libevolution_importerinclude_HEADERS = \
GNOME_Evolution_Importer.h \
+ evolution-intelligent-importer.h \
evolution-importer-client.h \
evolution-importer-listener.h \
evolution-importer.h
diff --git a/shell/importer/evolution-importer-listener.c b/shell/importer/evolution-importer-listener.c
index 35e73634d5..62dc35b19c 100644
--- a/shell/importer/evolution-importer-listener.c
+++ b/shell/importer/evolution-importer-listener.c
@@ -31,9 +31,9 @@
#include "GNOME_Evolution_Importer.h"
#include "evolution-importer-listener.h"
-#define PARENT_TYPE (bonobo_object_get_type ())
+#define PARENT_TYPE BONOBO_X_OBJECT_TYPE
-static BonoboObjectClass *parent_class;
+static BonoboObjectClass *parent_class = NULL;
struct _EvolutionImporterListenerPrivate {
EvolutionImporterListenerCallback callback;
@@ -41,6 +41,7 @@ struct _EvolutionImporterListenerPrivate {
void *closure;
};
+#if 0
static POA_GNOME_Evolution_ImporterListener__vepv Listener_vepv;
static POA_GNOME_Evolution_ImporterListener *
@@ -64,6 +65,7 @@ create_servant (void)
return servant;
}
+#endif
static EvolutionImporterResult
corba_result_to_evolution (GNOME_Evolution_ImporterListener_ImporterResult corba_result)
@@ -88,20 +90,24 @@ corba_result_to_evolution (GNOME_Evolution_ImporterListener_ImporterResult corba
}
}
+static inline EvolutionImporterListener *
+evolution_importer_listener_from_servant (PortableServer_Servant servant)
+{
+ return EVOLUTION_IMPORTER_LISTENER (bonobo_object_from_servant (servant));
+}
+
static void
impl_GNOME_Evolution_ImporterListener_notifyResult (PortableServer_Servant servant,
GNOME_Evolution_ImporterListener_ImporterResult result,
CORBA_boolean more_items,
CORBA_Environment *ev)
{
- BonoboObject *bonobo_object;
EvolutionImporterListener *listener;
EvolutionImporterListenerPrivate *priv;
EvolutionImporterResult out_result;
- bonobo_object = bonobo_object_from_servant (servant);
- listener = EVOLUTION_IMPORTER_LISTENER (bonobo_object);
- priv = listener->private;
+ listener = evolution_importer_listener_from_servant (servant);
+ priv = listener->priv;
out_result = corba_result_to_evolution (result);
if (priv->callback) {
@@ -121,17 +127,18 @@ destroy (GtkObject *object)
EvolutionImporterListenerPrivate *priv;
listener = EVOLUTION_IMPORTER_LISTENER (object);
- priv = listener->private;
+ priv = listener->priv;
if (priv == NULL)
return;
g_free (priv);
- listener->private = NULL;
+ listener->priv = NULL;
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
+#if 0
static void
corba_class_init (void)
{
@@ -152,32 +159,30 @@ corba_class_init (void)
vepv->Bonobo_Unknown_epv = bonobo_object_get_epv ();
vepv->GNOME_Evolution_ImporterListener_epv = epv;
}
+#endif
static void
-class_init (EvolutionImporterListenerClass *klass)
+evolution_importer_listener_class_init (EvolutionImporterListenerClass *klass)
{
GtkObjectClass *object_class;
+ POA_GNOME_Evolution_ImporterListener__epv *epv = &klass->epv;
object_class = GTK_OBJECT_CLASS (klass);
object_class->destroy = destroy;
parent_class = gtk_type_class (PARENT_TYPE);
-
- corba_class_init ();
+ epv->notifyResult = impl_GNOME_Evolution_ImporterListener_notifyResult;
}
static void
-init (EvolutionImporterListener *listener)
+evolution_importer_listener_init (EvolutionImporterListener *listener)
{
EvolutionImporterListenerPrivate *priv;
priv = g_new0 (EvolutionImporterListenerPrivate, 1);
- listener->private = priv;
+ listener->priv = priv;
}
-E_MAKE_TYPE (evolution_importer_listener, "EvolutionImporterListener",
- EvolutionImporterListener, class_init, init, PARENT_TYPE);
-
static void
evolution_importer_listener_construct (EvolutionImporterListener *listener,
GNOME_Evolution_ImporterListener corba_object,
@@ -191,7 +196,7 @@ evolution_importer_listener_construct (EvolutionImporterListener *listener,
g_return_if_fail (corba_object != CORBA_OBJECT_NIL);
g_return_if_fail (callback != NULL);
- priv = listener->private;
+ priv = listener->priv;
priv->callback = callback;
priv->closure = closure;
@@ -212,18 +217,15 @@ evolution_importer_listener_new (EvolutionImporterListenerCallback callback,
void *closure)
{
EvolutionImporterListener *listener;
- POA_GNOME_Evolution_ImporterListener *servant;
GNOME_Evolution_ImporterListener corba_object;
- servant = create_servant ();
- if (servant == NULL)
- return NULL;
-
listener = gtk_type_new (evolution_importer_listener_get_type ());
- corba_object = bonobo_object_activate_servant (BONOBO_OBJECT (listener),
- servant);
evolution_importer_listener_construct (listener, corba_object,
callback, closure);
return listener;
}
+
+BONOBO_X_TYPE_FUNC_FULL (EvolutionImporterListener,
+ GNOME_Evolution_ImporterListener,
+ PARENT_TYPE, evolution_importer_listener);
diff --git a/shell/importer/evolution-importer-listener.h b/shell/importer/evolution-importer-listener.h
index 33c4617332..e61fdb3465 100644
--- a/shell/importer/evolution-importer-listener.h
+++ b/shell/importer/evolution-importer-listener.h
@@ -24,8 +24,8 @@
#ifndef EVOLUTION_IMPORTER_LISTENER_H
#define EVOLUTION_IMPORTER_LISTENER_H
-#include <bonobo/bonobo-object.h>
-
+#include <bonobo/bonobo-xobject.h>
+#include <importer/GNOME_Evolution_Importer.h>
#include "evolution-importer.h"
#ifdef __cplusplus
@@ -48,13 +48,15 @@ typedef void (* EvolutionImporterListenerCallback) (EvolutionImporterListener *l
gboolean more_items,
void *closure);
struct _EvolutionImporterListener {
- BonoboObject parent;
-
- EvolutionImporterListenerPrivate *private;
+ BonoboXObject parent;
+
+ EvolutionImporterListenerPrivate *priv;
};
struct _EvolutionImporterListenerClass {
- BonoboObjectClass parent_class;
+ BonoboXObjectClass parent_class;
+
+ POA_GNOME_Evolution_ImporterListener__epv epv;
};
GtkType evolution_importer_listener_get_type (void);
diff --git a/shell/importer/evolution-importer.c b/shell/importer/evolution-importer.c
index 85d2446a19..c48390c9e5 100644
--- a/shell/importer/evolution-importer.c
+++ b/shell/importer/evolution-importer.c
@@ -32,7 +32,7 @@
#include "evolution-importer.h"
-#define PARENT_TYPE BONOBO_OBJECT_TYPE
+#define PARENT_TYPE BONOBO_X_OBJECT_TYPE
static BonoboObjectClass *parent_class = NULL;
struct _EvolutionImporterPrivate {
@@ -45,28 +45,10 @@ struct _EvolutionImporterPrivate {
};
-static POA_GNOME_Evolution_Importer__vepv Importer_vepv;
-
-static POA_GNOME_Evolution_Importer *
-create_servant (void)
+static inline EvolutionImporter *
+evolution_importer_from_servant (PortableServer_Servant servant)
{
- POA_GNOME_Evolution_Importer *servant;
- CORBA_Environment ev;
-
- servant = (POA_GNOME_Evolution_Importer *) g_new0 (BonoboObjectServant, 1);
- servant->vepv = &Importer_vepv;
-
- CORBA_exception_init (&ev);
- POA_GNOME_Evolution_Importer__init ((PortableServer_Servant) servant, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_free (servant);
- CORBA_exception_free (&ev);
- return NULL;
- }
-
- CORBA_exception_free (&ev);
-
- return servant;
+ return EVOLUTION_IMPORTER (bonobo_object_from_servant (servant));
}
static CORBA_boolean
@@ -74,13 +56,11 @@ impl_GNOME_Evolution_Importer_supportFormat (PortableServer_Servant servant,
const CORBA_char *filename,
CORBA_Environment *ev)
{
- BonoboObject *bonobo_object;
EvolutionImporter *importer;
EvolutionImporterPrivate *priv;
- bonobo_object = bonobo_object_from_servant (servant);
- importer = EVOLUTION_IMPORTER (bonobo_object);
- priv = importer->private;
+ importer = evolution_importer_from_servant (servant);
+ priv = importer->priv;
if (priv->support_format_fn != NULL)
return (priv->support_format_fn) (importer, filename,
@@ -94,13 +74,11 @@ impl_GNOME_Evolution_Importer_loadFile (PortableServer_Servant servant,
const CORBA_char *filename,
CORBA_Environment *ev)
{
- BonoboObject *bonobo_object;
EvolutionImporter *importer;
EvolutionImporterPrivate *priv;
- bonobo_object = bonobo_object_from_servant (servant);
- importer = EVOLUTION_IMPORTER (bonobo_object);
- priv = importer->private;
+ importer = evolution_importer_from_servant (servant);
+ priv = importer->priv;
if (priv->load_file_fn != NULL)
return (priv->load_file_fn) (importer, filename, priv->closure);
@@ -113,13 +91,11 @@ impl_GNOME_Evolution_Importer_processItem (PortableServer_Servant servant,
GNOME_Evolution_ImporterListener listener,
CORBA_Environment *ev)
{
- BonoboObject *bonobo_object;
EvolutionImporter *importer;
EvolutionImporterPrivate *priv;
- bonobo_object = bonobo_object_from_servant (servant);
- importer = EVOLUTION_IMPORTER (bonobo_object);
- priv = importer->private;
+ importer = evolution_importer_from_servant (servant);
+ priv = importer->priv;
if (priv->process_item_fn != NULL)
(priv->process_item_fn) (importer, listener, priv->closure, ev);
@@ -132,14 +108,12 @@ static CORBA_char *
impl_GNOME_Evolution_Importer_getError (PortableServer_Servant servant,
CORBA_Environment *ev)
{
- BonoboObject *bonobo_object;
EvolutionImporter *importer;
EvolutionImporterPrivate *priv;
CORBA_char *out_str;
- bonobo_object = bonobo_object_from_servant (servant);
- importer = EVOLUTION_IMPORTER (bonobo_object);
- priv = importer->private;
+ importer = evolution_importer_from_servant (servant);
+ priv = importer->priv;
if (priv->get_error_fn != NULL) {
out_str = (priv->get_error_fn) (importer, priv->closure);
@@ -156,65 +130,47 @@ destroy (GtkObject *object)
EvolutionImporterPrivate *priv;
importer = EVOLUTION_IMPORTER (object);
- priv = importer->private;
+ priv = importer->priv;
if (priv == NULL)
return;
g_free (priv);
- importer->private = NULL;
+ importer->priv = NULL;
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
-corba_class_init (void)
-{
- POA_GNOME_Evolution_Importer__vepv *vepv;
- POA_GNOME_Evolution_Importer__epv *epv;
- PortableServer_ServantBase__epv *base_epv;
-
- base_epv = g_new0 (PortableServer_ServantBase__epv, 1);
-
- epv = g_new0 (POA_GNOME_Evolution_Importer__epv, 1);
- epv->supportFormat = impl_GNOME_Evolution_Importer_supportFormat;
- epv->loadFile = impl_GNOME_Evolution_Importer_loadFile;
- epv->processItem = impl_GNOME_Evolution_Importer_processItem;
- epv->getError = impl_GNOME_Evolution_Importer_getError;
-
- vepv = &Importer_vepv;
- vepv->_base_epv = base_epv;
- vepv->Bonobo_Unknown_epv = bonobo_object_get_epv ();
- vepv->GNOME_Evolution_Importer_epv = epv;
-}
-
-static void
-class_init (EvolutionImporterClass *klass)
+evolution_importer_class_init (EvolutionImporterClass *klass)
{
GtkObjectClass *object_class;
+ POA_GNOME_Evolution_Importer__epv *epv = &klass->epv;
object_class = GTK_OBJECT_CLASS (klass);
object_class->destroy = destroy;
parent_class = gtk_type_class (PARENT_TYPE);
- corba_class_init ();
+ epv->supportFormat = impl_GNOME_Evolution_Importer_supportFormat;
+ epv->loadFile = impl_GNOME_Evolution_Importer_loadFile;
+ epv->processItem = impl_GNOME_Evolution_Importer_processItem;
+ epv->getError = impl_GNOME_Evolution_Importer_getError;
}
static void
-init (EvolutionImporter *importer)
+evolution_importer_init (EvolutionImporter *importer)
{
EvolutionImporterPrivate *priv;
priv = g_new0 (EvolutionImporterPrivate, 1);
- importer->private = priv;
+ importer->priv = priv;
}
static void
evolution_importer_construct (EvolutionImporter *importer,
- GNOME_Evolution_Importer corba_object,
EvolutionImporterSupportFormatFn support_format_fn,
EvolutionImporterLoadFileFn load_file_fn,
EvolutionImporterProcessItemFn process_item_fn,
@@ -225,14 +181,11 @@ evolution_importer_construct (EvolutionImporter *importer,
g_return_if_fail (importer != NULL);
g_return_if_fail (EVOLUTION_IS_IMPORTER (importer));
- g_return_if_fail (corba_object != CORBA_OBJECT_NIL);
g_return_if_fail (support_format_fn != NULL);
g_return_if_fail (load_file_fn != NULL);
g_return_if_fail (process_item_fn != NULL);
- bonobo_object_construct (BONOBO_OBJECT (importer), corba_object);
-
- priv = importer->private;
+ priv = importer->priv;
priv->support_format_fn = support_format_fn;
priv->load_file_fn = load_file_fn;
priv->process_item_fn = process_item_fn;
@@ -262,21 +215,14 @@ evolution_importer_new (EvolutionImporterSupportFormatFn support_format_fn,
void *closure)
{
EvolutionImporter *importer;
- POA_GNOME_Evolution_Importer *servant;
- GNOME_Evolution_Importer corba_object;
-
- servant = create_servant ();
- if (servant == NULL)
- return NULL;
importer = gtk_type_new (evolution_importer_get_type ());
- corba_object = bonobo_object_activate_servant (BONOBO_OBJECT (importer),
- servant);
- evolution_importer_construct (importer, corba_object,
- support_format_fn, load_file_fn,
+ evolution_importer_construct (importer, support_format_fn, load_file_fn,
process_item_fn, get_error_fn, closure);
return importer;
}
-E_MAKE_TYPE (evolution_importer, "EvolutionImporter", EvolutionImporter,
- class_init, init, PARENT_TYPE);
+BONOBO_X_TYPE_FUNC_FULL (EvolutionImporter,
+ GNOME_Evolution_Importer,
+ PARENT_TYPE,
+ evolution_importer);
diff --git a/shell/importer/evolution-importer.h b/shell/importer/evolution-importer.h
index fa5c944c2c..a5f6e07e87 100644
--- a/shell/importer/evolution-importer.h
+++ b/shell/importer/evolution-importer.h
@@ -24,7 +24,8 @@
#ifndef EVOLUTION_IMPORTER_H
#define EVOLUTION_IMPORTER_H
-#include <bonobo/bonobo-object.h>
+#include <bonobo/bonobo-xobject.h>
+#include <importer/GNOME_Evolution_Importer.h>
#ifdef __cplusplus
extern "C" {
@@ -67,13 +68,15 @@ typedef enum {
} EvolutionImporterResult;
struct _EvolutionImporter {
- BonoboObject parent;
-
- EvolutionImporterPrivate *private;
+ BonoboXObject parent;
+
+ EvolutionImporterPrivate *priv;
};
struct _EvolutionImporterClass {
- BonoboObjectClass parent_class;
+ BonoboXObjectClass parent_class;
+
+ POA_GNOME_Evolution_Importer__epv epv;
};
GtkType evolution_importer_get_type (void);
diff --git a/shell/importer/evolution-intelligent-importer.c b/shell/importer/evolution-intelligent-importer.c
new file mode 100644
index 0000000000..0149d48f97
--- /dev/null
+++ b/shell/importer/evolution-intelligent-importer.c
@@ -0,0 +1,198 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* evolution-intelligent-importer.c
+ *
+ * Copyright (C) 2000, 2001 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
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * 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: Iain Holmes <iain@ximian.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <bonobo/bonobo-object.h>
+
+#include "GNOME_Evolution_Importer.h"
+#include "evolution-intelligent-importer.h"
+
+
+#define PARENT_TYPE BONOBO_X_OBJECT_TYPE
+static BonoboObjectClass *parent_class = NULL;
+
+struct _EvolutionIntelligentImporterPrivate {
+ EvolutionIntelligentImporterCanImportFn can_import_fn;
+ EvolutionIntelligentImporterImportDataFn import_data_fn;
+
+ char *importername;
+ char *message;
+ void *closure;
+};
+
+
+static inline EvolutionIntelligentImporter *
+evolution_intelligent_importer_from_servant (PortableServer_Servant servant)
+{
+ return EVOLUTION_INTELLIGENT_IMPORTER (bonobo_object_from_servant (servant));
+}
+
+static CORBA_char *
+impl_GNOME_Evolution_IntelligentImporter__get_importername (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ EvolutionIntelligentImporter *ii;
+
+ ii = evolution_intelligent_importer_from_servant (servant);
+
+ return CORBA_string_dup (ii->priv->importername ?
+ ii->priv->importername : "");
+}
+
+static CORBA_char *
+impl_GNOME_Evolution_IntelligentImporter__get_message (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ EvolutionIntelligentImporter *ii;
+
+ ii = evolution_intelligent_importer_from_servant (servant);
+
+ return CORBA_string_dup (ii->priv->message ?
+ ii->priv->message : "");
+}
+
+static CORBA_boolean
+impl_GNOME_Evolution_IntelligentImporter_canImport (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ EvolutionIntelligentImporter *ii;
+ EvolutionIntelligentImporterPrivate *priv;
+
+ ii = evolution_intelligent_importer_from_servant (servant);
+ priv = ii->priv;
+
+ if (priv->can_import_fn != NULL)
+ return (priv->can_import_fn) (ii, priv->closure);
+ else
+ return FALSE;
+}
+
+static void
+impl_GNOME_Evolution_IntelligentImporter_importData (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ EvolutionIntelligentImporter *ii;
+ EvolutionIntelligentImporterPrivate *priv;
+
+ ii = evolution_intelligent_importer_from_servant (servant);
+ priv = ii->priv;
+
+ if (priv->import_data_fn)
+ (priv->import_data_fn) (ii, priv->closure);
+}
+
+
+static void
+destroy (GtkObject *object)
+{
+ EvolutionIntelligentImporter *ii;
+
+ ii = EVOLUTION_INTELLIGENT_IMPORTER (object);
+
+ if (ii->priv == NULL)
+ return;
+
+ g_free (ii->priv->importername);
+ g_free (ii->priv);
+ ii->priv = NULL;
+
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
+}
+
+static void
+evolution_intelligent_importer_class_init (EvolutionIntelligentImporterClass *klass)
+{
+ GtkObjectClass *object_class;
+ POA_GNOME_Evolution_IntelligentImporter__epv *epv = &klass->epv;
+
+ object_class = GTK_OBJECT_CLASS (klass);
+ object_class->destroy = destroy;
+
+ parent_class = gtk_type_class (PARENT_TYPE);
+ epv->_get_importername = impl_GNOME_Evolution_IntelligentImporter__get_importername;
+ epv->_get_message = impl_GNOME_Evolution_IntelligentImporter__get_message;
+ epv->canImport = impl_GNOME_Evolution_IntelligentImporter_canImport;
+ epv->importData = impl_GNOME_Evolution_IntelligentImporter_importData;
+}
+
+static void
+evolution_intelligent_importer_init (EvolutionIntelligentImporter *ii)
+{
+ ii->priv = g_new0 (EvolutionIntelligentImporterPrivate, 1);
+}
+
+
+static void
+evolution_intelligent_importer_construct (EvolutionIntelligentImporter *ii,
+ EvolutionIntelligentImporterCanImportFn can_import_fn,
+ EvolutionIntelligentImporterImportDataFn import_data_fn,
+ const char *importername,
+ const char *message,
+ void *closure)
+{
+ g_return_if_fail (ii != NULL);
+ ii->priv->importername = g_strdup (importername);
+ ii->priv->message = g_strdup (message);
+
+ ii->priv->can_import_fn = can_import_fn;
+ ii->priv->import_data_fn = import_data_fn;
+ ii->priv->closure = closure;
+}
+
+/**
+ * evolution_intelligent_importer_new:
+ * can_import_fn: The function that will be called to see if this importer can do
+ * anything.
+ * import_data_fn: The function that will be called when the importer should
+ * import the data.
+ * importername: The name of this importer.
+ * message: The message that will be displayed when the importer can import.
+ * closure: The data to be passed to @can_import_fn and @import_data_fn.
+ *
+ * Creates a new IntelligentImporter.
+ *
+ * Returns: A newly allocated EvolutionIntelligentImporter.
+ */
+EvolutionIntelligentImporter *
+evolution_intelligent_importer_new (EvolutionIntelligentImporterCanImportFn can_import_fn,
+ EvolutionIntelligentImporterImportDataFn import_data_fn,
+ const char *importername,
+ const char *message,
+ void *closure)
+{
+ EvolutionIntelligentImporter *ii;
+
+ ii = gtk_type_new (evolution_intelligent_importer_get_type ());
+ evolution_intelligent_importer_construct (ii, can_import_fn,
+ import_data_fn, importername,
+ message, closure);
+ return ii;
+}
+
+BONOBO_X_TYPE_FUNC_FULL (EvolutionIntelligentImporter,
+ GNOME_Evolution_IntelligentImporter,
+ PARENT_TYPE,
+ evolution_intelligent_importer);
diff --git a/shell/importer/evolution-intelligent-importer.h b/shell/importer/evolution-intelligent-importer.h
new file mode 100644
index 0000000000..1714a2a046
--- /dev/null
+++ b/shell/importer/evolution-intelligent-importer.h
@@ -0,0 +1,74 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* evolution-intelligent-importer.h
+ *
+ * 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
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * 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: Iain Holmes <iain@ximian.com>
+ */
+
+#ifndef EVOLUTION_INTELLIGENT_IMPORTER_H
+#define EVOLUTION_INTELLIGENT_IMPORTER_H
+
+#include <bonobo/bonobo-xobject.h>
+#include <importer/GNOME_Evolution_Importer.h>
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+#define EVOLUTION_TYPE_INTELLIGENT_IMPORTER (evolution_intelligent_importer_get_type ())
+#define EVOLUTION_INTELLIGENT_IMPORTER(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_TYPE_INTELLIGENT_IMPORTER, EvolutionIntelligentImporter))
+#define EVOLUTION_INTELLIGENT_IMPORTER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_INTELLIGENT_IMPORTER, EvolutionIntelligentImporterClass))
+#define EVOLUTION_IS_INTELLIGENT_IMPORTER(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_TYPE_INTELLIGENT_IMPORTER))
+#define EVOLUTION_IS_INTELLIGENT_IMPORTER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_INTELLIGENT_IMPORTER))
+
+typedef struct _EvolutionIntelligentImporter EvolutionIntelligentImporter;
+typedef struct _EvolutionIntelligentImporterPrivate EvolutionIntelligentImporterPrivate;
+typedef struct _EvolutionIntelligentImporterClass EvolutionIntelligentImporterClass;
+
+typedef gboolean (* EvolutionIntelligentImporterCanImportFn) (EvolutionIntelligentImporter *ii,
+ void *closure);
+typedef void (* EvolutionIntelligentImporterImportDataFn) (EvolutionIntelligentImporter *ii,
+ void *closure);
+
+struct _EvolutionIntelligentImporter {
+ BonoboXObject parent;
+
+ EvolutionIntelligentImporterPrivate *priv;
+};
+
+struct _EvolutionIntelligentImporterClass {
+ BonoboXObjectClass parent_class;
+
+ POA_GNOME_Evolution_IntelligentImporter__epv epv;
+};
+
+GtkType evolution_intelligent_importer_get_type (void);
+
+EvolutionIntelligentImporter *evolution_intelligent_importer_new (EvolutionIntelligentImporterCanImportFn can_import_fn,
+ EvolutionIntelligentImporterImportDataFn import_data_fn,
+ const char *importername,
+ const char *message,
+ void *closure);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/shell/importer/intelligent.c b/shell/importer/intelligent.c
new file mode 100644
index 0000000000..e3f0f4b03b
--- /dev/null
+++ b/shell/importer/intelligent.c
@@ -0,0 +1,174 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* intelligent.c
+ *
+ * Authors:
+ * Iain Holmes <iain@ximian.com>
+ *
+ * Copyright 2001 Ximian, Inc. (http://www.ximian.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * 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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gnome.h>
+
+#include <liboaf/liboaf.h>
+
+#include "intelligent.h"
+#include "GNOME_Evolution_Importer.h"
+
+static void
+start_importer (const char *iid)
+{
+ CORBA_Object importer;
+ CORBA_Environment ev;
+ CORBA_char *name;
+ CORBA_char *message;
+ CORBA_boolean can_run;
+
+ GtkWidget *dialog, *label;
+ char *str;
+
+ if (iid == NULL || *iid == '\0')
+ return;
+
+ CORBA_exception_init (&ev);
+ importer = oaf_activate_from_id ((char *) iid, 0, NULL, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ CORBA_exception_free (&ev);
+ g_warning ("Could not start %s", iid);
+ return;
+ }
+
+ CORBA_exception_free (&ev);
+ if (importer == CORBA_OBJECT_NIL) {
+ g_warning ("Could not activate_component %s", iid);
+ return;
+ }
+
+ CORBA_exception_init (&ev);
+ can_run = GNOME_Evolution_IntelligentImporter_canImport (importer, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("Could not get canImport(%s): %s", iid, CORBA_exception_id (&ev));
+ CORBA_Object_release (importer, &ev);
+ CORBA_exception_free (&ev);
+ return;
+ }
+ CORBA_exception_free (&ev);
+
+ if (can_run == FALSE) {
+ return;
+ }
+
+ name = GNOME_Evolution_IntelligentImporter__get_importername (importer,
+ &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("Could not get name(%s): %s", iid, CORBA_exception_id (&ev));
+ CORBA_Object_release (importer, &ev);
+ CORBA_exception_free (&ev);
+ return;
+ }
+ message = GNOME_Evolution_IntelligentImporter__get_message (importer, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("Could not get message(%s): %s", iid, CORBA_exception_id (&ev));
+ CORBA_Object_release (importer, &ev);
+ CORBA_exception_free (&ev);
+ return;
+ }
+
+ CORBA_exception_free (&ev);
+
+ dialog = gnome_dialog_new ("Import files",
+ GNOME_STOCK_BUTTON_YES, GNOME_STOCK_BUTTON_NO,
+ NULL);
+ gtk_window_set_title (GTK_WINDOW (dialog), name);
+ CORBA_free (name);
+
+ label = gtk_label_new (message);
+ CORBA_free (message);
+
+ gtk_box_pack_start (GNOME_DIALOG (dialog)->vbox, label, FALSE, FALSE, 0);
+ gtk_widget_show (label);
+ switch (gnome_dialog_run_and_close (GNOME_DIALOG (dialog))) {
+ case 0:
+ /* Yes */
+#if 0
+ /* This sucks */
+ dialog = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ label = gtk_label_new ("Importing");
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+ gtk_container_add (GTK_CONTAINER (dialog), label);
+ gtk_widget_show_all (dialog);
+#endif
+
+ GNOME_Evolution_IntelligentImporter_importData (importer, &ev);
+ break;
+ case 1:
+ case -1:
+ default:
+ /* No */
+ break;
+ }
+
+ CORBA_exception_init (&ev);
+ CORBA_Object_release (importer, &ev);
+ CORBA_exception_free (&ev);
+}
+
+
+static GList *
+get_intelligent_importers (void)
+{
+ OAF_ServerInfoList *info_list;
+ GList *iids_ret = NULL;
+ CORBA_Environment ev;
+ int i;
+
+ CORBA_exception_init (&ev);
+ info_list = oaf_query ("repo_ids.has ('IDL:GNOME/Evolution/IntelligentImporter:1.0')", NULL, &ev);
+ CORBA_exception_free (&ev);
+
+ for (i = 0; i < info_list->_length; i++) {
+ const OAF_ServerInfo *info;
+
+ info = info_list->_buffer + i;
+ iids_ret = g_list_prepend (iids_ret, g_strdup (info->iid));
+ }
+
+ return iids_ret;
+}
+
+void
+intelligent_importer_init (void)
+{
+ GList *importers, *l;
+
+ importers = get_intelligent_importers ();
+ if (importers == NULL)
+ return; /* No intelligent importers. Easy :) */
+
+ /* Loop through each importer, running it. */
+ for (l = importers; l; l = l->next) {
+ start_importer (l->data);
+ g_free (l->data);
+ }
+
+ g_list_free (importers);
+}
+
diff --git a/shell/importer/intelligent.h b/shell/importer/intelligent.h
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/shell/importer/intelligent.h