aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/gui/component/eab-composer-util.c2
-rw-r--r--calendar/gui/Makefile.am2
-rw-r--r--calendar/gui/e-attachment-handler-calendar.c516
-rw-r--r--calendar/gui/e-attachment-handler-calendar.h65
-rw-r--r--calendar/modules/e-cal-shell-module.c3
-rw-r--r--composer/e-composer-private.c1
-rw-r--r--composer/e-msg-composer.c5
-rw-r--r--configure.in4
-rw-r--r--mail/em-format-html-display.c46
-rw-r--r--mail/em-popup.c16
-rw-r--r--mail/em-popup.h33
-rw-r--r--plugins/import-ics-attachments/ChangeLog109
-rw-r--r--plugins/import-ics-attachments/Makefile.am35
-rw-r--r--plugins/import-ics-attachments/icsimporter.c434
-rw-r--r--plugins/import-ics-attachments/org-gnome-evolution-mail-attachments-import-ics.eplug.xml26
15 files changed, 593 insertions, 704 deletions
diff --git a/addressbook/gui/component/eab-composer-util.c b/addressbook/gui/component/eab-composer-util.c
index b7daa3dddc..943225b011 100644
--- a/addressbook/gui/component/eab-composer-util.c
+++ b/addressbook/gui/component/eab-composer-util.c
@@ -117,7 +117,7 @@ eab_send_as_attachment (GList *destinations)
GList *contacts, *iter;
gchar *data;
- if (contacts == NULL)
+ if (destinations == NULL)
return;
composer = e_msg_composer_new ();
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index bffbe8731f..560d09857d 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -50,6 +50,8 @@ privsolib_LTLIBRARIES = libcal-gui.la
# gnome-cal.h
libcal_gui_la_SOURCES = \
+ e-attachment-handler-calendar.c \
+ e-attachment-handler-calendar.h \
e-calendar-view.c \
e-calendar-view.h \
e-calendar-table.c \
diff --git a/calendar/gui/e-attachment-handler-calendar.c b/calendar/gui/e-attachment-handler-calendar.c
new file mode 100644
index 0000000000..a3ad62cfab
--- /dev/null
+++ b/calendar/gui/e-attachment-handler-calendar.c
@@ -0,0 +1,516 @@
+/*
+ * e-attachment-handler-calendar.c
+ *
+ * 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 <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "e-attachment-handler-calendar.h"
+
+#include <config.h>
+#include <glib/gi18n.h>
+#include <libical/ical.h>
+#include <libecal/e-cal.h>
+#include <camel/camel-stream-mem.h>
+#include <libedataserverui/e-source-selector.h>
+
+#include "calendar/common/authentication.h"
+
+#define E_ATTACHMENT_HANDLER_CALENDAR_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_ATTACHMENT_HANDLER_CALENDAR, EAttachmentHandlerCalendarPrivate))
+
+typedef struct _ImportContext ImportContext;
+
+struct _EAttachmentHandlerCalendarPrivate {
+ gint placeholder;
+};
+
+struct _ImportContext {
+ ECal *client;
+ icalcomponent *component;
+ ECalSourceType source_type;
+};
+
+static gpointer parent_class;
+
+static const gchar *ui =
+"<ui>"
+" <popup name='context'>"
+" <placeholder name='custom-actions'>"
+" <menuitem action='import-to-calendar'/>"
+" <menuitem action='import-to-tasks'/>"
+" </placeholder>"
+" </popup>"
+"</ui>";
+
+static icalcomponent *
+attachment_handler_get_component (EAttachment *attachment)
+{
+ CamelDataWrapper *wrapper;
+ CamelMimePart *mime_part;
+ CamelStream *stream;
+ GByteArray *buffer;
+ icalcomponent *component;
+ const gchar *key = "__icalcomponent__";
+
+ component = g_object_get_data (G_OBJECT (attachment), key);
+ if (component != NULL)
+ return component;
+
+ mime_part = e_attachment_get_mime_part (attachment);
+ if (!CAMEL_IS_MIME_PART (mime_part))
+ return NULL;
+
+ buffer = g_byte_array_new ();
+ stream = camel_stream_mem_new ();
+ camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (stream), buffer);
+ wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
+ camel_data_wrapper_decode_to_stream (wrapper, stream);
+ camel_object_unref (stream);
+
+ component = e_cal_util_parse_ics_string ((gchar *) buffer->data);
+
+ g_byte_array_free (buffer, TRUE);
+
+ if (component == NULL)
+ return NULL;
+
+ g_object_set_data_full (
+ G_OBJECT (attachment), key, component,
+ (GDestroyNotify) icalcomponent_free);
+
+ return component;
+}
+
+static gboolean
+attachment_handler_update_objects (ECal *client,
+ icalcomponent *component)
+{
+ icalcomponent_kind kind;
+ icalcomponent *vcalendar;
+ gboolean success;
+
+ kind = icalcomponent_isa (component);
+
+ switch (kind) {
+ case ICAL_VTODO_COMPONENT:
+ case ICAL_VEVENT_COMPONENT:
+ vcalendar = e_cal_util_new_top_level ();
+ if (icalcomponent_get_method (component) == ICAL_METHOD_CANCEL)
+ icalcomponent_set_method (vcalendar, ICAL_METHOD_CANCEL);
+ else
+ icalcomponent_set_method (vcalendar, ICAL_METHOD_PUBLISH);
+ icalcomponent_add_component (
+ vcalendar, icalcomponent_new_clone (component));
+ break;
+
+ case ICAL_VCALENDAR_COMPONENT:
+ vcalendar = icalcomponent_new_clone (component);
+ if (!icalcomponent_get_first_property (vcalendar, ICAL_METHOD_PROPERTY))
+ icalcomponent_set_method (vcalendar, ICAL_METHOD_PUBLISH);
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ success = e_cal_receive_objects (client, vcalendar, NULL);
+
+ icalcomponent_free (vcalendar);
+
+ return success;
+}
+
+static void
+attachment_handler_import_event (ECal *client,
+ ECalendarStatus status,
+ EAttachment *attachment)
+{
+ icalcomponent *component;
+ icalcomponent *subcomponent;
+ icalcompiter iter;
+
+ /* FIXME Notify the user somehow. */
+ g_return_if_fail (status == E_CALENDAR_STATUS_OK);
+
+ component = attachment_handler_get_component (attachment);
+ g_return_if_fail (component != NULL);
+
+ iter = icalcomponent_begin_component (component, ICAL_ANY_COMPONENT);
+
+ while ((subcomponent = icalcompiter_deref (&iter)) != NULL) {
+ icalcomponent_kind kind;
+
+ kind = icalcomponent_isa (subcomponent);
+ icalcompiter_next (&iter);
+
+ if (kind == ICAL_VEVENT_COMPONENT)
+ continue;
+
+ if (kind == ICAL_VTIMEZONE_COMPONENT)
+ continue;
+
+ icalcomponent_remove_component (component, subcomponent);
+ icalcomponent_free (subcomponent);
+ }
+
+ /* XXX Do something with the return value. */
+ attachment_handler_update_objects (client, component);
+
+ g_object_unref (attachment);
+ g_object_unref (client);
+}
+
+static void
+attachment_handler_import_todo (ECal *client,
+ ECalendarStatus status,
+ EAttachment *attachment)
+{
+ icalcomponent *component;
+ icalcomponent *subcomponent;
+ icalcompiter iter;
+
+ /* FIXME Notify the user somehow. */
+ g_return_if_fail (status == E_CALENDAR_STATUS_OK);
+
+ component = attachment_handler_get_component (attachment);
+ g_return_if_fail (component != NULL);
+
+ iter = icalcomponent_begin_component (component, ICAL_ANY_COMPONENT);
+
+ while ((subcomponent = icalcompiter_deref (&iter)) != NULL) {
+ icalcomponent_kind kind;
+
+ kind = icalcomponent_isa (subcomponent);
+ icalcompiter_next (&iter);
+
+ if (kind == ICAL_VTODO_COMPONENT)
+ continue;
+
+ if (kind == ICAL_VTIMEZONE_COMPONENT)
+ continue;
+
+ icalcomponent_remove_component (component, subcomponent);
+ icalcomponent_free (subcomponent);
+ }
+
+ /* XXX Do something with the return value. */
+ attachment_handler_update_objects (client, component);
+
+ g_object_unref (attachment);
+ g_object_unref (client);
+}
+
+static void
+attachment_handler_row_activated_cb (GtkDialog *dialog)
+{
+ gtk_dialog_response (dialog, GTK_RESPONSE_OK);
+}
+
+static void
+attachment_handler_run_dialog (GtkWindow *parent,
+ EAttachment *attachment,
+ ECalSourceType source_type,
+ const gchar *title)
+{
+ GtkWidget *dialog;
+ GtkWidget *container;
+ GtkWidget *widget;
+ GCallback callback;
+ ESourceSelector *selector;
+ ESourceList *source_list;
+ ESource *source;
+ ECal *client;
+ icalcomponent *component;
+ GError *error = NULL;
+
+ component = attachment_handler_get_component (attachment);
+ g_return_if_fail (component != NULL);
+
+ e_cal_get_sources (&source_list, source_type, &error);
+ if (error != NULL) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ source = e_source_list_peek_source_any (source_list);
+ g_return_if_fail (source != NULL);
+
+ dialog = gtk_dialog_new_with_buttons (
+ title, parent, GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
+
+ widget = gtk_button_new_with_mnemonic (_("I_mport"));
+ gtk_button_set_image (
+ GTK_BUTTON (widget), gtk_image_new_from_icon_name (
+ "stock_mail-import", GTK_ICON_SIZE_MENU));
+ gtk_dialog_add_action_widget (
+ GTK_DIALOG (dialog), widget, GTK_RESPONSE_OK);
+ gtk_widget_show (widget);
+
+ gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+ gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 400);
+
+ container = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+ widget = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (
+ GTK_SCROLLED_WINDOW (widget),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (
+ GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ widget = e_source_selector_new (source_list);
+ selector = E_SOURCE_SELECTOR (widget);
+ e_source_selector_set_primary_selection (selector, source);
+ e_source_selector_show_selection (selector, FALSE);
+ gtk_container_add (GTK_CONTAINER (container), widget);
+ gtk_widget_show (widget);
+
+ g_signal_connect_swapped (
+ widget, "row-activated",
+ G_CALLBACK (attachment_handler_row_activated_cb), dialog);
+
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK)
+ goto exit;
+
+ source = e_source_selector_peek_primary_selection (selector);
+ if (source == NULL)
+ goto exit;
+
+ client = auth_new_cal_from_source (source, source_type);
+ if (client == NULL)
+ goto exit;
+
+ if (source_type == E_CAL_SOURCE_TYPE_EVENT)
+ callback = G_CALLBACK (attachment_handler_import_event);
+ else if (source_type == E_CAL_SOURCE_TYPE_TODO)
+ callback = G_CALLBACK (attachment_handler_import_todo);
+ else
+ goto exit;
+
+ g_object_ref (attachment);
+ g_signal_connect (client, "cal-opened", callback, attachment);
+ e_cal_open_async (client, FALSE);
+
+exit:
+ gtk_widget_destroy (dialog);
+}
+
+static void
+attachment_handler_import_to_calendar (GtkAction *action,
+ EAttachmentHandler *handler)
+{
+ EAttachment *attachment;
+ EAttachmentView *view;
+ GList *selected;
+ gpointer parent;
+
+ view = e_attachment_handler_get_view (handler);
+
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (view));
+ parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
+
+ selected = e_attachment_view_get_selected_attachments (view);
+ g_return_if_fail (g_list_length (selected) == 1);
+ attachment = E_ATTACHMENT (selected->data);
+
+ attachment_handler_run_dialog (
+ parent, attachment,
+ E_CAL_SOURCE_TYPE_EVENT,
+ _("Select a Calendar"));
+
+ g_object_unref (attachment);
+ g_list_free (selected);
+}
+
+static void
+attachment_handler_import_to_tasks (GtkAction *action,
+ EAttachmentHandler *handler)
+{
+ EAttachment *attachment;
+ EAttachmentView *view;
+ GList *selected;
+ gpointer parent;
+
+ view = e_attachment_handler_get_view (handler);
+
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (view));
+ parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
+
+ selected = e_attachment_view_get_selected_attachments (view);
+ g_return_if_fail (g_list_length (selected) == 1);
+ attachment = E_ATTACHMENT (selected->data);
+
+ attachment_handler_run_dialog (
+ parent, attachment,
+ E_CAL_SOURCE_TYPE_TODO,
+ _("Select a Task List"));
+
+ g_object_unref (attachment);
+ g_list_free (selected);
+}
+
+static GtkActionEntry standard_entries[] = {
+
+ { "import-to-calendar",
+ "stock_mail-import",
+ N_("I_mport to Calendar"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ G_CALLBACK (attachment_handler_import_to_calendar) },
+
+ { "import-to-tasks",
+ "stock_mail-import",
+ N_("I_mport to Tasks"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ G_CALLBACK (attachment_handler_import_to_tasks) }
+};
+
+static void
+attachment_handler_calendar_update_actions (EAttachmentView *view)
+{
+ EAttachment *attachment;
+ GtkAction *action;
+ GList *selected;
+ icalcomponent *component;
+ icalcomponent *subcomponent;
+ icalcomponent_kind kind;
+ gboolean is_vevent = FALSE;
+ gboolean is_vtodo = FALSE;
+
+ selected = e_attachment_view_get_selected_attachments (view);
+
+ if (g_list_length (selected) != 1)
+ goto exit;
+
+ attachment = E_ATTACHMENT (selected->data);
+ component = attachment_handler_get_component (attachment);
+
+ if (component == NULL)
+ goto exit;
+
+ subcomponent = icalcomponent_get_inner (component);
+
+ if (subcomponent == NULL)
+ goto exit;
+
+ kind = icalcomponent_isa (subcomponent);
+ is_vevent = (kind == ICAL_VEVENT_COMPONENT);
+ is_vtodo = (kind == ICAL_VTODO_COMPONENT);
+
+exit:
+ action = e_attachment_view_get_action (view, "import-to-calendar");
+ gtk_action_set_visible (action, is_vevent);
+
+ action = e_attachment_view_get_action (view, "import-to-tasks");
+ gtk_action_set_visible (action, is_vtodo);
+
+ g_list_foreach (selected, (GFunc) g_object_unref, NULL);
+ g_list_free (selected);
+}
+
+static void
+attachment_handler_calendar_constructed (GObject *object)
+{
+ EAttachmentHandler *handler;
+ EAttachmentView *view;
+ GtkActionGroup *action_group;
+ GtkUIManager *ui_manager;
+ const gchar *domain = GETTEXT_PACKAGE;
+ GError *error = NULL;
+
+ handler = E_ATTACHMENT_HANDLER (object);
+
+ /* Chain up to parent's constructed() method. */
+ G_OBJECT_CLASS (parent_class)->constructed (object);
+
+ view = e_attachment_handler_get_view (handler);
+ ui_manager = e_attachment_view_get_ui_manager (view);
+
+ action_group = gtk_action_group_new ("calendar");
+ gtk_action_group_set_translation_domain (action_group, domain);
+ gtk_action_group_add_actions (
+ action_group, standard_entries,
+ G_N_ELEMENTS (standard_entries), handler);
+ gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
+ g_object_unref (action_group);
+
+ gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
+
+ if (error != NULL) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+
+ g_signal_connect (
+ view, "update_actions",
+ G_CALLBACK (attachment_handler_calendar_update_actions),
+ NULL);
+}
+
+static void
+attachment_handler_calendar_class_init (EAttachmentHandlerCalendarClass *class)
+{
+ GObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EAttachmentHandlerCalendarPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->constructed = attachment_handler_calendar_constructed;
+}
+
+static void
+attachment_handler_calendar_init (EAttachmentHandlerCalendar *handler)
+{
+ handler->priv = E_ATTACHMENT_HANDLER_CALENDAR_GET_PRIVATE (handler);
+}
+
+GType
+e_attachment_handler_calendar_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (EAttachmentHandlerCalendarClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) attachment_handler_calendar_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EAttachmentHandlerCalendar),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) attachment_handler_calendar_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ E_TYPE_ATTACHMENT_HANDLER,
+ "EAttachmentHandlerCalendar", &type_info, 0);
+ }
+
+ return type;
+}
diff --git a/calendar/gui/e-attachment-handler-calendar.h b/calendar/gui/e-attachment-handler-calendar.h
new file mode 100644
index 0000000000..b6788611f8
--- /dev/null
+++ b/calendar/gui/e-attachment-handler-calendar.h
@@ -0,0 +1,65 @@
+/*
+ * e-attachment-handler-calendar.h
+ *
+ * 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 <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef E_ATTACHMENT_HANDLER_CALENDAR_H
+#define E_ATTACHMENT_HANDLER_CALENDAR_H
+
+#include <widgets/misc/e-attachment-handler.h>
+
+/* Standard GObject macros */
+#define E_TYPE_ATTACHMENT_HANDLER_CALENDAR \
+ (e_attachment_handler_calendar_get_type ())
+#define E_ATTACHMENT_HANDLER_CALENDAR(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_ATTACHMENT_HANDLER_CALENDAR, EAttachmentHandlerCalendar))
+#define E_ATTACHMENT_HANDLER_CALENDAR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_ATTACHMENT_HANDLER_CALENDAR, EAttachmentHandlerCalendarClass))
+#define E_IS_ATTACHMENT_HANDLER_CALENDAR(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_ATTACHMENT_HANDLER_CALENDAR))
+#define E_IS_ATTACHMENT_HANDLER_CALENDAR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_ATTACHMENT_HANDLER_CALENDAR))
+#define E_ATTACHMENT_HANDLER_CALENDAR_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_ATTACHMENT_HANDLER_CALENDAR, EAttachmentHandlerCalendarClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EAttachmentHandlerCalendar EAttachmentHandlerCalendar;
+typedef struct _EAttachmentHandlerCalendarClass EAttachmentHandlerCalendarClass;
+typedef struct _EAttachmentHandlerCalendarPrivate EAttachmentHandlerCalendarPrivate;
+
+struct _EAttachmentHandlerCalendar {
+ EAttachmentHandler parent;
+ EAttachmentHandlerCalendarPrivate *priv;
+};
+
+struct _EAttachmentHandlerCalendarClass {
+ EAttachmentHandlerClass parent_class;
+};
+
+GType e_attachment_handler_calendar_get_type (void);
+
+G_END_DECLS
+
+#endif /* E_ATTACHMENT_HANDLER_CALENDAR_H */
diff --git a/calendar/modules/e-cal-shell-module.c b/calendar/modules/e-cal-shell-module.c
index b3d296c3b0..15b5af2d20 100644
--- a/calendar/modules/e-cal-shell-module.c
+++ b/calendar/modules/e-cal-shell-module.c
@@ -36,6 +36,7 @@
#include "calendar/common/authentication.h"
#include "calendar/gui/calendar-config.h"
#include "calendar/gui/comp-util.h"
+#include "calendar/gui/e-attachment-handler-calendar.h"
#include "calendar/gui/e-cal-config.h"
#include "calendar/gui/e-cal-event.h"
#include "calendar/gui/dialogs/cal-prefs-dialog.h"
@@ -541,4 +542,6 @@ e_shell_module_init (GTypeModule *type_module)
cal_shell_module_init_hooks ();
cal_shell_module_init_importers ();
cal_shell_module_init_preferences (shell);
+
+ e_attachment_handler_calendar_get_type ();
}
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 91d71850fd..fd345d6410 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -152,7 +152,6 @@ e_composer_private_init (EMsgComposer *composer)
/* Construct the attachment paned. */
widget = e_attachment_paned_new ();
- /*gtk_container_set_border_width (GTK_CONTAINER (widget), 6);*/
gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
priv->attachment_paned = g_object_ref (widget);
gtk_widget_show (widget);
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index ad61b1b461..e8375d8b85 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -3419,7 +3419,10 @@ handle_mailto (EMsgComposer *composer, const gchar *mailto)
!g_ascii_strcasecmp (header, "attachment")) {
EAttachment *attachment;
- attachment = e_attachment_new_for_uri (content);
+ if (g_ascii_strncasecmp (content, "file:", 5) == 0)
+ attachment = e_attachment_new_for_uri (content);
+ else
+ attachment = e_attachment_new_for_path (content);
e_attachment_store_add_attachment (store, attachment);
e_attachment_load_async (
attachment, (GAsyncReadyCallback)
diff --git a/configure.in b/configure.in
index dc84ca7dbd..a899f9f30b 100644
--- a/configure.in
+++ b/configure.in
@@ -1780,7 +1780,7 @@ plugins_base_always="calendar-file calendar-http $CALENDAR_WEATHER itip-formatte
plugins_base="$plugins_base_always $SA_JUNK_PLUGIN $BF_JUNK_PLUGIN $EXCHANGE_PLUGIN $MONO_PLUGIN "
all_plugins_base="$plugins_base_always sa-junk-plugin bogo-junk-plugin exchange-operations mono"
-plugins_standard_always="bbdb subject-thread save-calendar copy-tool mail-to-task audio-inline mailing-list-actions default-mailer import-ics-attachments prefer-plain mail-notification attachment-reminder face backup-restore email-custom-header templates pst-import vcard-inline"
+plugins_standard_always="bbdb subject-thread save-calendar copy-tool mail-to-task audio-inline mailing-list-actions default-mailer prefer-plain mail-notification attachment-reminder face backup-restore email-custom-header templates pst-import vcard-inline"
plugins_standard="$plugins_standard_always"
all_plugins_standard="$plugins_standard"
@@ -1802,7 +1802,6 @@ dnl exchange-operations
dnl face
dnl folder-unsubscribe
dnl groupwise-features
-dnl import-ics-attachments
dnl ipod-sync
dnl itip-formatter
dnl mailing-list-actions
@@ -2122,7 +2121,6 @@ plugins/groupwise-account-setup/Makefile
plugins/groupwise-features/Makefile
plugins/hula-account-setup/Makefile
plugins/imap-features/Makefile
-plugins/import-ics-attachments/Makefile
plugins/ipod-sync/Makefile
plugins/itip-formatter/Makefile
plugins/mail-notification/Makefile
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index de965135c8..d413133c3d 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -462,7 +462,7 @@ efhd_format_attachment (EMFormat *emf,
info->encrypt = emf->valid->encrypt.status;
}
- camel_stream_write_string(
+ camel_stream_write_string (
stream, EM_FORMAT_HTML_VPAD
"<table cellspacing=0 cellpadding=0><tr><td>"
"<table width=10 cellspacing=0 cellpadding=0>"
@@ -1202,14 +1202,6 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje
{
EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)efh;
struct _attach_puri *info;
- GtkWidget *hbox, *w, *button, *mainbox;
- char *simple_type;
- GtkTargetEntry drag_types[] = {
- { NULL, 0, 0 },
- { "text/uri-list", 0, 1 },
- };
- AtkObject *a11y;
-
EAttachmentView *view;
EAttachmentStore *store;
EAttachment *attachment;
@@ -1259,39 +1251,6 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje
widget, "notify::expanded",
G_CALLBACK (efhd_attachment_button_expanded), info);
-#if 0
- /* FIXME: offline parts, just get icon */
- if (camel_content_type_is(((CamelDataWrapper *)pobject->part)->mime_type, "image", "*")) {
- EMFormatHTMLJob *job;
- GdkPixbuf *mini;
- char *key;
-
- key = pobject->classid;
- mini = em_icon_stream_get_image(key, 24, 24);
- if (mini) {
- d(printf("got image from cache '%s'\n", key));
- gtk_image_set_from_pixbuf((GtkImage *)w, mini);
- g_object_unref(mini);
- } else {
- d(printf("need to create icon image '%s'\n", key));
- job = em_format_html_job_new(efh, efhd_write_icon_job, pobject);
- job->stream = (CamelStream *)em_icon_stream_new((GtkImage *)w, key, 24, 24, FALSE);
- em_format_html_job_queue(efh, job);
- }
- }
-
- drag_types[0].target = simple_type;
- gtk_drag_source_set(button, GDK_BUTTON1_MASK, drag_types, sizeof(drag_types)/sizeof(drag_types[0]), GDK_ACTION_COPY);
- g_signal_connect(button, "drag-data-get", G_CALLBACK(efhd_drag_data_get), pobject);
- g_signal_connect (button, "drag-data-delete", G_CALLBACK(efhd_drag_data_delete), pobject);
- g_free(simple_type);
-
- g_signal_connect(button, "button_press_event", G_CALLBACK(efhd_attachment_popup), info);
- g_signal_connect(button, "popup_menu", G_CALLBACK(efhd_attachment_popup_menu), info);
- g_signal_connect(button, "clicked", G_CALLBACK(efhd_attachment_popup_menu), info);
- gtk_box_pack_start((GtkBox *)mainbox, button, TRUE, TRUE, 0);
-#endif
-
return TRUE;
}
@@ -1356,11 +1315,8 @@ efhd_message_add_bar (EMFormat *emf,
CamelMimePart *part,
const EMFormatHandler *info)
{
- EMFormatHTMLDisplayPrivate *priv;
const char *classid = "attachment-bar";
- priv = EM_FORMAT_HTML_DISPLAY_GET_PRIVATE (emf);
-
em_format_html_add_pobject (
EM_FORMAT_HTML (emf),
sizeof (EMFormatHTMLPObject),
diff --git a/mail/em-popup.c b/mail/em-popup.c
index e57b1de7f8..914b9840b5 100644
--- a/mail/em-popup.c
+++ b/mail/em-popup.c
@@ -98,12 +98,6 @@ emp_target_free(EPopup *ep, EPopupTarget *t)
g_free(s->uri);
break; }
- case EM_POPUP_TARGET_ATTACHMENTS: {
- EMPopupTargetAttachments *s = (EMPopupTargetAttachments *)t;
-
- g_slist_foreach(s->attachments, (GFunc)g_object_unref, NULL);
- g_slist_free(s->attachments);
- break; }
}
((EPopupClass *)emp_parent)->target_free(ep, t);
@@ -434,21 +428,11 @@ static const EPopupHookTargetMask emph_folder_masks[] = {
{ NULL }
};
-static const EPopupHookTargetMask emph_attachments_masks[] = {
- { "one", EM_POPUP_ATTACHMENTS_ONE },
- { "many", EM_POPUP_ATTACHMENTS_MANY },
- { "multiple", EM_POPUP_ATTACHMENTS_MULTIPLE },
- { "image", EM_POPUP_ATTACHMENTS_IMAGE },
- { "message", EM_POPUP_ATTACHMENTS_MESSAGE },
- { NULL }
-};
-
static const EPopupHookTargetMap emph_targets[] = {
{ "select", EM_POPUP_TARGET_SELECT, emph_select_masks },
{ "uri", EM_POPUP_TARGET_URI, emph_uri_masks },
{ "part", EM_POPUP_TARGET_PART, emph_part_masks },
{ "folder", EM_POPUP_TARGET_FOLDER, emph_folder_masks },
- { "attachments", EM_POPUP_TARGET_ATTACHMENTS, emph_attachments_masks },
{ NULL }
};
diff --git a/mail/em-popup.h b/mail/em-popup.h
index fbe41a310a..4d075ec9f7 100644
--- a/mail/em-popup.h
+++ b/mail/em-popup.h
@@ -43,7 +43,6 @@ typedef struct _EMPopupClass EMPopupClass;
* @EM_POPUP_TARGET_URI: A URI.
* @EM_POPUP_TARGET_PART: A CamelMimePart message part.
* @EM_POPUP_TARGET_FOLDER: A folder URI.
- * @EM_POPUP_TARGET_ATTACHMENTS: A list of attachments.
*
* Defines the value of the targetid for all EMPopup target types.
**/
@@ -52,7 +51,6 @@ enum _em_popup_target_t {
EM_POPUP_TARGET_URI,
EM_POPUP_TARGET_PART,
EM_POPUP_TARGET_FOLDER,
- EM_POPUP_TARGET_ATTACHMENTS,
};
/**
@@ -158,26 +156,10 @@ enum _em_popup_target_folder_t {
EM_POPUP_FOLDER_NONSTATIC = 1<<6, /* Except static folders like Outbox.*/
};
-/**
- * enum _em_popup_target_attachments_t - EMPopupTargetAttachments qualifiers.
- *
- * @EM_POPUP_ATTACHMENTS_ONE: There is one and only one attachment selected.
- * @EM_POPUP_ATTACHMENTS_MANY: There is one or more attachments selected.
- *
- **/
-enum _em_popup_target_attachments_t {
- EM_POPUP_ATTACHMENTS_ONE = 1<<0, /* only 1 selected */
- EM_POPUP_ATTACHMENTS_MANY = 1<<1, /* one or more selected */
- EM_POPUP_ATTACHMENTS_MULTIPLE = 1<<2, /* More than 1 selected */
- EM_POPUP_ATTACHMENTS_IMAGE = 1<<3, /* Image selected */
- EM_POPUP_ATTACHMENTS_MESSAGE = 1<<4 /* Message selected */
-};
-
typedef struct _EMPopupTargetSelect EMPopupTargetSelect;
typedef struct _EMPopupTargetURI EMPopupTargetURI;
typedef struct _EMPopupTargetPart EMPopupTargetPart;
typedef struct _EMPopupTargetFolder EMPopupTargetFolder;
-typedef struct _EMPopupTargetAttachments EMPopupTargetAttachments;
/**
* struct _EMPopupTargetURI - An inline URI.
@@ -241,20 +223,6 @@ struct _EMPopupTargetFolder {
char *uri;
};
-/**
- * struct _EMPopupTargetAttachments - A list of composer attachments.
- *
- * @target: Superclass.
- * @attachments: A GSList list of EMsgComposer attachments.
- *
- * This target is used to represent a selected list of attachments in
- * the message composer attachment area.
- **/
-struct _EMPopupTargetAttachments {
- EPopupTarget target;
- GSList *attachments;
-};
-
typedef struct _EPopupItem EMPopupItem;
/* The object */
@@ -276,7 +244,6 @@ EMPopupTargetURI *em_popup_target_new_uri(EMPopup *emp, const char *uri);
EMPopupTargetSelect *em_popup_target_new_select(EMPopup *emp, struct _CamelFolder *folder, const char *folder_uri, GPtrArray *uids);
EMPopupTargetPart *em_popup_target_new_part(EMPopup *emp, struct _CamelMimePart *part, const char *mime_type);
EMPopupTargetFolder *em_popup_target_new_folder(EMPopup *emp, const char *uri, guint32 info_flags, guint32 popup_flags);
-EMPopupTargetAttachments *em_popup_target_new_attachments(EMPopup *emp, GSList *attachments);
/* ********************************************************************** */
diff --git a/plugins/import-ics-attachments/ChangeLog b/plugins/import-ics-attachments/ChangeLog
deleted file mode 100644
index 21a9408c9c..0000000000
--- a/plugins/import-ics-attachments/ChangeLog
+++ /dev/null
@@ -1,109 +0,0 @@
-2009-01-21 Milan Crha <mcrha@redhat.com>
-
- * Makefile.am: Use also EVOLUTION_CALENDAR_CFLAGS.
-
-2008-09-02 Sankar P <psankar@novell.com>
-
-License Changes
-
- * icsimporter.c:
-
-2008-08-12 Bharath Acharya <abharath@novell.com>
-
- * Makefile.am: Added necessary libraries to link to. Build break while
- compiling on Windows.
-
-2008-08-11 Matthew Barnes <mbarnes@redhat.com>
-
- ** Fixes part of bug #546892
-
- * icsimporter.c:
- Prefer gtk_image_new_from_icon_name() over e_icon_factory_get_image().
-
-2008-04-17 Milan Crha <mcrha@redhat.com>
-
- ** Part of fix for bug #526739
-
- * icsimporter.c: Do not include gnome-vfs.
-
-2007-02-20 Paul Bolle <pebolle@tiscali.nl>
-
- ** Fix for bug #517082
-
- * icsimporter.c: (init_widgets): Fix small leak.
-
-2008-02-06 Milan Crha <mcrha@redhat.com>
-
- ** Fix for bug #514622
-
- * icsimporter.c: (dialog_close_cb): Drop this function.
- * icsimporter.c: (init_widgets), (dialog_response_cb),
- (ical_import_done): Do not call "close" on already closed dialog.
-
-2007-10-01 Milan Crha <mcrha@redhat.com>
-
- * icsimporter.c: (prepare_events), (prepare_tasks):
- Really go through every component when removing one.
-
-2007-06-03 Srinivasa Ragavan <sragavan@novell.com>
-
- ** Fix for version removal from Installed files from Gilles Dartiguelongue
-
- * Makefile.am:
-
-2007-05-12 Matthew Barnes <mbarnes@redhat.com>
-
- ** Fixes part of bug #337616
-
- * Makefile.am: Add "eplug" file to CLEANFILES.
-
-2007-03-27 Matthew Barnes <mbarnes@redhat.com>
-
- * icsimporter.c: Don't mix declarations and code (#405495).
-
-2007-03-20 Matthew Barnes <mbarnes@redhat.com>
-
- ** Fixes part of bug #419524
-
- * Include <glib/gi18n.h> instead of <libgnome/gnome-i18n.h>.
-
-2006-11-28 Parthasarathi Susarla <ajaysusarla@gmail.com>
-
- ** Fix bug #348679
-
- * icsimporter.c: (org_gnome_evolution_import_ics_attachment):
- Do not access structure elements directly. Use the methods of the
- class in the CamelDataWrapper Class
-
-2006-08-28 Kjartan Maraas <kmaraas@gnome.org>
-
- * org-gnome-evolution-mail-attachments-import-ics.eplug.xml: Mark
- name and description for translation.
-
-2006-08-23 Srinivasa Ragavan <sragavan@novell.com>
-
- ** Fix for bug #347248
-
- * icsimporter.c: (get_menu_type), (import_ics): Update the
- em_utils_temp_save_part to use readwrite mode.
-
-2006-02-21 Chenthill Palanisamy <pchenthill@novell.com>
-
- reviewed by Veerapuram Varadhan <vvaradhan@novell.com>
-
- Fixes a crash
- * icsimporter.c: (org_gnome_evolution_import_ics_attachments):
- If the number of attachments selected is not equal to one, just return;
-
-
-2006-01-22 Harish Krishnaswamy <kharish@novell.com>
-
- * icsimporter.c (get_menu_type), (dialog_response_cb),
- (dialog_close_cb), (get_icalcomponent_from_file):
- Fix twenty odd compiler warnings and style oddness.
-
-2006-01-17 Harish Krishnaswamy <kharish@novell.com>
-
- * import-ics-attachments : Initial commits. Plugin written and submitted by
- Johnny Jacob <johnnyjacob@gmail.com>
-
diff --git a/plugins/import-ics-attachments/Makefile.am b/plugins/import-ics-attachments/Makefile.am
deleted file mode 100644
index baded42123..0000000000
--- a/plugins/import-ics-attachments/Makefile.am
+++ /dev/null
@@ -1,35 +0,0 @@
-INCLUDES = \
- -I$(top_srcdir)\
- -I$(top_srcdir)/camel \
- -I$(top_srcdir)/widgets/misc \
- $(EVOLUTION_MAIL_CFLAGS) \
- $(EVOLUTION_CALENDAR_CFLAGS) \
- -DEVOLUTION_DATADIR=\""$(datadir)"\" \
- -DEVOLUTION_PRIVDATADIR=\""$(privdatadir)"\" \
- -DEVOLUTION_ICONSDIR=\""$(imagesdir)"\" \
- -DEVOLUTION_IMAGES=\""$(imagesdir)"\" \
- -DEVOLUTION_BUTTONSDIR=\""$(buttonsdir)"\" \
- -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \
- -DEVOLUTION_UIDIR=\""$(evolutionuidir)"\" \
- -DCAMEL_PROVIDERDIR=\""$(camel_providerdir)"\" \
- -DPLUGINDIR=\""$(plugindir)"\" \
- -DPREFIX=\""$(prefix)"\"
-
-@EVO_PLUGIN_RULE@
-
-plugin_DATA = org-gnome-evolution-mail-attachments-import-ics.eplug
-plugin_LTLIBRARIES = liborg-gnome-evolution-mail-attachments-import-ics.la
-
-liborg_gnome_evolution_mail_attachments_import_ics_la_SOURCES = icsimporter.c
-liborg_gnome_evolution_mail_attachments_import_ics_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED)
-liborg_gnome_evolution_mail_attachments_import_ics_la_LIBADD = \
- $(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/mail/libevolution-mail.la \
- $(top_builddir)/calendar/common/libevolution-calendarprivate.la \
- $(EVOLUTION_CALENDAR_LIBS) \
- $(EVOLUTION_MAIL_LIBS)
-
-EXTRA_DIST = org-gnome-evolution-mail-attachments-import-ics.eplug.xml
-
-BUILT_SOURCES = $(plugin_DATA)
-CLEANFILES = $(BUILT_SOURCES)
diff --git a/plugins/import-ics-attachments/icsimporter.c b/plugins/import-ics-attachments/icsimporter.c
deleted file mode 100644
index 096ccdec9a..0000000000
--- a/plugins/import-ics-attachments/icsimporter.c
+++ /dev/null
@@ -1,434 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Johnny Jacob <johnnyjacob@gmail.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <string.h>
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-#include <e-util/e-config.h>
-#include <e-util/e-popup.h>
-#include <mail/em-popup.h>
-#include <mail/em-menu.h>
-#include <mail/mail-ops.h>
-#include <mail/mail-mt.h>
-#include <mail/em-folder-view.h>
-#include <mail/em-format-html-display.h>
-#include <mail/em-utils.h>
-#include <camel/camel-vee-folder.h>
-#include "e-util/e-error.h"
-#include <libedataserverui/e-source-selector.h>
-#include <libecal/e-cal.h>
-#include <libical/icalvcal.h>
-#include <calendar/common/authentication.h>
-
-typedef struct {
- ECal *client;
- int source_type;
- icalcomponent *icalcomp;
- GtkWidget *window;
- GtkWidget *selector;
-} ICalImporterData;
-
-
-static void import_ics (EPlugin *ep, EPopupTarget *t, void *data);
-static icalcomponent* get_icalcomponent_from_file(char *filename);
-static void prepare_events (icalcomponent *icalcomp, GList **vtodos);
-static void prepare_tasks (icalcomponent *icalcomp, GList *vtodos);
-static void import_items(ICalImporterData *icidata);
-static gboolean update_objects (ECal *client, icalcomponent *icalcomp);
-static void dialog_response_cb (GtkDialog *dialog, gint response_id, ICalImporterData *icidata);
-static void ical_import_done(ICalImporterData *icidata);
-static void init_widgets (char *path);
-static icalcomponent_kind get_menu_type (void *data);
-
-void org_gnome_evolution_import_ics_attachments (EPlugin *ep, EMPopupTargetAttachments *t);
-void org_gnome_evolution_import_ics_part (EPlugin *ep, EMPopupTargetPart *t);
-
-static void
-popup_free (EPopup *ep, GSList *items, void *data)
-{
- g_slist_free (items);
-}
-
-static EPopupItem popup_calendar_items[] = {
- { E_POPUP_BAR, "25.display.00"},
- { E_POPUP_ITEM, "25.display.01", N_("_Import to Calendar"), (EPopupActivateFunc)import_ics, NULL, "stock_mail-import"}
-};
-
-static EPopupItem popup_tasks_items[] = {
- { E_POPUP_BAR, "25.display.00"},
- { E_POPUP_ITEM, "25.display.01", N_("_Import to Tasks"), (EPopupActivateFunc)import_ics, NULL, "stock_mail-import"}
-};
-
-
-void org_gnome_evolution_import_ics_attachments (EPlugin *ep, EMPopupTargetAttachments *t)
-{
- GSList *menus = NULL;
- icalcomponent_kind kind;
- int len = 0;
- int i = 0;
- CamelContentType *type;
-
- len = g_slist_length(t->attachments);
-
- if (len != 1)
- return;
-
- type = camel_data_wrapper_get_mime_type_field (((CamelDataWrapper *) ((EAttachment *) t->attachments->data)->body));
- if (type && camel_content_type_is(type, "text", "calendar")) {
-
- kind = get_menu_type (t);
-
- if (kind == ICAL_VTODO_COMPONENT ) {
- for (i = 0; i < sizeof (popup_tasks_items) / sizeof (popup_tasks_items[0]); i++)
- menus = g_slist_prepend (menus, &popup_tasks_items[i]);
- } else if ( kind == ICAL_VEVENT_COMPONENT) {
- for (i = 0; i < sizeof (popup_calendar_items) / sizeof (popup_calendar_items[0]); i++)
- menus = g_slist_prepend (menus, &popup_calendar_items[i]);
- }
-
- e_popup_add_items (t->target.popup, menus, NULL, popup_free, t);
- }
-}
-
-void org_gnome_evolution_import_ics_part (EPlugin*ep, EMPopupTargetPart *t)
-{
- GSList *menus = NULL;
- icalcomponent_kind kind;
- int i = 0;
-
- if (!camel_content_type_is(((CamelDataWrapper *) t->part)->mime_type, "text", "calendar"))
- return;
-
- kind = get_menu_type (t);
-
- if (kind == ICAL_VTODO_COMPONENT ) {
- for (i = 0; i < sizeof (popup_tasks_items) / sizeof (popup_tasks_items[0]); i++)
- menus = g_slist_prepend (menus, &popup_tasks_items[i]);
- } else if ( kind == ICAL_VEVENT_COMPONENT) {
- for (i = 0; i < sizeof (popup_calendar_items) / sizeof (popup_calendar_items[0]); i++)
- menus = g_slist_prepend (menus, &popup_calendar_items[i]);
- }
-
- e_popup_add_items (t->target.popup, menus, NULL, popup_free, t);
-}
-
-static icalcomponent_kind
-get_menu_type (void *data)
-{
- CamelMimePart *part;
- char *path;
- icalcomponent *icalcomp, *subcomp;
- icalcomponent_kind kind;
- EPopupTarget *target = (EPopupTarget *) data;
-
- if (target->type == EM_POPUP_TARGET_ATTACHMENTS)
- part = ((EAttachment *) ((EMPopupTargetAttachments *) target)->attachments->data)->body;
- else
- part = ((EMPopupTargetPart *) target)->part;
-
- path = em_utils_temp_save_part (NULL, part, FALSE);
-
- icalcomp = get_icalcomponent_from_file (path);
-
- subcomp = icalcomponent_get_inner(icalcomp);
- kind = icalcomponent_isa (subcomp);
-
- if (kind == ICAL_VTODO_COMPONENT ) {
- return ICAL_VTODO_COMPONENT;
- } else if ( kind == ICAL_VEVENT_COMPONENT) {
- return ICAL_VEVENT_COMPONENT;
- }
- return ICAL_NO_COMPONENT;
-}
-
-static void
-import_ics (EPlugin *ep, EPopupTarget *t, void *data)
-{
- CamelMimePart *part;
- char *path;
- EPopupTarget *target = (EPopupTarget *) data;
-
- if (target->type == EM_POPUP_TARGET_ATTACHMENTS)
- part = ((EAttachment *) ((EMPopupTargetAttachments *) target)->attachments->data)->body;
- else
- part = ((EMPopupTargetPart *) target)->part;
-
- path = em_utils_temp_save_part (NULL, part, FALSE);
- init_widgets(path);
-}
-
-static void
-init_widgets(char *path)
-{
-
- GtkWidget *vbox, *hbox, *dialog;
- icalcomponent_kind kind;
- icalcomponent *subcomp;
- GtkWidget *selector, *label;
- ESourceList *source_list;
- ESource *primary;
- GtkWidget *scrolled;
- ICalImporterData *icidata = g_malloc0(sizeof(*icidata));
- GtkWidget *icon, *button;
- char *label_str = NULL;
- char *markup;
-
- g_return_if_fail ( path != NULL);
- dialog = gtk_dialog_new_with_buttons (_("Import ICS"),
- NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- NULL);
- icidata->window = dialog;
- g_signal_connect (dialog,
- "response",
- G_CALLBACK (dialog_response_cb),
- icidata);
-
- vbox = GTK_DIALOG(dialog)->vbox;
- hbox = gtk_hbox_new (FALSE, FALSE);
- label = gtk_label_new(NULL);
-
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 6);
-
- icidata->icalcomp = get_icalcomponent_from_file (path);
-
- subcomp = icalcomponent_get_inner(icidata->icalcomp);
- kind = icalcomponent_isa (subcomp);
-
- if (kind == ICAL_VTODO_COMPONENT ) {
- e_cal_get_sources (&source_list, E_CAL_SOURCE_TYPE_TODO, NULL);
- label_str = _("Select Task List");
- icidata->source_type = E_CAL_SOURCE_TYPE_TODO;
- } else if ( kind == ICAL_VEVENT_COMPONENT) {
- e_cal_get_sources (&source_list, E_CAL_SOURCE_TYPE_EVENT, NULL);
- label_str = _("Select Calendar");
- icidata->source_type = E_CAL_SOURCE_TYPE_EVENT;
- }
-
- markup = g_markup_printf_escaped ("<b>%s</b>", label_str);
- gtk_label_set_markup (GTK_LABEL (label), markup);
- g_free (markup);
- hbox = gtk_hbox_new (FALSE, FALSE);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 6);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 6);
-
- selector = e_source_selector_new (source_list);
- e_source_selector_show_selection (E_SOURCE_SELECTOR (selector), FALSE);
- scrolled = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_container_add((GtkContainer *)scrolled, selector);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled), GTK_SHADOW_IN);
- hbox = gtk_hbox_new (FALSE, FALSE);
- gtk_box_pack_start (GTK_BOX (hbox), scrolled, TRUE, TRUE, 6);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 6);
- icidata->selector = selector;
-
-
- /* FIXME What if no sources? */
- primary = e_source_list_peek_source_any (source_list);
- e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (selector), primary);
-
- g_object_unref (source_list);
- hbox = gtk_hbox_new (FALSE, FALSE);
- icon = gtk_image_new_from_icon_name (
- "stock_mail-import", GTK_ICON_SIZE_MENU);
- gtk_box_pack_start (GTK_BOX(hbox), icon, FALSE, FALSE, 6);
- label = gtk_label_new_with_mnemonic (_("_Import"));
- gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 6);
- gtk_widget_show(label);
- button = gtk_button_new ();
- gtk_container_add (GTK_CONTAINER (button), hbox);
- gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_OK);
- gtk_widget_grab_focus (button);
-
- gtk_window_set_default_size (GTK_WINDOW (dialog), 210,340);
- gtk_widget_show_all (dialog);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-}
-
-static void
-dialog_response_cb (GtkDialog *dialog, gint response_id, ICalImporterData *icidata)
-{
- switch (response_id) {
- case GTK_RESPONSE_OK :
- import_items(icidata);
- break;
-
- case GTK_RESPONSE_CANCEL :
- case GTK_RESPONSE_DELETE_EVENT :
- break;
- }
-}
-
-/* This removes all components except VEVENTs and VTIMEZONEs from the toplevel */
-static void
-prepare_events (icalcomponent *icalcomp, GList **vtodos)
-{
- icalcomponent *subcomp;
- icalcompiter iter;
-
- if (vtodos)
- *vtodos = NULL;
-
- 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)
- *vtodos = g_list_prepend (*vtodos, subcomp);
- else
- icalcomponent_free (subcomp);
- } else {
- icalcompiter_next (&iter);
- }
- }
-}
-
-/* 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);
- } else {
- icalcompiter_next (&iter);
- }
- }
-
- for (elem = vtodos; elem; elem = elem->next) {
- icalcomponent_add_component (icalcomp, elem->data);
- }
- g_list_free (vtodos);
-}
-
-static void
-import_items(ICalImporterData *icidata)
-{
- ESource *source;
- g_return_if_fail (icidata != NULL);
-
- source = e_source_selector_peek_primary_selection ((ESourceSelector *)icidata->selector);
- g_return_if_fail ( source != NULL);
-
- icidata->client = auth_new_cal_from_source (source, icidata->source_type);
- e_cal_open (icidata->client, FALSE, NULL);
-
- switch (icidata->source_type) {
- case E_CAL_SOURCE_TYPE_EVENT:
- prepare_events (icidata->icalcomp, NULL);
- if (!update_objects (icidata->client, icidata->icalcomp))
- /* FIXME: e_error ... */;
- break;
- case E_CAL_SOURCE_TYPE_TODO:
- prepare_tasks (icidata->icalcomp, NULL);
- if (!update_objects (icidata->client, icidata->icalcomp))
- /* FIXME: e_error ... */;
- break;
- default:
- g_assert_not_reached ();
- }
- ical_import_done (icidata);
-}
-
-static gboolean
-update_objects (ECal *client, icalcomponent *icalcomp)
-{
- icalcomponent_kind kind;
- icalcomponent *vcal;
- gboolean success = TRUE;
-
- kind = icalcomponent_isa (icalcomp);
-
- if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT) {
- vcal = e_cal_util_new_top_level ();
- if (icalcomponent_get_method (icalcomp) == ICAL_METHOD_CANCEL)
- icalcomponent_set_method (vcal, ICAL_METHOD_CANCEL);
- else
- icalcomponent_set_method (vcal, ICAL_METHOD_PUBLISH);
- icalcomponent_add_component (vcal, icalcomponent_new_clone (icalcomp));
- } else if (kind == ICAL_VCALENDAR_COMPONENT) {
- vcal = icalcomponent_new_clone (icalcomp);
- if (!icalcomponent_get_first_property (vcal, ICAL_METHOD_PROPERTY))
- icalcomponent_set_method (vcal, ICAL_METHOD_PUBLISH);
- } else
- return FALSE;
-
- if (!e_cal_receive_objects (client, vcal, NULL))
- success = FALSE;
-
- icalcomponent_free (vcal);
-
- return success;
-}
-
-static void
-ical_import_done(ICalImporterData *icidata)
-{
- g_object_unref (icidata->client);
- icalcomponent_free (icidata->icalcomp);
- g_free (icidata);
-}
-
-static icalcomponent *
-get_icalcomponent_from_file(char *filename)
-{
- char *contents;
- icalcomponent *icalcomp;
-
- g_return_val_if_fail (filename != NULL, NULL);
-
- if (!g_file_get_contents (filename, &contents, NULL, NULL)) {
- g_free (filename);
- return NULL;
- }
- g_free (filename);
-
- icalcomp = e_cal_util_parse_ics_string (contents);
- g_free (contents);
-
- if (icalcomp) {
- return icalcomp;
- }
- return NULL;
-}
diff --git a/plugins/import-ics-attachments/org-gnome-evolution-mail-attachments-import-ics.eplug.xml b/plugins/import-ics-attachments/org-gnome-evolution-mail-attachments-import-ics.eplug.xml
deleted file mode 100644
index 745d0fb724..0000000000
--- a/plugins/import-ics-attachments/org-gnome-evolution-mail-attachments-import-ics.eplug.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0"?>
-<e-plugin-list>
- <!-- the path to the shared library -->
- <e-plugin
- id="org.gnome.evolution.mail.attachments.import.ics"
- type="shlib"
- location="@PLUGINDIR@/liborg-gnome-evolution-mail-attachments-import-ics@SOEXT@"
- _name="Import to Calendar">
-
- <author name="Johnny Jacob" email="johnnyjacob@gmail.com"/>
- <_description>Imports ICS attachments to calendar.</_description>
-
- <hook class="org.gnome.evolution.mail.popup:1.0">
- <menu id="org.gnome.evolution.mail.formathtmldisplay.popup" target="part" factory="org_gnome_evolution_import_ics_part">
- </menu>
- </hook>
- <hook class="org.gnome.evolution.mail.popup:1.0">
- <menu id="org.gnome.evolution.mail.attachments.popup" target="attachments" factory="org_gnome_evolution_import_ics_attachments">
- </menu>
- </hook>
- <hook class="org.gnome.evolution.mail.popup:1.0">
- <menu target="attachments" id="org.gnome.evolution.mail.composer.attachmentbar.popup" factory="org_gnome_evolution_import_ics_attachments">
- </menu>
- </hook>
- </e-plugin>
-</e-plugin-list>