26
27
#include "node_type.h"
28
29
/* The search folder implementation of Liferea is similar to the
29
30
one in Evolution. Search folders are effectivly permanent searches.
32
As Liferea realizes filtered lists of items using rule based itemsets,
33
search folders are effectively persistent rule based itemsets.
31
Each search folder instance is a set of rules applied to all items
32
of all other feeds (excluding other search folders). Each search
33
folder instance can be represented by a single node in the feed list.
34
The search feature is realized using a temporary search folder.
35
GUI wise a search folder is a type of node in the subscription list.
37
/** search vfolder data structure */
38
/** search folder data structure */
38
39
typedef struct vfolder {
39
GSList *rules; /**< list of rules of this search folder */
40
struct node *node; /**< the feed list node of this search folder (or NULL) */
41
gboolean anyMatch; /**< TRUE means only one of the rules must match for item inclusion */
40
struct node *node; /**< the feed list node of this search folder */
42
itemSetPtr itemset; /**< the itemset with the rules and matching items */
44
gboolean reloading; /**< if the search folder is in async reloading */
45
gulong maxLoadedId; /**< when in reloading maximum scanned id so far */
51
55
vfolderPtr vfolder_new (struct node *node);
54
* Method that adds an existing rule to a search folder.
55
* To be used when editing search folders.
57
* @param vfdoler search folder
58
* @param rule rule to add
60
void vfolder_add_existing_rule (vfolderPtr vfolder, rulePtr rule);
63
* Method that creates and adds a rule to a search folder. To be used
64
* on loading time, when creating searches or when editing
65
* search folder properties.
67
* vfolder_refresh() needs to called to update the item matches
69
* @param vfolder search folder the rule belongs to
70
* @param ruleId id string for this rule type
71
* @param value argument string for this rule
72
* @param additive indicates positive or negative logic
74
void vfolder_add_rule (vfolderPtr vfolder, const gchar *ruleId, const gchar *value, gboolean additive);
77
* Method that removes a rule from the rule list of a given
78
* search folder. To be used when deleting search folders
79
* or editing its rules.
81
* vfolder_refresh() needs to called to update the item matches
83
* @param vfolder search folder
84
* @param rule rule to remove
86
void vfolder_remove_rule (vfolderPtr vfolder, rulePtr rule);
89
* Method to unconditionally invoke a callback for all search folders.
58
* Method to unconditionally invoke an node callback for all search folders.
91
60
* @param func callback
93
62
void vfolder_foreach (nodeActionFunc func);
64
typedef void (*vfolderActionDataFunc) (vfolderPtr vfolder, itemPtr item);
96
* Method to invoke a callback for all search folders that do use
67
* Method to unconditionally invoke an item callback for all search folders.
99
* @param ruleName the rule type
100
69
* @param func callback
102
void vfolder_foreach_with_rule (const gchar *ruleName, nodeActionFunc func);
105
* Method to invoke callbacks for all search folders that are
106
* affected by a modification of the given item. For each
107
* search folder it is checked if the item matches the search folder
108
* rules. If yes then the given callback is invoked.
110
* @param itemId the item id
111
* @param func function to call if the search folder contains the item
113
void vfolder_foreach_with_item (gulong itemId, nodeActionFunc func);
116
* Method that updates the unread and item count for the given
117
* search folder node.
119
* @param node the search folder node
121
void vfolder_update_counters (nodePtr node);
124
* Method that "refreshes" the DB view according
125
* to the search folder rules. To be called after
126
* vfolder_(add|remove)_rule().
70
* @param data the item to process
72
void vfolder_foreach_data (vfolderActionDataFunc func, itemPtr item);
75
* Method to remove an item from a search folder.
77
* @param vfolder search folder
78
* @param item the item
80
void vfolder_remove_item (vfolderPtr vfolder, itemPtr item);
83
* Method to add an item to a search folder.
85
* @param vfolder search folder
86
* @param item the item
88
void vfolder_add_item (vfolderPtr vfolder, itemPtr item);
91
* Method to merge an item to a search folder if
92
* it matches the search folder rules.
94
* @param vfolder search folder
95
* @param item the item
97
void vfolder_merge_item (vfolderPtr vfolder, itemPtr item);
100
* Returns a list of all search folders currently matching
103
* @param id the item id
105
* @returns a list of vfolderPtr (to be free'd using g_slist_free())
107
GSList * vfolder_get_all_with_item_id (gulong id);
110
* Resets vfolder state. Drops all items from it.
111
* To be called after vfolder_(add|remove)_rule().
113
* @param vfolder search folder to reset
115
void vfolder_reset (vfolderPtr vfolder);
118
* Rebuilds a search folder by scanning all existing items.
128
120
* @param vfolder search folder to rebuild
130
void vfolder_refresh (vfolderPtr vfolder);
122
void vfolder_rebuild (nodePtr node);
132
124
/* implementation of the node type interface */