aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/backend/ebook/evolution-ldif-importer.c
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/backend/ebook/evolution-ldif-importer.c')
-rw-r--r--addressbook/backend/ebook/evolution-ldif-importer.c93
1 files changed, 61 insertions, 32 deletions
diff --git a/addressbook/backend/ebook/evolution-ldif-importer.c b/addressbook/backend/ebook/evolution-ldif-importer.c
index 6f4a3ac957..5602f3fb18 100644
--- a/addressbook/backend/ebook/evolution-ldif-importer.c
+++ b/addressbook/backend/ebook/evolution-ldif-importer.c
@@ -13,22 +13,22 @@
*/
#include <config.h>
+#include <bonobo.h>
+#include <gnome.h>
+#include <liboaf/liboaf.h>
#include <stdio.h>
#include <ctype.h>
-#include <string.h>
#include <e-book.h>
#include <e-card-simple.h>
#include <e-destination.h>
-#include <libgnome/gnome-init.h>
-#include <bonobo/bonobo-generic-factory.h>
-
#include <importer/evolution-importer.h>
#include <importer/GNOME_Evolution_Importer.h>
#define COMPONENT_FACTORY_IID "OAFIID:GNOME_Evolution_Addressbook_LDIF_ImporterFactory"
-#define COMPONENT_IID "OAFIID:GNOME_Evolution_Addressbook_LDIF_Importer"
+
+static BonoboGenericFactory *factory = NULL;
static GHashTable *dn_card_hash;
@@ -269,9 +269,9 @@ parseLine( ECardSimple *simple, ECardDeliveryAddress *address, char **buf )
}
else if (!g_strcasecmp (ptr, "member")) {
EList *email;
- g_object_get (simple->card,
- "email", &email,
- NULL);
+ gtk_object_get (GTK_OBJECT (simple->card),
+ "email", &email,
+ NULL);
e_list_append (email, ldif_value->str);
}
}
@@ -326,7 +326,7 @@ getNextLDIFEntry( FILE *f )
while (buf) {
if (!parseLine (simple, address, &buf)) {
/* parsing error */
- g_object_unref (simple);
+ gtk_object_unref (GTK_OBJECT (simple));
e_card_delivery_address_unref (address);
return NULL;
}
@@ -374,17 +374,17 @@ resolve_list_card (LDIFImporter *gci, ECard *card)
if (!e_card_evolution_list (card))
return;
- g_object_get (card,
- "email", &email,
- "full_name", &full_name,
- NULL);
+ gtk_object_get (GTK_OBJECT (card),
+ "email", &email,
+ "full_name", &full_name,
+ NULL);
/* set file_as to full_name so we don't later try and figure
out a first/last name for the list. */
if (full_name)
- g_object_set (card,
- "file_as", full_name,
- NULL);
+ gtk_object_set (GTK_OBJECT (card),
+ "file_as", full_name,
+ NULL);
email_iter = e_list_get_iterator (email);
while (e_iterator_is_valid (email_iter)) {
@@ -397,7 +397,7 @@ resolve_list_card (LDIFImporter *gci, ECard *card)
gchar *dest_xml;
e_destination_set_card (dest, dn_card, 0); /* Hard-wired for default e-mail, since netscape only exports 1 email address */
dest_xml = e_destination_export (dest);
- g_object_unref (dest);
+ gtk_object_unref (GTK_OBJECT (dest));
if (dest_xml) {
e_iterator_set (email_iter, dest_xml);
g_free (dest_xml);
@@ -549,10 +549,10 @@ support_format_fn (EvolutionImporter *importer,
}
static void
-importer_destroy_cb (gpointer data,
- GObject *where_object_was)
+importer_destroy_cb (GtkObject *object,
+ LDIFImporter *gci)
{
- bonobo_main_quit ();
+ gtk_main_quit ();
}
static gboolean
@@ -575,26 +575,55 @@ load_file_fn (EvolutionImporter *importer,
static BonoboObject *
factory_fn (BonoboGenericFactory *_factory,
- const char *component_id,
void *closure)
{
EvolutionImporter *importer;
LDIFImporter *gci;
- if (!strcmp (component_id, COMPONENT_IID)) {
- gci = g_new (LDIFImporter, 1);
- importer = evolution_importer_new (support_format_fn, load_file_fn,
- process_item_fn, NULL, gci);
+ gci = g_new (LDIFImporter, 1);
+ importer = evolution_importer_new (support_format_fn, load_file_fn,
+ process_item_fn, NULL, gci);
- g_object_weak_ref (G_OBJECT (importer),
- importer_destroy_cb, gci);
+ gtk_signal_connect (GTK_OBJECT (importer), "destroy",
+ GTK_SIGNAL_FUNC (importer_destroy_cb), gci);
- return BONOBO_OBJECT (importer);
+ return BONOBO_OBJECT (importer);
+}
+
+static void
+importer_init (void)
+{
+ if (factory != NULL)
+ return;
+
+ factory = bonobo_generic_factory_new (COMPONENT_FACTORY_IID,
+ factory_fn, NULL);
+
+ if (factory == NULL) {
+ g_error ("Unable to create factory");
}
- else {
- g_warning (COMPONENT_FACTORY_IID, ": Don't know what to do with %s", component_id);
- return NULL;
+
+ bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory));
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ CORBA_ORB orb;
+
+ gnome_init_with_popt_table ("Evolution-LDIF-Importer",
+ "0.0", argc, argv, oaf_popt_options, 0,
+ NULL);
+ orb = oaf_init (argc, argv);
+ if (bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) {
+ g_error ("Could not initialize Bonobo.");
}
+
+ importer_init ();
+ bonobo_main ();
+
+ return 0;
}
-BONOBO_ACTIVATION_FACTORY (COMPONENT_FACTORY_IID, "Evolution LDIF Importer Factory", VERSION, factory_fn, NULL);
+