sync with 0.8.10cvs20
authorPaul Mangan <paul@claws-mail.org>
Fri, 28 Feb 2003 16:05:49 +0000 (16:05 +0000)
committerPaul Mangan <paul@claws-mail.org>
Fri, 28 Feb 2003 16:05:49 +0000 (16:05 +0000)
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.ac
src/compose.c
src/prefs_account.c
src/prefs_account.h

index ad3ee26..803fed3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-02-28
+
+       * src/prefs_account.[ch]: added an option to use command output for
+         signature.
+       * src/compose.c: compose_insert_sig(): use command output if
+         specified.
+         compose_insert_command_output(): new.
+
 2003-02-28
 
        * src/main.c: main(): remove lock socket if sylpheed is not running
index caced98..5023b7d 100644 (file)
@@ -1,3 +1,8 @@
+2003-02-28 [paul]      0.8.10claws60
+
+       * sync with 0.8.10cvs20
+               see ChangeLog 2003-02-28
+
 2003-02-28 [paul]      0.8.10claws59
 
        * po/POTFILES.in
index 3a62af2..8c60fe6 100644 (file)
@@ -1,3 +1,11 @@
+2003-02-28
+
+       * src/prefs_account.[ch]: ½ð̾¤Ë¥³¥Þ¥ó¥É¤Î½ÐÎϤò»ÈÍѤ¹¤ë¥ª¥×¥·¥ç¥ó
+         ¤òÄɲá£
+       * src/compose.c: compose_insert_sig(): »ØÄꤵ¤ì¤¿¾ì¹ç¤Ï¥³¥Þ¥ó¥É¤Î
+         ½ÐÎϤò»ÈÍÑ¡£
+         compose_insert_command_output(): ¿·µ¬¡£
+
 2003-02-28
 
        * src/main.c: main(): --status ¥³¥Þ¥ó¥É¤¬¼Â¹Ô¤µ¤ì¤¿»þ¤Ë sylpheed
index ebb1ee2..2282f6c 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=10
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws59
+EXTRA_VERSION=claws60
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 9b27b97..ba36887 100644 (file)
@@ -199,6 +199,8 @@ static void compose_reedit_set_entry                (Compose        *compose,
 static void compose_insert_sig                 (Compose        *compose);
 static void compose_insert_file                        (Compose        *compose,
                                                 const gchar    *file);
+static void compose_insert_command_output      (Compose        *compose,
+                                                const gchar    *cmdline);
 static void compose_attach_append              (Compose        *compose,
                                                 const gchar    *file,
                                                 const gchar    *type,
@@ -1787,59 +1789,28 @@ static void compose_reedit_set_entry(Compose *compose, MsgInfo *msginfo)
 #undef SET_ENTRY
 #undef SET_ADDRESS
 
-static void compose_exec_sig(Compose *compose, gchar *sigfile)
+static void compose_insert_sig(Compose *compose)
 {
-       FILE  *sigprg;
-       gchar  *buf;
-       size_t buf_len = 128;
-       if (strlen(sigfile) < 2)
-         return;
-       sigprg = popen(sigfile+1, "r");
-       if (sigprg) {
-
-               buf = g_malloc(buf_len);
+       static gchar *default_sigfile;
+       gchar *sigfile = NULL;
 
-               if (!buf) {
-                       gtk_stext_insert(GTK_STEXT(compose->text), NULL, NULL, NULL, \
-                       "Unable to insert signature (malloc failed)\n", -1);
+       g_return_if_fail(compose->account != NULL);
 
-                       pclose(sigprg);
-                       return;
+       if (compose->account->sig_type == SIG_FILE) {
+               if (compose->account->sig_path)
+                       sigfile = compose->account->sig_path;
+               else {
+                       if (!default_sigfile)
+                               default_sigfile = g_strconcat
+                                       (get_home_dir(), G_DIR_SEPARATOR_S,
+                                        DEFAULT_SIGNATURE, NULL);
+                       sigfile = default_sigfile;
                }
 
-               while (!feof(sigprg)) {
-                       bzero(buf, buf_len);
-                       fread(buf, buf_len-1, 1, sigprg);
-                       gtk_stext_insert(GTK_STEXT(compose->text), NULL, NULL, NULL, buf, -1);
+               if (!is_file_or_fifo_exist(sigfile)) {
+                       g_warning("can't open signature file: %s\n", sigfile);
+                       return;
                }
-
-               g_free(buf);
-               pclose(sigprg);
-       }
-       else
-       {
-               gtk_stext_insert(GTK_STEXT(compose->text), NULL, NULL, NULL, \
-               "Can't exec file: ", -1);
-               gtk_stext_insert(GTK_STEXT(compose->text), NULL, NULL, NULL, \
-               sigfile+1, -1);
-       }
-}
-
-static void compose_insert_sig(Compose *compose)
-{
-       gchar *sigfile;
-
-       if (compose->account && compose->account->sig_path)
-               sigfile = g_strdup(compose->account->sig_path);
-       else
-               sigfile = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
-                                     DEFAULT_SIGNATURE, NULL);
-
-       if (!is_file_or_fifo_exist(sigfile) && sigfile[0] != '|') {
-               g_free(sigfile);
-               return;
        }
 
        gtk_stext_insert(GTK_STEXT(compose->text), NULL, NULL, NULL, "\n\n", 2);
@@ -1850,11 +1821,12 @@ static void compose_insert_sig(Compose *compose)
                                "\n", 1);
        }
 
-       if (sigfile[0] == '|')
-               compose_exec_sig(compose, sigfile);
-       else
+       if (compose->account->sig_type == SIG_COMMAND) {
+               if (compose->account->sig_path)
+                       compose_insert_command_output
+                               (compose, compose->account->sig_path);
+       } else
                compose_insert_file(compose, sigfile);
-       g_free(sigfile);
 }
 
 static void compose_insert_file(Compose *compose, const gchar *file)
@@ -1890,6 +1862,38 @@ static void compose_insert_file(Compose *compose, const gchar *file)
        fclose(fp);
 }
 
+static void compose_insert_command_output(Compose *compose,
+                                         const gchar *cmdline)
+{
+       GtkSText *text = GTK_STEXT(compose->text);
+       gchar buf[BUFFSIZE];
+       gint len;
+       FILE *fp;
+
+       g_return_if_fail(cmdline != NULL);
+
+       if ((fp = popen(cmdline, "r")) == NULL) {
+               FILE_OP_ERROR(cmdline, "popen");
+               return;
+       }
+
+       gtk_stext_freeze(text);
+
+       while (fgets(buf, sizeof(buf), fp) != NULL) {
+               strcrchomp(buf);
+               len = strlen(buf);
+               if (len > 0 && buf[len - 1] != '\n') {
+                       while (--len >= 0)
+                               if (buf[len] == '\r') buf[len] = '\n';
+               }
+               gtk_stext_insert(text, NULL, NULL, NULL, buf, -1);
+       }
+
+       gtk_stext_thaw(text);
+
+       pclose(fp);
+}
+
 static void compose_attach_append(Compose *compose, const gchar *file,
                                  const gchar *filename,
                                  const gchar *content_type)
index de2dd56..c7f376a 100644 (file)
@@ -119,6 +119,7 @@ static struct Send {
 } p_send;
 
 static struct Compose {
+       GtkWidget *sigfile_radiobtn;
        GtkWidget *entry_sigpath;
        GtkWidget *checkbtn_autosig;
        GtkWidget *entry_sigsep;
@@ -206,10 +207,8 @@ static void prefs_account_smtp_auth_type_set_data_from_optmenu
                                                        (PrefParam *pparam);
 static void prefs_account_smtp_auth_type_set_optmenu   (PrefParam *pparam);
 
-#if USE_GPGME || USE_OPENSSL
 static void prefs_account_enum_set_data_from_radiobtn  (PrefParam *pparam);
 static void prefs_account_enum_set_radiobtn            (PrefParam *pparam);
-#endif /* USE_GPGME || USE_OPENSSL */
 
 #if USE_GPGME
 static void prefs_account_gnupg_inline_warning         (GtkWidget *widget);
@@ -357,6 +356,10 @@ static PrefParam param[] = {
         prefs_set_data_from_entry, prefs_set_entry},
 
        /* Compose */
+       {"signature_type", "0", &tmp_ac_prefs.sig_type, P_ENUM,
+        &compose.sigfile_radiobtn,
+        prefs_account_enum_set_data_from_radiobtn,
+        prefs_account_enum_set_radiobtn},
        {"signature_path", "~/"DEFAULT_SIGNATURE, &tmp_ac_prefs.sig_path, P_STRING,
         &compose.entry_sigpath,
         prefs_set_data_from_entry, prefs_set_entry},
@@ -1479,6 +1482,7 @@ static void prefs_account_send_create(void)
 static void prefs_account_compose_create(void)
 {
        GtkWidget *vbox1;
+       GtkWidget *sig_hbox;
        GtkWidget *hbox1;
        GtkWidget *hbox2;
        GtkWidget *frame_sig;
@@ -1488,6 +1492,8 @@ static void prefs_account_compose_create(void)
        GtkWidget *checkbtn_autosig;
        GtkWidget *label_sigsep;
        GtkWidget *entry_sigsep;
+       GtkWidget *sigfile_radiobtn;
+       GtkWidget *sigcmd_radiobtn;
        GtkWidget *frame;
        GtkWidget *table;
        GtkWidget *autocc_chkbtn;
@@ -1509,6 +1515,25 @@ static void prefs_account_compose_create(void)
        gtk_container_add (GTK_CONTAINER (frame_sig), vbox_sig);
        gtk_container_set_border_width (GTK_CONTAINER (vbox_sig), 8);
 
+       sig_hbox = gtk_hbox_new (FALSE, 8);
+       gtk_widget_show (sig_hbox);
+       gtk_box_pack_start (GTK_BOX (vbox_sig), sig_hbox, FALSE, FALSE, 0);
+
+       sigfile_radiobtn = gtk_radio_button_new_with_label (NULL, _("File"));
+       gtk_widget_show (sigfile_radiobtn);
+       gtk_box_pack_start (GTK_BOX (sig_hbox), sigfile_radiobtn,
+                           FALSE, FALSE, 0);
+       gtk_object_set_user_data (GTK_OBJECT (sigfile_radiobtn),
+                                 GINT_TO_POINTER (SIG_FILE));
+
+       sigcmd_radiobtn = gtk_radio_button_new_with_label_from_widget
+               (GTK_RADIO_BUTTON(sigfile_radiobtn), _("Command output"));
+       gtk_widget_show (sigcmd_radiobtn);
+       gtk_box_pack_start (GTK_BOX (sig_hbox), sigcmd_radiobtn,
+                           FALSE, FALSE, 0);
+       gtk_object_set_user_data (GTK_OBJECT (sigcmd_radiobtn),
+                                 GINT_TO_POINTER (SIG_COMMAND));
+
        PACK_CHECK_BUTTON (vbox_sig, checkbtn_autosig,
                           _("Insert signature automatically"));
 
@@ -1584,6 +1609,7 @@ static void prefs_account_compose_create(void)
 
        SET_TOGGLE_SENSITIVITY (autoreplyto_chkbtn, autoreplyto_entry);
 
+       compose.sigfile_radiobtn = sigfile_radiobtn;
        compose.entry_sigpath      = entry_sigpath;
        compose.checkbtn_autosig   = checkbtn_autosig;
        compose.entry_sigsep       = entry_sigsep;
index 40d75a1..c5eae9a 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
@@ -44,6 +44,12 @@ typedef enum {
        A_LOCAL
 } RecvProtocol;
 
+typedef enum {
+       SIG_FILE,
+       SIG_COMMAND,
+       SIG_DIRECT
+} SigType;
+
 typedef enum {
        /* login and retrieve messages, as before */
        STYPE_NORMAL,
@@ -141,6 +147,7 @@ struct _PrefsAccount
        GSList *customhdr_list;
 
        /* Compose */
+       SigType sig_type;
        gchar    *sig_path;
        gboolean  auto_sig;
        gchar    *sig_sep;