aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/importers
diff options
context:
space:
mode:
authornobody <nobody@localhost>2003-12-09 09:57:09 +0800
committernobody <nobody@localhost>2003-12-09 09:57:09 +0800
commit4ef7d31cb740e45d402fa986aea2449fc1e1ed02 (patch)
tree75bb0caf9afd4b94842023406d6a7938c5d8b2b7 /calendar/importers
parent0031a7166cd0f3fc0cec0b60c468ca22a8c45b0b (diff)
downloadgsoc2013-evolution-LIBGLADE_2_4_0.tar.gz
gsoc2013-evolution-LIBGLADE_2_4_0.tar.zst
gsoc2013-evolution-LIBGLADE_2_4_0.zip
This commit was manufactured by cvs2svn to create tagLIBGLADE_2_4_0
'LIBGLADE_2_4_0'. svn path=/tags/LIBGLADE_2_4_0/; revision=23842
Diffstat (limited to 'calendar/importers')
-rw-r--r--calendar/importers/.cvsignore6
-rw-r--r--calendar/importers/GNOME_Evolution_Calendar_Importer.server.in.in54
-rw-r--r--calendar/importers/Makefile.am53
-rw-r--r--calendar/importers/evolution-calendar-importer.h37
-rw-r--r--calendar/importers/icalendar-importer.c753
-rw-r--r--calendar/importers/main.c56
6 files changed, 0 insertions, 959 deletions
diff --git a/calendar/importers/.cvsignore b/calendar/importers/.cvsignore
deleted file mode 100644
index 99d6030704..0000000000
--- a/calendar/importers/.cvsignore
+++ /dev/null
@@ -1,6 +0,0 @@
-.deps
-.libs
-Makefile
-Makefile.in
-evolution-calendar-importer
-GNOME_Evolution_Calendar_Importer*.server
diff --git a/calendar/importers/GNOME_Evolution_Calendar_Importer.server.in.in b/calendar/importers/GNOME_Evolution_Calendar_Importer.server.in.in
deleted file mode 100644
index 810905fbfa..0000000000
--- a/calendar/importers/GNOME_Evolution_Calendar_Importer.server.in.in
+++ /dev/null
@@ -1,54 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Calendar_ImporterFactory:@VERSION@"
- type="shlib"
- location="@IMPORTERSDIR@/libevolution-calendar-importers.so">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/ObjectFactory:1.0"/>
- </oaf_attribute>
- <oaf_attribute name="name" type="string"
- _value="Evolution iCalendar importer"/>
-</oaf_server>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Calendar_iCalendar_Importer:@VERSION@"
- type="factory"
- location="OAFIID:GNOME_Evolution_Calendar_ImporterFactory:@VERSION@">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/Importer:@VERSION@"/>
- </oaf_attribute>
- <oaf_attribute name="evolution:menu_name" type="string"
- _value="iCalendar files (.ics)"/>
- <oaf_attribute name="name" type="string"
- _value="Evolution iCalendar importer"/>
-
-</oaf_server>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Calendar_vCalendar_Importer:@VERSION@"
- type="factory"
- location="OAFIID:GNOME_Evolution_Calendar_ImporterFactory:@VERSION@">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/Importer:@VERSION@"/>
- </oaf_attribute>
- <oaf_attribute name="evolution:menu_name" type="string"
- _value="vCalendar files (.vcf)"/>
- <oaf_attribute name="name" type="string"
- _value="Evolution vCalendar importer"/>
-
-</oaf_server>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Gnome_Calendar_Intelligent_Importer:@VERSION@"
- type="factory"
- location="OAFIID:GNOME_Evolution_Calendar_ImporterFactory:@VERSION@">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/IntelligentImporter:@VERSION@"/>
- </oaf_attribute>
-
- <oaf_attribute name="name" type="string"
- _value="Evolution Calendar intelligent importer"/>
-
-</oaf_server>
-</oaf_info>
diff --git a/calendar/importers/Makefile.am b/calendar/importers/Makefile.am
deleted file mode 100644
index a36c7ef4a6..0000000000
--- a/calendar/importers/Makefile.am
+++ /dev/null
@@ -1,53 +0,0 @@
-importersdir = $(privlibdir)/evolution-calendar-importers
-
-importers_LTLIBRARIES = libevolution-calendar-importers.la
-
-# privlibexec_PROGRAMS = evolution-calendar-importer
-
-INCLUDES = \
- -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \
- -DEVOLUTION_SOUNDDIR=\""$(soundsdir)"\" \
- -DG_LOG_DOMAIN=\"Evolution-Importer\" \
- -I$(top_srcdir) \
- -I$(top_builddir)/shell \
- -I$(top_srcdir)/shell \
- -I$(top_srcdir)/calendar \
- -I$(top_builddir)/calendar \
- $(EVOLUTION_CALENDAR_CFLAGS)
-
-libevolution_calendar_importers_la_SOURCES = \
- evolution-calendar-importer.h \
- icalendar-importer.c \
- main.c
-
-libevolution_calendar_importers_la_LDFLAGS = -avoid-version -module
-
-libevolution_calendar_importers_la_LIBADD = \
- $(top_builddir)/shell/importer/libevolution-importer.la \
- $(IMPORTERS_LIBS)
-
-# evolution_calendar_importer_SOURCES = \
-# evolution-calendar-importer.h \
-# icalendar-importer.c \
-# main.c
-#
-# evolution_calendar_importer_LDADD = \
-# $(top_builddir)/shell/libeshell.la \
-# $(top_builddir)/shell/importer/libevolution-importer.la \
-# $(top_builddir)/calendar/cal-util/libcal-util.la \
-# $(top_builddir)/calendar/cal-client/libcal-client.la \
-# $(top_builddir)/libwombat/libwombat.la \
-# $(EVOLUTION_CALENDAR_LIBS)
-
-server_in_files = GNOME_Evolution_Calendar_Importer.server.in.in
-server_DATA = $(server_in_files:.server.in.in=_$(BASE_VERSION).server)
-@EVO_SERVER_RULE@
-@INTLTOOL_SERVER_RULE@
-
-BUILT_SOURCES = $(server_DATA)
-CLEANFILES = $(BUILT_SOURCES)
-
-EXTRA_DIST = $(server_in_files)
-
-dist-hook:
- cd $(distdir); rm -f $(BUILT_SOURCES) \ No newline at end of file
diff --git a/calendar/importers/evolution-calendar-importer.h b/calendar/importers/evolution-calendar-importer.h
deleted file mode 100644
index 0691ee2cab..0000000000
--- a/calendar/importers/evolution-calendar-importer.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* Evolution calendar importer component
- *
- * Authors: Rodrigo Moya <rodrigo@ximian.com>
- *
- * Copyright (C) 2001 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.
- */
-
-#ifndef EVOLUTION_CALENDAR_IMPORTER_H
-#define EVOLUTION_CALENDAR_IMPORTER_H
-
-#include <bonobo/bonobo-object.h>
-
-G_BEGIN_DECLS
-
-BonoboObject *ical_importer_new (void);
-BonoboObject *vcal_importer_new (void);
-
-BonoboObject *gnome_calendar_importer_new (void);
-
-G_END_DECLS
-
-#endif
diff --git a/calendar/importers/icalendar-importer.c b/calendar/importers/icalendar-importer.c
deleted file mode 100644
index ae9a5c9b21..0000000000
--- a/calendar/importers/icalendar-importer.c
+++ /dev/null
@@ -1,753 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* Evolution calendar importer component
- *
- * Authors: Rodrigo Moya <rodrigo@ximian.com>
- *
- * Copyright (C) 2001 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.
- */
-
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkcheckbutton.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkmain.h>
-#include <libgnome/gnome-util.h>
-#include <libgnome/gnome-i18n.h>
-#include <bonobo/bonobo-control.h>
-#include <bonobo/bonobo-exception.h>
-#include <libecal/e-cal.h>
-#include <importer/evolution-importer.h>
-#include <importer/evolution-intelligent-importer.h>
-#include <importer/GNOME_Evolution_Importer.h>
-#include <libical/icalvcal.h>
-#include "evolution-calendar-importer.h"
-
-/* We timeout after 2 minutes, when opening the folders. */
-#define IMPORTER_TIMEOUT_SECONDS 120
-
-
-typedef struct {
- ECal *client;
- ECal *tasks_client;
- EvolutionImporter *importer;
- icalcomponent *icalcomp;
- gboolean folder_contains_events;
- gboolean folder_contains_tasks;
-} ICalImporter;
-
-typedef struct {
- gboolean do_calendar;
- gboolean do_tasks;
-} ICalIntelligentImporter;
-
-/*
- * Functions shared by iCalendar & vCalendar importer.
- */
-
-static void
-importer_destroy_cb (gpointer user_data)
-{
- ICalImporter *ici = (ICalImporter *) user_data;
-
- g_return_if_fail (ici != NULL);
-
- g_object_unref (ici->client);
- g_object_unref (ici->tasks_client);
-
- if (ici->icalcomp != NULL) {
- icalcomponent_free (ici->icalcomp);
- ici->icalcomp = NULL;
- }
-
- g_free (ici);
-}
-
-/* This reads in an entire file and returns it. It returns NULL on error.
- The returned string should be freed. */
-static char*
-read_file (const char *filename)
-{
- int fd, n;
- GString *str;
- char buffer[2049];
- gboolean error = FALSE;
-
- /* read file contents */
- fd = open (filename, O_RDONLY);
- if (fd == -1)
- return NULL;
-
- str = g_string_new ("");
- while (1) {
- memset (buffer, 0, sizeof(buffer));
- n = read (fd, buffer, sizeof (buffer) - 1);
- if (n > 0) {
- str = g_string_append (str, buffer);
- } else if (n == 0) {
- break;
- } else {
- error = TRUE;
- break;
- }
- }
-
- close (fd);
-
- if (error) {
- g_string_free (str, FALSE);
- return NULL;
- } else {
- gchar *retval = str->str;
- g_string_free (str, FALSE);
- return retval;
- }
-}
-
-/* This removes all components except VEVENTs and VTIMEZONEs from the toplevel
- icalcomponent, and returns a GList of the VTODO components. */
-static GList*
-prepare_events (icalcomponent *icalcomp)
-{
- icalcomponent *subcomp;
- GList *vtodos = NULL;
- icalcompiter iter;
-
- iter = icalcomponent_begin_component (icalcomp, ICAL_ANY_COMPONENT);
- while ((subcomp = icalcompiter_deref (&iter)) != NULL) {
- icalcomponent_kind child_kind = icalcomponent_isa (subcomp);
- if (child_kind != ICAL_VEVENT_COMPONENT
- && child_kind != ICAL_VTIMEZONE_COMPONENT) {
-
- icalcompiter_next (&iter);
-
- icalcomponent_remove_component (icalcomp, subcomp);
- if (child_kind == ICAL_VTODO_COMPONENT)
- vtodos = g_list_prepend (vtodos, subcomp);
- else
- icalcomponent_free (subcomp);
-
- continue;
- }
-
- icalcompiter_next (&iter);
- }
-
- return vtodos;
-}
-
-
-/* This removes all components except VTODOs and VTIMEZONEs from the toplevel
- icalcomponent, and adds the given list of VTODO components. The list is
- freed afterwards. */
-static void
-prepare_tasks (icalcomponent *icalcomp, GList *vtodos)
-{
- icalcomponent *subcomp;
- GList *elem;
- icalcompiter iter;
-
- iter = icalcomponent_begin_component (icalcomp, ICAL_ANY_COMPONENT);
- while ((subcomp = icalcompiter_deref (&iter)) != NULL) {
- icalcomponent_kind child_kind = icalcomponent_isa (subcomp);
- if (child_kind != ICAL_VTODO_COMPONENT
- && child_kind != ICAL_VTIMEZONE_COMPONENT) {
- icalcompiter_next (&iter);
- icalcomponent_remove_component (icalcomp, subcomp);
- icalcomponent_free (subcomp);
-
- continue;
- }
-
- icalcompiter_next (&iter);
- }
-
- for (elem = vtodos; elem; elem = elem->next) {
- icalcomponent_add_component (icalcomp, elem->data);
- }
- g_list_free (vtodos);
-}
-
-static gboolean
-update_single_object (ECal *client, icalcomponent *icalcomp)
-{
- char *uid;
- icalcomponent *tmp_icalcomp;
-
- uid = (char *) icalcomponent_get_uid (icalcomp);
-
- if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL))
- return e_cal_modify_object (client, icalcomp, CALOBJ_MOD_ALL, NULL);
-
- return e_cal_create_object (client, icalcomp, &uid, NULL);
-}
-
-static gboolean
-update_objects (ECal *client, icalcomponent *icalcomp)
-{
- icalcomponent *subcomp;
- icalcomponent_kind kind;
-
- kind = icalcomponent_isa (icalcomp);
- if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT)
- return update_single_object (client, icalcomp);
- else if (kind != ICAL_VCALENDAR_COMPONENT)
- return FALSE;
-
- subcomp = icalcomponent_get_first_component (icalcomp, ICAL_ANY_COMPONENT);
- while (subcomp) {
- gboolean success;
-
- kind = icalcomponent_isa (subcomp);
- if (kind == ICAL_VTIMEZONE_COMPONENT) {
- icaltimezone *zone;
-
- zone = icaltimezone_new ();
- icaltimezone_set_component (zone, subcomp);
-
- success = e_cal_add_timezone (client, zone, NULL);
- icaltimezone_free (zone, 1);
- if (!success)
- return success;
- } else if (kind == ICAL_VTODO_COMPONENT ||
- kind == ICAL_VEVENT_COMPONENT) {
- success = update_single_object (client, subcomp);
- if (!success)
- return success;
- }
-
- subcomp = icalcomponent_get_next_component (icalcomp, ICAL_ANY_COMPONENT);
- }
-
- return TRUE;
-}
-
-static void
-process_item_fn (EvolutionImporter *importer,
- CORBA_Object listener,
- void *closure,
- CORBA_Environment *ev)
-{
- ECalLoadState state, tasks_state;
- ICalImporter *ici = (ICalImporter *) closure;
- GNOME_Evolution_ImporterListener_ImporterResult result;
-
- result = GNOME_Evolution_ImporterListener_OK;
-
- g_return_if_fail (ici != NULL);
- g_return_if_fail (E_IS_CAL (ici->client));
- g_return_if_fail (ici->icalcomp != NULL);
-
- state = e_cal_get_load_state (ici->client);
- tasks_state = e_cal_get_load_state (ici->tasks_client);
- if (state == E_CAL_LOAD_LOADING
- || tasks_state == E_CAL_LOAD_LOADING) {
- GNOME_Evolution_ImporterListener_notifyResult (
- listener,
- GNOME_Evolution_ImporterListener_BUSY,
- TRUE, ev);
- return;
- } else if (state != E_CAL_LOAD_LOADED
- || tasks_state != E_CAL_LOAD_LOADED) {
- GNOME_Evolution_ImporterListener_notifyResult (
- listener,
- GNOME_Evolution_ImporterListener_UNSUPPORTED_OPERATION,
- FALSE, ev);
- return;
- }
-
- /* If the folder contains events & tasks we can just import everything
- into it. If it contains just events, we have to strip out the
- VTODOs and import them into the default tasks folder. If the folder
- contains just tasks, we strip out the VEVENTs, which do not get
- imported at all. */
- if (ici->folder_contains_events && ici->folder_contains_tasks) {
- if (!update_objects (ici->client, ici->icalcomp))
- result = GNOME_Evolution_ImporterListener_BAD_DATA;
- } else if (ici->folder_contains_events) {
- GList *vtodos = prepare_events (ici->icalcomp);
- if (!update_objects (ici->client, ici->icalcomp))
- result = GNOME_Evolution_ImporterListener_BAD_DATA;
-
- prepare_tasks (ici->icalcomp, vtodos);
- if (!update_objects (ici->tasks_client, ici->icalcomp))
- result = GNOME_Evolution_ImporterListener_BAD_DATA;
- } else {
- prepare_tasks (ici->icalcomp, NULL);
- if (!update_objects (ici->client, ici->icalcomp))
- result = GNOME_Evolution_ImporterListener_BAD_DATA;
- }
-
- GNOME_Evolution_ImporterListener_notifyResult (listener, result, FALSE,
- ev);
-}
-
-
-/*
- * iCalendar importer functions.
- */
-
-static gboolean
-support_format_fn (EvolutionImporter *importer,
- const char *filename,
- void *closure)
-{
- char *contents;
- icalcomponent *icalcomp;
- gboolean ret = FALSE;
-
- contents = read_file (filename);
-
- /* parse the file */
- if (contents) {
- icalcomp = icalparser_parse_string (contents);
- if (icalcomp) {
- if (icalcomponent_is_valid (icalcomp))
- ret = TRUE;
- else
- ret = FALSE;
- icalcomponent_free (icalcomp);
- }
- }
-
- g_free (contents);
-
- return ret;
-}
-
-static gboolean
-load_file_fn (EvolutionImporter *importer,
- const char *filename,
- const char *physical_uri,
- const char *folder_type,
- void *closure)
-{
- char *contents, *f;
- gboolean ret = FALSE;
- ICalImporter *ici = (ICalImporter *) closure;
-
- g_return_val_if_fail (ici != NULL, FALSE);
-
- contents = read_file (filename);
-
- if (!strcmp (folder_type, "calendar")) {
- ici->folder_contains_events = TRUE;
- ici->folder_contains_tasks = FALSE;
-
- f = g_strdup ("calendar.ics");
- } else {
- ici->folder_contains_events = FALSE;
- ici->folder_contains_tasks = TRUE;
-
- f = g_strdup ("tasks.ics");
- }
-
- /* parse the file */
- if (contents) {
- icalcomponent *icalcomp;
-
- icalcomp = icalparser_parse_string (contents);
- if (icalcomp) {
- char *real_uri;
-
- if (!g_strncasecmp (physical_uri, "file", 4) &&
- g_strcasecmp (physical_uri + (strlen (physical_uri) - strlen (f)), f)) {
- real_uri = g_concat_dir_and_file (physical_uri, f);
- } else
- real_uri = g_strdup (physical_uri);
-
- /* create ECal's */
- if (!ici->client)
- ici->client = e_cal_new_from_uri (real_uri, CALOBJ_TYPE_EVENT);
- if (!ici->tasks_client)
- ici->tasks_client = e_cal_new_from_uri ("", CALOBJ_TYPE_TODO); /* FIXME */
-
- if (e_cal_open (ici->client, TRUE, NULL)
- && e_cal_open (ici->tasks_client, FALSE, NULL)) {
- ici->icalcomp = icalcomp;
- ret = TRUE;
- }
-
- g_free (real_uri);
- }
- }
-
- g_free (contents);
- g_free (f);
-
- return ret;
-}
-
-BonoboObject *
-ical_importer_new (void)
-{
- ICalImporter *ici;
-
- ici = g_new0 (ICalImporter, 1);
- ici->client = NULL;
- ici->tasks_client = NULL;
- ici->icalcomp = NULL;
- ici->importer = evolution_importer_new (support_format_fn,
- load_file_fn,
- process_item_fn,
- NULL,
- ici);
-
- g_object_weak_ref (G_OBJECT (ici->importer), (GWeakNotify) importer_destroy_cb, ici);
-
- return BONOBO_OBJECT (ici->importer);
-}
-
-
-
-/*
- * vCalendar importer functions.
- */
-
-static gboolean
-vcal_support_format_fn (EvolutionImporter *importer,
- const char *filename,
- void *closure)
-{
- char *contents;
- gboolean ret = FALSE;
-
- contents = read_file (filename);
-
- /* parse the file */
- if (contents) {
- VObject *vcal;
-
- vcal = Parse_MIME (contents, strlen (contents));
-
- if (vcal) {
- icalcomponent *icalcomp;
-
- icalcomp = icalvcal_convert (vcal);
-
- if (icalcomp) {
- icalcomponent_free (icalcomp);
- ret = TRUE;
- }
-
- cleanVObject (vcal);
- }
- }
-
- g_free (contents);
-
- return ret;
-}
-
-/* This tries to load in a vCalendar file and convert it to an icalcomponent.
- It returns NULL on failure. */
-static icalcomponent*
-load_vcalendar_file (const char *filename)
-{
- icalvcal_defaults defaults = { 0 };
- icalcomponent *icalcomp = NULL;
- char *contents;
-
- defaults.alarm_audio_url = "file://" EVOLUTION_SOUNDDIR "/default_alarm.wav";
- defaults.alarm_audio_fmttype = "audio/x-wav";
- defaults.alarm_description = (char*) _("Reminder!!");
-
- contents = read_file (filename);
-
- /* parse the file */
- if (contents) {
- VObject *vcal;
-
- vcal = Parse_MIME (contents, strlen (contents));
-
- if (vcal) {
- icalcomp = icalvcal_convert_with_defaults (vcal,
- &defaults);
- cleanVObject (vcal);
- }
- }
-
- g_free (contents);
-
- return icalcomp;
-}
-
-static gboolean
-vcal_load_file_fn (EvolutionImporter *importer,
- const char *filename,
- const char *physical_uri,
- const char *folder_type,
- void *closure)
-{
- gboolean ret = FALSE;
- char *f;
- ICalImporter *ici = (ICalImporter *) closure;
- icalcomponent *icalcomp;
-
- g_return_val_if_fail (ici != NULL, FALSE);
-
- if (!strcmp (folder_type, "calendar")) {
- ici->folder_contains_events = TRUE;
- ici->folder_contains_tasks = FALSE;
-
- f = g_strdup ("calendar.ics");
- } else {
- ici->folder_contains_events = FALSE;
- ici->folder_contains_tasks = TRUE;
-
- f = g_strdup ("tasks.ics");
- }
-
- icalcomp = load_vcalendar_file (filename);
- if (icalcomp) {
- char *real_uri;
-
- if (!g_strncasecmp (physical_uri, "file", 4) &&
- g_strcasecmp (physical_uri + (strlen (physical_uri) - strlen (f)), f)) {
- real_uri = g_concat_dir_and_file (physical_uri, f);
- } else
- real_uri = g_strdup (physical_uri);
-
- /* create ECal's */
- if (!ici->client)
- ici->client = e_cal_new_from_uri (real_uri, CALOBJ_TYPE_EVENT);
- if (!ici->tasks_client)
- ici->tasks_client = e_cal_new_from_uri ("", CALOBJ_TYPE_TODO);
-
- if (e_cal_open (ici->client, TRUE, NULL)
- && e_cal_open (ici->tasks_client, FALSE, NULL)) {
- ici->icalcomp = icalcomp;
- ret = TRUE;
- }
-
- g_free (real_uri);
- }
-
- g_free (f);
-
- return ret;
-}
-
-BonoboObject *
-vcal_importer_new (void)
-{
- ICalImporter *ici;
-
- ici = g_new0 (ICalImporter, 1);
- ici->client = NULL;
- ici->tasks_client = NULL;
- ici->icalcomp = NULL;
- ici->importer = evolution_importer_new (vcal_support_format_fn,
- vcal_load_file_fn,
- process_item_fn,
- NULL,
- ici);
-
- g_object_weak_ref (G_OBJECT (ici->importer), (GWeakNotify) importer_destroy_cb, ici);
-
- return BONOBO_OBJECT (ici->importer);
-}
-
-
-
-
-
-
-static void
-gnome_calendar_importer_destroy_cb (gpointer user_data)
-{
- ICalIntelligentImporter *ici = (ICalIntelligentImporter *) user_data;
-
- g_return_if_fail (ici != NULL);
-
- g_free (ici);
-}
-
-
-
-static gboolean
-gnome_calendar_can_import_fn (EvolutionIntelligentImporter *ii,
- void *closure)
-{
- char *filename;
- gboolean gnome_calendar_exists;
-
- filename = gnome_util_home_file ("user-cal.vcf");
- gnome_calendar_exists = g_file_exists (filename);
- g_free (filename);
-
- return gnome_calendar_exists;
-}
-
-
-static void
-gnome_calendar_import_data_fn (EvolutionIntelligentImporter *ii,
- void *closure)
-{
- ICalIntelligentImporter *ici = closure;
- icalcomponent *icalcomp = NULL;
- char *filename;
- GList *vtodos;
- ECal *calendar_client = NULL, *tasks_client = NULL;
- int t;
-
- /* If neither is selected, just return. */
- if (!ici->do_calendar && !ici->do_tasks) {
- return;
- }
-
- /* Try to open the default calendar & tasks folders. */
- if (ici->do_calendar) {
- calendar_client = e_cal_new_from_uri ("", CALOBJ_TYPE_EVENT); /* FIXME: use default folder */
- if (!e_cal_open (calendar_client, FALSE, NULL))
- goto out;
- }
-
- if (ici->do_tasks) {
- tasks_client = e_cal_new_from_uri ("", CALOBJ_TYPE_TODO); /* FIXME: use default folder */
- if (!e_cal_open (tasks_client, FALSE, NULL))
- goto out;
- }
-
- /* Load the Gnome Calendar file and convert to iCalendar. */
- filename = gnome_util_home_file ("user-cal.vcf");
- icalcomp = load_vcalendar_file (filename);
- g_free (filename);
-
- /* If we couldn't load the file, just return. FIXME: Error message? */
- if (!icalcomp)
- goto out;
-
- /*
- * Import the calendar events into the default calendar folder.
- */
- vtodos = prepare_events (icalcomp);
-
- /* Wait for client to finish opening the calendar & tasks folders. */
- for (t = 0; t < IMPORTER_TIMEOUT_SECONDS; t++) {
- ECalLoadState calendar_state, tasks_state;
-
- calendar_state = tasks_state = E_CAL_LOAD_LOADED;
-
- /* We need this so the ECal gets notified that the
- folder is opened, via Corba. */
- while (gtk_events_pending ())
- gtk_main_iteration ();
-
- if (ici->do_calendar)
- calendar_state = e_cal_get_load_state (calendar_client);
-
- if (ici->do_tasks)
- tasks_state = e_cal_get_load_state (tasks_client);
-
- if (calendar_state == E_CAL_LOAD_LOADED
- && tasks_state == E_CAL_LOAD_LOADED)
- break;
-
- sleep (1);
- }
-
- /* If we timed out, just return. */
- if (t == IMPORTER_TIMEOUT_SECONDS)
- goto out;
-
- /* Import the calendar events. */
- /* FIXME: What do intelligent importers do about errors? */
- if (ici->do_calendar)
- update_objects (calendar_client, icalcomp);
-
-
- /*
- * Import the tasks into the default tasks folder.
- */
- prepare_tasks (icalcomp, vtodos);
- if (ici->do_tasks)
- update_objects (tasks_client, icalcomp);
-
- out:
- if (icalcomp)
- icalcomponent_free (icalcomp);
- if (calendar_client)
- g_object_unref (calendar_client);
- if (tasks_client)
- g_object_unref (tasks_client);
-}
-
-
-/* Fun with aggregation */
-static void
-checkbox_toggle_cb (GtkToggleButton *tb,
- gboolean *do_item)
-{
- *do_item = gtk_toggle_button_get_active (tb);
-}
-
-static BonoboControl *
-create_checkboxes_control (ICalIntelligentImporter *ici)
-{
- GtkWidget *hbox, *calendar_checkbox, *tasks_checkbox;
- BonoboControl *control;
-
- hbox = gtk_hbox_new (FALSE, 2);
-
- calendar_checkbox = gtk_check_button_new_with_label (_("Calendar Events"));
- g_signal_connect (G_OBJECT (calendar_checkbox), "toggled",
- G_CALLBACK (checkbox_toggle_cb),
- &ici->do_calendar);
- gtk_box_pack_start (GTK_BOX (hbox), calendar_checkbox,
- FALSE, FALSE, 0);
-
- tasks_checkbox = gtk_check_button_new_with_label (_("Tasks"));
- g_signal_connect (G_OBJECT (tasks_checkbox), "toggled",
- G_CALLBACK (checkbox_toggle_cb),
- &ici->do_tasks);
- gtk_box_pack_start (GTK_BOX (hbox), tasks_checkbox,
- FALSE, FALSE, 0);
-
- gtk_widget_show_all (hbox);
- control = bonobo_control_new (hbox);
- return control;
-}
-
-BonoboObject *
-gnome_calendar_importer_new (void)
-{
- EvolutionIntelligentImporter *importer;
- ICalIntelligentImporter *ici;
- BonoboControl *control;
- char *message = N_("Evolution has found Gnome Calendar files.\n"
- "Would you like to import them into Evolution?");
-
- ici = g_new0 (ICalIntelligentImporter, 1);
-
- importer = evolution_intelligent_importer_new (gnome_calendar_can_import_fn,
- gnome_calendar_import_data_fn,
- _("Gnome Calendar"),
- _(message),
- ici);
-
-
- g_object_weak_ref (G_OBJECT (importer), (GWeakNotify) gnome_calendar_importer_destroy_cb, ici);
-
- control = create_checkboxes_control (ici);
- bonobo_object_add_interface (BONOBO_OBJECT (importer),
- BONOBO_OBJECT (control));
-
- return BONOBO_OBJECT (importer);
-}
diff --git a/calendar/importers/main.c b/calendar/importers/main.c
deleted file mode 100644
index d19f98a271..0000000000
--- a/calendar/importers/main.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* Evolution calendar importer component
- *
- * Authors: Rodrigo Moya <rodrigo@ximian.com>
- *
- * Copyright (C) 2001 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <string.h>
-#include <bonobo/bonobo-shlib-factory.h>
-#include <bonobo/bonobo-context.h>
-#include <bonobo/bonobo-main.h>
-#include "evolution-calendar-importer.h"
-
-#define IMPORTER_FACTORY_ID "OAFIID:GNOME_Evolution_Calendar_ImporterFactory:" BASE_VERSION
-#define ICALENDAR_IMPORTER_ID "OAFIID:GNOME_Evolution_Calendar_iCalendar_Importer:" BASE_VERSION
-#define VCALENDAR_IMPORTER_ID "OAFIID:GNOME_Evolution_Calendar_vCalendar_Importer:" BASE_VERSION
-#define GNOME_CALENDAR_IMPORTER_ID "OAFIID:GNOME_Evolution_Gnome_Calendar_Intelligent_Importer:" BASE_VERSION
-
-static BonoboObject *
-importer_factory_fn (BonoboGenericFactory *factory, const char *id, void *closure)
-{
- BonoboObject *object = NULL;
-
- g_return_val_if_fail (id != NULL, NULL);
-
- if (!strcmp (id, ICALENDAR_IMPORTER_ID))
- object = ical_importer_new ();
- else if (!strcmp (id, VCALENDAR_IMPORTER_ID))
- object = vcal_importer_new ();
- else if (!strcmp (id, GNOME_CALENDAR_IMPORTER_ID))
- object = gnome_calendar_importer_new ();
- else
- g_warning ("Component not supported by this factory");
-
- return object;
-}
-
-BONOBO_ACTIVATION_SHLIB_FACTORY (IMPORTER_FACTORY_ID, "Evolution Calendar importer factory", importer_factory_fn, NULL)