sync with 0.8.8cvs8
authorPaul Mangan <paul@claws-mail.org>
Wed, 15 Jan 2003 11:31:35 +0000 (11:31 +0000)
committerPaul Mangan <paul@claws-mail.org>
Wed, 15 Jan 2003 11:31:35 +0000 (11:31 +0000)
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.ac
src/common/quoted-printable.c
src/common/quoted-printable.h
src/compose.c
src/procmime.c

index 6098a2d..14a7e67 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2003-01-15
+
+       * src/quoted-printable.[ch]: qp_encode_line(): fixed a bug if the
+         line doesn't end with linebreak.
+
+2003-01-15
+
+       * implemented quoted-printable encoding.
+       * src/quoted-printable.[ch]: qp_encode_line(): new.
+       * src/compose.c:
+         compose_write_to_file()
+         compose_write_attach(): implemented quoted-printable encoding.
+         compose_attach_property_create(): enabled quoted-printable menu
+         item.
+       * src/procmime.c: procmime_get_encoding_for_charset(): return
+         ENC_QUOTED_PRINTABLE for ISO-8859-* and CP125* charset.
+       * src/Makefile.am: added $(LIBICONV) to sylpheed_LDADD for libiconv
+         support.
+
 2003-01-14
 
        * src/folderview.c
index b2b8f65..1d60240 100644 (file)
@@ -1,3 +1,8 @@
+2003-01-15 [paul]      0.8.8claws102
+
+       * sync with 0.8.8cvs8
+               see ChangeLog 2002-01-15
+
 2003-01-15 [colin]     0.8.8claws101
 
        * src/Makefile.am
index eb3fe05..e33516c 100644 (file)
@@ -1,3 +1,23 @@
+2003-01-15
+
+       * src/quoted-printable.[ch]: qp_encode_line(): ¹Ô¤¬²þ¹Ô¤Ç½ª¤ï¤é¤Ê¤¤
+         ¾ì¹ç¤Î¥Ð¥°¤ò½¤Àµ¡£
+
+2003-01-15
+
+       * quoted-printable Éä¹æ²½¤ò¼ÂÁõ¡£
+       * src/quoted-printable.[ch]: qp_encode_line(): ¿·µ¬¡£
+       * src/compose.c:
+         compose_write_to_file()
+         compose_write_attach(): quoted-printable Éä¹æ²½¤ò¼ÂÁõ¡£
+         compose_attach_property_create(): quoted-printable ¥á¥Ë¥å¡¼¹àÌܤò
+         Í­¸ú¤Ë¤·¤¿¡£
+       * src/procmime.c: procmime_get_encoding_for_charset(): ISO-8859-*
+         ¤È CP125* Ê¸»ú¥»¥Ã¥È¤Î¾ì¹ç¤Ï ENC_QUOTED_PRINTABLE ¤òÊÖ¤¹¤è¤¦¤Ë
+         ¤·¤¿¡£
+       * src/Makefile.am: libiconv Âбþ¤Î¤¿¤á¤Ë sylpheed_LDADD ¤Ë
+         $(LIBICONV) ¤òÄɲá£
+
 2003-01-14
 
        * src/folderview.c
index 1bdfaca..588b0a6 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws101
+EXTRA_VERSION=claws102
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index df6cca4..515641b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2003 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
 static gboolean get_hex_value(guchar *out, gchar c1, gchar c2);
 static void get_hex_str(gchar *out, guchar ch);
 
+#define MAX_LINELEN    76
+
+#define IS_LBREAK(p) \
+       (*(p) == '\0' || *(p) == '\n' || (*(p) == '\r' && *((p) + 1) == '\n'))
+
+#define SOFT_LBREAK_IF_REQUIRED(n)                                     \
+       if (len + (n) > MAX_LINELEN ||                                  \
+           (len + (n) == MAX_LINELEN && (!IS_LBREAK(inp + 1)))) {      \
+               *outp++ = '=';                                          \
+               *outp++ = '\n';                                         \
+               len = 0;                                                \
+       }
+
+void qp_encode_line(gchar *out, const guchar *in)
+{
+       const guchar *inp = in;
+       gchar *outp = out;
+       guchar ch;
+       gint len = 0;
+
+       while (*inp != '\0') {
+               ch = *inp;
+
+               if (IS_LBREAK(inp)) {
+                       *outp++ = '\n';
+                       len = 0;
+                       inp++;
+               } else if (ch == '\t' || ch == ' ') {
+                       if (IS_LBREAK(inp + 1)) {
+                               SOFT_LBREAK_IF_REQUIRED(3);
+                               *outp++ = '=';
+                               get_hex_str(outp, ch);
+                               outp += 2;
+                               len += 3;
+                               inp++;
+                       } else {
+                               SOFT_LBREAK_IF_REQUIRED(1);
+                               *outp++ = *inp++;
+                               len++;
+                       }
+               } else if ((ch >= 33 && ch <= 60) || (ch >= 62 && ch <= 126)) {
+                       SOFT_LBREAK_IF_REQUIRED(1);
+                       *outp++ = *inp++;
+                       len++;
+               } else {
+                       SOFT_LBREAK_IF_REQUIRED(3);
+                       *outp++ = '=';
+                       get_hex_str(outp, ch);
+                       outp += 2;
+                       len += 3;
+                       inp++;
+               }
+       }
+
+       if (len > 0)
+               *outp++ = '\n';
+
+       *outp = '\0';
+}
+
 gint qp_decode_line(gchar *str)
 {
        gchar *inp = str, *outp = str;
index 8c1ad0c..e5abf4f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2003 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
 
 #include <glib.h>
 
+void qp_encode_line            (gchar          *out,
+                                const guchar   *in);
 gint qp_decode_line            (gchar          *str);
+
 gint qp_decode_q_encoding      (guchar         *out,
                                 const gchar    *in,
                                 gint            inlen);
index 924bcf1..be28caa 100644 (file)
@@ -92,6 +92,7 @@
 #include "statusbar.h"
 #include "about.h"
 #include "base64.h"
+#include "quoted-printable.h"
 #include "codeconv.h"
 #include "utils.h"
 #include "gtkutils.h"
@@ -3235,7 +3236,7 @@ static gint compose_write_to_file(Compose *compose, const gchar *file,
                if (!is_draft &&
                    compose->use_signing && !compose->gnupg_mode &&
                    encoding == ENC_8BIT)
-                       encoding = ENC_BASE64;
+                       encoding = ENC_QUOTED_PRINTABLE;
 #endif
 
                src_codeset = conv_get_current_charset_str();
@@ -3347,6 +3348,22 @@ static gint compose_write_to_file(Compose *compose, const gchar *file,
                        fputs(outbuf, fp);
                        fputc('\n', fp);
                }
+       } else if (encoding == ENC_QUOTED_PRINTABLE) {
+               gchar *outbuf;
+               size_t outlen;
+
+               outbuf = g_malloc(len * 4);
+               qp_encode_line(outbuf, buf);
+               outlen = strlen(outbuf);
+               if (fwrite(outbuf, sizeof(gchar), outlen, fp) != outlen) {
+                       FILE_OP_ERROR(file, "fwrite");
+                       fclose(fp);
+                       unlink(file);
+                       g_free(outbuf);
+                       g_free(buf);
+                       return -1;
+               }
+               g_free(outbuf);
        } else if (fwrite(buf, sizeof(gchar), len, fp) != len) {
                FILE_OP_ERROR(file, "fwrite");
                fclose(fp);
@@ -3723,19 +3740,8 @@ static void compose_write_attach(Compose *compose, FILE *fp)
                fprintf(fp, "Content-Transfer-Encoding: %s\n\n",
                        procmime_get_encoding_str(ainfo->encoding));
 
-               switch (ainfo->encoding) {
-
-               case ENC_7BIT:
-               case ENC_8BIT:
-                       /* if (ainfo->encoding == ENC_7BIT) { */
-
-                       while (fgets(buf, sizeof(buf), attach_fp) != NULL) {
-                               strcrchomp(buf);
-                               fputs(buf, fp);
-                       }
-                       break;
-                       /* } else { */
-               case ENC_BASE64:
+               if (ainfo->encoding == ENC_BASE64) {
+                       gchar inbuf[B64_LINE_SIZE], outbuf[B64_BUFFSIZE];
 
                        while ((len = fread(inbuf, sizeof(gchar),
                                            B64_LINE_SIZE, attach_fp))
@@ -3749,10 +3755,20 @@ static void compose_write_attach(Compose *compose, FILE *fp)
                                fputs(outbuf, fp);
                                fputc('\n', fp);
                        }
-                       break;
-               default:
-                       debug_print("Tried to write attachment in unsupported encoding type\n");
-                       break;
+               } else if (ainfo->encoding == ENC_QUOTED_PRINTABLE) {
+                       gchar inbuf[BUFFSIZE], outbuf[BUFFSIZE * 4];
+
+                       while (fgets(inbuf, sizeof(inbuf), attach_fp) != NULL) {
+                               qp_encode_line(outbuf, inbuf);
+                               fputs(outbuf, fp);
+                       }
+               } else {
+                       gchar buf[BUFFSIZE];
+
+                       while (fgets(buf, sizeof(buf), attach_fp) != NULL) {
+                               strcrchomp(buf);
+                               fputs(buf, fp);
+                       }
                }
 
                fclose(attach_fp);
@@ -5498,8 +5514,10 @@ static void compose_attach_property_create(gboolean *cancelled)
 #if 0
        gtk_widget_set_sensitive(menuitem, FALSE);
 #endif
-       MENUITEM_ADD(optmenu_menu, menuitem, "quoted-printable", ENC_QUOTED_PRINTABLE);
-       gtk_widget_set_sensitive(menuitem, FALSE);
+       MENUITEM_ADD(optmenu_menu, menuitem, "quoted-printable",
+                    ENC_QUOTED_PRINTABLE);
+       gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), optmenu_menu);
+
        MENUITEM_ADD(optmenu_menu, menuitem, "base64", ENC_BASE64);
 
        gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), optmenu_menu);
index d5057e1..3485672 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2003 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
@@ -1238,10 +1238,11 @@ EncodingType procmime_get_encoding_for_charset(const gchar *charset)
        else if (!strncasecmp(charset, "ISO-2022-", 9) ||
                 !strcasecmp(charset, "US-ASCII"))
                return ENC_7BIT;
+       else if (!strncasecmp(charset, "ISO-8859-", 9) ||
+                !strncasecmp(charset, "CP125", 5))
+               return ENC_QUOTED_PRINTABLE;
        else
                return ENC_8BIT;
-               /* return ENC_BASE64; */
-               /* return ENC_QUOTED_PRINTABLE; */
 }
 
 EncodingType procmime_get_encoding_for_file(const gchar *file)