[pan2] -compat fixes -compile fixes -pgp fixes
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2] -compat fixes -compile fixes -pgp fixes
- Date: Sun, 8 Jan 2012 22:58:07 +0000 (UTC)
commit eb8f1a797a7bbf48d536c294c3c39ca819329715
Author: Heinrich MÃller <henmull src gnome org>
Date: Sun Jan 8 23:57:26 2012 +0100
-compat fixes
-compile fixes
-pgp fixes
configure.in | 9 +++++++--
pan/data-impl/article-filter.cc | 5 ++++-
pan/data/article-cache.cc | 10 +++++++++-
pan/data/article-cache.h | 6 ++++--
pan/gui/body-pane.cc | 30 ++++++++++++++++++++++++------
pan/gui/body-pane.h | 4 ++--
pan/gui/gtk-compat.h | 29 ++++++++++++++++-------------
pan/gui/gui.cc | 10 ++++++++--
pan/gui/pan.cc | 2 +-
pan/gui/post-ui.cc | 4 ++--
pan/usenet-utils/gpg.cc | 3 +++
pan/usenet-utils/gpg.h | 4 ++++
pan/usenet-utils/mime-utils.cc | 35 ++++++++++++++++++++++++++++-------
pan/usenet-utils/mime-utils.h | 11 ++++++++---
14 files changed, 120 insertions(+), 42 deletions(-)
---
diff --git a/configure.in b/configure.in
index 4048cc5..a7a1e76 100644
--- a/configure.in
+++ b/configure.in
@@ -46,7 +46,8 @@ dnl GtkSpell is optional: GTKSPELL_REQUIRED refers to the minimum version
dnl needed if you want to build Pan with spellchecking in the Post window.
GLIB_REQUIRED=2.17.6
-GMIME_REQUIRED=2.5.5
+GMIME24_REQUIRED=2.4.0
+GMIME26_REQUIRED=2.5.5
GTK_REQUIRED=2.16.0
GTK3_REQUIRED=3.0.0
GTKSPELL_REQUIRED=2.0.7
@@ -86,7 +87,11 @@ AM_GLIB_GNU_GETTEXT
panlocaledir='${prefix}/${DATADIRNAME}/locale'
AM_PATH_GLIB_2_0($GLIB_REQUIRED,,exit 1,gobject gmodule gthread)
-PKG_CHECK_MODULES([GMIME], [gmime-2.6 >= $GMIME_REQUIRED],[],)
+dnl PKG_CHECK_MODULES([GMIME], [ gmime-2.6 >= $GMIME26_REQUIRED ],
+dnl AC_DEFINE(HAVE_GMIME_CRYPTO,[1],[crypto support (pgp) with gmime 2.6])],
+ dnl [
+ PKG_CHECK_MODULES( [GMIME], [gmime-2.4 >= $GMIME24_REQUIRED] )
+ dnl ] )
AC_ARG_WITH(dbus, AC_HELP_STRING([--with-dbus], [Enable DBUS support]), [want_dbus=$withval], [want_dbus=yes])
if test "x$want_dbus" = "xyes" ; then
diff --git a/pan/data-impl/article-filter.cc b/pan/data-impl/article-filter.cc
index 82f2dce..6f6ffce 100644
--- a/pan/data-impl/article-filter.cc
+++ b/pan/data-impl/article-filter.cc
@@ -189,9 +189,12 @@ ArticleFilter :: test_article (const Data & data,
{
if (cache.contains(article.message_id)) {
ArticleCache::mid_sequence_t mid(1, article.message_id);
+#ifdef HAVE_GMIME_CRYPTO
GPGDecErr err;
GMimeMessage *msg = cache.get_message(mid,err);
-
+#else
+ GMimeMessage *msg = cache.get_message(mid);
+#endif
const char *hdr = g_mime_object_get_header(GMIME_OBJECT(msg), criteria._header);
pass = criteria._text.test (hdr);
g_object_unref(msg);
diff --git a/pan/data/article-cache.cc b/pan/data/article-cache.cc
index 035407b..487983a 100644
--- a/pan/data/article-cache.cc
+++ b/pan/data/article-cache.cc
@@ -397,8 +397,13 @@ ArticleCache :: get_message_mem_stream (const Quark& mid) const
return retval;
}
+#ifdef HAVE_GMIME_CRYPTO
GMimeMessage*
ArticleCache :: get_message (const mid_sequence_t& mids, GPGDecErr& err) const
+#else
+GMimeMessage*
+ArticleCache :: get_message (const mid_sequence_t& mids) const
+#endif
{
debug ("trying to get a message with " << mids.size() << " parts");
GMimeMessage * retval = NULL;
@@ -422,8 +427,11 @@ ArticleCache :: get_message (const mid_sequence_t& mids, GPGDecErr& err) const
// build the message
if (!streams.empty())
+#ifdef HAVE_GMIME_CRYPTO
retval = mime :: construct_message (&streams.front(), streams.size(), err);
-
+#else
+ retval = mime :: construct_message (&streams.front(), streams.size());
+#endif
// cleanup
foreach (streams_t, streams, it)
g_object_unref (*it);
diff --git a/pan/data/article-cache.h b/pan/data/article-cache.h
index bffe5a7..74d604c 100644
--- a/pan/data/article-cache.h
+++ b/pan/data/article-cache.h
@@ -71,9 +71,11 @@ namespace pan
void release (const mid_sequence_t& mids);
void resize ();
void clear ();
-
+#ifdef HAVE_GMIME_CRYPTO
GMimeMessage* get_message (const mid_sequence_t&, GPGDecErr&) const;
-
+#else
+ GMimeMessage* get_message (const mid_sequence_t&) const;
+#endif
typedef std::vector<std::string> strings_t;
strings_t get_filenames (const mid_sequence_t&);
diff --git a/pan/gui/body-pane.cc b/pan/gui/body-pane.cc
index 9b0261d..6c22b79 100644
--- a/pan/gui/body-pane.cc
+++ b/pan/gui/body-pane.cc
@@ -1237,6 +1237,7 @@ namespace
}
}
+#ifdef HAVE_GMIME_CRYPTO
gboolean
BodyPane:: on_tooltip_query(GtkWidget *widget,
gint x,
@@ -1271,6 +1272,7 @@ BodyPane:: on_tooltip_query(GtkWidget *widget,
return true;
}
+#endif
void
@@ -1298,11 +1300,14 @@ BodyPane :: set_article (const Article& a)
if (_message)
g_object_unref (_message);
-
+#ifdef HAVE_GMIME_CRYPTO
_gpgerr.clear();
-
_message = _cache.get_message (_article.get_part_mids(), _gpgerr);
+#else
+ _message = _cache.get_message (_article.get_part_mids());
+#endif
+#ifdef HAVE_GMIME_CRYPTO
int val(-1);
{
if (_gpgerr.verify_ok && !_gpgerr.no_sigs)
@@ -1314,6 +1319,7 @@ BodyPane :: set_article (const Article& a)
}
update_sig_valid(val);
+#endif
refresh ();
_data.mark_read (_article);
@@ -1614,6 +1620,7 @@ BodyPane :: clear_attachments()
}
/// FIXME : shows only half the icon on gtk2+, gtk3+ works fine. hm....
+/// NOTE :
void
BodyPane :: add_attachment_to_toolbar (const char* fn)
{
@@ -1624,8 +1631,15 @@ BodyPane :: add_attachment_to_toolbar (const char* fn)
#if !GTK_CHECK_VERSION(3,0,0)
guint cols(0), rows(0);
+#if GTK_CHECK_VERSION(2,22,0)
gtk_table_get_size (GTK_TABLE(_att_toolbar), &rows, &cols);
-
+#else
+ GtkTablePrivate *priv = _att_toolbar->priv;
+ if (rows)
+ *rows = priv->nrows;
+ if (cols)
+ *cols = priv->ncols;
+#endif
if (_attachments % 4 == 0 && _attachments != 0)
{
gtk_table_resize (GTK_TABLE(_att_toolbar), rows+1, cols);
@@ -1633,7 +1647,7 @@ BodyPane :: add_attachment_to_toolbar (const char* fn)
_cur_col = 0;
}
- gtk_table_attach_defaults (GTK_TABLE(_att_toolbar), w, _cur_col, _cur_col+2, _cur_row,_cur_row+2);
+ gtk_table_attach_defaults (GTK_TABLE(_att_toolbar), w, _cur_col, _cur_col+1, _cur_row,_cur_row+1);
++_cur_col;
@@ -1689,17 +1703,19 @@ BodyPane :: BodyPane (Data& data, ArticleCache& cache, Prefs& prefs, GroupPrefs
_hscroll_visible (false),
_vscroll_visible (false),
_message (0),
+#ifdef HAVE_GMIME_CRYPTO
_gpgerr(GPG_DECODE),
+#endif
_attachments(0),
_current_attachment(0)
{
for (guint i=0; i<NUM_ICONS; ++i)
icons[i].pixbuf = gdk_pixbuf_new_from_inline (-1, icons[i].pixbuf_txt, FALSE, 0);
-
+#ifdef HAVE_GMIME_CRYPTO
// signature pgp valid/invalid icon
_sig_icon = gtk_image_new();
-
+#endif
// menu for popup menu for attachments
_menu = gtk_menu_new ();
GtkWidget* l = gtk_menu_item_new_with_label(_("Save attachment as ...."));
@@ -1744,10 +1760,12 @@ BodyPane :: BodyPane (Data& data, ArticleCache& cache, Prefs& prefs, GroupPrefs
gtk_label_set_ellipsize (GTK_LABEL(w), PANGO_ELLIPSIZE_MIDDLE);
gtk_label_set_use_markup (GTK_LABEL(w), true);
gtk_box_pack_start (GTK_BOX(hbox), w, true, true, PAD_SMALL);
+#ifdef HAVE_GMIME_CRYPTO
gtk_widget_set_size_request (_sig_icon, 32, 32);
gtk_box_pack_start (GTK_BOX(hbox), _sig_icon, true, true, PAD_SMALL);
gtk_widget_set_has_tooltip (_sig_icon, true);
g_signal_connect(_sig_icon,"query-tooltip",G_CALLBACK(on_tooltip_query), this);
+#endif
w = _xface = gtk_image_new();
gtk_widget_set_size_request (w, 48, 48);
gtk_box_pack_start (GTK_BOX(hbox), w, false, false, PAD_SMALL);
diff --git a/pan/gui/body-pane.h b/pan/gui/body-pane.h
index 4ae3fa9..eeb4274 100644
--- a/pan/gui/body-pane.h
+++ b/pan/gui/body-pane.h
@@ -153,9 +153,9 @@ namespace pan
GMimeMessage * _message;
TextMassager _tm;
std::string _charset;
-
+#ifdef HAVE_GMIME_CRYPTO
GPGDecErr _gpgerr;
-
+#endif
int _attachments;
int _cur_col, _cur_row;
std::set<char*> _freeme;
diff --git a/pan/gui/gtk-compat.h b/pan/gui/gtk-compat.h
index 62d0ae4..985cfcb 100644
--- a/pan/gui/gtk-compat.h
+++ b/pan/gui/gtk-compat.h
@@ -1,9 +1,10 @@
//========================================================================
/** file pan/pan/gui/gtk-compat.h
+ * @author imhotep
* @author kid
* @date
* Created: Mon 09 May 2011 04:42:46 PM MDT \n
- * Last Update: Mon 09 May 2011 04:42:46 PM MDT
+ * Last Update: Sun 08 Jan 2012 11:56:00 PM GMT
*/
/*------------------------------------------------------------------------
* Description: GTK Compatibility layer for GTK2/3+ migration
@@ -22,30 +23,30 @@ namespace
{
#endif
#if !GTK_CHECK_VERSION(2,18,0)
- void gtk_widget_get_allocation( GtkWidget *w, GtkAllocation *a)
+ static inline void gtk_widget_get_allocation( GtkWidget *w, GtkAllocation *a)
{
*a = w->allocation;
}
- bool gtk_widget_has_focus( GtkWidget *w)
+ static inline bool gtk_widget_has_focus( GtkWidget *w)
{
return GTK_WIDGET_HAS_FOCUS(w);
}
- bool gtk_widget_get_sensitive( GtkWidget *w)
+ static inline bool gtk_widget_get_sensitive( GtkWidget *w)
{
return GTK_WIDGET_SENSITIVE(w);
}
- bool gtk_widget_get_visible(GtkWidget *w)
+ static inline bool gtk_widget_get_visible(GtkWidget *w)
{
return GTK_WIDGET_VISIBLE(w);
}
- bool gtk_widget_is_toplevel(GtkWidget *w)
+ static inline bool gtk_widget_is_toplevel(GtkWidget *w)
{
return GTK_WIDGET_TOPLEVEL(w);
}
#endif
#if !GTK_CHECK_VERSION(2,20,0)
- gboolean gtk_widget_get_realized(GtkWidget *w)
+ static inline gboolean gtk_widget_get_realized(GtkWidget *w)
{
return GTK_WIDGET_REALIZED(w);
}
@@ -60,23 +61,23 @@ namespace
#if !GTK_CHECK_VERSION(2,24,0)
#define GTK_COMBO_BOX_TEXT(cb) GTK_COMBO_BOX(cb)
typedef GtkComboBox GtkComboBoxText;
- GtkWidget* gtk_combo_box_text_new()
+ static inline GtkWidget* gtk_combo_box_text_new()
{
return gtk_combo_box_new_text();
}
- GtkWidget* gtk_combo_box_text_new_with_entry()
+ static inline GtkWidget* gtk_combo_box_text_new_with_entry()
{
return gtk_combo_box_entry_new_text();
}
- void gtk_combo_box_text_append_text(GtkComboBoxText *cb, const gchar *t)
+ static inline void gtk_combo_box_text_append_text(GtkComboBoxText *cb, const gchar *t)
{
gtk_combo_box_append_text(cb,t);
}
- gchar *gtk_combo_box_text_get_active_text(GtkComboBoxText *cb)
+ static inline gchar *gtk_combo_box_text_get_active_text(GtkComboBoxText *cb)
{
return gtk_combo_box_get_active_text(cb);
}
- void gtk_combo_box_text_remove(GtkComboBoxText *cb, int p)
+ static inline void gtk_combo_box_text_remove(GtkComboBoxText *cb, int p)
{
gtk_combo_box_remove_text(cb, p);
}
@@ -101,6 +102,8 @@ namespace
#define GDK_KEY_Return GDK_Return
#define GDK_KEY_Down GDK_Down
#define GDK_KEY_Up GDK_Up
+ #define GDK_KEY_KP_Up GDK_KP_Up
+ #define GDK_KEY_KP_Down GDK_KP_Down
#endif
#if !GTK_CHECK_VERSION(3,0,0)
@@ -129,7 +132,7 @@ namespace
#define GTK_OBJECT(w) w
typedef GtkWidget GtkObject;
#ifdef GTK_DISABLE_DEPRECATED
- void gdk_cursor_unref(GdkCursor *p)
+ static inline void gdk_cursor_unref(GdkCursor *p)
{
g_object_unref(p);
}
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index 924fcac..4df1c8b 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -350,7 +350,9 @@ GUI :: GUI (Data& data, Queue& queue, Prefs& prefs, GroupPrefs& group_prefs):
}
}
+#ifdef HAVE_GMIME_CRYPTO
init_gpg();
+#endif
}
namespace
@@ -404,9 +406,9 @@ GUI :: ~GUI ()
foreach (std::set<GtkWidget*>, unref, it)
g_object_unref (*it);
g_object_unref (G_OBJECT(_ui_manager));
-
+#ifdef HAVE_GMIME_CRYPTO
deinit_gpg();
-
+#endif
if (iconv_inited) iconv_close(conv);
_certstore.remove_listener(this);
@@ -711,8 +713,12 @@ namespace
virtual void on_progress_finished (Progress&, int status)
{
if (status == OK) {
+#ifdef HAVE_GMIME_CRYPTO
GPGDecErr err;
GMimeMessage * message = _cache.get_message (_article.get_part_mids(),err);
+#else
+ GMimeMessage * message = _cache.get_message (_article.get_part_mids());
+#endif
g_mime_message_foreach (message, foreach_part_cb, this);
g_object_unref (message);
}
diff --git a/pan/gui/pan.cc b/pan/gui/pan.cc
index c5316c5..ec3c7dc 100644
--- a/pan/gui/pan.cc
+++ b/pan/gui/pan.cc
@@ -815,8 +815,8 @@ _("General Options\n"
static void
pan_dbus_deinit (Pan* pan)
{
- if (dbus_connection) g_dbus_connection_close(dbus_connection,NULL,0,NULL);
g_bus_unown_name(pan->dbus_id);
+ if (dbus_connection) g_dbus_connection_close(dbus_connection,NULL,0,NULL);
}
/***
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index 0925317..0e1e9b9 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -1065,7 +1065,7 @@ PostUI :: maybe_post_message (GMimeMessage * message)
if(_file_queue_empty)
{
bool go_on(true);
-
+#ifdef HAVE_GMIME_CRYPTO
/* adding yourself to the list of recipients */
GPtrArray * rcp;
Profile p(get_current_profile());
@@ -1082,7 +1082,7 @@ PostUI :: maybe_post_message (GMimeMessage * message)
go_on = go_on && gpg_encrypt(p.gpg_sig_uid, get_body(), msg, rcp, false);
else if (user_has_gpg && gpg_enc && gpg_sign)
go_on = go_on && gpg_encrypt(p.gpg_sig_uid, get_body(), msg, rcp, true);
-
+#endif
if (go_on)
{
_post_task = new TaskPost (server, msg);
diff --git a/pan/usenet-utils/gpg.cc b/pan/usenet-utils/gpg.cc
index ca23be2..566e928 100644
--- a/pan/usenet-utils/gpg.cc
+++ b/pan/usenet-utils/gpg.cc
@@ -32,6 +32,8 @@ extern "C" {
#include <gmime/gmime.h>
}
+#ifdef HAVE_GMIME_CRYPTO
+
namespace pan
{
@@ -134,3 +136,4 @@ namespace pan
}
+#endif // g_mime_crypto
diff --git a/pan/usenet-utils/gpg.h b/pan/usenet-utils/gpg.h
index d48f790..905519f 100644
--- a/pan/usenet-utils/gpg.h
+++ b/pan/usenet-utils/gpg.h
@@ -24,6 +24,8 @@
#include <map>
#include <vector>
+#ifdef HAVE_GMIME_CRYPTO
+
namespace pan
{
@@ -132,5 +134,7 @@ namespace pan
}
+#endif // g_mime_crypto
+
#endif
diff --git a/pan/usenet-utils/mime-utils.cc b/pan/usenet-utils/mime-utils.cc
index 886cbe4..4af732f 100644
--- a/pan/usenet-utils/mime-utils.cc
+++ b/pan/usenet-utils/mime-utils.cc
@@ -1144,6 +1144,7 @@ namespace pan
temp_p(GMimeObject *p, GMimeObject *par):parent(p),part(par) {};
};
+#ifdef HAVE_GMIME_CRYPTO
struct QueryMPType
{
GMimeObject* obj;
@@ -1152,6 +1153,15 @@ namespace pan
QueryMPType() : obj(0), type(GPG_DECODE) {}
};
+#else
+ struct QueryMPType
+ {
+ GMimeObject* obj;
+ std::string algo;
+
+ QueryMPType() : obj(0) {}
+ };
+#endif
}
namespace
@@ -1213,11 +1223,12 @@ namespace
GMimeContentType * content_type = g_mime_object_get_content_type (part);
if (!content_type) return;
-
+#ifdef HAVE_GMIME_CRYPTO
if (g_mime_content_type_is_type (content_type, "application", "pgp-signature"))
type->type = GPG_VERIFY;
else if (g_mime_content_type_is_type (content_type, "application", "pgp-encrypted"))
type->type = GPG_DECODE;
+#endif
}
@@ -1227,10 +1238,16 @@ namespace
****
***/
+#ifdef HAVE_GMIME_CRYPTO
GMimeMessage*
mime :: construct_message (GMimeStream ** istreams,
int qty,
GPGDecErr & err)
+#else
+GMimeMessage*
+mime :: construct_message (GMimeStream ** istreams,
+ int qty)
+#endif
{
const char * message_id = "Foo <bar mum>";
GMimeMessage * retval = 0;
@@ -1255,7 +1272,7 @@ mime :: construct_message (GMimeStream ** istreams,
GMimeObject* part = g_mime_parser_construct_part(parser);
GMimeContentType * type = g_mime_object_get_content_type (part);
const bool multipart (GMIME_IS_MULTIPART_SIGNED(part) || GMIME_IS_MULTIPART_ENCRYPTED(part));
-
+#ifdef HAVE_GMIME_CRYPTO
if (GMIME_IS_MULTIPART_SIGNED(part))
{
err.type = GPG_VERIFY;
@@ -1266,7 +1283,7 @@ mime :: construct_message (GMimeStream ** istreams,
err.type = GPG_DECODE;
err.verify_ok = gpg_verify_mps(part, err);
}
-
+#endif
if (type)
{
if (g_mime_content_type_is_type (type, "multipart", "mixed"))
@@ -1274,7 +1291,7 @@ mime :: construct_message (GMimeStream ** istreams,
QueryMPType qtype;
g_mime_multipart_foreach (GMIME_MULTIPART(part), mixed_mp_find_gpg_params_cb, &qtype);
GMimeObject* o(0);
-
+#ifdef HAVE_GMIME_CRYPTO
if (qtype.type == GPG_VERIFY)
{
GMimeMultipartSigned* new_mp = g_mime_multipart_signed_new();
@@ -1294,16 +1311,20 @@ mime :: construct_message (GMimeStream ** istreams,
err.verify_ok = gpg_verify_mps(GMIME_OBJECT(new_mp), err);
g_mime_message_set_mime_part(messages[i], GMIME_OBJECT(new_mp));
}
-
+#endif
g_object_unref(o);
}
else if (multipart)
{
+#ifdef HAVE_GMIME_CRYPTO
if (err.decrypted)
g_mime_message_set_mime_part(messages[i], err.decrypted);
} else
+ {
+#endif
g_mime_message_set_mime_part(messages[i], part);
+ }
}
}
@@ -1678,7 +1699,7 @@ namespace pan
g_mime_part_set_content_object (part, content);
g_object_unref (content);
}
-
+#ifdef HAVE_GMIME_CRYPTO
GMimeSignatureStatus
get_sig_status (GMimeSignatureList *signatures)
{
@@ -1813,7 +1834,7 @@ namespace pan
g_object_unref(mpe);
}
-
+#endif
}
diff --git a/pan/usenet-utils/mime-utils.h b/pan/usenet-utils/mime-utils.h
index 66822ab..e05fc02 100644
--- a/pan/usenet-utils/mime-utils.h
+++ b/pan/usenet-utils/mime-utils.h
@@ -69,11 +69,11 @@ namespace pan
std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len);
std::string base64_decode(std::string const& encoded_string);
-
+#ifdef HAVE_GMIME_CRYPTO
GMimeMessage* message_add_signed_part (const std::string& uid, const std::string& body_str, GMimeMessage* body);
GMimeMessage* gpg_encrypt (const std::string& uid, const std::string& body_str, GMimeMessage* body, GPtrArray* rcp, bool sign);
bool gpg_verify_mps (GMimeObject*, GPGDecErr&);
-
+#endif
/**
* Utilities to build and parse GMimeMessages.
*
@@ -85,11 +85,16 @@ namespace pan
*/
struct mime
{
+#ifdef HAVE_GMIME_CRYPTO
static GMimeMessage *
construct_message (GMimeStream ** istreams,
int qty,
GPGDecErr &);
-
+#else
+ static GMimeMessage *
+ construct_message (GMimeStream ** istreams,
+ int qty);
+#endif
static const char *
get_charset (GMimeMessage * message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]