From 65a932a8d1ed4da87694c05b99466c487659226a Mon Sep 17 00:00:00 2001 From: Paul Mangan Date: Sun, 21 Apr 2002 09:24:27 +0000 Subject: [PATCH] sync with 0.7.4cvs49 --- ChangeLog | 24 ++++++++++++++++++++ ChangeLog.claws | 9 ++++++++ ChangeLog.jp | 25 +++++++++++++++++++++ configure.in | 2 +- src/Makefile.am | 42 +++++++++++++++++----------------- src/folder.c | 2 +- src/imap.c | 55 ++++++++++++++++++++++++++++++++++++--------- src/inputdialog.c | 5 ++++- src/inputdialog.h | 3 ++- src/mh.c | 57 +++++++++++++++++++++-------------------------- src/mimeview.c | 3 ++- src/utils.c | 12 ++++++++++ src/utils.h | 9 +++++--- 13 files changed, 177 insertions(+), 71 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4aa161bf2..0e2ab4b9a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2002-04-21 + + * src/mh.c: mh_get_new_msg_filename(): new. It returns the filename + for new message. + mh_add_msg() + mh_do_move() + mh_do_move_msgs_with_dest() + mh_copy_msg() + mh_copy_msgs_with_dest(): use mh_get_new_msg_filename(). + * src/utils.[ch]: added is_file_entry_exist() which returns TRUE + if stat() succeeded. + * src/imap.c: + imap_fetch_msg(): SELECT mailbox before FETCH if required. + imap_scan_folder(): set last_num using the value of UIDNEXT. + imap_select(): return immediately if there is no need for SELECT. + preserve the path of currently selected mailbox. + imap_status(): added UIDNEXT. + +2002-04-20 + + * src/folder.c: folder_item_scan(): removed the warning. + * src/inputdialog.[ch]: input_dialog_combo(): added an argument for + setting case sensitivity. + 2002-04-17 * src/mainwindow.c: main_window_create(): restrict the minimum size. diff --git a/ChangeLog.claws b/ChangeLog.claws index bf20ca403..f8358c0ca 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,12 @@ +2002-04-21 [paul] 0.7.4claws85 + + * sync with 0.7.4cvs49 + see ChangeLog entries 2002-04-20 and 2002-04-21 + + * src/Makefile.am + clean up: remove old 'stock_' element from xpm + filenames. + 2002-04-21 [alfons] 0.7.4claws84 apply sync patch from Paul diff --git a/ChangeLog.jp b/ChangeLog.jp index 0738d08eb..24f032a95 100644 --- a/ChangeLog.jp +++ b/ChangeLog.jp @@ -1,3 +1,28 @@ +2002-04-21 + + * src/mh.c: mh_get_new_msg_filename(): ¿·µ¬¡£¿·µ¬¥á¥Ã¥»¡¼¥¸¤Î¥Õ¥¡¥¤¥ë + ̾¤òÊÖ¤¹¡£ + mh_add_msg() + mh_do_move() + mh_do_move_msgs_with_dest() + mh_copy_msg() + mh_copy_msgs_with_dest(): mh_get_new_msg_filename() ¤ò»ÈÍÑ¡£ + * src/utils.[ch]: is_file_entry_exist() ¤òÄɲᣠstat() ¤¬À®¸ù¤·¤¿¤é + TRUE ¤òÊÖ¤¹¡£ + * src/imap.c: + imap_fetch_msg(): ɬÍפǤ¢¤ì¤Ð FETCH ¤ÎÁ°¤Ë¥á¡¼¥ë¥Ü¥Ã¥¯¥¹¤ò SELECT + ¤¹¤ë¤è¤¦¤Ë¤·¤¿¡£ + imap_scan_folder(): UIDNEXT ¤ÎÃͤòÍѤ¤¤Æ last_num ¤ò¥»¥Ã¥È¡£ + imap_select(): SELECT ¤ÎɬÍפ¬¤Ê¤±¤ì¤Ð¤¹¤°¤ËÊÖ¤ë¤è¤¦¤Ë¤·¤¿¡£ + ¸½ºßÁªÂòÃæ¤Î¥á¡¼¥ë¥Ü¥Ã¥¯¥¹¤Î¥Ñ¥¹¤òÊݸ¡£ + imap_status(): UIDNEXT ¤òÄɲᣠ+ +2002-04-20 + + * src/folder.c: folder_item_scan(): ·Ù¹ð¤ò½üµî¡£ + * src/inputdialog.[ch]: input_dialog_combo(): Â羮ʸ»ú¤Î¶èÊ̤λØÄê¤Î + ¤¿¤á¤Î°ú¿ô¤òÄɲᣠ+ 2002-04-17 * src/mainwindow.c: main_window_create(): ºÇ¾®¥µ¥¤¥º¤òÀ©¸Â¡£ diff --git a/configure.in b/configure.in index 9b94b00aa..69da0eb1b 100644 --- a/configure.in +++ b/configure.in @@ -8,7 +8,7 @@ MINOR_VERSION=7 MICRO_VERSION=4 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws84 +EXTRA_VERSION=claws85 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target diff --git a/src/Makefile.am b/src/Makefile.am index 4672f9041..69572941a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -166,27 +166,27 @@ EXTRA_DIST = \ pixmaps/continue.xpm \ pixmaps/complete.xpm \ pixmaps/error.xpm \ - pixmaps/stock_mail.xpm \ - pixmaps/stock_mail_attach.xpm \ - pixmaps/stock_mail_receive.xpm \ - pixmaps/stock_mail_receive_all.xpm \ - pixmaps/stock_mail_send.xpm \ - pixmaps/stock_mail_send_queue.xpm \ - pixmaps/stock_mail_compose.xpm \ - pixmaps/stock_news_compose.xpm \ - pixmaps/stock_mail_reply.xpm \ - pixmaps/stock_mail_reply_to_all.xpm \ - pixmaps/stock_mail_reply_to_author.xpm \ - pixmaps/stock_mail_forward.xpm \ - pixmaps/stock_preferences.xpm \ - pixmaps/stock_properties.xpm \ - pixmaps/stock_search.xpm \ - pixmaps/stock_close.xpm \ - pixmaps/stock_exec.xpm \ - pixmaps/stock_trash.xpm \ - pixmaps/stock_up_arrow.xpm \ - pixmaps/stock_down_arrow.xpm \ - pixmaps/stock_paste.xpm \ + pixmaps/mail.xpm \ + pixmaps/mail_attach.xpm \ + pixmaps/mail_receive.xpm \ + pixmaps/mail_receive_all.xpm \ + pixmaps/mail_send.xpm \ + pixmaps/mail_send_queue.xpm \ + pixmaps/mail_compose.xpm \ + pixmaps/news_compose.xpm \ + pixmaps/mail_reply.xpm \ + pixmaps/mail_reply_to_all.xpm \ + pixmaps/mail_reply_to_author.xpm \ + pixmaps/mail_forward.xpm \ + pixmaps/preferences.xpm \ + pixmaps/properties.xpm \ + pixmaps/search.xpm \ + pixmaps/close.xpm \ + pixmaps/exec.xpm \ + pixmaps/trash.xpm \ + pixmaps/up_arrow.xpm \ + pixmaps/down_arrow.xpm \ + pixmaps/paste.xpm \ pixmaps/tb_address_book.xpm \ pixmaps/sylpheed-logo.xpm \ pixmaps/address.xpm \ diff --git a/src/folder.c b/src/folder.c index 06da57955..906c2e757 100644 --- a/src/folder.c +++ b/src/folder.c @@ -750,7 +750,7 @@ gint folder_item_scan(FolderItem *item) { Folder *folder; - g_return_if_fail(item != NULL); + g_return_val_if_fail(item != NULL, -1); folder = item->folder; return folder->scan(folder, item); diff --git a/src/imap.c b/src/imap.c index 8e86b4605..747c4a843 100644 --- a/src/imap.c +++ b/src/imap.c @@ -144,8 +144,9 @@ static gint imap_status (IMAPSession *session, const gchar *path, gint *messages, gint *recent, - gint *unseen, - guint32 *uid_validity); + guint32 *uid_next, + guint32 *uid_validity, + gint *unseen); static void imap_parse_namespace (IMAPSession *session, IMAPFolder *folder); @@ -589,6 +590,15 @@ gchar *imap_fetch_msg(Folder *folder, FolderItem *item, gint uid) return NULL; } + ok = imap_select(session, IMAP_FOLDER(folder), item->path, + NULL, NULL, NULL, NULL); + statusbar_pop_all(); + if (ok != IMAP_SUCCESS) { + g_warning(_("can't select mailbox %s\n"), item->path); + g_free(filename); + return NULL; + } + debug_print(_("getting message %d...\n"), uid); ok = imap_cmd_fetch(SESSION(session)->sock, (guint32)uid, filename); @@ -926,7 +936,7 @@ gint imap_scan_folder(Folder *folder, FolderItem *item) { IMAPSession *session; gint messages, recent, unseen; - guint32 uid_validity; + guint32 uid_next, uid_validity; gint ok; g_return_val_if_fail(folder != NULL, -1); @@ -936,13 +946,14 @@ gint imap_scan_folder(Folder *folder, FolderItem *item) if (!session) return -1; ok = imap_status(session, IMAP_FOLDER(folder), item->path, - &messages, &recent, &unseen, &uid_validity); + &messages, &recent, &uid_next, &uid_validity, &unseen); statusbar_pop_all(); if (ok != IMAP_SUCCESS) return -1; item->new = unseen > 0 ? recent : 0; item->unread = unseen; item->total = messages; + item->last_num = (messages > 0 && uid_next > 0) ? uid_next - 1 : 0; /* item->mtime = uid_validity; */ return 0; @@ -1349,6 +1360,8 @@ gint imap_rename_folder(Folder *folder, FolderItem *item, const gchar *name) real_oldpath = imap_get_real_path(IMAP_FOLDER(folder), item->path); + g_free(session->mbox); + session->mbox = NULL; ok = imap_cmd_examine(SESSION(session)->sock, "INBOX", &exists, &recent, &unseen, &uid_validity); statusbar_pop_all(); @@ -2184,12 +2197,27 @@ static gint imap_select(IMAPSession *session, IMAPFolder *folder, { gchar *real_path; gint ok; + gint exists_, recent_, unseen_, uid_validity_; + + if (!exists || !recent || !unseen || !uid_validity) { + if (session->mbox && strcmp(session->mbox, path) == 0) + return IMAP_SUCCESS; + exists = &exists_; + recent = &recent_; + unseen = &unseen_; + uid_validity = &uid_validity_; + } + + g_free(session->mbox); + session->mbox = NULL; real_path = imap_get_real_path(folder, path); ok = imap_cmd_select(SESSION(session)->sock, real_path, exists, recent, unseen, uid_validity); if (ok != IMAP_SUCCESS) log_warning(_("can't select folder: %s\n"), real_path); + else + session->mbox = g_strdup(path); g_free(real_path); return ok; @@ -2229,8 +2257,9 @@ catch: static gint imap_status(IMAPSession *session, IMAPFolder *folder, const gchar *path, - gint *messages, gint *recent, gint *unseen, - guint32 *uid_validity) + gint *messages, gint *recent, + guint32 *uid_next, guint32 *uid_validity, + gint *unseen) { gchar *real_path; gchar *real_path_; @@ -2238,14 +2267,15 @@ static gint imap_status(IMAPSession *session, IMAPFolder *folder, GPtrArray *argbuf; gchar *str; - *messages = *recent = *unseen = *uid_validity = 0; + *messages = *recent = *uid_next = *uid_validity = *unseen = 0; argbuf = g_ptr_array_new(); real_path = imap_get_real_path(folder, path); QUOTE_IF_REQUIRED(real_path_, real_path); imap_cmd_gen_send(SESSION(session)->sock, "STATUS %s " - "(MESSAGES RECENT UNSEEN UIDVALIDITY)", real_path_); + "(MESSAGES RECENT UIDNEXT UIDVALIDITY UNSEEN)", + real_path_); ok = imap_cmd_ok(SESSION(session)->sock, argbuf); if (ok != IMAP_SUCCESS) THROW(ok); @@ -2265,12 +2295,15 @@ static gint imap_status(IMAPSession *session, IMAPFolder *folder, } else if (!strncmp(str, "RECENT ", 7)) { str += 7; *recent = strtol(str, &str, 10); - } else if (!strncmp(str, "UNSEEN ", 7)) { - str += 7; - *unseen = strtol(str, &str, 10); + } else if (!strncmp(str, "UIDNEXT ", 8)) { + str += 8; + *uid_next = strtoul(str, &str, 10); } else if (!strncmp(str, "UIDVALIDITY ", 12)) { str += 12; *uid_validity = strtoul(str, &str, 10); + } else if (!strncmp(str, "UNSEEN ", 7)) { + str += 7; + *unseen = strtol(str, &str, 10); } else { g_warning("invalid STATUS response: %s\n", str); break; diff --git a/src/inputdialog.c b/src/inputdialog.c index 2f7656d55..ff2cd8dce 100644 --- a/src/inputdialog.c +++ b/src/inputdialog.c @@ -116,7 +116,8 @@ gchar *input_dialog_with_invisible(const gchar *title, const gchar *message, } gchar *input_dialog_combo(const gchar *title, const gchar *message, - const gchar *default_string, GList *list) + const gchar *default_string, GList *list, + gboolean case_sensitive) { if (dialog && GTK_WIDGET_VISIBLE(dialog)) return NULL; @@ -137,6 +138,8 @@ gchar *input_dialog_combo(const gchar *title, const gchar *message, } else gtk_combo_set_popdown_strings(GTK_COMBO(combo), list); + gtk_combo_set_case_sensitive(GTK_COMBO(combo), case_sensitive); + return input_dialog_open(title, message, default_string); } diff --git a/src/inputdialog.h b/src/inputdialog.h index c93bb707c..0e9175a80 100644 --- a/src/inputdialog.h +++ b/src/inputdialog.h @@ -31,7 +31,8 @@ gchar *input_dialog_with_invisible (const gchar *title, gchar *input_dialog_combo (const gchar *title, const gchar *message, const gchar *default_string, - GList *list); + GList *list, + gboolean case_sensitive); gchar *input_dialog_query_password (const gchar *server, const gchar *user); diff --git a/src/mh.c b/src/mh.c index b45a1433a..bd9f632b8 100644 --- a/src/mh.c +++ b/src/mh.c @@ -47,6 +47,8 @@ static void mh_folder_init (Folder *folder, const gchar *name, const gchar *path); +static gchar *mh_get_new_msg_filename (FolderItem *dest); + static GSList *mh_get_uncached_msgs (GHashTable *msg_table, FolderItem *item); static MsgInfo *mh_parse_msg (const gchar *file, @@ -177,27 +179,27 @@ gchar *mh_fetch_msg(Folder *folder, FolderItem *item, gint num) return file; } -gchar *mh_get_newmsg_filename(FolderItem *dest) +static gchar *mh_get_new_msg_filename(FolderItem *dest) { gchar *destfile; gchar *destpath; - gboolean found = FALSE; destpath = folder_item_get_path(dest); g_return_val_if_fail(destpath != NULL, NULL); + if (!is_dir_exist(destpath)) make_dir_hier(destpath); - do { + for (;;) { destfile = g_strdup_printf("%s%c%d", destpath, G_DIR_SEPARATOR, dest->last_num + 1); - if(is_file_exist(destfile)) { + if (is_file_entry_exist(destfile)) { dest->last_num++; g_free(destfile); - } else { - found = TRUE; - } - } while(!found); + } else + break; + } + g_free(destpath); return destfile; @@ -232,8 +234,8 @@ gint mh_add_msg(Folder *folder, FolderItem *dest, const gchar *file, if (dest->last_num < 0) return -1; } - destfile = mh_get_newmsg_filename(dest); - if(!destfile) return -1; + destfile = mh_get_new_msg_filename(dest); + g_return_val_if_fail(destfile != NULL, -1); if (link(file, destfile) < 0) { if (copy_file(file, destfile) < 0) { @@ -278,21 +280,22 @@ static gint mh_do_move(Folder *folder, FolderItem *dest, MsgInfo *msginfo) prefs = dest->prefs; - destdir = folder_item_get_path(dest); + destfile = mh_get_new_msg_filename(dest); + g_return_val_if_fail(destfile != NULL, -1); debug_print(_("Moving message %s%c%d to %s ...\n"), msginfo->folder->path, G_DIR_SEPARATOR, msginfo->msgnum, dest->path); srcfile = procmsg_get_message_file(msginfo); - destfile = mh_get_newmsg_filename(dest); + destfile = mh_get_new_msg_filename(dest); if(!destfile) return -1; + srcfile = procmsg_get_message_file(msginfo); if (move_file(srcfile, destfile) < 0) { g_free(srcfile); g_free(destfile); - g_free(destdir); return -1; } @@ -310,6 +313,7 @@ static gint mh_do_move(Folder *folder, FolderItem *dest, MsgInfo *msginfo) g_free(destfile); dest->last_num++; + destdir = folder_item_get_path(dest); if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL) g_warning(_("Can't open mark file.\n")); else { @@ -409,8 +413,10 @@ static gint mh_do_move_msgs_with_dest(Folder *folder, FolderItem *dest, msginfo->folder->path, G_DIR_SEPARATOR, msginfo->msgnum, dest->path); + destfile = mh_get_new_msg_filename(dest); + if (!destfile) break; srcfile = procmsg_get_message_file(msginfo); - destfile = mh_get_newmsg_filename(dest); + destfile = mh_get_new_msg_filename(dest); if(!destfile) return -1; if (move_file(srcfile, destfile) < 0) { @@ -477,28 +483,19 @@ gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo) prefs = dest->prefs; - destdir = folder_item_get_path(dest); - if (!is_dir_exist(destdir)) - make_dir_hier(destdir); + destfile = mh_get_new_msg_filename(dest); + g_return_val_if_fail(destfile != NULL, -1); debug_print(_("Copying message %s%c%d to %s ...\n"), msginfo->folder->path, G_DIR_SEPARATOR, msginfo->msgnum, dest->path); + srcfile = procmsg_get_message_file(msginfo); - destfile = mh_get_newmsg_filename(dest); - if(!destfile) { - g_free(srcfile); - if (fp) fclose(fp); - return -1; - } - - dest->op_count--; if (copy_file(srcfile, destfile) < 0) { FILE_OP_ERROR(srcfile, "copy"); g_free(srcfile); g_free(destfile); - g_free(destdir); return -1; } @@ -516,6 +513,7 @@ gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo) g_free(destfile); dest->last_num++; + destdir = folder_item_get_path(dest); if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL) g_warning(_("Can't open mark file.\n")); else { @@ -620,12 +618,9 @@ gint mh_copy_msgs_with_dest(Folder *folder, FolderItem *dest, GSList *msglist) msginfo->folder->path, G_DIR_SEPARATOR, msginfo->msgnum, dest->path); + destfile = mh_get_new_msg_filename(dest); + if (!destfile) break; srcfile = procmsg_get_message_file(msginfo); - destfile = mh_get_newmsg_filename(dest); - if(!destfile) { - g_free(srcfile); - break; - } if (copy_file(srcfile, destfile) < 0) { FILE_OP_ERROR(srcfile, "copy"); diff --git a/src/mimeview.c b/src/mimeview.c index ff78a740f..76f8de169 100644 --- a/src/mimeview.c +++ b/src/mimeview.c @@ -862,7 +862,8 @@ static void mimeview_open_with(MimeView *mimeview) _("Enter the command line to open file:\n" "(`%s' will be replaced with file name)"), prefs_common.mime_open_cmd, - prefs_common.mime_open_cmd_history); + prefs_common.mime_open_cmd_history, + TRUE); if (cmd) { mimeview_view_file(filename, partinfo, cmd); g_free(prefs_common.mime_open_cmd); diff --git a/src/utils.c b/src/utils.c index 715d69adf..140f5f3a4 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1438,6 +1438,18 @@ gboolean is_dir_exist(const gchar *dir) return FALSE; } +gboolean is_file_entry_exist(const gchar *file) +{ + struct stat s; + + if (stat(file, &s) < 0) { + if (ENOENT != errno) FILE_OP_ERROR(file, "stat"); + return FALSE; + } + + return TRUE; +} + gint change_dir(const gchar *dir) { gchar *prevdir = NULL; diff --git a/src/utils.h b/src/utils.h index e69dd2663..f9f93c769 100644 --- a/src/utils.h +++ b/src/utils.h @@ -298,9 +298,15 @@ gchar *get_domain_name (void); off_t get_file_size (const gchar *file); off_t get_file_size_as_crlf (const gchar *file); off_t get_left_file_size (FILE *fp); + gboolean file_exist (const gchar *file, gboolean allow_fifo); gboolean is_dir_exist (const gchar *dir); +gboolean is_file_entry_exist (const gchar *file); + +#define is_file_exist(file) file_exist(file, FALSE) +#define is_file_or_fifo_exist(file) file_exist(file, TRUE) + gint change_dir (const gchar *dir); gint make_dir_hier (const gchar *dir); gint remove_all_files (const gchar *dir); @@ -318,9 +324,6 @@ gint change_file_mode_rw (FILE *fp, FILE *my_tmpfile (void); FILE *str_open_as_stream (const gchar *str); -#define is_file_exist(file) file_exist(file, FALSE) -#define is_file_or_fifo_exist(file) file_exist(file, TRUE) - /* process execution */ gint execute_async (gchar *const argv[]); gint execute_sync (gchar *const argv[]); -- 2.25.1