diff options
Diffstat (limited to 'calendar/importers')
-rw-r--r-- | calendar/importers/.cvsignore | 6 | ||||
-rw-r--r-- | calendar/importers/GNOME_Evolution_Calendar_Importer.oaf.in | 27 | ||||
-rw-r--r-- | calendar/importers/Makefile.am | 38 | ||||
-rw-r--r-- | calendar/importers/evolution-calendar-importer.h | 34 | ||||
-rw-r--r-- | calendar/importers/icalendar-importer.c | 241 | ||||
-rw-r--r-- | calendar/importers/main.c | 83 |
6 files changed, 0 insertions, 429 deletions
diff --git a/calendar/importers/.cvsignore b/calendar/importers/.cvsignore deleted file mode 100644 index dfa0930c53..0000000000 --- a/calendar/importers/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -evolution-calendar-importer -GNOME_Evolution_Calendar_Importer.oaf diff --git a/calendar/importers/GNOME_Evolution_Calendar_Importer.oaf.in b/calendar/importers/GNOME_Evolution_Calendar_Importer.oaf.in deleted file mode 100644 index 0460bf471f..0000000000 --- a/calendar/importers/GNOME_Evolution_Calendar_Importer.oaf.in +++ /dev/null @@ -1,27 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:GNOME_Evolution_Calendar_ImporterFactory" - type="exe" - location="evolution-calendar-importer"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/ObjectFactory:1.0"/> - </oaf_attribute> - <oaf_attribute name="description" type="string" - _value="Factory to import iCalendar files into Evolution"/> -</oaf_server> - -<oaf_server iid="OAFIID:GNOME_Evolution_Calendar_iCalendar_Importer" - type="factory" - location="OAFIID:GNOME_Evolution_Calendar_ImporterFactory"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/Evolution/Importer:1.0"/> - </oaf_attribute> - <oaf_attribute name="evolution:menu-name" type="string" - value="iCalendar files (.ics)"/> - <oaf_attribute name="description" type="string" - _value="Imports iCalendar files into Evolution"/> - -</oaf_server> -</oaf_info> diff --git a/calendar/importers/Makefile.am b/calendar/importers/Makefile.am deleted file mode 100644 index 22f3b41a80..0000000000 --- a/calendar/importers/Makefile.am +++ /dev/null @@ -1,38 +0,0 @@ -bin_PROGRAMS = evolution-calendar-importer - -INCLUDES = \ - -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \ - -DG_LOG_DOMAIN=\"Evolution-Importer\" \ - -I$(top_srcdir) \ - -I$(top_builddir)/shell \ - -I$(top_srcdir)/shell \ - -I$(top_srcdir)/calendar/cal-client \ - -I$(top_builddir)/calendar/cal-client \ - -I$(top_srcdir)/calendar \ - -I$(top_builddir)/calendar \ - -I$(top_srcdir)/libical/src/libical \ - -I$(top_builddir)/libical/src/libical \ - $(BONOBO_GNOME_CFLAGS) \ - $(GNOME_INCLUDEDIR) - -evolution_calendar_importer_SOURCES = \ - evolution-calendar-importer.h \ - icalendar-importer.c \ - main.c - -evolution_calendar_importer_LDADD = \ - $(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 \ - $(top_builddir)/libical/src/libical/libical-evolution.la \ - $(EXTRA_GNOME_LIBS) - -oafdir = $(datadir)/oaf -oaf_in_files = GNOME_Evolution_Calendar_Importer.oaf.in - -oaf_DATA = $(oaf_in_files:.oaf.in=.oaf) - -EXTRA_DIST = $(oaf_in_files) $(oaf_DATA) - -@XML_I18N_MERGE_OAF_RULE@ diff --git a/calendar/importers/evolution-calendar-importer.h b/calendar/importers/evolution-calendar-importer.h deleted file mode 100644 index ac4d15dd8d..0000000000 --- a/calendar/importers/evolution-calendar-importer.h +++ /dev/null @@ -1,34 +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> - -BEGIN_GNOME_DECLS - -BonoboObject *ical_importer_new (void); - -END_GNOME_DECLS - -#endif diff --git a/calendar/importers/icalendar-importer.c b/calendar/importers/icalendar-importer.c deleted file mode 100644 index 262c925b74..0000000000 --- a/calendar/importers/icalendar-importer.c +++ /dev/null @@ -1,241 +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 <sys/types.h> -#include <fcntl.h> -#include <gtk/gtksignal.h> -#include <cal-client.h> -#include <importer/evolution-importer.h> -#include <importer/GNOME_Evolution_Importer.h> -#include "evolution-calendar-importer.h" - -typedef struct { - CalClient *client; - EvolutionImporter *importer; - icalcomponent *icalcomp; -} ICalImporter; - -static void -importer_destroy_cb (GtkObject *object, gpointer user_data) -{ - ICalImporter *ici = (ICalImporter *) user_data; - - g_return_if_fail (ici != NULL); - - gtk_object_unref (GTK_OBJECT (ici->client)); - if (ici->icalcomp != NULL) - icalcomponent_free (ici->icalcomp); - g_free (ici); -} - -static gboolean -support_format_fn (EvolutionImporter *importer, - const char *filename, - void *closure) -{ - int fd; - GString *str; - icalcomponent *icalcomp; - int n; - char buffer[2049]; - gboolean ret = TRUE; - - /* read file contents */ - fd = open (filename, O_RDONLY); - if (fd == -1) - return FALSE; - - 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 { - ret = FALSE; - break; - } - } - - close (fd); - - /* parse the file */ - if (ret) { - icalcomp = icalparser_parse_string (str->str); - if (icalcomp) - icalcomponent_free (icalcomp); - else - ret = FALSE; - } - - g_string_free (str, TRUE); - - return ret; -} - -static gboolean -load_file_fn (EvolutionImporter *importer, - const char *filename, - const char *folderpath, - void *closure) -{ - int fd; - GString *str; - icalcomponent *icalcomp; - int n; - char buffer[2049]; - char *uri_str; - gboolean ret = TRUE; - ICalImporter *ici = (ICalImporter *) closure; - - g_return_val_if_fail (ici != NULL, FALSE); - - if (folderpath == NULL || *folderpath == '\0') - uri_str = g_strdup_printf ("%s/evolution/local/Calendar/calendar.ics", - g_get_home_dir ()); - else { - char *name; - char *parent; - - name = strrchr (folderpath, '/'); - if (name == NULL || name == folderpath) { - parent = g_strdup ("evolution/local/"); - if (folderpath[0] == '/') - name = folderpath + 1; - else - name = folderpath; - } - else { - name += 1; - parent = g_strdup ("evolution/local/Calendar/subfolders/"); - } - uri_str = g_strdup_printf ("%s/%s%s/calendar.ics", g_get_home_dir (), - parent, name); - } - - /* read file contents */ - fd = open (filename, O_RDONLY); - if (fd == -1) - return FALSE; - - 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 { - ret = FALSE; - break; - } - } - - close (fd); - - /* parse the file */ - if (ret) { - icalcomp = icalparser_parse_string (str->str); - if (icalcomp) { - if (!cal_client_open_calendar (ici->client, uri_str, TRUE)) - ret = FALSE; - else - ici->icalcomp = icalcomp; - } - else - ret = FALSE; - } - - g_string_free (str, TRUE); - g_free (uri_str); - - return ret; -} - -static void -process_item_fn (EvolutionImporter *importer, - CORBA_Object listener, - void *closure, - CORBA_Environment *ev) -{ - CalClientLoadState state; - ICalImporter *ici = (ICalImporter *) closure; - - g_return_if_fail (ici != NULL); - g_return_if_fail (IS_CAL_CLIENT (ici->client)); - g_return_if_fail (ici->icalcomp != NULL); - - state = cal_client_get_load_state (ici->client); - if (state == CAL_CLIENT_LOAD_LOADING) { - GNOME_Evolution_ImporterListener_notifyResult ( - listener, - GNOME_Evolution_ImporterListener_NOT_READY, - TRUE, ev); - return; - } - else if (state != CAL_CLIENT_LOAD_LOADED) { - GNOME_Evolution_ImporterListener_notifyResult ( - listener, - GNOME_Evolution_ImporterListener_UNSUPPORTED_OPERATION, - FALSE, ev); - return; - } - - /* import objects into the given client */ - if (!cal_client_update_objects (ici->client, ici->icalcomp)) { - g_warning ("Could not update objects"); - GNOME_Evolution_ImporterListener_notifyResult ( - listener, - GNOME_Evolution_ImporterListener_BAD_DATA, - FALSE, ev); - } - else { - GNOME_Evolution_ImporterListener_notifyResult ( - listener, - GNOME_Evolution_ImporterListener_OK, - FALSE, ev); - } -} - -BonoboObject * -ical_importer_new (void) -{ - ICalImporter *ici; - - ici = g_new0 (ICalImporter, 1); - ici->client = cal_client_new (); - ici->icalcomp = NULL; - ici->importer = evolution_importer_new (support_format_fn, - load_file_fn, - process_item_fn, - NULL, - ici); - gtk_signal_connect (GTK_OBJECT (ici->importer), "destroy", - GTK_SIGNAL_FUNC (importer_destroy_cb), ici); - - return BONOBO_OBJECT (ici->importer); -} diff --git a/calendar/importers/main.c b/calendar/importers/main.c deleted file mode 100644 index aaf4ced23a..0000000000 --- a/calendar/importers/main.c +++ /dev/null @@ -1,83 +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 <bonobo/bonobo-generic-factory.h> -#include "evolution-calendar-importer.h" - -#define IMPORTER_FACTORY_ID "OAFIID:GNOME_Evolution_Calendar_ImporterFactory" -#define ICALENDAR_IMPORTER_ID "OAFIID:GNOME_Evolution_Calendar_iCalendar_Importer" - -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 - g_warning ("Component not supporte by this factory"); - - return object; -} - -static void -init_importer (void) -{ - BonoboGenericFactory *factory; - - factory = bonobo_generic_factory_new_multi (IMPORTER_FACTORY_ID, - importer_factory_fn, NULL); - if (factory == NULL) { - g_error ("Unable to create factory"); - exit (0); - } - - bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory)); -} - -int -main (int argc, char *argv[]) -{ - CORBA_ORB orb; - - bindtextdomain(PACKAGE, EVOLUTION_LOCALEDIR); - textdomain(PACKAGE); - - gnome_init_with_popt_table ("evolution-calendar-importer", - VERSION, 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."); - exit (0); - } - - init_importer (); - bonobo_main (); - - return 0; -} |