got back the function addressbook_browse_entry_cb() that is needed in case we compile...
authorHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Thu, 4 Dec 2003 14:05:56 +0000 (14:05 +0000)
committerHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Thu, 4 Dec 2003 14:05:56 +0000 (14:05 +0000)
14 files changed:
ChangeLog.claws
configure.ac
src/addressbook.c
src/filtering.c
src/filtering.h
src/folder.c
src/folderview.c
src/mainwindow.c
src/matcher.c
src/matcher_parser_parse.y
src/messageview.c
src/prefs_filtering.c
src/prefs_filtering.h
src/summaryview.c

index 27f6521..e917ed5 100644 (file)
@@ -1,3 +1,26 @@
+2003-12-04 [hoa]       0.9.7claws20
+
+       * src/filtering.[ch]
+       * src/folder.c
+       * src/mainwindow.c
+       * src/matcher.c
+       * src/matcher_parser_parse.y
+       * src/folderview.c
+               global rules to run before folder specific rules.
+               global rules to run after folder specific rules.
+               
+       * src/messageview.c
+               fixed quick addition of rules.
+       
+       * src/prefs_filtering.[ch]
+       * src/summaryview.c
+               we can now customize the title for the dialog.
+               updated case where we rename of delete folders.
+
+       * src/addressbook.c
+               got back the function addressbook_browse_entry_cb()
+               that is needed in case we compiled with LDAP support.
+
 2003-12-04 [paul]      0.9.7claws19
 
        * sync with 0.9.7cvs6
index 866e0d1..8690cd4 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=7
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=19
+EXTRA_VERSION=20
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index f4269d7..29c937b 100644 (file)
@@ -3686,6 +3686,59 @@ static void addressbook_lup_clicked( GtkButton *button, gpointer data ) {
        g_free( searchTerm );
 }
 
+/**
+ * Browse address entry for highlighted entry.
+ */
+#ifdef USE_LDAP
+static void addressbook_browse_entry_cb(void)
+{
+       GtkCTree *clist = GTK_CTREE(addrbook.clist);
+       AddressObject *obj;
+       AddressDataSource *ds;
+       AddressInterface *iface;
+       ItemPerson *person;
+       ItemEMail *email;
+
+       if(addrbook.listSelected == NULL)
+               return;
+       
+       obj = gtk_ctree_node_get_row_data(clist, addrbook.listSelected);
+       if (obj == NULL)
+               return;
+       
+       ds = addressbook_find_datasource(GTK_CTREE_NODE(addrbook.treeSelected));
+       if(ds == NULL)
+               return;
+       
+       iface = ds->interface;
+       if(iface->haveLibrary == NULL)
+               return;
+       
+       person = NULL;
+       if (obj->type == ADDR_ITEM_EMAIL) {
+               email = ( ItemEMail * ) obj;
+               if (email == NULL)
+                       return;
+               
+               person = (ItemPerson *) ADDRITEM_PARENT(email);
+       }
+       else if (obj->type == ADDR_ITEM_PERSON) {
+               person = (ItemPerson *) obj;
+       }
+       else {
+               /* None of these */
+               return;
+       }
+
+       if( iface->type == ADDR_IF_LDAP ) {
+#ifdef USE_LDAP
+               browseldap_entry(ds, person->externalID);
+#endif
+       }
+}
+#endif
+
+
 /* **********************************************************************
 * Build lookup tables.
 * ***********************************************************************
index 22369ec..bf516d2 100644 (file)
@@ -34,7 +34,8 @@
 
 #define PREFSBUFSIZE           1024
 
-GSList * global_processing = NULL;
+GSList * pre_global_processing = NULL;
+GSList * post_global_processing = NULL;
 GSList * filtering_rules = NULL;
 
 static gboolean filtering_is_final_action(FilteringAction *filtering_action);
@@ -550,8 +551,10 @@ void prefs_filtering_clear(void)
 
        prefs_filtering_free(filtering_rules);
        filtering_rules = NULL;
-       prefs_filtering_free(global_processing);
-       global_processing = NULL;
+       prefs_filtering_free(pre_global_processing);
+       pre_global_processing = NULL;
+       prefs_filtering_free(post_global_processing);
+       post_global_processing = NULL;
 }
 
 void prefs_filtering_clear_folder(Folder *folder)
index c6381d4..61425b6 100644 (file)
@@ -75,6 +75,7 @@ void prefs_filtering_free(GSList *prefs_filtering);
 FilteringProp * filteringprop_copy(FilteringProp *src);
 
 extern GSList * filtering_rules;
-extern GSList * global_processing;
+extern GSList * pre_global_processing;
+extern GSList * post_global_processing;
 
 #endif
index d6d261f..a7f965a 100644 (file)
@@ -2881,11 +2881,14 @@ void folder_item_apply_processing(FolderItem *item)
                 msginfo->hidden = 0;
                 msginfo->score = 0;
                 
-                /* apply global rules */
-               filter_message_by_msginfo(global_processing, msginfo);
+                /* apply pre global rules */
+               filter_message_by_msginfo(pre_global_processing, msginfo);
                 
                 /* apply rules of the folder */
                filter_message_by_msginfo(processing_list, msginfo);
+
+                /* apply post global rules */
+               filter_message_by_msginfo(post_global_processing, msginfo);
                 
                procmsg_msginfo_free(msginfo);
        }
index ad91e16..3474423 100644 (file)
@@ -2620,7 +2620,8 @@ static void folderview_processing_cb(FolderView *folderview, guint action,
        g_return_if_fail(item != NULL);
        g_return_if_fail(item->folder != NULL);
 
-       prefs_filtering_open(&item->prefs->processing, NULL, NULL);
+       prefs_filtering_open(&item->prefs->processing,
+                            _("Processing configuration"), NULL, NULL);
 }
 
 void folderview_set_target_folder_color(gint color_op) 
index fe65d04..01c39cf 100644 (file)
@@ -357,9 +357,13 @@ static void prefs_account_open_cb  (MainWindow     *mainwin,
                                         guint           action,
                                         GtkWidget      *widget);
 
-static void prefs_processing_open_cb   (MainWindow     *mainwin,
-                                        guint           action,
-                                        GtkWidget      *widget);
+static void prefs_pre_processing_open_cb  (MainWindow  *mainwin,
+                                          guint         action,
+                                          GtkWidget    *widget);
+
+static void prefs_post_processing_open_cb (MainWindow  *mainwin,
+                                          guint         action,
+                                          GtkWidget    *widget);
 
 static void prefs_filtering_open_cb    (MainWindow     *mainwin,
                                         guint           action,
@@ -691,8 +695,10 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_Configuration/---"),             NULL, NULL, 0, "<Separator>"},
        {N_("/_Configuration/_Common preferences..."),
                                                NULL, prefs_common_open_cb, 0, NULL},
-       {N_("/_Configuration/Processing..."),
-                                               NULL, prefs_processing_open_cb, 0, NULL},
+       {N_("/_Configuration/Pre processing..."),
+                                               NULL, prefs_pre_processing_open_cb, 0, NULL},
+       {N_("/_Configuration/Post processing..."),
+                                               NULL, prefs_post_processing_open_cb, 0, NULL},
        {N_("/_Configuration/_Filtering..."),
                                                NULL, prefs_filtering_open_cb, 0, NULL},
        {N_("/_Configuration/_Templates..."),   NULL, prefs_template_open_cb, 0, NULL},
@@ -2676,16 +2682,28 @@ static void prefs_common_open_cb(MainWindow *mainwin, guint action,
        prefs_common_open();
 }
 
-static void prefs_processing_open_cb(MainWindow *mainwin, guint action,
-                                 GtkWidget *widget)
+static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
+                                        GtkWidget *widget)
+{
+       prefs_filtering_open(&pre_global_processing,
+                            _("Processing rules to apply before folder rules"),
+                            NULL, NULL);
+}
+
+static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
+                                         GtkWidget *widget)
 {
-       prefs_filtering_open(&global_processing, NULL, NULL);
+       prefs_filtering_open(&post_global_processing,
+                            _("Processing rules to apply after folder rules"),
+                            NULL, NULL);
 }
 
 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
                                    GtkWidget *widget)
 {
-       prefs_filtering_open(&filtering_rules, NULL, NULL);
+       prefs_filtering_open(&filtering_rules,
+                            _("Filtering configuration"),
+                            NULL, NULL);
 }
 
 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
index 437fc02..edaffe1 100644 (file)
@@ -1449,9 +1449,14 @@ static void prefs_matcher_save(FILE *fp)
                                prefs_matcher_write_func, fp);
        }
         
-        /* global rules */
-        fprintf(fp, "[global]\n");
-        prefs_filtering_write(fp, global_processing);
+        /* pre global rules */
+        fprintf(fp, "[preglobal]\n");
+        prefs_filtering_write(fp, pre_global_processing);
+        fputc('\n', fp);
+
+        /* post global rules */
+        fprintf(fp, "[postglobal]\n");
+        prefs_filtering_write(fp, post_global_processing);
         fputc('\n', fp);
         
         /* filtering rules */
index b96fa24..b11fc2d 100644 (file)
@@ -51,15 +51,16 @@ static FilteringAction *action = NULL;
 static FilteringProp *filtering;
 
 static GSList **prefs_filtering = NULL;
+static int enable_compatibility = 0;
 
 enum {
-        MATCHER_PARSE_NONE,
+        MATCHER_PARSE_FILE,
         MATCHER_PARSE_NO_EOL,
         MATCHER_PARSE_CONDITION,
         MATCHER_PARSE_FILTERING_ACTION,
 };
 
-static int matcher_parse_op = MATCHER_PARSE_NONE;
+static int matcher_parse_op = MATCHER_PARSE_FILE;
 
 
 /* ******************************************************************** */
@@ -87,7 +88,7 @@ FilteringProp *matcher_parser_get_filtering(gchar *str)
         matcher_parser_switch_to_buffer(bufstate);
        if (matcher_parserparse() != 0)
                filtering = NULL;
-       matcher_parse_op = MATCHER_PARSE_NONE;
+       matcher_parse_op = MATCHER_PARSE_FILE;
        matcher_parser_delete_buffer(bufstate);
        return filtering;
 }
@@ -128,7 +129,7 @@ MatcherList *matcher_parser_get_cond(gchar *str)
         matcher_parser_init();
        bufstate = matcher_parser_scan_string(str);
        matcher_parserparse();
-       matcher_parse_op = MATCHER_PARSE_NONE;
+       matcher_parse_op = MATCHER_PARSE_FILE;
        matcher_parser_delete_buffer(bufstate);
        return cond;
 }
@@ -150,7 +151,7 @@ GSList *matcher_parser_get_action_list(gchar *str)
         matcher_parser_init();
        bufstate = matcher_parser_scan_string(str);
        matcher_parserparse();
-       matcher_parse_op = MATCHER_PARSE_NONE;
+       matcher_parse_op = MATCHER_PARSE_FILE;
        matcher_parser_delete_buffer(bufstate);
        return action_list;
 }
@@ -248,8 +249,8 @@ int matcher_parserwrap(void)
 
 file:
 {
-       if (matcher_parse_op == MATCHER_PARSE_NONE) {
-               prefs_filtering = &global_processing;
+       if (matcher_parse_op == MATCHER_PARSE_FILE) {
+               prefs_filtering = &pre_global_processing;
        }
 }
 file_line_list;
@@ -276,9 +277,17 @@ MATCHER_SECTION MATCHER_EOL
        gchar *folder = $1;
        FolderItem *item = NULL;
 
-       if (matcher_parse_op == MATCHER_PARSE_NONE) {
+       if (matcher_parse_op == MATCHER_PARSE_FILE) {
+                enable_compatibility = 0;
                if (!strcmp(folder, "global")) {
-                       prefs_filtering = &global_processing;
+                        /* backward compatibility */
+                        enable_compatibility = 1;
+                }
+               else if (!strcmp(folder, "preglobal")) {
+                       prefs_filtering = &pre_global_processing;
+                }
+               else if (!strcmp(folder, "postglobal")) {
+                       prefs_filtering = &post_global_processing;
                 }
                else if (!strcmp(folder, "filtering")) {
                         prefs_filtering = &filtering_rules;
@@ -331,9 +340,23 @@ filtering:
 filtering_action_list
 {
        filtering = filteringprop_new(cond, action_list);
+        
+        if (enable_compatibility) {
+                prefs_filtering = &filtering_rules;
+                if (action_list != NULL) {
+                        FilteringAction * first_action;
+                        
+                        first_action = action_list->data;
+                        
+                        if (first_action->type == MATCHACTION_ADD_SCORE)
+                                prefs_filtering = &pre_global_processing;
+                }
+        }
+        
        cond = NULL;
        action_list = NULL;
-       if ((matcher_parse_op == MATCHER_PARSE_NONE) &&
+        
+       if ((matcher_parse_op == MATCHER_PARSE_FILE) &&
             (prefs_filtering != NULL)) {
                *prefs_filtering = g_slist_append(*prefs_filtering,
                                                  filtering);
index 2eacc02..d0ad10b 100644 (file)
@@ -61,6 +61,7 @@
 #include "send_message.h"
 #include "stock_pixmap.h"
 #include "hooks.h"
+#include "filtering.h"
 
 static GList *messageview_list = NULL;
 
@@ -1302,12 +1303,22 @@ static void create_filter_cb(gpointer data, guint action, GtkWidget *widget)
        MessageView *messageview = (MessageView *)data;
        gchar *header = NULL;
        gchar *key = NULL;
-
+       FolderItem * item;
+       
        if (!messageview->msginfo) return;
 
        procmsg_get_filter_keyword(messageview->msginfo, &header, &key,
                                   (PrefsFilterType)action);
-       prefs_filtering_open(NULL, header, key);
+       
+       item = messageview->msginfo->folder;
+       if (item == NULL)
+               prefs_filtering_open(&pre_global_processing,
+                                    _("Processing rules to apply before folder rules"),
+                                    header, key);
+       else
+               prefs_filtering_open(&item->prefs->processing,
+                                    _("Processing configuration"),
+                                    header, key);
 
        g_free(header);
        g_free(key);
index afb344a..51db83a 100644 (file)
@@ -104,6 +104,7 @@ static gboolean prefs_filtering_delete_path_func(GNode *node, gpointer data);
 static GSList ** p_processing_list = NULL;
 
 void prefs_filtering_open(GSList ** p_processing,
+                         const gchar * title,
                          const gchar *header,
                          const gchar *key)
 {
@@ -120,9 +121,15 @@ void prefs_filtering_open(GSList ** p_processing,
 
        manage_window_set_transient(GTK_WINDOW(filtering.window));
        gtk_widget_grab_focus(filtering.ok_btn);
-
+       
+       if (title != NULL)
+               gtk_window_set_title(GTK_WINDOW(filtering.window), title);
+       else
+               gtk_window_set_title (GTK_WINDOW(filtering.window),
+                                     _("Filtering/Processing configuration"));
+       
        esckey = matcher_escape_str(key);
-
+       
         p_processing_list = p_processing;
         
        prefs_filtering_set_dialog(header, esckey);
@@ -367,25 +374,32 @@ static void prefs_filtering_update_hscrollbar(void)
        gtk_clist_set_column_width(GTK_CLIST(filtering.cond_clist), 0, optwidth);
 }
 
+static void rename_path(GSList * filters,
+                       const gchar * old_path, const gchar * new_path);
+
 void prefs_filtering_rename_path(const gchar *old_path, const gchar *new_path)
 {
        GList * cur;
-       gchar *paths[2] = {NULL, NULL};
-       paths[0] = (gchar*)old_path;
-       paths[1] = (gchar*)new_path;
+       const gchar *paths[2] = {NULL, NULL};
+       paths[0] = old_path;
+       paths[1] = new_path;
        for (cur = folder_get_list() ; cur != NULL ; cur = g_list_next(cur)) {
                Folder *folder;
                folder = (Folder *) cur->data;
                g_node_traverse(folder->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
                                prefs_filtering_rename_path_func, paths);
        }
-       prefs_filtering_rename_path_func(NULL, paths);
+        
+       rename_path(pre_global_processing, old_path, new_path);
+       rename_path(post_global_processing, old_path, new_path);
+       rename_path(filtering_rules, old_path, new_path);
+        
+       prefs_matcher_write_config();
 }
 
-static gboolean prefs_filtering_rename_path_func(GNode *node, gpointer data)
+static void rename_path(GSList * filters,
+                       const gchar * old_path, const gchar * new_path)
 {
-       GSList *cur;
-       gchar *old_path, *new_path;
        gchar *base;
        gchar *prefix;
        gchar *suffix;
@@ -396,26 +410,12 @@ static gboolean prefs_filtering_rename_path_func(GNode *node, gpointer data)
        gint oldpathlen;
        FolderItem *item;
         GSList * action_cur;
-
-       old_path = ((gchar **)data)[0];
-       new_path = ((gchar **)data)[1];
-
-       g_return_val_if_fail(old_path != NULL, FALSE);
-       g_return_val_if_fail(new_path != NULL, FALSE);
+        GSList * cur;
 
        oldpathlen = strlen(old_path);
        old_path_with_sep = g_strconcat(old_path,G_DIR_SEPARATOR_S,NULL);
-       if (node == NULL)
-               cur = global_processing;
-       else {
-               item = node->data;
-               if (!item || !item->prefs) 
-                       return FALSE;
-               cur = item->prefs->processing;
-       }
-
 
-       for (; cur != NULL; cur = cur->next) {
+       for (cur = filters; cur != NULL; cur = cur->next) {
                FilteringProp   *filtering = (FilteringProp *)cur->data;
                 
                 for(action_cur = filtering->action_list ; action_cur != NULL ;
@@ -465,7 +465,7 @@ static gboolean prefs_filtering_rename_path_func(GNode *node, gpointer data)
                                 }
                         } else {
                                 /* folder-moving a leaf */
-                                if (!strcmp(old_path, action->destination)) {          
+                                if (!strcmp(old_path, action->destination)) {
                                         dest_path = g_strdup(new_path);
                                         g_free(action->destination);
                                         action->destination = dest_path;
@@ -473,13 +473,36 @@ static gboolean prefs_filtering_rename_path_func(GNode *node, gpointer data)
                         }
                 }
         }
+}
+
+static gboolean prefs_filtering_rename_path_func(GNode *node, gpointer data)
+{
+       GSList *filters;
+       const gchar * old_path;
+        const gchar * new_path;
+        const gchar ** paths;
+       FolderItem *item;
         
-       g_free(old_path_with_sep);
-       prefs_matcher_write_config();
+        paths = data;
+       old_path = paths[0];
+       new_path = paths[1];
+
+       g_return_val_if_fail(old_path != NULL, FALSE);
+       g_return_val_if_fail(new_path != NULL, FALSE);
+       g_return_val_if_fail(node != NULL, FALSE);
+
+        item = node->data;
+        if (!item || !item->prefs)
+                return FALSE;
+        filters = item->prefs->processing;
+
+        rename_path(filters, old_path, new_path);
 
        return FALSE;
 }
 
+static void delete_path(GSList ** p_filters, const gchar * path);
+
 void prefs_filtering_delete_path(const gchar *path)
 {
        GList * cur;
@@ -489,32 +512,26 @@ void prefs_filtering_delete_path(const gchar *path)
                g_node_traverse(folder->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
                                prefs_filtering_delete_path_func, (gchar *)path);
        }
-       prefs_filtering_delete_path_func(NULL, (gchar *)path);
+        delete_path(&pre_global_processing, path);
+        delete_path(&post_global_processing, path);
+        delete_path(&filtering_rules, path);
+        
+       prefs_matcher_write_config();
 }
 
-static gboolean prefs_filtering_delete_path_func(GNode *node, gpointer data)
+static void delete_path(GSList ** p_filters, const gchar * path)
 {
-       GSList *cur, *filters, *duplist;
-       gchar *path = (gchar *) data;
+        GSList * filters;
+        GSList * duplist;
        gchar *suffix;
        gint destlen;
        gint prefixlen;
        gint pathlen;
        FolderItem *item;
         GSList * action_cur;
-       
-       g_return_val_if_fail(path != NULL, FALSE);
-
+       GSList * cur;
+        
        pathlen = strlen(path);
-       if (node == NULL)
-               filters = global_processing;
-       else {
-               item = node->data;
-               if (!item || !item->prefs)
-                       return FALSE;
-               filters = item->prefs->processing;
-       }
-
        duplist = g_slist_copy(filters);
        for (cur = duplist ; cur != NULL; cur = g_slist_next(cur)) {
                FilteringProp *filtering = (FilteringProp *) cur->data;
@@ -545,17 +562,25 @@ static gboolean prefs_filtering_delete_path_func(GNode *node, gpointer data)
                 }
         }                
        g_slist_free(duplist);
+        
+        * p_filters = filters;
+}
 
-        if (node == NULL)
-                global_processing = filters;
-        else {
-                item = node->data;
-                if (!item || !item->prefs)
-                       return FALSE;
-                item->prefs->processing = filters;
-        }
+static gboolean prefs_filtering_delete_path_func(GNode *node, gpointer data)
+{
+       const gchar *path = data;
+       FolderItem *item;
+        GSList ** p_filters;
+       
+       g_return_val_if_fail(path != NULL, FALSE);
+       g_return_val_if_fail(node != NULL, FALSE);
+
+        item = node->data;
+        if (!item || !item->prefs)
+                return FALSE;
+        p_filters = &item->prefs->processing;
         
-       prefs_matcher_write_config();
+        delete_path(p_filters, path);
 
        return FALSE;
 }
index a4183ba..71d61c6 100644 (file)
@@ -39,8 +39,9 @@ typedef enum
 #include "folder.h"
 
 void prefs_filtering_open(GSList ** p_processing,
-                          const gchar *header,
-                          const gchar *key);
+                         const gchar * title,
+                         const gchar *header,
+                         const gchar *key);
 
 void prefs_filtering_rename_path       (const gchar    *old_path,
                                         const gchar    *new_path);
index 35eaed7..a1ddddf 100644 (file)
@@ -4018,7 +4018,8 @@ void summary_filter_open(SummaryView *summaryview, PrefsFilterType type)
        MsgInfo *msginfo;
        gchar *header = NULL;
        gchar *key = NULL;
-
+       FolderItem * item;
+       
        if (!summaryview->selected) return;
 
        msginfo = gtk_ctree_node_get_row_data(GTK_CTREE(summaryview->ctree),
@@ -4026,7 +4027,16 @@ void summary_filter_open(SummaryView *summaryview, PrefsFilterType type)
        if (!msginfo) return;
 
        procmsg_get_filter_keyword(msginfo, &header, &key, type);
-       prefs_filtering_open(NULL, header, key);
+       
+       item = summaryview->folder_item;
+       if (item == NULL)
+               prefs_filtering_open(&pre_global_processing,
+                                    _("Processing rules to apply before folder rules"),
+                                    header, key);
+       else
+               prefs_filtering_open(&item->prefs->processing,
+                                    _("Processing configuration"),
+                                    header, key);
 
        g_free(header);
        g_free(key);