Re: [PATCH (Experimental)] : find/find again for Balsa
- From: Emmanuel <e allaud wanadoo fr>
- To: balsa-list gnome org
- Subject: Re: [PATCH (Experimental)] : find/find again for Balsa
- Date: Fri, 16 Nov 2001 17:49:50 +0100
On 2001.11.16 21:02 Olaf Frączyk wrote:
> On 2001.11.12 13:40:05 +0100 Emmanuel wrote:
>> On 2001.11.11 14:14 Emmanuel wrote:
>>> Hi all,
>>> here a patch that provides a find/find again capability to Balsa.
>>> Consider it as a proof of concept or some sort :)
>>> I mean that this patch may look as an ugly hack (and it is :), it is
>>> by no mean in final state (in particular it touches a lot of files,
>>> and it'd be better had a new source file to implement part of the
>>> patch).
>>> But it works (at least for me).
> Hi,
>
> After applying patch I get:
>
> balsa-index.o: In function `balsa_index_scan_node':
> /home/projects/build/filters/balsa-1.2.3/src/balsa-index.c:956:
> undefined reference to `match_conditions'.
>
Ooops my fault. I think that something escaped me in the patching process.
The mentionned function was static before, and I changed that to implement
search functions, but it seems that search-1.2.3-1 patch does not have
this change!
Here is a little patch you can apply to have it working.
I'll post soon 2 new patches to bugzilla (#63459) one with search one
without.
Thanks for pointing the problem.
Bye
Manu
diff -u balsa-1.2.3/libbalsa/filter.c balsa-1.2.3-dev/libbalsa/filter.c
--- balsa-1.2.3/libbalsa/filter.c Fri Nov 16 17:11:11 2001
+++ balsa-1.2.3-dev/libbalsa/filter.c Thu Nov 15 12:55:48 2001
@@ -40,10 +40,6 @@
#include "filter.h"
#include "filter-funcs.h"
#include "filter-private.h"
-
-/* FIXME : misc.h is included for libbalsa_make_string_from_list
- which should be moved in address.h.
-*/
#include "misc.h"
/* FIXME : filtering takes time, we should notify progress to user */
@@ -53,7 +49,8 @@
static
gboolean in_string(const gchar * s1,const gchar * s2)
{
- gchar * p,*q;
+ const gchar * p,* q;
+
/* convention : NULL string is contained in anything */
if (!s2) return TRUE;
/* s2 is non-NULL, so if s1==NULL we return FALSE :)*/
@@ -80,7 +77,9 @@
return FALSE;
}
-static gint match_condition(condition * cond,LibBalsaMessage * message)
+/*---------------------- Helper functions (also exported to have a fine-grained API) --------*/
+
+gint match_condition(condition * cond,LibBalsaMessage * message)
{
gint match=0;
gchar * str;
@@ -189,7 +188,7 @@
return 0;
}
-static gint match_conditions(filter_op_type op,GSList * cond,LibBalsaMessage * message)
+gint match_conditions(filter_op_type op,GSList * cond,LibBalsaMessage * message)
{
g_assert((op!=FILTER_NOOP) && cond); // should be impossible
@@ -229,16 +228,18 @@
* Run all filters until one matches (so order of filter is important)
* filters must be valid and compiled (ie filters_prepare_to_run have been called before)
* Assume that all messages come from ONE mailbox
+ * returns TRUE if the trash bin has been filled
* FIXME : Should position filter_errno on errors (bad command action,bad destination mailbox...)
*/
-void filters_run_on_messages(GSList * filter_list, GList * messages)
+gboolean filters_run_on_messages(GSList * filter_list, GList * messages)
{
gint match;
GSList * lst;
GList * lst_messages;
filter * filt=NULL;
LibBalsaMailbox * source_mbox;
+ gboolean result=FALSE;
g_return_if_fail(filter_list && messages);
@@ -283,6 +284,7 @@
case FILTER_TRASH:
if (!balsa_app.trash || !libbalsa_messages_move(filt->matching_messages,balsa_app.trash))
libbalsa_information(LIBBALSA_INFORMATION_ERROR,"Error when trashing messages");
+ else result=TRUE;
break;
case FILTER_MOVE:
mbox = mblist_find_mbox_by_name(balsa_app.mblist,filt->action_string);
@@ -307,6 +309,7 @@
filt->matching_messages=NULL;
}
}
+ return result;
}
/*--------- End of Filtering functions -------------------------------*/
diff -u balsa-1.2.3/libbalsa/filter.h balsa-1.2.3-dev/libbalsa/filter.h
--- balsa-1.2.3/libbalsa/filter.h Fri Nov 16 17:11:11 2001
+++ balsa-1.2.3-dev/libbalsa/filter.h Thu Nov 15 12:55:48 2001
@@ -154,9 +154,14 @@
/*
* Exported filter functions
- * FIXME : for now a lot of functions is exported, it's far too much
+ * A lot are, to have a fine-grained API so we can use filter engine for a lot of different
+ * purpose : search functions, virtual folders..., not only filtering
*/
+gint match_condition(condition * cond,LibBalsaMessage * message);
+
+gint match_conditions(filter_op_type op,GSList * cond,LibBalsaMessage * message);
+
/* Filtering functions */
/* FIXME : perhaps I should try to use multithreading -> but we must therefore use lock very well */
@@ -169,10 +174,12 @@
gint filters_prepare_to_run(GSList * filters);
/* filters_run_on_messages run all filters on the list of messages
+ * It returns TRUE if the trash bin has been filled with something
+ * this is used to call enable_empty_trash after
* FIXME : No locking is done for now
*/
-void filters_run_on_messages(GSList * filter_list, GList * messages);
+gboolean filters_run_on_messages(GSList * filter_list, GList * messages);
/*
* filter_by_name()
diff -u balsa-1.2.3/src/filter-run-callbacks.c balsa-1.2.3-dev/src/filter-run-callbacks.c
--- balsa-1.2.3/src/filter-run-callbacks.c Fri Nov 16 17:11:21 2001
+++ balsa-1.2.3-dev/src/filter-run-callbacks.c Fri Nov 16 17:34:48 2001
@@ -108,7 +108,8 @@
if (!filters_prepare_to_run(filters))
return FALSE;
gtk_clist_freeze(GTK_CLIST(balsa_app.mblist));
- filters_run_on_messages(filters,mbox->message_list);
+ if (filters_run_on_messages(filters,mbox->message_list))
+ enable_empty_trash(TRASH_FULL);
gtk_clist_thaw(GTK_CLIST(balsa_app.mblist));
g_slist_free(filters);
return TRUE;
@@ -139,13 +140,17 @@
{
gint row;
BalsaFilterRunDialog * p;
+ gchar * msg;
p=BALSA_FILTER_RUN_DIALOG(widget);
switch (button) {
case 0: /* Apply button */
+ msg = g_strdup_printf(_("Filtering mailbox %s. Please wait..."),p->mbox->name);
+ gnome_appbar_push(balsa_app.appbar, msg);
+ g_free(msg);
if (!run_filters_on_mailbox(p->selected_filters,p->mbox))
balsa_information(LIBBALSA_INFORMATION_ERROR,_("Error when applying filters"));
- enable_empty_trash(TRASH_CHECK);
+ gnome_appbar_pop(balsa_app.appbar);
return;
case 1: /* OK button */
save_filters(p);
Common subdirectories: balsa-1.2.3/src/pixmaps and balsa-1.2.3-dev/src/pixmaps
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]