2006-02-16 [wwp] 2.0.0cvs57
[claws.git] / src / quote_fmt_parse.y
index 29f6dd7e308cba659b13cf61c57bb758748ad0b3..e345257396df6842fecebd8a40324be9861d5fdf 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 Hiroyuki Yamamoto and the Sylpheed-Claws Team
+ * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Sylpheed-Claws Team
  *
  * 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
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 %{
@@ -42,6 +42,7 @@ int yylex(void);
 
 static MsgInfo *msginfo = NULL;
 static gboolean *visible = NULL;
+static gboolean dry_run = FALSE;
 static gint maxsize = 0;
 static gint stacksize = 0;
 
@@ -52,7 +53,7 @@ static const gchar *quote_str = NULL;
 static const gchar *body = NULL;
 static gint error = 0;
 
-static gint cursor_pos  = 0;
+static gint cursor_pos  = -1;
 
 extern int quote_fmt_firsttime;
 
@@ -116,11 +117,12 @@ gint quote_fmt_get_cursor_pos(void)
        }
 
 void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str,
-                   const gchar *my_body)
+                   const gchar *my_body, gboolean my_dry_run)
 {
        quote_str = my_quote_str;
        body = my_body;
        msginfo = info;
+       dry_run = my_dry_run;
        stacksize = 0;
        add_visibility(TRUE);
        if (buffer != NULL)
@@ -131,7 +133,7 @@ void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str,
          * force LEX initialization
          */
        quote_fmt_firsttime = 1;
-       cursor_pos = 0;
+       cursor_pos = -1;
 }
 
 void quote_fmterror(char *str)
@@ -147,7 +149,7 @@ int quote_fmtwrap(void)
 
 static int isseparator(int ch)
 {
-       return isspace(ch) || ch == '.' || ch == '-';
+       return g_ascii_isspace(ch) || ch == '.' || ch == '-';
 }
 
 static void quote_fmt_show_date(const MsgInfo *msginfo, const gchar *format)
@@ -304,7 +306,7 @@ static void quote_fmt_show_sender_initial(const MsgInfo *msginfo)
        p = msginfo->fromname;
        cur = tmp;
        while (*p) {
-               if (*p && isalnum(*p)) {
+               if (*p && g_utf8_validate(p, 1, NULL)) {
                        *cur = toupper(*p);
                                cur++;
                        len++;
@@ -331,8 +333,12 @@ static void quote_fmt_show_msg(MsgInfo *msginfo, const gchar *body,
 
        if (body)
                fp = str_open_as_stream(body);
-       else
-               fp = procmime_get_first_text_content(msginfo);
+       else {
+               if (procmime_msginfo_is_encrypted(msginfo))
+                       fp = procmime_get_first_encrypted_text_content(msginfo);
+               else
+                       fp = procmime_get_first_text_content(msginfo);
+       }
 
        if (fp == NULL)
                g_warning("Can't get text part\n");
@@ -357,7 +363,7 @@ static void quote_fmt_insert_file(const gchar *filename)
        FILE *file;
        char buffer[256];
        
-       if ((file = fopen(filename, "rb")) != NULL) {
+       if ((file = g_fopen(filename, "rb")) != NULL) {
                while (fgets(buffer, sizeof(buffer), file)) {
                        INSERT(buffer);
                }
@@ -375,7 +381,7 @@ static void quote_fmt_insert_program_output(const gchar *progname)
                while (fgets(buffer, sizeof(buffer), file)) {
                        INSERT(buffer);
                }
-               fclose(file);
+               pclose(file);
        }
 }
 
@@ -643,9 +649,13 @@ query:
 insert:
        INSERT_FILE OPARENT string CPARENT
        {
-               quote_fmt_insert_file($3);
+               if (!dry_run) {
+                       quote_fmt_insert_file($3);
+               }
        }
        | INSERT_PROGRAMOUTPUT OPARENT string CPARENT
        {
-               quote_fmt_insert_program_output($3);
+               if (!dry_run) {
+                       quote_fmt_insert_program_output($3);
+               }
        };