sync with 0.7.4cvs31
authorPaul Mangan <paul@claws-mail.org>
Fri, 5 Apr 2002 08:20:10 +0000 (08:20 +0000)
committerPaul Mangan <paul@claws-mail.org>
Fri, 5 Apr 2002 08:20:10 +0000 (08:20 +0000)
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.in
src/export.c
src/filter.c
src/folder.c
src/folder.h
src/import.c
src/inc.c
src/prefs_filter.c

index ece06d1..e4923bc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2002-04-05
+
+       * src/filter.c
+         src/inc.c: changed folder_find_item_from_path() to
+         folder_find_item_from_identifier().
+         src/prefs_account.c
+         src/prefs_filter.c: use folder_item_get_identifier() to specify
+         folder path.
+
+2002-04-05
+
+       * src/folder.[ch]: implemented "folder identifier" (and fixed a bug
+         existed in claws' implementation).
+         folder_find_from_name(): find Folder from name and type.
+         folder_get_identifier(): return Folder id.
+         folder_item_get_identifier(): return FolderItem id.
+         folder_find_item_from_identifier(): find FolderItem from id.
+         folder_get_type_string(): return folder type string.
+         folder_get_type_from_string(): return FolderType from string
+         (and fixed the wrong g_strcasecmp() usage).
+       * src/export.c
+         src/import.c: use folder_item_get_identifier() and
+         folder_find_item_from_identifier().
+
 2002-04-03
 
        * src/imap.c: imap_parse_atom(): fixed a bug that cur_pos didn't
index a9811a7..49108a1 100644 (file)
@@ -1,3 +1,8 @@
+2002-04-05 [paul]      0.7.4claws64
+
+       * sync with 0.7.4cvs31
+               see ChangeLog entries 2002-04-05
+
 2002-04-03 [paul]      0.7.4claws63
 
        * sync with 0.7.4cvs29
index 4166709..d376e1f 100644 (file)
@@ -1,3 +1,27 @@
+2002-04-05
+
+       * src/filter.c
+         src/inc.c: folder_find_item_from_path() ¤ò
+         folder_find_item_from_identifier() ¤ËÊѹ¹¡£
+         src/prefs_account.c
+         src/prefs_filter.c: ¥Õ¥©¥ë¥À¥Ñ¥¹¤ò»ØÄꤹ¤ë¤Î¤Ë
+         folder_item_get_identifier() ¤ò»ÈÍÑ¡£
+
+2002-04-05
+
+       * src/folder.[ch]: ¡Ö¥Õ¥©¥ë¥À¼±Ê̻ҡפò¼ÂÁõ(¤½¤·¤Æ claws ¤Î¼ÂÁõ¤Ë
+         Â¸ºß¤·¤¿¥Ð¥°¤ò½¤Àµ)¡£
+         folder_find_from_name(): Ì¾Á°¤È¥¿¥¤¥×¤«¤é Folder ¤ò¸¡º÷¡£
+         folder_get_identifier(): Folder ¤Î id ¤òÊÖ¤¹¡£
+         folder_item_get_identifier(): FolderItem ¤Î id ¤òÊÖ¤¹¡£
+         folder_find_item_from_identifier(): id ¤«¤é FolderItem ¤òÊÖ¤¹¡£
+         folder_get_type_string(): ¥Õ¥©¥ë¥À¥¿¥¤¥×ʸ»úÎó¤òÊÖ¤¹¡£
+         folder_get_type_from_string(): Ê¸»úÎ󤫤é FolderType ¤òÊÖ¤¹¡£
+         (¤½¤·¤Æ¸í¤Ã¤¿ g_strcasecmp() ¤ÎÍÑË¡¤ò½¤Àµ)¡£
+       * src/export.c
+         src/import.c: folder_item_get_identifier() ¤È
+         folder_find_item_from_identifier() ¤ò»ÈÍÑ¡£
+
 2002-04-03
 
        * src/imap.c: imap_parse_atom(): ·Ñ³¹Ô¤òÆɤó¤À¸å¤Ë cur_pos ¤¬Àµ¤·¤¤
index 03b9fad..91307e3 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=7
 MICRO_VERSION=4
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws63
+EXTRA_VERSION=claws64
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 40fdf2e..0f7f8d6 100644 (file)
@@ -68,6 +68,7 @@ static void key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data);
 gint export_mbox(FolderItem *default_src)
 {
        gint ok = 0;
+       gchar *src_id = NULL;
 
        if (!window)
                export_create();
@@ -77,8 +78,12 @@ gint export_mbox(FolderItem *default_src)
        change_dir(startup_dir);
 
        if (default_src && default_src->path)
-               gtk_entry_set_text(GTK_ENTRY(src_entry), default_src->path);
-       else
+               src_id = folder_item_get_identifier(default_src);
+
+       if (src_id) {
+               gtk_entry_set_text(GTK_ENTRY(src_entry), src_id);
+               g_free(src_id);
+       } else
                gtk_entry_set_text(GTK_ENTRY(src_entry), "");
        gtk_entry_set_text(GTK_ENTRY(file_entry), "");
        gtk_widget_grab_focus(file_entry);
@@ -95,7 +100,7 @@ gint export_mbox(FolderItem *default_src)
                mbox = gtk_entry_get_text(GTK_ENTRY(file_entry));
 
                if (mbox && *mbox) {
-                       src = folder_find_item_from_path(srcdir);
+                       src = folder_find_item_from_identifier(srcdir);
                        if (!src)
                                g_warning("Can't find the folder.\n");
                        else
index eddba63..b6043b1 100644 (file)
@@ -57,7 +57,7 @@ FolderItem *filter_get_dest_folder(GSList *fltlist, const gchar *file)
                                }
                                dest_folder = dummy;
                        } else
-                               dest_folder = folder_find_item_from_path
+                               dest_folder = folder_find_item_from_identifier
                                        (filter->dest);
                        break;
                }
index 8e200ec..86ddd15 100644 (file)
@@ -438,6 +438,20 @@ Folder *folder_find_from_path(const gchar *path)
        return NULL;
 }
 
+Folder *folder_find_from_name(const gchar *name, FolderType type)
+{
+       GList *list;
+       Folder *folder;
+
+       for (list = folder_list; list != NULL; list = list->next) {
+               folder = list->data;
+               if (folder->type == type && strcmp2(name, folder->name) == 0)
+                       return folder;
+       }
+
+       return NULL;
+}
+
 static gboolean folder_item_find_func(GNode *node, gpointer data)
 {
        FolderItem *item = node->data;
@@ -467,6 +481,114 @@ FolderItem *folder_find_item_from_path(const gchar *path)
        return d[1];
 }
 
+static const struct {
+       gchar *str;
+       FolderType type;
+} type_str_table[] = {
+       {"#mh"     , F_MH},
+       {"#mbox"   , F_MBOX},
+       {"#maildir", F_MAILDIR},
+       {"#imap"   , F_IMAP},
+       {"#news"   , F_NEWS}
+};
+
+static gchar *folder_get_type_string(FolderType type)
+{
+       gint i;
+
+       for (i = 0; i < sizeof(type_str_table) / sizeof(type_str_table[0]);
+            i++) {
+               if (type_str_table[i].type == type)
+                       return type_str_table[i].str;
+       }
+
+       return NULL;
+}
+
+static FolderType folder_get_type_from_string(const gchar *str)
+{
+       gint i;
+
+       for (i = 0; i < sizeof(type_str_table) / sizeof(type_str_table[0]);
+            i++) {
+               if (g_strcasecmp(type_str_table[i].str, str) == 0)
+                       return type_str_table[i].type;
+       }
+
+       return F_UNKNOWN;
+}
+
+gchar *folder_get_identifier(Folder *folder)
+{
+       gchar *type_str;
+
+       g_return_val_if_fail(folder != NULL, NULL);
+
+       type_str = folder_get_type_string(folder->type);
+       return g_strconcat(type_str, "/", folder->name, NULL);
+}
+
+gchar *folder_item_get_identifier(FolderItem *item)
+{
+       gchar *id;
+       gchar *folder_id;
+
+       g_return_val_if_fail(item != NULL, NULL);
+       g_return_val_if_fail(item->path != NULL, NULL);
+
+       folder_id = folder_get_identifier(item->folder);
+       id = g_strconcat(folder_id, "/", item->path, NULL);
+       g_free(folder_id);
+
+       return id;
+}
+
+FolderItem *folder_find_item_from_identifier(const gchar *identifier)
+{
+       Folder *folder;
+       gpointer d[2];
+       gchar *str;
+       gchar *p;
+       gchar *name;
+       gchar *path;
+       FolderType type;
+
+       g_return_val_if_fail(identifier != NULL, NULL);
+
+       if (*identifier != '#')
+               return folder_find_item_from_path(identifier);
+
+       Xstrdup_a(str, identifier, return NULL);
+
+       p = strchr(str, '/');
+       if (!p)
+               return folder_find_item_from_path(identifier);
+       *p = '\0';
+       p++;
+       type = folder_get_type_from_string(str);
+       if (type == F_UNKNOWN)
+               return folder_find_item_from_path(identifier);
+
+       name = p;
+       p = strchr(p, '/');
+       if (!p)
+               return folder_find_item_from_path(identifier);
+       *p = '\0';
+       p++;
+
+       folder = folder_find_from_name(name, type);
+       if (!folder)
+               return folder_find_item_from_path(identifier);
+
+       path = p;
+
+       d[0] = (gpointer)path;
+       d[1] = NULL;
+       g_node_traverse(folder->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
+                       folder_item_find_func, d);
+       return d[1];
+}
+
 Folder *folder_get_default_folder(void)
 {
        return folder_list ? FOLDER(folder_list->data) : NULL;
@@ -1331,46 +1453,6 @@ typedef struct _type_str {
 } type_str;
 
 
-static type_str type_str_table[] = 
-{
-       {"#mh", F_MH},
-       {"#mbox", F_MBOX},
-       {"#maildir", F_MAILDIR},
-       {"#imap", F_IMAP},
-       {"#news", F_NEWS}
-};
-
-
-static gchar * folder_get_type_string(gint type)
-{
-       gint i;
-
-       for(i = 0 ; i < sizeof(type_str_table) / sizeof(type_str) ; i++) {
-               if (type_str_table[i].type == type)
-                       return type_str_table[i].str;
-       }
-       return NULL;
-}
-
-static gint folder_get_type_from_string(gchar * str)
-{
-       gint i;
-
-       for(i = 0 ; i < sizeof(type_str_table) / sizeof(type_str) ; i++) {
-               if (g_strcasecmp(type_str_table[i].str, str))
-                       return type_str_table[i].type;
-       }
-       return F_UNKNOWN;
-}
-
-gchar * folder_get_identifier(Folder * folder)
-{
-       gchar * type_str;
-       type_str = folder_get_type_string(folder->type);
-
-       return g_strconcat(type_str, "/", folder->name, NULL);
-}
-
 /*
 static gchar * folder_item_get_tree_identifier(FolderItem * item)
 {
@@ -1393,85 +1475,7 @@ static gchar * folder_item_get_tree_identifier(FolderItem * item)
 }
 */
 
-gchar * folder_item_get_identifier(FolderItem * item)
-{
-       gchar * id;
-       gchar * folder_str;
-
-       g_return_val_if_fail(item->path != NULL, NULL);
-
-       folder_str = folder_get_identifier(item->folder);
-       id = g_strconcat(folder_str, "/", item->path, NULL);
-       g_free(folder_str);
-
-       return id;
-}
-
-Folder * folder_find_from_name(const gchar * name)
-{
-       GList *list;
-       Folder *folder;
-
-       for (list = g_list_first(folder_list); list != NULL;
-            list = list->next) {
-               folder = list->data;
-               if (strcmp(name, folder->name) == 0)
-                       return folder;
-       }
-       return NULL;
-}
-
-FolderItem * folder_find_item_from_identifier(const gchar *identifier)
-{
-       Folder *folder;
-       gpointer d[2];
-       gchar * str;
-       gchar * p;
-       gint type;
-       gchar * name;
-       gchar * path;
-
-       Xstrdup_a(str, identifier, return NULL);
-
-       /* extract box type */
-
-       p = strchr(str, '/');
-
-       if (p == NULL)
-               return NULL;
-
-       *p = '\0';
-
-       type = folder_get_type_from_string(str);
-
-       str = p + 1;
-
-       /* extract box name */
-
-       p = strchr(str, '/');
-
-       if (p == NULL)
-               return NULL;
-
-       *p = '\0';
-
-       name = str;
-
-       folder = folder_find_from_name(name);
-       if (folder == NULL)
-               return;
-
-       path = p + 1;
-
-       d[0] = (gpointer)path;
-       d[1] = NULL;
-       g_node_traverse(folder->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
-                       folder_item_find_func, d);
-       return d[1];
-}
-
 /* CLAWS: temporary local folder for filtering */
-
 static Folder *processing_folder;
 static FolderItem *processing_folder_item;
 
index ed79686..78cf114 100644 (file)
@@ -259,8 +259,14 @@ void   folder_count_total_msgs     (guint          *new,
                                 guint          *unread,
                                 guint          *total);
 
-Folder     *folder_find_from_path      (const gchar    *path);
-FolderItem *folder_find_item_from_path (const gchar    *path);
+Folder     *folder_find_from_path              (const gchar    *path);
+Folder     *folder_find_from_name              (const gchar    *name,
+                                                FolderType      type);
+FolderItem *folder_find_item_from_path         (const gchar    *path);
+gchar      *folder_get_identifier              (Folder         *folder);
+gchar      *folder_item_get_identifier         (FolderItem     *item);
+FolderItem *folder_find_item_from_identifier   (const gchar    *identifier);
+
 Folder     *folder_get_default_folder  (void);
 FolderItem *folder_get_default_inbox   (void);
 FolderItem *folder_get_default_outbox  (void);
index 6cc35ad..4518db7 100644 (file)
@@ -68,7 +68,7 @@ static void key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data);
 gint import_mbox(FolderItem *default_dest)
 {
        gint ok = 0;
-       gchar *path;
+       gchar *dest_id = NULL;
 
        if (!window)
                import_create();
@@ -76,13 +76,13 @@ gint import_mbox(FolderItem *default_dest)
                gtk_widget_show(window);
 
        gtk_entry_set_text(GTK_ENTRY(file_entry), "");
+       if (default_dest && default_dest->path)
+               dest_id = folder_item_get_identifier(default_dest);
 
-       if (default_dest) { 
-               path = folder_item_get_identifier(default_dest);
-               gtk_entry_set_text(GTK_ENTRY(dest_entry), path);
-               g_free(path);
-       }       
-       else
+       if (dest_id) {
+               gtk_entry_set_text(GTK_ENTRY(dest_entry), dest_id);
+               g_free(dest_id);
+       } else
                gtk_entry_set_text(GTK_ENTRY(dest_entry), "");
        gtk_widget_grab_focus(file_entry);
 
@@ -100,7 +100,8 @@ gint import_mbox(FolderItem *default_dest)
                        if (!destdir || !*destdir) {
                                dest = folder_find_item_from_path(INBOX_DIR);
                        } else
-                               dest = folder_find_item_from_identifier(destdir);
+                               dest = folder_find_item_from_identifier
+                                       (destdir);
 
                        if (!dest) {
                                g_warning("Can't find the folder.\n");
index 5ff2d83..aed7c6e 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -145,7 +145,7 @@ static void inc_finished(MainWindow *mainwin, gboolean new_messages)
 
        if (prefs_common.open_inbox_on_inc) {
                item = cur_account && cur_account->inbox
-                       ? folder_find_item_from_path(cur_account->inbox)
+                       ? folder_find_item_from_identifier(cur_account->inbox)
                        : folder_get_default_inbox();
                if (FOLDER_SUMMARY_MISMATCH(item, mainwin->summaryview)) {      
                        folderview_unselect(mainwin->folderview);
@@ -1016,7 +1016,8 @@ gint inc_drop_message(const gchar *file, Pop3State *state)
        /* CLAWS: get default inbox (perhaps per account) */
        if (state->ac_prefs->inbox) {
                /* CLAWS: get destination folder / mailbox */
-               inbox = folder_find_item_from_identifier(state->ac_prefs->inbox);
+               inbox = folder_find_item_from_identifier
+                       (state->ac_prefs->inbox);
                if (!inbox)
                        inbox = folder_get_default_inbox();
        } else
index 40c94af..eace8b9 100644 (file)
@@ -757,11 +757,16 @@ static gint prefs_filter_clist_set_row(gint row)
 static void prefs_filter_select_dest_cb(void)
 {
        FolderItem *dest;
+       gchar *id;
 
        dest = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL);
-       if (!dest) return;
+       if (!dest || !dest->path) return;
 
-       gtk_entry_set_text(GTK_ENTRY(filter.dest_entry), dest->path);
+       id = folder_item_get_identifier(dest);
+       if (id) {
+               gtk_entry_set_text(GTK_ENTRY(filter.dest_entry), id);
+               g_free(id);
+       }
 }
 
 static void prefs_filter_register_cb(void)