From: Hoà Viêt Dinh Date: Fri, 18 May 2001 03:39:01 +0000 (+0000) Subject: new filtering action : forward - some fixes X-Git-Tag: VERSION_0_5_0~149 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=ae706ee0f7354bacac74c77f00862ddf3dc00a7a;hp=b3a20810c8b0faebb897beddecbcee44291fe7a4 new filtering action : forward - some fixes --- diff --git a/ChangeLog.claws b/ChangeLog.claws index 2bb826ace..084f29979 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,27 @@ +2001-05-18 [hoa] + + * src/compose.[ch] + * src/filtering.c + * src/summaryview.c + new filtering action : forward and forward as attachment + + * src/main.c + no need for $DISPLAY when we run sylpheed --help + call to parse_cmd_opt() is moved + + * src/mainwindow.[ch] + execute button is hidden when immediate execute + is chosen + + * src/mh.c + * src/news.c + * src/prefs_folder_item.c + * src/procmsg.c + better handling of missing directories + + * src/summaryview.c + reedit is enabled is outbox + 2001-05-17 [hoa] * src/filtering.c diff --git a/src/compose.c b/src/compose.c index 88c2535cd..c2c91ecd3 100644 --- a/src/compose.c +++ b/src/compose.c @@ -152,7 +152,7 @@ static void compose_attach_append (Compose *compose, static void compose_wrap_line (Compose *compose); static void compose_set_title (Compose *compose); -static gint compose_send (Compose *compose); +/* static gint compose_send (Compose *compose); */ static gint compose_write_to_file (Compose *compose, const gchar *file, gboolean is_draft); @@ -430,12 +430,12 @@ static GtkTargetEntry compose_mime_types[] = {"text/uri-list", 0, 0} }; -void compose_new(PrefsAccount *account) +Compose * compose_new(PrefsAccount *account) { - compose_new_with_recipient(account, NULL); + return compose_new_with_recipient(account, NULL); } -void compose_new_with_recipient(PrefsAccount *account, const gchar *to) +Compose * compose_new_with_recipient(PrefsAccount *account, const gchar *to) { Compose *compose; @@ -458,6 +458,8 @@ void compose_new_with_recipient(PrefsAccount *account, const gchar *to) gtk_widget_grab_focus(compose->to_entry); } else gtk_widget_grab_focus(compose->newsgroups_entry); + + return compose; } void compose_reply(MsgInfo *msginfo, gboolean quote, gboolean to_all) @@ -517,10 +519,11 @@ if (msginfo->var && *msginfo->var) { \ gtk_stext_insert(text, NULL, NULL, NULL, "\n", 1); \ } -void compose_forward(MsgInfo *msginfo, gboolean as_attach) +Compose * compose_forward(PrefsAccount * account, MsgInfo *msginfo, + gboolean as_attach) { Compose *compose; - PrefsAccount *account; + /* PrefsAccount *account; */ GtkSText *text; FILE *fp; gchar buf[BUFFSIZE]; @@ -528,8 +531,10 @@ void compose_forward(MsgInfo *msginfo, gboolean as_attach) g_return_if_fail(msginfo != NULL); g_return_if_fail(msginfo->folder != NULL); - account = msginfo->folder->folder->account; - if (!account) account = cur_account; + if (account == NULL) { + account = msginfo->folder->folder->account; + if (!account) account = cur_account; + } g_return_if_fail(account != NULL); MSG_UNSET_FLAGS(msginfo->flags, MSG_REPLIED); @@ -590,6 +595,8 @@ void compose_forward(MsgInfo *msginfo, gboolean as_attach) gtk_widget_grab_focus(compose->to_entry); else gtk_widget_grab_focus(compose->newsgroups_entry); + + return compose; } #undef INSERT_FW_HEADER @@ -651,6 +658,9 @@ void compose_entry_append(Compose *compose, const gchar *address, case COMPOSE_BCC: entry = GTK_ENTRY(compose->bcc_entry); break; + case COMPOSE_NEWSGROUPS: + entry = GTK_ENTRY(compose->newsgroups_entry); + break; case COMPOSE_TO: default: entry = GTK_ENTRY(compose->to_entry); @@ -1377,7 +1387,7 @@ static void compose_set_title(Compose *compose) g_free(str); } -static gint compose_send(Compose *compose) +gint compose_send(Compose *compose) { gchar tmp[MAXPATHLEN + 1]; gchar *to, *newsgroups; @@ -1671,6 +1681,9 @@ static gint compose_save_to_outbox(Compose *compose, const gchar *file) } path = folder_item_get_path(outbox); + if (!is_dir_exist(path)) + make_dir_hier(path); + if ((fp = procmsg_open_mark_file(path, TRUE)) == NULL) g_warning(_("can't open mark file\n")); else { @@ -1778,6 +1791,9 @@ static gint compose_queue(Compose *compose, const gchar *file) g_free(tmp); queue_path = folder_item_get_path(queue); + if (!is_dir_exist(queue_path)) + make_dir_hier(queue_path); + if ((fp = procmsg_open_mark_file(queue_path, TRUE)) == NULL) g_warning(_("can't open mark file\n")); else { diff --git a/src/compose.h b/src/compose.h index d5d356a5f..a6ceb139d 100644 --- a/src/compose.h +++ b/src/compose.h @@ -42,7 +42,8 @@ typedef enum { COMPOSE_TO, COMPOSE_CC, - COMPOSE_BCC + COMPOSE_BCC, + COMPOSE_NEWSGROUPS } ComposeEntryType; typedef enum @@ -164,15 +165,16 @@ struct _AttachInfo off_t size; }; -void compose_new (PrefsAccount *account); +Compose * compose_new (PrefsAccount *account); -void compose_new_with_recipient (PrefsAccount *account, - const gchar *to); +Compose * compose_new_with_recipient (PrefsAccount *account, + const gchar *to); void compose_reply (MsgInfo *msginfo, gboolean quote, gboolean to_all); -void compose_forward (MsgInfo *msginfo, +Compose * compose_forward (PrefsAccount *account, + MsgInfo *msginfo, gboolean as_attach); void compose_reedit (MsgInfo *msginfo); @@ -181,5 +183,6 @@ GList *compose_get_compose_list (void); void compose_entry_append (Compose *compose, const gchar *address, ComposeEntryType type); +gint compose_send(Compose *compose); #endif /* __COMPOSE_H__ */ diff --git a/src/filtering.c b/src/filtering.c index a2d764623..e5e45a845 100644 --- a/src/filtering.c +++ b/src/filtering.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include "intl.h" #include "utils.h" @@ -10,6 +11,7 @@ #include "matcher.h" #include "filtering.h" #include "prefs.h" +#include "compose.h" #define PREFSBUFSIZE 1024 @@ -174,6 +176,9 @@ static gboolean filteringaction_update_mark(MsgInfo * info) FILE * fp; dest_path = folder_item_get_path(info->folder); + if (!is_dir_exist(dest_path)) + make_dir_hier(dest_path); + if (dest_path == NULL) { g_warning(_("Can't open mark file.\n")); return FALSE; @@ -201,6 +206,8 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info, { FolderItem * dest_folder; gint val; + Compose * compose; + PrefsAccount * account; switch(action->type) { case MATCHING_ACTION_MOVE: @@ -284,10 +291,42 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info, case MATCHING_ACTION_FORWARD: + account = account_find_from_id(action->account_id); + compose = compose_forward(account, info, FALSE); + if (compose->account->protocol == A_NNTP) + compose_entry_append(compose, action->destination, + COMPOSE_NEWSGROUPS); + else + compose_entry_append(compose, action->destination, + COMPOSE_TO); + + val = compose_send(compose); + if (val == 0) { + gtk_widget_destroy(compose->window); + return TRUE; + } + + gtk_widget_destroy(compose->window); return FALSE; case MATCHING_ACTION_FORWARD_AS_ATTACHMENT: + account = account_find_from_id(action->account_id); + compose = compose_forward(account, info, TRUE); + if (compose->account->protocol == A_NNTP) + compose_entry_append(compose, action->destination, + COMPOSE_NEWSGROUPS); + else + compose_entry_append(compose, action->destination, + COMPOSE_TO); + + val = compose_send(compose); + if (val == 0) { + gtk_widget_destroy(compose->window); + return TRUE; + } + + gtk_widget_destroy(compose->window); return FALSE; default: diff --git a/src/main.c b/src/main.c index 5335d0d0f..5c80e9460 100644 --- a/src/main.c +++ b/src/main.c @@ -139,6 +139,8 @@ int main(int argc, char *argv[]) bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + parse_cmd_opt(argc, argv); + gtk_set_locale(); gtk_init(&argc, &argv); @@ -176,7 +178,7 @@ int main(int argc, char *argv[]) prog_version = PROG_VERSION; startup_dir = g_get_current_dir(); - parse_cmd_opt(argc, argv); + /* parse_cmd_opt(argc, argv); */ CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1); diff --git a/src/mainwindow.c b/src/mainwindow.c index bbc87f042..99d38c998 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -804,6 +804,10 @@ void main_window_reflect_prefs_all(void) gtk_widget_set_sensitive(mainwin->get_btn, FALSE); gtk_widget_set_sensitive(mainwin->getall_btn, FALSE); } + if (prefs_common.immediate_exec) + gtk_widget_hide(mainwin->exec_btn); + else + gtk_widget_show(mainwin->exec_btn); summary_change_display_item(mainwin->summaryview); summary_redisplay_msg(mainwin->summaryview); @@ -1339,8 +1343,10 @@ static void main_window_toolbar_create(MainWindow *mainwin, GtkWidget *replyall_btn; GtkWidget *fwd_btn; GtkWidget *send_btn; + /* GtkWidget *prefs_btn; GtkWidget *account_btn; + */ GtkWidget *next_btn; GtkWidget *delete_btn; GtkWidget *exec_btn; @@ -1445,6 +1451,7 @@ static void main_window_toolbar_create(MainWindow *mainwin, toolbar_next_unread_cb, mainwin); + /* gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); CREATE_TOOLBAR_ICON(stock_preferences_xpm); @@ -1466,6 +1473,7 @@ static void main_window_toolbar_create(MainWindow *mainwin, gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event", GTK_SIGNAL_FUNC(toolbar_account_button_pressed), mainwin); + */ mainwin->toolbar = toolbar; mainwin->get_btn = get_btn; @@ -1475,8 +1483,10 @@ static void main_window_toolbar_create(MainWindow *mainwin, mainwin->replyall_btn = replyall_btn; mainwin->fwd_btn = fwd_btn; mainwin->send_btn = send_btn; + /* mainwin->prefs_btn = prefs_btn; mainwin->account_btn = account_btn; + */ mainwin->next_btn = next_btn; mainwin->delete_btn = delete_btn; mainwin->exec_btn = exec_btn; @@ -1849,10 +1859,10 @@ static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget) compose_reply(msginfo, prefs_common.reply_with_quote, TRUE); break; case COMPOSE_FORWARD: - compose_forward(msginfo, FALSE); + compose_forward(NULL, msginfo, FALSE); break; case COMPOSE_FORWARD_AS_ATTACH: - compose_forward(msginfo, TRUE); + compose_forward(NULL, msginfo, TRUE); break; default: compose_reply(msginfo, prefs_common.reply_with_quote, FALSE); diff --git a/src/mainwindow.h b/src/mainwindow.h index a1c816c6f..3c0d2f2f6 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -85,8 +85,10 @@ struct _MainWindow GtkWidget *replyall_btn; GtkWidget *fwd_btn; GtkWidget *send_btn; + /* GtkWidget *prefs_btn; GtkWidget *account_btn; + */ GtkWidget *next_btn; GtkWidget *delete_btn; GtkWidget *exec_btn; diff --git a/src/mh.c b/src/mh.c index 45cad370b..22ae8821e 100644 --- a/src/mh.c +++ b/src/mh.c @@ -69,6 +69,7 @@ GSList *mh_get_msg_list(Folder *folder, FolderItem *item, gboolean use_cache) g_return_val_if_fail(item != NULL, NULL); path = folder_item_get_path(item); + if (stat(path, &s) < 0) { FILE_OP_ERROR(path, "stat"); } else { @@ -120,6 +121,7 @@ gchar *mh_fetch_msg(Folder *folder, FolderItem *item, gint num) g_return_val_if_fail(num > 0 && num <= item->last_num, NULL); path = folder_item_get_path(item); + file = g_strconcat(path, G_DIR_SEPARATOR_S, itos(num), NULL); g_free(path); if (!is_file_exist(file)) { @@ -146,6 +148,9 @@ gint mh_add_msg(Folder *folder, FolderItem *dest, const gchar *file, destpath = folder_item_get_path(dest); g_return_val_if_fail(destpath != NULL, -1); + if (!is_dir_exist(destpath)) + make_dir_hier(destpath); + destfile = g_strdup_printf("%s%c%d", destpath, G_DIR_SEPARATOR, dest->last_num + 1); @@ -195,6 +200,10 @@ gint mh_move_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo) } destdir = folder_item_get_path(dest); + + if (!is_dir_exist(destdir)) + make_dir_hier(destdir); + if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL) g_warning(_("Can't open mark file.\n")); @@ -272,6 +281,9 @@ gint mh_move_msgs_with_dest(Folder *folder, FolderItem *dest, GSList *msglist) } destdir = folder_item_get_path(dest); + if (!is_dir_exist(destdir)) + make_dir_hier(destdir); + if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL) g_warning(_("Can't open mark file.\n")); @@ -360,6 +372,9 @@ gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo) } destdir = folder_item_get_path(dest); + if (!is_dir_exist(destdir)) + make_dir_hier(destdir); + if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL) g_warning(_("Can't open mark file.\n")); @@ -427,6 +442,9 @@ gint mh_copy_msgs_with_dest(Folder *folder, FolderItem *dest, GSList *msglist) } destdir = folder_item_get_path(dest); + if (!is_dir_exist(destdir)) + make_dir_hier(destdir); + if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL) g_warning(_("Can't open mark file.\n")); @@ -677,6 +695,9 @@ FolderItem *mh_create_folder(Folder *folder, FolderItem *parent, g_return_val_if_fail(name != NULL, NULL); path = folder_item_get_path(parent); + if (!is_dir_exist(path)) + make_dir_hier(path); + fullpath = g_strconcat(path, G_DIR_SEPARATOR_S, name, NULL); g_free(path); @@ -716,6 +737,9 @@ gint mh_rename_folder(Folder *folder, FolderItem *item, const gchar *name) g_return_val_if_fail(name != NULL, -1); oldpath = folder_item_get_path(item); + if (!is_dir_exist(oldpath)) + make_dir_hier(oldpath); + dirname = g_dirname(oldpath); newpath = g_strconcat(dirname, G_DIR_SEPARATOR_S, name, NULL); g_free(dirname); diff --git a/src/news.c b/src/news.c index d67fc954f..399e707e7 100644 --- a/src/news.c +++ b/src/news.c @@ -235,6 +235,9 @@ gchar *news_fetch_msg(Folder *folder, FolderItem *item, gint num) g_return_val_if_fail(item != NULL, NULL); path = folder_item_get_path(item); + if (!is_dir_exist(path)) + make_dir_hier(path); + filename = g_strconcat(path, G_DIR_SEPARATOR_S, itos(num), NULL); g_free(path); @@ -643,6 +646,9 @@ static void news_delete_all_article(FolderItem *item) gchar *file; dir = folder_item_get_path(item); + if (!is_dir_exist(dir)) + make_dir_hier(dir); + if ((dp = opendir(dir)) == NULL) { FILE_OP_ERROR(dir, "opendir"); g_free(dir); @@ -749,6 +755,9 @@ void news_reset_group_list(FolderItem *item) debug_print(_("\tDeleting cached group list... ")); path = folder_item_get_path(item); + if (!is_dir_exist(path)) + make_dir_hier(path); + filename = g_strconcat(path, G_DIR_SEPARATOR_S, GROUPLIST_FILE, NULL); g_free(path); if (remove(filename) != 0) diff --git a/src/prefs_folder_item.c b/src/prefs_folder_item.c index 1897523d4..ce87c2fbd 100644 --- a/src/prefs_folder_item.c +++ b/src/prefs_folder_item.c @@ -31,6 +31,9 @@ void prefs_folder_item_read_config(FolderItem * item) gchar * path; path = folder_item_get_path(item); + if (!is_dir_exist(path)) + make_dir_hier(path); + prefs_read_config(param, path, FOLDERITEM_RC); g_free(path); @@ -44,6 +47,9 @@ void prefs_folder_item_save_config(FolderItem * item) tmp_prefs = * item->prefs; path = folder_item_get_path(item); + if (!is_dir_exist(path)) + make_dir_hier(path); + prefs_save_config(param, path, FOLDERITEM_RC); g_free(path); } diff --git a/src/procmsg.c b/src/procmsg.c index 065a1540e..d0d44de80 100644 --- a/src/procmsg.c +++ b/src/procmsg.c @@ -281,6 +281,9 @@ void procmsg_set_flags(GSList *mlist, FolderItem *item) debug_print(_("\tMarking the messages...")); markdir = folder_item_get_path(item); + if (!is_dir_exist(markdir)) + make_dir_hier(markdir); + mark_table = procmsg_read_mark_file(markdir); g_free(markdir); @@ -560,6 +563,7 @@ gchar *procmsg_get_message_file_path(MsgInfo *msginfo) file = g_strdup(msginfo->plaintext_file); else { path = folder_item_get_path(msginfo->folder); + file = g_strconcat(path, G_DIR_SEPARATOR_S, itos(msginfo->msgnum), NULL); g_free(path); diff --git a/src/summaryview.c b/src/summaryview.c index a8125f194..2c7b0f9ab 100644 --- a/src/summaryview.c +++ b/src/summaryview.c @@ -844,7 +844,8 @@ static void summary_set_menu_sensitive(SummaryView *summaryview) menu_set_sensitive(ifactory, "/Open in new window", sens); menu_set_sensitive(ifactory, "/View source", sens); menu_set_sensitive(ifactory, "/Show all header", sens); - if (summaryview->folder_item->stype == F_DRAFT) + if ((summaryview->folder_item->stype == F_DRAFT) || + (summaryview->folder_item->stype == F_OUTBOX)) menu_set_sensitive(ifactory, "/Reedit", sens); menu_set_sensitive(ifactory, "/Save as...", sens); @@ -3020,10 +3021,10 @@ static void summary_reply_cb(SummaryView *summaryview, guint action, compose_reply(msginfo, FALSE, TRUE); break; case COMPOSE_FORWARD: - compose_forward(msginfo, FALSE); + compose_forward(NULL, msginfo, FALSE); break; case COMPOSE_FORWARD_AS_ATTACH: - compose_forward(msginfo, TRUE); + compose_forward(NULL, msginfo, TRUE); break; default: compose_reply(msginfo, prefs_common.reply_with_quote, FALSE);