static void compose_toggle_encrypt_cb (gpointer data,
guint action,
GtkWidget *widget);
+static void compose_set_gnupg_mode_cb (gpointer data,
+ guint action,
+ GtkWidget *widget);
+static void compose_update_gnupg_mode_menu_item(Compose * compose);
+static void activate_gnupg_mode (Compose *compose,
+ PrefsAccount *account);
#endif
static void compose_toggle_return_receipt_cb(gpointer data, guint action,
GtkWidget *widget);
{N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Message/Si_gn"), NULL, compose_toggle_sign_cb , 0, "<ToggleItem>"},
{N_("/_Message/_Encrypt"), NULL, compose_toggle_encrypt_cb, 0, "<ToggleItem>"},
+ {N_("/_Message/Mode/MIME"), NULL, compose_set_gnupg_mode_cb, GNUPG_MODE_DETACH, "<RadioItem>"},
+ {N_("/_Message/Mode/Inline"), NULL, compose_set_gnupg_mode_cb, GNUPG_MODE_INLINE, "/Message/Mode/MIME"},
#endif /* USE_GPGME */
{N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Message/_Priority"), NULL, NULL, 0, "<Branch>"},
return compose;
}
-#define CHANGE_FLAGS(msginfo) \
-{ \
-if (msginfo->folder->folder->change_flags != NULL) \
-msginfo->folder->folder->change_flags(msginfo->folder->folder, \
- msginfo->folder, \
- msginfo); \
-}
-
/*
Compose *compose_new_followup_and_replyto(PrefsAccount *account,
const gchar *followupto, gchar * to)
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;
else
qmark = "> ";
- quote_str = compose_quote_fmt(compose, msginfo,
+ quote_str = compose_quote_fmt(compose, compose->replyinfo,
prefs_common.quotefmt,
qmark, body);
}
gboolean as_attach, const gchar *body)
{
Compose *compose;
- /* PrefsAccount *account; */
GtkSText *text;
g_return_val_if_fail(msginfo != NULL, NULL);
g_return_val_if_fail(msginfo->folder != NULL, NULL);
- account = msginfo->folder->folder->account;
+ if (!account)
+ account = msginfo->folder->folder->account;
if (!account && msginfo->to && prefs_common.forward_account_autosel) {
gchar *to;
Xstrdup_a(to, msginfo->to, return NULL);
MSG_SET_PERM_FLAGS(msginfo->flags, MSG_FORWARDED);
if (MSG_IS_IMAP(msginfo->flags))
imap_msg_unset_perm_flags(msginfo, MSG_REPLIED);
- CHANGE_FLAGS(msginfo);
compose = compose_create(account, COMPOSE_FORWARD);
} 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)
for (msginfo = msginfo_list; msginfo != NULL; msginfo = msginfo->next) {
MSG_UNSET_PERM_FLAGS(((MsgInfo *)msginfo->data)->flags, MSG_REPLIED);
MSG_SET_PERM_FLAGS(((MsgInfo *)msginfo->data)->flags, MSG_FORWARDED);
- CHANGE_FLAGS(((MsgInfo *)msginfo->data));
}
compose = compose_create(account, COMPOSE_FORWARD);
g_return_if_fail(msginfo != NULL);
g_return_if_fail(msginfo->folder != NULL);
- if (msginfo->folder->stype == F_QUEUE) {
+ if (msginfo->folder->stype == F_QUEUE || msginfo->folder->stype == F_DRAFT) {
gchar queueheader_buf[BUFFSIZE];
gint id;
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);
#if USE_GPGME
menu_set_sensitive(ifactory, "/Message/Sign", FALSE);
menu_set_sensitive(ifactory, "/Message/Encrypt", FALSE);
+ menu_set_sensitive(ifactory, "/Message/Mode/MIME", FALSE);
+ menu_set_sensitive(ifactory, "/Message/Mode/Inline", FALSE);
#endif
menu_set_sensitive(ifactory, "/Message/Request Return Receipt", FALSE);
menu_set_sensitive(ifactory, "/Tools/Template", FALSE);
hentry[H_LIST_POST].body = NULL;
}
+ /* CLAWS - X-Priority */
if (compose->mode == COMPOSE_REEDIT)
if (hentry[H_X_PRIORITY].body != NULL) {
gint priority;
g_return_if_fail(compose->account != NULL);
g_return_if_fail(msginfo != NULL);
- 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) {
- compose_entry_append(compose,
- ((compose->replyto && !ignore_replyto)
- ? compose->replyto
- : msginfo->from ? msginfo->from : ""),
- COMPOSE_TO);
+ if (compose->account->protocol != A_NNTP || followup_and_reply_to) {
+ if (!compose->replyto && to_ml && compose->ml_post)
+ compose_entry_append(compose,
+ compose->ml_post,
+ COMPOSE_TO);
+ else 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
+ : msginfo->from ? msginfo->from : "",
+ COMPOSE_TO);
} else {
if (ignore_replyto)
compose_entry_append
(compose, msginfo->from ? msginfo->from : "",
COMPOSE_TO);
else {
- if (compose->followup_to && !strncmp(compose->followup_to,"poster",6)) {
+ if (compose->followup_to && !strncmp(compose->followup_to, "poster", 6)) {
compose_entry_append
(compose,
((compose->replyto && !ignore_replyto)
SET_ADDRESS(COMPOSE_REPLYTO, compose->replyto);
compose_update_priority_menu_item(compose);
-
+#if USE_GPGME
+ compose_update_gnupg_mode_menu_item(compose);
+#endif
compose_show_first_last_header(compose, TRUE);
#if 0 /* NEW COMPOSE GUI */
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
menuitem = gtk_item_factory_get_item(ifactory, "/Message/Encrypt");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
account->default_encrypt);
+
+ activate_gnupg_mode(compose, account);
#endif /* USE_GPGME */
}
g_free(msgpath);
folder_item_remove_msg(folder, msgnum);
- folderview_update_item(folder, TRUE);
+ folder_update_item(folder, TRUE);
return val;
}
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);
if (compose->mode == COMPOSE_REEDIT) {
compose_remove_reedit_target(compose);
if (compose->targetinfo)
- folderview_update_item
+ folder_update_item
(compose->targetinfo->folder, TRUE);
}
/* save message to outbox */
alertpanel_error
(_("Can't save the message to Sent."));
else
- folderview_update_item(outbox, TRUE);
+ folder_update_item(outbox, TRUE);
}
}
#if USE_GPGME
if (!is_draft &&
- compose->use_signing && !compose->account->clearsign &&
+ compose->use_signing && !compose->gnupg_mode &&
encoding == ENC_8BIT)
encoding = ENC_BASE64;
#endif
}
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 (!is_draft && compose->use_signing && compose->gnupg_mode) {
if (compose_clearsign_text(compose, &buf) < 0) {
g_warning("clearsign failed\n");
fclose(fp);
if (is_draft)
return 0;
- if ((compose->use_signing && !compose->account->clearsign) ||
+ if ((compose->use_signing && !compose->gnupg_mode) ||
compose->use_encryption) {
if (canonicalize_file_replace(file) < 0) {
unlink(file);
}
}
- if (compose->use_signing && !compose->account->clearsign) {
+ if (compose->use_signing && !compose->gnupg_mode) {
GSList *key_list;
if (compose_create_signers_list(compose, &key_list) < 0 ||
}
if (compose->use_encryption) {
if (rfc2015_encrypt(file, compose->to_list,
- compose->account->ascii_armored) < 0) {
+ compose->gnupg_mode) < 0) {
unlink(file);
return -1;
}
if (procmsg_msg_exist(msginfo)) {
folder_item_remove_msg(drafts, msginfo->msgnum);
- folderview_update_item(drafts, TRUE);
+ folder_update_item(drafts, TRUE);
}
}
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);
compose_remove_reedit_target(compose);
if (compose->targetinfo &&
compose->targetinfo->folder != queue)
- folderview_update_item
+ folder_update_item
(compose->targetinfo->folder, TRUE);
}
- folderview_update_item(queue, TRUE);
+ folder_update_item(queue, TRUE);
if ((msgnum != NULL) && (item != NULL)) {
*msgnum = num;
g_return_val_if_fail(compose->account != NULL, -1);
g_return_val_if_fail(compose->account->address != NULL, -1);
- /* Save copy folder */
+ /* Save draft infos */
if (is_draft) {
+ fprintf(fp, "S:%s\n", compose->account->address);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(compose->savemsg_checkbtn))) {
gchar *savefolderid;
savefolderid = gtk_editable_get_chars(GTK_EDITABLE(compose->savemsg_entry), 0, -1);
- fprintf(fp, "SCF:%s\n\n", savefolderid);
+ fprintf(fp, "SCF:%s\n", savefolderid);
g_free(savefolderid);
- } else {
- fprintf(fp, " \n\n");
}
+ fprintf(fp, "\n");
}
/* Date */
/* 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
/* drag and drop */
gtk_drag_dest_set(attach_clist,
GTK_DEST_DEFAULT_ALL, compose_mime_types, 1,
- GDK_ACTION_COPY);
+ GDK_ACTION_COPY | GDK_ACTION_MOVE);
gtk_signal_connect(GTK_OBJECT(attach_clist), "drag_data_received",
GTK_SIGNAL_FUNC(compose_attach_drag_received_cb),
compose);
GdkColormap *cmap;
GdkColor color[1];
gboolean success[1];
- GdkFont *font;
GtkWidget *popupmenu;
GtkItemFactory *popupfactory;
GtkItemFactory *ifactory;
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);
/* drag and drop */
gtk_drag_dest_set(text, GTK_DEST_DEFAULT_ALL, compose_mime_types, 1,
- GDK_ACTION_COPY);
+ GDK_ACTION_COPY | GDK_ACTION_MOVE);
gtk_signal_connect(GTK_OBJECT(text), "drag_data_received",
GTK_SIGNAL_FUNC(compose_insert_drag_received_cb),
compose);
new_style = gtk_style_copy(style);
if (prefs_common.textfont) {
- if (MB_CUR_MAX == 1) {
- gchar *fontstr, *p;
+ GdkFont *font;
- Xstrdup_a(fontstr, prefs_common.textfont, );
- if (fontstr && (p = strchr(fontstr, ',')) != NULL)
- *p = '\0';
- font = gdk_font_load(fontstr);
- } else
- font = gdk_fontset_load(prefs_common.textfont);
- if (font) {
+ if ((font = gtkut_font_load(prefs_common.textfont)) != NULL) {
gdk_font_unref(new_style->font);
new_style->font = font;
}
#if USE_ASPELL
menu_set_sensitive(ifactory, "/Spelling", FALSE);
- if (prefs_common.enable_aspell) {
+ if (prefs_common.enable_aspell &&
+ strcmp(prefs_common.dictionary, _("None"))) {
gtkaspell = gtkaspell_new((const gchar*)prefs_common.dictionary,
conv_get_current_charset_str(),
prefs_common.misspelled_col,
/* Priority */
compose->priority = PRIORITY_NORMAL;
compose_update_priority_menu_item(compose);
+
+#if USE_GPGME
+ activate_gnupg_mode(compose, account);
+#endif
set_toolbar_style(compose);
}
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
}
+
+#if USE_GPGME
+static void compose_set_gnupg_mode_cb(gpointer data,
+ guint action,
+ GtkWidget *widget)
+{
+ Compose *compose = (Compose *) data;
+ compose->gnupg_mode = action;
+}
+
+static void compose_update_gnupg_mode_menu_item(Compose * compose)
+{
+ GtkItemFactory *ifactory;
+ GtkWidget *menuitem = NULL;
+
+ ifactory = gtk_item_factory_from_widget(compose->menubar);
+
+ switch (compose->gnupg_mode) {
+ case GNUPG_MODE_DETACH:
+ menuitem = gtk_item_factory_get_item
+ (ifactory, "/Message/Mode/MIME");
+ break;
+ case GNUPG_MODE_INLINE:
+ menuitem = gtk_item_factory_get_item
+ (ifactory, "/Message/Mode/Inline");
+ break;
+ }
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
+
+ if (compose->use_encryption == TRUE || compose->use_signing == TRUE)
+ menu_set_sensitive(ifactory, "/Message/Mode", TRUE);
+ else
+ menu_set_sensitive(ifactory, "/Message/Mode", FALSE);
+}
+#endif
static void compose_set_template_menu(Compose *compose)
{
tmpl->subject);
if (tmpl->to && *tmpl->to != '\0')
compose_entry_append(compose, tmpl->to, COMPOSE_TO);
+ if (tmpl->cc && *tmpl->cc != '\0')
+ compose_entry_append(compose, tmpl->cc, COMPOSE_CC);
+
+ if (tmpl->bcc && *tmpl->bcc != '\0')
+ compose_entry_append(compose, tmpl->bcc, COMPOSE_BCC);
if (replace)
gtk_stext_clear(GTK_STEXT(compose->text));
if (!val) gtk_widget_destroy(compose->window);
}
+void compose_draft (gpointer data)
+{
+ compose_draft_cb(data, 0, NULL);
+}
+
static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget)
{
Compose *compose = (Compose *)data;
compose_remove_reedit_target(compose);
if (compose->targetinfo &&
compose->targetinfo->folder != draft)
- folderview_update_item(compose->targetinfo->folder,
+ folder_update_item(compose->targetinfo->folder,
TRUE);
}
newmsginfo = folder_item_fetch_msginfo(draft, msgnum);
procmsg_msginfo_unset_flags(newmsginfo, ~0, ~0);
MSG_SET_TMP_FLAGS(newmsginfo->flags, MSG_DRAFT);
- folderview_update_item(draft, TRUE);
+ folder_update_item(draft, TRUE);
procmsg_msginfo_free(newmsginfo);
lock = FALSE;
compose->use_signing = TRUE;
else
compose->use_signing = FALSE;
+
+ compose_update_gnupg_mode_menu_item(compose);
}
static void compose_toggle_encrypt_cb(gpointer data, guint action,
compose->use_encryption = TRUE;
else
compose->use_encryption = FALSE;
+
+ compose_update_gnupg_mode_menu_item(compose);
+}
+
+static void activate_gnupg_mode (Compose *compose, PrefsAccount *account)
+{
+ if (account->default_gnupg_mode)
+ compose->gnupg_mode = GNUPG_MODE_INLINE;
+ else
+ compose->gnupg_mode = GNUPG_MODE_DETACH;
+
+ compose_update_gnupg_mode_menu_item(compose);
}
#endif /* USE_GPGME */
compose_send_control_enter(compose);
}
-#define EDITABLE_LENGTH(x) \
- strlen(gtk_editable_get_chars(x,0,-1))
-
static void text_inserted(GtkWidget *widget, const gchar *text,
gint length, gint *position, Compose *compose)
{
if (prefs_common.autosave &&
- EDITABLE_LENGTH(editable) % prefs_common.autosave_length == 0)
+ gtk_stext_get_length(GTK_STEXT(widget)) % prefs_common.autosave_length == 0)
compose_draft_cb((gpointer)compose, 1, NULL);
}