2007-03-05 [wwp] 2.8.0cvs18
[claws.git] / src / filtering.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2007 Hiroyuki Yamamoto & The Claws Mail Team
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 #include "defs.h"
21 #include <glib.h>
22 #include <glib/gi18n.h>
23 #include <ctype.h>
24 #include <string.h>
25 #include <stdlib.h>
26 #include <errno.h>
27 #include <gtk/gtk.h>
28 #include <stdio.h>
29
30 #include "utils.h"
31 #include "procheader.h"
32 #include "matcher.h"
33 #include "filtering.h"
34 #include "prefs_gtk.h"
35 #include "compose.h"
36 #include "prefs_common.h"
37
38 #define PREFSBUFSIZE            1024
39
40 GSList * pre_global_processing = NULL;
41 GSList * post_global_processing = NULL;
42 GSList * filtering_rules = NULL;
43
44 static gboolean filtering_is_final_action(FilteringAction *filtering_action);
45
46 #define STRLEN_WITH_CHECK(expr) \
47         strlen_with_check(#expr, __LINE__, expr)
48                 
49 static inline gint strlen_with_check(const gchar *expr, gint fline, const gchar *str)
50 {
51         if (str) 
52                 return strlen(str);
53         else {
54                 debug_print("%s(%d) - invalid string %s\n", __FILE__, fline, expr);
55                 return 0;
56         }
57 }
58
59 FilteringAction * filteringaction_new(int type, int account_id,
60                                       gchar * destination,
61                                       gint labelcolor, gint score)
62 {
63         FilteringAction * action;
64
65         action = g_new0(FilteringAction, 1);
66
67         action->type = type;
68         action->account_id = account_id;
69         if (destination) {
70                 action->destination       = g_strdup(destination);
71         } else {
72                 action->destination       = NULL;
73         }
74         action->labelcolor = labelcolor;        
75         action->score = score;
76         return action;
77 }
78
79 void filteringaction_free(FilteringAction * action)
80 {
81         g_return_if_fail(action);
82         g_free(action->destination);
83         g_free(action);
84 }
85
86 FilteringProp * filteringprop_new(gboolean enabled,
87                                   const gchar *name,
88                                   gint account_id,
89                                   MatcherList * matchers,
90                                   GSList * action_list)
91 {
92         FilteringProp * filtering;
93
94         filtering = g_new0(FilteringProp, 1);
95         filtering->enabled = enabled;
96         filtering->name = name ? g_strdup(name): NULL;
97         filtering->account_id = account_id;
98         filtering->matchers = matchers;
99         filtering->action_list = action_list;
100
101         return filtering;
102 }
103
104 static FilteringAction * filteringaction_copy(FilteringAction * src)
105 {
106         FilteringAction * new;
107         
108         new = g_new0(FilteringAction, 1);
109         
110         new->type = src->type;
111         new->account_id = src->account_id;
112         if (src->destination)
113                 new->destination = g_strdup(src->destination);
114         else 
115                 new->destination = NULL;
116         new->labelcolor = src->labelcolor;
117         new->score = src->score;
118
119         return new;
120 }
121
122 FilteringProp * filteringprop_copy(FilteringProp *src)
123 {
124         FilteringProp * new;
125         GSList *tmp;
126         
127         new = g_new0(FilteringProp, 1);
128         new->matchers = g_new0(MatcherList, 1);
129
130         for (tmp = src->matchers->matchers; tmp != NULL && tmp->data != NULL;) {
131                 MatcherProp *matcher = (MatcherProp *)tmp->data;
132                 
133                 new->matchers->matchers = g_slist_append(new->matchers->matchers,
134                                                    matcherprop_copy(matcher));
135                 tmp = tmp->next;
136         }
137
138         new->matchers->bool_and = src->matchers->bool_and;
139
140         new->action_list = NULL;
141
142         for (tmp = src->action_list ; tmp != NULL ; tmp = tmp->next) {
143                 FilteringAction *filtering_action;
144                 
145                 filtering_action = tmp->data;
146                 
147                 new->action_list = g_slist_append(new->action_list,
148                     filteringaction_copy(filtering_action));
149         }
150
151         new->enabled = src->enabled;
152         new->name = g_strdup(src->name);
153
154         return new;
155 }
156
157 void filteringprop_free(FilteringProp * prop)
158 {
159         GSList * tmp;
160
161         g_return_if_fail(prop);
162         matcherlist_free(prop->matchers);
163         
164         for (tmp = prop->action_list ; tmp != NULL ; tmp = tmp->next) {
165                 filteringaction_free(tmp->data);
166         }
167         g_free(prop->name);
168         g_free(prop);
169 }
170
171 void filtering_move_and_copy_msg(MsgInfo *msginfo)
172 {
173         GSList *list = g_slist_append(NULL, msginfo);
174         filtering_move_and_copy_msgs(list);
175         g_slist_free(list);
176 }
177
178 /* move and copy messages by batches to be faster on IMAP */
179 void filtering_move_and_copy_msgs(GSList *msgs)
180 {
181         GSList *messages = g_slist_copy(msgs);
182         FolderItem *last_item = NULL;
183         gboolean is_copy = FALSE, is_move = FALSE;
184         debug_print("checking %d messages\n", g_slist_length(msgs));
185         while (messages) {
186                 GSList *batch = NULL, *cur;
187                 gint found = 0;
188                 for (cur = messages; cur; cur = cur->next) {
189                         MsgInfo *info = (MsgInfo *)cur->data;
190                         if (last_item == NULL) {
191                                 last_item = info->to_filter_folder;
192                         }
193                         if (last_item == NULL)
194                                 continue;
195                         if (!is_copy && !is_move) {
196                                 if (info->is_copy)
197                                         is_copy = TRUE;
198                                 else if (info->is_move)
199                                         is_move = TRUE;
200                         }
201                         found++;
202                         if (info->to_filter_folder == last_item 
203                         &&  info->is_copy == is_copy
204                         &&  info->is_move == is_move) {
205                                 batch = g_slist_prepend(batch, info);
206                         }
207                 }
208                 if (found == 0) {
209                         debug_print("no more messages to move/copy\n");
210                         break;
211                 } else {
212                         debug_print("%d messages to %s in %s\n", found,
213                                 is_copy ? "copy":"move", last_item->name ? last_item->name:"(noname)");
214                 }
215                 for (cur = batch; cur; cur = cur->next) {
216                         MsgInfo *info = (MsgInfo *)cur->data;
217                         messages = g_slist_remove(messages, info);
218                 }
219                 batch = g_slist_reverse(batch);
220                 if (g_slist_length(batch)) {
221                         MsgInfo *info = (MsgInfo *)batch->data;
222                         if (is_copy && last_item != info->folder) {
223                                 folder_item_copy_msgs(last_item, batch);
224                         } else if (is_move && last_item != info->folder) {
225                                 if (folder_item_move_msgs(last_item, batch) < 0)
226                                         folder_item_move_msgs(
227                                                 folder_get_default_inbox(), 
228                                                 batch);
229                         }
230                         /* we don't reference the msginfos, because caller will do */
231                         g_slist_free(batch);
232                         batch = NULL;
233                 }
234                 last_item = NULL;
235                 is_copy = FALSE;
236                 is_move = FALSE;
237         }
238         /* we don't reference the msginfos, because caller will do */
239         g_slist_free(messages);
240 }
241
242 /*
243   fitleringaction_apply
244   runs the action on one MsgInfo
245   return value : return TRUE if the action could be applied
246 */
247
248 static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info)
249 {
250         FolderItem * dest_folder;
251         gint val;
252         Compose * compose;
253         PrefsAccount * account;
254         gchar * cmd;
255
256         switch(action->type) {
257         case MATCHACTION_MOVE:
258                 dest_folder =
259                         folder_find_item_from_identifier(action->destination);
260                 if (!dest_folder) {
261                         debug_print("*** folder not found '%s'\n",
262                                 action->destination ?action->destination :"");
263                         return FALSE;
264                 }
265                 
266                 /* check if mail is set to copy already, 
267                  * in which case we have to do it */
268                 if (info->is_copy && info->to_filter_folder) {
269                         debug_print("should cp and mv !\n");
270                         folder_item_copy_msg(info->to_filter_folder, info);
271                         info->is_copy = FALSE;
272                 }
273                 /* mark message to be moved */          
274                 info->is_move = TRUE;
275                 info->to_filter_folder = dest_folder;
276                 return TRUE;
277
278         case MATCHACTION_COPY:
279                 dest_folder =
280                         folder_find_item_from_identifier(action->destination);
281
282                 if (!dest_folder) {
283                         debug_print("*** folder not found '%s'\n",
284                                 action->destination ?action->destination :"");
285                         return FALSE;
286                 }
287
288                 /* check if mail is set to copy already, 
289                  * in which case we have to do it */
290                 if (info->is_copy && info->to_filter_folder) {
291                         debug_print("should cp and mv !\n");
292                         folder_item_copy_msg(info->to_filter_folder, info);
293                         info->is_copy = FALSE;
294                 }
295                 /* mark message to be copied */         
296                 info->is_copy = TRUE;
297                 info->to_filter_folder = dest_folder;
298                 return TRUE;
299
300         case MATCHACTION_DELETE:
301                 if (folder_item_remove_msg(info->folder, info->msgnum) == -1)
302                         return FALSE;
303                 return TRUE;
304
305         case MATCHACTION_MARK:
306                 procmsg_msginfo_set_flags(info, MSG_MARKED, 0);
307                 return TRUE;
308
309         case MATCHACTION_UNMARK:
310                 procmsg_msginfo_unset_flags(info, MSG_MARKED, 0);
311                 return TRUE;
312
313         case MATCHACTION_LOCK:
314                 procmsg_msginfo_set_flags(info, MSG_LOCKED, 0);
315                 return TRUE;
316
317         case MATCHACTION_UNLOCK:
318                 procmsg_msginfo_unset_flags(info, MSG_LOCKED, 0);       
319                 return TRUE;
320                 
321         case MATCHACTION_MARK_AS_READ:
322                 procmsg_msginfo_unset_flags(info, MSG_UNREAD | MSG_NEW, 0);
323                 return TRUE;
324
325         case MATCHACTION_MARK_AS_UNREAD:
326                 procmsg_msginfo_set_flags(info, MSG_UNREAD | MSG_NEW, 0);
327                 return TRUE;
328         
329         case MATCHACTION_MARK_AS_SPAM:
330                 procmsg_spam_learner_learn(info, NULL, TRUE);
331                 procmsg_msginfo_change_flags(info, MSG_SPAM, 0, MSG_NEW|MSG_UNREAD, 0);
332                 if (procmsg_spam_get_folder(info)) {
333                         info->is_move = TRUE;
334                         info->to_filter_folder = procmsg_spam_get_folder(info);
335                 }
336                 return TRUE;
337
338         case MATCHACTION_MARK_AS_HAM:
339                 procmsg_spam_learner_learn(info, NULL, FALSE);
340                 procmsg_msginfo_unset_flags(info, MSG_SPAM, 0);
341                 return TRUE;
342         
343         case MATCHACTION_COLOR:
344                 procmsg_msginfo_unset_flags(info, MSG_CLABEL_FLAG_MASK, 0); 
345                 procmsg_msginfo_set_flags(info, MSG_COLORLABEL_TO_FLAGS(action->labelcolor), 0);
346                 return TRUE;
347
348         case MATCHACTION_FORWARD:
349         case MATCHACTION_FORWARD_AS_ATTACHMENT:
350                 account = account_find_from_id(action->account_id);
351                 compose = compose_forward(account, info,
352                         action->type == MATCHACTION_FORWARD ? FALSE : TRUE,
353                         NULL, TRUE, TRUE);
354                 compose_entry_append(compose, action->destination,
355                                      compose->account->protocol == A_NNTP
356                                             ? COMPOSE_NEWSGROUPS
357                                             : COMPOSE_TO);
358
359                 val = compose_send(compose);
360
361                 return val == 0 ? TRUE : FALSE;
362
363         case MATCHACTION_REDIRECT:
364                 account = account_find_from_id(action->account_id);
365                 compose = compose_redirect(account, info, TRUE);
366                 if (compose->account->protocol == A_NNTP)
367                         break;
368                 else
369                         compose_entry_append(compose, action->destination,
370                                              COMPOSE_TO);
371
372                 val = compose_send(compose);
373                 
374                 return val == 0 ? TRUE : FALSE;
375
376         case MATCHACTION_EXECUTE:
377                 cmd = matching_build_command(action->destination, info);
378                 if (cmd == NULL)
379                         return FALSE;
380                 else {
381                         system(cmd);
382                         g_free(cmd);
383                 }
384                 return TRUE;
385
386         case MATCHACTION_SET_SCORE:
387                 info->score = action->score;
388                 return TRUE;
389
390         case MATCHACTION_CHANGE_SCORE:
391                 info->score += action->score;
392                 return TRUE;
393
394         case MATCHACTION_STOP:
395                 return FALSE;
396
397         case MATCHACTION_HIDE:
398                 info->hidden = TRUE;
399                 return TRUE;
400
401         case MATCHACTION_IGNORE:
402                 procmsg_msginfo_set_flags(info, MSG_IGNORE_THREAD, 0);
403                 return TRUE;
404
405         default:
406                 break;
407         }
408         return FALSE;
409 }
410
411 gboolean filteringaction_apply_action_list(GSList *action_list, MsgInfo *info)
412 {
413         GSList *p;
414         g_return_val_if_fail(action_list, FALSE);
415         g_return_val_if_fail(info, FALSE);
416         for (p = action_list; p && p->data; p = g_slist_next(p)) {
417                 FilteringAction *a = (FilteringAction *) p->data;
418                 if (filteringaction_apply(a, info)) {
419                         if (filtering_is_final_action(a))
420                                 break;
421                 } else
422                         return FALSE;
423                 
424         }
425         return TRUE;
426 }
427
428 static gboolean filtering_match_condition(FilteringProp *filtering, MsgInfo *info,
429                                                         PrefsAccount *ac_prefs)
430 {
431         gboolean matches = FALSE;
432
433         if (ac_prefs != NULL) {
434                 matches = ((filtering->account_id == 0)
435                                         || (filtering->account_id == ac_prefs->account_id));
436         } else {
437                 switch (prefs_common.apply_per_account_filtering_rules) {
438                 case FILTERING_ACCOUNT_RULES_FORCE:
439                         /* apply filtering rules regardless to the account info */
440                         matches = TRUE;
441                         break;
442                 case FILTERING_ACCOUNT_RULES_SKIP:
443                         /* don't apply filtering rules that belong to an account */
444                         matches = (filtering->account_id == 0);
445                         break;
446                 case FILTERING_ACCOUNT_RULES_USE_CURRENT:
447                         matches = ((filtering->account_id == 0)
448                                         || (filtering->account_id == cur_account->account_id));
449                         break;
450                 }
451         }
452
453         return matches && matcherlist_match(filtering->matchers, info);
454 }
455
456 /*!
457  *\brief        Apply a rule on message.
458  *
459  *\param        filtering List of filtering rules.
460  *\param        info Message to apply rules on.
461  *\param        final Variable returning TRUE or FALSE if one of the
462  *              encountered actions was final. 
463  *              See also \ref filtering_is_final_action.
464  *
465  *\return       gboolean TRUE to continue applying rules.
466  */
467 static gboolean filtering_apply_rule(FilteringProp *filtering, MsgInfo *info,
468     gboolean * final)
469 {
470         gboolean result = TRUE;
471         gchar    buf[256];
472         GSList * tmp;
473         
474         * final = FALSE;
475         for (tmp = filtering->action_list ; tmp != NULL ; tmp = tmp->next) {
476                 FilteringAction * action;
477                 
478                 action = tmp->data;
479                 
480                 if (FALSE == (result = filteringaction_apply(action, info))) {
481                         g_warning("No further processing after rule %s\n",
482                             filteringaction_to_string(buf, sizeof buf, action));
483                 }
484                 
485                 if (filtering_is_final_action(action)) {
486                         * final = TRUE;
487                         break;
488                 }
489         }
490         return result;
491 }
492
493 /*!
494  *\brief        Check if an action is "final", i.e. should break further
495  *              processing.
496  *
497  *\param        filtering_action Action to check.
498  *
499  *\return       gboolean TRUE if \a filtering_action is final.  
500  */
501 static gboolean filtering_is_final_action(FilteringAction *filtering_action)
502 {
503         switch(filtering_action->type) {
504         case MATCHACTION_MOVE:
505         case MATCHACTION_DELETE:
506         case MATCHACTION_STOP:
507         case MATCHACTION_MARK_AS_SPAM:
508                 return TRUE; /* MsgInfo invalid for message */
509         default:
510                 return FALSE;
511         }
512 }
513
514 static gboolean filter_msginfo(GSList * filtering_list, MsgInfo * info, PrefsAccount* ac_prefs)
515 {
516         GSList  *l;
517         gboolean final;
518         gboolean apply_next;
519         
520         g_return_val_if_fail(info != NULL, TRUE);
521         
522         for (l = filtering_list, final = FALSE, apply_next = FALSE; l != NULL; l = g_slist_next(l)) {
523                 FilteringProp * filtering = (FilteringProp *) l->data;
524
525                 if (filtering->enabled && filtering_match_condition(filtering, info, ac_prefs)) {
526                         apply_next = filtering_apply_rule(filtering, info, &final);
527                         if (final)
528                                 break;
529                 }               
530         }
531
532         /* put in inbox if a final rule could not be applied, or
533          * the last rule was not a final one. */
534         if ((final && !apply_next) || !final) {
535                 return FALSE;
536         }
537
538         return TRUE;
539 }
540
541 /*!
542  *\brief        Filter a message against a list of rules.
543  *
544  *\param        flist List of filter rules.
545  *\param        info Message.
546  *
547  *\return       gboolean TRUE if filter rules handled the message.
548  *
549  *\note         Returning FALSE means the message was not handled,
550  *              and that the calling code should do the default
551  *              processing. E.g. \ref inc.c::inc_start moves the 
552  *              message to the inbox.   
553  */
554 gboolean filter_message_by_msginfo(GSList *flist, MsgInfo *info, PrefsAccount* ac_prefs)
555 {
556         return filter_msginfo(flist, info, ac_prefs);
557 }
558
559 gchar *filteringaction_to_string(gchar *dest, gint destlen, FilteringAction *action)
560 {
561         const gchar *command_str;
562         gchar * quoted_dest;
563         
564         command_str = get_matchparser_tab_str(action->type);
565
566         if (command_str == NULL)
567                 return NULL;
568
569         switch(action->type) {
570         case MATCHACTION_MOVE:
571         case MATCHACTION_COPY:
572         case MATCHACTION_EXECUTE:
573                 quoted_dest = matcher_quote_str(action->destination);
574                 g_snprintf(dest, destlen, "%s \"%s\"", command_str, quoted_dest);
575                 g_free(quoted_dest);
576                 return dest;
577
578         case MATCHACTION_DELETE:
579         case MATCHACTION_MARK:
580         case MATCHACTION_UNMARK:
581         case MATCHACTION_LOCK:
582         case MATCHACTION_UNLOCK:
583         case MATCHACTION_MARK_AS_READ:
584         case MATCHACTION_MARK_AS_UNREAD:
585         case MATCHACTION_MARK_AS_SPAM:
586         case MATCHACTION_MARK_AS_HAM:
587         case MATCHACTION_STOP:
588         case MATCHACTION_HIDE:
589         case MATCHACTION_IGNORE:
590                 g_snprintf(dest, destlen, "%s", command_str);
591                 return dest;
592
593         case MATCHACTION_REDIRECT:
594         case MATCHACTION_FORWARD:
595         case MATCHACTION_FORWARD_AS_ATTACHMENT:
596                 quoted_dest = matcher_quote_str(action->destination);
597                 g_snprintf(dest, destlen, "%s %d \"%s\"", command_str, action->account_id, quoted_dest);
598                 g_free(quoted_dest);
599                 return dest; 
600
601         case MATCHACTION_COLOR:
602                 g_snprintf(dest, destlen, "%s %d", command_str, action->labelcolor);
603                 return dest;  
604
605         case MATCHACTION_CHANGE_SCORE:
606         case MATCHACTION_SET_SCORE:
607                 g_snprintf(dest, destlen, "%s %d", command_str, action->score);
608                 return dest;  
609
610         default:
611                 return NULL;
612         }
613 }
614
615 gchar * filteringaction_list_to_string(GSList * action_list)
616 {
617         gchar *action_list_str;
618         gchar  buf[256];
619         GSList * tmp;
620         gchar *list_str;
621
622         action_list_str = NULL;
623         for (tmp = action_list ; tmp != NULL ; tmp = tmp->next) {
624                 gchar *action_str;
625                 FilteringAction * action;
626                 
627                 action = tmp->data;
628                 
629                 action_str = filteringaction_to_string(buf,
630                     sizeof buf, action);
631                 
632                 if (action_list_str != NULL) {
633                         list_str = g_strconcat(action_list_str, " ", action_str, NULL);
634                         g_free(action_list_str);
635                 }
636                 else {
637                         list_str = g_strdup(action_str);
638                 }
639                 action_list_str = list_str;
640         }
641
642         return action_list_str;
643 }
644
645 gchar * filteringprop_to_string(FilteringProp * prop)
646 {
647         gchar *list_str;
648         gchar *action_list_str;
649         gchar *filtering_str;
650
651         action_list_str = filteringaction_list_to_string(prop->action_list);
652
653         if (action_list_str == NULL)
654                 return NULL;
655
656         list_str = matcherlist_to_string(prop->matchers);
657
658         if (list_str == NULL) {
659                 g_free(action_list_str);
660                 return NULL;
661         }
662
663         filtering_str = g_strconcat(list_str, " ", action_list_str, NULL);
664         g_free(action_list_str);
665         g_free(list_str);
666
667         return filtering_str;
668 }
669
670 void prefs_filtering_free(GSList * prefs_filtering)
671 {
672         while (prefs_filtering != NULL) {
673                 FilteringProp * filtering = (FilteringProp *)
674                         prefs_filtering->data;
675                 filteringprop_free(filtering);
676                 prefs_filtering = g_slist_remove(prefs_filtering, filtering);
677         }
678 }
679
680 static gboolean prefs_filtering_free_func(GNode *node, gpointer data)
681 {
682         FolderItem *item = node->data;
683
684         g_return_val_if_fail(item, FALSE);
685         g_return_val_if_fail(item->prefs, FALSE);
686
687         prefs_filtering_free(item->prefs->processing);
688         item->prefs->processing = NULL;
689
690         return FALSE;
691 }
692
693 void prefs_filtering_clear(void)
694 {
695         GList * cur;
696
697         for (cur = folder_get_list() ; cur != NULL ; cur = g_list_next(cur)) {
698                 Folder *folder;
699
700                 folder = (Folder *) cur->data;
701                 g_node_traverse(folder->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
702                                 prefs_filtering_free_func, NULL);
703         }
704
705         prefs_filtering_free(filtering_rules);
706         filtering_rules = NULL;
707         prefs_filtering_free(pre_global_processing);
708         pre_global_processing = NULL;
709         prefs_filtering_free(post_global_processing);
710         post_global_processing = NULL;
711 }
712
713 void prefs_filtering_clear_folder(Folder *folder)
714 {
715         g_return_if_fail(folder);
716         g_return_if_fail(folder->node);
717
718         g_node_traverse(folder->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
719                         prefs_filtering_free_func, NULL);
720         /* FIXME: Note folder settings were changed, where the updates? */
721 }
722
723 gboolean filtering_peek_per_account_rules(GSList *filtering_list)
724 /* return TRUE if there's at least one per-account filtering rule */
725 {
726         GSList *l;
727
728         for (l = filtering_list; l != NULL; l = g_slist_next(l)) {
729                 FilteringProp * filtering = (FilteringProp *) l->data;
730
731                 if (filtering->enabled && (filtering->account_id != 0)) {
732                         return TRUE;
733                 }               
734         }
735
736         return FALSE;
737 }