[pan2/testing] * gpgme build fixes
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2/testing] * gpgme build fixes
- Date: Fri, 9 Dec 2011 15:17:58 +0000 (UTC)
commit 59b7ec32e40942084dce45798d7f280956881955
Author: Heinrich MÃller <henmull src gnome org>
Date: Fri Dec 9 16:17:27 2011 +0100
* gpgme build fixes
configure.in | 3 ++-
pan/data-impl/article-filter.cc | 6 +++++-
pan/data/article-cache.cc | 9 ++++++++-
pan/data/article-cache.h | 5 ++++-
pan/gui/body-pane.cc | 29 ++++++++++++++++++++---------
pan/gui/body-pane.h | 5 ++++-
pan/gui/gui.cc | 8 ++++++--
pan/gui/post-ui.cc | 39 +++++++++++++++++++++++++--------------
pan/gui/post-ui.h | 4 ++--
pan/gui/profiles-dialog.cc | 39 +++++++++++++++++++++++++--------------
pan/gui/profiles-dialog.h | 7 +++++++
pan/usenet-utils/mime-utils.cc | 15 ++++++++++++++-
pan/usenet-utils/mime-utils.h | 10 ++++++++--
13 files changed, 130 insertions(+), 49 deletions(-)
---
diff --git a/configure.in b/configure.in
index 9175c81..4e0ccf7 100644
--- a/configure.in
+++ b/configure.in
@@ -54,7 +54,8 @@ OPENSSL_REQUIRED=1.0.0
LIBNOTIFY_REQUIRED=0.4.1
LIBGSASL_REQUIRED=1.6.1
LIBGKR_REQUIRED=3.2.2
-LIBGPGME_REQUIRED=1.3.0
+LIBGPGME_REQUIRED=6.0.0
+dnl 1.3.0
AC_SUBST(GLIB_REQUIRED)
AC_SUBST(GMIME_REQUIRED)
AC_SUBST(GTK_REQUIRED)
diff --git a/pan/data-impl/article-filter.cc b/pan/data-impl/article-filter.cc
index 3432334..8bee5a7 100644
--- a/pan/data-impl/article-filter.cc
+++ b/pan/data-impl/article-filter.cc
@@ -188,10 +188,14 @@ ArticleFilter :: test_article (const Data & data,
else
{
if (cache.contains(article.message_id)) {
+ ArticleCache::mid_sequence_t mid(1, article.message_id);
+#ifdef HAVE_GPGME
GPGDecErr unused_for_now;
GPGSignersInfo unused;
- ArticleCache::mid_sequence_t mid(1, article.message_id);
GMimeMessage *msg = cache.get_message(mid, unused, unused_for_now);
+#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 f28d2ed..f76333c 100644
--- a/pan/data/article-cache.cc
+++ b/pan/data/article-cache.cc
@@ -398,7 +398,11 @@ ArticleCache :: get_message_mem_stream (const Quark& mid) const
}
GMimeMessage*
+#ifdef HAVE_GPGME
ArticleCache :: get_message (const mid_sequence_t& mids, GPGSignersInfo& signer_info, GPGDecErr& err) const
+#else
+ArticleCache :: get_message (const mid_sequence_t& mids) const
+#endif
{
debug ("trying to get a message with " << mids.size() << " parts");
GMimeMessage * retval = NULL;
@@ -421,8 +425,11 @@ ArticleCache :: get_message (const mid_sequence_t& mids, GPGSignersInfo& signer_
// build the message
if (!streams.empty())
+#ifdef HAVE_GPGME
retval = mime :: construct_message (&streams.front(), streams.size(), signer_info, 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 0dab3f4..31937e8 100644
--- a/pan/data/article-cache.h
+++ b/pan/data/article-cache.h
@@ -74,8 +74,11 @@ namespace pan
void resize ();
void clear ();
+#ifdef HAVE_GPGME
GMimeMessage* get_message (const mid_sequence_t&, GPGSignersInfo&, 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 78ea7f7..9766c40 100644
--- a/pan/gui/body-pane.cc
+++ b/pan/gui/body-pane.cc
@@ -889,6 +889,7 @@ namespace
}
+#ifdef HAVE_GPGME
bool
BodyPane ::get_gpgsig_from_gmime_part (GMimePart * part)
{
@@ -903,6 +904,7 @@ BodyPane ::get_gpgsig_from_gmime_part (GMimePart * part)
}
return false;
}
+#endif
void
BodyPane :: append_part (GMimeObject * obj, GtkAllocation * widget_size)
@@ -986,14 +988,14 @@ BodyPane :: append_part (GMimeObject * obj, GtkAllocation * widget_size)
const bool do_urls (_prefs.get_flag ("highlight-urls", true));
append_text_buffer_nolock (&_tm, _buffer, str, do_mute, do_smilies, do_markup, do_urls);
is_done = true;
-
+#ifdef HAVE_GPGME
/* verify signature */
if (g_mime_content_type_is_type (type, "*", "pgp-signature"))
{
bool res = get_gpgsig_from_gmime_part(part);
if (res) update_sig_valid(_gpgerr.verify_ok);
}
-
+#endif
}
// otherwise, bitch and moan.
@@ -1256,6 +1258,7 @@ namespace
}
}
+#ifdef HAVE_GPGME
gboolean
BodyPane:: on_tooltip_query(GtkWidget *widget,
gint x,
@@ -1298,6 +1301,7 @@ BodyPane:: on_tooltip_query(GtkWidget *widget,
return true;
}
+
void
BodyPane :: update_sig_valid(int i)
{
@@ -1315,19 +1319,25 @@ BodyPane :: update_sig_valid(int i)
break;
}
}
+#endif
void
BodyPane :: set_article (const Article& a)
{
_article = a;
+ const char* gpg_sign(0);
+
if (_message)
g_object_unref (_message);
+#ifdef HAVE_GPGME
_message = _cache.get_message (_article.get_part_mids(), _signer_info, _gpgerr);
+ gpg_sign = g_mime_object_get_header(GMIME_OBJECT(_message), "X-GPG-Signed");
+#else
+ _message = _cache.get_message (_article.get_part_mids());
+#endif
- const char* gpg_sign = g_mime_object_get_header(GMIME_OBJECT(_message), "X-GPG-Signed");
int val(-1);
-
if (gpg_sign)
{
if (!strcmp(gpg_sign, "valid"))
@@ -1335,9 +1345,9 @@ BodyPane :: set_article (const Article& a)
else if (!strcmp(gpg_sign, "invalid"))
val = 0;
}
-
+#ifdef HAVE_GPGME
update_sig_valid(val);
-
+#endif
refresh ();
_data.mark_read (_article);
@@ -1574,12 +1584,12 @@ BodyPane :: BodyPane (Data& data, ArticleCache& cache, Prefs& prefs):
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_GPGME
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);
@@ -1625,8 +1635,9 @@ BodyPane :: BodyPane (Data& data, ArticleCache& cache, Prefs& prefs):
g_signal_connect (_root, "show", G_CALLBACK(show_cb), this);
gtk_widget_show_all (_root);
-
+#ifdef HAVE_GPGME
update_sig_valid(-1);
+#endif
}
BodyPane :: ~BodyPane ()
diff --git a/pan/gui/body-pane.h b/pan/gui/body-pane.h
index afdf73d..17c111b 100644
--- a/pan/gui/body-pane.h
+++ b/pan/gui/body-pane.h
@@ -42,6 +42,7 @@ namespace pan
Data& _data;
ArticleCache& _cache;
GtkWidget* _sig_icon;
+#ifdef HAVE_GPGME
void update_sig_valid(int i);
static gboolean on_tooltip_query(GtkWidget *widget,
gint x,
@@ -49,7 +50,7 @@ namespace pan
gboolean keyboard_tip,
GtkTooltip *tooltip,
gpointer data);
-
+#endif
public:
BodyPane (Data&, ArticleCache&, Prefs&);
~BodyPane ();
@@ -110,9 +111,11 @@ namespace pan
/* updated with values from gmimemessage */
public:
+#ifdef HAVE_GPGME
GPGDecErr _gpgerr;
GPGSignersInfo _signer_info;
bool get_gpgsig_from_gmime_part (GMimePart * part);
+#endif
private:
std::string _hover_url;
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index d2ee329..0ad9389 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -695,10 +695,14 @@ namespace
virtual void on_progress_finished (Progress&, int status)
{
- GPGDecErr unused;
- GPGSignersInfo unuse;
if (status == OK) {
+#ifdef HAVE_GPGME
+ GPGDecErr unused;
+ GPGSignersInfo unuse;
GMimeMessage * message = _cache.get_message (_article.get_part_mids(), unuse, unused);
+#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/post-ui.cc b/pan/gui/post-ui.cc
index e32ac04..4c10244 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -104,6 +104,7 @@ namespace pan
bool master_reply (true);
bool gpg_enc (false);
bool gpg_sign (false);
+ bool user_has_gpg (false);
void on_remember_charset_toggled (GtkToggleAction * toggle, gpointer)
{
@@ -349,7 +350,7 @@ PostUI :: set_always_run_editor (bool run)
_prefs.set_flag ("always-run-editor", run);
}
-
+#ifdef HAVE_GPGME
std::string
PostUI :: gpg_sign_and_encrypt(const std::string& body, GPGEncErr& fail)
{
@@ -419,6 +420,7 @@ PostUI :: gpg_sign_and_encrypt(const std::string& body, GPGEncErr& fail)
fail.err = GPG_ERR_NO_ERROR;
return ret_str.str();
}
+#endif
void
PostUI :: set_wrap_mode (bool wrap)
@@ -1098,18 +1100,26 @@ PostUI :: maybe_post_message (GMimeMessage * message)
if(_file_queue_empty)
{
- GPGEncErr fail;
- std::string res = gpg_sign_and_encrypt(get_body(), fail);
- if (gpgme_err_code(fail.err) == GPG_ERR_NO_ERROR)
+#ifdef HAVE_GPGME
+ if (user_has_gpg)
{
- gtk_text_buffer_set_text (_body_buf, res.c_str(), res.size());
- GMimeMessage* msg = new_message_from_ui(POSTING);
- _post_task = new TaskPost (server, msg);
- _post_task->add_listener (this);
- _queue.add_task (_post_task, Queue::TOP);
- } else
- Log::add_err_va("Failed to sign the Message with your public key : \"%s\"",gpgme_strerror(fail.err));
- return false;
+ GPGEncErr fail;
+ std::string res = gpg_sign_and_encrypt(get_body(), fail);
+ if (gpgme_err_code(fail.err) == GPG_ERR_NO_ERROR)
+ {
+ gtk_text_buffer_set_text (_body_buf, res.c_str(), res.size());
+ }
+ else
+ {
+ Log::add_err_va("Failed to sign the Message with your public key : \"%s\"",gpgme_strerror(fail.err));
+ return false;
+ }
+ }
+#endif
+ GMimeMessage* msg = new_message_from_ui(POSTING);
+ _post_task = new TaskPost (server, msg);
+ _post_task->add_listener (this);
+ _queue.add_task (_post_task, Queue::TOP);
} else {
// prepend header for xml file (if one was chosen)
@@ -1823,7 +1833,7 @@ namespace
}
else if (type == Profile::GPGSIG)
{
-
+ /// TODO : Perhaps show but omit in gmimemessage, or make a multipart ??
}
/* Convert signature to UTF-8. Since the signature is a local file,
@@ -2208,12 +2218,13 @@ PostUI :: body_view_realized_cb (GtkWidget*, gpointer self_gpointer)
self->spawn_editor ();
g_signal_handler_disconnect (self->_body_view, self->body_view_realized_handler);
- self->_realized = true;
/* gpg stuff */
const Profile profile (self->get_current_profile ());
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (gtk_action_group_get_action (self->_agroup, "gpg-sign")),profile.use_sigfile);
+ user_has_gpg == profile.sig_type != Profile::GPGSIG;
+ self->_realized = true;
}
/***
diff --git a/pan/gui/post-ui.h b/pan/gui/post-ui.h
index aa071c3..582e0b8 100644
--- a/pan/gui/post-ui.h
+++ b/pan/gui/post-ui.h
@@ -87,14 +87,14 @@ namespace pan
void close_window (bool flag=false);
void set_wrap_mode (bool wrap);
void set_always_run_editor (bool);
-
+#ifdef HAVE_GPGME
/** Encrypts a message with GPG and signs it.
* @return The encrypted/signed message
* @param body The unencrypted/unsigned message body
* @param fail Error struct that holds the GPG errcode and two gpgme error info structs.
**/
std::string gpg_sign_and_encrypt(const std::string& body, GPGEncErr& fail);
-
+#endif
void update_parts_tab();
//popup action entries
diff --git a/pan/gui/profiles-dialog.cc b/pan/gui/profiles-dialog.cc
index 2b72f41..dd31ae5 100644
--- a/pan/gui/profiles-dialog.cc
+++ b/pan/gui/profiles-dialog.cc
@@ -165,9 +165,11 @@ ProfileDialog :: ProfileDialog (const Data & data,
file_entry_set (w, profile.signature_file.c_str());
GtkTreeIter iter;
-
+ GtkListStore * store;
+ GtkCellRenderer * renderer;
+#ifdef HAVE_GPGME
std::map<std::string, int> author_numbers;
- GtkListStore * store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
+ store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
int cnt(0);
foreach (signers_m, gpg_signers, it)
{
@@ -192,19 +194,20 @@ ProfileDialog :: ProfileDialog (const Data & data,
}
gtk_combo_box_set_active (GTK_COMBO_BOX(w), signer_no);
-
- GtkCellRenderer * renderer (gtk_cell_renderer_text_new ());
+ renderer = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (w), renderer, true);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (w), renderer, "text", 0, NULL);
-
+#endif
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, _("Text File"), 1, Profile::FILE, -1);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, _("Text"), 1, Profile::TEXT, -1);
gtk_list_store_append (store, &iter);
+#ifdef HAVE_GPGME
gtk_list_store_set (store, &iter, 0, _("GPG Signature"),1, Profile::GPGSIG, -1);
gtk_list_store_append (store, &iter);
+#endif
gtk_list_store_set (store, &iter, 0, _("Command"), 1, Profile::COMMAND, -1);
w = gtk_combo_box_new_with_model (GTK_TREE_MODEL(store));
hbox = gtk_hbox_new(FALSE, 3);
@@ -214,17 +217,22 @@ ProfileDialog :: ProfileDialog (const Data & data,
gtk_box_pack_start(GTK_BOX(hbox), w, true, true, 0);
_signature_file_combo = hbox;
_signature_file_combo_box = w;
-
+#ifdef HAVE_GPGME
g_signal_connect (w, "changed", G_CALLBACK(on_signature_type_changed), this);
-
+#endif
renderer = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (w), renderer, true);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (w), renderer, "text", 0, NULL);
- int active = 0;
- if (profile.sig_type == profile.TEXT) active = 1;
- if (profile.sig_type == profile.GPGSIG) active = 2;
- if (profile.sig_type == profile.COMMAND) active = 3;
+ int active = ROW_FILE;
+ if (profile.sig_type == profile.TEXT) active = ROW_TEXT;
+#ifdef HAVE_GPGME
+ if (profile.sig_type == profile.GPGSIG) active = ROW_GPGSIG;
+ if (profile.sig_type == profile.COMMAND) active = ROW_COMMAND;
+#else
+ if (profile.sig_type == profile.COMMAND) active = ROW_GPGSIG;
+#endif
+
gtk_combo_box_set_active (GTK_COMBO_BOX(w), active);
@@ -232,7 +240,9 @@ ProfileDialog :: ProfileDialog (const Data & data,
gtk_box_pack_start(GTK_BOX(vbox), _signature_file_combo, false, false, 0);
gtk_box_pack_start(GTK_BOX(vbox), _signature_file, false, false, 0);
+#ifdef HAVE_GPGME
gtk_box_pack_start(GTK_BOX(vbox), _gpg_sig_entry, false, false, 0);
+#endif
HIG :: workarea_add_row (t, &row, "",vbox);
HIG :: workarea_add_section_divider (t, &row);
@@ -304,8 +314,9 @@ ProfileDialog :: ProfileDialog (const Data & data,
gtk_window_set_transient_for (GTK_WINDOW(_root), parent);
gtk_window_set_position (GTK_WINDOW(_root), GTK_WIN_POS_CENTER_ON_PARENT);
}
-
+#ifdef HAVE_GPGME
on_signature_type_changed(GTK_COMBO_BOX(_signature_file_combo_box), this);
+#endif
}
ProfileDialog :: ~ProfileDialog ()
@@ -369,14 +380,14 @@ ProfileDialog :: get_profile (std::string& profile_name, Profile& profile)
profile.use_gpgsig = (type == profile.GPGSIG);
if (!profile.use_gpgsig)
from_entry (file_entry_gtk_entry(_signature_file), profile.signature_file);
-
+#ifdef HAVE_GPGME
char* uid;
combo = GTK_COMBO_BOX (_gpg_sig_entry_box);
gtk_combo_box_get_active_iter (combo, &iter);
model = gtk_combo_box_get_model (combo);
gtk_tree_model_get (model, &iter, 1, &uid, -1);
profile.gpg_sig_uid = uid;
-
+#endif
char * pch;
combo = GTK_COMBO_BOX (_server_combo);
gtk_combo_box_get_active_iter (combo, &iter);
diff --git a/pan/gui/profiles-dialog.h b/pan/gui/profiles-dialog.h
index 6ec6779..b595a4d 100644
--- a/pan/gui/profiles-dialog.h
+++ b/pan/gui/profiles-dialog.h
@@ -36,6 +36,13 @@ namespace pan
~ProfileDialog ();
GtkWidget* root() { return _root; }
void get_profile (std::string& setme_name, Profile& setme_profile);
+ enum
+ {
+ ROW_FILE=0,
+ ROW_TEXT=1,
+ ROW_GPGSIG=2,
+ ROW_COMMAND=3
+ };
private:
GtkWidget * _root;
diff --git a/pan/usenet-utils/mime-utils.cc b/pan/usenet-utils/mime-utils.cc
index c33b3ad..20058bb 100644
--- a/pan/usenet-utils/mime-utils.cc
+++ b/pan/usenet-utils/mime-utils.cc
@@ -478,6 +478,7 @@ namespace pan
return true;
}
+#ifdef HAVE_GPGME
GMimeStream* gpd_decrypt_and_verify (GPGSignersInfo& signer_info, GPGDecErr& info, GMimeStream* s)
{
@@ -558,6 +559,7 @@ namespace pan
return decrypted;
}
+#endif
void apply_source_and_maybe_filter (TempPart * part, GMimeStream * s)
{
@@ -593,9 +595,10 @@ namespace pan
temp_parts_t current_list;
TempPart *uu_temp;
std::string gpg_verified;
+#ifdef HAVE_GPGME
GPGDecErr gpgerr;
GPGSignersInfo signer_info;
-
+#endif
sep_state():uu_temp(NULL), gpg_verified("") {};
};
@@ -807,6 +810,7 @@ namespace pan
}
break;
}
+#ifdef HAVE_GPGME
case ENC_GPG:
{
if (gpg_is_ending_line(line_str))
@@ -835,6 +839,7 @@ namespace pan
}
break;
}
+#endif
}
}
@@ -1109,11 +1114,17 @@ namespace{
****
***/
+#ifdef HAVE_GPGME
GMimeMessage*
mime :: construct_message (GMimeStream ** istreams,
int qty,
GPGSignersInfo & signer_info,
GPGDecErr & gpgerr)
+#else
+GMimeMessage*
+mime :: construct_message (GMimeStream ** istreams,
+ int qty)
+#endif
{
const char * message_id = "Foo <bar mum>";
GMimeMessage * retval = 0;
@@ -1161,9 +1172,11 @@ mime :: construct_message (GMimeStream ** istreams,
temp_p &data(*it);
handle_uu_and_yenc_in_text_plain_cb(data.parent, data.part, &state);
/* set gpg signature verify success/fail flag */
+#ifdef HAVE_GPGME
g_mime_object_set_header(GMIME_OBJECT(data.parent), "X-GPG-Signed", state.gpg_verified.c_str());
gpgerr = state.gpgerr;
signer_info = state.signer_info;
+#endif
}
// cleanup
diff --git a/pan/usenet-utils/mime-utils.h b/pan/usenet-utils/mime-utils.h
index 0f886af..1ec04da 100644
--- a/pan/usenet-utils/mime-utils.h
+++ b/pan/usenet-utils/mime-utils.h
@@ -75,8 +75,9 @@
namespace pan
{
-
+#ifdef HAVE_GPGME
GMimeStream* gpd_decrypt_and_verify (GPGSignersInfo& signer_info, GPGDecErr& info, GMimeStream* s);
+#endif
/**
* Utilities to build and parse GMimeMessages.
@@ -89,12 +90,17 @@ namespace pan
*/
struct mime
{
+#ifdef HAVE_GPGME
static GMimeMessage *
construct_message (GMimeStream ** istreams,
int qty,
GPGSignersInfo & signer_info,
GPGDecErr & gpgerr);
-
+#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]