static void compose_toolbar_create (Compose *compose,
GtkWidget *container);
static void compose_toolbar_update (Compose *compose);
+static void compose_toolbar_set_sensitive (Compose *compose,
+ gboolean sensitive);
static GtkWidget *compose_account_option_menu_create
(Compose *compose);
static void compose_reply_set_entry (Compose *compose,
MsgInfo *msginfo,
gboolean to_all,
+ gboolean to_ml,
gboolean to_sender,
gboolean
followup_and_reply_to);
gint *position,
Compose *compose);
static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
- gboolean to_all,
+ gboolean to_all, gboolean to_ml,
gboolean ignore_replyto,
gboolean followup_and_reply_to,
const gchar *body);
gtk_stext_thaw(text);
- /* workaround for initial XIM problem */
- gtk_widget_grab_focus(compose->text);
- gtkut_widget_wait_for_draw(compose->text);
-
if (account->protocol != A_NNTP) {
if (mailto && *mailto != '\0') {
compose_entries_set(compose, mailto);
*/
void compose_reply(MsgInfo *msginfo, gboolean quote, gboolean to_all,
- gboolean ignore_replyto, const gchar *body)
+ gboolean to_ml, gboolean ignore_replyto,
+ const gchar *body)
{
- compose_generic_reply(msginfo, quote, to_all, ignore_replyto, FALSE,
- body);
+ compose_generic_reply(msginfo, quote, to_all, to_ml,
+ ignore_replyto, FALSE, body);
}
void compose_followup_and_reply_to(MsgInfo *msginfo, gboolean quote,
gboolean ignore_replyto,
const gchar *body)
{
- compose_generic_reply(msginfo, quote, to_all, ignore_replyto, TRUE,
- body);
+ compose_generic_reply(msginfo, quote, to_all, FALSE,
+ ignore_replyto, TRUE, body);
}
static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
- gboolean to_all,
+ gboolean to_all, gboolean to_ml,
gboolean ignore_replyto,
gboolean followup_and_reply_to,
const gchar *body)
reply_account = account;
compose = compose_create(account, COMPOSE_REPLY);
- compose->replyinfo = procmsg_msginfo_new_ref(msginfo);
-#if 0 /* NEW COMPOSE GUI */
- if (followup_and_reply_to) {
- gtk_widget_show(compose->to_hbox);
- gtk_widget_show(compose->to_entry);
- gtk_table_set_row_spacing(GTK_TABLE(compose->table), 1, 4);
- compose->use_to = TRUE;
- }
-#endif
+ compose->replyinfo = procmsg_msginfo_get_full_info(msginfo);
+ if (!compose->replyinfo)
+ compose->replyinfo = procmsg_msginfo_copy(msginfo);
+
if (msginfo->folder && msginfo->folder->ret_rcpt) {
GtkItemFactory *ifactory;
}
if (compose_parse_header(compose, msginfo) < 0) return;
- compose_reply_set_entry(compose, msginfo, to_all, ignore_replyto,
- followup_and_reply_to);
+ compose_reply_set_entry(compose, msginfo, to_all, to_ml,
+ ignore_replyto, followup_and_reply_to);
compose_show_first_last_header(compose, TRUE);
text = GTK_STEXT(compose->text);
else
qmark = "> ";
- quote_str = compose_quote_fmt(compose, msginfo,
+ quote_str = compose_quote_fmt(compose, compose->replyinfo,
prefs_common.quotefmt,
qmark, body);
}
} else {
gchar *qmark;
gchar *quote_str;
+ MsgInfo *full_msginfo;
+
+ full_msginfo = procmsg_msginfo_get_full_info(msginfo);
+ if (!full_msginfo)
+ full_msginfo = procmsg_msginfo_copy(msginfo);
if (prefs_common.fw_quotemark &&
*prefs_common.fw_quotemark)
else
qmark = "> ";
- quote_str = compose_quote_fmt(compose, msginfo,
+ quote_str = compose_quote_fmt(compose, full_msginfo,
prefs_common.fw_quotefmt,
qmark, body);
compose_attach_parts(compose, msginfo);
+
+ procmsg_msginfo_free(full_msginfo);
}
if (prefs_common.auto_sig)
if ((fp = procmime_get_first_text_content(msginfo)) == NULL)
g_warning(_("Can't get text part\n"));
else {
- while (fgets(buf, sizeof(buf), fp) != NULL)
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ strcrchomp(buf);
gtk_stext_insert(text, NULL, NULL, NULL, buf, -1);
+ }
fclose(fp);
}
compose_attach_parts(compose, msginfo);
static void compose_entries_set(Compose *compose, const gchar *mailto)
{
- gchar *subject = NULL;
gchar *to = NULL;
gchar *cc = NULL;
gchar *bcc = NULL;
+ gchar *subject = NULL;
gchar *body = NULL;
- gchar *p;
- gchar *tmp_mailto;
-
- Xstrdup_a(tmp_mailto, mailto, return);
-
- to = tmp_mailto;
-
- p = strchr(tmp_mailto, '?');
- if (p) {
- *p = '\0';
- p++;
- }
-
- while (p) {
- gchar *field, *value;
-
- field = p;
-
- p = strchr(p, '=');
- if (!p) break;
- *p = '\0';
- p++;
-
- value = p;
- p = strchr(p, '&');
- if (p) {
- *p = '\0';
- p++;
- }
-
- if (*value == '\0') continue;
-
- if (!g_strcasecmp(field, "subject")) {
- Xalloca(subject, strlen(value) + 1, return);
- decode_uri(subject, value);
- } else if (!g_strcasecmp(field, "cc")) {
- cc = value;
- } else if (!g_strcasecmp(field, "bcc")) {
- bcc = value;
- } else if (!g_strcasecmp(field, "body")) {
- Xalloca(body, strlen(value) + 1, return);
- decode_uri(body, value);
- }
- }
+ scan_mailto_url(mailto, &to, &cc, &bcc, &subject, &body);
if (to)
compose_entry_append(compose, to, COMPOSE_TO);
- if (subject)
- gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), subject);
if (cc)
compose_entry_append(compose, cc, COMPOSE_CC);
if (bcc)
compose_entry_append(compose, bcc, COMPOSE_BCC);
+ if (subject)
+ gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), subject);
if (body) {
gtk_stext_insert(GTK_STEXT(compose->text),
NULL, NULL, NULL, body, -1);
gtk_stext_insert(GTK_STEXT(compose->text),
NULL, NULL, NULL, "\n", 1);
}
+
+ g_free(to);
+ g_free(cc);
+ g_free(bcc);
+ g_free(subject);
+ g_free(body);
}
static gint compose_parse_header(Compose *compose, MsgInfo *msginfo)
{
- static HeaderEntry hentry[] = {{"Reply-To:", NULL, TRUE},
- {"Cc:", NULL, FALSE},
- {"References:", NULL, FALSE},
- {"Bcc:", NULL, FALSE},
- {"Newsgroups:", NULL, FALSE},
- {"Followup-To:", NULL, FALSE},
- {"X-Mailing-List:", NULL, FALSE},
- {"X-BeenThere:", NULL, FALSE},
- {"X-Priority:", NULL, FALSE},
- {NULL, NULL, FALSE}};
+ static HeaderEntry hentry[] = {{"Reply-To:", NULL, TRUE},
+ {"Cc:", NULL, FALSE},
+ {"References:", NULL, FALSE},
+ {"Bcc:", NULL, FALSE},
+ {"Newsgroups:", NULL, FALSE},
+ {"Followup-To:", NULL, FALSE},
+ {"List-Post:", NULL, FALSE},
+ {"X-Priority:", NULL, FALSE},
+ {NULL, NULL, FALSE}};
enum
{
- H_REPLY_TO = 0,
- H_CC = 1,
- H_REFERENCES = 2,
- H_BCC = 3,
- H_NEWSGROUPS = 4,
- H_FOLLOWUP_TO = 5,
- H_X_MAILING_LIST = 6,
- H_X_BEENTHERE = 7,
- H_X_PRIORITY = 8
+ H_REPLY_TO = 0,
+ H_CC = 1,
+ H_REFERENCES = 2,
+ H_BCC = 3,
+ H_NEWSGROUPS = 4,
+ H_FOLLOWUP_TO = 5,
+ H_LIST_POST = 6,
+ H_X_PRIORITY = 7
};
FILE *fp;
compose->cc = hentry[H_CC].body;
hentry[H_CC].body = NULL;
}
- if (hentry[H_X_MAILING_LIST].body != NULL) {
- /* this is good enough to parse debian-devel */
- gchar *buf = g_malloc(strlen(hentry[H_X_MAILING_LIST].body) + 1);
- g_return_val_if_fail(buf != NULL, -1 );
- if (1 == sscanf(hentry[H_X_MAILING_LIST].body, "<%[^>]>", buf))
- compose->mailinglist = g_strdup(buf);
- g_free(buf);
- g_free(hentry[H_X_MAILING_LIST].body);
- hentry[H_X_MAILING_LIST].body = NULL ;
- }
- if (hentry[H_X_BEENTHERE].body != NULL) {
- /* this is good enough to parse the sylpheed-claws lists */
- gchar *buf = g_malloc(strlen(hentry[H_X_BEENTHERE].body) + 1);
- g_return_val_if_fail(buf != NULL, -1 );
- if (1 == sscanf(hentry[H_X_BEENTHERE].body, "%[^>]", buf))
- compose->mailinglist = g_strdup(buf);
- g_free(buf);
- g_free(hentry[H_X_BEENTHERE].body);
- hentry[H_X_BEENTHERE].body = NULL ;
- }
if (hentry[H_REFERENCES].body != NULL) {
if (compose->mode == COMPOSE_REEDIT)
compose->references = hentry[H_REFERENCES].body;
compose->followup_to = hentry[H_FOLLOWUP_TO].body;
hentry[H_FOLLOWUP_TO].body = NULL;
}
+ if (hentry[H_LIST_POST].body != NULL) {
+ gchar *to = NULL;
+
+ extract_address(hentry[H_LIST_POST].body);
+ if (hentry[H_LIST_POST].body[0] != '\0') {
+ scan_mailto_url(hentry[H_LIST_POST].body,
+ &to, NULL, NULL, NULL, NULL);
+ if (to) {
+ g_free(compose->ml_post);
+ compose->ml_post = to;
+ }
+ }
+ g_free(hentry[H_LIST_POST].body);
+ hentry[H_LIST_POST].body = NULL;
+ }
if (compose->mode == COMPOSE_REEDIT)
if (hentry[H_X_PRIORITY].body != NULL) {
}
static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo,
- gboolean to_all, gboolean ignore_replyto,
+ gboolean to_all, gboolean to_ml,
+ gboolean ignore_replyto,
gboolean followup_and_reply_to)
{
GSList *cc_list = NULL;
g_return_if_fail(compose->account != NULL);
g_return_if_fail(msginfo != NULL);
- if ((compose->account->protocol != A_NNTP) || followup_and_reply_to)
- compose_entry_append(compose,
- ((compose->replyto && !ignore_replyto)
+ if (to_ml && compose->ml_post) {
+ compose_entry_append(compose, compose->ml_post,
+ COMPOSE_TO);
+ } else if ((compose->account->protocol != A_NNTP) || followup_and_reply_to) {
+ if (!(to_all || ignore_replyto)
+ && msginfo->folder
+ && msginfo->folder->prefs->enable_default_reply_to) {
+ compose_entry_append(compose,
+ msginfo->folder->prefs->default_reply_to,
+ COMPOSE_TO);
+ } else
+ compose_entry_append(compose,
+ ((compose->replyto && !ignore_replyto)
? compose->replyto
- : (compose->mailinglist && !ignore_replyto)
- ? compose->mailinglist
: msginfo->from ? msginfo->from : ""),
COMPOSE_TO);
-
- if (compose->account->protocol == A_NNTP) {
+ } else {
if (ignore_replyto)
compose_entry_append
(compose, msginfo->from ? msginfo->from : "",
(compose,
((compose->replyto && !ignore_replyto)
? compose->replyto
- : (compose->mailinglist && !ignore_replyto)
- ? compose->mailinglist
: msginfo->from ? msginfo->from : ""),
COMPOSE_TO);
} else {
} else
gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), "Re: ");
+ if (to_ml && compose->ml_post) return;
if (!to_all || compose->account->protocol == A_NNTP) return;
if (compose->replyto) {
extract_address(from);
}
- if (compose->mailinglist && from) {
- cc_list = address_list_append(cc_list, from);
- }
-
if (replyto && from)
cc_list = address_list_append(cc_list, from);
-
- if (!compose->mailinglist)
- cc_list = address_list_append(cc_list, msginfo->to);
-
+ cc_list = address_list_append(cc_list, msginfo->to);
cc_list = address_list_append(cc_list, compose->cc);
to_table = g_hash_table_new(g_str_hash, g_str_equal);
gtk_widget_show(compose->newsgroups_hbox);
gtk_widget_show(compose->newsgroups_entry);
gtk_table_set_row_spacing(GTK_TABLE(compose->table), 2, 4);
+ compose->use_newsgroups = TRUE;
menuitem = gtk_item_factory_get_item(ifactory, "/View/To");
gtk_check_menu_item_set_active
gtk_widget_hide(compose->newsgroups_entry);
gtk_table_set_row_spacing(GTK_TABLE(compose->table), 2, 0);
gtk_widget_queue_resize(compose->table_vbox);
+ compose->use_newsgroups = FALSE;
menuitem = gtk_item_factory_get_item(ifactory, "/View/To");
gtk_check_menu_item_set_active
if (lock) return 1;
g_return_val_if_fail(compose->account != NULL, -1);
- g_return_val_if_fail(compose->orig_account != NULL, -1);
lock = TRUE;
#if 0 /* NEW COMPOSE GUI */
if (compose->account->protocol != A_NNTP)
ac = compose->account;
- else if (compose->orig_account->protocol != A_NNTP)
- ac = compose->orig_account;
- else if (cur_account && cur_account->protocol != A_NNTP)
- ac = cur_account;
else {
- ac = compose_current_mail_account();
+ ac = account_find_from_address(compose->account->address);
if (!ac) {
+ if (cur_account && cur_account->protocol != A_NNTP)
+ ac = cur_account;
+ else
+ ac = account_get_default();
+ }
+ if (!ac || ac->protocol == A_NNTP) {
+ alertpanel_error(_("Account for sending mail is not specified.\n"
+ "Please select a mail account before sending."));
unlink(tmp);
lock = FALSE;
return -1;
}
if (ok == 0 && compose->newsgroup_list) {
- Folder *folder;
-
- if (compose->account->protocol == A_NNTP)
- folder = FOLDER(compose->account->folder);
- else
- folder = FOLDER(compose->orig_account->folder);
-
- ok = news_post(folder, tmp);
+ ok = news_post(FOLDER(compose->account->folder), tmp);
if (ok < 0) {
alertpanel_error(_("Error occurred while posting the message to %s ."),
compose->account->nntp_server);
}
g_free(chars);
+ /* Canonicalize line endings in the message text */
+ {
+ gchar *canon_buf, *out;
+ const gchar *p;
+ guint new_len = 0;
+
+ for (p = buf ; *p; ++p) {
+ if (*p != '\r') {
+ ++new_len;
+ if (*p == '\n')
+ ++new_len;
+ }
+ }
+
+ out = canon_buf = g_new(gchar, new_len + 1);
+ for (p = buf; *p; ++p) {
+ if (*p != '\r') {
+ if (*p == '\n')
+ *out++ = '\r';
+ *out++ = *p;
+ }
+ }
+ *out = '\0';
+
+ free(buf);
+ buf = canon_buf;
+ }
+
#if USE_GPGME
if (!is_draft && compose->use_signing && compose->account->clearsign) {
if (compose_clearsign_text(compose, &buf) < 0) {
debug_print("queueing message...\n");
g_return_val_if_fail(compose->account != NULL, -1);
- g_return_val_if_fail(compose->orig_account != NULL, -1);
lock = TRUE;
if (compose->to_list) {
if (compose->account->protocol != A_NNTP)
mailac = compose->account;
- else if (compose->orig_account->protocol != A_NNTP)
- mailac = compose->orig_account;
else if (cur_account && cur_account->protocol != A_NNTP)
mailac = cur_account;
else if (!(mailac = compose_current_mail_account())) {
if (compose->newsgroup_list) {
if (compose->account->protocol == A_NNTP)
newsac = compose->account;
- else if (!(newsac = compose->orig_account) || (newsac->protocol != A_NNTP)) {
+ else if (!newsac->protocol != A_NNTP) {
lock = FALSE;
alertpanel_error(_("No account for posting news available!"));
return -1;
fprintf(fp, "NSV:\n");
fprintf(fp, "SSH:\n");
/* write recepient list */
- fprintf(fp, "R:");
if (compose->to_list) {
- fprintf(fp, "<%s>", (gchar *)compose->to_list->data);
- for (cur = compose->to_list->next; cur != NULL; cur = cur->next)
+ fprintf(fp, "R:<%s>", (gchar *)compose->to_list->data);
+ for (cur = compose->to_list->next; cur != NULL;
+ cur = cur->next)
fprintf(fp, ",<%s>", (gchar *)cur->data);
+ fprintf(fp, "\n");
}
- fprintf(fp, "\n");
/* write newsgroup list */
- fprintf(fp, "NG:");
if (compose->newsgroup_list) {
+ fprintf(fp, "NG:");
fprintf(fp, "%s", (gchar *)compose->newsgroup_list->data);
for (cur = compose->newsgroup_list->next; cur != NULL; cur = cur->next)
fprintf(fp, ",%s", (gchar *)cur->data);
+ fprintf(fp, "\n");
}
- fprintf(fp, "\n");
/* Sylpheed account IDs */
if (mailac) {
fprintf(fp, "MAID:%d\n", mailac->account_id);
fputc('\n', fp);
}
break;
+ default:
+ debug_print("Tried to write attachment in unsupported encoding type\n");
+ break;
}
fclose(attach_fp);
/* Newsgroups */
compose_write_headers_from_headerlist(compose, fp, "Newsgroups");
#if 0 /* NEW COMPOSE GUI */
- str = gtk_entry_get_text(GTK_ENTRY(compose->newsgroups_entry));
- if (*str != '\0') {
- Xstrdup_a(str, str, return -1);
- g_strstrip(str);
- remove_space(str);
+ if (compose->use_newsgroups) {
+ str = gtk_entry_get_text(GTK_ENTRY(compose->newsgroups_entry));
if (*str != '\0') {
- compose->newsgroup_list =
- newsgroup_list_append(compose->newsgroup_list,
- str);
- compose_convert_header(buf, sizeof(buf), str,
- strlen("Newsgroups: "));
- fprintf(fp, "Newsgroups: %s\n", buf);
+ Xstrdup_a(str, str, return -1);
+ g_strstrip(str);
+ remove_space(str);
+ if (*str != '\0') {
+ compose->newsgroup_list =
+ newsgroup_list_append
+ (compose->newsgroup_list, str);
+ compose_convert_header(buf, sizeof(buf), str,
+ strlen("Newsgroups: "));
+ fprintf(fp, "Newsgroups: %s\n", buf);
+ }
}
}
#endif
titles[COL_NAME] = _("Name");
compose->account = account;
- compose->orig_account = account;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
compose->replyinfo = NULL;
compose->replyto = NULL;
- compose->mailinglist = NULL;
compose->cc = NULL;
compose->bcc = NULL;
compose->followup_to = NULL;
+
+ compose->ml_post = NULL;
+
compose->inreplyto = NULL;
compose->references = NULL;
compose->msgid = NULL;
gtk_widget_show_all(toolbar);
}
+static void compose_toolbar_set_sensitive (Compose * compose, gboolean sensitive)
+{
+ GSList *items = compose->toolbar->t_action_list;
+ if (compose->toolbar->send_btn)
+ gtk_widget_set_sensitive(compose->toolbar->send_btn, sensitive);
+ if (compose->toolbar->sendl_btn)
+ gtk_widget_set_sensitive(compose->toolbar->sendl_btn, sensitive);
+ if (compose->toolbar->draft_btn )
+ gtk_widget_set_sensitive(compose->toolbar->draft_btn , sensitive);
+ if (compose->toolbar->insert_btn )
+ gtk_widget_set_sensitive(compose->toolbar->insert_btn , sensitive);
+ if (compose->toolbar->attach_btn)
+ gtk_widget_set_sensitive(compose->toolbar->attach_btn, sensitive);
+ if (compose->toolbar->sig_btn)
+ gtk_widget_set_sensitive(compose->toolbar->sig_btn, sensitive);
+ if (compose->toolbar->exteditor_btn)
+ gtk_widget_set_sensitive(compose->toolbar->exteditor_btn, sensitive);
+ if (compose->toolbar->linewrap_btn)
+ gtk_widget_set_sensitive(compose->toolbar->linewrap_btn, sensitive);
+ if (compose->toolbar->addrbook_btn)
+ gtk_widget_set_sensitive(compose->toolbar->addrbook_btn, sensitive);
+ for (; items != NULL; items = g_slist_next(items)) {
+ ToolbarSylpheedActions *item = (ToolbarSylpheedActions *)items->data;
+ gtk_widget_set_sensitive(item->widget, sensitive);
+ }
+}
+
static GtkWidget *compose_account_option_menu_create(Compose *compose)
{
GList *accounts;
g_free(compose->newsgroups);
g_free(compose->followup_to);
+ g_free(compose->ml_post);
+
g_free(compose->inreplyto);
g_free(compose->references);
g_free(compose->msgid);
}
}
+static void compose_allow_user_actions (Compose *compose, gboolean allow)
+{
+ GtkItemFactory *ifactory = gtk_item_factory_from_widget(compose->menubar);
+ compose_toolbar_set_sensitive(compose, allow);
+ menu_set_sensitive(ifactory, "/File", allow);
+ menu_set_sensitive(ifactory, "/Edit", allow);
+ menu_set_sensitive(ifactory, "/Message", allow);
+ menu_set_sensitive(ifactory, "/Tools", allow);
+ menu_set_sensitive(ifactory, "/Help", allow);
+}
+
static void compose_send_cb(gpointer data, guint action, GtkWidget *widget)
{
Compose *compose = (Compose *)data;
if (alertpanel(_("Offline warning"),
_("You're working offline. Override?"),
_("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
- return;
-
+ return;
+
+ compose_allow_user_actions (compose, FALSE);
+ compose->sending = TRUE;
val = compose_send(compose);
+ compose_allow_user_actions (compose, TRUE);
+ compose->sending = FALSE;
if (val == 0) gtk_widget_destroy(compose->window);
}
static gint compose_delete_cb(GtkWidget *widget, GdkEventAny *event,
gpointer data)
{
- compose_close_cb(data, 0, NULL);
+ Compose *compose = (Compose *)data;
+ if (compose->sending)
+ return TRUE;
+ compose_close_cb(compose, 0, NULL);
return TRUE;
}
static void compose_destroy_cb(GtkWidget *widget, Compose *compose)
{
+ if (compose->sending)
+ return;
compose_destroy(compose);
}