#include "statusbar.h"
#include "folder_item_prefs.h"
#include "avatars.h"
+#include "file-utils.h"
+
#ifndef USE_ALT_ADDRBOOK
#include "addressbook.h"
#else
gpointer data);
static PrefsAccount *select_account_from_list
- (GList *ac_list);
+ (GList *ac_list,
+ gboolean has_accounts);
static void addressbook_open_cb (GtkAction *action,
gpointer data);
static void add_address_cb (GtkAction *action,
"It is advised to not send the return receipt."),
to, buf);
val = alertpanel_full(_("Warning"), message,
- _("_Don't Send"), _("_Send"), NULL, FALSE,
- NULL, ALERT_WARNING, G_ALERTDEFAULT);
+ _("_Don't Send"), _("_Send"), NULL, ALERTFOCUS_FIRST, FALSE,
+ NULL, ALERT_WARNING);
g_free(message);
if (val != G_ALERTALTERNATE) {
g_free(buf);
ac_list = account_find_all_from_address(ac_list, msginfo->cc);
if (ac_list == NULL) {
- AlertValue val;
- gchar *tr;
- gchar *text;
- tr = g_strdup(C_("'%s' stands for 'To' then 'Cc'",
- "This message is asking for a return receipt notification\n"
- "but according to its '%s' and '%s' headers it was not\n"
- "officially addressed to you.\n"
- "It is advised to not send the return receipt."));
- text = g_strdup_printf(tr,
- prefs_common_translated_header_name("To"),
- prefs_common_translated_header_name("Cc"));
- val = alertpanel_full(_("Warning"),
- text,
- _("_Don't Send"), _("_Send"), NULL, FALSE,
- NULL, ALERT_WARNING, G_ALERTDEFAULT);
- g_free(text);
- g_free(tr);
- if (val != G_ALERTALTERNATE)
+ ac_list = account_find_all();
+ if ((account = select_account_from_list(ac_list, FALSE)) == NULL)
return -1;
- }
-
- if (g_list_length(ac_list) > 1) {
- if ((account = select_account_from_list(ac_list)) == NULL)
+ } else if (g_list_length(ac_list) > 1) {
+ if ((account = select_account_from_list(ac_list, TRUE)) == NULL)
return -1;
- }
- else if (ac_list != NULL)
+ } else if (ac_list != NULL)
account = (PrefsAccount *) ac_list->data;
g_list_free(ac_list);
g_snprintf(tmp, sizeof(tmp), "%s%ctmpmsg%p",
get_rc_dir(), G_DIR_SEPARATOR, msginfo);
- if ((fp = g_fopen(tmp, "wb")) == NULL) {
- FILE_OP_ERROR(tmp, "fopen");
+ if ((fp = claws_fopen(tmp, "wb")) == NULL) {
+ FILE_OP_ERROR(tmp, "claws_fopen");
return -1;
}
g_free(buf);
buf = NULL;
} else
- if (fprintf(fp, "From: %s\n", account->address) < 0)
- goto FILE_ERROR;
+ goto FILE_ERROR;
if (fprintf(fp, "To: %s\n", to) < 0)
goto FILE_ERROR;
if (ok < 0)
goto FILE_ERROR;
- if (fclose(fp) == EOF) {
- FILE_OP_ERROR(tmp, "fclose");
+ if (claws_safe_fclose(fp) == EOF) {
+ FILE_OP_ERROR(tmp, "claws_fclose");
claws_unlink(tmp);
return -1;
}
return ok;
FILE_ERROR:
- fclose(fp);
+ claws_fclose(fp);
claws_unlink(tmp);
return -1;
}
if (end->prev) {
end->prev->next = NULL;
end->prev = NULL;
- list_free_strings(end);
- g_list_free(end);
+ list_free_strings_full(end);
} else {
- list_free_strings(messageview->trail);
- g_list_free(messageview->trail);
+ list_free_strings_full(messageview->trail);
messageview->trail = NULL;
}
}
messageview->trail = g_list_append(messageview->trail, id);
- messageview->trail_pos = g_list_length(messageview->trail) - 1;
+ messageview->trail_pos = (gint)g_list_length(messageview->trail) - 1;
/* Cut the beginning if needed */
while (messageview->trail_pos > prefs_common.nav_history_length) {
return TRUE;
} else if (!strcasecmp(mimeinfo->subtype, "html")
&& mimeinfo->disposition != DISPOSITIONTYPE_ATTACHMENT
- && (msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_ALWAYS
- || (msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_DEFAULT
+ && ((msginfo->folder && msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_ALWAYS)
+ || ((msginfo->folder && msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_DEFAULT)
&& prefs_common.promote_html_part))) {
mimeview_select_mimepart_icon(messageview->mimeview, mimeinfo);
return TRUE;
g_free(subject);
}
- if (msginfo && msginfo->folder) {
+ if (msginfo->folder) {
msginfo->folder->last_seen = msginfo->msgnum;
}
}
messageview_find_part_depth_first(&context, MIMETYPE_TEXT, "html");
if (context.found &&
- (msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_ALWAYS ||
- (msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_DEFAULT &&
+ ((msginfo->folder && msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_ALWAYS) ||
+ ((msginfo->folder && msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_DEFAULT) &&
prefs_common.promote_html_part))) { /* html found */
mimeinfo = context.found;
if (messageview_try_select_mimeinfo(messageview, msginfo, mimeinfo))
g_free(messageview->toolbar);
}
- list_free_strings(messageview->trail);
- g_list_free(messageview->trail);
+ message_search_close(messageview);
+
+ list_free_strings_full(messageview->trail);
msgview_list = g_list_remove(msgview_list, messageview);
if (messageview->window)
return messageview->visible;
}
-static void messageview_save_as(MessageView *messageview)
-{
- gchar *filename = NULL;
- MsgInfo *msginfo;
- gchar *src, *dest, *tmp;
-
- if (!messageview->msginfo) return;
- msginfo = messageview->msginfo;
-
- if (msginfo->subject) {
- Xstrdup_a(filename, msginfo->subject, return);
- subst_for_filename(filename);
- }
- if (filename && !g_utf8_validate(filename, -1, NULL)) {
- gchar *oldstr = filename;
- filename = conv_codeset_strdup(filename,
- conv_get_locale_charset_str(),
- CS_UTF_8);
- if (!filename) {
- g_warning("messageview_save_as(): failed to convert character set.");
- filename = g_strdup(oldstr);
- }
- dest = filesel_select_file_save(_("Save as"), filename);
- g_free(filename);
- } else
- dest = filesel_select_file_save(_("Save as"), filename);
- if (!dest) return;
- if (is_file_exist(dest)) {
- AlertValue aval;
-
- aval = alertpanel(_("Overwrite"),
- _("Overwrite existing file?"),
- GTK_STOCK_CANCEL, GTK_STOCK_OK, NULL);
- if (G_ALERTALTERNATE != aval) return;
- }
-
- src = procmsg_get_message_file(msginfo);
- if (copy_file(src, dest, TRUE) < 0) {
- tmp = g_path_get_basename(dest);
- alertpanel_error(_("Couldn't save the file '%s'."), tmp);
- g_free(tmp);
- }
- g_free(dest);
- g_free(src);
-}
-
static gint messageview_delete_cb(GtkWidget *widget, GdkEventAny *event,
MessageView *messageview)
{
*(gint*)data = combobox_get_active_data(GTK_COMBO_BOX(w));
}
-static PrefsAccount *select_account_from_list(GList *ac_list)
+static PrefsAccount *select_account_from_list(GList *ac_list, gboolean has_accounts)
{
GtkWidget *optmenu;
gint account_id;
+ AlertValue val;
cm_return_val_if_fail(ac_list != NULL, NULL);
cm_return_val_if_fail(ac_list->data != NULL, NULL);
-
+
optmenu = gtkut_account_menu_new(ac_list,
G_CALLBACK(select_account_cb),
&account_id);
if (!optmenu)
return NULL;
account_id = ((PrefsAccount *) ac_list->data)->account_id;
- if (alertpanel_with_widget(
+ if (!has_accounts) {
+ gchar *tr;
+ gchar *text;
+ tr = g_strdup(C_("'%s' stands for 'To' then 'Cc'",
+ "This message is asking for a return receipt notification\n"
+ "but according to its '%s' and '%s' headers it was not\n"
+ "officially addressed to you.\n"
+ "It is advised to not send the return receipt."));
+ text = g_strdup_printf(tr,
+ prefs_common_translated_header_name("To"),
+ prefs_common_translated_header_name("Cc"));
+ val = alertpanel_with_widget(
+ _("Return Receipt Notification"),
+ text,
+ _("_Cancel"), _("_Send Notification"), NULL,
+ ALERTFOCUS_FIRST, FALSE, optmenu);
+ g_free(tr);
+ g_free(text);
+ } else
+ val = alertpanel_with_widget(
_("Return Receipt Notification"),
_("More than one of your accounts uses the "
- "address that this message was sent to.\n"
- "Please choose which account you want to "
- "use for sending the receipt notification:"),
- _("_Cancel"), _("_Send Notification"), NULL,
- FALSE, G_ALERTDEFAULT, optmenu) != G_ALERTALTERNATE)
+ "address that this message was sent to.\n"
+ "Please choose which account you want to "
+ "use for sending the receipt notification:"),
+ _("_Cancel"), _("_Send Notification"), NULL,
+ ALERTFOCUS_FIRST, FALSE, optmenu);
+
+ if (val != G_ALERTALTERNATE)
return NULL;
- return account_find_from_id(account_id);
+ else
+ return account_find_from_id(account_id);
}
/*
static void save_as_cb(GtkAction *action, gpointer data)
{
MessageView *messageview = (MessageView *)data;
- messageview_save_as(messageview);
+ summary_save_as(messageview->mainwin->summaryview);
}
static void print_mimeview(MimeView *mimeview, gint sel_start, gint sel_end, gint partnum)