aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTing-Wei Lan <lantw44@gmail.com>2013-09-10 23:19:10 +0800
committerLAN-TW <lantw44@gmail.com>2013-09-10 23:19:10 +0800
commit83a349654cc6bf1984e4d757094d63ab815d3e87 (patch)
treeb60063f48f51d61b794cc73fc2c3449013a4cf64
parent6ae3cd7747313301ad1484b1d7f5ccd7f9129c99 (diff)
downloadgsoc2013-evolution-archive-integration-review.tar
gsoc2013-evolution-archive-integration-review.tar.gz
gsoc2013-evolution-archive-integration-review.tar.bz2
gsoc2013-evolution-archive-integration-review.tar.lz
gsoc2013-evolution-archive-integration-review.tar.xz
gsoc2013-evolution-archive-integration-review.tar.zst
gsoc2013-evolution-archive-integration-review.zip
Make gnome-autoar be an optional dependencyarchive-integration-review
-rw-r--r--configure.ac31
-rw-r--r--e-util/Makefile.am2
-rw-r--r--e-util/e-attachment-store.c56
-rw-r--r--e-util/e-attachment-view.c1
-rw-r--r--e-util/e-attachment.c21
5 files changed, 101 insertions, 10 deletions
diff --git a/configure.ac b/configure.ac
index aa5df893f6..dd427e66f1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,6 +61,7 @@ m4_define([champlain_minimum_version], [0.12])
m4_define([clutter_gtk_minimum_version], [0.90])
m4_define([geoclue_minimum_version], [0.12.0])
m4_define([gladeui_minimum_version], [3.10.0])
+m4_define([gnome_autoar_minimum_version], [0.1])
m4_define([gweather_minimum_version], [3.5.0])
m4_define([libcanberra_gtk_minimum_version], [0.25])
m4_define([libnotify_minimum_version], [0.7])
@@ -287,8 +288,7 @@ PKG_CHECK_MODULES([GNOME_PLATFORM],
shared-mime-info >= shared_mime_info_minimum_version
gnome-desktop-3.0 >= gnome_desktop_minimum_version
gsettings-desktop-schemas >= gsettings_desktop_schemas_minimum_version
- webkitgtk-3.0 >= webkitgtk_minimum_version
- gnome-autoar])
+ webkitgtk-3.0 >= webkitgtk_minimum_version])
AC_SUBST(GNOME_PLATFORM_CFLAGS)
AC_SUBST(GNOME_PLATFORM_LIBS)
@@ -327,6 +327,32 @@ fi
AC_SUBST(CANBERRA_CFLAGS)
AC_SUBST(CANBERRA_LIBS)
+dnl ***********************************
+dnl Archives Integration / gnome-autoar
+dnl ***********************************
+AC_ARG_ENABLE([autoar],
+ [AS_HELP_STRING([--enable-autoar],
+ [Enable archives support in attachments @<:@default=yes@:>@])],
+ [enable_autoar="$enableval"], [enable_autoar=yes])
+
+if test x"$enable_autoar" = xyes; then
+ PKG_CHECK_MODULES(
+ [AUTOAR],
+ [gnome-autoar >= gnome_autoar_minimum_version],,
+ [AC_MSG_ERROR([
+
+ gnome-autoar not found (or version < gnome_autoar_minimum_version)
+
+ If you want to disable support for automatic archives handling,
+ please append --disable-autoar to configure.
+
+ ])])
+
+ AC_DEFINE(HAVE_AUTOAR, 1, [Define if gnome-autoar is enabled])
+fi
+AC_SUBST(AUTOAR_CFLAGS)
+AC_SUBST(AUTOAR_LIBS)
+
dnl ******************
dnl User Documentation
dnl ******************
@@ -1582,6 +1608,7 @@ fi
echo "
LDAP support: $msg_ldap
Contact Maps: $enable_contact_maps
+ Archives support: $enable_autoar
Libnotify: $HAVE_LIBNOTIFY
Kerberos 5: $msg_krb5
SSL support: $msg_ssl
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index f1fb677f43..369b2ce5aa 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -99,6 +99,7 @@ libevolution_util_la_CPPFLAGS = \
$(GNOME_PLATFORM_CFLAGS) \
$(GEO_CFLAGS) \
$(GTKHTML_CFLAGS) \
+ $(AUTOAR_CFLAGS) \
$(NULL)
evolution_util_include_HEADERS = \
@@ -574,6 +575,7 @@ libevolution_util_la_LIBADD = \
$(GNOME_PLATFORM_LIBS) \
$(GEO_LIBS) \
$(GTKHTML_LIBS) \
+ $(AUTOAR_LIBS) \
$(INTLLIBS) \
$(MATH_LIB) \
$(NULL)
diff --git a/e-util/e-attachment-store.c b/e-util/e-attachment-store.c
index ac52083de6..c261c92e63 100644
--- a/e-util/e-attachment-store.c
+++ b/e-util/e-attachment-store.c
@@ -28,7 +28,10 @@
#include <errno.h>
#include <glib/gi18n.h>
+
+#ifdef HAVE_AUTOAR
#include <gnome-autoar/autoar.h>
+#endif
#include "e-mktemp.h"
@@ -444,7 +447,9 @@ update_preview_cb (GtkFileChooser *file_chooser,
g_object_unref (pixbuf);
}
+#ifdef HAVE_AUTOAR
#define LOAD_RESPONSE_ATTACH 1
+#endif
void
e_attachment_store_run_load_dialog (EAttachmentStore *store,
@@ -457,10 +462,12 @@ e_attachment_store_run_load_dialog (EAttachmentStore *store,
GtkWidget *extra_box_widget;
GtkWidget *option_display;
+#ifdef HAVE_AUTOAR
GtkBox *option_format_box;
GtkWidget *option_format_box_widget;
GtkWidget *option_format_label;
GtkWidget *option_format_combo;
+#endif
GtkImage *preview;
@@ -469,9 +476,11 @@ e_attachment_store_run_load_dialog (EAttachmentStore *store,
gboolean active;
gint response;
+#ifdef HAVE_AUTOAR
GSettings *settings;
AutoarPref *arpref;
int format, filter;
+#endif
g_return_if_fail (E_IS_ATTACHMENT_STORE (store));
g_return_if_fail (GTK_IS_WINDOW (parent));
@@ -479,14 +488,25 @@ e_attachment_store_run_load_dialog (EAttachmentStore *store,
dialog = gtk_file_chooser_dialog_new (
_("Add Attachment"), parent,
GTK_FILE_CHOOSER_ACTION_OPEN,
+#ifdef HAVE_AUTOAR
_("_Open"), GTK_RESPONSE_OK,
+#endif
_("_Cancel"), GTK_RESPONSE_CANCEL,
- _("A_ttach"), LOAD_RESPONSE_ATTACH, NULL);
+#ifdef HAVE_AUTOAR
+ _("A_ttach"), LOAD_RESPONSE_ATTACH,
+#else
+ _("A_ttach"), GTK_RESPONSE_OK,
+#endif
+ NULL);
file_chooser = GTK_FILE_CHOOSER (dialog);
gtk_file_chooser_set_local_only (file_chooser, FALSE);
gtk_file_chooser_set_select_multiple (file_chooser, TRUE);
+#ifdef HAVE_AUTOAR
gtk_dialog_set_default_response (GTK_DIALOG (dialog), LOAD_RESPONSE_ATTACH);
+#else
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+#endif
gtk_window_set_icon_name (GTK_WINDOW (dialog), "mail-attachment");
preview = GTK_IMAGE (gtk_image_new ());
@@ -504,6 +524,7 @@ e_attachment_store_run_load_dialog (EAttachmentStore *store,
_("_Suggest automatic display of attachment"));
gtk_box_pack_start (extra_box, option_display, FALSE, FALSE, 0);
+#ifdef HAVE_AUTOAR
option_format_box_widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
option_format_box = GTK_BOX (option_format_box_widget);
gtk_box_pack_start (extra_box, option_format_box_widget, FALSE, FALSE, 0);
@@ -518,22 +539,29 @@ e_attachment_store_run_load_dialog (EAttachmentStore *store,
autoar_pref_get_default_filter (arpref));
gtk_box_pack_start (option_format_box, option_format_label, FALSE, FALSE, 0);
gtk_box_pack_start (option_format_box, option_format_combo, FALSE, FALSE, 0);
+#endif
gtk_file_chooser_set_extra_widget (file_chooser, extra_box_widget);
gtk_widget_show_all (extra_box_widget);
response = gtk_dialog_run (GTK_DIALOG (dialog));
+#ifdef HAVE_AUTOAR
if (response != GTK_RESPONSE_OK && response != LOAD_RESPONSE_ATTACH)
+#else
+ if (response != GTK_RESPONSE_OK)
+#endif
goto exit;
files = gtk_file_chooser_get_files (file_chooser);
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (option_display));
disposition = active ? "inline" : "attachment";
+#ifdef HAVE_AUTOAR
autoar_gtk_format_filter_simple_get (option_format_combo, &format, &filter);
autoar_pref_set_default_format (arpref, format);
autoar_pref_set_default_filter (arpref, filter);
+#endif
for (iter = files; iter != NULL; iter = g_slist_next (iter)) {
EAttachment *attachment;
@@ -544,8 +572,10 @@ e_attachment_store_run_load_dialog (EAttachmentStore *store,
e_attachment_set_disposition (attachment, disposition);
e_attachment_store_add_attachment (store, attachment);
+#ifdef HAVE_AUTOAR
g_object_set_data_full (G_OBJECT (attachment),
"autoar-pref", g_object_ref (arpref), g_object_unref);
+#endif
e_attachment_load_async (
attachment, (GAsyncReadyCallback)
@@ -558,9 +588,10 @@ e_attachment_store_run_load_dialog (EAttachmentStore *store,
exit:
gtk_widget_destroy (dialog);
+#ifdef HAVE_AUTOAR
g_object_unref (settings);
g_object_unref (arpref);
-
+#endif
}
GFile *
@@ -572,6 +603,7 @@ e_attachment_store_run_save_dialog (EAttachmentStore *store,
GtkFileChooserAction action;
GtkWidget *dialog;
+#ifdef HAVE_AUTOAR
GtkBox *extra_box;
GtkWidget *extra_box_widget;
@@ -584,6 +616,7 @@ e_attachment_store_run_save_dialog (EAttachmentStore *store,
GtkWidget *extract_yes;
GtkToggleButton *extract_yes_toggle;
+#endif
GFile *destination;
const gchar *title;
@@ -615,6 +648,7 @@ e_attachment_store_run_save_dialog (EAttachmentStore *store,
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
gtk_window_set_icon_name (GTK_WINDOW (dialog), "mail-attachment");
+#ifdef HAVE_AUTOAR
extra_box_widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
extra_box = GTK_BOX (extra_box_widget);
@@ -643,14 +677,18 @@ e_attachment_store_run_save_dialog (EAttachmentStore *store,
gtk_widget_show_all (extra_box_widget);
gtk_file_chooser_set_extra_widget (file_chooser, extra_box_widget);
+#endif
if (action == GTK_FILE_CHOOSER_ACTION_SAVE) {
EAttachment *attachment;
- AutoarPref *arpref;
- GSettings *settings;
GFileInfo *file_info;
const gchar *name = NULL;
+
+#ifdef HAVE_AUTOAR
+ AutoarPref *arpref;
+ GSettings *settings;
gchar *mime_type;
+#endif
attachment = attachment_list->data;
file_info = e_attachment_ref_file_info (attachment);
@@ -664,6 +702,7 @@ e_attachment_store_run_save_dialog (EAttachmentStore *store,
gtk_file_chooser_set_current_name (file_chooser, name);
+#ifdef HAVE_AUTOAR
mime_type = e_attachment_dup_mime_type (attachment);
settings = g_settings_new (AUTOAR_PREF_DEFAULT_GSCHEMA_ID);
arpref = autoar_pref_new_with_gsettings (settings);
@@ -672,18 +711,24 @@ e_attachment_store_run_save_dialog (EAttachmentStore *store,
gtk_toggle_button_set_active (extract_yes_toggle, FALSE);
}
- g_clear_object (&file_info);
g_clear_object (&settings);
g_clear_object (&arpref);
g_free (mime_type);
+#endif
+
+ g_clear_object (&file_info);
}
response = gtk_dialog_run (GTK_DIALOG (dialog));
if (response == GTK_RESPONSE_OK) {
+#ifdef HAVE_AUTOAR
gboolean save_self, save_extracted;
+#endif
destination = gtk_file_chooser_get_file (file_chooser);
+
+#ifdef HAVE_AUTOAR
save_self = !gtk_toggle_button_get_active (extract_yes_toggle) ||
!gtk_toggle_button_get_active (extract_only_toggle);
save_extracted = gtk_toggle_button_get_active (extract_yes_toggle);
@@ -727,6 +772,7 @@ e_attachment_store_run_save_dialog (EAttachmentStore *store,
g_object_unref (settings);
g_object_unref (arpref);
}
+#endif
} else {
destination = NULL;
}
diff --git a/e-util/e-attachment-view.c b/e-util/e-attachment-view.c
index 131e0c56d7..383fc12e21 100644
--- a/e-util/e-attachment-view.c
+++ b/e-util/e-attachment-view.c
@@ -257,7 +257,6 @@ action_save_all_cb (GtkAction *action,
GList *list, *iter;
GFile *destination;
gpointer parent;
- gboolean save_attachments, save_extracted_files;
store = e_attachment_view_get_store (view);
diff --git a/e-util/e-attachment.c b/e-util/e-attachment.c
index cd097f30a6..92df03417a 100644
--- a/e-util/e-attachment.c
+++ b/e-util/e-attachment.c
@@ -28,7 +28,10 @@
#include <errno.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
+
+#ifdef HAVE_AUTOAR
#include <gnome-autoar/autoar.h>
+#endif
#include <libedataserver/libedataserver.h>
@@ -2071,6 +2074,7 @@ attachment_load_file_read_cb (GFile *file,
load_context);
}
+#ifdef HAVE_AUTOAR
static void
attachment_load_created_decide_dest_cb (AutoarCreate *arcreate,
GFile *destination,
@@ -2119,7 +2123,7 @@ attachment_load_created_error_cb (AutoarCreate *arcreate,
attachment_load_check_for_error (load_context, g_error_copy (error));
g_object_unref (arcreate);
}
-
+#endif
static void
attachment_load_query_info_cb (GFile *file,
@@ -2143,6 +2147,7 @@ attachment_load_query_info_cb (GFile *file,
load_context->total_num_bytes = g_file_info_get_size (file_info);
+#ifdef HAVE_AUTOAR
if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY) {
AutoarCreate *arcreate;
AutoarPref *arpref; /* Do not unref */
@@ -2165,11 +2170,14 @@ attachment_load_query_info_cb (GFile *file,
g_object_unref (temporary);
} else {
+#endif
g_file_read_async (
file, G_PRIORITY_DEFAULT,
cancellable, (GAsyncReadyCallback)
attachment_load_file_read_cb, load_context);
+#ifdef HAVE_AUTOAR
}
+#endif
}
#define ATTACHMENT_LOAD_CONTEXT "attachment-load-context-data"
@@ -3056,6 +3064,7 @@ attachment_save_read_cb (GInputStream *input_stream,
save_context);
}
+#ifdef HAVE_AUTOAR
static void
attachment_save_extracted_progress_cb (AutoarExtract *arextract,
gdouble fraction_size,
@@ -3093,6 +3102,7 @@ attachment_save_extracted_error_cb (AutoarExtract *arextract,
attachment_save_check_for_error (save_context, g_error_copy (error));
g_object_unref (arextract);
}
+#endif
static void
attachment_save_got_output_stream (SaveContext *save_context)
@@ -3141,6 +3151,7 @@ attachment_save_got_output_stream (SaveContext *save_context)
save_context);
}
+#ifdef HAVE_AUTOAR
if (attachment->priv->save_extracted) {
GSettings *settings;
AutoarPref *arpref;
@@ -3178,6 +3189,7 @@ attachment_save_got_output_stream (SaveContext *save_context)
* reference count of arextract. We unref the object in
* callbacks instead. */
}
+#endif
g_clear_object (&mime_part);
}
@@ -3290,6 +3302,7 @@ attachment_save_query_info_cb (GFile *destination,
g_object_unref (destination);
}
+#ifdef HAVE_AUTOAR
if (attachment->priv->save_extracted) {
EAttachment *attachment;
GFileInfo *info;
@@ -3311,7 +3324,7 @@ attachment_save_query_info_cb (GFile *destination,
attachment_save_got_output_stream (save_context);
g_mutex_unlock (&(save_context->prepared_tasks_mutex));
}
-
+#endif
return;
}
@@ -3325,6 +3338,7 @@ replace:
save_context);
}
+#ifdef HAVE_AUTOAR
if (attachment->priv->save_extracted) {
/* We can safely use save_context->directory here because
* attachment_save_replace_cb never calls
@@ -3342,6 +3356,7 @@ replace:
attachment_save_got_output_stream (save_context);
g_mutex_unlock (&(save_context->prepared_tasks_mutex));
}
+#endif
}
void
@@ -3390,8 +3405,10 @@ e_attachment_save_async (EAttachment *attachment,
if (attachment->priv->save_self)
save_context->total_tasks++;
+#ifdef HAVE_AUTOAR
if (attachment->priv->save_extracted)
save_context->total_tasks++;
+#endif
cancellable = attachment->priv->cancellable;
g_cancellable_reset (cancellable);