From 5a80f92d37e7e8a814f70f826b7b33f5d21b0f72 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 22 Sep 2009 07:46:44 -0400 Subject: Kill the ipod-sync plugin, along with the HAL dependency. --- plugins/ipod-sync/ChangeLog | 187 --------- plugins/ipod-sync/Makefile.am | 30 -- plugins/ipod-sync/evolution-ipod-sync.c | 105 ----- plugins/ipod-sync/evolution-ipod-sync.h | 37 -- plugins/ipod-sync/format-handler.h | 52 --- plugins/ipod-sync/ical-format.c | 126 ------ plugins/ipod-sync/ipod-sync.c | 267 ------------ plugins/ipod-sync/ipod.c | 256 ------------ .../org-gnome-ipod-sync-evolution.eplug.xml | 26 -- plugins/ipod-sync/sync.c | 453 --------------------- 10 files changed, 1539 deletions(-) delete mode 100644 plugins/ipod-sync/ChangeLog delete mode 100644 plugins/ipod-sync/Makefile.am delete mode 100644 plugins/ipod-sync/evolution-ipod-sync.c delete mode 100644 plugins/ipod-sync/evolution-ipod-sync.h delete mode 100644 plugins/ipod-sync/format-handler.h delete mode 100644 plugins/ipod-sync/ical-format.c delete mode 100644 plugins/ipod-sync/ipod-sync.c delete mode 100644 plugins/ipod-sync/ipod.c delete mode 100644 plugins/ipod-sync/org-gnome-ipod-sync-evolution.eplug.xml delete mode 100644 plugins/ipod-sync/sync.c (limited to 'plugins') diff --git a/plugins/ipod-sync/ChangeLog b/plugins/ipod-sync/ChangeLog deleted file mode 100644 index be39031895..0000000000 --- a/plugins/ipod-sync/ChangeLog +++ /dev/null @@ -1,187 +0,0 @@ -2009-01-21 Suman Manjunath - - ** Fix for bug #541209 - - ** Adapt to the new APIs from upstream libical. Changes made include - using the "_r" counterpart for the following APIs: - + icalproperty_as_ical_string () - + icalvalue_as_ical_string () - + icalcomponent_as_ical_string () - + icalparameter_as_ical_string () - + icaldurationtype_as_ical_string () - + icalenum_reqstat_code () - + icallangbind_property_eval_string () - + icallangbind_quote_as_ical () - + icalmime_text_end_part () - + icalperiodtype_as_ical_string () - + icalproperty_enum_to_string () - + icalproperty_get_parameter_as_string () - + icalproperty_get_value_as_string () - + icalproperty_get_property_name () - + icalrecurrencetype_as_string () - + icaltime_as_ical_string () - + icalreqstattype_as_string () - + icalvalue_binary_as_ical_string () - + icalvalue_int_as_ical_string () - + icalvalue_utcoffset_as_ical_string () - + icalvalue_string_as_ical_string () - + icalvalue_recur_as_ical_string () - + icalvalue_text_as_ical_string () - + icalvalue_attach_as_ical_string () - + icalvalue_duration_as_ical_string () - + icalvalue_date_as_ical_string () - + icalvalue_datetime_as_ical_string () - + icalvalue_float_as_ical_string () - + icalvalue_geo_as_ical_string () - + icalvalue_datetimeperiod_as_ical_string () - + icalvalue_period_as_ical_string () - + icalvalue_trigger_as_ical_string () - + icalvalue_as_ical_string () - - * ical-format.c (do_save_calendar_ical): - -2008-09-19 Sankar P - -License Changes - - * evolution-ipod-sync.c: - -2008-09-16 Sankar P - -License Changes - - * ical-format.c: - * ipod-sync.c: - -2008-09-12 Sankar P - -License Changes - - * sync.c: - -2008-09-02 Sankar P - -License Changes - - * evolution-ipod-sync.h: - * ipod.c: - -2008-08-27 Philip Withnall - - ** Fix for bug #534762 - - * org-gnome-ipod-sync-evolution.eplug.xml: Change "addressbook" to - "address book" in translatable strings. - -2008-08-27 Sankar P - -License Changes - - * format-handler.h: - -2008-08-12 Milan Crha - - * ipod-sync.c: Added missing include. - -2008-04-19 Matthew Barnes - - * ical-fomat.c (do_save_calendar_ical): - * ipod-sync.c (open_for_writing), (destination_save_addressbook): - Fix some compilation errors. - -2008-04-17 Milan Crha - - ** Part of fix for bug #526739 - - * ical-format.c: (do_save_calendar_ical): - * ipod-sync.c: (destination_save_addressbook): - Write to gio GOutputStream instead of gnome-vfs handle. - * format-handler.h: (open_for_writing): - * ipod-sync.c: (open_for_writing): New helper function. - -2008-01-07 João Vale - - ** Fix for bug #375580 - - * ipod-sync.c: (destination_save_addressbook): Use ISO-8859-1 encoding - to store contacts in iPod. - -2007-11-11 Gilles Dartiguelongue - - ** Fix bug #495872 - - * ipod-sync.c: (org_gnome_sync_memos): - * org-gnome-ipod-sync-evolution.eplug.xml: - * sync.c: (export_memos), (export_to_ipod): - add memo support - -2007-10-26 Kjartan Maraas - - * evolution-ipod-sync.c: (ipod_check_status): Don't mix code - and declarations. - -2007-09-14 Matthew Barnes - - ** Fixes part of bug #476231 - - * ical-format.c: - Remove non-USE_GTKFILECHOOSER code. - GtkFileChooser has been around since 2004. - -2007-06-07 Gilles Dartiguelongue - - * evolution-ipod-sync.c: (ipod_get_mount): - * evolution-ipod-sync.h: - * ipod.c: (try_mount), (try_umount): more compilation - warnings cleanup, completes bug #437584 fixes. Removes - hopefully useless code in headers. - -2007-05-14 Srinivasa Ragavan - - ** Fix for bug #375234 from Vitaliy Ischenko - - * ipod.c: (find_ipod_mount_point): - -2007-04-10 Andre Klapper - - * plugins/ipod-sync/evolution-ipod-sync.c: - fix typos and reword a string. Fixes bug #404764. - -2007-04-02 Sankar P - - * Committed on behalf of Gilles Dartiguelongue - - * org-gnome-ipod-sync-evolution.eplug.xml: - Cleanup. - Fixes part of #301149 - -2007-01-27 Nickolay V. Shmyrev - - * evolution-ipod-sync.c: (ipod_check_status): - mark strings as translatable. See bug #399381 for details. - -2006-05-13 Harish Krishnaswamy - - * Makefile.am : Add evolution-ipod-sync.h to dist. - Fixes #350388. - -2006-05-13 Harish Krishnaswamy - - patch submitted by: Hiroyuki Ikezoe - - * ipod.c: Remove compiler warning. Fixes 341606. - -2006-05-08 Srinivasa Ragavan - - * ipod-sync.c: (destination_save_addressbook), - (destination_save_cal), (org_gnome_sync_calendar), - (org_gnome_sync_tasks), (org_gnome_sync_addressbook): Added support - for multiple addressbook/calendar/task support for iPod. - -2005-10-18 Srinivasa Ragavan - - * Created the iPod sync plugin. It based on Justin Wakes bounty - work and rodrigo's save calendar plugin. - - - diff --git a/plugins/ipod-sync/Makefile.am b/plugins/ipod-sync/Makefile.am deleted file mode 100644 index 74522a41a3..0000000000 --- a/plugins/ipod-sync/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -AM_CPPFLAGS = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/widgets \ - $(EVOLUTION_CALENDAR_CFLAGS) \ - -DDBUS_API_SUBJECT_TO_CHANGE - -@EVO_PLUGIN_RULE@ - -plugin_DATA = org-gnome-ipod-sync-evolution.eplug -plugin_LTLIBRARIES = liborg-gnome-ipod-sync-evolution.la - -liborg_gnome_ipod_sync_evolution_la_SOURCES = \ - ipod-sync.c \ - ical-format.c \ - evolution-ipod-sync.c \ - ipod.c \ - format-handler.h \ - evolution-ipod-sync.h - -liborg_gnome_ipod_sync_evolution_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED) -liborg_gnome_ipod_sync_evolution_la_LIBADD = \ - $(EVOLUTION_CALENDAR_LIBS) - - -EXTRA_DIST = org-gnome-ipod-sync-evolution.eplug.xml - -BUILT_SOURCES = $(plugin_DATA) -CLEANFILES = $(BUILT_SOURCES) - --include $(top_srcdir)/git.mk diff --git a/plugins/ipod-sync/evolution-ipod-sync.c b/plugins/ipod-sync/evolution-ipod-sync.c deleted file mode 100644 index a381e2a80b..0000000000 --- a/plugins/ipod-sync/evolution-ipod-sync.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Evolution->Ipod synchronisation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * (C)2004 Justin Wake - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "evolution-ipod-sync.h" - -#include -#include -#include - -gchar * mount_point = NULL; -LibHalContext *ctx; - -gboolean -ipod_check_status (gboolean silent) -{ - LibHalContext *ctx; - DBusConnection *conn; - - if (check_hal () == FALSE) - { - if (!silent) { - GtkWidget *message; - gchar *msg1; - msg1 = g_strdup_printf("%s\n\n", _("Hardware Abstraction Layer not loaded")); - - message = gtk_message_dialog_new_with_markup (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - "%s%s", msg1, _("The \"hald\" service is required but not currently " - "running. Please enable the service and rerun this " - "program, or contact your system administrator.")); - - gtk_dialog_run (GTK_DIALOG (message)); - - g_free(msg1); - gtk_widget_destroy (message); - } - return FALSE; - - } - - conn = dbus_bus_get (DBUS_BUS_SYSTEM, NULL); - - ctx = libhal_ctx_new (); - libhal_ctx_set_dbus_connection (ctx, conn); - if (!libhal_ctx_init(ctx, NULL)) - return FALSE; - - mount_point = find_ipod_mount_point (ctx); - - if (mount_point == NULL) { - /* Either the iPod wasn't mounted when we started, or - * it wasn't plugged in. Either way, we want to umount - * the iPod when we finish syncing. */ - if (!silent) { - GtkWidget *message; - gchar *msg1; - msg1 = g_strdup_printf("%s\n\n", _("Search for an iPod failed")); - - message = gtk_message_dialog_new_with_markup (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - "%s%s", msg1, _("Evolution could not find an iPod to synchronize with. " - "Either the iPod is not connected to the system or it " - "is not powered on.")); - - gtk_dialog_run (GTK_DIALOG (message)); - - g_free(msg1); - gtk_widget_destroy (message); - } - - return FALSE; - } - - return TRUE; -} - -gchar * -ipod_get_mount (void) -{ - return mount_point; -} - diff --git a/plugins/ipod-sync/evolution-ipod-sync.h b/plugins/ipod-sync/evolution-ipod-sync.h deleted file mode 100644 index 656cf266f1..0000000000 --- a/plugins/ipod-sync/evolution-ipod-sync.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * Copyright (C) 2004 Justin Wake - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include -#include -#include -#include - -gboolean check_hal (void); -gboolean ipod_check_status (gboolean silent); -gboolean try_umount (gchar *device); - -gchar *find_ipod_mount_point (LibHalContext *ctx); -gchar *ipod_get_mount (void); - diff --git a/plugins/ipod-sync/format-handler.h b/plugins/ipod-sync/format-handler.h deleted file mode 100644 index 4a9207a474..0000000000 --- a/plugins/ipod-sync/format-handler.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Philip Van Hoof - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include - -typedef struct _FormatHandler FormatHandler; - -struct _FormatHandler -{ - gboolean isdefault; - const gchar *combo_label; - const gchar *filename_ext; - GtkWidget *options_widget; - - gpointer data; - - void (*save) (FormatHandler *handler, EPlugin *ep, ECalPopupTargetSource *target, ECalSourceType type, gchar *dest_uri); -}; - -FormatHandler *ical_format_handler_new (void); - -GOutputStream *open_for_writing (GtkWindow *parent, const gchar *uri, GError **error); diff --git a/plugins/ipod-sync/ical-format.c b/plugins/ipod-sync/ical-format.c deleted file mode 100644 index d8961e2520..0000000000 --- a/plugins/ipod-sync/ical-format.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Rodrigo Moya - * Philip Van Hoof - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "format-handler.h" - -static void -display_error_message (GtkWidget *parent, const gchar *message) -{ - GtkWidget *dialog; - - dialog = gtk_message_dialog_new (GTK_WINDOW (parent), 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", message); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); -} - -static void -do_save_calendar_ical (FormatHandler *handler, EPlugin *ep, ECalPopupTargetSource *target, ECalSourceType type, gchar *dest_uri) -{ - ESource *primary_source; - ECal *source_client; - GError *error = NULL; - GList *objects; - icalcomponent *top_level = NULL; - - primary_source = e_source_selector_peek_primary_selection (target->selector); - - if (!dest_uri) - return; - - /* open source client */ - source_client = auth_new_cal_from_source (primary_source, type); - if (!e_cal_open (source_client, TRUE, &error)) { - display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (target->selector)), error->message); - g_object_unref (source_client); - g_error_free (error); - return; - } - - /* create destination file */ - top_level = e_cal_util_new_top_level (); - - error = NULL; - if (e_cal_get_object_list (source_client, "#t", &objects, &error)) { - GOutputStream *stream; - - while (objects != NULL) { - icalcomponent *icalcomp = objects->data; - - icalcomponent_add_component (top_level, icalcomp); - - /* remove item from the list */ - objects = g_list_remove (objects, icalcomp); - } - - /* save the file */ - stream = open_for_writing (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (target->selector))), dest_uri, &error); - - if (stream && !error) { - gchar *ical_str = icalcomponent_as_ical_string_r (top_level); - - g_output_stream_write_all (stream, ical_str, strlen (ical_str), NULL, NULL, &error); - g_output_stream_close (stream, NULL, NULL); - - g_free (ical_str); - } - - if (stream) - g_object_unref (stream); - } - - if (error) { - display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (target->selector)), error->message); - g_error_free (error); - } - - /* terminate */ - g_object_unref (source_client); - icalcomponent_free (top_level); -} - -FormatHandler *ical_format_handler_new (void) -{ - FormatHandler *handler = g_new (FormatHandler, 1); - - handler->isdefault = TRUE; - handler->combo_label = _("iCalendar format (.ics)"); - handler->filename_ext = ".ics"; - handler->options_widget = NULL; - handler->save = do_save_calendar_ical; - handler->data = NULL; - - return handler; -} diff --git a/plugins/ipod-sync/ipod-sync.c b/plugins/ipod-sync/ipod-sync.c deleted file mode 100644 index f5672ef1d0..0000000000 --- a/plugins/ipod-sync/ipod-sync.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Srinivasa Ragavan - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -/* This is written from the save-calendar plugin and James Bowes evo-iPod - * sync code. - * - * This provides eplugin support to sync calendar/task/addressbook with iPod - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "e-util/e-error.h" -#include "format-handler.h" -#include "evolution-ipod-sync.h" - -void org_gnome_sync_calendar (EPlugin *ep, ECalPopupTargetSource *target); -void org_gnome_sync_tasks (EPlugin *ep, ECalPopupTargetSource *target); -void org_gnome_sync_memos (EPlugin *ep, ECalPopupTargetSource *target); -void org_gnome_sync_addressbook (EPlugin *ep, EABPopupTargetSource *target); - -static void -display_error_message (GtkWidget *parent, const gchar *message) -{ - GtkWidget *dialog; - - dialog = gtk_message_dialog_new (GTK_WINDOW (parent), 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", message); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); -} - -/* Returns output stream for the uri, or NULL on any error. - When done with the stream, just g_output_stream_close and g_object_unref it. - It will ask for overwrite if file already exists. -*/ -GOutputStream * -open_for_writing (GtkWindow *parent, const gchar *uri, GError **error) -{ - GFile *file; - GFileOutputStream *fostream; - GError *err = NULL; - - g_return_val_if_fail (uri != NULL, NULL); - - file = g_file_new_for_uri (uri); - - g_return_val_if_fail (file != NULL, NULL); - - fostream = g_file_create (file, G_FILE_CREATE_NONE, NULL, &err); - - if (err && err->code == G_IO_ERROR_EXISTS) { - g_clear_error (&err); - - if (e_error_run (parent, E_ERROR_ASK_FILE_EXISTS_OVERWRITE, uri, NULL) == GTK_RESPONSE_OK) { - fostream = g_file_replace (file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &err); - - if (err && fostream) { - g_object_unref (fostream); - fostream = NULL; - } - } else if (fostream) { - g_object_unref (fostream); - fostream = NULL; - } - } - - g_object_unref (file); - - if (error && err) - *error = err; - else if (err) - g_error_free (err); - - if (fostream) - return G_OUTPUT_STREAM (fostream); - - return NULL; -} - -static void -destination_save_addressbook (EPlugin *ep, EABPopupTargetSource *target) -{ - EBook *book; - EBookQuery *query; - GList *contacts, *tmp; - ESource *primary_source; - gchar *uri; - GOutputStream *stream; - GError *error = NULL; - gchar *dest_uri = NULL; - gchar *mount = ipod_get_mount(); - - primary_source = e_source_selector_peek_primary_selection (target->selector); - - /* use g_file api here to build path*/ - dest_uri = g_strdup_printf("%s/%s/Evolution-Addressbook-%s.vcf", mount, "Contacts", e_source_peek_name (primary_source)); - g_free (mount); - - uri = e_source_get_uri (primary_source); - - book = e_book_new_from_uri (uri, NULL); - - if (!book - || !e_book_open (book, TRUE, NULL)) { - g_warning ("Couldn't load addressbook %s", uri); - return; - } - - /* Let us export some meaning full contacts */ - query = e_book_query_any_field_contains (""); - e_book_get_contacts (book, query, &contacts, NULL); - e_book_query_unref (query); - - stream = open_for_writing (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (target->selector))), dest_uri, &error); - - if (stream && !error) { - for (tmp = contacts; tmp; tmp=tmp->next) { - EContact *contact = tmp->data; - gchar *temp = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30); - gchar *vcard; - gchar *converted_vcard; - gsize vcard_latin1_length; - - vcard = g_strconcat (temp, "\r\n", NULL); - converted_vcard = g_convert (vcard, -1, "ISO-8859-1", "UTF-8", NULL, &vcard_latin1_length, NULL); - g_output_stream_write_all (stream, converted_vcard, vcard_latin1_length, NULL, NULL, &error); - - if (error) { - display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (target->selector)), error->message); - g_clear_error (&error); - } - - g_object_unref (contact); - g_free (temp); - g_free (vcard); - g_free (converted_vcard); - } - - g_output_stream_close (stream, NULL, NULL); - } - - if (stream) - g_object_unref (stream); - - sync(); - - if (contacts != NULL) - g_list_free (contacts); - - g_object_unref (book); - g_free (dest_uri); - g_free (uri); - - if (error) { - display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (target->selector)), error->message); - g_error_free (error); - } -} - -static void -destination_save_cal (EPlugin *ep, ECalPopupTargetSource *target, ECalSourceType type) -{ - FormatHandler *handler = NULL; - gchar *mount = ipod_get_mount(); - gchar *dest_uri = NULL, *path; - ESource *primary_source = e_source_selector_peek_primary_selection (target->selector); - - /* The available formathandlers */ - handler= ical_format_handler_new (); - - switch (type) { - case E_CAL_SOURCE_TYPE_EVENT: - path = g_strdup_printf ("Evolution-Calendar-%s", e_source_peek_name (primary_source)); - break; - case E_CAL_SOURCE_TYPE_TODO: - path = g_strdup_printf ("Evolution-Tasks-%s", e_source_peek_name (primary_source)); - break; - case E_CAL_SOURCE_TYPE_JOURNAL: - path = g_strdup_printf ("Evolution-Memos-%s", e_source_peek_name (primary_source)); - break; - default: - path = NULL; - g_assert_not_reached (); - } - - dest_uri = g_strdup_printf("%s/%s/%s.ics", mount, "Calendars", path); - g_free (path); - - handler->save (handler, ep, target, type, dest_uri); - - sync(); - - g_free (dest_uri); - g_free (mount); - g_free (handler); -} - -void -org_gnome_sync_calendar (EPlugin *ep, ECalPopupTargetSource *target) -{ - if (!ipod_check_status(FALSE)) - return; - - destination_save_cal (ep, target, E_CAL_SOURCE_TYPE_EVENT); -} - -void -org_gnome_sync_tasks (EPlugin *ep, ECalPopupTargetSource *target) -{ - if (!ipod_check_status(FALSE)) - return; - - destination_save_cal (ep, target, E_CAL_SOURCE_TYPE_TODO); -} - -void -org_gnome_sync_memos (EPlugin *ep, ECalPopupTargetSource *target) -{ - if (!ipod_check_status(FALSE)) - return; - - destination_save_cal (ep, target, E_CAL_SOURCE_TYPE_JOURNAL); -} - -void -org_gnome_sync_addressbook (EPlugin *ep, EABPopupTargetSource *target) -{ - if (!ipod_check_status(FALSE)) - return; - - destination_save_addressbook (ep, target); -} diff --git a/plugins/ipod-sync/ipod.c b/plugins/ipod-sync/ipod.c deleted file mode 100644 index ee7bfcb501..0000000000 --- a/plugins/ipod-sync/ipod.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * ipod.c - Find an iPod mount point using HAL - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * Copyright (C) 2004 Justin Wake - * - */ - -#include "config.h" -#include "evolution-ipod-sync.h" -#include -#include - -/** - * Ensure that HAL is running before we try to use it. - * From gnome-volume-manager's src/properties.c - */ -gboolean -check_hal (void) -{ - LibHalContext *ctx; - gchar **devices; - gint num; - DBusConnection *conn; - - conn = dbus_bus_get (DBUS_BUS_SYSTEM, NULL); - - ctx = libhal_ctx_new (); - libhal_ctx_set_dbus_connection (ctx, conn); - if (!libhal_ctx_init(ctx, NULL)) - return FALSE; - devices = libhal_get_all_devices (ctx, &num, NULL); - if (!devices) - { - libhal_ctx_shutdown (ctx, NULL); - return FALSE; - } - libhal_free_string_array (devices); - - libhal_ctx_shutdown (ctx, NULL); - return TRUE; -} - -#define MOUNT "/bin/mount" -#define UMOUNT "/bin/umount" - -/** - * Try to mount a given device. - */ -static gboolean -try_mount (gchar *device) -{ - gchar *argv[3]; - GError *err = NULL; - gint exit_status; - - argv[0] = (gchar *)MOUNT; - argv[1] = device; - argv[2] = NULL; - - if (!g_spawn_sync (g_get_home_dir (), argv, NULL, 0, NULL, NULL, NULL, - NULL, &exit_status, &err)) - { - g_warning ("try_mount failed: %s", err->message); - return FALSE; - } - - return (exit_status == 0); -} - -/** - * Try to unmount a given device. - */ -gboolean -try_umount (gchar *device) -{ - gchar *argv[3]; - GError *err = NULL; - gint exit_status; - - argv[0] = (gchar *)UMOUNT; - argv[1] = device; - argv[2] = NULL; - - sync (); - - if (!g_spawn_sync (g_get_home_dir (), argv, NULL, 0, NULL, NULL, NULL, - NULL, &exit_status, &err)) - { - g_warning ("try_umount failed: %s", err->message); - return FALSE; - } - - return (exit_status == 0); -} - -/** - * See if a given mount point contains an iPod. - * - * Do this by checking for the presence of an iTunes - * database at /iPod_Control/iTunes/. - */ -static gboolean -is_ipod (gchar *mount_point) -{ - gboolean ret = FALSE; - - gchar *itunes_path; - - itunes_path = g_build_path (G_DIR_SEPARATOR_S, mount_point, - "iPod_Control", "iTunes", - NULL); - - if (!g_file_test (itunes_path, G_FILE_TEST_IS_DIR)) - goto out; - - ret = TRUE; - -out: - g_free (itunes_path); - return ret; -} - -/** - * Try to find a mount point for an iPod. - */ -gchar * -find_ipod_mount_point (LibHalContext *ctx) -{ - gchar **apple_devices = NULL; - gchar **volumes = NULL; - gchar *udi, *udi2, *device, *fsusage, *mount_point = NULL; - gchar *retval = NULL; - gint apple_count = 0; - gint volume_count = 0; - gint has_fs = 0; - gint i, j; - - /* First, we look for things made by Apple. */ - apple_devices = libhal_manager_find_device_string_match (ctx, - "info.vendor", - "Apple", - &apple_count, - NULL); - - for (i = 0; i < apple_count; i++) - { - udi = apple_devices[i]; - - volumes = NULL; - volumes = libhal_manager_find_device_string_match (ctx, - "info.parent", - udi, - &volume_count, - NULL); - - for (j = 0; j < volume_count; j++) - { - udi2 = volumes[j]; - - /* Only interested if it has a filesystem. */ - has_fs = 0; - - if (!libhal_device_property_exists (ctx, udi2, - "volume.is_filesystem", NULL) || - !libhal_device_get_property_bool (ctx, udi2, - "volume.is_filesystem", NULL)) - { - has_fs = 1; - } - - fsusage = libhal_device_get_property_string (ctx, udi2, - "volume.fsusage", NULL); - - if (fsusage == NULL) - continue; - - if (strncmp (fsusage, "filesystem", 10) == 0) - { - has_fs = 1; - } - - libhal_free_string (fsusage); - - if (has_fs == 0) - continue; - - device = libhal_device_get_property_string (ctx, udi2, - "block.device", NULL); - - /* Let's see if it's mounted. */ - if (!libhal_device_property_exists (ctx, udi2, - "volume.is_mounted", NULL) || - !libhal_device_get_property_bool (ctx, udi2, - "volume.is_mounted", NULL)) - { - /* It isn't, so let's attempt to mount it */ - if (device != NULL) - { - try_mount (device); - } - } - - if (!libhal_device_property_exists (ctx, udi2, - "volume.mount_point", NULL)) - { - libhal_free_string (device); - continue; - } - - libhal_free_string (device); - - mount_point = libhal_device_get_property_string (ctx, udi2, - "volume.mount_point", NULL); - - if (is_ipod (mount_point)) - { - goto out; - } - - libhal_free_string (mount_point); - mount_point = NULL; - } - } - -out: - if (volumes != NULL) - libhal_free_string_array (volumes); - - if (apple_devices != NULL) - libhal_free_string_array (apple_devices); - - if (mount_point != NULL) - { - retval = g_strdup (mount_point); - libhal_free_string (mount_point); - } - - return (retval); -} diff --git a/plugins/ipod-sync/org-gnome-ipod-sync-evolution.eplug.xml b/plugins/ipod-sync/org-gnome-ipod-sync-evolution.eplug.xml deleted file mode 100644 index fdd70064e6..0000000000 --- a/plugins/ipod-sync/org-gnome-ipod-sync-evolution.eplug.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - <_description>Synchronize your data with your Apple iPod. - - - - - - - - - - - - - - - - - - - diff --git a/plugins/ipod-sync/sync.c b/plugins/ipod-sync/sync.c deleted file mode 100644 index 91e99c02e1..0000000000 --- a/plugins/ipod-sync/sync.c +++ /dev/null @@ -1,453 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * Copyright (C) 2004 Justin Wake - * - */ - -#include "config.h" -#include "evolution-ipod-sync.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define EBOOK_SOURCE_LIST "/apps/evolution/addressbook/sources" -#define ECAL_SOURCE_LIST "/apps/evolution/calendar/sources" -#define ETASK_SOURCE_LIST "/apps/evolution/tasks/sources" -#define EMEMO_SOURCE_LIST "/apps/evolution/memos/sources" - -extern GtkWidget *progress_bar; -extern IPod ipod_info; - -static void pulse (void) -{ - gtk_progress_bar_pulse (GTK_PROGRESS_BAR (progress_bar)); - g_main_context_iteration (NULL, FALSE); -} - -/** - * Something bad happened. - */ -static void error_dialog (gchar *title, gchar *error) -{ - GtkWidget *error_dlg = - gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - "" - "%s\n\n%s.", title, error); - - gtk_dialog_set_has_separator (GTK_DIALOG (error_dlg), FALSE); - gtk_container_set_border_width (GTK_CONTAINER (error_dlg), 5); - gtk_label_set_use_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (error_dlg)->label), - TRUE); - gtk_dialog_set_default_response (GTK_DIALOG (error_dlg), - GTK_RESPONSE_OK); - - gtk_dialog_run (GTK_DIALOG (error_dlg)); - gtk_widget_destroy (error_dlg); -} - -/** - * Something really bad happened. - */ -static void critical_error (gchar *title, gchar *error) -{ - error_dialog (title, error); - gtk_main_quit (); - exit (EXIT_FAILURE); -} - -static GSList * -get_source_uris_for_type (gchar *key) -{ - ESourceList *sources; - GSList *groups; - GSList *uris = NULL; - GSList *item, *source; - sources = e_source_list_new_for_gconf_default (key); - groups = e_source_list_peek_groups (sources); - - for (item = groups; item != NULL; item = item->next) - { - ESourceGroup *group; - - g_assert (item->data != NULL); - - group = E_SOURCE_GROUP (item->data); - for (source = e_source_group_peek_sources(group); - source != NULL; - source = source->next) - { - gchar *uri; - g_assert (source->data != NULL); - uri = e_source_get_uri (E_SOURCE (source->data)); - uris = g_slist_append (uris, uri); - } - } - - g_object_unref (sources); - - return uris; -} - -static void -free_uri_list (GSList *uris) -{ - g_slist_foreach (uris, (GFunc)g_free, NULL); - g_slist_free (uris); -} - -/** - * Force the data into little-endian output. - * - * Note: data must be of even length. - */ -static void -force_little_endian (gunichar2 *data, gint length) -{ - gint i; - - /* We're big-endian? - (A little tidier than before) */ - if (G_BYTE_ORDER == G_BIG_ENDIAN) - { - for (i = 0; i < length; i++) - { - gunichar2 c = data[i]; - - c = ((((guint16)(c) & 0xFF00) >> 8) | - (((guint16)(c) & 0x00FF) << 8)); - - data[i] = c; - } - } -} - -/** - * Write a string of data to a file on the iPod. - * - * Will return if the write worked, otherwise will - * display an error dialog and end the program. - */ -static void -write_to_ipod (GString *str, gchar *path, gchar *filename) -{ - gchar *output_path; - gchar *output_file; - FILE *f; - guchar *utf8; - gunichar2 *utf16; - guchar bom[2] = {0xFF, 0xFE}; - gint i, count; - - output_path = g_build_path (G_DIR_SEPARATOR_S, - ipod_info.mount_point, - path, NULL); - - if (!g_file_test (output_path, G_FILE_TEST_IS_DIR)) - { - if (mkdir (output_path, 0777) != 0) - critical_error (_("No output directory!"), - _("The output directory was not found on " - "iPod! Please ensure that iPod has been correctly " - "set up and try again.")); - } - - output_file = g_build_filename (output_path, filename, NULL); - - g_free (output_path); - - f = fopen (output_file, "w"); - - g_free (output_file); - - if (f == NULL) - { - critical_error (_("Could not export data!"), g_strerror (errno)); - } - - /* Convert the input string into UTF16 */ - utf8 = str->str; - if (g_utf8_validate (utf8, -1, NULL)) - { - utf16 = g_utf8_to_utf16 (utf8, -1, NULL, NULL, NULL); - - /* Swap the bytes if we're big-endian so that the output - * remains little-endian according to the BOM. */ - force_little_endian (utf16, g_utf8_strlen (utf8, -1)); - } - - count = 2 * g_utf8_strlen (utf8, -1); - - /* Write the BOM - * 0xFF 0xFE - * UTF-16 Little Endian - */ - for (i = 0; i < 2; i++) - fwrite (&bom[i], 1, 1, f); - - if ((fwrite(utf16, count, 1, f) != 1) && - (count > 0)) - { - g_free (utf16); - fclose (f); - critical_error (_("Could not export data!"), - _("Exporting data failed.")); - } - - g_free (utf16); - fclose (f); -} - -static GString * -uri_list_to_vcard_string (GSList *uris) -{ - GString *str = NULL; - EBook *book = NULL; - EBookQuery *qry = NULL; - GList *contacts = NULL, *c = NULL; - GSList *uri; - - qry = e_book_query_field_exists (E_CONTACT_FILE_AS); - - str = g_string_new (NULL); - - for (uri = uris; uri != NULL; uri = uri->next) - { - g_assert (uri->data != NULL); - - book = e_book_new_from_uri (uri->data, NULL); - - if (e_book_open (book, TRUE, NULL) == FALSE) - { - error_dialog (_("Could not open addressbook!"), - _("Could not open the Evolution addressbook to export data.")); - - /* Maybe the next one will work. */ - continue; - } - - if (e_book_get_contacts (book, qry, &contacts, NULL) == FALSE) - { - /* Looks like this one is empty. */ - g_object_unref (book); - continue; - } - - /* Loop through the contacts, adding them to the string. */ - for (c = contacts; c != NULL; c = c->next) - { - gchar *tmp; - EContact *contact = E_CONTACT (c->data); - - tmp = e_vcard_to_string (E_VCARD (contact), - EVC_FORMAT_VCARD_30); - - g_string_append (str, tmp); - g_string_append (str, "\r\n"); - g_free (tmp); - g_object_unref (contact); - } - - if (contacts != NULL) - g_list_free (contacts); - - g_object_unref (book); - } - - /* Okay, all done. */ - e_book_query_unref (qry); - - return (str); -} - -static GString * -uri_list_to_vcal_string (GSList *uris, ECalSourceType type) -{ - GString *str = NULL; - ECal *cal = NULL; - icalcomponent *obj = NULL; - GList *objects = NULL, *o = NULL; - GSList *uri; - - str = g_string_new (NULL); - - for (uri = uris; uri != NULL; uri = uri->next) - { - g_assert (uri->data != NULL); - - cal = e_cal_new_from_uri (uri->data, type); - - if (e_cal_open (cal, TRUE, NULL) == FALSE) - { - error_dialog (_("Could not open calendar/todo!"), - _("Could not open the Evolution calendar/todo list to export data.")); - - /* Maybe the next one will work. */ - continue; - } - - e_cal_get_object_list (cal, "#t", &objects, NULL); - - for (o = objects; o != NULL; o = o->next) - { - gchar *tmp; - icalcomponent *comp; - - g_assert (o->data != NULL); - - comp = o->data; - tmp = e_cal_get_component_as_string (cal, comp); - g_string_append (str, tmp); - g_free (tmp); - } - - g_object_unref (cal); - } - - /* Okay, all done. */ - - return (str); -} - -/* Attempt to export the addressbook. */ -static void -export_addressbook (void) -{ - GSList *uris; - GString *data; - pulse (); - - uris = get_source_uris_for_type (EBOOK_SOURCE_LIST); - - pulse (); - - data = uri_list_to_vcard_string (uris); - - write_to_ipod (data, "/Contacts/", "evolution.vcf"); - - g_string_free (data, TRUE); - - pulse (); - - free_uri_list (uris); - - pulse (); -} - -/* Attempt to export the calendar(s). */ -static void -export_calendar (void) -{ - GSList *uris; - GString *data; - - pulse (); - - uris = get_source_uris_for_type (ECAL_SOURCE_LIST); - - pulse (); - - data = uri_list_to_vcal_string (uris, E_CAL_SOURCE_TYPE_EVENT); - - write_to_ipod (data, "/Calendars/", "evolution-cal.ics"); - - g_string_free (data, TRUE); - - free_uri_list (uris); - - pulse (); -} - -/* Attempt to export the task list(s). */ -static void -export_tasks (void) -{ - GSList *uris; - GString *data; - - pulse (); - - uris = get_source_uris_for_type (ETASK_SOURCE_LIST); - - pulse (); - - data = uri_list_to_vcal_string (uris, E_CAL_SOURCE_TYPE_TODO); - - write_to_ipod (data, "/Calendars/", "evolution-todo.ics"); - - g_string_free (data, TRUE); - - free_uri_list (uris); - - pulse (); -} - -/* Attempt to export the memo list(s). */ -static void -export_memos (void) -{ - GSList *uris; - GString *data; - - pulse (); - - uris = get_source_uris_for_type (EMEMO_SOURCE_LIST); - - pulse (); - - data = uri_list_to_vcal_string (uris, E_CAL_SOURCE_TYPE_JOURNAL); - - write_to_ipod (data, "/Calendars/", "evolution-memo.ics"); - - g_string_free (data, TRUE); - - free_uri_list (uris); - - pulse (); -} - -void -export_to_ipod (void) -{ - pulse (); - - if (ipod_info.addressbook == TRUE) - export_addressbook (); - - if (ipod_info.calendar == TRUE) - export_calendar (); - - if (ipod_info.tasks == TRUE) - export_tasks (); - - if (ipod_info.memos == TRUE) - export_memos (); - - pulse (); - sync (); - pulse (); - return; -} - -- cgit