--- message-window.orig 2002-07-23 01:49:10.000000000 +0100 +++ message-window.changed 2002-07-23 01:58:45.000000000 +0100 @@ -1375,16 +1375,16 @@ } static void -append_signature (GtkTextBuffer * body_buffer, const char *sig_file) +append_signature (GtkTextBuffer * body_buffer, const char *sig_file, const char * news_group) { char * sig = NULL; char * pch; - + /* sanity clause */ g_return_if_fail (body_buffer!=NULL); g_return_if_fail (GTK_IS_TEXT_BUFFER(body_buffer)); g_return_if_fail (sig_file!=NULL); - + /* since we're applying a signature, remove any signature anyway */ remove_signature (body_buffer); @@ -1400,16 +1400,58 @@ /* expand the home directory character */ if (*pch=='~') replace_gstr (&pch, g_strconcat (g_get_home_dir(), pch+1, NULL)); - - if (!g_shell_parse_argv (pch, &argc, &argv, &err)) + + /* need to find out if pch contains the string '%N'. If so, + * replace that with the contents of news_group. Big thanks + * to Merdydd Luff for helping me here! */ + + int count_refs=0; + int a, b, wpos; + int pch2length = strlen(pch); + int nglength = strlen(news_group); + char * pch2; + + for(a=0; pch[a]!='\0'; a++) + { + if(pch[a]=='%' && pch[a+1]=='N') + { + pch2length += strlen(news_group) - 2; + } + } + + pch2length += 2; + pch2 = (char *) malloc( (pch2length*sizeof(char))); + for(a=0; amessage); + log_add_va (LOG_ERROR, _("Couldn't parse signature command \"%s\": %s"), pch2, err->message); g_error_free (err); err = NULL; } else if (!argv || !argv[0]) { - log_add_va (LOG_ERROR, _("Couldn't parse signature command \"%s\""), pch); + log_add_va (LOG_ERROR, _("Couldn't parse signature command \"%s\""), pch2); } else { @@ -1421,7 +1463,7 @@ if (!g_spawn_sync (NULL, argv, NULL, 0, NULL, NULL, &standard_output, &standard_error, &exit_status, &err)) { - log_add_va (LOG_ERROR, _("Couldn't run signature program '%s': %s"), pch, err->message); + log_add_va (LOG_ERROR, _("Couldn't run signature program '%s': %s"), pch2, err->message); g_error_free (err); err = NULL; } @@ -1438,7 +1480,8 @@ GError * err = NULL; if (!g_file_get_contents (argv[0], &sig, NULL, &err)) { - log_add_va (LOG_ERROR, _("Couldn't read signature file '%s': %s"), pch, err->message); + printf("blah 10\n"); + log_add_va (LOG_ERROR, _("Couldn't read signature file '%s': %s"), pch2, err->message); g_error_free (err); } } @@ -1446,6 +1489,7 @@ /* cleanup */ g_strfreev (argv); + g_free (pch2); } g_free (pch); @@ -1453,6 +1497,7 @@ /* append the signature */ if (sig!=NULL) { + GtkTextIter start; GtkTextIter end; char * out; @@ -1471,7 +1516,7 @@ || (pan_strstr(sig, "\n-- \n")!=NULL)); out = g_strdup_printf ("%s%s%s", text, delimiter_exists ? "" : "\n-- \n", sig); - + update_body_pane (body_buffer, out, FALSE); g_free (out); @@ -1619,7 +1664,7 @@ } static void -apply_identity (Compose * mw, const Identity * id) +apply_identity (Compose * mw, const Identity * id, const char *ng) { g_return_if_fail (mw!=NULL); g_return_if_fail (id!=NULL); @@ -1632,7 +1677,7 @@ prepend_attribution_line (mw, id->attribution); if (is_nonempty_string (id->signature)) - append_signature (mw->body_buffer, id->signature); + append_signature (mw->body_buffer, id->signature, ng); add_custom_headers (mw->custom_headers_text, id); } @@ -1663,7 +1708,7 @@ if (new_id!=NULL) { - apply_identity (mw, new_id); + apply_identity (mw, new_id, NULL); replace_gstr (&mw->identity_name, g_strdup(new_id_name)); pan_object_unref (PAN_OBJECT(new_id)); } @@ -1815,6 +1860,7 @@ const char * cp; GMimeMessage * m; char * default_id_name; + const char * ng; g_return_if_fail (mw != NULL); @@ -1987,11 +2033,16 @@ { pan_gtk_entry_set_text (mw->newsgroups, followup); } + + ng = followup; + } else if (is_nonempty_string(newsgroups)) /* explicit groups */ { pan_gtk_entry_set_text (mw->newsgroups, newsgroups); default_newsgroups = FALSE; + + ng = newsgroups; } } @@ -2037,7 +2088,7 @@ g_string_truncate (str, str->len-1); /* zotz last comma */ pan_gtk_entry_set_text (mw->newsgroups, str->str); } - + g_string_free (str, TRUE); } } @@ -2053,7 +2104,10 @@ if (id) { - apply_identity (mw, id); + /* FIX ME: + * The "ng" variable only has a sensible value when following + * up a post. Otherwise it's just filled with garbage :-( */ + apply_identity (mw, id, ng); pan_object_unref (PAN_OBJECT (id)); } }