#include "alertpanel.h"
#include "manage_window.h"
#include "folder.h"
+#include "folder_item_prefs.h"
#include "addr_compl.h"
#include "quote_fmt.h"
#include "undo.h"
#define MAX_REFERENCES_LEN 999
static GList *compose_list = NULL;
+static GSList *extra_headers = NULL;
static Compose *compose_generic_new (PrefsAccount *account,
const gchar *to,
GdkColormap *cmap;
gboolean success[8];
int i;
-#endif
GdkColor color[8];
+#endif
buffer = gtk_text_view_get_buffer(text);
compose->no_wrap_tag = gtk_text_buffer_create_tag(buffer, "no_wrap", NULL);
compose->no_join_tag = gtk_text_buffer_create_tag(buffer, "no_join", NULL);
+#if !GTK_CHECK_VERSION(2, 24, 0)
color[0] = quote_color1;
color[1] = quote_color2;
color[2] = quote_color3;
color[5] = quote_bgcolor3;
color[6] = signature_color;
color[7] = uri_color;
-#if !GTK_CHECK_VERSION(2, 24, 0)
+
cmap = gdk_drawable_get_colormap(gtk_widget_get_window(compose->window));
gdk_colormap_alloc_colors(cmap, color, 8, FALSE, TRUE, success);
for (i = 0; i < 8; i++) {
if (success[i] == FALSE) {
- GtkStyle *style;
-
g_warning("Compose: color allocation failed.\n");
- style = gtk_widget_get_style(GTK_WIDGET(text));
quote_color1 = quote_color2 = quote_color3 =
quote_bgcolor1 = quote_bgcolor2 = quote_bgcolor3 =
signature_color = uri_color = black;
const gchar *body_fmt = NULL;
MsgInfo *full_msginfo;
- if (prefs_common.fw_quotefmt && *prefs_common.fw_quotefmt)
- body_fmt = gettext(prefs_common.fw_quotefmt);
- else
- body_fmt = "";
-
full_msginfo = procmsg_msginfo_get_full_info(msginfo);
if (!full_msginfo)
full_msginfo = procmsg_msginfo_copy(msginfo);
}
if (fp != NULL) {
- gboolean prev_autowrap = compose->autowrap;
- GtkTextBuffer *buffer = textbuf;
+ gboolean prev_autowrap;
+ GtkTextBuffer *buffer;
BLOCK_WRAP();
while (fgets(buf, sizeof(buf), fp) != NULL) {
strcrchomp(buf);
gchar *tmp = g_strdup(begin);
gchar *o_tmp = tmp;
tmp[cur-begin]='\0';
- cur++;
- begin = cur;
while (*tmp == ' ' || *tmp == '\t')
tmp++;
compose_add_header_entry(compose, header, tmp, pref_type);
FILE *fp;
GSList *cur;
gint num;
- static gboolean lock = FALSE;
PrefsAccount *mailac = NULL, *newsac = NULL;
gboolean err = FALSE;
debug_print("queueing message...\n");
cm_return_val_if_fail(compose->account != NULL, -1);
- lock = TRUE;
-
if (compose_check_entries(compose, check_subject) == FALSE) {
- lock = FALSE;
if (compose->batch) {
gtk_widget_show_all(compose->window);
}
if (!compose->to_list && !compose->newsgroup_list) {
g_warning("can't get recipient list.");
- lock = FALSE;
return -1;
}
else if (cur_account && cur_account->protocol != A_NNTP)
mailac = cur_account;
else if (!(mailac = compose_current_mail_account())) {
- lock = FALSE;
alertpanel_error(_("No account for sending mails available!"));
return -1;
}
if (compose->account->protocol == A_NNTP)
newsac = compose->account;
else {
- lock = FALSE;
alertpanel_error(_("Selected account isn't NNTP: Posting is impossible."));
return -1;
}
if ((fp = g_fopen(tmp, "wb")) == NULL) {
FILE_OP_ERROR(tmp, "fopen");
g_free(tmp);
- lock = FALSE;
return -2;
}
if (compose->use_encryption) {
gchar *encdata;
if (!compose_warn_encryption(compose)) {
- lock = FALSE;
fclose(fp);
claws_unlink(tmp);
g_free(tmp);
err |= (fprintf(fp, "X-Claws-Encrypt:%d\n", compose->use_encryption) < 0);
/* and if encdata was null, it means there's been a problem in
* key selection */
- lock = FALSE;
+ if (err == TRUE)
+ g_warning("failed to write queue message");
fclose(fp);
claws_unlink(tmp);
g_free(tmp);
if (compose->redirect_filename != NULL) {
if (compose_redirect_write_to_file(compose, fp) < 0) {
- lock = FALSE;
fclose(fp);
claws_unlink(tmp);
g_free(tmp);
} else {
gint result = 0;
if ((result = compose_write_to_file(compose, fp, COMPOSE_WRITE_FOR_SEND, TRUE)) < 0) {
- lock = FALSE;
fclose(fp);
claws_unlink(tmp);
g_free(tmp);
fclose(fp);
claws_unlink(tmp);
g_free(tmp);
- lock = FALSE;
return -2;
}
if (fclose(fp) == EOF) {
FILE_OP_ERROR(tmp, "fclose");
claws_unlink(tmp);
g_free(tmp);
- lock = FALSE;
return -2;
}
g_warning("can't find queue folder\n");
claws_unlink(tmp);
g_free(tmp);
- lock = FALSE;
return -1;
}
folder_item_scan(queue);
g_warning("can't queue the message\n");
claws_unlink(tmp);
g_free(tmp);
- lock = FALSE;
return -1;
}
!g_ascii_strcasecmp(mimepart->subtype, "rfc822")) {
mimepart->disposition = DISPOSITIONTYPE_INLINE;
} else if (mimepart->type == MIMETYPE_TEXT) {
- if (!ainfo->name && compose->mode == COMPOSE_FORWARD_INLINE) {
+ if (!ainfo->name && g_ascii_strcasecmp(mimepart->subtype, "plain")) {
/* Text parts with no name come from multipart/alternative
* forwards. Make sure the recipient won't look at the
* original HTML part by mistake. */
gtk_widget_show(menuitem);
}
+void compose_add_extra_header(gchar *header, GtkListStore *model)
+{
+ GtkTreeIter iter;
+ if (strcmp(header, "")) {
+ COMBOBOX_ADD(model, header, COMPOSE_TO);
+ }
+}
+
+void compose_add_extra_header_entries(GtkListStore *model)
+{
+ FILE *exh;
+ gchar *exhrc;
+ gchar buf[BUFFSIZE];
+ gint lastc;
+
+ if (extra_headers == NULL) {
+ exhrc = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "extraheaderrc", NULL);
+ if ((exh = g_fopen(exhrc, "rb")) == NULL) {
+ debug_print("extra headers file not found\n");
+ goto extra_headers_done;
+ }
+ while (fgets(buf, BUFFSIZE, exh) != NULL) {
+ lastc = strlen(buf) - 1; /* remove trailing \n */
+ buf[lastc] = (buf[lastc] == '\n')? '\0': buf[lastc];
+ --lastc;
+ if (lastc > 0 && buf[0] != '#' && buf[lastc] == ':') {
+ buf[lastc] = '\0'; /* remove trailing : for comparison */
+ if (custom_header_is_allowed(buf)) {
+ buf[lastc] = ':';
+ extra_headers = g_slist_prepend(extra_headers, g_strdup(buf));
+ }
+ else
+ g_message("disallowed extra header line: %s\n", buf);
+ }
+ else {
+ if (buf[0] != '#')
+ g_message("invalid extra header line: %s\n", buf);
+ }
+ }
+ fclose(exh);
+extra_headers_done:
+ g_free(exhrc);
+ extra_headers = g_slist_prepend(extra_headers, g_strdup("")); /* end of list */
+ extra_headers = g_slist_reverse(extra_headers);
+ }
+ g_slist_foreach(extra_headers, (GFunc)compose_add_extra_header, (gpointer)model);
+}
+
static void compose_create_header_entry(Compose *compose)
{
gchar *headers[] = {"To:", "Cc:", "Bcc:", "Newsgroups:", "Reply-To:", "Followup-To:", NULL};
COMPOSE_REPLYTO);
COMBOBOX_ADD(model, prefs_common_translated_header_name("Followup-To:"),
COMPOSE_FOLLOWUPTO);
+ compose_add_extra_header_entries(model);
gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
- g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN((combo)))), "grab_focus",
+ g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN(combo))), "grab_focus",
G_CALLBACK(compose_grab_focus_cb), compose);
gtk_widget_show(combo);
+
+ GList *l = NULL;
+ l = g_list_prepend(l, gtk_bin_get_child(GTK_BIN(combo)));
+ gtk_container_set_focus_chain(GTK_CONTAINER(combo), l);
+ g_list_free(l);
+
gtk_table_attach(GTK_TABLE(compose->header_table), combo, 0, 1,
compose->header_nextrow, compose->header_nextrow+1,
GTK_SHRINK, GTK_FILL, 0, 0);
G_CALLBACK(compose_savemsg_select_cb),
compose);
- rowcount++;
-
return table;
}
UndoMain *undostruct;
- gchar *titles[N_ATTACH_COLS];
GtkWidget *popupmenu;
GtkWidget *tmpl_menu;
GtkActionGroup *action_group = NULL;
debug_print("Creating compose window...\n");
compose = g_new0(Compose, 1);
- titles[COL_MIMETYPE] = _("MIME type");
- titles[COL_SIZE] = _("Size");
- titles[COL_NAME] = _("Name");
- titles[COL_CHARSET] = _("Charset");
-
compose->batch = batch;
compose->account = account;
compose->folder = folder;
slist_free_strings(compose->header_list);
g_slist_free(compose->header_list);
+ slist_free_strings(extra_headers);
+ extra_headers = NULL;
+
compose->header_list = compose->newsgroup_list = compose->to_list = NULL;
g_hash_table_destroy(compose->email_hashtable);
gtk_window_set_modal(GTK_WINDOW(attach_prop.window), TRUE);
gtk_widget_grab_focus(attach_prop.ok_btn);
gtk_widget_show(attach_prop.window);
- manage_window_set_transient(GTK_WINDOW(attach_prop.window));
+ gtk_window_set_transient_for(GTK_WINDOW(attach_prop.window),
+ GTK_WINDOW(compose->window));
optmenu = GTK_COMBO_BOX(attach_prop.encoding_optmenu);
if (ainfo->encoding == ENC_UNKNOWN)
attach_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
attach_nr_selected = gtk_tree_selection_count_selected_rows(attach_selection);
- if (attach_nr_selected > 0)
- {
- cm_menu_set_sensitive_full(compose->ui_manager, "Popup/Compose/Remove", TRUE);
- cm_menu_set_sensitive_full(compose->ui_manager, "Popup/Compose/Properties", TRUE);
- } else {
- cm_menu_set_sensitive_full(compose->ui_manager, "Popup/Compose/Remove", FALSE);
- cm_menu_set_sensitive_full(compose->ui_manager, "Popup/Compose/Properties", FALSE);
- }
+ cm_menu_set_sensitive_full(compose->ui_manager, "Popup/Compose/Remove", (attach_nr_selected > 0));
+ cm_menu_set_sensitive_full(compose->ui_manager, "Popup/Compose/Properties", (attach_nr_selected > 0));
gtk_menu_popup(GTK_MENU(compose->popupmenu), NULL, NULL,
NULL, NULL, event->button, event->time);
if (compose->redirect_filename != NULL)
return;
+ /* Set focus_window properly, in case we were called via popup menu,
+ * which unsets it (via focus_out_event callback on compose window). */
+ manage_window_focus_in(compose->window, NULL, NULL);
+
file_list = filesel_select_multiple_files_open(_("Select file"));
if (file_list) {
GtkTextBuffer *buffer;
GtkTextMark *mark;
GtkTextIter ins;
- gint count;
cm_return_if_fail(GTK_IS_TEXT_VIEW(text));
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
mark = gtk_text_buffer_get_insert(buffer);
gtk_text_buffer_get_iter_at_mark(buffer, &ins, mark);
- count = gtk_text_iter_inside_word (&ins) ? 2 : 1;
if (gtk_text_iter_backward_word_starts(&ins, 1))
gtk_text_buffer_place_cursor(buffer, &ins);
}