2011-07-05 [mones] 3.7.9cvs32
authorRicardo Mones <mones@claws-mail.org>
Tue, 5 Jul 2011 17:37:14 +0000 (17:37 +0000)
committerRicardo Mones <mones@claws-mail.org>
Tue, 5 Jul 2011 17:37:14 +0000 (17:37 +0000)
* src/imap.c
* src/common/tags.c
* src/common/tags.h
* src/etpan/imap-thread.c
Make constants for reserved tags and use them
Removed also duplicate comparison while at it

ChangeLog
PATCHSETS
configure.ac
src/common/tags.c
src/common/tags.h
src/etpan/imap-thread.c
src/imap.c

index 191b7f6..5b0b9d9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-07-05 [mones]     3.7.9cvs32
+
+       * src/imap.c
+       * src/common/tags.c
+       * src/common/tags.h
+       * src/etpan/imap-thread.c
+               Make constants for reserved tags and use them
+               Removed also duplicate comparison while at it
+
 2011-07-05 [paul]      3.7.9cvs31
 
        * src/compose.c
index 85f7302..b17a440 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.2.83 -r 1.1.2.84 src/wizard.c;  ) > 3.7.9cvs29.patchset
 ( cvs diff -u -r 1.115.2.238 -r 1.115.2.239 src/main.c;  ) > 3.7.9cvs30.patchset
 ( cvs diff -u -r 1.382.2.576 -r 1.382.2.577 src/compose.c;  ) > 3.7.9cvs31.patchset
+( cvs diff -u -r 1.179.2.255 -r 1.179.2.256 src/imap.c;  cvs diff -u -r 1.1.2.11 -r 1.1.2.12 src/common/tags.c;  cvs diff -u -r 1.1.2.6 -r 1.1.2.7 src/common/tags.h;  cvs diff -u -r 1.1.4.113 -r 1.1.4.114 src/etpan/imap-thread.c;  ) > 3.7.9cvs32.patchset
index f081ba2..964b0cf 100644 (file)
@@ -12,7 +12,7 @@ MINOR_VERSION=7
 MICRO_VERSION=9
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=31
+EXTRA_VERSION=32
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 4da6d0b..953836f 100644 (file)
@@ -38,6 +38,7 @@
 
 #include "defs.h"
 #include "utils.h"
+#include "tags.h"
 
 static GHashTable *tags_table = NULL;
 static GHashTable *tags_reverse_table = NULL;
@@ -77,11 +78,7 @@ void tags_read_tags(void)
                        continue;
                g_strstrip(tag_name);
                *(sep) = '\0';
-               if (strcmp(tag_name, "NonJunk") && 
-                   strcmp(tag_name, "NotJunk") && 
-                   strcmp(tag_name, "NoJunk") && 
-                   strcmp(tag_name, "$Forwarded") && 
-                   strcmp(tag_name, "Junk")) {
+               if (IS_NOT_RESERVED_TAG(tag_name)) {
                        id = atoi(tmp);
                        g_hash_table_insert(tags_table,
                                            GINT_TO_POINTER(id), g_strdup(tag_name));
@@ -171,11 +168,7 @@ gint tags_add_tag(const gchar *tag)
        if (g_hash_table_lookup(tags_reverse_table, tag))
                return -1;
 
-       if (strcmp(tag, "NonJunk") && 
-           strcmp(tag, "NotJunk") && 
-           strcmp(tag, "NoJunk") && 
-           strcmp(tag, "$Forwarded") && 
-           strcmp(tag, "Junk")) {
+       if (IS_NOT_RESERVED_TAG(tag)) {
                tag_max_id++;
                g_hash_table_insert(tags_table, GINT_TO_POINTER(tag_max_id), 
                        g_strdup(tag));
@@ -205,11 +198,7 @@ void tags_update_tag(gint id, const gchar *tag)
 {
        gchar *old_tag = g_hash_table_lookup(tags_table, GINT_TO_POINTER(id));
 
-       if (strcmp(tag, "NonJunk") && 
-           strcmp(tag, "NotJunk") && 
-           strcmp(tag, "NoJunk") && 
-           strcmp(tag, "$Forwarded") && 
-           strcmp(tag, "Junk")) {
+       if (IS_NOT_RESERVED_TAG(tag)) {
                if (old_tag) {
                        prefs_filtering_rename_tag(old_tag, tag);
                        g_hash_table_remove(tags_reverse_table, old_tag);
index 985b2be..39978ec 100644 (file)
 
 #include <glib.h>
 
+/* Reserved tags */
+#define RTAG_NON_JUNK "NonJunk"
+#define RTAG_NOT_JUNK "NotJunk"
+#define RTAG_NO_JUNK "NoJunk"
+#define RTAG_JUNK "Junk"
+#define RTAG_FORWARDED "$Forwarded"
+
+#define IS_NOT_RESERVED_TAG(tag) \
+       (strcmp((tag), "NonJunk") && \
+         strcmp((tag), "NotJunk") && \
+         strcmp((tag), "NoJunk") && \
+         strcmp((tag), "Junk") && \
+         strcmp((tag), "$Forwarded")) 
+
 void tags_read_tags(void);
 void tags_write_tags(void);
 gint tags_add_tag(const gchar *tag);
index ece7d0e..1f30be2 100644 (file)
@@ -44,6 +44,7 @@
 #include "ssl_certificate.h"
 #include "socket.h"
 #include "remotefolder.h"
+#include "tags.h"
 
 #define DISABLE_LOG_DURING_LOGIN
 
@@ -1456,13 +1457,13 @@ int imap_threaded_select(Folder * folder, const char * mb,
                                        c_flag = IMAP_FLAG_SEEN;
                                        break;
                                case MAILIMAP_FLAG_KEYWORD:
-                                       if (!strcasecmp(flag->fl_flag->fl_data.fl_keyword, "$Forwarded"))
+                                       if (!strcasecmp(flag->fl_flag->fl_data.fl_keyword, RTAG_FORWARDED))
                                                c_flag = IMAP_FLAG_FORWARDED;
-                                       if (!strcasecmp(flag->fl_flag->fl_data.fl_keyword, "Junk"))
+                                       if (!strcasecmp(flag->fl_flag->fl_data.fl_keyword, RTAG_JUNK))
                                                c_flag = IMAP_FLAG_SPAM;
-                                       if (!strcasecmp(flag->fl_flag->fl_data.fl_keyword, "NonJunk") ||
-                                           !strcasecmp(flag->fl_flag->fl_data.fl_keyword, "NoJunk") ||
-                                           !strcasecmp(flag->fl_flag->fl_data.fl_keyword, "NotJunk"))
+                                       if (!strcasecmp(flag->fl_flag->fl_data.fl_keyword, RTAG_NON_JUNK) ||
+                                           !strcasecmp(flag->fl_flag->fl_data.fl_keyword, RTAG_NO_JUNK) ||
+                                           !strcasecmp(flag->fl_flag->fl_data.fl_keyword, RTAG_NOT_JUNK))
                                                c_flag = IMAP_FLAG_HAM;
                                        break;
                                default:
@@ -1685,7 +1686,7 @@ static void search_run(struct etpan_thread_op * op)
        case IMAP_SEARCH_TYPE_FORWARDED:
                search_type_key = mailimap_search_key_new(MAILIMAP_SEARCH_KEY_KEYWORD,
                                                          NULL, NULL, NULL, NULL, NULL,
-                                                         strdup("$Forwarded"), NULL, NULL, NULL, NULL,
+                                                         strdup(RTAG_FORWARDED), NULL, NULL, NULL, NULL,
                                                          NULL, NULL, NULL, NULL, 0,
                                                          NULL, NULL, NULL, NULL, NULL,
                                                          NULL, 0, NULL, NULL, NULL);
@@ -1693,7 +1694,7 @@ static void search_run(struct etpan_thread_op * op)
        case IMAP_SEARCH_TYPE_SPAM:
                search_type_key = mailimap_search_key_new(MAILIMAP_SEARCH_KEY_KEYWORD,
                                                          NULL, NULL, NULL, NULL, NULL,
-                                                         strdup("Junk"), NULL, NULL, NULL, NULL,
+                                                         strdup(RTAG_JUNK), NULL, NULL, NULL, NULL,
                                                          NULL, NULL, NULL, NULL, 0,
                                                          NULL, NULL, NULL, NULL, NULL,
                                                          NULL, 0, NULL, NULL, NULL);
@@ -2566,13 +2567,13 @@ static int imap_flags_to_flags(struct mailimap_msg_att_dynamic * att_dyn, GSList
                                flags &= ~MSG_NEW;
                                break;
                        case MAILIMAP_FLAG_KEYWORD:
-                               if (!strcasecmp(flag_fetch->fl_flag->fl_data.fl_keyword, "$Forwarded"))
+                               if (!strcasecmp(flag_fetch->fl_flag->fl_data.fl_keyword, RTAG_FORWARDED))
                                        flags |= MSG_FORWARDED;
-                               else if (!strcasecmp(flag_fetch->fl_flag->fl_data.fl_keyword, "Junk")) 
+                               else if (!strcasecmp(flag_fetch->fl_flag->fl_data.fl_keyword, RTAG_JUNK)) 
                                        flags |= MSG_SPAM;
-                               else if (!strcasecmp(flag_fetch->fl_flag->fl_data.fl_keyword, "NonJunk") ||
-                                        !strcasecmp(flag_fetch->fl_flag->fl_data.fl_keyword, "NoJunk") ||
-                                        !strcasecmp(flag_fetch->fl_flag->fl_data.fl_keyword, "NotJunk")) 
+                               else if (!strcasecmp(flag_fetch->fl_flag->fl_data.fl_keyword, RTAG_NON_JUNK) ||
+                                        !strcasecmp(flag_fetch->fl_flag->fl_data.fl_keyword, RTAG_NO_JUNK) ||
+                                        !strcasecmp(flag_fetch->fl_flag->fl_data.fl_keyword, RTAG_NOT_JUNK)) 
                                        flags &= ~MSG_SPAM;
                                else if (s_tags)
                                        tags = g_slist_prepend(tags, g_strdup(flag_fetch->fl_flag->fl_data.fl_keyword));
index 3fcd7d6..939d1e6 100644 (file)
@@ -1364,7 +1364,7 @@ static void imap_commit_tags(FolderItem *item, MsgInfo *msginfo, GSList *tags_se
                for (cur = tags_set; cur; cur = cur->next) {
                        gint cur_tag = GPOINTER_TO_INT(cur->data);
                        const gchar *str = tags_get_tag(cur_tag);
-                       if (strcmp(str, "$Forwarded") && strcmp(str, "Junk") && strcmp(str, "NonJunk") && strcmp(str, "NotJunk") && strcmp(str, "NoJunk") && strcmp(str, "Junk") )
+                       if (IS_NOT_RESERVED_TAG(str))
                                list_set = g_slist_prepend(list_set, g_strdup(str));
                }
                if (list_set) {
@@ -1380,7 +1380,7 @@ static void imap_commit_tags(FolderItem *item, MsgInfo *msginfo, GSList *tags_se
                for (cur = tags_unset; cur; cur = cur->next) {
                        gint cur_tag = GPOINTER_TO_INT(cur->data);
                        const gchar *str = tags_get_tag(cur_tag);
-                       if (strcmp(str, "$Forwarded") && strcmp(str, "Junk") && strcmp(str, "NonJunk") && strcmp(str, "NotJunk") && strcmp(str, "NoJunk") && strcmp(str, "Junk") )
+                       if (IS_NOT_RESERVED_TAG(str))
                                list_unset = g_slist_prepend(list_unset, g_strdup(str));
                }
                if (list_unset) {
@@ -5380,13 +5380,13 @@ static struct mailimap_flag_list * imap_flag_to_lep(IMAPFolderItem *item, IMAPFl
                                       mailimap_flag_new_draft());
        if (IMAP_IS_FORWARDED(flags) && flag_ok(item, IMAP_FLAG_FORWARDED))
                mailimap_flag_list_add(flag_list,
-                                      mailimap_flag_new_flag_keyword(strdup("$Forwarded")));
+                                      mailimap_flag_new_flag_keyword(strdup(RTAG_FORWARDED)));
        if (IMAP_IS_SPAM(flags) && flag_ok(item, IMAP_FLAG_SPAM))
                mailimap_flag_list_add(flag_list,
-                                      mailimap_flag_new_flag_keyword(strdup("Junk")));
+                                      mailimap_flag_new_flag_keyword(strdup(RTAG_JUNK)));
        else if (IMAP_IS_HAM(flags) && flag_ok(item, IMAP_FLAG_HAM))
                mailimap_flag_list_add(flag_list,
-                                      mailimap_flag_new_flag_keyword(strdup("NonJunk")));
+                                      mailimap_flag_new_flag_keyword(strdup(RTAG_NON_JUNK)));
        
        for (; cur; cur = cur->next) {
                gchar *enc_str =