NULL, NULL, 0, "<Branch>"},
#endif
{N_("/_Options"), NULL, NULL, 0, "<Branch>"},
- {N_("/_Options/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Options/Privacy System"), NULL, NULL, 0, "<Branch>"},
{N_("/_Options/Privacy System/None"), NULL, compose_set_privacy_system_cb, 0, "<RadioItem>"},
{N_("/_Options/Si_gn"), NULL, compose_toggle_sign_cb , 0, "<ToggleItem>"},
g_signal_handlers_block_by_func(G_OBJECT(textbuf),
G_CALLBACK(compose_changed_cb),
compose);
+
+ g_signal_handlers_block_by_func(G_OBJECT(textbuf),
+ G_CALLBACK(text_inserted),
+ compose);
if ((fp = procmime_get_first_text_content(msginfo)) == NULL)
g_warning("Can't get text part\n");
while (fgets(buf, sizeof(buf), fp) != NULL) {
strcrchomp(buf);
gtk_text_buffer_insert(textbuf, &iter, buf, -1);
+ gtk_text_buffer_get_iter_at_mark(textbuf, &iter, mark);
}
fclose(fp);
}
compose_attach_parts(compose, msginfo);
+ g_signal_handlers_unblock_by_func(G_OBJECT(textbuf),
+ G_CALLBACK(text_inserted),
+ compose);
g_signal_handlers_unblock_by_func(G_OBJECT(textbuf),
G_CALLBACK(compose_changed_cb),
compose);
for (h_list = compose->header_list; h_list != NULL; h_list = h_list->next) {
entry = GTK_ENTRY(((ComposeHeaderEntry *)h_list->data)->entry);
if (gtk_entry_get_text(entry) &&
- !g_strcasecmp(gtk_entry_get_text(entry), mailto)) {
+ !g_utf8_collate(gtk_entry_get_text(entry), mailto)) {
gtk_widget_ensure_style(GTK_WIDGET(entry));
if (!bold_style) {
PangoFontDescription *font_desc = NULL;
for (cur = ref_id_list; cur != NULL; cur = cur->next) {
if (new_ref->len > 0)
g_string_append(new_ref, "\n\t");
- g_string_sprintfa(new_ref, "<%s>", (gchar *)cur->data);
+ g_string_append_printf(new_ref, "<%s>", (gchar *)cur->data);
}
slist_free_strings(ref_id_list);
FILE *fp;
off_t size;
gint row;
+ gchar *name;
if (!is_file_exist(file)) {
g_warning("File %s doesn't exist\n", file);
if (content_type) {
ainfo->content_type = g_strdup(content_type);
- if (!g_strcasecmp(content_type, "message/rfc822")) {
+ if (!g_ascii_strcasecmp(content_type, "message/rfc822")) {
MsgInfo *msginfo;
MsgFlags flags = {0, 0};
- const gchar *name;
- if (procmime_get_encoding_for_file(file) == ENC_7BIT)
+ if (procmime_get_encoding_for_text_file(file) == ENC_7BIT)
ainfo->encoding = ENC_7BIT;
else
ainfo->encoding = ENC_8BIT;
if (msginfo && msginfo->subject)
name = msginfo->subject;
else
- name = g_basename(filename ? filename : file);
+ name = g_path_get_basename(filename ? filename : file);
ainfo->name = g_strdup_printf(_("Message: %s"), name);
procmsg_msginfo_free(msginfo);
} else {
- if (!g_strncasecmp(content_type, "text", 4))
- ainfo->encoding =
- procmime_get_encoding_for_file(file);
+ if (!g_ascii_strncasecmp(content_type, "text", 4))
+ ainfo->encoding = procmime_get_encoding_for_text_file(file);
else
ainfo->encoding = ENC_BASE64;
- ainfo->name = g_strdup
- (g_basename(filename ? filename : file));
+ name = g_path_get_basename(filename ? filename : file);
+ ainfo->name = g_strdup(name);
}
+ g_free(name);
} else {
ainfo->content_type = procmime_get_mime_type(file);
if (!ainfo->content_type) {
ainfo->content_type =
g_strdup("application/octet-stream");
ainfo->encoding = ENC_BASE64;
- } else if (!g_strncasecmp(ainfo->content_type, "text", 4))
- ainfo->encoding = procmime_get_encoding_for_file(file);
+ } else if (!g_ascii_strncasecmp(ainfo->content_type, "text", 4))
+ ainfo->encoding =
+ procmime_get_encoding_for_text_file(file);
else
ainfo->encoding = ENC_BASE64;
- ainfo->name = g_strdup(g_basename(filename ? filename : file));
+ name = g_path_get_basename(filename ? filename : file);
+ ainfo->name = g_strdup(name);
+ g_free(name);
+ }
+
+ if (!strcmp(ainfo->content_type, "unknown")) {
+ g_free(ainfo->content_type);
+ ainfo->content_type = g_strdup("application/octet-stream");
}
+
ainfo->size = size;
text[COL_MIMETYPE] = ainfo->content_type;
debug_print("First text part found\n");
} else if (compose->mode == COMPOSE_REEDIT &&
child->type == MIMETYPE_APPLICATION &&
- !g_strcasecmp(child->subtype, "pgp-encrypted")) {
+ !g_ascii_strcasecmp(child->subtype, "pgp-encrypted")) {
AlertValue val;
val = alertpanel(_("Encrypted message"),
_("Cannot re-edit an encrypted message. \n"
folder_item_scan(folder);
if (prefs_common.send_dialog_mode == SEND_DIALOG_ALWAYS)
gtk_widget_destroy(compose->window);
- }
+ } else {
+ alertpanel_error(_("The message was queued but could not be "
+ "sent.\nUse \"Send queued messages\" from "
+ "the main window to retry."));
+ if (prefs_common.send_dialog_mode == SEND_DIALOG_ALWAYS) {
+ compose_allow_user_actions (compose, TRUE);
+ compose->sending = FALSE;
+ }
+ return -1;
+ }
return 0;
headerentry = ((ComposeHeaderEntry *)list->data);
headerentryname = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(headerentry->combo)->entry));
- if (g_strcasecmp(headerentryname, cc_hdr) == 0
- || g_strcasecmp(headerentryname, to_hdr) == 0) {
+ if (g_utf8_collate(headerentryname, cc_hdr) == 0
+ || g_utf8_collate(headerentryname, to_hdr) == 0) {
const gchar *entstr = gtk_entry_get_text(GTK_ENTRY(headerentry->entry));
Xstrdup_a(str, entstr, return -1);
g_strstrip(str);
compose_convert_header
(buf, sizeof(buf), str,
strlen("Resent-To") + 2, TRUE);
- if (g_strcasecmp(headerentryname, to_hdr) == 0) {
+ if (g_utf8_collate(headerentryname, to_hdr) == 0) {
if (first_to_address) {
fprintf(fp, "Resent-To: ");
first_to_address = FALSE;
fprintf(fp, ",");
}
}
- if (g_strcasecmp(headerentryname, cc_hdr) == 0) {
+ if (g_utf8_collate(headerentryname, cc_hdr) == 0) {
if (first_cc_address) {
fprintf(fp, "\n");
fprintf(fp, "Resent-Cc: ");
/* Resent-Message-ID */
if (compose->account->gen_msgid) {
- generate_msgid(compose->account->address, buf, sizeof(buf));
+ generate_msgid(buf, sizeof(buf));
fprintf(fp, "Resent-Message-ID: <%s>\n", buf);
compose->msgid = g_strdup(buf);
}
while (procheader_get_one_field_asis(buf, sizeof(buf), fp) != -1) {
/* should filter returnpath, delivered-to */
- if (g_strncasecmp(buf, "Return-Path:",
- strlen("Return-Path:")) == 0 ||
- g_strncasecmp(buf, "Delivered-To:",
- strlen("Delivered-To:")) == 0 ||
- g_strncasecmp(buf, "Received:",
- strlen("Received:")) == 0 ||
- g_strncasecmp(buf, "Subject:",
- strlen("Subject:")) == 0 ||
- g_strncasecmp(buf, "X-UIDL:",
- strlen("X-UIDL:")) == 0)
+ if (g_ascii_strncasecmp(buf, "Return-Path:",
+ strlen("Return-Path:")) == 0 ||
+ g_ascii_strncasecmp(buf, "Delivered-To:",
+ strlen("Delivered-To:")) == 0 ||
+ g_ascii_strncasecmp(buf, "Received:",
+ strlen("Received:")) == 0 ||
+ g_ascii_strncasecmp(buf, "Subject:",
+ strlen("Subject:")) == 0 ||
+ g_ascii_strncasecmp(buf, "X-UIDL:",
+ strlen("X-UIDL:")) == 0)
continue;
if (fputs(buf, fdest) == -1)
goto error;
if (!prefs_common.redirect_keep_from) {
- if (g_strncasecmp(buf, "From:",
+ if (g_ascii_strncasecmp(buf, "From:",
strlen("From:")) == 0) {
fputs(" (by way of ", fdest);
if (compose->account->name
const gchar *src_codeset;
out_codeset = conv_get_outgoing_charset_str();
- if (!g_strcasecmp(out_codeset, CS_US_ASCII))
+ if (!g_ascii_strcasecmp(out_codeset, CS_US_ASCII))
out_codeset = CS_ISO_8859_1;
if (prefs_common.encoding_method == CTE_BASE64)
src_codeset = CS_UTF_8;
/* if current encoding is US-ASCII, set it the same as
outgoing one to prevent code conversion failure */
- if (!g_strcasecmp(src_codeset, CS_US_ASCII))
+ if (!g_ascii_strcasecmp(src_codeset, CS_US_ASCII))
src_codeset = out_codeset;
debug_print("src encoding = %s, out encoding = %s, transfer encoding = %s\n",
mimetext->subtype = g_strdup("plain");
g_hash_table_insert(mimetext->typeparameters, g_strdup("charset"),
g_strdup(out_codeset));
- /* procmime_encode_content(mimetext, encoding); */
+ if (encoding != ENC_UNKNOWN)
+ procmime_encode_content(mimetext, encoding);
/* append attachment parts */
if (compose_use_attach(compose)) {
} else
g_node_append(mimemsg->node, mimetext->node);
- /* sign message */
- if (compose->use_signing && privacy_system_can_sign(compose->privacy_system))
+ /* sign message if sending */
+ if (action == COMPOSE_WRITE_FOR_SEND && compose->use_signing &&
+ privacy_system_can_sign(compose->privacy_system))
if (!privacy_sign(compose->privacy_system, mimemsg))
return -1;
gchar *encdata;
encdata = privacy_get_encrypt_data(compose->privacy_system, compose->to_list);
- fprintf(fp, "X-Sylpheed-Encrypt-Data:%s\n", encdata);
+ if (encdata != NULL)
+ fprintf(fp, "X-Sylpheed-Encrypt-Data:%s\n",
+ encdata);
g_free(encdata);
}
}
mimepart->length = statbuf.st_size;
type = g_strdup(ainfo->content_type);
+
+ if (!strchr(type, '/')) {
+ g_free(type);
+ type = g_strdup("application/octet-stream");
+ }
+
subtype = strchr(type, '/') + 1;
*(subtype - 1) = '\0';
mimepart->type = procmime_get_media_type(type);
g_free(type);
if (mimepart->type == MIMETYPE_MESSAGE &&
- !g_strcasecmp(mimepart->subtype, "rfc822")) {
+ !g_ascii_strcasecmp(mimepart->subtype, "rfc822")) {
mimepart->disposition = DISPOSITIONTYPE_INLINE;
} else {
g_hash_table_insert(mimepart->typeparameters,
headerentry = ((ComposeHeaderEntry *)list->data);
headerentryname = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(headerentry->combo)->entry));
- if (!g_strcasecmp(trans_fieldname, headerentryname)) {
+ if (!g_utf8_collate(trans_fieldname, headerentryname)) {
str = gtk_editable_get_chars(GTK_EDITABLE(headerentry->entry), 0, -1);
g_strstrip(str);
if (str[0] != '\0') {
compose_convert_header
(buf, fieldstr->len * 4 + 256, fieldstr->str,
strlen(fieldname) + 2, TRUE);
- g_string_sprintfa(header, "%s: %s\n", fieldname, buf);
+ g_string_append_printf(header, "%s: %s\n", fieldname, buf);
g_free(buf);
}
/* Date */
if (compose->account->add_date) {
get_rfc822_date(buf, sizeof(buf));
- g_string_sprintfa(header, "Date: %s\n", buf);
+ g_string_append_printf(header, "Date: %s\n", buf);
}
/* From */
(buf, sizeof(buf), compose->account->name,
strlen("From: "), TRUE);
QUOTE_IF_REQUIRED(name, buf);
- g_string_sprintfa(header, "From: %s <%s>\n",
+ g_string_append_printf(header, "From: %s <%s>\n",
name, compose->account->address);
} else
- g_string_sprintfa(header, "From: %s\n", compose->account->address);
+ g_string_append_printf(header, "From: %s\n", compose->account->address);
/* To */
compose_add_headerfield_from_headerlist(compose, header, "To", ", ");
compose_add_headerfield_from_headerlist(compose, header, "Bcc", ", ");
/* Subject */
- str = gtk_entry_get_text(GTK_ENTRY(compose->subject_entry));
+ str = gtk_editable_get_chars(GTK_EDITABLE(compose->subject_entry), 0, -1);
if (*str != '\0' && !IS_IN_CUSTOM_HEADER("Subject")) {
- gchar *tmpstr;
-
- tmpstr = g_strdup(str);
- if (tmpstr == NULL) {
- g_string_free(header, TRUE);
- return NULL;
- }
g_strstrip(str);
if (*str != '\0') {
compose_convert_header(buf, sizeof(buf), str,
strlen("Subject: "), FALSE);
- g_string_sprintfa(header, "Subject: %s\n", buf);
+ g_string_append_printf(header, "Subject: %s\n", buf);
}
- g_free(tmpstr);
}
+ g_free(str);
/* Message-ID */
if (compose->account->gen_msgid) {
- generate_msgid(compose->account->address, buf, sizeof(buf));
- g_string_sprintfa(header, "Message-ID: <%s>\n", buf);
+ generate_msgid(buf, sizeof(buf));
+ g_string_append_printf(header, "Message-ID: <%s>\n", buf);
compose->msgid = g_strdup(buf);
}
if (compose->remove_references == FALSE) {
/* In-Reply-To */
if (compose->inreplyto && compose->to_list)
- g_string_sprintfa(header, "In-Reply-To: <%s>\n", compose->inreplyto);
+ g_string_append_printf(header, "In-Reply-To: <%s>\n", compose->inreplyto);
/* References */
if (compose->references)
- g_string_sprintfa(header, "References: %s\n", compose->references);
+ g_string_append_printf(header, "References: %s\n", compose->references);
}
/* Followup-To */
compose_convert_header(buf, sizeof(buf),
compose->account->organization,
strlen("Organization: "), FALSE);
- g_string_sprintfa(header, "Organization: %s\n", buf);
+ g_string_append_printf(header, "Organization: %s\n", buf);
}
/* Program version and system info */
/* uname(&utsbuf); */
if (g_slist_length(compose->to_list) && !IS_IN_CUSTOM_HEADER("X-Mailer") &&
!compose->newsgroup_list) {
- g_string_sprintfa(header, "X-Mailer: %s (GTK+ %d.%d.%d; %s)\n",
+ g_string_append_printf(header, "X-Mailer: %s (GTK+ %d.%d.%d; %s)\n",
prog_version,
gtk_major_version, gtk_minor_version, gtk_micro_version,
TARGET_ALIAS);
/* utsbuf.sysname, utsbuf.release, utsbuf.machine); */
}
if (g_slist_length(compose->newsgroup_list) && !IS_IN_CUSTOM_HEADER("X-Newsreader")) {
- g_string_sprintfa(header, "X-Newsreader: %s (GTK+ %d.%d.%d; %s)\n",
+ g_string_append_printf(header, "X-Newsreader: %s (GTK+ %d.%d.%d; %s)\n",
prog_version,
gtk_major_version, gtk_minor_version, gtk_micro_version,
TARGET_ALIAS);
(buf, sizeof(buf),
chdr->value ? chdr->value : "",
strlen(chdr->name) + 2, FALSE);
- g_string_sprintfa(header, "%s: %s\n", chdr->name, buf);
+ g_string_append_printf(header, "%s: %s\n", chdr->name, buf);
}
}
}
/* PRIORITY */
switch (compose->priority) {
- case PRIORITY_HIGHEST: g_string_sprintfa(header, "Importance: high\n"
+ case PRIORITY_HIGHEST: g_string_append_printf(header, "Importance: high\n"
"X-Priority: 1 (Highest)\n");
break;
- case PRIORITY_HIGH: g_string_sprintfa(header, "Importance: high\n"
+ case PRIORITY_HIGH: g_string_append_printf(header, "Importance: high\n"
"X-Priority: 2 (High)\n");
break;
case PRIORITY_NORMAL: break;
- case PRIORITY_LOW: g_string_sprintfa(header, "Importance: low\n"
+ case PRIORITY_LOW: g_string_append_printf(header, "Importance: low\n"
"X-Priority: 4 (Low)\n");
break;
- case PRIORITY_LOWEST: g_string_sprintfa(header, "Importance: low\n"
+ case PRIORITY_LOWEST: g_string_append_printf(header, "Importance: low\n"
"X-Priority: 5 (Lowest)\n");
break;
default: debug_print("compose: priority unknown : %d\n",
compose->account->name,
strlen("Disposition-Notification-To: "),
TRUE);
- g_string_sprintfa(header, "Disposition-Notification-To: %s <%s>\n", buf, compose->account->address);
+ g_string_append_printf(header, "Disposition-Notification-To: %s <%s>\n", buf, compose->account->address);
} else
- g_string_sprintfa(header, "Disposition-Notification-To: %s\n", compose->account->address);
+ g_string_append_printf(header, "Disposition-Notification-To: %s\n", compose->account->address);
}
}
g_free(tmp);
entry_str = gtk_entry_get_text(GTK_ENTRY(headerentry->entry));
- Xstrdup_a(headervalue, entry_str, return -1);
+ Xstrdup_a(headervalue, entry_str, return NULL);
subst_char(headervalue, '\r', ' ');
subst_char(headervalue, '\n', ' ');
string = std_headers;
string++;
}
if (!standard_header && !IS_IN_CUSTOM_HEADER(headername))
- g_string_sprintfa(header, "%s %s\n", headername_wcolon, headervalue);
+ g_string_append_printf(header, "%s %s\n", headername_wcolon, headervalue);
g_free(headername);
g_free(headername_wcolon);
}
gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL,
&geometry, GDK_HINT_MAX_SIZE);
+ if (!geometry.min_width) {
+ geometry.min_width = 600;
+ geometry.min_height = 480;
+ }
+ gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL,
+ &geometry, GDK_HINT_MIN_SIZE);
gtk_widget_set_uposition(window, prefs_common.compose_x,
prefs_common.compose_y);
text = gtk_text_view_new();
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
+ gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD_CHAR);
gtk_text_view_set_editable(GTK_TEXT_VIEW(text), TRUE);
clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
gtk_text_buffer_add_selection_clipboard(buffer, clipboard);
GtkItemFactory *ifactory;
gboolean can_sign = FALSE, can_encrypt = FALSE;
- systemid = gtk_object_get_data(GTK_OBJECT(widget), "privacy_system");
+ systemid = g_object_get_data(G_OBJECT(widget), "privacy_system");
g_free(compose->privacy_system);
compose->privacy_system = NULL;
if (systemid != NULL) {
while (amenu != NULL) {
GList *alist = amenu->next;
- systemid = gtk_object_get_data(GTK_OBJECT(amenu->data), "privacy_system");
+ systemid = g_object_get_data(G_OBJECT(amenu->data), "privacy_system");
if (systemid != NULL)
if (strcmp(systemid, compose->privacy_system) == 0) {
menuitem = GTK_WIDGET(amenu->data);
for ( tmp = file_list; tmp; tmp = tmp->next) {
gchar *file = (gchar *) tmp->data;
gchar *filedup = g_strdup(file);
- const gchar *shortfile = g_basename(filedup);
+ gchar *shortfile = g_path_get_basename(filedup);
ComposeInsertResult res;
res = compose_insert_file(compose, file);
alertpanel_error(_("File '%s' contained invalid characters\n"
"for the current encoding, insertion may be incorrect."), shortfile);
}
+ g_free(shortfile);
g_free(filedup);
g_free(file);
}
static void activate_privacy_system(Compose *compose, PrefsAccount *account)
{
- /* TODO
- if (account->default_gnupg_mode)
- compose->gnupg_mode = GNUPG_MODE_INLINE;
- else
- compose->gnupg_mode = GNUPG_MODE_DETACH;
- */
+ g_free(compose->privacy_system);
+ compose->privacy_system = g_strdup(account->default_privacy_system);
compose_update_privacy_system_menu_item(compose);
}
} else
gtk_text_buffer_insert(buffer, iter, text, len);
- if (prefs_common.autowrap)
+ if (compose->autowrap)
compose_wrap_line_all_full(compose, TRUE);
g_signal_handlers_unblock_by_func(G_OBJECT(buffer),