[pan2] Fix nits wrt GMime 3.0



commit 12b6b462264d468247e0e26b52acb76f760c0498
Author: Petr Kovar <pknbe volny cz>
Date:   Mon Oct 9 22:52:58 2017 +0200

    Fix nits wrt GMime 3.0

 README                         |    4 +-
 configure.ac                   |    7 ++-
 pan/gui/body-pane.cc           |   26 ++++++------
 pan/gui/post-ui.cc             |   88 ++++++++++++++++++++--------------------
 pan/usenet-utils/mime-utils.cc |    4 +-
 5 files changed, 65 insertions(+), 64 deletions(-)
---
diff --git a/README b/README
index 7a88793..81a7af8 100644
--- a/README
+++ b/README
@@ -35,8 +35,8 @@ REQUIREMENTS
         * GTK+ 2.16.0 or higher (optionally GTK+ 3.0.0 or higher)
           <http://www.gtk.org/>
 
-        * GMime 2.4.0 or higher <http://spruce.sourceforge.net/gmime/>
-          (optionally GMime 2.5.5 or higher for PGP cryptography support)
+        * GMime 2.6.20 or higher <http://spruce.sourceforge.net/gmime/>
+          (optionally with PGP cryptography support)
 
     The following libraries add extra features but are optional:
 
diff --git a/configure.ac b/configure.ac
index aad40d0..9a99f5c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -114,6 +114,7 @@ else
 fi
 
 dnl Check for GMime
+have_gmime30=no
 PKG_CHECK_MODULES([GMIME], [gmime-3.0 >= $GMIME30_REQUIRED],[have_gmime30=yes],
   [
     PKG_CHECK_MODULES([GMIME], [gmime-2.6 >= $GMIME26_REQUIRED])
@@ -122,7 +123,7 @@ PKG_CHECK_MODULES([GMIME], [gmime-3.0 >= $GMIME30_REQUIRED],[have_gmime30=yes],
   )
 
 if test "x$have_gmime30" = "xyes"; then
-   AC_DEFINE(HAVE_GMIME_30,[1],[Gmime 3.0 available])
+   AC_DEFINE(HAVE_GMIME_30,[1],[GMime 3.0 available])
 fi
 
 dnl Check for GMime cryptography support
@@ -131,7 +132,7 @@ AC_ARG_WITH([gmime-crypto],
   [want_gmime_crypto=$withval], [want_gmime_crypto=yes])
 
 if test "x$want_gmime_crypto" = "xyes" ; then
-if test "x$have_gmime26" = "xyes" ; then
+  if test "x$have_gmime26" = "xyes" ; then
     AC_DEFINE(HAVE_GMIME_CRYPTO,[1],[cryptography (PGP) support with GMime 2.6])
   fi
 fi
@@ -347,7 +348,7 @@ Configuration:
         Source code location:   ${srcdir}
         Compiler:               ${CXX}
         With D-Bus:             ${want_dbus}
-        With GMime 2.6+:        ${have_gmime26}
+        With GMime 3.0:         ${have_gmime30}
         With GMime crypto:      ${want_gmime_crypto}
         With GtkSpell:          ${gtkspell_msg}
         With GTK+ 3:            ${gtk_msg}
diff --git a/pan/gui/body-pane.cc b/pan/gui/body-pane.cc
index 0a40ca3..9f32fee 100644
--- a/pan/gui/body-pane.cc
+++ b/pan/gui/body-pane.cc
@@ -2072,16 +2072,16 @@ BodyPane :: create_followup_or_reply (bool is_reply)
       const std::string& to (reply_to.empty() ? from : reply_to);
 #ifdef HAVE_GMIME_30
       pan_g_mime_message_add_recipients_from_string (msg, GMIME_ADDRESS_TYPE_TO, to.c_str());
-#else      
+#else
       pan_g_mime_message_add_recipients_from_string (msg, GMIME_RECIPIENT_TYPE_TO, to.c_str());
-#endif      
+#endif
     } else {
       const std::string& groups (fup_to.empty() ? newsgroups : fup_to);
 #ifdef HAVE_GMIME_30
       g_mime_object_append_header ((GMimeObject *) msg, "Newsgroups", groups.c_str(), NULL);
-#else      
+#else
       g_mime_object_append_header ((GMimeObject *) msg, "Newsgroups", groups.c_str());
-#endif      
+#endif
     }
 
     // Subject:
@@ -2092,18 +2092,18 @@ BodyPane :: create_followup_or_reply (bool is_reply)
       val.insert (0, "Re: ");
 #ifdef HAVE_GMIME_30
     g_mime_message_set_subject (msg, val.c_str(), NULL);
-#else    
+#else
     g_mime_message_set_subject (msg, val.c_str());
-#endif    
+#endif
 
     // attribution lines
     const char * cpch = g_mime_object_get_header (_message_obj, "From");
     h = header_to_utf8 (cpch, message_charset, group_charset);
 #ifdef HAVE_GMIME_30
     g_mime_object_append_header (msg_obj, "X-Draft-Attribution-Author", h.c_str(), NULL);
-#else    
+#else
     g_mime_object_append_header (msg_obj, "X-Draft-Attribution-Author", h.c_str());
-#endif    
+#endif
 
     cpch = g_mime_message_get_message_id (_message);
     h = header_to_utf8 (cpch, message_charset, group_charset);
@@ -2116,17 +2116,17 @@ BodyPane :: create_followup_or_reply (bool is_reply)
 #ifdef HAVE_GMIME_30
     const char * header_t = "Date";
     const char * tmp_s = g_mime_object_get_header (_message_obj, header_t);
-    const char * tmp = tmp_s;  // fixme: convert time to string
-#else    
+    const char * tmp = tmp_s;  // FIXME: convert time to string
+#else
     char * tmp = g_mime_message_get_date_as_string (_message);
-#endif    
+#endif
     h = header_to_utf8 (tmp, message_charset, group_charset);
 #ifdef HAVE_GMIME_30
     g_mime_object_append_header (msg_obj, "X-Draft-Attribution-Date", h.c_str(), NULL);
-#else    
+#else
     g_mime_object_append_header (msg_obj, "X-Draft-Attribution-Date", h.c_str());
     g_free (tmp);
-#endif    
+#endif
 
     // references
     const char * header = "References";
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index 7ee303e..8b4e0eb 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -959,9 +959,9 @@ PostUI :: maybe_mail_message (GMimeMessage * message)
   gboolean unused;
 #ifdef HAVE_GMIME_30
   char * headers (g_mime_object_get_headers ((GMimeObject *) message, NULL));
-#else  
+#else
   char * headers (g_mime_object_get_headers ((GMimeObject *) message));
-#endif  
+#endif
   char * body (pan_g_mime_message_get_body (message, &unused));
   StringView key, val, v(headers);
   v.trim ();
@@ -1061,9 +1061,9 @@ PostUI :: save_message_in_local_folder(const Mode& mode, const std::string& fold
          const char * refs = g_mime_object_get_header(GMIME_OBJECT(msg), "References");
 #ifdef HAVE_GMIME_30
          g_mime_object_set_header((GMimeObject *) msg, "Newsgroups", folder.c_str(), NULL);
-#else    
+#else
          g_mime_object_set_header((GMimeObject *) msg, "Newsgroups", folder.c_str());
-#endif   
+#endif
 
          // pseudo mid to get data from cache
          std::string message_id = pan_g_mime_message_set_message_id(msg, mid.c_str());
@@ -1076,15 +1076,15 @@ PostUI :: save_message_in_local_folder(const Mode& mode, const std::string& fold
 #ifdef HAVE_GMIME_30
           GDateTime * postedGDT = g_date_time_new_from_unix_utc(posted);  
                  g_mime_message_set_date(msg, postedGDT);
-#else            
+#else
                  g_mime_message_set_date(msg, posted, 0);
-#endif           
+#endif
                  ArticleCache& cache(_data.get_cache());
-#ifdef HAVE_GMIME_30  
+#ifdef HAVE_GMIME_30
                  ArticleCache :: CacheResponse response = cache.add(mid, 
g_mime_object_to_string(GMIME_OBJECT(msg), NULL), true);
-#else            
+#else
                  ArticleCache :: CacheResponse response = cache.add(mid, 
g_mime_object_to_string(GMIME_OBJECT(msg)), true);
-#endif           
+#endif
                  g_object_unref(msg);
 
                  if (response.type != ArticleCache::CACHE_OK)
@@ -1525,9 +1525,9 @@ PostUI :: open_draft ()
       GMimeParser * parser = g_mime_parser_new_with_stream (stream);
 #ifdef HAVE_GMIME_30
       GMimeMessage * message = g_mime_parser_construct_message (parser, NULL);
-#else      
+#else
       GMimeMessage * message = g_mime_parser_construct_message (parser);
-#endif      
+#endif
       if (message) {
         set_message (message);
         g_object_unref (G_OBJECT(message));
@@ -1608,16 +1608,16 @@ PostUI :: new_message_from_ui (Mode mode, bool copy_body)
   profile.get_from_header (s);
 #ifdef HAVE_GMIME_30
   g_mime_message_add_mailbox (msg, GMIME_ADDRESS_TYPE_SENDER, NULL, s.c_str());
-#else  
+#else
   g_mime_message_set_sender (msg, s.c_str());
-#endif  
+#endif
 
   // headers from the ui: Subject
   const char * cpch (gtk_entry_get_text (GTK_ENTRY(_subject_entry)));
   if (cpch) {
 #ifdef HAVE_GMIME_30
     g_mime_message_set_subject (msg, cpch, NULL);
-#else    
+#else
     g_mime_message_set_subject (msg, cpch);
 #endif
   }
@@ -1627,36 +1627,36 @@ PostUI :: new_message_from_ui (Mode mode, bool copy_body)
   if (!to.empty())
 #ifdef HAVE_GMIME_30
     pan_g_mime_message_add_recipients_from_string (msg, GMIME_ADDRESS_TYPE_TO, to.str);
-#else    
+#else
     pan_g_mime_message_add_recipients_from_string (msg, GMIME_RECIPIENT_TYPE_TO, to.str);
-#endif    
+#endif
 
   // headers from the ui: Newsgroups
   const StringView groups (gtk_entry_get_text (GTK_ENTRY(_groups_entry)));
   if (!groups.empty())
 #ifdef HAVE_GMIME_30
     g_mime_object_set_header ((GMimeObject *) msg, "Newsgroups", groups.str, NULL);
-#else    
+#else
     g_mime_object_set_header ((GMimeObject *) msg, "Newsgroups", groups.str);
-#endif    
+#endif
 
   // headers from the ui: Followup-To
   const StringView followupto (gtk_entry_get_text (GTK_ENTRY(_followupto_entry)));
   if (!followupto.empty())
 #ifdef HAVE_GMIME_30
     g_mime_object_set_header ((GMimeObject *) msg, "Followup-To", followupto.str, NULL);
-#else    
+#else
     g_mime_object_set_header ((GMimeObject *) msg, "Followup-To", followupto.str);
-#endif    
+#endif
 
   // headers from the ui: Reply-To
   const StringView replyto (gtk_entry_get_text (GTK_ENTRY(_replyto_entry)));
   if (!replyto.empty())
 #ifdef HAVE_GMIME_30
     g_mime_object_set_header ((GMimeObject *) msg, "Reply-To", replyto.str, NULL);
-#else    
+#else
     g_mime_object_set_header ((GMimeObject *) msg, "Reply-To", replyto.str);
-#endif    
+#endif
 
   // headers from posting profile(via prefs): X-Face
   if (!profile.xface.empty())
@@ -1665,9 +1665,9 @@ PostUI :: new_message_from_ui (Mode mode, bool copy_body)
     f += " " + profile.xface;
 #ifdef HAVE_GMIME_30
     g_mime_object_set_header ((GMimeObject *) msg, "X-Face", f.c_str(), NULL);
-#else    
+#else
     g_mime_object_set_header ((GMimeObject *) msg, "X-Face", f.c_str());
-#endif    
+#endif
   }
 
   // add the 'hidden headers'
@@ -1675,9 +1675,9 @@ PostUI :: new_message_from_ui (Mode mode, bool copy_body)
     if ((mode==DRAFTING) || (it->first.find ("X-Draft-")!=0))
 #ifdef HAVE_GMIME_30
       g_mime_object_set_header ((GMimeObject *) msg, it->first.c_str(), it->second.c_str(), NULL);
-#else      
+#else
       g_mime_object_set_header ((GMimeObject *) msg, it->first.c_str(), it->second.c_str());
-#endif      
+#endif
 
   // build headers from the 'more headers' entry field
   std::map<std::string,std::string> headers;
@@ -1696,10 +1696,10 @@ PostUI :: new_message_from_ui (Mode mode, bool copy_body)
 #ifdef HAVE_GMIME_30
       g_mime_object_set_header ((GMimeObject *) msg, key.to_string().c_str(),
                                 val.to_string().c_str(), NULL);
-#else                                
+#else
       g_mime_object_set_header ((GMimeObject *) msg, key.to_string().c_str(),
-                                val.to_string().c_str());                                
-#endif                                
+                                val.to_string().c_str());
+#endif
   }
   g_free (pch);
 
@@ -1707,9 +1707,9 @@ PostUI :: new_message_from_ui (Mode mode, bool copy_body)
   if ((mode==POSTING || mode == UPLOADING) && _prefs.get_flag (USER_AGENT_PREFS_KEY, true))
 #ifdef HAVE_GMIME_30
     g_mime_object_set_header ((GMimeObject *) msg, "User-Agent", get_user_agent(), NULL);
-#else    
+#else
     g_mime_object_set_header ((GMimeObject *) msg, "User-Agent", get_user_agent());
-#endif    
+#endif
 
   // Message-ID for single text-only posts
   if (mode==DRAFTING || ((mode==POSTING || mode==UPLOADING) && _prefs.get_flag (MESSAGE_ID_PREFS_KEY, 
false))) {
@@ -1741,16 +1741,16 @@ PostUI :: new_message_from_ui (Mode mode, bool copy_body)
 
 #ifdef HAVE_GMIME_30
     GMimeContentType * type = g_mime_content_type_parse (NULL, pch);
-#else    
+#else
     GMimeContentType * type = g_mime_content_type_new_from_string (pch);
-#endif    
+#endif
     g_free (pch);
     g_mime_object_set_content_type ((GMimeObject *) part, type); // part owns type now. type isn't 
refcounted.
 #ifdef HAVE_GMIME_30
     g_mime_part_set_content(part, content_object);
-#else    
+#else
     g_mime_part_set_content_object (part, content_object);
-#endif    
+#endif
     if (mode != UPLOADING) g_mime_part_set_content_encoding (part, _enc);
     g_object_unref (content_object);
     g_mime_message_set_mime_part (msg, GMIME_OBJECT(part));
@@ -1835,9 +1835,9 @@ PostUI :: save_draft ()
       std::ofstream o (filename);
 #ifdef HAVE_GMIME_30
       char * pch = g_mime_object_to_string ((GMimeObject *) msg, NULL);
-#else      
+#else
       char * pch = g_mime_object_to_string ((GMimeObject *) msg);
-#endif      
+#endif
       o << pch;
       o.close ();
 
@@ -2337,10 +2337,10 @@ PostUI :: set_message (GMimeMessage * message)
 #ifdef HAVE_GMIME_30
   InternetAddressList * addresses = g_mime_message_get_addresses (message, GMIME_ADDRESS_TYPE_TO);
   char * pch  = internet_address_list_to_string (addresses, NULL, true);
-#else  
+#else
   InternetAddressList * addresses = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
   char * pch  = internet_address_list_to_string (addresses, true);
-#endif  
+#endif
   s = utf8ize (pch);
   gtk_entry_set_text (GTK_ENTRY(_to_entry), s.c_str());
   g_free (pch);
@@ -2350,12 +2350,12 @@ PostUI :: set_message (GMimeMessage * message)
   const char *name, *value;
 #ifdef HAVE_GMIME_30
   GMimeHeaderList HList;
-#else  
+#else
   GMimeHeaderIter iter;
-#endif  
+#endif
 
 #ifdef HAVE_GMIME_30
-     // GMime 3.0 not yet implemented
+     // FIXME: GMime 3.0 not yet implemented
 #else
   if (message->mime_part && g_mime_header_list_get_stream (message->mime_part->headers)) {
     if (g_mime_header_list_get_iter (message->mime_part->headers, &iter)) {
@@ -3144,9 +3144,9 @@ PostUI::draft_save_cb(gpointer ptr)
     std::ofstream o (filename);
 #ifdef HAVE_GMIME_30
     char * headers (g_mime_object_get_headers ((GMimeObject *) msg, NULL));
-#else    
+#else
     char * headers (g_mime_object_get_headers ((GMimeObject *) msg));
-#endif    
+#endif
     o << headers;
     const std::string body (data->get_body ());
     o << body;
diff --git a/pan/usenet-utils/mime-utils.cc b/pan/usenet-utils/mime-utils.cc
index be2ccb8..127faef 100644
--- a/pan/usenet-utils/mime-utils.cc
+++ b/pan/usenet-utils/mime-utils.cc
@@ -1586,10 +1586,11 @@ void pan::pan_g_mime_message_add_recipients_from_string (GMimeMessage *message,
 /**
 * Works around a GMime bug that uses `Message-Id' rather than `Message-ID'
 */
+
 #ifdef HAVE_GMIME_30
 std::string pan::pan_g_mime_message_set_message_id (GMimeMessage *msg, const char *mid)
 {
-       const char * charset = NULL; // "ISO-8859-1";  // fixme
+    const char * charset = NULL; // "ISO-8859-1";  // FIXME
     g_mime_object_append_header ((GMimeObject *) msg, "Message-ID", mid, charset);
     char * bracketed = g_strdup_printf ("<%s>", mid);
     g_mime_header_list_set (GMIME_OBJECT(msg)->headers, "Message-ID", bracketed, charset);
@@ -1598,7 +1599,6 @@ std::string pan::pan_g_mime_message_set_message_id (GMimeMessage *msg, const cha
     return ret;
 }
 #else
-
 std::string pan::pan_g_mime_message_set_message_id (GMimeMessage *msg, const char *mid)
 {
     g_mime_object_append_header ((GMimeObject *) msg, "Message-ID", mid);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]