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,
text = GTK_STEXT(compose->text);
gtk_stext_freeze(text);
- if (prefs_common.auto_sig)
+ if (account->auto_sig)
compose_insert_sig(compose);
gtk_editable_set_position(GTK_EDITABLE(text), 0);
gtk_stext_set_point(text, 0);
}
*/
+void compose_reply_mode(ComposeMode mode, GSList *msginfo_list, gchar *body)
+{
+ MsgInfo *msginfo;
+ guint list_len;
+
+ g_return_if_fail(msginfo_list != NULL);
+
+ msginfo = (MsgInfo*)g_slist_nth_data(msginfo_list, 0);
+ g_return_if_fail(msginfo != NULL);
+
+ list_len = g_slist_length(msginfo_list);
+
+ switch (mode) {
+ case COMPOSE_REPLY:
+ compose_reply(msginfo, prefs_common.reply_with_quote,
+ FALSE, prefs_common.default_reply_list, FALSE, body);
+ break;
+ case COMPOSE_REPLY_WITH_QUOTE:
+ compose_reply(msginfo, TRUE, FALSE, prefs_common.default_reply_list, FALSE, body);
+ break;
+ case COMPOSE_REPLY_WITHOUT_QUOTE:
+ compose_reply(msginfo, FALSE, FALSE, prefs_common.default_reply_list, FALSE, NULL);
+ break;
+ case COMPOSE_REPLY_TO_SENDER:
+ compose_reply(msginfo, prefs_common.reply_with_quote,
+ FALSE, FALSE, TRUE, body);
+ break;
+ case COMPOSE_FOLLOWUP_AND_REPLY_TO:
+ compose_followup_and_reply_to(msginfo,
+ prefs_common.reply_with_quote,
+ FALSE, FALSE, body);
+ break;
+ case COMPOSE_REPLY_TO_SENDER_WITH_QUOTE:
+ compose_reply(msginfo, TRUE, FALSE, FALSE, TRUE, body);
+ break;
+ case COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE:
+ compose_reply(msginfo, FALSE, FALSE, FALSE, TRUE, NULL);
+ break;
+ case COMPOSE_REPLY_TO_ALL:
+ compose_reply(msginfo, prefs_common.reply_with_quote,
+ TRUE, FALSE, FALSE, body);
+ break;
+ case COMPOSE_REPLY_TO_ALL_WITH_QUOTE:
+ compose_reply(msginfo, TRUE, TRUE, FALSE, FALSE, body);
+ break;
+ case COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE:
+ compose_reply(msginfo, FALSE, TRUE, FALSE, FALSE, NULL);
+ break;
+ case COMPOSE_REPLY_TO_LIST:
+ compose_reply(msginfo, prefs_common.reply_with_quote,
+ FALSE, TRUE, FALSE, body);
+ break;
+ case COMPOSE_REPLY_TO_LIST_WITH_QUOTE:
+ compose_reply(msginfo, TRUE, FALSE, TRUE, FALSE, body);
+ break;
+ case COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE:
+ compose_reply(msginfo, FALSE, FALSE, TRUE, FALSE, NULL);
+ break;
+ case COMPOSE_FORWARD:
+ if (prefs_common.forward_as_attachment) {
+ compose_reply_mode(COMPOSE_FORWARD_AS_ATTACH, msginfo_list, body);
+ return;
+ } else {
+ compose_reply_mode(COMPOSE_FORWARD_INLINE, msginfo_list, body);
+ return;
+ }
+ break;
+ case COMPOSE_FORWARD_INLINE:
+ /* check if we reply to more than one Message */
+ if (list_len == 1) {
+ compose_forward(NULL, msginfo, FALSE, body);
+ break;
+ }
+ /* more messages FALL THROUGH */
+ case COMPOSE_FORWARD_AS_ATTACH:
+ compose_forward_multiple(NULL, msginfo_list);
+ break;
+ case COMPOSE_REDIRECT:
+ compose_redirect(NULL, msginfo);
+ break;
+ default:
+ g_warning("compose_reply(): invalid Compose Mode: %d\n", mode);
+ }
+
+ //summary_set_marks_selected(summaryview);
+}
+
void compose_reply(MsgInfo *msginfo, gboolean quote, gboolean to_all,
gboolean to_ml, gboolean to_sender,
const gchar *body)
qmark, body);
}
- if (prefs_common.auto_sig)
+ if (account->auto_sig)
compose_insert_sig(compose);
if (quote && prefs_common.linewrap_quote)
procmsg_msginfo_free(full_msginfo);
}
- if (prefs_common.auto_sig)
+ if (account->auto_sig)
compose_insert_sig(compose);
if (prefs_common.linewrap_quote)
g_free(msgfile);
}
- if (prefs_common.auto_sig)
+ if (account->auto_sig)
compose_insert_sig(compose);
if (prefs_common.linewrap_quote)
} else
compose_entry_append(compose,
(compose->replyto && !to_sender)
- ? compose->replyto
- : msginfo->from ? msginfo->from : "",
- COMPOSE_TO);
+ ? compose->replyto :
+ msginfo->from ? msginfo->from : "",
+ COMPOSE_TO);
} else {
if (to_sender || (compose->followup_to &&
- strncmp(compose->followup_to, "poster\n", 7)))
+ !strncmp(compose->followup_to, "poster", 6)))
compose_entry_append
(compose,
- ((compose->replyto && !to_sender)
- ? compose->replyto
- : msginfo->from ? msginfo->from : ""),
+ (compose->replyto ? compose->replyto :
+ msginfo->from ? msginfo->from : ""),
COMPOSE_TO);
else if (followup_and_reply_to || to_all) {
compose_entry_append
(compose,
- (compose->replyto
- ? compose->replyto
- : msginfo->from ? msginfo->from : ""),
+ (compose->replyto ? compose->replyto :
+ msginfo->from ? msginfo->from : ""),
COMPOSE_TO);
compose_entry_append
(compose,
+ compose->followup_to ? compose->followup_to :
compose->newsgroups ? compose->newsgroups : "",
COMPOSE_NEWSGROUPS);
- } else {
+ }
+ else
compose_entry_append
(compose,
+ compose->followup_to ? compose->followup_to :
compose->newsgroups ? compose->newsgroups : "",
COMPOSE_NEWSGROUPS);
- }
}
if (msginfo->subject && *msginfo->subject) {
#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);
- if (prefs_common.sig_sep) {
+ if (compose->account->sig_sep) {
gtk_stext_insert(GTK_STEXT(compose->text), NULL, NULL, NULL,
- prefs_common.sig_sep, -1);
+ compose->account->sig_sep, -1);
gtk_stext_insert(GTK_STEXT(compose->text), NULL, NULL, NULL,
"\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)
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)
for (row = 0; (ainfo = gtk_clist_get_row_data(clist, row)) != NULL;
row++) {
- gchar buf[BUFFSIZE];
- gchar inbuf[B64_LINE_SIZE], outbuf[B64_BUFFSIZE];
-
if ((attach_fp = fopen(ainfo->file, "rb")) == NULL) {
g_warning("Can't open file %s\n", ainfo->file);
continue;
parsed_str = NULL;
}
- if (replace && parsed_str && prefs_common.auto_sig)
+ if (replace && parsed_str && compose->account->auto_sig)
compose_insert_sig(compose);
if (replace && parsed_str) {