From 4449a34101406bffe508dd40b8b653f7c7d14c7d Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 27 Apr 2009 15:36:19 -0400 Subject: Commit the rest of the attachment UI rewrite Oops, last commit only included the -new- files. This also removes EExpander, which is no longer used. --- plugins/attachment-reminder/attachment-reminder.c | 13 +- plugins/import-ics-attachments/ChangeLog | 109 ------ plugins/import-ics-attachments/Makefile.am | 35 -- plugins/import-ics-attachments/icsimporter.c | 435 --------------------- ...evolution-mail-attachments-import-ics.eplug.xml | 26 -- plugins/save-attachments/ChangeLog | 102 ----- plugins/save-attachments/Makefile.am | 31 -- .../org-gnome-save-attachments.eplug.xml | 26 -- .../org-gnome-save-attachments.xml | 20 - plugins/save-attachments/save-attachments.c | 392 ------------------- 10 files changed, 8 insertions(+), 1181 deletions(-) delete mode 100644 plugins/import-ics-attachments/ChangeLog delete mode 100644 plugins/import-ics-attachments/Makefile.am delete mode 100644 plugins/import-ics-attachments/icsimporter.c delete mode 100644 plugins/import-ics-attachments/org-gnome-evolution-mail-attachments-import-ics.eplug.xml delete mode 100644 plugins/save-attachments/ChangeLog delete mode 100644 plugins/save-attachments/Makefile.am delete mode 100644 plugins/save-attachments/org-gnome-save-attachments.eplug.xml delete mode 100644 plugins/save-attachments/org-gnome-save-attachments.xml delete mode 100644 plugins/save-attachments/save-attachments.c (limited to 'plugins') diff --git a/plugins/attachment-reminder/attachment-reminder.c b/plugins/attachment-reminder/attachment-reminder.c index 15bac58080..8634ce4000 100644 --- a/plugins/attachment-reminder/attachment-reminder.c +++ b/plugins/attachment-reminder/attachment-reminder.c @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -43,9 +44,10 @@ #include -#include "widgets/misc/e-attachment-bar.h" #include "composer/e-msg-composer.h" #include "composer/e-composer-actions.h" +#include "widgets/misc/e-attachment-view.h" +#include "widgets/misc/e-attachment-store.h" #define GCONF_KEY_ATTACH_REMINDER_CLUES "/apps/evolution/mail/attachment_reminder_clues" #define SIGNATURE "-- " @@ -182,12 +184,13 @@ check_for_attachment_clues (gchar *msg) static gboolean check_for_attachment (EMsgComposer *composer) { - EAttachmentBar* bar = (EAttachmentBar*)e_msg_composer_get_attachment_bar (composer); + EAttachmentView *view; + EAttachmentStore *store; - if (e_attachment_bar_get_num_attachments (bar)) - return TRUE; + view = e_msg_composer_get_attachment_view (composer); + store = e_attachment_view_get_store (view); - return FALSE; + return (e_attachment_store_get_num_attachments (store) > 0); } static gchar* 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 - - * Makefile.am: Use also EVOLUTION_CALENDAR_CFLAGS. - -2008-09-02 Sankar P - -License Changes - - * icsimporter.c: - -2008-08-12 Bharath Acharya - - * Makefile.am: Added necessary libraries to link to. Build break while - compiling on Windows. - -2008-08-11 Matthew Barnes - - ** 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 - - ** Part of fix for bug #526739 - - * icsimporter.c: Do not include gnome-vfs. - -2007-02-20 Paul Bolle - - ** Fix for bug #517082 - - * icsimporter.c: (init_widgets): Fix small leak. - -2008-02-06 Milan Crha - - ** 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 - - * icsimporter.c: (prepare_events), (prepare_tasks): - Really go through every component when removing one. - -2007-06-03 Srinivasa Ragavan - - ** Fix for version removal from Installed files from Gilles Dartiguelongue - - * Makefile.am: - -2007-05-12 Matthew Barnes - - ** Fixes part of bug #337616 - - * Makefile.am: Add "eplug" file to CLEANFILES. - -2007-03-27 Matthew Barnes - - * icsimporter.c: Don't mix declarations and code (#405495). - -2007-03-20 Matthew Barnes - - ** Fixes part of bug #419524 - - * Include instead of . - -2006-11-28 Parthasarathi Susarla - - ** 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 - - * org-gnome-evolution-mail-attachments-import-ics.eplug.xml: Mark - name and description for translation. - -2006-08-23 Srinivasa Ragavan - - ** 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 - - reviewed by Veerapuram Varadhan - - 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 - - * 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 - - * import-ics-attachments : Initial commits. Plugin written and submitted by - Johnny Jacob - 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 fbd5e46518..0000000000 --- a/plugins/import-ics-attachments/icsimporter.c +++ /dev/null @@ -1,435 +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: - * Johnny Jacob - * - * 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 -#include -#include -#include -#include "e-attachment-bar.h" -#include -#include "e-util/e-error.h" -#include -#include -#include -#include - -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 ("%s", 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 @@ - - - - - - - <_description>Imports ICS attachments to calendar. - - - - - - - - - - - - - - - diff --git a/plugins/save-attachments/ChangeLog b/plugins/save-attachments/ChangeLog deleted file mode 100644 index 9980fdf13d..0000000000 --- a/plugins/save-attachments/ChangeLog +++ /dev/null @@ -1,102 +0,0 @@ -2009-01-28 Tor Lillqvist - - * Makefile.am: Use -no-undefined and link with more libs on - Windows. - -2008-09-19 Sankar P - -License Changes - - * save-attachments.c: - -2007-12-20 Matthew Barnes - - ** Fixes part of bug #362638 - - * save-attachments.c: - Use the new MailMsg API for messages. - -2007-04-02 Sankar P - - * Committed on behalf of Gilles Dartiguelongue - - * org-gnome-save-attachments.eplug.xml: - Cleanup. - Fixes part of #301149 - -2007-03-29 Matthew Barnes - - * save-attachments.c: - Evolution requires GLib 2.10 now; remove dead backward-compatibility - code for GLib < 2.8 (#418971). - -2007-01-27 Nickolay V. Shmyrev - - * save-attachments.c: (save_got_message): - mark strings as translatable. See bug #399381 for details. - -2006-07-07 Hiroyuki Ikezoe - - ** Fixes bug #341369 - * save-attachments.c: fixing a memory leak. - -2006-02-28 Shi Pu - - ** Fixes #323853 - - * save-attachments.c: (save_response), (entry_changed), - (save_got_message): - replace GnomeFileEntry by GtkFileChooserButton. - -2005-12-17 Tor Lillqvist - - * save-attachments.c (entry_changed): Use GLib API to manipulate - pathname. - -2005-05-16 Not Zed - - * save-attachments.c: moved e-error to e-util - -2005-05-13 Rodney Dawes - - * org-gnome-save-attachments.xml: Update for new menu layout - -2005-05-12 Not Zed - - * Makefile.am: setup built_sources/cleanfiles. - -2005-05-06 Not Zed - - * Makefile.am: - * org-gnome-save-attachments.eplug.xml: s/.in/.xml/ & i18n. - -2005-02-24 Björn Torkelsson - - * org-gnome-save-attachments.eplug.in: Removed plugin from the - name. - Fixed description and added author - -2005-02-07 Not Zed - - * save-attachments.c (save_part): fix the access() call test. - -2005-01-04 Philip Van Hoof - - * save-attachments.c: Use standard error messages - -2004-12-27 Philip Van Hoof - - * save-attachments.c: Warning when overwriting file - -2004-11-01 JP Rosevear - - * Makefile.am: dist xml menu file - -2004-11-01 JP Rosevear - - * Makefile.am: dist .eplug.in file - -2004-10-20 Not Zed - - * Imported save-attachments example plugin. - diff --git a/plugins/save-attachments/Makefile.am b/plugins/save-attachments/Makefile.am deleted file mode 100644 index 05c724a4e4..0000000000 --- a/plugins/save-attachments/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -if OS_WIN32 -NO_UNDEFINED_REQUIRED_LIBS = \ - $(top_builddir)/mail/libevolution-mail.la \ - $(EVOLUTION_MAIL_LIBS) \ - $(GNOME_PLATFORM_LIBS) \ - $(top_builddir)/e-util/libeutil.la -endif - -INCLUDES = \ - -I$(top_srcdir) \ - $(EVOLUTION_MAIL_CFLAGS) - -@EVO_PLUGIN_RULE@ - -plugin_DATA = org-gnome-save-attachments.eplug org-gnome-save-attachments.xml -plugin_LTLIBRARIES = liborg-gnome-save-attachments.la - -liborg_gnome_save_attachments_la_SOURCES = save-attachments.c -liborg_gnome_save_attachments_la_LDFLAGS = -module \ - -avoid-version $(NO_UNDEFINED) - -liborg_gnome_save_attachments_la_LIBADD = \ - $(NO_UNDEFINED_REQUIRED_LIBS) - - -EXTRA_DIST = \ - org-gnome-save-attachments.eplug.xml \ - org-gnome-save-attachments.xml - -BUILT_SOURCES = org-gnome-save-attachments.eplug -CLEANFILES = $(BUILT_SOURCES) diff --git a/plugins/save-attachments/org-gnome-save-attachments.eplug.xml b/plugins/save-attachments/org-gnome-save-attachments.eplug.xml deleted file mode 100644 index d51b341db4..0000000000 --- a/plugins/save-attachments/org-gnome-save-attachments.eplug.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - <_description>A plugin for saving all attachments or parts of a message at once. - - - - - - - - - - diff --git a/plugins/save-attachments/org-gnome-save-attachments.xml b/plugins/save-attachments/org-gnome-save-attachments.xml deleted file mode 100644 index 75f4aef7fb..0000000000 --- a/plugins/save-attachments/org-gnome-save-attachments.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - diff --git a/plugins/save-attachments/save-attachments.c b/plugins/save-attachments/save-attachments.c deleted file mode 100644 index c48711c55a..0000000000 --- a/plugins/save-attachments/save-attachments.c +++ /dev/null @@ -1,392 +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: - * Michael Zucchi - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -/* This is prototype code only, this may, or may not, use undocumented - * unstable or private internal function calls. */ - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "e-util/e-error.h" - -#include "mail/em-menu.h" -#include "mail/em-utils.h" - -/* these are sort of mail-internal */ -#include "mail/mail-mt.h" -#include "mail/mail-ops.h" - -void org_gnome_save_attachments_save(EPlugin *ep, EMMenuTargetSelect *target); - -struct _save_data { - CamelFolder *folder; - char *uid; - CamelMimeMessage *msg; - - char *path; - char *base; - - GtkWidget *entry; - GtkWidget *tree; - GtkTreeStore *model; -}; - -static void -free_data(struct _save_data *data) -{ - if (data->msg) - camel_object_unref(data->msg); - g_free(data->base); - g_free(data->path); - g_free(data->uid); - camel_object_unref(data->folder); - if (data->model) - g_object_unref(data->model); - g_free(data); -} - -static char * -clean_name(const char *s) -{ - GString *out = g_string_new(""); - int c; - char *r; - - while ( (c = camel_utf8_getc((const unsigned char **)&s)) ) { - if (!g_unichar_isprint(c) || ( c < 0x7f && strchr(" /'\"`&();|<>$%{}!", c ))) - c = '_'; - g_string_append_u(out, c); - } - - r = g_strdup(out->str); - g_string_free(out, TRUE); - - return r; -} - -static void -fill_model_rec(CamelMimeMessage *msg, CamelMimePart *part, GtkTreeStore *model, GtkTreeIter *parent, GString *name) -{ - CamelDataWrapper *containee; - int parts, i; - char *type; - GtkTreeIter iter; - int len = name->len; - CamelContentType *mime; - - containee = camel_medium_get_content_object((CamelMedium *)part); - if (containee == NULL) - return; - - mime = ((CamelDataWrapper *)containee)->mime_type; - type = camel_content_type_simple(mime); - - if (CAMEL_IS_MULTIPART(containee)) { - gtk_tree_store_append(model, &iter, parent); - g_string_append_printf(name, ".multipart"); - gtk_tree_store_set(model, &iter, 0, FALSE, 1, type, 2, name->str, 3, name->str, 4, part, -1); - - parts = camel_multipart_get_number((CamelMultipart *)containee); - for (i = 0; i < parts; i++) { - CamelMimePart *mpart = camel_multipart_get_part((CamelMultipart *)containee, i); - - g_string_truncate(name, len); - g_string_append_printf(name, ".%d", i); - fill_model_rec(msg, mpart, model, &iter, name); - } - } else if (CAMEL_IS_MIME_MESSAGE(containee)) { - gtk_tree_store_append(model, &iter, parent); - g_string_append_printf(name, ".msg"); - gtk_tree_store_set(model, &iter, 0, FALSE, 1, type, 2, name->str, 3, name->str, 4, part, -1); - fill_model_rec(msg, (CamelMimePart *)containee, model, &iter, name); - } else { - char *filename = NULL; - const char *ext = NULL, *tmp; - int save = FALSE; - - gtk_tree_store_append(model, &iter, parent); - tmp = camel_mime_part_get_filename(part); - if (tmp) { - filename = clean_name(tmp); - ext = strrchr(filename, '.'); - } - tmp = camel_mime_part_get_disposition(part); - if (tmp && !strcmp(tmp, "attachment")) - save = TRUE; - - if (camel_content_type_is(mime, "text", "*")) { - if (ext == NULL) { - if ((ext = mime->subtype) == NULL || !strcmp(ext, "plain")) - ext = "text"; - } - } else if (camel_content_type_is(mime, "image", "*")) { - if (ext == NULL) { - if ((ext = mime->subtype) == NULL) - ext = "image"; - } - save = TRUE; - } - - g_string_append_printf(name, ".%s", ext); - gtk_tree_store_set(model, &iter, 0, save, 1, type, 2, filename?filename:name->str, 3, filename?NULL:name->str, 4, part, -1); - g_free(filename); - } - g_free(type); - - g_string_truncate(name, len); -} - -static void -fill_model(CamelMimeMessage *msg, GtkTreeStore *model) -{ - GString *name = g_string_new(""); - GtkTreeIter iter; - - gtk_tree_store_append(model, &iter, NULL); - gtk_tree_store_set(model, &iter, 0, FALSE, 1, "message/rfc822", 2, ".msg", 3, ".msg", 4, msg, -1); - fill_model_rec(msg, (CamelMimePart *)msg, model, &iter, name); - g_string_free(name, TRUE); -} - -static gboolean -save_part(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, void *d) -{ - struct _save_data *data = d; - char *filename, *ext, *save; - CamelMimePart *part; - gboolean doit; - - /* TODO: check for existing file */ - - gtk_tree_model_get(model, iter, 0, &doit, -1); - if (!doit) - return FALSE; - - gtk_tree_model_get(model, iter, 2, &filename, 3, &ext, 4, &part, -1); - if (ext == NULL) - save = g_build_filename(data->path, filename, NULL); - else - save = g_strdup_printf("%s%s", data->base, ext); - - /* FIXME: if part == data->msg then we need to save this - * differently, not using the envelope MimePart */ - - /* - * The underlying em_utils_save_part_to_file ain't using gnome-vfs. Therefor - * the POSIX access-call should suffice for checking the file existence. - */ - - if (g_access(save, F_OK) == 0) - doit = e_error_run(NULL, E_ERROR_ASK_FILE_EXISTS_OVERWRITE, save, NULL) == GTK_RESPONSE_OK; - - if (doit) - em_utils_save_part_to_file(NULL, save, part); - - g_free(ext); - g_free(filename); - - return FALSE; -} - -static void -save_response(GtkWidget *d, int id, struct _save_data *data) -{ - if (id == GTK_RESPONSE_OK) { - char *tmp; - - data->base = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (data->entry)); - data->path = g_strdup(data->base); - tmp = strrchr(data->path, '/'); - if (tmp) - *tmp = 0; - gtk_tree_model_foreach((GtkTreeModel *)data->model, save_part, data); - } - - gtk_widget_destroy(d); - free_data(data); -} - -static gboolean -entry_changed_update(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, void *d) -{ - const char *name = d; - char *filename, *ext; - - gtk_tree_model_get(model, iter, 3, &ext, -1); - if (ext) { - filename = g_strdup_printf("%s%s", name, ext); - gtk_tree_store_set((GtkTreeStore *)model, iter, 2, filename, -1); - g_free(filename); - g_free(ext); - } - - return FALSE; -} - -static void -entry_changed(GtkWidget *entry, struct _save_data *data) -{ - char *path; - char *basename = NULL; - const char *file; - - path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (data->entry)); - if (path == NULL - || G_IS_DIR_SEPARATOR (path[strlen(path)-1]) - || (basename = g_path_get_basename(path)) == NULL - || (basename[0] == '.' && basename[1] == '\0') - || (g_file_test(path, G_FILE_TEST_IS_DIR))) - file = "attachment"; - else - file = basename; - - gtk_tree_model_foreach((GtkTreeModel *)data->model, entry_changed_update, (void *)file); - g_free(path); - g_free(basename); -} - -static void -toggle_changed(GtkWidget *entry, const char *spath, struct _save_data *data) -{ - GtkTreePath *path; - GtkTreeIter iter; - - path = gtk_tree_path_new_from_string(spath); - if (gtk_tree_model_get_iter((GtkTreeModel *)data->model, &iter, path)) { - gboolean on; - - gtk_tree_model_get((GtkTreeModel *)data->model, &iter, 0, &on, -1); - gtk_tree_store_set(data->model, &iter, 0, !on, -1); - } - - gtk_tree_path_free (path); -} - -static void -save_got_message(CamelFolder *folder, const char *uid, CamelMimeMessage *msg, void *d) -{ - struct _save_data *data = d; - GtkDialog *dialog; - GtkWidget *w, *tree; - GtkTreeStore *model; - GtkCellRenderer *renderer; - - /* not found, the mailer will show an error box for this */ - if (msg == NULL) { - free_data(data); - return; - } - - data->msg = msg; - camel_object_ref(msg); - - dialog = (GtkDialog *)gtk_dialog_new_with_buttons(_("Save attachments"), - NULL, /* target->parent? */ - 0, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_OK, - NULL); - w = gtk_file_chooser_button_new (_("Select save base name"), GTK_FILE_CHOOSER_ACTION_OPEN); - data->entry = w; - g_object_set(w, "filechooser_action", GTK_FILE_CHOOSER_ACTION_SAVE, NULL); - gtk_widget_show(w); - gtk_box_pack_start((GtkBox *)dialog->vbox, w, FALSE, TRUE, 6); - - g_signal_connect(GTK_FILE_CHOOSER_BUTTON (w), "selection-changed", G_CALLBACK(entry_changed), data); - - model = gtk_tree_store_new(5, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); - data->model = model; - fill_model(msg, model); - - tree = gtk_tree_view_new_with_model((GtkTreeModel *)model); - data->tree = tree; - gtk_widget_show(tree); - gtk_tree_view_expand_all((GtkTreeView *)tree); - - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_insert_column_with_attributes((GtkTreeView *)tree, -1, - _("MIME Type"), renderer, "text", 1, NULL); - gtk_tree_view_set_expander_column((GtkTreeView *)tree, gtk_tree_view_get_column((GtkTreeView *)tree, 0)); - - renderer = gtk_cell_renderer_toggle_new(); - g_object_set(renderer, "activatable", TRUE, NULL); - g_signal_connect(renderer, "toggled", G_CALLBACK(toggle_changed), data); - - gtk_tree_view_insert_column_with_attributes((GtkTreeView *)tree, -1, - _("Save"), renderer, "active", 0, NULL); - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_insert_column_with_attributes((GtkTreeView *)tree, -1, - _("Name"), renderer, "text", 2, NULL); - - w = g_object_new(gtk_frame_get_type(), - "shadow_type", GTK_SHADOW_NONE, - "label_widget", g_object_new(gtk_label_get_type(), - "label", "Attachments", - "use_markup", TRUE, - "xalign", 0.0, NULL), - "child", g_object_new(gtk_alignment_get_type(), - "left_padding", 12, - "top_padding", 6, - "child", g_object_new(gtk_scrolled_window_get_type(), - "hscrollbar_policy", GTK_POLICY_AUTOMATIC, - "vscrollbar_policy", GTK_POLICY_AUTOMATIC, - "shadow_type", GTK_SHADOW_IN, - "child", tree, - NULL), - NULL), - NULL); - gtk_widget_show_all(w); - - gtk_box_pack_start((GtkBox *)dialog->vbox, w, TRUE, TRUE, 0); - g_signal_connect(dialog, "response", G_CALLBACK(save_response), data); - gtk_window_set_default_size((GtkWindow *)dialog, 500, 500); - gtk_widget_show((GtkWidget *)dialog); -} - -void -org_gnome_save_attachments_save(EPlugin *ep, EMMenuTargetSelect *target) -{ - struct _save_data *data; - - if (target->uids->len != 1) - return; - - data = g_malloc0(sizeof(*data)); - data->folder = target->folder; - camel_object_ref(data->folder); - data->uid = g_strdup(target->uids->pdata[0]); - - mail_get_message(data->folder, data->uid, save_got_message, data, mail_msg_unordered_push); -} -- cgit v1.2.3