[FILTERS] : next patchs



	Hi all,
after having compiled carefully with all warnings enabled (what I've 
forgotten before alas), I found a lot of small bugs (almost warnings, 
but also several actual bugs). So for the braves who are trying my 
patchs found on christophe's site (URL given in previous post from him) 
here are two patches : new_libbalsa.patch and new_src.patch to apply on 
the corresponding directories (after the aboe mentionned patches).
I apologize for the bugs, I hope it will at least compile now :)
Bye
Manu
diff -u ../balsa-1.1.7-manu-sync/libbalsa/filter-file.c libbalsa/filter-file.c
--- ../balsa-1.1.7-manu-sync/libbalsa/filter-file.c	Wed Aug  1 10:07:39 2001
+++ libbalsa/filter-file.c	Thu Aug  2 15:40:35 2001
@@ -133,7 +133,6 @@
 
 filter * libbalsa_filter_new_from_config(gchar * prefix,gchar * name)
 {
-    gchar * str;
     filter * newf = NULL;
 
     newf=filter_new();
@@ -146,7 +145,7 @@
 
     /* First we load the fixed part of the filter */
     newf->name=name;
-    newf->sound==gnome_config_get_string("Sound");
+    newf->sound=gnome_config_get_string("Sound");
     newf->popup_text=gnome_config_get_string("Popup-text");
     newf->action=gnome_config_get_int("Action-type");
     newf->action_string=gnome_config_get_string("Action-string");
@@ -208,10 +207,12 @@
     case CONDITION_EXEC:
 	gnome_config_set_string("Command",cond->match.command);
 	break;
+    case CONDITION_NONE:
+	/* Hmm this should not happen */
     }
 }
 
-static GList * libbalsa_conditions_save_config(GList * conds,gchar * prefix)
+static void libbalsa_conditions_save_config(GList * conds,gchar * prefix)
 {
     gint nb=1;
     gchar * tmp;
diff -u ../balsa-1.1.7-manu-sync/libbalsa/filter-funcs.c libbalsa/filter-funcs.c
--- ../balsa-1.1.7-manu-sync/libbalsa/filter-funcs.c	Thu Aug  2 08:05:28 2001
+++ libbalsa/filter-funcs.c	Thu Aug  2 16:00:01 2001
@@ -75,6 +75,8 @@
 	break;
     case CONDITION_REGEX:
 	regexs_free(cond->match.regexs);
+    case CONDITION_NONE:
+	/* to avoid warnings */
     }
     g_free(cond);
 }	                       /* end condition_free() */
diff -u ../balsa-1.1.7-manu-sync/libbalsa/filter-funcs.h libbalsa/filter-funcs.h
--- ../balsa-1.1.7-manu-sync/libbalsa/filter-funcs.h	Wed Aug  1 10:01:35 2001
+++ libbalsa/filter-funcs.h	Thu Aug  2 15:11:36 2001
@@ -30,13 +30,11 @@
 #ifndef _FUNCS_H
 #define _FUNCS_H
 
-/*
- * Files including this one need to
- * #include "filter.h"
- * first.
- */
+#include "filter.h"
+#include "filter-private.h"
 
 /* Conditions */
+
 condition * condition_new();
 void condition_regcomp(condition_regex *, gpointer);   // gpointer has no meaning
 gint condition_compile_regexs(condition *,gpointer);   //gpointer has no meaning
diff -u ../balsa-1.1.7-manu-sync/libbalsa/filter-private.h libbalsa/filter-private.h
--- ../balsa-1.1.7-manu-sync/libbalsa/filter-private.h	Wed Aug  1 08:45:04 2001
+++ libbalsa/filter-private.h	Thu Aug  2 15:57:22 2001
@@ -28,6 +28,9 @@
 #ifndef _FILTER_PRIVATE_H
 #define _FILTER_PRIVATE_H
 
+#include <sys/types.h>
+#include "mutt_regex.h"
+
 /* regex options */
 #define FILTER_REGCOMP       (REG_NEWLINE | REG_NOSUB | REG_EXTENDED)
 #define FILTER_REGEXEC       0
diff -u ../balsa-1.1.7-manu-sync/libbalsa/filter.c libbalsa/filter.c
--- ../balsa-1.1.7-manu-sync/libbalsa/filter.c	Thu Aug  2 08:08:19 2001
+++ libbalsa/filter.c	Thu Aug  2 15:55:04 2001
@@ -32,6 +32,7 @@
 #include "balsa-app.h"
 #include "libbalsa.h"
 #include "filter.h"
+#include "filter-funcs.h"
 #include "filter-private.h"
 
 /* FIXME : misc.h in included for libbalsa_make_string_from_list
@@ -74,34 +75,34 @@
     GList * regexs;
     condition_regex * regex;
 
-    g_assert(cond); // should be impossible
+    g_return_val_if_fail(cond,0); // should be impossible
 
     switch (cond->type) {
     case CONDITION_SIMPLE:
-	if (FILTER_CHKMATCH(cond,CONDITION_MATCH_TO)) {
+	if (CONDITION_CHKMATCH(cond,CONDITION_MATCH_TO)) {
 	    str=libbalsa_make_string_from_list(message->to_list);
 	    match=strstr(str,cond->match.string)!=NULL;
 	    g_free(str);
 	    if (match) return 1;
 	}
-	if (FILTER_CHKMATCH(cond,CONDITION_MATCH_FROM)) {
+	if (CONDITION_CHKMATCH(cond,CONDITION_MATCH_FROM)) {
 	    str=libbalsa_address_to_gchar(message->from,-1);
 	    match=strstr(str,cond->match.string)!=NULL;
 	    g_free(str);
 	    if (match) return 1;
 	}
-	if (FILTER_CHKMATCH(cond,CONDITION_MATCH_SUBJECT)) {
+	if (CONDITION_CHKMATCH(cond,CONDITION_MATCH_SUBJECT)) {
 	    str=libbalsa_address_to_gchar(message->from,-1);
 	    if (strstr(message->subj,cond->match.string)!=NULL)
 		return 1;
 	}
-	if (FILTER_CHKMATCH(cond,CONDITION_MATCH_CC)) {
+	if (CONDITION_CHKMATCH(cond,CONDITION_MATCH_CC)) {
 	    str=libbalsa_make_string_from_list(message->cc_list);
 	    match=strstr(str,cond->match.string)!=NULL;
 	    g_free(str);
 	    if (match) return 1;
 	}
-	if (FILTER_CHKMATCH(cond,CONDITION_MATCH_BODY)) {
+	if (CONDITION_CHKMATCH(cond,CONDITION_MATCH_BODY)) {
 	    str=libbalsa_message_get_text_content(message,100);
 	    match=strstr(str,cond->match.string)!=NULL;
 	    g_free(str);
@@ -113,30 +114,30 @@
 	regexs=cond->match.regexs;
 	for (;regexs;regexs=g_list_next(regexs)) {
 	    regex=(condition_regex *) regexs->data;
-	    if (FILTER_CHKMATCH(cond,CONDITION_MATCH_TO)) {
+	    if (CONDITION_CHKMATCH(cond,CONDITION_MATCH_TO)) {
 		str=libbalsa_make_string_from_list(message->to_list);
 		match=REGEXEC(*(regex->compiled),str);
 		g_free(str);
 		if (match) return 1;
 	    }
-	    if (FILTER_CHKMATCH(cond,CONDITION_MATCH_FROM)) {
+	    if (CONDITION_CHKMATCH(cond,CONDITION_MATCH_FROM)) {
 		str=libbalsa_address_to_gchar(message->from,-1);
 		match=REGEXEC(*(regex->compiled),str);
 		g_free(str);
 		if (match) return 1;
 	    }
-	    if (FILTER_CHKMATCH(cond,CONDITION_MATCH_SUBJECT)) {
+	    if (CONDITION_CHKMATCH(cond,CONDITION_MATCH_SUBJECT)) {
 		str=libbalsa_address_to_gchar(message->from,-1);
 		if (REGEXEC(*(regex->compiled),message->subj)) 
 		    return 1;
 	    }
-	    if (FILTER_CHKMATCH(cond,CONDITION_MATCH_CC)) {
+	    if (CONDITION_CHKMATCH(cond,CONDITION_MATCH_CC)) {
 		str=libbalsa_make_string_from_list(message->cc_list);
 		match=REGEXEC(*(regex->compiled),str);
 		g_free(str);
 		if (match) return 1;
 	    }
-	    if (FILTER_CHKMATCH(cond,CONDITION_MATCH_BODY)) {
+	    if (CONDITION_CHKMATCH(cond,CONDITION_MATCH_BODY)) {
 		str=libbalsa_message_get_text_content(message,100);
 		match=REGEXEC(*(regex->compiled),str);
 		g_free(str);
@@ -146,13 +147,16 @@
 	return 0;
     case CONDITION_EXEC:
 	/* FIXME : Not done yet */
+	return 0;
+    case CONDITION_NONE:
+	return 0;
     }
+    /* To avoid warnings */
+    return 0;
 }
 
 static gint match_conditions(filter_op_type op,GList * cond,LibBalsaMessage * message)
 {
-    gint match=1;
-
     g_assert((op!=FILTER_NOOP) && cond); // should be impossible
     
     if (op==FILTER_OP_OR) {
@@ -167,13 +171,10 @@
 
 gint filter_run_single(filter * filt, LibBalsaMessage * message)
 {
-    gint field,match=0;
-    gboolean free=FALSE;
-    gchar * p;
     LibBalsaMailbox *mbox;
 
     /* No match if the filter is disabled */
-    if (!FILTER_CHKFLAGS(filt,FILTER_ENABLED)) return 0;
+    if (!FILTER_CHKFLAG(filt,FILTER_ENABLED)) return 0;
 
     /* The filter must be valid (eg all regexs have to be compiled...) */
     if (!FILTER_CHKFLAG(filt,FILTER_VALID)) {
@@ -191,10 +192,10 @@
 
     /* The message matches the filter, let's act now! */
     
-    if (FILTER_CHKFLAGS(filt,FILTER_SOUND)) {
+    if (FILTER_CHKFLAG(filt,FILTER_SOUND)) {
 	/* FIXME : Emit sound */
     }
-    if (FILTER_CHKFLAGS(filt,FILTER_POPUP)) {
+    if (FILTER_CHKFLAG(filt,FILTER_POPUP)) {
 	/* FIXME : Print popup text */
     }
     switch (filt->action) {
diff -u ../balsa-1.1.7-manu-sync/libbalsa/filter.h libbalsa/filter.h
--- ../balsa-1.1.7-manu-sync/libbalsa/filter.h	Sat Jul 28 22:16:30 2001
+++ libbalsa/filter.h	Thu Aug  2 15:52:55 2001
@@ -30,8 +30,6 @@
 #ifndef _FILTER_H
 #define _FILTER_H
 
-#include <sys/types.h>
-#include <regex.h>
 #include <glib.h>
 
 #include "libbalsa.h"
@@ -87,13 +85,13 @@
     FILTER_MOVE,
     FILTER_PRINT,
     FILTER_RUN,
-    FILTER_TRASH
+    FILTER_TRASH              // Must be the last one
 } filter_action_type;
 
 typedef enum {
     FILTER_NOOP,
     FILTER_OP_OR,
-    FILTER_OP_AND
+    FILTER_OP_AND             // Must be the last one
 } filter_op_type;
 
 /* filter_run_dialog() modes */
diff -u ../balsa-1.1.7-manu-sync/src/filter-edit-callbacks.c src/filter-edit-callbacks.c
--- ../balsa-1.1.7-manu-sync/src/filter-edit-callbacks.c	Thu Aug  2 08:04:39 2001
+++ src/filter-edit-callbacks.c	Thu Aug  2 15:36:42 2001
@@ -160,7 +160,7 @@
     g_return_if_fail(bevent);
     selected=(GList *)GTK_LIST(fe_type_regex_list)->selection;
 
-    gtk_label_get_text(GTK_LABEL(gtk_container_children(GTK_CONTAINER(selected->data))->data),
+    gtk_label_get(GTK_LABEL(gtk_container_children(GTK_CONTAINER(selected->data))->data),
 		       &str);
 
     gtk_entry_set_text(GTK_ENTRY(fe_type_regex_entry),str);
@@ -187,6 +187,8 @@
     case CONDITION_EXEC:
 	gtk_widget_set_sensitive(fe_type_exec_entry,activating);
 	break;
+    case CONDITION_NONE:
+	/* to avoid warnings */
     }
     if (activating) {
 	gtk_notebook_set_page(GTK_NOTEBOOK(fe_type_notebook),type-1);
@@ -265,6 +267,8 @@
 	break;
     case CONDITION_EXEC:
 	fe_update_type_exec_label();
+    case CONDITION_NONE:
+	/* to avoid warnings */
     }
     condition_has_changed=TRUE;
 }                      /* end fe_negate_condition */
@@ -293,10 +297,9 @@
 {
     condition * cnd;
     GtkWidget * menu;
-    GList * list,* selected;
+    GList * list;
     condition_regex * new_reg;
     gchar * str;
-    gboolean sane;
     condition_match_type type;
     gint match;
 
@@ -361,6 +364,8 @@
 	    return;
 	}
 	break;
+    case CONDITION_NONE:
+	/* to avoid warnings */
     }
 
     /* Sanity checks OK, retrieve datas from widgets */
@@ -717,8 +722,6 @@
 {
     GtkWidget *clist;
     gint new_row;
-    GdkPixmap *pixmap;
-    GdkBitmap *mask;
     filter * fil;
     gchar * new_item[] = { "New filter" };
     condition * cnd;
@@ -860,7 +863,8 @@
 	    case CONDITION_REGEX:
 		for (regex=cnd->match.regexs;regex && (filter_errno==FILTER_NOERR);
 		     regex=g_list_next(regex)) {
-		    if (new_reg=condition_regex_new()) {
+		    new_reg=condition_regex_new();
+		    if (new_reg) {
 			new_reg->string=g_strdup(((condition_regex*)regex->data)->string);
 			new_cnd->match.regexs=g_list_append(new_cnd->match.regexs,new_reg);
 		    }
@@ -869,6 +873,8 @@
 	    case CONDITION_EXEC:
 		new_cnd->match.command=g_strdup(cnd->match.command);
 		break;
+	    case CONDITION_NONE:
+		/* to avoid warnings */
 	    }
 	}
     }
@@ -1029,8 +1035,7 @@
     filter * fil;
     condition * cnd;
     condition * new_cnd;
-    GList * regex,*list;
-    condition_regex * new_reg;
+    GList *list;
     GtkWidget *list_item;
 
     if ( event == NULL )
@@ -1053,9 +1058,8 @@
     gtk_entry_set_text(GTK_ENTRY(fe_sound_entry),
 		       FILTER_CHKFLAG(fil,FILTER_SOUND) ? fil->sound : "");
 
-    set_option_menu(fe_op_codes,fil->conditions_op,ELEMENTS(fe_op_codes),
-		    NULL);
-    set_option_menu(fe_actions,fil->action,5,GTK_SIGNAL_FUNC(fe_action_selected));
+    set_option_menu(fe_op_codes,fil->conditions_op,FILTER_OP_AND,NULL);
+    set_option_menu(fe_actions,fil->action,FILTER_TRASH,GTK_SIGNAL_FUNC(fe_action_selected));
     if (fil->action!=FILTER_TRASH)
 	gtk_entry_set_text(GTK_ENTRY(fe_action_entry),fil->action_string);
 
diff -u ../balsa-1.1.7-manu-sync/src/filter-edit-dialog.c src/filter-edit-dialog.c
--- ../balsa-1.1.7-manu-sync/src/filter-edit-dialog.c	Thu Aug  2 08:04:47 2001
+++ src/filter-edit-dialog.c	Thu Aug  2 15:36:52 2001
@@ -20,14 +20,14 @@
  */
 
 #include "config.h"
+
 #include <gnome.h>
 #ifdef USE_PIXBUF
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #endif
 #include "balsa-app.h"
-#include "filter.h"
 #include "filter-edit.h"
-#include "pixmaps/enabled.xpm"
+#include "filter-funcs.h"
 
 /* ******************************** */
 
@@ -112,9 +112,11 @@
 void fe_free_associated_filters(GtkWidget * clist)
 {
     gint row;
-    g_return_if_fail(GTK_IS_CLIST(clist));
+
+    g_return_if_fail(clist && GTK_IS_CLIST(clist));
+
     for (row=0;row<GTK_CLIST(clist)->rows;row++)
-	filter_free(gtk_clist_get_row_data(GTK_CLIST(clist),row),NULL);
+	filter_free((filter *)gtk_clist_get_row_data(GTK_CLIST(clist),row),NULL);
 }
 
 /*
@@ -242,8 +244,6 @@
 void build_type_notebook()
 {
     GtkWidget *page;
-    GtkWidget *frame;
-    GtkWidget *table;
     GtkWidget *scroll;
     GtkWidget *box;
     GtkWidget *button;
diff -u ../balsa-1.1.7-manu-sync/src/filter-edit.h src/filter-edit.h
--- ../balsa-1.1.7-manu-sync/src/filter-edit.h	Wed Aug  1 17:55:07 2001
+++ src/filter-edit.h	Thu Aug  2 15:16:21 2001
@@ -28,6 +28,8 @@
 #include <glib.h>
 #include <gtk/gtk.h>
 
+#include "filter.h"
+
 /*
  * fe = filter edit
  */
@@ -119,7 +121,8 @@
  * clean-up
  */
 
-static condition_match_type fe_old_condition_type;
+condition_match_type fe_old_condition_type;
+
 /* callbacks */
 void fe_conditions_select_row(GtkWidget * widget, gint row, gint column,
 			 GdkEventButton * bevent, gpointer data);
diff -u ../balsa-1.1.7-manu-sync/src/save-restore.c src/save-restore.c
--- ../balsa-1.1.7-manu-sync/src/save-restore.c	Thu Aug  2 08:16:46 2001
+++ src/save-restore.c	Thu Aug  2 15:36:31 2001
@@ -1042,7 +1042,6 @@
     filter * fil;
     void *iterator;
     gchar *val, *tmp;
-    int pref_len = strlen(FILTER_SECTION_PREFIX);
 
     filter_errno=FILTER_NOERR;
     iterator = gnome_config_init_iterator_sections(BALSA_CONFIG_PREFIX FILTER_SECTION_PREFIX);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]