Sync with HEAD 0.9.12cvs46
authorColin Leroy <colin@colino.net>
Fri, 6 Aug 2004 11:34:34 +0000 (11:34 +0000)
committerColin Leroy <colin@colino.net>
Fri, 6 Aug 2004 11:34:34 +0000 (11:34 +0000)
(got a bit of time :))

39 files changed:
ChangeLog
ChangeLog-gtk2.claws
ChangeLog.claws
ChangeLog.jp
PATCHSETS
configure.ac
m4/openssl.m4 [deleted file]
src/common/defs.h
src/common/nntp.c
src/common/session.c
src/common/session.h
src/common/socket.c
src/common/utils.h
src/common/xml.c
src/common/xml.h
src/folder.c
src/gtk/prefswindow.c
src/gtk/prefswindow.h
src/imap.c
src/localfolder.c
src/messageview.c
src/mimeview.c
src/mimeview.h
src/msgcache.c
src/news.c
src/plugins/clamav/clamav_plugin_gtk.c
src/plugins/dillo_viewer/dillo_prefs.c
src/plugins/image_viewer/viewerprefs.c
src/plugins/spamassassin/spamassassin_gtk.c
src/prefs_ext_prog.c
src/prefs_folder_item.c
src/prefs_fonts.c
src/prefs_msg_colors.c
src/prefs_spelling.c
src/prefs_themes.c
src/prefs_toolbar.c
src/prefs_wrapping.c
src/procmime.h
sylpheed-claws.pc.in

index b2b450b..d50f7ae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2004-08-04
+
+       * src/socket.c:
+         ssl_read()
+         ssl_peek(): check SSL before reading data (fixes freeze when
+         socket is broken).
+       * src/session.[ch]: session_set_access_time(): new.
+       * src/imap.c
+         src/news.c
+         src/nntp.c: only update last_access_time when successfully
+         receiving a server response.
+       * thanks to Cedric Pradalier for above.
+
+2004-07-23
+
+       * src/xml.[ch]: code cleanup and added some functions.
+
 2004-07-16
 
        * src/pop.[ch]: pop3_getrange_uidl_recv(): relaxed invalid UIDL
index d8d419d..363bc18 100644 (file)
@@ -1,3 +1,44 @@
+2004-08-06 [colin]     0.9.12cvs46.1
+
+       * ChangeLog
+       * ChangeLog.claws
+       * ChangeLog.jp
+       * configure.ac
+       * sylpheed-claws.pc.in
+       * src/folder.c
+       * src/imap.c
+       * src/localfolder.c
+       * src/messageview.c
+       * src/mimeview.c
+       * src/mimeview.h
+       * src/msgcache.c
+       * src/news.c
+       * src/prefs_ext_prog.c
+       * src/prefs_folder_item.c
+       * src/prefs_fonts.c
+       * src/prefs_msg_colors.c
+       * src/prefs_spelling.c
+       * src/prefs_themes.c
+       * src/prefs_toolbar.c
+       * src/prefs_wrapping.c
+       * src/procmime.h
+       * src/common/defs.h
+       * src/common/nntp.c
+       * src/common/session.c
+       * src/common/session.h
+       * src/common/socket.c
+       * src/common/utils.h
+       * src/common/xml.c
+       * src/common/xml.h
+       * src/gtk/prefswindow.c
+       * src/gtk/prefswindow.h
+       * src/plugins/clamav/clamav_plugin_gtk.c
+       * src/plugins/dillo_viewer/dillo_prefs.c
+       * src/plugins/image_viewer/viewerprefs.c
+       * src/plugins/spamassassin/spamassassin_gtk.c
+       * m4/openssl.m4 *** REMOVED ***
+               Sync with HEAD 0.9.12cvs46
+
 2004-08-03 [paul]      0.9.12cvs40.2
 
        * src/action.c
index 51705aa..bc87081 100644 (file)
@@ -1,3 +1,82 @@
+2004-08-05 [christoph] 0.9.12cvs46
+
+       * src/msgcache.c
+       * src/common/defs.h
+               add charset to cache file and convert charset when reading the
+               cache if different from internal used charset
+
+2004-08-05 [christoph] 0.9.12cvs45
+
+       * src/messageview.c
+       * src/mimeview.[ch]
+       * src/procmime.h
+       * src/common/utils.h
+               cleanup (remove unused includes/reorganize)
+
+       * src/prefs_ext_prog.c
+       * src/prefs_folder_item.c
+       * src/prefs_fonts.c
+       * src/prefs_msg_colors.c
+       * src/prefs_spelling.c
+       * src/prefs_themes.c
+       * src/prefs_toolbar.c
+       * src/prefs_wrapping.c
+       * src/gtk/prefswindow.[ch]
+       * src/plugins/clamav/clamav_plugin_gtk.c
+       * src/plugins/dillo_viewer/dillo_prefs.c
+       * src/plugins/image_viewer/viewerprefs.c
+       * src/plugins/spamassassin/spamassassin_gtk.c
+               change PrefsPage path into an array of strings and don't
+               split a single string into parts (better for translation)
+
+2004-08-05 [christoph] 0.9.12cvs44
+
+       * src/folder.c
+               fix FolderItem's message counts after rebuilding a cache
+
+2004-08-05 [paul]      0.9.12cvs43
+
+       * ChangeLog
+       * ChangeLog.jp
+       * src/imap.c
+       * src/news.c
+       * src/common/nntp.c
+       * src/common/session.c
+       * src/common/session.h
+       * src/common/socket.c
+               sync with main 0.9.12cvs2
+               see ChangeLog 2004-08-04
+
+2004-08-04 [christoph] 0.9.12cvs42
+
+       * configure.ac
+               add missing AC_DEFINE(USE_OPENSSL, ...)
+       * src/folder.c
+               use new xml_node_new() function
+
+2004-08-03 [christoph] 0.9.12cvs41
+
+       * src/folder.c
+       * src/localfolder.c
+       * src/common/xml.[ch]
+               sync with main 0.9.12cvs1
+               see ChangeLog 2004-07-23
+
+2004-08-03 [christoph]
+
+       * configure.ac
+       * m4/openssl.m4                 ** REMOVE **
+               use pkg-config to get OpenSSL CFLAGS and LIBS
+               (OpenSSL 0.9.7 is required now)
+
+2004-08-02 [paul]      0.9.12cvs40
+
+       * AUTHORS
+               update translation team section
+       * po/pt_BR.po
+               updated by Frederico Goncalves Guimaraes
+               <fggdebian@yahoo.com.br>
+
 2004-07-29 [colin]     0.9.12cvs39
 
        * src/messageview.c
index ebd361e..6f624bb 100644 (file)
@@ -1,3 +1,20 @@
+2004-08-04
+
+       * src/socket.c:
+         ssl_read()
+         ssl_peek(): ¥Ç¡¼¥¿¤ÎÆɤ߹þ¤ß¤ÎÁ°¤Ë SSL ¤ò¥Á¥§¥Ã¥¯¤¹¤ë¤è¤¦¤Ë¤·¤¿
+         (¥½¥±¥Ã¥È¤¬Ç˲õ¤µ¤ì¤¿¤È¤­¤Î¥Õ¥ê¡¼¥º¤ò½¤Àµ)¡£
+       * src/session.[ch]: session_set_access_time(): ¿·µ¬¡£
+       * src/imap.c
+         src/news.c
+         src/nntp.c: ¥µ¡¼¥Ð¤Î±þÅú¤Î¼õ¿®¤ËÀ®¸ù¤·¤¿¤È¤­¤Î¤ß last_access_time
+         ¤ò¹¹¿·¤¹¤ë¤è¤¦¤Ë¤·¤¿¡£
+       * ¾åµ­¤Ë¤Ä¤¤¤Æ Cedric Pradalier ¤µ¤ó thanks¡£
+
+2004-07-23
+
+       * src/xml.[ch]: ¥³¡¼¥É¤ÎÀ°Íý¤È¤¤¤¯¤Ä¤«¤Î´Ø¿ô¤ÎÄɲá£
+
 2004-07-16
 
        * src/pop.[ch]: pop3_getrange_uidl_recv(): Ìµ¸ú¤Ê UIDL ¤Î¥Á¥§¥Ã¥¯¤ò
index 4789244..746ac7a 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.3.2.4 -r 1.3.2.5 src/exphtmldlg.c; ) > 0.9.12cvs39.9.patchset
 ( cvs diff -u -r 1.100.2.3 -r 1.100.2.4 AUTHORS; cvs diff -u -r 1.50 -r 1.51 po/pt_BR.po; ) > 0.9.12cvs40.1.patchset
 ( cvs diff -u -r 1.12.2.9 -r 1.12.2.10 src/action.c; cvs diff -u -r 1.9.2.1 -r 1.9.2.2 src/addressadd.c; cvs diff -u -r 1.60.2.8 -r 1.60.2.9 src/addressbook.c; cvs diff -u -r 1.5.10.3 -r 1.5.10.4 src/addrgather.c; cvs diff -u -r 1.2.4.3 -r 1.2.4.4 src/browseldap.c; cvs diff -u -r 1.382.2.38 -r 1.382.2.39 src/compose.c; cvs diff -u -r 1.23.2.4 -r 1.23.2.5 src/crash.c; cvs diff -u -r 1.14.2.1 -r 1.14.2.2 src/editaddress.c; cvs diff -u -r 1.11.2.1 -r 1.11.2.2 src/editgroup.c; cvs diff -u -r 1.10.2.1 -r 1.10.2.2 src/editldap_basedn.c; cvs diff -u -r 1.26.2.4 -r 1.26.2.5 src/foldersel.c; cvs diff -u -r 1.14.2.1 -r 1.14.2.2 src/importldif.c; cvs diff -u -r 1.83.2.14 -r 1.83.2.15 src/mimeview.c; cvs diff -u -r 1.204.2.18 -r 1.204.2.19 src/prefs_common.c; cvs diff -u -r 1.12.2.3 -r 1.12.2.4 src/prefs_template.c; cvs diff -u -r 1.9.2.6 -r 1.9.2.7 src/sourcewindow.c; cvs diff -u -r 1.395.2.26 -r 1.395.2.27 src/summaryview.c; cvs diff -u -r 1.4.2.2 -r 1.4.2.3 src/gtk/about.c; cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/gtk/foldersort.c; cvs diff -u -r 1.1.4.4 -r 1.1.4.5 src/gtk/logwindow.c; cvs diff -u -r 1.5.2.4 -r 1.5.2.5 src/gtk/pluginwindow.c; cvs diff -u -r 1.12.2.4 -r 1.12.2.5 src/gtk/prefswindow.c; ) > 0.9.12cvs40.2.patchset
+( cvs diff -u -r 1.396.2.6 -r 1.396.2.7 ChangeLog; cvs diff -u -r 1.2504.2.9 -r 1.2504.2.10 ChangeLog.claws; cvs diff -u -r 1.391.2.6 -r 1.391.2.7 ChangeLog.jp; cvs diff -u -r 1.654.2.131 -r 1.654.2.132 configure.ac; cvs diff -u -r 1.1 -r 1.2 sylpheed-claws.pc.in; cvs diff -u -r 1.213.2.10 -r 1.213.2.11 src/folder.c; cvs diff -u -r 1.179.2.5 -r 1.179.2.6 src/imap.c; cvs diff -u -r 1.3.4.1 -r 1.3.4.2 src/localfolder.c; cvs diff -u -r 1.94.2.28 -r 1.94.2.29 src/messageview.c; cvs diff -u -r 1.83.2.15 -r 1.83.2.16 src/mimeview.c; cvs diff -u -r 1.20.2.1 -r 1.20.2.2 src/mimeview.h; cvs diff -u -r 1.16.2.8 -r 1.16.2.9 src/msgcache.c; cvs diff -u -r 1.101.2.5 -r 1.101.2.6 src/news.c; cvs diff -u -r 1.3.2.1 -r 1.3.2.2 src/prefs_ext_prog.c; cvs diff -u -r 1.52.2.4 -r 1.52.2.5 src/prefs_folder_item.c; cvs diff -u -r 1.4.2.5 -r 1.4.2.6 src/prefs_fonts.c; cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/prefs_msg_colors.c; cvs diff -u -r 1.5.2.2 -r 1.5.2.3 src/prefs_spelling.c; cvs diff -u -r 1.3.2.6 -r 1.3.2.7 src/prefs_themes.c; cvs diff -u -r 1.30.2.3 -r 1.30.2.4 src/prefs_toolbar.c; cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/prefs_wrapping.c; cvs diff -u -r 1.17.2.2 -r 1.17.2.3 src/procmime.h; cvs diff -u -r 1.9.2.5 -r 1.9.2.6 src/common/defs.h; cvs diff -u -r 1.6.2.2 -r 1.6.2.3 src/common/nntp.c; cvs diff -u -r 1.23.2.3 -r 1.23.2.4 src/common/session.c; cvs diff -u -r 1.8.2.1 -r 1.8.2.2 src/common/session.h; cvs diff -u -r 1.13.2.6 -r 1.13.2.7 src/common/socket.c; cvs diff -u -r 1.20.2.5 -r 1.20.2.6 src/common/utils.h; cvs diff -u -r 1.1.4.3 -r 1.1.4.4 src/common/xml.c; cvs diff -u -r 1.1.4.2 -r 1.1.4.3 src/common/xml.h; cvs diff -u -r 1.12.2.5 -r 1.12.2.6 src/gtk/prefswindow.c; cvs diff -u -r 1.7 -r 1.8 src/gtk/prefswindow.h; cvs diff -u -r 1.9.2.2 -r 1.9.2.3 src/plugins/clamav/clamav_plugin_gtk.c; cvs diff -u -r 1.5.2.2 -r 1.5.2.3 src/plugins/dillo_viewer/dillo_prefs.c; cvs diff -u -r 1.5.2.2 -r 1.5.2.3 src/plugins/image_viewer/viewerprefs.c; cvs diff -u -r 1.23.2.2 -r 1.23.2.3 src/plugins/spamassassin/spamassassin_gtk.c; ) > 0.9.12cvs46.1.patchset
index 179cae3..40c48ca 100644 (file)
@@ -11,9 +11,9 @@ MINOR_VERSION=9
 MICRO_VERSION=12
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=40
+EXTRA_VERSION=46
 EXTRA_RELEASE=
-EXTRA_GTK2_VERSION=.2
+EXTRA_GTK2_VERSION=.1
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}${EXTRA_RELEASE}${EXTRA_GTK2_VERSION}
@@ -279,7 +279,15 @@ else
 fi
 
 dnl Check for OpenSSL
-AM_PATH_OPENSSL
+AC_ARG_ENABLE(openssl,
+       [  --enable-openssl    Attempt to use OpenSSL for SSL support.],
+       [ac_cv_enable_openssl=$enableval], [ac_cv_enable_openssl=yes])
+if test x"$ac_cv_enable_openssl" = xyes; then
+       PKG_CHECK_MODULES(OPENSSL, openssl >= 0.9.7, :, ac_cv_enable_openssl=no)
+       AC_DEFINE(USE_OPENSSL, 1, Define if you want OpenSSL support)
+fi
+AC_SUBST(OPENSSL_CFLAGS)
+AC_SUBST(OPENSSL_LIBS)
 
 dnl password encryption
 OLDLIBS=$LIBS
@@ -475,12 +483,12 @@ if test x"$ac_cv_enable_mathml_viewer_plugin" = xyes; then
        PKG_CHECK_MODULES(GTK_MATH_VIEW, gtkmathview >= 0.5, :, ac_cv_enable_mathml_viewer_plugin=no)
 
        if test x"$ac_cv_enable_mathml_viewer_plugin" = xyes; then
-               AC_SUBST(GTK_MATH_VIEW_CFLAGS)
-               AC_SUBST(GTK_MATH_VIEW_LIBS)
 
                PLUGINS="mathml-viewer $PLUGINS"
        fi
 fi
+AC_SUBST(GTK_MATH_VIEW_CFLAGS)
+AC_SUBST(GTK_MATH_VIEW_LIBS)
 AM_CONDITIONAL(BUILD_MATHML_VIEWER_PLUGIN, test x"$ac_cv_enable_mathml_viewer_plugin" = xyes)
 
 dnl --- Image Viewer ---
@@ -537,13 +545,13 @@ if test x"$ac_cv_enable_clamav_plugin" = xyes; then
        AC_CHECK_HEADERS(clamav.h, :, ac_cv_enable_clamav_plugin=no)
        if test x"$ac_cv_enable_clamav_plugin" = xyes; then
                CLAMAV_LIBS="${clamav_lib}"
-               AC_SUBST(CLAMAV_LIBS)
 
                PLUGINS="clamav $PLUGINS"
        else
                AC_MSG_NOTICE([clamav library not found, will not build clamav plugin])
        fi
 fi
+AC_SUBST(CLAMAV_LIBS)
 AM_CONDITIONAL(BUILD_CLAMAV_PLUGIN, test x"$ac_cv_enable_clamav_plugin" = xyes)
 
 dnl ****************************
diff --git a/m4/openssl.m4 b/m4/openssl.m4
deleted file mode 100644 (file)
index fea4649..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-dnl ******************************
-dnl OpenSSL
-dnl ******************************
-
-AC_DEFUN([AM_PATH_OPENSSL],
-[dnl
-       USE_OPENSSL=0
-
-       AC_ARG_ENABLE(openssl, [  --enable-openssl        Attempt to use OpenSSL for SSL support.],
-               [ac_cv_enable_openssl=$enableval], [ac_cv_enable_openssl=no])
-
-       dnl detect OpenSSL
-       if test "x${ac_cv_enable_openssl}" != "xno"; then
-               AC_ARG_WITH(openssl-includes, [  --with-openssl-includes=PREFIX     Location of OpenSSL includes.],
-                       with_openssl_includes="$withval", with_openssl_includes="/usr/include")
-               have_openssl_includes="no"
-               if test "x${with_openssl_includes}" != "xno"; then
-                       CPPFLAGS_save="$CPPFLAGS"
-               
-                       AC_MSG_CHECKING(for OpenSSL includes)
-                       AC_MSG_RESULT("")
-               
-                       CPPFLAGS="$CPPFLAGS -I$with_openssl_includes"
-                       AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h, [ openssl_includes="yes" ])
-                       CPPFLAGS="$CPPFLAGS_save"
-               
-                       if test "x{$openssl_includes}" != "xno" -a "x{$openssl_includes}" != "x"; then
-                               have_openssl_includes="yes"
-                               OPENSSL_CFLAGS="-I$with_openssl_includes"
-                       else
-                               OPENSSL_CFLAGS=""
-                       fi
-               else
-                       AC_MSG_CHECKING(for OpenSSL includes)
-                       AC_MSG_RESULT(no)
-               fi
-       
-               AC_ARG_WITH(openssl-libs, [  --with-openssl-libs=PREFIX         Location of OpenSSL libs.],
-                       with_openssl_libs="$withval")
-               if test "x${with_openssl_libs}" != "xno" -a "x${have_openssl_includes}" != "xno"; then
-                       case $with_openssl_libs in
-                       ""|-L*) ;;
-                       *) with_openssl_libs="-L$with_openssl_libs" ;;
-                       esac
-       
-                       AC_CHECK_LIB(dl, dlopen, DL_LIBS="-ldl", DL_LIBS="")
-                       AC_CACHE_CHECK([for OpenSSL libraries], openssl_libs,
-                       [
-                               LIBS_save="$LIBS"
-                               LIBS="$LIBS $with_openssl_libs -lssl -lcrypto $DL_LIBS"
-                               AC_TRY_LINK_FUNC(SSL_read, openssl_libs="yes", openssl_libs="no")
-                               LIBS="$LIBS_save"
-                       ])
-                       if test "x${openssl_libs}" != "xno"; then
-                               AC_DEFINE(USE_OPENSSL, 1, [Define if you use OpenSSL to support SSL])
-                               USE_OPENSSL=1
-                               msg_ssl="yes (OpenSSL)"
-                               OPENSSL_LIBS="$with_openssl_libs -lssl -lcrypto $DL_LIBS"
-                       else
-                               OPENSSL_CFLAGS=""
-                               OPENSSL_LIBS=""
-                       fi
-               else
-                       AC_MSG_CHECKING(for OpenSSL libraries)
-                       AC_MSG_RESULT(no)
-               fi
-       else
-               OPENSSL_CFLAGS=""
-               OPENSSL_LIBS=""
-               ac_cv_enable_openssl="no"
-       fi
-
-       AC_SUBST(OPENSSL_CFLAGS)
-       AC_SUBST(OPENSSL_LIBS)
-])
\ No newline at end of file
index 8acd15a..f8e1f92 100644 (file)
@@ -78,7 +78,7 @@
 #define CACHE_FILE             ".sylpheed_cache"
 #define MARK_FILE              ".sylpheed_mark"
 /* #warning FIXME_GTK2 */
-#define CACHE_VERSION          2021
+#define CACHE_VERSION          22
 #define MARK_VERSION           2
 
 #define DEFAULT_SIGNATURE      ".signature"
index 991feb6..0bb0691 100644 (file)
@@ -125,6 +125,8 @@ Session *nntp_session_new(const gchar *server, gushort port, gchar *buf,
                }
        }
 
+       session_set_access_time(SESSION(session));
+       
        return SESSION(session);
 }
 
@@ -298,6 +300,8 @@ gint nntp_post(NNTPSession *session, FILE *fp)
        if ((ok = nntp_ok(SESSION(session)->sock, buf)) != NN_SUCCESS)
                return ok;
 
+       session_set_access_time(SESSION(session));
+
        return NN_SUCCESS;
 }
 
@@ -439,6 +443,8 @@ static gint nntp_gen_command(NNTPSession *session, gchar *argbuf,
                }
                 ok = nntp_ok(sock, NULL);
        }
-
+       
+       session_set_access_time(SESSION(session));
+       
        return ok;
 }
index 6824c00..6db4d64 100644 (file)
@@ -33,6 +33,7 @@
 #include <sys/signal.h>
 #include <sys/wait.h>
 #include <sys/time.h>
+#include <time.h>
 #include <errno.h>
 
 #include "session.h"
@@ -205,6 +206,11 @@ gboolean session_is_connected(Session *session)
                session->state == SESSION_RECV);
 }
 
+void session_set_access_time(Session *session)
+{
+       session->last_access_time = time(NULL);
+}
+
 void session_set_timeout(Session *session, guint interval)
 {
        if (session->timeout_tag > 0)
index 2aca7c8..0ebe0f6 100644 (file)
@@ -159,6 +159,8 @@ gint session_disconnect             (Session        *session);
 void session_destroy           (Session        *session);
 gboolean session_is_connected  (Session        *session);
 
+void session_set_access_time   (Session        *session);
+
 void session_set_timeout       (Session        *session,
                                 guint           interval);
 
index 4f85e93..0512cf6 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2003 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2004 Hiroyuki Yamamoto
  *
  * 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
@@ -1037,6 +1037,11 @@ gint ssl_read(SSL *ssl, gchar *buf, gint len)
 {
        gint ret;
 
+       if (SSL_pending(ssl) == 0) {
+               if (fd_check_io(SSL_get_rfd(ssl), G_IO_IN) < 0)
+                       return -1;
+       }
+
        ret = SSL_read(ssl, buf, len);
 
        switch (SSL_get_error(ssl, ret)) {
@@ -1327,6 +1332,11 @@ gint ssl_peek(SSL *ssl, gchar *buf, gint len)
 {
        gint ret;
 
+       if (SSL_pending(ssl) == 0) {
+               if (fd_check_io(SSL_get_rfd(ssl), G_IO_IN) < 0)
+                       return -1;
+       }
+
        ret = SSL_peek(ssl, buf, len);
 
        switch (SSL_get_error(ssl, ret)) {
index 085e2c9..8df78bd 100644 (file)
        perror(func); \
 }
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef gpointer (*GNodeMapFunc)       (gpointer nodedata, gpointer data);
 
 /* debug functions */
@@ -448,4 +452,8 @@ gint quote_cmd_argument(gchar * result, guint size,
                        const gchar * path);
 GNode *g_node_map(GNode *node, GNodeMapFunc func, gpointer data);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __UTILS_H__ */
index d86f045..4f4dfdd 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "xml.h"
 #include "utils.h"
+/* UGLY! */
 #include "../codeconv.h"
 
 #define SPARSE_MEMORY
@@ -120,8 +121,7 @@ static GNode *xml_build_tree(XMLFile *file, GNode *parent, guint level)
 
                tag = xml_get_current_tag(file);
                if (!tag) break;
-               xmlnode = g_new(XMLNode, 1);
-               xmlnode->tag = xml_copy_tag(tag);
+               xmlnode = xml_node_new(xml_copy_tag(tag), NULL);
                xmlnode->element = xml_get_element(file);
                if (!parent)
                        node = g_node_new(xmlnode);
@@ -205,7 +205,7 @@ gint xml_parse_next_tag(XMLFile *file)
                return 0;
        }
 
-       tag = g_new0(XMLTag, 1);
+       tag = xml_tag_new(NULL);
        xml_push_tag(file, tag);
 
        len = strlen(buf);
@@ -263,7 +263,6 @@ gint xml_parse_next_tag(XMLFile *file)
                g_strchomp(attr_name);
                xml_unescape_str(attr_value);
 
-               attr = g_new(XMLAttr, 1);
 #warning FIXME_GTK2
                utf8attr_name  = conv_codeset_strdup
                                        (attr_name,
@@ -283,10 +282,9 @@ gint xml_parse_next_tag(XMLFile *file)
                                  "faild to convert character set of attr_value\n");
                        utf8attr_value = g_strdup(attr_value);
                }
-
-               attr->name  = XML_STRING_ADD(utf8attr_name);
-               attr->value = utf8attr_value;
-               tag->attr   = g_list_append(tag->attr, attr);
+               
+               attr = xml_attr_new(utf8attr_name, utf8attr_value);
+               xml_tag_add_attr(tag, attr);
 
                g_free(utf8attr_name);
        }
@@ -412,29 +410,73 @@ gboolean xml_compare_tag(XMLFile *file, const gchar *name)
                return FALSE;
 }
 
-XMLTag *xml_new_tag(const gchar        *tag)
+XMLNode *xml_node_new(XMLTag *tag, const gchar *text)
 {
-       XMLTag *new_tag;
+       XMLNode *node;
+
+       node = g_new(XMLNode, 1);
+       node->tag = tag;
+       node->element = g_strdup(text);
+
+        return node;
+}
 
+XMLTag *xml_tag_new(const gchar *tag)
+{
+       XMLTag *new_tag;
        new_tag = g_new(XMLTag, 1);
-       new_tag->tag = XML_STRING_ADD(tag);
+       if (tag)
+               new_tag->tag = XML_STRING_ADD(tag);
+       else
+               new_tag->tag = NULL;
        new_tag->attr = NULL;
-
        return new_tag;
 }
 
+XMLAttr *xml_attr_new(const gchar *name, const gchar *value)
+{
+       XMLAttr *new_attr;
+       new_attr = g_new(XMLAttr, 1);
+       new_attr->name = XML_STRING_ADD(name);
+       new_attr->value = g_strdup(value);
+       return new_attr;
+}
+
+XMLAttr *xml_attr_new_int(const gchar *name, const gint value)
+{
+       XMLAttr *new_attr;
+       gchar *valuestr;
+
+       valuestr = g_strdup_printf("%d", value);
+
+       new_attr = g_new(XMLAttr, 1);
+       new_attr->name = XML_STRING_ADD(name);
+       new_attr->value = g_strdup(valuestr);
+       g_free(valuestr);
+
+       return new_attr;
+}
+
+void xml_tag_add_attr(XMLTag *tag, XMLAttr *attr)
+{
+       tag->attr = g_list_append(tag->attr, attr);
+}
+
 XMLTag *xml_copy_tag(XMLTag *tag)
 {
        XMLTag *new_tag;
        XMLAttr *attr;
        GList *list;
 
-       new_tag = g_new(XMLTag, 1);
-       new_tag->tag = XML_STRING_ADD(tag->tag);
-       new_tag->attr = NULL;
+       new_tag = xml_tag_new(tag->tag);
        for (list = tag->attr; list != NULL; list = list->next) {
                attr = xml_copy_attr((XMLAttr *)list->data);
-               new_tag->attr = g_list_append(new_tag->attr, attr);
+               xml_tag_add_attr(new_tag, attr);
        }
 
        return new_tag;
@@ -442,13 +484,7 @@ XMLTag *xml_copy_tag(XMLTag *tag)
 
 XMLAttr *xml_copy_attr(XMLAttr *attr)
 {
-       XMLAttr *new_attr;
-
-       new_attr = g_new(XMLAttr, 1);
-       new_attr->name  = XML_STRING_ADD(attr->name);
-       new_attr->value = g_strdup(attr->value);
-
-       return new_attr;
+       return xml_attr_new(attr->name, attr->value);
 }
 
 gint xml_unescape_str(gchar *str)
@@ -541,6 +577,42 @@ gint xml_file_put_escape_str(FILE *fp, const gchar *str)
        return 0;
 }
 
+gint xml_file_put_xml_decl(FILE *fp)
+{
+       g_return_val_if_fail(fp != NULL, -1);
+
+       fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\"?>\n",
+       conv_get_current_charset_str());
+       return 0;
+}
+
+gint xml_file_put_node(FILE *fp, XMLNode *node)
+{
+       GList *cur;
+
+       g_return_val_if_fail(fp != NULL, -1);
+       g_return_val_if_fail(node != NULL, -1);
+
+       fprintf(fp, "<%s", node->tag->tag);
+
+       for (cur = node->tag->attr; cur != NULL; cur = cur->next) {
+               XMLAttr *attr = (XMLAttr *)cur->data;
+               fprintf(fp, " %s=\"", attr->name);
+               xml_file_put_escape_str(fp, attr->value);
+               fputs("\"", fp);
+       }
+
+       if (node->element) {
+               fputs(">", fp);
+               xml_file_put_escape_str(fp, node->element);
+               fprintf(fp, "</%s>\n", node->tag->tag);
+       } else {
+               fputs(" />\n", fp);
+       }
+
+       return 0;
+}
+
 void xml_free_node(XMLNode *node)
 {
        if (!node) return;
@@ -607,17 +679,6 @@ static gint xml_get_parenthesis(XMLFile *file, gchar *buf, gint len)
        return 0;
 }
 
-void xml_tag_add_attr(XMLTag *tag, const gchar *name, gchar *value)
-{
-       XMLAttr *attr;
-
-       attr = g_new0(XMLAttr, 1);
-       attr->name = XML_STRING_ADD(name);
-       attr->value = value;
-
-       tag->attr = g_list_append(tag->attr, attr);
-}
-
 static void xml_write_tree_recursive(GNode *node, FILE *fp)
 {
        gint i, depth;
index b9036ce..e6b1cbc 100644 (file)
@@ -81,7 +81,17 @@ void xml_truncate_buf                (XMLFile        *file);
 gboolean  xml_compare_tag      (XMLFile        *file,
                                 const gchar    *name);
 
-XMLTag *xml_new_tag            (const gchar    *tag);
+XMLNode *xml_node_new          (XMLTag         *tag,
+                                const gchar    *text);
+
+XMLTag *xml_tag_new            (const gchar    *tag);
+XMLAttr *xml_attr_new          (const gchar    *name,
+                                const gchar    *value);
+XMLAttr *xml_attr_new_int      (const gchar    *name,
+                                const gint      value);
+void xml_tag_add_attr          (XMLTag         *tag,
+                                XMLAttr*       attr);
+
 XMLTag  *xml_copy_tag          (XMLTag         *tag);
 XMLAttr *xml_copy_attr         (XMLAttr        *attr);
 
@@ -89,13 +99,14 @@ gint xml_unescape_str               (gchar          *str);
 gint xml_file_put_escape_str   (FILE           *fp,
                                 const gchar    *str);
 
+gint xml_file_put_xml_decl     (FILE           *fp);
+gint xml_file_put_node         (FILE           *fp,
+                                XMLNode        *node);
+
 void xml_free_node             (XMLNode        *node);
 void xml_free_tree             (GNode          *node);
 
 void xml_free_tag              (XMLTag         *tag);
-void xml_tag_add_attr          (XMLTag         *tag,
-                                const gchar    *name, 
-                                gchar          *value);
 void xml_write_tree            (GNode          *node,
                                 FILE           *fp);
 GNode *xml_copy_tree           (GNode          *node);
index af8abe5..a9bcd92 100644 (file)
@@ -236,18 +236,18 @@ XMLTag *folder_get_xml(Folder *folder)
 {
        XMLTag *tag;
 
-       tag = xml_new_tag("folder");
+       tag = xml_tag_new("folder");
 
        if (folder->name)
-               xml_tag_add_attr(tag, "name", g_strdup(folder->name));
+               xml_tag_add_attr(tag, xml_attr_new("name", folder->name));
        if (folder->account)
-               xml_tag_add_attr(tag, "account_id", g_strdup_printf("%d", folder->account->account_id));
+               xml_tag_add_attr(tag, xml_attr_new_int("account_id", folder->account->account_id));
        if (folder->node && folder->node->data) {
                FolderItem *rootitem = (FolderItem *) folder->node->data;
 
-               xml_tag_add_attr(tag, "collapsed", g_strdup(rootitem->collapsed ? "1" : "0"));
+               xml_tag_add_attr(tag, xml_attr_new("collapsed", rootitem->collapsed ? "1" : "0"));
        }
-       xml_tag_add_attr(tag, "sort", g_strdup_printf("%d", folder->sort));
+       xml_tag_add_attr(tag, xml_attr_new_int("sort", folder->sort));
 
        return tag;
 }
@@ -511,40 +511,43 @@ XMLTag *folder_item_get_xml(Folder *folder, FolderItem *item)
                                        "mark", "unread", "mime", "to", 
                                        "locked"};
        XMLTag *tag;
+       gchar *value;
 
-       tag = xml_new_tag("folderitem");
+       tag = xml_tag_new("folderitem");
 
-       xml_tag_add_attr(tag, "type", g_strdup(folder_item_stype_str[item->stype]));
+       xml_tag_add_attr(tag, xml_attr_new("type", folder_item_stype_str[item->stype]));
        if (item->name)
-               xml_tag_add_attr(tag, "name", g_strdup(item->name));
+               xml_tag_add_attr(tag, xml_attr_new("name", item->name));
        if (item->path)
-               xml_tag_add_attr(tag, "path", g_strdup(item->path));
+               xml_tag_add_attr(tag, xml_attr_new("path", item->path));
        if (item->no_sub)
-               xml_tag_add_attr(tag, "no_sub", g_strdup("1"));
+               xml_tag_add_attr(tag, xml_attr_new("no_sub", "1"));
        if (item->no_select)
-               xml_tag_add_attr(tag, "no_select", g_strdup("1"));
-       xml_tag_add_attr(tag, "collapsed", g_strdup(item->collapsed && item->node->children ? "1" : "0"));
-       xml_tag_add_attr(tag, "thread_collapsed", g_strdup(item->thread_collapsed ? "1" : "0"));
-       xml_tag_add_attr(tag, "threaded", g_strdup(item->threaded ? "1" : "0"));
-       xml_tag_add_attr(tag, "hidereadmsgs", g_strdup(item->hide_read_msgs ? "1" : "0"));
+               xml_tag_add_attr(tag, xml_attr_new("no_select", "1"));
+       xml_tag_add_attr(tag, xml_attr_new("collapsed", item->collapsed && item->node->children ? "1" : "0"));
+       xml_tag_add_attr(tag, xml_attr_new("thread_collapsed", item->thread_collapsed ? "1" : "0"));
+       xml_tag_add_attr(tag, xml_attr_new("threaded", item->threaded ? "1" : "0"));
+       xml_tag_add_attr(tag, xml_attr_new("hidereadmsgs", item->hide_read_msgs ? "1" : "0"));
        if (item->ret_rcpt)
-               xml_tag_add_attr(tag, "reqretrcpt", g_strdup("1"));
+               xml_tag_add_attr(tag, xml_attr_new("reqretrcpt", "1"));
 
        if (item->sort_key != SORT_BY_NONE) {
-               xml_tag_add_attr(tag, "sort_key", g_strdup(sort_key_str[item->sort_key]));
-               xml_tag_add_attr(tag, "sort_type", g_strdup(item->sort_type == SORT_ASCENDING ? "ascending" : "descending"));
+               xml_tag_add_attr(tag, xml_attr_new("sort_key", sort_key_str[item->sort_key]));
+               xml_tag_add_attr(tag, xml_attr_new("sort_type", item->sort_type == SORT_ASCENDING ? "ascending" : "descending"));
        }
 
-       xml_tag_add_attr(tag, "mtime", g_strdup_printf("%ld", (unsigned long int) item->mtime));
-       xml_tag_add_attr(tag, "new", g_strdup_printf("%d", item->new_msgs));
-       xml_tag_add_attr(tag, "unread", g_strdup_printf("%d", item->unread_msgs));
-       xml_tag_add_attr(tag, "unreadmarked", g_strdup_printf("%d", item->unreadmarked_msgs));
-       xml_tag_add_attr(tag, "total", g_strdup_printf("%d", item->total_msgs));
+       value = g_strdup_printf("%ld", (unsigned long int) item->mtime);
+       xml_tag_add_attr(tag, xml_attr_new("mtime", value));
+       g_free(value);
+       xml_tag_add_attr(tag, xml_attr_new_int("new", item->new_msgs));
+       xml_tag_add_attr(tag, xml_attr_new_int("unread", item->unread_msgs));
+       xml_tag_add_attr(tag, xml_attr_new_int("unreadmarked", item->unreadmarked_msgs));
+       xml_tag_add_attr(tag, xml_attr_new_int("total", item->total_msgs));
 
        if (item->account)
-               xml_tag_add_attr(tag, "account_id", g_strdup_printf("%d", item->account->account_id));
+               xml_tag_add_attr(tag, xml_attr_new_int("account_id", item->account->account_id));
        if (item->apply_sub)
-               xml_tag_add_attr(tag, "apply_sub", g_strdup("1"));
+               xml_tag_add_attr(tag, xml_attr_new("apply_sub", "1"));
 
        return tag;
 }
@@ -701,13 +704,10 @@ void folder_write_list(void)
        path = folder_get_list_path();
        if ((pfile = prefs_write_open(path)) == NULL) return;
 
-       fprintf(pfile->fp, "<?xml version=\"1.0\" encoding=\"%s\"?>\n",
-               conv_get_current_charset_str());
-       tag = xml_new_tag("folderlist");
+       xml_file_put_xml_decl(pfile->fp);
+       tag = xml_tag_new("folderlist");
 
-       xmlnode = g_new0(XMLNode, 1);
-       xmlnode->tag = tag;
-       xmlnode->element = NULL;
+       xmlnode = xml_node_new(tag, NULL);
 
        rootnode = g_node_new(xmlnode);
 
@@ -1998,10 +1998,33 @@ void folder_item_read_cache(FolderItem *item)
                mark_file = folder_item_get_mark_file(item);
                item->cache = msgcache_read_cache(item, cache_file);
                if (!item->cache) {
+                       MsgInfoList *list, *cur;
+                       guint newcnt = 0, unreadcnt = 0, unreadmarkedcnt = 0;
+                       MsgInfo *msginfo;
+
                        item->cache = msgcache_new();
                        folder_item_scan_full(item, TRUE);
-               }
-               msgcache_read_mark(item->cache, mark_file);
+
+                       msgcache_read_mark(item->cache, mark_file);
+
+                       list = msgcache_get_msg_list(item->cache);
+                       for (cur = list; cur != NULL; cur = g_slist_next(cur)) {
+                               msginfo = cur->data;
+
+                               if (MSG_IS_NEW(msginfo->flags))
+                                       newcnt++;
+                               if (MSG_IS_UNREAD(msginfo->flags))
+                                       unreadcnt++;
+                               if (MSG_IS_UNREAD(msginfo->flags) && procmsg_msg_has_marked_parent(msginfo))
+                                       unreadmarkedcnt++;
+                       }
+                       item->new_msgs = newcnt;
+                       item->unread_msgs = unreadcnt;
+                       item->unreadmarked_msgs = unreadmarkedcnt;
+                       procmsg_msg_list_free(list);
+               } else
+                       msgcache_read_mark(item->cache, mark_file);
+
                g_free(cache_file);
                g_free(mark_file);
        } else {
@@ -2975,7 +2998,6 @@ static gchar *folder_get_list_path(void)
 static gpointer folder_item_to_xml(gpointer nodedata, gpointer data)
 {
        FolderItem *item = (FolderItem *) nodedata;
-       XMLNode *xmlnode;
        XMLTag *tag;
 
        g_return_val_if_fail(item != NULL, NULL);
@@ -2985,11 +3007,7 @@ static gpointer folder_item_to_xml(gpointer nodedata, gpointer data)
        else
                tag = folder_item_get_xml(item->folder, item);
 
-       xmlnode = g_new0(XMLNode, 1);
-       xmlnode->tag = tag;
-       xmlnode->element = NULL;
-
-       return xmlnode;
+       return xml_node_new(tag, NULL);;
 }
 
 static GNode *folder_get_xml_node(Folder *folder)
@@ -3005,11 +3023,9 @@ static GNode *folder_get_xml_node(Folder *folder)
        else
                tag = folder_get_xml(folder);
 
-       xml_tag_add_attr(tag, "type", g_strdup(folder->klass->idstr));
+       xml_tag_add_attr(tag, xml_attr_new("type", folder->klass->idstr));
 
-       xmlnode = g_new0(XMLNode, 1);
-       xmlnode->tag = tag;
-       xmlnode->element = NULL;
+       xmlnode = xml_node_new(tag, NULL);
 
        node = g_node_new(xmlnode);
        if (folder->node->children) {
index 33500e6..d37db26 100644 (file)
@@ -66,7 +66,7 @@ static gboolean ctree_select_row(GtkCTree *ctree, GList *node, gint column, gpoi
        PrefsPage *page;
        PrefsWindow *prefswindow = (PrefsWindow *) user_data;
        gchar *labeltext;
-       gint pagenum;
+       gint pagenum, i;
 
        prefsnode = gtk_ctree_node_get_row_data(GTK_CTREE(ctree), GTK_CTREE_NODE(node));
        page = prefsnode->page;
@@ -87,11 +87,11 @@ static gboolean ctree_select_row(GtkCTree *ctree, GList *node, gint column, gpoi
                page->page_open = TRUE;
        }
 
-       labeltext = (gchar *) strrchr(page->path, '/');
-       if (labeltext == NULL)
-               labeltext = page->path;
-       else
-               labeltext = labeltext + 1;
+       i = 0;
+       while (page->path[i + 1] != 0)
+               i++;
+       labeltext = page->path[i];
+       
        gtk_label_set_text(GTK_LABEL(prefswindow->pagelabel), labeltext);
 
        pagenum = gtk_notebook_page_num(GTK_NOTEBOOK(prefswindow->notebook),
@@ -265,14 +265,13 @@ void prefswindow_open(const gchar *title, GSList *prefs_pages, gpointer data)
        for (cur = prefs_pages; cur != NULL; cur = g_slist_next(cur)) {
                PrefsPage *page = (PrefsPage *)cur->data;
                GtkCTreeNode *node = NULL;
-               gchar *text[2], **split, *part;
+               gchar *text[2], *part;
                int i;
                struct name_search name_search;
                PrefsTreeNode *prefsnode;
 
-               split = g_strsplit(page->path, "/", 0);
-               for (i = 0; split[i] != NULL; i++) {
-                       part = split[i];                        
+               for (i = 0; page->path[i] != NULL; i++) {
+                       part = page->path[i];
                        name_search.text = part;
                        name_search.node = NULL;
 
@@ -289,7 +288,6 @@ void prefswindow_open(const gchar *title, GSList *prefs_pages, gpointer data)
                                gtk_ctree_node_set_row_data_full(GTK_CTREE(prefswindow->ctree), node, prefsnode, g_free);
                        }
                }
-               g_strfreev(split);
 
                prefsnode = (PrefsTreeNode *) GTK_CTREE_ROW(node)->row.data;
                prefsnode->page = page;
index f3b8133..016f4fb 100644 (file)
@@ -31,14 +31,14 @@ typedef void (*PrefsSavePageFunc) (PrefsPage *);
 
 struct _PrefsPage
 {
-       gchar                   *path;
-       gboolean                 page_open;
-       GtkWidget               *widget;
-       gfloat                   weight;
-
-       PrefsCreateWidgetFunc    create_widget;
-       PrefsDestroyWidgetFunc   destroy_widget;
-       PrefsSavePageFunc        save_page;
+       gchar                   **path;
+       gboolean                  page_open;
+       GtkWidget                *widget;
+       gfloat                    weight;
+
+       PrefsCreateWidgetFunc     create_widget;
+       PrefsDestroyWidgetFunc    destroy_widget;
+       PrefsSavePageFunc         save_page;
 };
 
 void prefswindow_open                  (const gchar *title, 
index f0e1fbe..cdd7e04 100644 (file)
@@ -685,9 +685,7 @@ static IMAPSession *imap_session_get(Folder *folder)
        }
 
        rfolder->session = SESSION(session);
-       if (session) {
-               session->last_access_time = time(NULL);
-       }
+       
        return IMAP_SESSION(session);
 }
 
@@ -1902,6 +1900,8 @@ static GSList *imap_get_uncached_messages(IMAPSession *session,
                g_string_free(str, TRUE);
        }
        imap_seq_set_free(seq_list);
+       
+       session_set_access_time(SESSION(session));
 
        return newlist;
 }
@@ -3261,6 +3261,8 @@ static gint imap_gen_recv(IMAPSession *session, gchar **ret)
        strretchomp(*ret);
 
        log_print("IMAP4< %s\n", *ret);
+       
+       session_set_access_time(SESSION(session));
 
        return IMAP_SUCCESS;
 }
index b348799..7793900 100644 (file)
@@ -63,7 +63,7 @@ XMLTag *folder_local_get_xml(Folder *_folder)
 
        tag = folder_get_xml(_folder);
 
-       xml_tag_add_attr(tag, "path", g_strdup(folder->rootpath));
+       xml_tag_add_attr(tag, xml_attr_new("path", folder->rootpath));
 
        return tag;
 }
index 5b50a60..a27c1a7 100644 (file)
@@ -57,7 +57,6 @@
 #include "prefs_account.h"
 #include "gtkutils.h"
 #include "utils.h"
-#include "rfc2015.h"
 #include "send_message.h"
 #include "stock_pixmap.h"
 #include "hooks.h"
index fc00bf5..237dbb5 100644 (file)
@@ -60,7 +60,6 @@
 #include "utils.h"
 #include "gtkutils.h"
 #include "prefs_common.h"
-#include "rfc2015.h"
 #include "stock_pixmap.h"
 #include "gtk/gtkvscrollbutton.h"
 
index 0c44afb..70633e5 100644 (file)
@@ -20,9 +20,9 @@
 #ifndef MIMEVIEW_H
 #define MIMEVIEW_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+typedef struct _MimeView               MimeView;
+typedef struct _MimeViewerFactory      MimeViewerFactory;
+typedef struct _MimeViewer             MimeViewer;
 
 #include <glib.h>
 #include <gdk/gdk.h>
@@ -30,10 +30,6 @@ extern "C" {
 #include <gtk/gtkctree.h>
 #include <gtk/gtktooltips.h>
 
-typedef struct _MimeView               MimeView;
-typedef struct _MimeViewerFactory      MimeViewerFactory;
-typedef struct _MimeViewer             MimeViewer;
-
 #include "textview.h"
 #include "messageview.h"
 #include "procmime.h"
@@ -109,6 +105,11 @@ struct _MimeViewer
        void            (*destroy_viewer)       (MimeViewer *);
 };
 
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
 MimeView *mimeview_create      (MainWindow     *mainwin);
 void mimeview_init             (MimeView       *mimeview);
 void mimeview_show_message     (MimeView       *mimeview,
index 3c3a0d4..89b0c67 100644 (file)
@@ -27,6 +27,7 @@
 #include "msgcache.h"
 #include "utils.h"
 #include "procmsg.h"
+#include "codeconv.h"
 
 typedef enum
 {
@@ -42,6 +43,25 @@ struct _MsgCache {
        time_t           last_access;
 };
 
+typedef struct _StringConverter StringConverter;
+struct _StringConverter {
+       gchar *(*convert) (StringConverter *converter, gchar *srcstr);
+       void   (*free)    (StringConverter *converter);
+};
+
+typedef struct _StrdupConverter StrdupConverter;
+struct _StrdupConverter {
+       StringConverter converter;
+};
+
+typedef struct _CharsetConverter CharsetConverter;
+struct _CharsetConverter {
+       StringConverter converter;
+
+       gchar *srccharset;
+       gchar *dstcharset;
+};
+
 MsgCache *msgcache_new(void)
 {
        MsgCache *cache;
@@ -116,14 +136,12 @@ void msgcache_update_msg(MsgCache *cache, MsgInfo *msginfo)
        g_return_if_fail(msginfo != NULL);
 
        oldmsginfo = g_hash_table_lookup(cache->msgnum_table, &msginfo->msgnum);
-       if(oldmsginfo && oldmsginfo->msgid) {
+       if(oldmsginfo && oldmsginfo->msgid) 
                g_hash_table_remove(cache->msgid_table, oldmsginfo->msgid);
-       }
-
        if (oldmsginfo) {
                g_hash_table_remove(cache->msgnum_table, &oldmsginfo->msgnum);
-               procmsg_msginfo_free(oldmsginfo);
                cache->memusage -= procmsg_msginfo_memusage(oldmsginfo);
+               procmsg_msginfo_free(oldmsginfo);
        }
 
        newmsginfo = procmsg_msginfo_new_ref(msginfo);
@@ -209,7 +227,7 @@ gint msgcache_get_memory_usage(MsgCache *cache)
 
 #define READ_CACHE_DATA(data, fp) \
 { \
-       if (msgcache_read_cache_data_str(fp, &data) < 0) { \
+       if (msgcache_read_cache_data_str(fp, &data, conv) < 0) { \
                procmsg_msginfo_free(msginfo); \
                error = TRUE; \
                break; \
@@ -304,9 +322,9 @@ static FILE *msgcache_open_data_file(const gchar *file, gint version,
        return fp;
 }
 
-static gint msgcache_read_cache_data_str(FILE *fp, gchar **str)
+static gint msgcache_read_cache_data_str(FILE *fp, gchar **str, StringConverter *conv)
 {
-       gchar buf[BUFFSIZE];
+       gchar buf[BUFFSIZE], *tmpstr = NULL;
        gint ret = 0;
        guint32 len;
 
@@ -322,7 +340,7 @@ static gint msgcache_read_cache_data_str(FILE *fp, gchar **str)
                                if (fread(buf, size, 1, fp) != 1) {
                                        ret = -1;
                                        if (tmp) g_free(tmp);
-                                       *str = NULL;
+                                       tmpstr = NULL;
                                        break;
                                }
 
@@ -330,9 +348,9 @@ static gint msgcache_read_cache_data_str(FILE *fp, gchar **str)
                                if (tmp) {
                                        *str = g_strconcat(tmp, buf, NULL);
                                        g_free(tmp);
-                                       tmp = *str;
+                                       tmp = tmpstr;
                                } else
-                                       tmp = *str = g_strdup(buf);
+                                       tmp = tmpstr = g_strdup(buf);
 
                                len -= size;
                        }
@@ -343,9 +361,38 @@ static gint msgcache_read_cache_data_str(FILE *fp, gchar **str)
        if (ret < 0)
                g_warning("Cache data is corrupted\n");
 
+       if (tmpstr != NULL && conv != NULL) {
+               *str = conv->convert(conv, tmpstr);
+               g_free(tmpstr);
+       } else if (tmpstr != NULL) {
+               *str = g_strdup(tmpstr);
+               g_free(tmpstr);
+       } else
+               *str = NULL;
+
        return ret;
 }
 
+gchar *strconv_strdup_convert(StringConverter *conv, gchar *srcstr)
+{
+       return g_strdup(srcstr);
+}
+
+gchar *strconv_charset_convert(StringConverter *conv, gchar *srcstr)
+{
+       CharsetConverter *charsetconv = (CharsetConverter *) conv;
+
+       return conv_codeset_strdup(srcstr, charsetconv->srccharset, charsetconv->dstcharset);
+}
+
+void strconv_charset_free(StringConverter *conv)
+{
+       CharsetConverter *charsetconv = (CharsetConverter *) conv;
+
+       g_free(charsetconv->srccharset);
+       g_free(charsetconv->dstcharset);
+}
+
 MsgCache *msgcache_read_cache(FolderItem *item, const gchar *cache_file)
 {
        MsgCache *cache;
@@ -355,6 +402,9 @@ MsgCache *msgcache_read_cache(FolderItem *item, const gchar *cache_file)
        gchar file_buf[BUFFSIZE];
        guint num;
        gboolean error = FALSE;
+       StringConverter *conv = NULL;
+       gchar *srccharset = NULL;
+       const gchar *dstcharset = NULL;
 
        g_return_val_if_fail(cache_file != NULL, NULL);
        g_return_val_if_fail(item != NULL, NULL);
@@ -371,8 +421,37 @@ MsgCache *msgcache_read_cache(FolderItem *item, const gchar *cache_file)
                tmp_flags |= MSG_DRAFT;
        }
 
-       cache = msgcache_new();
+       if (msgcache_read_cache_data_str(fp, &srccharset, NULL) < 0)
+               return NULL;
+       dstcharset = CS_UTF_8;
+       if (srccharset == NULL || dstcharset == NULL) {
+               conv = NULL;
+       } else if (strcmp(srccharset, dstcharset) == 0) {
+               StrdupConverter *strdupconv;
+
+               debug_print("using StrdupConverter\n");
 
+               strdupconv = g_new0(StrdupConverter, 1);
+               strdupconv->converter.convert = strconv_strdup_convert;
+               strdupconv->converter.free = NULL;
+
+               conv = (StringConverter *) strdupconv;
+       } else {
+               CharsetConverter *charsetconv;
+
+               debug_print("using CharsetConverter\n");
+
+               charsetconv = g_new0(CharsetConverter, 1);
+               charsetconv->converter.convert = strconv_charset_convert;
+               charsetconv->converter.free = strconv_charset_free;
+               charsetconv->srccharset = g_strdup(srccharset);
+               charsetconv->dstcharset = g_strdup(dstcharset);
+
+               conv = (StringConverter *) charsetconv;
+       }
+       g_free(srccharset);
+
+       cache = msgcache_new();
        g_hash_table_freeze(cache->msgnum_table);
 
        while (fread(&num, sizeof(num), 1, fp) == 1) {
@@ -413,6 +492,12 @@ MsgCache *msgcache_read_cache(FolderItem *item, const gchar *cache_file)
                return NULL;
        }
 
+       if (conv != NULL) {
+               if (conv->free != NULL)
+                       conv->free(conv);
+               g_free(conv);
+       }
+
        cache->last_access = time(NULL);
 
        debug_print("done. (%d items read)\n", g_hash_table_size(cache->msgnum_table));
@@ -508,6 +593,8 @@ gint msgcache_write(const gchar *cache_file, const gchar *mark_file, MsgCache *c
        if (write_fps.cache_fp == NULL)
                return -1;
 
+       WRITE_CACHE_DATA(CS_UTF_8, write_fps.cache_fp);
+
        write_fps.mark_fp = msgcache_open_data_file(mark_file, MARK_VERSION,
                DATA_WRITE, NULL, 0);
        if (write_fps.mark_fp == NULL) {
index b7bf280..23a4d4c 100644 (file)
@@ -267,8 +267,8 @@ static NNTPSession *news_session_get(Folder *folder)
                return NNTP_SESSION(rfolder->session);
        }
 
-       if (time(NULL) - rfolder->session->last_access_time < SESSION_TIMEOUT_INTERVAL) {
-               rfolder->session->last_access_time = time(NULL);
+       if (time(NULL) - rfolder->session->last_access_time <
+               SESSION_TIMEOUT_INTERVAL) {
                return NNTP_SESSION(rfolder->session);
        }
 
@@ -284,7 +284,8 @@ static NNTPSession *news_session_get(Folder *folder)
        }
 
        if (rfolder->session)
-               rfolder->session->last_access_time = time(NULL);
+               session_set_access_time(rfolder->session);
+
        return NNTP_SESSION(rfolder->session);
 }
 
@@ -1049,6 +1050,8 @@ static GSList *news_get_msginfos_for_range(NNTPSession *session, FolderItem *ite
                llast = llast->next;
        }
 
+       session_set_access_time(SESSION(session));
+
        return newlist;
 }
 
index da41a8a..788371d 100644 (file)
@@ -228,6 +228,8 @@ static struct ClamAvPage clamav_page;
 
 gint plugin_init(gchar **error)
 {
+       static gchar *path[3];
+
        if ((sylpheed_get_version() > VERSION_NUMERIC)) {
                *error = g_strdup("Your sylpheed version is newer than the version the plugin was built with");
                return -1;
@@ -238,7 +240,11 @@ gint plugin_init(gchar **error)
                return -1;
        }
 
-       clamav_page.page.path = _("Filtering/Clam AntiVirus");
+       path[0] = _("Filtering");
+       path[1] = _("Clam AntiVirus");
+       path[2] = NULL;
+
+       clamav_page.page.path = path;
        clamav_page.page.create_widget = clamav_create_widget_func;
        clamav_page.page.destroy_widget = clamav_destroy_widget_func;
        clamav_page.page.save_page = clamav_save_func;
index 7f4178e..4a7fec0 100644 (file)
@@ -68,10 +68,16 @@ static void save_dillo_prefs                (PrefsPage *page);
 
 void dillo_prefs_init(void)
 {
+       static gchar *path[3];
+
+       path[0] = _("Message View");
+       path[1] = _("Dillo Browser");
+       path[2] = NULL;
+
         prefs_set_default(param);
         prefs_read_config(param, PREFS_BLOCK_NAME, COMMON_RC);
         
-        prefs_page.page.path = _("Message View/Dillo Browser");
+        prefs_page.page.path = path;
         prefs_page.page.create_widget = create_dillo_prefs_page;
         prefs_page.page.destroy_widget = destroy_dillo_prefs_page;
         prefs_page.page.save_page = save_dillo_prefs;
index fa534c1..5708e89 100644 (file)
@@ -147,10 +147,16 @@ static struct ImageViewerPage imageviewer_page;
 
 void image_viewer_prefs_init(void)
 {
+       static gchar *path[3];
+
+       path[0] = _("Message View");
+       path[1] = _("Image Viewer");
+       path[2] = NULL;
+
        prefs_set_default(param);
        prefs_read_config(param, PREFS_BLOCK_NAME, COMMON_RC);
 
-       imageviewer_page.page.path = _("Message View/Image Viewer");
+       imageviewer_page.page.path = path;
        imageviewer_page.page.create_widget = imageviewer_create_widget_func;
        imageviewer_page.page.destroy_widget = imageviewer_destroy_widget_func;
        imageviewer_page.page.save_page = imageviewer_save_func;
index c563fa1..9979d45 100644 (file)
@@ -441,6 +441,8 @@ static struct SpamAssassinPage spamassassin_page;
 
 gint plugin_init(gchar **error)
 {
+       static gchar *path[3];
+
        if ((sylpheed_get_version() > VERSION_NUMERIC)) {
                *error = g_strdup("Your sylpheed version is newer than the version the plugin was built with");
                return -1;
@@ -450,8 +452,12 @@ gint plugin_init(gchar **error)
                *error = g_strdup("Your sylpheed version is too old");
                return -1;
        }
+    
+       path[0] = _("Filtering");
+       path[1] = _("SpamAssassin");
+       path[2] = NULL;
 
-       spamassassin_page.page.path = _("Filtering/SpamAssassin");
+       spamassassin_page.page.path = path;
        spamassassin_page.page.create_widget = spamassassin_create_widget_func;
        spamassassin_page.page.destroy_widget = spamassassin_destroy_widget_func;
        spamassassin_page.page.save_page = spamassassin_save_func;
index e44d1f3..80ed6a0 100644 (file)
@@ -260,9 +260,14 @@ ExtProgPage *prefs_ext_prog;
 void prefs_ext_prog_init(void)
 {
        ExtProgPage *page;
+       static gchar *path[3];
+       
+       path[0] = _("Message View");
+       path[1] = _("External Programs");
+       path[2] = NULL;
 
        page = g_new0(ExtProgPage, 1);
-       page->page.path = _("Message View/External Programs");
+       page->page.path = path;
        page->page.create_widget = prefs_ext_prog_create_widget;
        page->page.destroy_widget = prefs_ext_prog_destroy_widget;
        page->page.save_page = prefs_ext_prog_save;
index eea85f3..7540832 100644 (file)
@@ -564,7 +564,12 @@ struct FolderItemGeneralPage folder_item_general_page;
 
 static void register_general_page()
 {
-        folder_item_general_page.page.path = _("General");
+       gchar *path[2];
+
+       path[0] = _("General");
+       path[1] = NULL;
+
+        folder_item_general_page.page.path = path;
         folder_item_general_page.page.create_widget = prefs_folder_item_general_create_widget_func;
         folder_item_general_page.page.destroy_widget = prefs_folder_item_general_destroy_widget_func;
         folder_item_general_page.page.save_page = prefs_folder_item_general_save_func;
@@ -576,7 +581,12 @@ struct FolderItemComposePage folder_item_compose_page;
 
 static void register_compose_page(void)
 {
-        folder_item_compose_page.page.path = _("Compose");
+       gchar *path[2];
+
+       path[0] = _("Compose");
+       path[1] = NULL;
+
+        folder_item_compose_page.page.path = path;
         folder_item_compose_page.page.create_widget = prefs_folder_item_compose_create_widget_func;
         folder_item_compose_page.page.destroy_widget = prefs_folder_item_compose_destroy_widget_func;
         folder_item_compose_page.page.save_page = prefs_folder_item_compose_save_func;
index 63e55e2..aa5c014 100644 (file)
@@ -284,9 +284,14 @@ FontsPage *prefs_fonts;
 void prefs_fonts_init(void)
 {
        FontsPage *page;
+       static gchar *path[3];
+
+       path[0] = _("Display");
+       path[1] = _("Fonts");
+       path[2] = NULL;
 
        page = g_new0(FontsPage, 1);
-       page->page.path = _("Display/Fonts");
+       page->page.path = path;
        page->page.create_widget = prefs_fonts_create_widget;
        page->page.destroy_widget = prefs_fonts_destroy_widget;
        page->page.save_page = prefs_fonts_save;
index 0332b07..1999f58 100644 (file)
@@ -379,9 +379,14 @@ MsgColorsPage *prefs_msg_colors;
 void prefs_msg_colors_init(void)
 {
        MsgColorsPage *page;
+       static gchar *path[3];
+
+       path[0] = _("Message View");
+       path[1] = _("Colors");
+       path[2] = NULL;
 
        page = g_new0(MsgColorsPage, 1);
-       page->page.path = _("Message View/Colors");
+       page->page.path = path;
        page->page.create_widget = prefs_msg_colors_create_widget;
        page->page.destroy_widget = prefs_msg_colors_destroy_widget;
        page->page.save_page = prefs_msg_colors_save;
index 23560f9..0c4473b 100644 (file)
@@ -356,13 +356,19 @@ SpellingPage *prefs_spelling;
 void prefs_spelling_init(void)
 {
        SpellingPage *page;
+       static gchar *path[3];
+
+       path[0] = _("Compose");
+       path[1] = _("Spell Checker");
+       path[2] = NULL;
 
        page = g_new0(SpellingPage, 1);
-       page->page.path = _("Compose/Spell Checker");
+       page->page.path = path;
        page->page.create_widget = prefs_spelling_create_widget;
        page->page.destroy_widget = prefs_spelling_destroy_widget;
        page->page.save_page = prefs_spelling_save;
        page->page.weight = 50.0;
+
        prefs_gtk_register_page((PrefsPage *) page);
        prefs_spelling = page;
 }
index cbb43eb..36cf475 100644 (file)
@@ -322,9 +322,14 @@ static void prefs_themes_get_themes_and_names(ThemesData *tdata)
 
 void prefs_themes_init(void)
 {
-       ThemesData *tdata;
-       ThemesPage *page;
-       GList      *tpaths;
+       ThemesData   *tdata;
+       ThemesPage   *page;
+       GList        *tpaths;
+       static gchar *path[3];
+
+       path[0] = _("Display");
+       path[1] = _("Themes");
+       path[2] = NULL;
 
        debug_print("Creating prefereces for themes...\n");
        
@@ -335,7 +340,7 @@ void prefs_themes_init(void)
        
        page = g_new0(ThemesPage, 1);
        
-       page->page.path = _("Display/Themes");
+       page->page.path = path;
        page->page.create_widget = prefs_themes_create_widget;
        page->page.destroy_widget = prefs_themes_destroy_widget;
        page->page.save_page = prefs_themes_save;
index b89824e..28f9db3 100644 (file)
@@ -870,9 +870,14 @@ ToolbarPage *prefs_toolbar_messageview;
 void prefs_toolbar_init(void)
 {
        ToolbarPage *page;
+       static gchar *mainpath[3], *messagepath[3], *composepath[3];
+
+       mainpath[0] = _("Customize Toolbars");
+       mainpath[1] = _("Main Window");
+       mainpath[2] = NULL;
 
        page = g_new0(ToolbarPage, 1);
-       page->page.path = _("Customize Toolbars/Main Window");
+       page->page.path = mainpath;
        page->page.create_widget = prefs_toolbar_create_widget;
        page->page.destroy_widget = prefs_toolbar_destroy_widget;
        page->page.save_page = prefs_toolbar_save;
@@ -880,8 +885,12 @@ void prefs_toolbar_init(void)
        prefs_gtk_register_page((PrefsPage *) page);
        prefs_toolbar_mainwindow = page;
 
+       messagepath[0] = _("Customize Toolbars");
+       messagepath[1] = _("Message Window");
+       messagepath[2] = NULL;
+
        page = g_new0(ToolbarPage, 1);
-       page->page.path = _("Customize Toolbars/Message Window");
+       page->page.path = messagepath;
        page->page.create_widget = prefs_toolbar_create_widget;
        page->page.destroy_widget = prefs_toolbar_destroy_widget;
        page->page.save_page = prefs_toolbar_save;
@@ -889,8 +898,12 @@ void prefs_toolbar_init(void)
        prefs_gtk_register_page((PrefsPage *) page);
        prefs_toolbar_messageview = page;
 
+       composepath[0] = _("Customize Toolbars");
+       composepath[1] = _("Compose Window");
+       composepath[2] = NULL;
+
        page = g_new0(ToolbarPage, 1);
-       page->page.path = _("Customize Toolbars/Compose Window");
+       page->page.path = composepath;
        page->page.create_widget = prefs_toolbar_create_widget;
        page->page.destroy_widget = prefs_toolbar_destroy_widget;
        page->page.save_page = prefs_toolbar_save;
index 51a6a0b..b7ae99a 100644 (file)
@@ -150,9 +150,14 @@ WrappingPage *prefs_wrapping;
 void prefs_wrapping_init(void)
 {
        WrappingPage *page;
+       static gchar *path[3];
+
+       path[0] = _("Compose");
+       path[1] = _("Message Wrapping");
+       path[2] = NULL;
 
        page = g_new0(WrappingPage, 1);
-       page->page.path = _("Compose/Message Wrapping");
+       page->page.path = path;
        page->page.create_widget = prefs_wrapping_create_widget;
        page->page.destroy_widget = prefs_wrapping_destroy_widget;
        page->page.save_page = prefs_wrapping_save;
index ef4d2c2..d7f84ef 100644 (file)
 #ifndef __PROCMIME_H__
 #define __PROCMIME_H__
 
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
 #endif
@@ -132,6 +128,10 @@ struct _MimeInfo
 #define IS_BOUNDARY(s, bnd, len) \
        (bnd && s[0] == '-' && s[1] == '-' && !strncmp(s + 2, bnd, len))
 
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
 /* MimeInfo handling */
 
 MimeInfo *procmime_mimeinfo_new                (void);
index 2873d5b..ba001ee 100644 (file)
@@ -9,5 +9,6 @@ plugindir=${pkglibdir}/plugins
 
 Name: Sylpheed-Claws
 Description: Sylpheed-Claws
-Version: @VERSION@
+Version: @MAJOR_VERSION@.@MINOR_VERSION@.@MICRO_VERSION@.@EXTRA_VERSION@
+
 Cflags: @ASPELL_CFLAGS@ @GPGME_CFLAGS@ @OPENSSL_CFLAGS@ -I${pkgincludedir} -I${pkgincludedir}/common -I${pkgincludedir}/gtk