[balsa/gtk3] Reduce code complexity by weeding out deprecations



commit 575e34c3d4428cf9bf69ab6e2a857f7bf2c73e04
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Tue May 31 18:24:33 2016 -0400

    Reduce code complexity by weeding out deprecations
    
        * configure.ac: apply the aforementioned simplifications
        * libbalsa/filter-funcs.c, libbalsa/filter-private.h, libbalsa/mime.c,
          libbalsa/misc.h, src/balsa-app.c, src/balsa-app.h,
          src/balsa-print-object-text.c, src/quote-color.c, src/quote-color.h,
          src/sendmsg-window.c, src/spell-check.c: always use GRegex
        * libbalsa/gmime-multipart-crypt.c, libbalsa/gmime-stream-gio.c,
          libbalsa/mailbox_mbox.c: drop conditional code for gmime < 2.6
        * libbalsa/html.h: remove hack for Gtkhtml 2
        * libbalsa/libbalsa.c, libbalsa/libbalsa.h: use GDateTime,
          simplify API of libbalsa_date_to_utf8()
        * libbalsa/mailbox.c, libbalsa/message.h, libbalsa/rfc3156.c,
          src/balsa-mime-widget-vcalendar.c, src/balsa-print-object-text.c:
          use simplified libbalsa_date_to_utf8() API
        * libbalsa/missing.h, libbalsa/missing_time.c: remove localtime_r,
          gmtime_r implementations
        * libbalsa/rfc2445.c: use ISO 8601 GTimeVal and GDateTime functions
        * libbalsa/send.c: use GTimeZone functions
        * src/filter-edit-callbacks.c: use GDateTime functions

 ChangeLog                         |   24 ++++
 configure.ac                      |  135 +++--------------------
 libbalsa/filter-funcs.c           |    4 -
 libbalsa/filter-private.h         |   13 --
 libbalsa/gmime-multipart-crypt.c  |   15 ---
 libbalsa/gmime-stream-gio.c       |   10 +--
 libbalsa/html.h                   |    5 -
 libbalsa/libbalsa.c               |   22 ++--
 libbalsa/libbalsa.h               |    2 +-
 libbalsa/mailbox.c                |    2 +-
 libbalsa/mailbox_mbox.c           |   56 ---------
 libbalsa/message.h                |    4 +-
 libbalsa/mime.c                   |  222 -------------------------------------
 libbalsa/misc.h                   |   15 ---
 libbalsa/missing.h                |    8 --
 libbalsa/missing_time.c           |   27 +-----
 libbalsa/rfc2445.c                |   70 +++---------
 libbalsa/rfc3156.c                |   10 +-
 libbalsa/send.c                   |   41 +++-----
 src/balsa-app.c                   |    2 -
 src/balsa-app.h                   |    2 -
 src/balsa-mime-widget-text.c      |   21 ----
 src/balsa-mime-widget-vcalendar.c |    2 +-
 src/balsa-print-object-text.c     |   22 +---
 src/filter-edit-callbacks.c       |   20 ++--
 src/quote-color.c                 |    4 -
 src/quote-color.h                 |   17 ---
 src/sendmsg-window.c              |   22 ----
 src/spell-check.c                 |   34 ------
 29 files changed, 110 insertions(+), 721 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 603a1aa..5968863 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2016-05-31  Albrecht Dreß
+
+       Reduce the code complexity (in particular conditional parts)
+       by weeding out deprecated stuff.
+
+       * configure.ac: apply the aforementioned simplifications
+       * libbalsa/filter-funcs.c, libbalsa/filter-private.h, libbalsa/mime.c,
+         libbalsa/misc.h, src/balsa-app.c, src/balsa-app.h,
+         src/balsa-print-object-text.c, src/quote-color.c, src/quote-color.h,
+         src/sendmsg-window.c, src/spell-check.c: always use GRegex
+       * libbalsa/gmime-multipart-crypt.c, libbalsa/gmime-stream-gio.c,
+         libbalsa/mailbox_mbox.c: drop conditional code for gmime < 2.6
+       * libbalsa/html.h: remove hack for Gtkhtml 2
+       * libbalsa/libbalsa.c, libbalsa/libbalsa.h: use GDateTime,
+         simplify API of libbalsa_date_to_utf8()
+       * libbalsa/mailbox.c, libbalsa/message.h, libbalsa/rfc3156.c,
+         src/balsa-mime-widget-vcalendar.c, src/balsa-print-object-text.c:
+         use simplified libbalsa_date_to_utf8() API
+       * libbalsa/missing.h, libbalsa/missing_time.c: remove localtime_r,
+         gmtime_r implementations
+       * libbalsa/rfc2445.c: use ISO 8601 GTimeVal and GDateTime functions
+       * libbalsa/send.c: use GTimeZone functions
+       * src/filter-edit-callbacks.c: use GDateTime functions
+
 2016-05-27  Albrecht Dreß
 
        Fix accessing MBox files > 2 GByte
diff --git a/configure.ac b/configure.ac
index 9a2f696..a2a227f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -115,18 +115,13 @@ AC_ARG_WITH(esmtp,
                   [Enable libESMTP (default=yes)]),
                   [ with_esmtp=$withval ],[ with_esmtp=yes ])
 
-AC_ARG_ENABLE([gregex], 
-   AC_HELP_STRING([--enable-gregex],
-                  [Use GRegex regular expressions if available (default=no)]),
-                  [ check_gregex=$enableval],[ check_gregex=no ])
-
 AC_ARG_WITH(gss,
    AC_HELP_STRING([--with-gss],
                   [Enable GSS (default=no)]),
                   [with_gss=$withval],[with_gss=no])
 
 AC_ARG_WITH(html-widget,
-            AC_HELP_STRING([--with-html-widget=(no|gtkhtml2|gtkhtml4|webkit|webkit2)],
+            AC_HELP_STRING([--with-html-widget=(no|gtkhtml4|webkit|webkit2)],
                            [select the HTML renderer (default webkit)]),
             [use_html_widget=$withval],
             [use_html_widget=webkit])
@@ -164,12 +159,6 @@ AC_ARG_WITH([macosx-desktop],
                  [Use Mac OS X Desktop Integration (default=no, extremely experimental)]),
                  [use_igemacint=$withval],[use_igemacint=no])
 
-AC_ARG_ENABLE([pcre], 
-   AC_HELP_STRING([--enable-pcre],
-                  [Use Perl-compatible regular expressions if available (default=no)]),
-                  [ check_pcre=$enableval],[ check_pcre=no ])
-
-
 AC_ARG_WITH([rubrica],
    AC_HELP_STRING([--with-rubrica],
                   [add Rubrica2 address book support (needs libxml2, default=no)]),
@@ -180,11 +169,6 @@ AC_ARG_WITH([sqlite],
                   [Use SQLite for GPE address books (default=no)]),
                   [with_sqlite=$withval],[with_sqlite=no])
 
-AC_ARG_WITH(gmime,
-   AC_HELP_STRING([--with-gmime],
-                  [Version of GMime 2.4, or 2.6 (default=detect)]),
-                  [with_gmime=$withval],[with_gmime=detect])
-
 AC_ARG_WITH(libsecret,
    AC_HELP_STRING([--with-libsecret],
                   [Link to libsecret instead of gnome-keyring (default=no)]),
@@ -233,11 +217,6 @@ else
     AM_CONDITIONAL([HAVE_YELPTOOL], [true])
 fi
 
-# glib-genmarshal
-#
-AC_SUBST(GLIB_GENMARSHAL)
-GLIB_GENMARSHAL=`pkg-config --variable=glib_genmarshal glib-2.0`
-
 # gettext
 #
 ALL_LINGUAS="am ar az bg ca cs da de dz el en_CA en_GB es et eu fi fr ga gl he hi hr hu id it ja ko lt lv mk 
ml ms nb ne nl nn oc pa pl pt pt_BR ro ru rw sk sl sq sr sr latin sv tr uk vi wa zh_CN zh_HK zh_TW"
@@ -302,34 +281,6 @@ else
 fi
 AC_SUBST(TOOLKIT_CATEGORIES)
 
-# GMime configuration
-#
-if test "$with_gmime" = detect; then
-   AC_MSG_CHECKING([Gmime version])
-   if $PKG_CONFIG --exists gmime-2.6; then
-      with_gmime=2.6
-   else
-      if $PKG_CONFIG --exists gmime-2.4; then
-         with_gmime=2.4
-      else
-         AC_MSG_ERROR([GMime 2.6 or 2.4 not detected.])
-      fi
-   fi
-   AC_MSG_RESULT([$with_gmime])
-fi
-
-case "$with_gmime" in
-    2.4) ;;
-    2.6) AC_DEFINE([HAVE_GMIME_2_6], [1],
-                   [Defined to build with GMime version 2.5 or 2.6])
-         if $PKG_CONFIG --atleast-version=2.5.7 gmime-2.6; then
-             AC_DEFINE([HAVE_GMIME_2_5_7], [1],
-                       [Defined when GMime version is at least 2.5.7])
-         fi
-         ;;
-    *) AC_MSG_ERROR([unknown GMime version $with_gmime]) ;;
-esac
-
 dnl #####################################################################
 dnl 4. Libraries.
 dnl #####################################################################
@@ -340,7 +291,7 @@ LIBS="$LIBS -lz"
 PKG_CHECK_MODULES(BALSA, [
 glib-2.0 >= 2.32.0
 gtk+-3.0 >= 3.4.0
-gmime-$with_gmime
+gmime-2.6
 gio-2.0
 gthread-2.0
 $gnome_extras
@@ -349,7 +300,7 @@ $gnome_extras
 PKG_CHECK_MODULES(BALSA_AB, [
    glib-2.0
    gtk+-3.0
-   gmime-$with_gmime
+   gmime-2.6
    $gnome_extras
 ])
 
@@ -391,11 +342,6 @@ AC_SUBST(BALSA_DEFS)
 #
 AC_MSG_CHECKING(whether to use an HTML widget)
 case "$use_html_widget" in
-    gtkhtml2)
-        AC_MSG_RESULT([$use_html_widget])
-        PKG_CHECK_MODULES(HTML, [ libgtkhtml-2.0 ])
-        AC_DEFINE(HAVE_GTKHTML2,1,[Defined when GtkHtml-2 can be used.])
-    ;;
     gtkhtml4)
         AC_MSG_RESULT([$use_html_widget])
         PKG_CHECK_MODULES(HTML, [ libgtkhtml-4.0 ], [],
@@ -405,11 +351,6 @@ case "$use_html_widget" in
     ;;
     webkit | webkit2)
         AC_MSG_RESULT([$use_html_widget])
-        if test x"$use_threads" = xno ; then
-            if ! $PKG_CONFIG --atleast-version=2.24.0 glib-2.0; then
-                AC_MSG_ERROR([WebKit cannot be used with threads disabled and glib older than version 2.24.])
-            fi
-        fi
         if test $use_html_widget = webkit2 ; then
             PKG_CHECK_MODULES(HTML, [ webkit2gtk-4.0 ])
             AC_DEFINE(USE_WEBKIT2,1,[Defined when WebKit2 is requested.])
@@ -453,11 +394,13 @@ if test x"$gpgmecfg" != xno ; then
         gpgme_ve=`echo $gpgmever|sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
         gpgme_ma=`echo $gpgmever|sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
         gpgme_mi=`echo $gpgmever|sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
-       if test $gpgme_ve -eq 0 ; then
-               if test $gpgme_ma -lt 9 ; then
-                       gpgmecfg=no
-                       have_smime=no
-               fi
+       if test $gpgme_ve -lt 1; then
+               gpgmecfg=no
+               have_smime=no
+       fi
+       if test \( $gpgme_ve -eq 1 \) -a \( $gpgme_ma -lt 2 \) ; then
+               gpgmecfg=no
+               have_smime=no
        fi
        if test x"$gpgmecfg" != xno ; then
                if test x"$use_threads" = xyes; then
@@ -472,7 +415,7 @@ if test x"$gpgmecfg" != xno ; then
                BALSA_CFLAGS="$BALSA_CFLAGS `$gpgmecfg --cflags`"
                gpgmecfg=yes
        else
-               AC_MSG_WARN([sorry, you need at least gpgme version 0.9.0])
+               AC_MSG_WARN([sorry, you need at least gpgme version 1.2.0])
        fi
 else
        have_smime=no
@@ -631,47 +574,6 @@ else
     AC_MSG_RESULT([no])
 fi
 
-# PCRE configuration.
-#
-
-AC_MSG_CHECKING(Regular expressions)
-if test x"$check_gregex" = xyes ; then
-    if $PKG_CONFIG --atleast-version=2.14.0 glib-2.0; then
-        AC_MSG_RESULT(GRegex)
-        AC_DEFINE(USE_GREGEX,1,[Defined when GRegex is to be used.])
-    else
-        AC_MSG_ERROR([*** You enabled GRegex but glib is too old. Please
-                      upgrade glib to version at least 2.14.0.])
-    fi
-else
-   if   test x"$check_pcre" = xyes ; then
-       if pcre-config --libs-posix > /dev/null 2>&1; then
-               vers=`pcre-config --version`
-               case $vers in
-                       2.*) have_pcre=no ;;
-                       *)   have_pcre=yes ;;
-               esac
-       else
-               have_pcre=no
-       fi
-
-       if test x"$have_pcre" = xyes ; then
-               AC_MSG_RESULT(PCRE)
-               BALSA_CFLAGS="$BALSA_CFLAGS `pcre-config --cflags-posix`"
-                PCRE_LIBS="`pcre-config --libs-posix`"
-                AC_SUBST(PCRE_LIBS)
-               BALSA_LIBS="$BALSA_LIBS $PCRE_LIBS"
-               AC_DEFINE(HAVE_PCRE,1,
-                          [Defined when PCRE library is available.])
-       else
-               AC_MSG_RESULT(not found)
-       fi
-   else
-       have_pcre=no
-       AC_MSG_RESULT(POSIX)
-   fi
-fi
-
 # OpenSSL configuration.
 #
 PKG_CHECK_MODULES(OPENSSL, [openssl],
@@ -829,8 +731,8 @@ dnl #####################################################################
 AC_C_CONST
 AC_STDC_HEADERS
 
-AC_CHECK_DECLS([localtime_r, gmtime_r, ctime_r], [], [], [[#include <time.h>]])
-AC_CHECK_FUNCS([localtime_r gmtime_r ctime_r])
+AC_CHECK_DECLS([ctime_r], [], [], [[#include <time.h>]])
+AC_CHECK_FUNCS([ctime_r])
 AC_CHECK_HEADER([zlib.h],,AC_MSG_ERROR([zlib library required]))
 
 # more warnings.
@@ -893,15 +795,7 @@ AC_MSG_RESULT($BALSA_FROM_GIT)
 dnl #####################################################################
 dnl 7. extra functions.
 dnl #####################################################################
-AC_CHECK_FUNCS(getaddrinfo getnameinfo gai_strerror)
-
-# isblank()
-AC_MSG_CHECKING([for isblank])
-AC_TRY_LINK( [#include <ctype.h>], [return isblank('a');],
-            AC_MSG_RESULT(yes),
-            [AC_MSG_RESULT(no)
-             AC_DEFINE(isblank,isspace,
-                        [Redefined to isspace if isblank is not available.])] )
+AC_CHECK_FUNCS(getaddrinfo)
 
 
 dnl ###########################################################################
@@ -1003,7 +897,6 @@ echo "         Use GtkSourceView: $with_gtksourceview"
 echo "              Use Compface: $with_compface"
 echo "  Install extra MIME icons: $install_mimeicons"
 echo "    Configure for Touch UI: $enable_touch_ui"
-echo "             GMime version: $with_gmime"
 echo "             Use libsecret: $with_libsecret"
 dnl echo "                  Use SASL: $need_sasl"
 echo ""
diff --git a/libbalsa/filter-funcs.c b/libbalsa/filter-funcs.c
index 81e94c7..b2028bf 100644
--- a/libbalsa/filter-funcs.c
+++ b/libbalsa/filter-funcs.c
@@ -496,11 +496,7 @@ libbalsa_condition_regex_free(LibBalsaConditionRegex* reg, gpointer throwaway)
 
     g_free(reg->string);
     if (reg->compiled) 
-#if USE_GREGEX
         g_regex_unref(reg->compiled);
-#else                           /* USE_GREGEX */
-       regfree(reg->compiled);
-#endif                          /* USE_GREGEX */
 }                              /* end condition_regex_free() */
 
 void 
diff --git a/libbalsa/filter-private.h b/libbalsa/filter-private.h
index 2bb5494..c008b84 100644
--- a/libbalsa/filter-private.h
+++ b/libbalsa/filter-private.h
@@ -32,15 +32,6 @@
 # error "Include config.h before this file."
 #endif
 
-#if !USE_GREGEX
-#  ifdef HAVE_PCRE
-#    include <pcreposix.h>
-#  else
-#    include <sys/types.h>
-#    include <regex.h>
-#  endif
-#endif                          /* USE_GREGEX */
-
 
 /* regex options */
 #define FILTER_REGCOMP       (REG_NEWLINE | REG_NOSUB | REG_EXTENDED)
@@ -49,11 +40,7 @@
 /* regex struct */
 struct _LibBalsaConditionRegex {
     gchar *string;
-#if USE_GREGEX
     GRegex *compiled;
-#else                           /* USE_GREGEX */
-    regex_t *compiled;
-#endif                          /* USE_GREGEX */
 };
 
 #endif                         /* __FILTER_PRIVATE_H__ */
diff --git a/libbalsa/gmime-multipart-crypt.c b/libbalsa/gmime-multipart-crypt.c
index 75a1ad9..64c36b2 100644
--- a/libbalsa/gmime-multipart-crypt.c
+++ b/libbalsa/gmime-multipart-crypt.c
@@ -369,11 +369,6 @@ g_mime_gpgme_mpe_encrypt(GMimeMultipartEncrypted * mpe,
     g_object_unref(wrapper);
     g_object_unref(stream);
 
-#if !defined(HAVE_GMIME_2_6)
-    mpe->decrypted = content;
-    g_object_ref(content);
-#endif
-
     /* construct the encrypted mime part */
     encrypted_part =
        g_mime_part_new_with_type("application", "octet-stream");
@@ -449,13 +444,6 @@ g_mime_gpgme_mpe_decrypt(GMimeMultipartEncrypted * mpe,
 
     g_return_val_if_fail(GMIME_IS_MULTIPART_ENCRYPTED(mpe), NULL);
 
-#if !defined(HAVE_GMIME_2_6)
-    if (mpe->decrypted) {
-       /* we seem to have already decrypted the part */
-       return mpe->decrypted;
-    }
-#endif
-
     if (signature && *signature) {
        g_object_unref(G_OBJECT(*signature));
        *signature = NULL;
@@ -549,9 +537,6 @@ g_mime_gpgme_mpe_decrypt(GMimeMultipartEncrypted * mpe,
 
 
     /* cache the decrypted part */
-#if !defined(HAVE_GMIME_2_6)
-    mpe->decrypted = decrypted;
-#endif
     if (signature) {
        if (sigstat->status != GPG_ERR_NOT_SIGNED)
            *signature = sigstat;
diff --git a/libbalsa/gmime-stream-gio.c b/libbalsa/gmime-stream-gio.c
index 214c785..3bda6c1 100644
--- a/libbalsa/gmime-stream-gio.c
+++ b/libbalsa/gmime-stream-gio.c
@@ -1,6 +1,6 @@
 /* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */
 /*  GMime GIO stream module
- *  Written/Copyright (c) by Albrecht Dre� <albrecht dress arcor de>
+ *  Written/Copyright (c) by Albrecht Dreß <albrecht dress arcor de>
  *  The basic structure of this file has been shamelessly stolen from the
  *  gmime-stream-fs module, written by Jeffrey Stedfast.
  *
@@ -51,11 +51,7 @@ static gint64 stream_seek(GMimeStream *stream,
                          gint64 offset,
                          GMimeSeekWhence whence);
 static gint64 stream_tell(GMimeStream *stream);
-#if defined(HAVE_GMIME_2_6)
 static gint64 stream_length(GMimeStream *stream);
-#else                           /* HAVE_GMIME_2_6 */
-static ssize_t stream_length(GMimeStream *stream);
-#endif                          /* HAVE_GMIME_2_6 */
 static GMimeStream *stream_substream(GMimeStream *stream,
                                     gint64 start,
                                     gint64 end);
@@ -383,11 +379,7 @@ stream_tell (GMimeStream *stream)
     return stream->position;
 }
 
-#if defined(HAVE_GMIME_2_6)
 static gint64
-#else                           /* HAVE_GMIME_2_6 */
-static ssize_t
-#endif                          /* HAVE_GMIME_2_6 */
 stream_length(GMimeStream *stream)
 {
     goffset bound_end;
diff --git a/libbalsa/html.h b/libbalsa/html.h
index 1856c77..baa200d 100644
--- a/libbalsa/html.h
+++ b/libbalsa/html.h
@@ -27,11 +27,6 @@
 # error "Include config.h before this file."
 #endif
 
-# if defined(HAVE_GTKHTML2)
-/* gtkhtml2 uses deprecated api */
-#  undef GTK_DISABLE_DEPRECATED
-# endif
-
 #  include <gtk/gtk.h>
 #include "libbalsa.h"
 
diff --git a/libbalsa/libbalsa.c b/libbalsa/libbalsa.c
index 73d19d5..49468f6 100644
--- a/libbalsa/libbalsa.c
+++ b/libbalsa/libbalsa.c
@@ -263,23 +263,23 @@ gboolean libbalsa_ldap_exists(const gchar *server)
 }
 
 gchar*
-libbalsa_date_to_utf8(const time_t *date, const gchar *date_string)
+libbalsa_date_to_utf8(const time_t date, const gchar *date_string)
 {
-    struct tm footime;
-    gchar rettime[128];
+       gchar *result;
 
-    g_return_val_if_fail(date != NULL, NULL);
     g_return_val_if_fail(date_string != NULL, NULL);
 
-    if (!*date)
+    if (date == (time_t) 0) {
         /* Missing "Date:" field?  It is required by RFC 2822. */
-        return NULL;
-
-    localtime_r(date, &footime);
+        result = NULL;
+    } else {
+       GDateTime *footime;
 
-    strftime(rettime, sizeof(rettime), date_string, &footime);
-
-    return g_locale_to_utf8(rettime, -1, NULL, NULL, NULL);
+       footime = g_date_time_new_from_unix_local(date);
+       result = g_date_time_format(footime, date_string);
+       g_date_time_unref(footime);
+    }
+    return result;
 }
 
 LibBalsaMessageStatus
diff --git a/libbalsa/libbalsa.h b/libbalsa/libbalsa.h
index 1de129b..b43ed49 100644
--- a/libbalsa/libbalsa.h
+++ b/libbalsa/libbalsa.h
@@ -130,7 +130,7 @@ gchar *libbalsa_guess_ldap_server(void);
 gchar *libbalsa_guess_imap_inbox(void);
 
 
-gchar* libbalsa_date_to_utf8(const time_t *date, const gchar *date_string);
+gchar* libbalsa_date_to_utf8(time_t date, const gchar *date_string);
 LibBalsaMessageStatus libbalsa_get_icon_from_flags(LibBalsaMessageFlag flags);
 
 gboolean libbalsa_is_cert_known(X509* cert, long vfy_result);
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index 860e44a..18884ed 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -3055,7 +3055,7 @@ mbox_model_get_value(GtkTreeModel *tree_model,
         break;
     case LB_MBOX_DATE_COL:
         if(msg) {
-            tmp = libbalsa_date_to_utf8(&msg->msg_date,
+            tmp = libbalsa_date_to_utf8(msg->msg_date,
                                        libbalsa_mailbox_date_format);
             g_value_take_string(value, tmp);
         }
diff --git a/libbalsa/mailbox_mbox.c b/libbalsa/mailbox_mbox.c
index fc946e0..78fa429 100644
--- a/libbalsa/mailbox_mbox.c
+++ b/libbalsa/mailbox_mbox.c
@@ -1843,57 +1843,6 @@ static void update_message_status_headers(GMimeMessage *message,
     g_string_free(new_header, TRUE);
 }
 
-#if !defined(HAVE_GMIME_2_6)
-/*
- * Encode text parts as quoted-printable.
- */
-static void
-lbm_mbox_prepare_object(GMimeObject * object)
-{
-    g_mime_object_remove_header(object, "Content-Length");
-
-    if (GMIME_IS_MULTIPART(object)) {
-        /* Do not break crypto */
-        if (!(GMIME_IS_MULTIPART_SIGNED(object) ||
-              GMIME_IS_MULTIPART_ENCRYPTED(object))) {
-            GMimeMultipart *multipart = (GMimeMultipart *) object;
-            gint i, count = g_mime_multipart_get_count(multipart);
-
-            for (i = 0; i < count; ++i)
-                lbm_mbox_prepare_object(g_mime_multipart_get_part
-                                        (multipart, i));
-        }
-    } else if (GMIME_IS_MESSAGE_PART(object))
-        lbm_mbox_prepare_object(GMIME_OBJECT
-                                (((GMimeMessagePart *) object)->message));
-    else if (GMIME_IS_MESSAGE(object))
-        lbm_mbox_prepare_object(((GMimeMessage *) object)->mime_part);
-    else if (GMIME_IS_PART(object)) {
-        GMimePart *mime_part = (GMimePart *) object;
-        GMimeContentEncoding encoding;
-        GMimeContentType *mime_type;
-
-        if (GMIME_IS_MESSAGE_PARTIAL(mime_part))
-            return;
-
-        encoding = g_mime_part_get_content_encoding(mime_part);
-        if (encoding == GMIME_CONTENT_ENCODING_BASE64)
-            return;
-
-        mime_type = g_mime_object_get_content_type(object);
-        if (g_mime_content_type_is_type(mime_type, "text", "plain")) {
-            const gchar *format =
-                g_mime_content_type_get_parameter(mime_type, "format");
-            if (format && !g_ascii_strcasecmp(format, "flowed"))
-                /* Format=Flowed text cannot contain From_ lines. */
-                return;
-        }
-
-        g_mime_part_set_content_encoding
-            (mime_part, GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE);
-    }
-}
-#endif                          /* defined(HAVE_GMIME_2_6) */
 
 static GMimeObject *
 lbm_mbox_armored_object(GMimeStream * stream)
@@ -1904,12 +1853,7 @@ lbm_mbox_armored_object(GMimeStream * stream)
     parser = g_mime_parser_new_with_stream(stream);
     object = GMIME_OBJECT(g_mime_parser_construct_message(parser));
     g_object_unref(parser);
-
-#if defined(HAVE_GMIME_2_6)
     g_mime_object_encode(object, GMIME_ENCODING_CONSTRAINT_7BIT);
-#else                           /* defined(HAVE_GMIME_2_6) */
-    lbm_mbox_prepare_object(object);
-#endif                          /* defined(HAVE_GMIME_2_6) */
 
     return object;
 }
diff --git a/libbalsa/message.h b/libbalsa/message.h
index b9e82ec..95769b2 100644
--- a/libbalsa/message.h
+++ b/libbalsa/message.h
@@ -342,8 +342,8 @@ glong libbalsa_message_get_length(LibBalsaMessage* msg);
 glong libbalsa_message_get_no(LibBalsaMessage* msg);
 LibBalsaMessageAttach libbalsa_message_get_attach_icon(LibBalsaMessage *
                                                       message);
-#define libbalsa_message_date_to_utf8(m, f) libbalsa_date_to_utf8(&(m)->headers->date, (f))
-#define libbalsa_message_headers_date_to_utf8(h, f) libbalsa_date_to_utf8(&(h)->date, (f))
+#define libbalsa_message_date_to_utf8(m, f) libbalsa_date_to_utf8((m)->headers->date, (f))
+#define libbalsa_message_headers_date_to_utf8(h, f) libbalsa_date_to_utf8((h)->date, (f))
 
 GList *libbalsa_message_refs_for_threading(LibBalsaMessage* msg);
 
diff --git a/libbalsa/mime.c b/libbalsa/mime.c
index 754fc91..41eec9d 100644
--- a/libbalsa/mime.c
+++ b/libbalsa/mime.c
@@ -677,11 +677,7 @@ is_in_url(GtkTextIter * iter, gint offset, GtkTextTag * url_tag)
 static gboolean prescanner(const gchar * p, guint len);
 static void mark_urls(GtkTextBuffer * buffer, GtkTextIter * iter,
                       GtkTextTag * tag, const gchar * p);
-#if USE_GREGEX
 static GRegex *get_url_reg(void);
-#else                           /* USE_GREGEX */
-static regex_t *get_url_reg(void);
-#endif                          /* USE_GREGEX */
 
 void
 libbalsa_unwrap_buffer(GtkTextBuffer * buffer, GtkTextIter * iter,
@@ -755,7 +751,6 @@ mark_urls(GtkTextBuffer * buffer, GtkTextIter * iter, GtkTextTag * tag,
 {
     const gchar *p = line;
     const gchar * const line_end = line + strlen(line);
-#if USE_GREGEX
     GRegex *url_reg = get_url_reg();
     GMatchInfo *url_match;
     GtkTextIter start = *iter;
@@ -778,24 +773,6 @@ mark_urls(GtkTextBuffer * buffer, GtkTextIter * iter, GtkTextTag * tag,
         g_match_info_free(url_match);
     }
     g_match_info_free(url_match);
-#else                          /* USE_GREGEX */
-    regex_t *url_reg = get_url_reg();
-    regmatch_t url_match;
-    GtkTextIter start = *iter;
-    GtkTextIter end = *iter;
-
-    while (!regexec(url_reg, p, 1, &url_match, 0)) {
-        glong offset = g_utf8_pointer_to_offset(line, p + url_match.rm_so);
-        gtk_text_iter_set_line_offset(&start, offset);
-        offset = g_utf8_pointer_to_offset(line, p + url_match.rm_eo);
-        gtk_text_iter_set_line_offset(&end, offset);
-        gtk_text_buffer_apply_tag(buffer, tag, &start, &end);
-
-        p += url_match.rm_eo;
-        if (!prescanner(p, line_end - p))
-            break;
-    }
-#endif                          /* USE_GREGEX */
 }
 
 /*
@@ -853,7 +830,6 @@ prescanner(const gchar * s, guint len)
     return FALSE;
 }
 
-#if USE_GREGEX
 struct url_regex_info {
     GRegex *url_reg;
     const gchar *str;
@@ -919,68 +895,6 @@ get_ml_flowed_url_reg(void)
 
     return get_url_helper(&info);
 }
-#else                           /* USE_GREGEX */
-static regex_t *
-get_url_reg(void)
-{
-    static regex_t *url_reg = NULL;
-
-    if (!url_reg) {
-        /* one-time compilation of a constant url_str expression */
-        static const char url_str[] =
-            "(((https?|ftps?|nntp)://)|(mailto:|news:))"
-            "(%[0-9A-F]{2}|[-_.!~*';/?:@&=+$,#[:alnum:]])+";
-
-        url_reg = g_new(regex_t, 1);
-        if (regcomp(url_reg, url_str, REG_EXTENDED | REG_ICASE) != 0)
-            g_warning("libbalsa_insert_with_url: "
-                      "url regex compilation failed.");
-    }
-
-    return url_reg;
-}
-
-static regex_t *
-get_ml_url_reg(void)
-{
-    static regex_t *url_reg = NULL;
-    
-    if (!url_reg) {
-        /* one-time compilation of a constant url_str expression */
-        static const char url_str[] =
-            "("
-            "%[0-9A-F]{2}|[-_.!~*';/?:@&=+$,#[:alnum:]]|[ \t]*[\r\n]+[ \t>]*"
-            ")+"
-            "(%[0-9A-F]{2}|[-_.!~*';/?:@&=+$,#[:alnum:]])>";
-
-       url_reg = g_new(regex_t, 1);
-        if (regcomp(url_reg, url_str, REG_EXTENDED | REG_ICASE) != 0)
-            g_warning("libbalsa_insert_with_url: "
-                      "multiline url regex compilation failed.");
-    }
-    
-    return url_reg;
-}
-
-static regex_t *
-get_ml_flowed_url_reg(void)
-{
-    static regex_t *url_reg = NULL;
-    
-    if (!url_reg) {
-        /* one-time compilation of a constant url_str expression */
-        static const char url_str[] =
-           "(%[0-9A-F]{2}|[-_.!~*';/?:@&=+$,#[:alnum:]]|[ \t]+)+>";
-
-       url_reg = g_new(regex_t, 1);
-        if (regcomp(url_reg, url_str, REG_EXTENDED | REG_ICASE) != 0)
-            g_warning("libbalsa_insert_with_url: "
-                      "multiline url regex compilation failed.");
-    }
-    
-    return url_reg;
-}
-#endif                          /* USE_GREGEX */
 
 gboolean
 libbalsa_insert_with_url(GtkTextBuffer * buffer,
@@ -993,14 +907,9 @@ libbalsa_insert_with_url(GtkTextBuffer * buffer,
     GtkTextTagTable *table = gtk_text_buffer_get_tag_table(buffer);
     GtkTextTag *url_tag = gtk_text_tag_table_lookup(table, "url");
     gboolean match;
-#if USE_GREGEX
     gint start_pos, end_pos;
     GRegex *url_reg;
     GMatchInfo *url_match;
-#else                           /* USE_GREGEX */
-    regex_t *url_reg;
-    regmatch_t url_match;
-#endif                          /* USE_GREGEX */
     const gchar * const line_end = chars + len;
 
     gtk_text_buffer_get_iter_at_mark(buffer, &iter,
@@ -1041,7 +950,6 @@ libbalsa_insert_with_url(GtkTextBuffer * buffer,
         return FALSE;
     }
 
-#if USE_GREGEX
     url_reg = get_url_reg();
     match = g_regex_match(url_reg, chars, 0, &url_match)
         && g_match_info_fetch_pos(url_match, 0, &start_pos, &end_pos)
@@ -1131,91 +1039,6 @@ libbalsa_insert_with_url(GtkTextBuffer * buffer,
             match = FALSE;
     }
     g_match_info_free(url_match);
-#else                           /* USE_GREGEX */
-    url_reg = get_url_reg();
-    match = regexec(url_reg, chars, 1, &url_match, 0) == 0
-        && chars + url_match.rm_so < line_end;
-
-    while (match) {
-        gchar *spc;
-        gint start_pos, end_pos;
-
-        start_pos = url_match.rm_so;
-        end_pos = url_match.rm_eo;
-
-        gtk_text_buffer_insert_with_tags(buffer, &iter, chars,
-                                         start_pos, tag, NULL);
-
-        /* check if we hit a multi-line URL... (see RFC 1738) */
-        if ((start_pos > 0 && (chars[start_pos - 1] == '<')) ||
-            (start_pos > 4 &&
-             !g_ascii_strncasecmp(chars + start_pos - 5, "<URL:", 5))) {
-            regex_t *ml_url_reg;
-            regmatch_t ml_url_match;
-
-            /* if the input is flowed, we may see a space at
-             * url_match.rm_eo - in this case the complete remainder
-             * of the ml uri should be in the passed buffer... */
-            if (url_info->buffer_is_flowed && chars[end_pos] == ' ') {
-                ml_url_reg = get_ml_flowed_url_reg();
-                if (!regexec(ml_url_reg, chars + end_pos, 1,
-                             &ml_url_match, 0)
-                    && ml_url_match.rm_so == 0)
-                    end_pos += ml_url_match.rm_eo - 1;
-            } else if (chars[end_pos] != '>') {
-                ml_url_reg = get_ml_url_reg();
-                if (!regexec(ml_url_reg, chars + end_pos, 1,
-                             &ml_url_match, 0)
-                    && ml_url_match.rm_so == 0) {
-                    chars += start_pos;
-                    url_info->ml_url_buffer =
-                        g_string_new_len(chars, line_end - chars);
-                    g_string_append_c(url_info->ml_url_buffer, '\n');
-                    return TRUE;
-                }
-            }
-        }
-
-        /* add the url - it /may/ contain spaces if the text is flowed */
-        if ((spc = strchr(chars + start_pos, ' ')) && spc < chars + end_pos) {
-            GString *uri_real = g_string_new("");
-            gchar *q, *buf;
-
-            q = buf = g_strndup(chars + start_pos, end_pos - start_pos);
-            spc = buf + (spc - (chars + start_pos));
-            do {
-                *spc = '\n';
-                g_string_append_len(uri_real, q, spc - q);
-                q = spc + 1;
-            } while ((spc = strchr(q, ' ')));
-            g_string_append(uri_real, q);
-            gtk_text_buffer_insert_with_tags(buffer, &iter, buf, -1,
-                                             url_tag, tag, NULL);
-            g_free(buf);
-            url_info->callback(buffer, &iter,
-                               uri_real->str, uri_real->len,
-                               url_info->callback_data);
-            g_string_free(uri_real, TRUE);
-        } else {
-            gtk_text_buffer_insert_with_tags(buffer, &iter,
-                                             chars + start_pos,
-                                             end_pos - start_pos,
-                                             url_tag, tag, NULL);
-
-            /* remember the URL and its position within the text */
-            url_info->callback(buffer, &iter, chars + start_pos,
-                               end_pos - start_pos,
-                               url_info->callback_data);
-        }
-
-        chars += end_pos;
-        if (prescanner(chars, line_end - chars))
-            match = regexec(url_reg, chars, 1, &url_match, 0) == 0
-                && chars + url_match.rm_so < line_end;
-        else
-            match = FALSE;
-    }
-#endif                          /* USE_GREGEX */
 
     gtk_text_buffer_insert_with_tags(buffer, &iter, chars,
                                      line_end - chars, tag, NULL);
@@ -1224,11 +1047,7 @@ libbalsa_insert_with_url(GtkTextBuffer * buffer,
 }
 
 void
-#if USE_GREGEX
 libbalsa_unwrap_selection(GtkTextBuffer * buffer, GRegex * rex)
-#else                           /* USE_GREGEX */
-libbalsa_unwrap_selection(GtkTextBuffer * buffer, regex_t * rex)
-#endif                          /* USE_GREGEX */
 {
     GtkTextIter start, end;
     gchar *line;
@@ -1299,7 +1118,6 @@ libbalsa_unwrap_selection(GtkTextBuffer * buffer, regex_t * rex)
     }
 }
 
-#if USE_GREGEX
 gboolean
 libbalsa_match_regex(const gchar * line, GRegex * rex, guint * count,
                      guint * index)
@@ -1326,26 +1144,6 @@ libbalsa_match_regex(const gchar * line, GRegex * rex, guint * count,
         *index = p - line;
     return c > 0;
 }
-#else                           /* USE_GREGEX */
-gboolean
-libbalsa_match_regex(const gchar * line, regex_t * rex, guint * count,
-                    guint * index)
-{
-    regmatch_t rm;
-    gint c;
-    const gchar *p;
-
-    c = 0;
-    for (p = line; !regexec(rex, p, 1, &rm, 0) && rm.rm_eo > 0;
-         p += rm.rm_eo)
-       c++;
-    if (count)
-       *count = c;
-    if (index)
-       *index = p - line;
-    return c > 0;
-}
-#endif                          /* USE_GREGEX */
 
 
 GString *
@@ -1353,13 +1151,8 @@ libbalsa_html_encode_hyperlinks(GString * paragraph)
 {
     GString * retval;
     gchar * p;
-#if USE_GREGEX
     GRegex *url_reg = get_url_reg();
     GMatchInfo *url_match;
-#else
-    regex_t *url_reg = get_url_reg();
-    regmatch_t url_match;
-#endif
     gboolean match;
     gchar * markup;
 
@@ -1375,22 +1168,13 @@ libbalsa_html_encode_hyperlinks(GString * paragraph)
     retval = g_string_new("");
     p = paragraph->str;
 
-#if USE_GREGEX
     match = g_regex_match(url_reg, p, 0, &url_match);
-#else
-    match = regexec(url_reg, p, 1, &url_match, 0) == 0;
-#endif
 
     while (match) {
         gint start_pos, end_pos;
 
-#if USE_GREGEX
         if (!g_match_info_fetch_pos(url_match, 0, &start_pos, &end_pos))
             break;
-#else
-        start_pos = url_match.rm_so;
-        end_pos   = url_match.rm_eo;
-#endif
 
         /* add the url to the result */
         if (start_pos > 0) {
@@ -1407,18 +1191,12 @@ libbalsa_html_encode_hyperlinks(GString * paragraph)
         /* find next (if any) */
         p += end_pos;
         if (prescanner(p, paragraph->len - (p - paragraph->str))) {
-#if USE_GREGEX
             g_match_info_free(url_match);
             match = g_regex_match(url_reg, p, 0, &url_match);
-#else
-            match = regexec(url_reg, p, 1, &url_match, 0) == 0;
-#endif
         } else
             match = FALSE;
     }
-#if USE_GREGEX
     g_match_info_free(url_match);
-#endif                          /* USE_GREGEX */
 
     /* copy remainder */
     if (*p != '\0') {
diff --git a/libbalsa/misc.h b/libbalsa/misc.h
index 4acd0e6..0156ece 100644
--- a/libbalsa/misc.h
+++ b/libbalsa/misc.h
@@ -31,15 +31,6 @@
 #include <gtk/gtk.h>
 #include <gmime/gmime.h>
 
-#if !USE_GREGEX
-#  ifdef HAVE_PCRE
-#    include <pcreposix.h>
-#  else
-#    include <sys/types.h>
-#    include <regex.h>
-#  endif
-#endif                          /* USE_GREGEX */
-
 typedef enum _LibBalsaCodeset LibBalsaCodeset;
 
 enum _LibBalsaCodeset {
@@ -140,15 +131,9 @@ gboolean libbalsa_insert_with_url(GtkTextBuffer * buffer,
                                  guint len,
                                  GtkTextTag * tag,
                                  LibBalsaUrlInsertInfo *url_info);
-#if USE_GREGEX
 void libbalsa_unwrap_selection(GtkTextBuffer * buffer, GRegex * rex);
 gboolean libbalsa_match_regex(const gchar * line, GRegex * rex,
                              guint * count, guint * index);
-#else                           /* USE_GREGEX */
-void libbalsa_unwrap_selection(GtkTextBuffer * buffer, regex_t * rex);
-gboolean libbalsa_match_regex(const gchar * line, regex_t * rex,
-                             guint * count, guint * index);
-#endif                          /* USE_GREGEX */
 
 int libbalsa_safe_open (const char *path, int flags, mode_t mode, GError **err);
 int libbalsa_lock_file (const char *path, int fd, int excl, int dot, int timeout);
diff --git a/libbalsa/missing.h b/libbalsa/missing.h
index c5d1b73..3999b45 100644
--- a/libbalsa/missing.h
+++ b/libbalsa/missing.h
@@ -33,13 +33,5 @@
 char * ctime_r(const time_t *clock, char *buf);
 #endif
 
-#if (HAVE_DECL_LOCALTIME_R == 0)
-struct tm * localtime_r(const time_t *clock, struct tm *result);
-#endif
-
-#if (HAVE_DECL_GMTIME_R == 0)
-struct tm * gmtime_r(const time_t *clock, struct tm *result);
-#endif
-
 #endif
 
diff --git a/libbalsa/missing_time.c b/libbalsa/missing_time.c
index 7164e17..8eeae41 100644
--- a/libbalsa/missing_time.c
+++ b/libbalsa/missing_time.c
@@ -24,9 +24,7 @@
 # include "config.h"
 #endif                          /* HAVE_CONFIG_H */
 
-#if !defined(HAVE_CTIME_R)     || \
-    !defined(HAVE_LOCALTIME_R) || \
-    !defined(HAVE_GMTIME_R)
+#if !defined(HAVE_CTIME_R)
 
 #include "missing.h"
 
@@ -53,27 +51,4 @@ ctime_r(const time_t *clock, char *buf)
 }
 #endif
 
-
-#ifndef HAVE_LOCALTIME_R 
-struct tm *
-localtime_r(const time_t *clock, struct tm *result)
-{
-    LOCK(time_lock);
-    memcpy(result, localtime(clock), sizeof(struct tm));
-    UNLOCK(time_lock);
-    return result;
-}
-#endif
-
-
-#ifndef HAVE_GMTIME_R
-struct tm *
-gmtime_r(const time_t *clock, struct tm *result)
-{
-    LOCK(time_lock);
-    memcpy(result, gmtime(clock), sizeof(struct tm));
-    UNLOCK(time_lock);
-    return result;
-}
-#endif
 #endif
diff --git a/libbalsa/rfc2445.c b/libbalsa/rfc2445.c
index fe208f8..081b61e 100644
--- a/libbalsa/rfc2445.c
+++ b/libbalsa/rfc2445.c
@@ -1,7 +1,7 @@
 /* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */
 /*
  * VCalendar (RFC 2445) stuff
- * Copyright (C) 2009 Albrecht Dre� <albrecht dress arcor de>
+ * Copyright (C) 2009 Albrecht Dreß <albrecht dress arcor de>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -536,62 +536,27 @@ libbalsa_vevent_reply(const LibBalsaVEvent * event, const gchar * sender,
 
 /* -- rfc 2445 parser helper functions -- */
 
-#define FILL_TM(tm, buf, idx)                   \
-    do {                                        \
-        tm = atoi(buf + idx);                   \
-        buf[idx] = '\0';                        \
-    } while (0)
-
 /* convert a rfc 2445 time string into a time_t value */
 // FIXME - what about entries containing a TZID?
 static time_t
-date_time_2445_to_time_t(const gchar * date_time)
+date_time_2445_to_time_t(const gchar *date_time)
 {
     gint len;
-    struct tm tm_buf;
-    char strbuf[17];
-    time_t the_time;
-    struct tm utc_tm;
-    time_t utc_time;
-    gint diff_min;
+    time_t the_time = (time_t) (-1);;
 
     g_return_val_if_fail(date_time != NULL, (time_t) (-1));
     len = strlen(date_time);
 
     /* must be yyyymmddThhmmssZ? */
-    if (len < 15 || len > 16 || date_time[8] != 'T' ||
-       (len == 16 && date_time[15] != 'Z'))
-       return (time_t) - 1;
-
-    /* fill for conversion... */
-    strcpy(strbuf, date_time); /* safe, due to checks above */
-    if (len == 16) {
-       strbuf[15] = '\0';
+    if (((len == 15) || ((len == 16) && (date_time[15] == 'Z'))) &&
+       (date_time[8] == 'T')) {
+        GTimeVal timeval;
+
+        /* the rfc2445 date-time is a special case of an iso8901 date/time value... */
+        if (g_time_val_from_iso8601(date_time, &timeval)) {
+               the_time = timeval.tv_sec;
+        }
     }
-    FILL_TM(tm_buf.tm_sec, strbuf, 13);
-    FILL_TM(tm_buf.tm_min, strbuf, 11);
-    FILL_TM(tm_buf.tm_hour, strbuf, 9);
-    FILL_TM(tm_buf.tm_mday, strbuf, 6);
-    FILL_TM(tm_buf.tm_mon, strbuf, 4);
-    FILL_TM(tm_buf.tm_year, strbuf, 0);
-    tm_buf.tm_mon--;
-    tm_buf.tm_year -= 1900;
-    tm_buf.tm_isdst = -1;
-    the_time = mktime(&tm_buf);
-
-    /* return value if local time was requested */
-    if (len == 15)
-       return the_time;
-
-    /* adjust for utc */
-    gmtime_r(&the_time, &utc_tm);
-    utc_tm.tm_isdst = -1;
-    utc_time = mktime(&utc_tm);
-    diff_min = (utc_time - the_time) / 60;
-    tm_buf.tm_min -= diff_min % 60;
-    tm_buf.tm_hour -= diff_min / 60;
-    tm_buf.tm_isdst = -1;
-    the_time = mktime(&tm_buf);
 
     return the_time;
 }
@@ -600,12 +565,15 @@ date_time_2445_to_time_t(const gchar * date_time)
 static gchar *
 time_t_to_date_time_2445(time_t ttime)
 {
-    gchar *retval = g_malloc(17);
-    struct tm tm;
+       gchar *retval = NULL;
+       GDateTime *date_time;
 
-    gmtime_r(&ttime, &tm);
-    strftime(retval, 17, "%Y%m%dT%H%M%SZ", &tm);
-    return retval;
+       date_time = g_date_time_new_from_unix_utc(ttime);
+       if (date_time != NULL) {
+               retval = g_date_time_format(date_time, "%Y%m%dT%H%M%SZ");
+               g_date_time_unref(date_time);
+       }
+       return retval;
 }
 
 
diff --git a/libbalsa/rfc3156.c b/libbalsa/rfc3156.c
index 64da2dd..fae4284 100644
--- a/libbalsa/rfc3156.c
+++ b/libbalsa/rfc3156.c
@@ -749,10 +749,10 @@ libbalsa_gpgme_sig_protocol_name(gpgme_protocol_t protocol)
 }
 
 static inline void
-append_time_t(GString *str, const gchar *format, time_t *when,
+append_time_t(GString *str, const gchar *format, time_t when,
               const gchar * date_string)
 {
-    if (*when != (time_t) 0) {
+    if (when != (time_t) 0) {
         gchar *tbuf = libbalsa_date_to_utf8(when, date_string);
         g_string_append_printf(str, format, tbuf);
         g_free(tbuf);
@@ -777,7 +777,7 @@ libbalsa_signature_info_to_gchar(GMimeGpgmeSigstat * info,
     g_string_append_printf(msg, _("\nSignature validity: %s"),
                           libbalsa_gpgme_validity_to_gchar(info->
                                                            validity));
-    append_time_t(msg, _("\nSigned on: %s"), &info->sign_time, date_string);
+    append_time_t(msg, _("\nSigned on: %s"), info->sign_time, date_string);
     if (info->protocol == GPGME_PROTOCOL_OpenPGP && info->key)
        g_string_append_printf(msg, _("\nKey owner trust: %s"),
                               libbalsa_gpgme_validity_to_gchar_short
@@ -841,9 +841,9 @@ libbalsa_signature_info_to_gchar(GMimeGpgmeSigstat * info,
 
             if (subkey) {
                append_time_t(msg, _("\nSubkey created on: %s"),
-                             &subkey->timestamp, date_string);
+                             subkey->timestamp, date_string);
                append_time_t(msg, _("\nSubkey expires on: %s"),
-                             &subkey->expires, date_string);
+                             subkey->expires, date_string);
                if (subkey->revoked || subkey->expired || subkey->disabled ||
                    subkey->invalid) {
        GString * attrs = g_string_new("");
diff --git a/libbalsa/send.c b/libbalsa/send.c
index e4e47eb..559111a 100644
--- a/libbalsa/send.c
+++ b/libbalsa/send.c
@@ -1702,32 +1702,21 @@ parse_content_type(const char* content_type)
     return ret;
 }
 
-/* get_tz_offset() returns tz offset in minutes. NOTE: not all hours
-   have 60 seconds! Once in a while they get corrected.  */
-#define MIN_SEC                60              /* seconds in a minute */
-#define        HOUR_MIN        60              /* minutes in an hour */
-#define DAY_MIN                (24 * HOUR_MIN) /* minutes in a day */
-
-static int
-get_tz_offset(time_t *t)
+/* get_tz_offset() returns tz offset in RFC 5322 format ([-]hhmm) */
+static gint
+get_tz_offset(time_t t)
 {
-    struct tm gmt, lt;
-    int off;
-    gmtime_r(t, &gmt);
-    localtime_r(t, &lt);
-
-    off = (lt.tm_hour - gmt.tm_hour) * HOUR_MIN + lt.tm_min - gmt.tm_min;
-    if (lt.tm_year < gmt.tm_year)       off -= DAY_MIN;
-    else if (lt.tm_year > gmt.tm_year) off += DAY_MIN;
-    else if (lt.tm_yday < gmt.tm_yday)  off -= DAY_MIN;
-    else if (lt.tm_yday > gmt.tm_yday)  off += DAY_MIN;
-
-    /* special case: funny minutes */
-    if (lt.tm_sec <= gmt.tm_sec - MIN_SEC) off -= 1;
-    else if (lt.tm_sec >= gmt.tm_sec + MIN_SEC)        off += 1;
-
-    return (off*100)/60; /* time zone offset in hundreds of hours (funny
-                          * unit required by gmime) */
+       GTimeZone *local_tz;
+       gint interval;
+       gint32 offset;
+       gint hours;
+
+       local_tz = g_time_zone_new_local();
+       interval = g_time_zone_find_interval(local_tz, G_TIME_TYPE_UNIVERSAL, t);
+       offset = g_time_zone_get_offset(local_tz, interval);
+       g_time_zone_unref(local_tz);
+       hours = offset / 3600;
+       return (hours * 100) + ((offset - (hours * 3600)) / 60);
 }
 
 static LibBalsaMsgCreateResult
@@ -1964,7 +1953,7 @@ libbalsa_message_create_mime_message(LibBalsaMessage* message, gboolean flow,
                                   LIBBALSA_MESSAGE_GET_SUBJECT(message));
 
     g_mime_message_set_date(mime_message, message->headers->date,
-                            get_tz_offset(&message->headers->date));
+                            get_tz_offset(message->headers->date));
 
     if ((ia_list = message->headers->to_list)) {
         InternetAddressList *recipients =
diff --git a/src/balsa-app.c b/src/balsa-app.c
index 22b8f01..0e3e04c 100644
--- a/src/balsa-app.c
+++ b/src/balsa-app.c
@@ -899,7 +899,6 @@ balsa_find_index_by_mailbox(LibBalsaMailbox * mailbox)
     return NULL;
 }
 
-#if USE_GREGEX
 GRegex *
 balsa_quote_regex_new(void)
 {
@@ -927,4 +926,3 @@ balsa_quote_regex_new(void)
 
     return g_regex_ref(regex);
 }
-#endif                          /* USE_GREGEX */
diff --git a/src/balsa-app.h b/src/balsa-app.h
index 5d72810..8a12b1d 100644
--- a/src/balsa-app.h
+++ b/src/balsa-app.h
@@ -418,8 +418,6 @@ BalsaIndex* balsa_find_index_by_mailbox(LibBalsaMailbox* mailbox);
 
 void  balsa_remove_children_mailbox_nodes(BalsaMailboxNode * mbnode);
 
-#if USE_GREGEX
 GRegex *balsa_quote_regex_new(void);
-#endif                          /* USE_GREGEX */
 
 #endif                         /* __BALSA_APP_H__ */
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index 156b44b..1bbf070 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -1315,26 +1315,14 @@ fill_text_buf_cited(GtkWidget *widget, const gchar *text_body,
     PangoContext *context = gtk_widget_get_pango_context(widget);
     PangoFontDescription *desc = pango_context_get_font_description(context);
     GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget));
-#if USE_GREGEX
     GRegex *rex = NULL;
-#else                           /* USE_GREGEX */
-    regex_t rex;
-#endif                          /* USE_GREGEX */
     gboolean have_regex;
     GdkRGBA *rgba;
 
     /* prepare citation regular expression for plain bodies */
     if (is_plain) {
-#if USE_GREGEX
         rex = balsa_quote_regex_new();
         have_regex = rex ? TRUE : FALSE;
-#else                           /* USE_GREGEX */
-        if (!balsa_app.mark_quoted
-            || regcomp(&rex, balsa_app.quote_regex, REG_EXTENDED))
-            have_regex = FALSE;
-        else
-            have_regex = TRUE;
-#endif                          /* USE_GREGEX */
     } else
         have_regex = FALSE;
 
@@ -1382,13 +1370,8 @@ fill_text_buf_cited(GtkWidget *widget, const gchar *text_body,
             guint cite_idx;
 
             /* get the cite level only for text/plain parts */
-#if USE_GREGEX
             libbalsa_match_regex(text_body, rex, &quote_level,
                                  &cite_idx);
-#else                           /* USE_GREGEX */
-            libbalsa_match_regex(text_body, &rex, &quote_level,
-                                 &cite_idx);
-#endif                          /* USE_GREGEX */
 
             /* check if the citation level changed */
             if (cite_level != quote_level) {
@@ -1458,11 +1441,7 @@ fill_text_buf_cited(GtkWidget *widget, const gchar *text_body,
     }
 
     if (have_regex)
-#if USE_GREGEX
         g_regex_unref(rex);
-#else                           /* USE_GREGEX */
-        regfree(&rex);
-#endif                          /* USE_GREGEX */
 
     return url_list;
 }
diff --git a/src/balsa-mime-widget-vcalendar.c b/src/balsa-mime-widget-vcalendar.c
index b27d8b3..f3c30e3 100644
--- a/src/balsa-mime-widget-vcalendar.c
+++ b/src/balsa-mime-widget-vcalendar.c
@@ -124,7 +124,7 @@ balsa_mime_widget_new_vcalendar(BalsaMessage * bm,
     do {                                                                \
         if (date != (time_t) -1) {                                      \
             gchar * _dstr =                                             \
-                libbalsa_date_to_utf8(&date, balsa_app.date_string);    \
+                libbalsa_date_to_utf8(date, balsa_app.date_string);     \
             GRID_ATTACH(g, _dstr, label);                               \
             g_free(_dstr);                                              \
         }                                                               \
diff --git a/src/balsa-print-object-text.c b/src/balsa-print-object-text.c
index afe721f..6ae111e 100644
--- a/src/balsa-print-object-text.c
+++ b/src/balsa-print-object-text.c
@@ -1,7 +1,7 @@
 /* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */
 /* Balsa E-Mail Client
  * Copyright (C) 1997-2013 Stuart Parmenter and others
- * Written by (C) Albrecht Dre� <albrecht dress arcor de> 2007
+ * Written by (C) Albrecht Dreß <albrecht dress arcor de> 2007
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -137,11 +137,7 @@ balsa_print_object_text_plain(GList *list, GtkPrintContext * context,
                              LibBalsaMessageBody * body,
                              BalsaPrintSetup * psetup)
 {
-#if USE_GREGEX
     GRegex *rex;
-#else                           /* USE_GREGEX */
-    regex_t rex;
-#endif                          /* USE_GREGEX */
     gchar *textbuf;
     PangoFontDescription *font;
     gdouble c_at_x;
@@ -152,11 +148,7 @@ balsa_print_object_text_plain(GList *list, GtkPrintContext * context,
     gint par_len;
 
     /* set up the regular expression for qouted text */
-#if USE_GREGEX
     if (!(rex = balsa_quote_regex_new()))
-#else                           /* USE_GREGEX */
-    if (regcomp(&rex, balsa_app.quote_regex, REG_EXTENDED) != 0)
-#endif                          /* USE_GREGEX */
        return balsa_print_object_default(list, context, body, psetup);
 
     /* start on new page if less than 2 lines can be printed */
@@ -223,13 +215,7 @@ balsa_print_object_text_plain(GList *list, GtkPrintContext * context,
            thispar = g_strndup(par_start, par_len);
 
            /* get the cite level and strip off the prefix */
-#if USE_GREGEX
-           if (libbalsa_match_regex
-               (thispar, rex, &cite_level, &cite_idx))
-#else                           /* USE_GREGEX */
-           if (libbalsa_match_regex
-               (thispar, &rex, &cite_level, &cite_idx))
-#endif                          /* USE_GREGEX */
+           if (libbalsa_match_regex(thispar, rex, &cite_level, &cite_idx))
             {
                gchar *new;
 
@@ -335,9 +321,7 @@ balsa_print_object_text_plain(GList *list, GtkPrintContext * context,
     /* clean up */
     pango_font_description_free(font);
     g_free(textbuf);
-#if USE_GREGEX
     g_regex_unref(rex);
-#endif                          /* USE_GREGEX */
     return list;
 }
 
@@ -577,7 +561,7 @@ balsa_print_object_text_vcard(GList * list,
     do {                                                                \
         if (date != (time_t) -1) {                                      \
             gchar * _dstr =                                             \
-                libbalsa_date_to_utf8(&date, balsa_app.date_string);    \
+                libbalsa_date_to_utf8(date, balsa_app.date_string);     \
             ADD_VCAL_FIELD(buf, labwidth, layout, _dstr, descr);        \
             g_free(_dstr);                                              \
         }                                                               \
diff --git a/src/filter-edit-callbacks.c b/src/filter-edit-callbacks.c
index e296c33..ec4be7b 100644
--- a/src/filter-edit-callbacks.c
+++ b/src/filter-edit-callbacks.c
@@ -724,8 +724,8 @@ fill_condition_widgets(LibBalsaCondition* cnd)
     GtkTreeModel *model =
         gtk_tree_view_get_model(fe_type_regex_list);
 #endif                  /* REGULAR_EXPRESSION_FILTERING_IS_IMPLEMENTED */
-    gchar str[20];
-    struct tm date;
+    gchar *str;
+    GDateTime *date;
     gint row,col;
     gboolean andmask;
     static gchar xformat[] = "%x"; /* to suppress error in strftime */
@@ -800,18 +800,22 @@ fill_condition_widgets(LibBalsaCondition* cnd)
 #endif
         break;
     case CONDITION_DATE:
-        if (cnd->match.date.date_low==0) str[0]='\0';
+        if (cnd->match.date.date_low==0) str = g_strdup("");
         else {
-            localtime_r(&cnd->match.date.date_low, &date);
-            strftime(str, sizeof(str), xformat, &date);
+               date = g_date_time_new_from_unix_local(cnd->match.date.date_low);
+            str = g_date_time_format(date, xformat);
+            g_date_time_unref(date);
         }
         gtk_entry_set_text(GTK_ENTRY(fe_type_date_low_entry),str);
-        if (cnd->match.date.date_high==0) str[0]='\0';
+        g_free(str);
+        if (cnd->match.date.date_high==0) str = g_strdup("");
         else {
-            localtime_r(&cnd->match.date.date_high, &date);
-            strftime(str,sizeof(str), xformat, &date);
+               date = g_date_time_new_from_unix_local(cnd->match.date.date_low);
+            str = g_date_time_format(date, xformat);
+            g_date_time_unref(date);
         }
         gtk_entry_set_text(GTK_ENTRY(fe_type_date_high_entry),str);
+        g_free(str);
         fe_update_label(fe_type_date_label, &date_label);
         break;
     case CONDITION_FLAG:
diff --git a/src/quote-color.c b/src/quote-color.c
index fa91b0a..85eae8a 100644
--- a/src/quote-color.c
+++ b/src/quote-color.c
@@ -63,11 +63,7 @@ make_gradient(GdkColor colors[], gint first, gint last)
  *   an integer saying how many levels deep.  
  * */
 guint
-#if USE_GREGEX
 is_a_quote(const gchar * str, GRegex * rex)
-#else                           /* USE_GREGEX */
-is_a_quote(const gchar * str, regex_t * rex)
-#endif                          /* USE_GREGEX */
 {
     guint cnt;
 
diff --git a/src/quote-color.h b/src/quote-color.h
index 659afba..c219d39 100644
--- a/src/quote-color.h
+++ b/src/quote-color.h
@@ -30,25 +30,8 @@
 
 G_BEGIN_DECLS
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#if !USE_GREGEX
-#  ifdef HAVE_PCRE
-#    include <pcreposix.h>
-#  else
-#    include <sys/types.h>
-#    include <regex.h>
-#  endif
-#endif                          /* USE_GREGEX */
-
     extern void make_gradient(GdkColor colors[], gint, gint);
-#if USE_GREGEX
     extern guint is_a_quote(const gchar *, GRegex * rex);
-#else                           /* USE_GREGEX */
-    extern guint is_a_quote(const gchar *, regex_t * rex);
-#endif                          /* USE_GREGEX */
 
 G_END_DECLS
 
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index 2702879..ca54c83 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -5863,27 +5863,13 @@ sw_reflow_activated(GSimpleAction * action, GVariant * parameter, gpointer data)
     BalsaSendmsg *bsmsg = data;
     GtkTextView *text_view;
     GtkTextBuffer *buffer;
-#if USE_GREGEX
     GRegex *rex;
-#else                           /* USE_GREGEX */
-    regex_t rex;
-#endif                          /* USE_GREGEX */
 
     if (!bsmsg->flow)
        return;
 
-#if USE_GREGEX
     if (!(rex = balsa_quote_regex_new()))
         return;
-#else                           /* USE_GREGEX */
-    if (regcomp(&rex, balsa_app.quote_regex, REG_EXTENDED)) {
-       balsa_information_parented(GTK_WINDOW(bsmsg->window),
-                                   LIBBALSA_INFORMATION_WARNING,
-                                   _("Could not compile %s"),
-                                   _("Quoted Text Regular Expression"));
-       return;
-    }
-#endif                          /* USE_GREGEX */
 
 #if !HAVE_GTKSOURCEVIEW
     sw_buffer_save(bsmsg);
@@ -5892,11 +5878,7 @@ sw_reflow_activated(GSimpleAction * action, GVariant * parameter, gpointer data)
     text_view = GTK_TEXT_VIEW(bsmsg->text);
     buffer = gtk_text_view_get_buffer(text_view);
     sw_buffer_signals_block(bsmsg, buffer);
-#if USE_GREGEX
     libbalsa_unwrap_selection(buffer, rex);
-#else                           /* USE_GREGEX */
-    libbalsa_unwrap_selection(buffer, &rex);
-#endif                          /* USE_GREGEX */
     sw_buffer_signals_unblock(bsmsg, buffer);
 
     bsmsg->state = SENDMSG_STATE_MODIFIED;
@@ -5904,11 +5886,7 @@ sw_reflow_activated(GSimpleAction * action, GVariant * parameter, gpointer data)
                                 gtk_text_buffer_get_insert(buffer),
                                 0, FALSE, 0, 0);
 
-#if USE_GREGEX
     g_regex_unref(rex);
-#else                           /* USE_GREGEX */
-    regfree(&rex);
-#endif                          /* USE_GREGEX */
 }
 
 /* To field "changed" signal callback. */
diff --git a/src/spell-check.c b/src/spell-check.c
index ec87061..b7db831 100644
--- a/src/spell-check.c
+++ b/src/spell-check.c
@@ -27,15 +27,6 @@
 #include <enchant.h>
 #include <glib/gi18n.h>
 
-#if !USE_GREGEX
-#  ifdef HAVE_PCRE
-#    include <pcreposix.h>
-#  else
-#    include <sys/types.h>
-#    include <regex.h>
-#  endif
-#endif                          /* USE_GREGEX */
-
 #include "balsa-app.h"
 #include "quote-color.h"
 #include "balsa-icons.h"
@@ -552,11 +543,7 @@ done_cb(GtkButton * button, gpointer data)
  * dictionary to do the checking.
  * */
 
-#if USE_GREGEX
 static GRegex *quoted_rex;
-#else                           /* USE_GREGEX */
-static regex_t quoted_rex;
-#endif                          /* USE_GREGEX */
 static gboolean quoted_rex_compiled = FALSE;
 
 void
@@ -632,7 +619,6 @@ balsa_spell_check_start(BalsaSpellCheck * spell_check)
      * balsa_app.quote_regex may change, so compile it new every
      * time!)
      */
-#if USE_GREGEX
     if (quoted_rex_compiled)
         g_regex_unref(quoted_rex);
     quoted_rex = balsa_quote_regex_new();
@@ -640,17 +626,6 @@ balsa_spell_check_start(BalsaSpellCheck * spell_check)
         quoted_rex_compiled = FALSE;
     else
         quoted_rex_compiled = TRUE;
-#else                           /* USE_GREGEX */
-    if (quoted_rex_compiled)
-        regfree(&quoted_rex);
-    if (regcomp(&quoted_rex, balsa_app.quote_regex, REG_EXTENDED)) {
-        balsa_information(LIBBALSA_INFORMATION_ERROR,
-                          _("BalsaSpellCheck: Quoted text "
-                            "regular expression compilation failed\n"));
-        quoted_rex_compiled = FALSE;
-    } else
-        quoted_rex_compiled = TRUE;
-#endif                          /* USE_GREGEX */
 
     spell_check->end_iter = start;
 
@@ -868,11 +843,7 @@ balsa_spell_check_destroy(GObject * object)
     }
 
     if (quoted_rex_compiled) {
-#if USE_GREGEX
         g_regex_unref(quoted_rex);
-#else                           /* USE_GREGEX */
-        regfree(&quoted_rex);
-#endif                          /* USE_GREGEX */
         quoted_rex_compiled = FALSE;
     }
 
@@ -1108,13 +1079,8 @@ next_word(BalsaSpellCheck * spell_check)
                                         &line_end, FALSE);
             skip_sig = (!balsa_app.check_sig
                         && strcmp(line, "-- \n") == 0);
-#if USE_GREGEX
             skip_quoted = (!balsa_app.check_quoted && quoted_rex_compiled
                            && is_a_quote(line, quoted_rex));
-#else                           /* USE_GREGEX */
-            skip_quoted = (!balsa_app.check_quoted && quoted_rex_compiled
-                           && is_a_quote(line, &quoted_rex));
-#endif                          /* USE_GREGEX */
             g_free(line);
 
             if (skip_sig)


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