2005-04-19 [paul] 1.9.6cvs42
authorPaul Mangan <paul@claws-mail.org>
Tue, 19 Apr 2005 16:19:40 +0000 (16:19 +0000)
committerPaul Mangan <paul@claws-mail.org>
Tue, 19 Apr 2005 16:19:40 +0000 (16:19 +0000)
sync with main:

* src/action.c
catch_output(): correctly select the insert text
(fix invalid iterator warnings).
* src/codeconv.c
* src/codeconv.h
* src/mainwindow.c
* src/messageview.c
* src/prefs_common.c
support GBK encoding. Fallback to GBK if "X-GBK"
is passed (thanks to SuperMMX)
* src/common/session.c
* src/common/session.h
use separate buffer for large data to be sent,
and don't duplicate it (reduces memory usage) (thanks to Dirk).

ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/action.c
src/codeconv.c
src/codeconv.h
src/common/session.c
src/common/session.h
src/mainwindow.c
src/messageview.c
src/prefs_common.c

index b354c3a4a9348b7958baf98c598ec3482cdd8e81..4375538604eb6f29fbc057619daadf5ab49d81fd 100644 (file)
@@ -1,3 +1,22 @@
+2005-04-19 [paul]      1.9.6cvs42
+
+       sync with main:
+
+       * src/action.c
+               catch_output(): correctly select the insert text
+               (fix invalid iterator warnings).
+       * src/codeconv.c
+       * src/codeconv.h
+       * src/mainwindow.c
+       * src/messageview.c
+       * src/prefs_common.c
+               support GBK encoding. Fallback to GBK if "X-GBK"
+               is passed (thanks to SuperMMX)
+       * src/common/session.c
+       * src/common/session.h
+               use separate buffer for large data to be sent,
+               and don't duplicate it (reduces memory usage) (thanks to Dirk).
+
 2005-04-18 [paul]      1.9.6cvs41
 
        * src/jpilot.c
index cdf9ffcfa2e392aa010807d16f9b526be67b307f..87acf0e78d82792635ee58d0b129d689fdd4effb 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.274.2.33 -r 1.274.2.34 src/mainwindow.c; ) > 1.9.6cvs39.patchset
 ( cvs diff -u -r 1.382.2.117 -r 1.382.2.118 src/compose.c; ) > 1.9.6cvs40.patchset
 ( cvs diff -u -r 1.18.2.7 -r 1.18.2.8 src/jpilot.c; ) > 1.9.6cvs41.patchset
+( cvs diff -u -r 1.12.2.21 -r 1.12.2.22 src/action.c; cvs diff -u -r 1.65.2.26 -r 1.65.2.27 src/codeconv.c; cvs diff -u -r 1.15.2.6 -r 1.15.2.7 src/codeconv.h; cvs diff -u -r 1.274.2.34 -r 1.274.2.35 src/mainwindow.c; cvs diff -u -r 1.94.2.49 -r 1.94.2.50 src/messageview.c; cvs diff -u -r 1.204.2.34 -r 1.204.2.35 src/prefs_common.c; cvs diff -u -r 1.23.2.4 -r 1.23.2.5 src/common/session.c; cvs diff -u -r 1.8.2.2 -r 1.8.2.3 src/common/session.h; ) > 1.9.6cvs42.patchset
index 9adcd7ec67e76cfa874afd54cf770ecd1a94c7aa..5ecf4b8007bd3366e0e8c8f0cbd0f13f370d388f 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=6
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=41
+EXTRA_VERSION=42
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 3b1d9b62f9e7daae511539c2aca17a6da3a52ea8..27bfe911b3badbe8235ee22e30a035900565e54d 100644 (file)
@@ -1340,12 +1340,13 @@ static void catch_output(gpointer data, gint source, GdkInputCondition cond)
                GtkTextView *text =
                        GTK_TEXT_VIEW(child_info->children->msg_text);
                GtkTextBuffer *textbuf = gtk_text_view_get_buffer(text);
-               GtkTextIter iter1, iter2;
+               GtkTextIter iter;
                GtkTextMark *mark;
+               gint ins_pos;
 
                mark = gtk_text_buffer_get_insert(textbuf);
-               gtk_text_buffer_get_iter_at_mark(textbuf, &iter1, mark);
-               gtk_text_buffer_get_iter_at_mark(textbuf, &iter2, mark);
+               gtk_text_buffer_get_iter_at_mark(textbuf, &iter, mark);
+               ins_pos = gtk_text_iter_get_offset(&iter);
 
                while (TRUE) {
                        gsize bytes_read = 0, bytes_written = 0;
@@ -1359,21 +1360,22 @@ static void catch_output(gpointer data, gint source, GdkInputCondition cond)
                                (buf, c, &bytes_read, &bytes_written, NULL);
                        if (ret_str && bytes_written > 0) {
                                gtk_text_buffer_insert
-                                       (textbuf, &iter2, ret_str,
+                                       (textbuf, &iter, ret_str,
                                         bytes_written);
                                g_free(ret_str);
                        } else
-                               gtk_text_buffer_insert(textbuf, &iter2, buf, c);
+                               gtk_text_buffer_insert(textbuf, &iter, buf, c);
                }
 
                if (child_info->children->is_selection) {
-                       gtk_text_buffer_place_cursor(textbuf, &iter1);
-                       gtk_text_buffer_move_mark_by_name
-                               (textbuf, "selection_bound", &iter2);
+                       GtkTextIter ins;
+
+                       gtk_text_buffer_get_iter_at_offset
+                               (textbuf, &ins, ins_pos);
+                       gtk_text_buffer_select_range(textbuf, &ins, &iter);
                }
        } else {
                c = read(source, buf, sizeof(buf) - 1);
-               
                if (c > 0) {
                        gsize bytes_read = 0, bytes_written = 0;
                        gchar *ret_str;
index 4d2c74d3f357ff6c461c478d48c42e19d2108231..dbfa47761a899c8d5e836946ebf58b04e0235d78 100644 (file)
@@ -1152,7 +1152,7 @@ static const struct {
        {"ko_KR.EUC-KR" , C_EUC_KR      , C_EUC_KR},
        {"ko_KR"        , C_EUC_KR      , C_EUC_KR},
        {"zh_CN.GB2312" , C_GB2312      , C_GB2312},
-       {"zh_CN.GBK"    , C_GBK         , C_GB2312},
+       {"zh_CN.GBK"    , C_GBK         , C_GBK},
        {"zh_CN"        , C_GB2312      , C_GB2312},
        {"zh_HK"        , C_BIG5_HKSCS  , C_BIG5_HKSCS},
        {"zh_TW.eucTW"  , C_EUC_TW      , C_BIG5},
@@ -1519,6 +1519,7 @@ gboolean conv_is_multibyte_encoding(CharSet encoding)
        case C_ISO_2022_CN:
        case C_SHIFT_JIS:
        case C_GB2312:
+       case C_GBK:
        case C_BIG5:
        case C_UTF_8:
        case C_UTF_7:
index 9139f547b816f8e9189e752aa1a178cb3d3dad75..fd979c59b70b833bd194acb379c01140668fca2e 100644 (file)
@@ -158,6 +158,7 @@ struct _CodeConverter
 #define CS_EUC_CN              "EUC-CN"
 #define CS_GB2312              "GB2312"
 #define CS_GBK                 "GBK"
+#define CS_X_GBK               "X-GBK"
 #define CS_EUC_TW              "EUC-TW"
 #define CS_BIG5                        "Big5"
 #define CS_BIG5_HKSCS          "BIG5-HKSCS"
index 6db4d644966191ed5bf32b7922463397b4137956..ae25c08fb218fc291f54288e8fb9deb417463ec4 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 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
@@ -91,6 +91,10 @@ void session_init(Session *session)
        session->write_buf_p = NULL;
        session->write_buf_len = 0;
 
+       session->write_data = NULL;
+       session->write_data_p = NULL;
+       session->write_data_len = 0;
+
        session->timeout_tag = 0;
        session->timeout_interval = 0;
 
@@ -405,16 +409,15 @@ gint session_send_data(Session *session, const guchar *data, guint size)
 {
        gboolean ret;
 
-       g_return_val_if_fail(session->write_buf == NULL, -1);
+       g_return_val_if_fail(session->write_data == NULL, -1);
        g_return_val_if_fail(data != NULL, -1);
        g_return_val_if_fail(size != 0, -1);
 
        session->state = SESSION_SEND;
 
-       session->write_buf = g_malloc(size);
-       session->write_buf_p = session->write_buf;
-       memcpy(session->write_buf, data, size);
-       session->write_buf_len = size;
+       session->write_data = data;
+       session->write_data_p = session->write_data;
+       session->write_data_len = size;
        gettimeofday(&session->tv_prev, NULL);
 
        ret = session_write_data_cb(session->sock, G_IO_OUT, session);
@@ -705,6 +708,48 @@ static gint session_write_buf(Session *session)
        return 0;
 }
 
+static gint session_write_data(Session *session)
+{
+       gint write_len;
+       gint to_write_len;
+
+       g_return_val_if_fail(session->write_data != NULL, -1);
+       g_return_val_if_fail(session->write_data_p != NULL, -1);
+       g_return_val_if_fail(session->write_data_len > 0, -1);
+
+       to_write_len = session->write_data_len -
+               (session->write_data_p - session->write_data);
+       to_write_len = MIN(to_write_len, SESSION_BUFFSIZE);
+
+       write_len = sock_write(session->sock, session->write_data_p,
+                              to_write_len);
+
+       if (write_len < 0) {
+               switch (errno) {
+               case EAGAIN:
+                       write_len = 0;
+                       break;
+               default:
+                       g_warning("sock_write: %s\n", g_strerror(errno));
+                       session->state = SESSION_ERROR;
+                       return -1;
+               }
+       }
+
+       /* incomplete write */
+       if (session->write_data_p - session->write_data + write_len <
+           session->write_data_len) {
+               session->write_data_p += write_len;
+               return 1;
+       }
+
+       session->write_data = NULL;
+       session->write_data_p = NULL;
+       session->write_data_len = 0;
+
+       return 0;
+}
+
 static gboolean session_write_msg_cb(SockInfo *source, GIOCondition condition,
                                     gpointer data)
 {
@@ -738,17 +783,17 @@ static gboolean session_write_data_cb(SockInfo *source,
                                      GIOCondition condition, gpointer data)
 {
        Session *session = SESSION(data);
-       guint write_buf_len;
+       guint write_data_len;
        gint ret;
 
        g_return_val_if_fail(condition == G_IO_OUT, FALSE);
-       g_return_val_if_fail(session->write_buf != NULL, FALSE);
-       g_return_val_if_fail(session->write_buf_p != NULL, FALSE);
-       g_return_val_if_fail(session->write_buf_len > 0, FALSE);
+       g_return_val_if_fail(session->write_data != NULL, FALSE);
+       g_return_val_if_fail(session->write_data_p != NULL, FALSE);
+       g_return_val_if_fail(session->write_data_len > 0, FALSE);
 
-       write_buf_len = session->write_buf_len;
+       write_data_len = session->write_data_len;
 
-       ret = session_write_buf(session);
+       ret = session_write_data(session);
 
        if (ret < 0) {
                session->state = SESSION_ERROR;
@@ -763,8 +808,8 @@ static gboolean session_write_data_cb(SockInfo *source,
                        session_set_timeout(session, session->timeout_interval);
                        session->send_data_progressive_notify
                                (session,
-                                session->write_buf_p - session->write_buf,
-                                write_buf_len,
+                                session->write_data_p - session->write_data,
+                                write_data_len,
                                 session->send_data_progressive_notify_data);
                        gettimeofday(&session->tv_prev, NULL);
                }
@@ -777,8 +822,8 @@ static gboolean session_write_data_cb(SockInfo *source,
        }
 
        /* callback */
-       ret = session->send_data_finished(session, write_buf_len);
-       session->send_data_notify(session, write_buf_len,
+       ret = session->send_data_finished(session, write_data_len);
+       session->send_data_notify(session, write_data_len,
                                  session->send_data_notify_data);
 
        return FALSE;
index 0ebe0f688b63b8ef75357a19172a54e7f11b24ce..840bff922eac2be25ebf7fb2646bc91bf0c05f8b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 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
@@ -116,10 +116,16 @@ struct _Session
        GByteArray *read_data_buf;
        gchar *read_data_terminator;
 
+       /* buffer for short messages */
        gchar *write_buf;
        gchar *write_buf_p;
        gint write_buf_len;
 
+       /* buffer for large data */
+       const guchar *write_data;
+       const guchar *write_data_p;
+       gint write_data_len;
+
        guint timeout_tag;
        guint timeout_interval;
 
index 893cc6264d128322c20a22d028b63b9ee79fc27a..b2ae49058d94f7676309bb953c78fe5df60e918c 100644 (file)
@@ -605,6 +605,8 @@ static GtkItemFactoryEntry mainwin_entries[] =
 
        {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
         ENC_ACTION(C_GB2312)},
+       {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
+        ENC_ACTION(C_GBK)},
        {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
         ENC_ACTION(C_BIG5)},
        {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
index b553630cdb9a9412b67d03b3a1b483d3ab765ab3..e697167b7bee94f4a2cede016b761588433d2c11 100644 (file)
@@ -219,6 +219,8 @@ static GtkItemFactoryEntry msgview_entries[] =
        ENC_SEPARATOR,
        {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
         ENC_ACTION(C_GB2312)},
+       {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
+        ENC_ACTION(C_GBK)},
        {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
         ENC_ACTION(C_BIG5)},
        {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
index 6ece36ad4881613eba639d91228cef206a47a6a4..8bdbff66b4d4ea1e30e5d88463825aa1a8e6db49 100644 (file)
@@ -1274,6 +1274,7 @@ static void prefs_send_create(void)
 #endif /* 0 */
        SET_MENUITEM(NULL, NULL);
        SET_MENUITEM(_("Simplified Chinese (GB2312)"),   CS_GB2312);
+       SET_MENUITEM(_("Simplified Chinese (GBK)"),      CS_GBK);
        SET_MENUITEM(_("Traditional Chinese (Big5)"),    CS_BIG5);
 #if 0
        SET_MENUITEM(_("Traditional Chinese (EUC-TW)"),  CS_EUC_TW);