Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 207 lines (180 sloc) 7.326 kb
abf9c63 @djcb * cleanup some header files
authored
1 /* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
2
3fa552a @djcb * mu-index: cosmetics
authored
3 /*
fade417 @djcb * many changes to the config system
authored
4 ** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
2b0aca1 @djcb * initial import of mu - the next generation
authored
5 **
6 ** This program is free software; you can redistribute it and/or modify
7 ** it under the terms of the GNU General Public License as published by
8 ** the Free Software Foundation; either version 3 of the License, or
9 ** (at your option) any later version.
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
10 **
2b0aca1 @djcb * initial import of mu - the next generation
authored
11 ** This program is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ** GNU General Public License for more details.
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
15 **
2b0aca1 @djcb * initial import of mu - the next generation
authored
16 ** You should have received a copy of the GNU General Public License
17 ** along with this program; if not, write to the Free Software Foundation,
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
18 ** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 **
2b0aca1 @djcb * initial import of mu - the next generation
authored
20 */
21
22 #ifndef __MU_INDEX_H__
23 #define __MU_INDEX_H__
24
8ed3eb9 @djcb * mu-index.[ch]: minor changes
authored
25 #include <stdlib.h>
26 #include <glib.h>
fade417 @djcb * many changes to the config system
authored
27 #include <mu-util.h> /* for MuResult */
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
28 #include <mu-store.h>
8ed3eb9 @djcb * mu-index.[ch]: minor changes
authored
29
fade417 @djcb * many changes to the config system
authored
30 G_BEGIN_DECLS
2b0aca1 @djcb * initial import of mu - the next generation
authored
31
32 /* opaque structure */
33 struct _MuIndex;
34 typedef struct _MuIndex MuIndex;
35
36 struct _MuIndexStats {
081e601 @djcb * mu-index: use unsigned instead of time_t
authored
37 unsigned _processed; /* number of msgs processed or counted */
38 unsigned _updated; /* number of msgs new or updated */
39 unsigned _cleaned_up; /* number of msgs cleaned up */
40 unsigned _uptodate; /* number of msgs already uptodate */
2b0aca1 @djcb * initial import of mu - the next generation
authored
41 };
42 typedef struct _MuIndexStats MuIndexStats;
43
3fa552a @djcb * mu-index: cosmetics
authored
44 /**
45 * create a new MuIndex instance. NOTE(1): the database does not have
46 * to exist yet, but the directory must already exist; NOTE(2): before
47 * doing anything with the returned Index object, make sure you haved
48 * called g_type_init, and mu_msg_init somewhere in your code.
2b0aca1 @djcb * initial import of mu - the next generation
authored
49 *
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
50 * @param store a writable MuStore object
e64e24a @djcb * create mu-error.h, update some functions to use GError for errors
authored
51 * @param err to receive error or NULL; there are only errors when this
52 * function returns NULL. Possible errors: see mu-error.h
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
53 *
2b0aca1 @djcb * initial import of mu - the next generation
authored
54 * @return a new MuIndex instance, or NULL in case of error
55 */
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
56 MuIndex* mu_index_new (MuStore *store, GError **err)
61bc73f @djcb * <many>: use some gcc attributes (if applicable) for optimization
authored
57 G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
2b0aca1 @djcb * initial import of mu - the next generation
authored
58
59
3fa552a @djcb * mu-index: cosmetics
authored
60 /**
2b0aca1 @djcb * initial import of mu - the next generation
authored
61 * destroy the index instance
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
62 *
2b0aca1 @djcb * initial import of mu - the next generation
authored
63 * @param index a MuIndex instance, or NULL
64 */
65 void mu_index_destroy (MuIndex *index);
66
67
3fa552a @djcb * mu-index: cosmetics
authored
68 /**
c76af05 @djcb * make mag-msg-store a configurable parameter; refactor the setting of t...
authored
69 * change the maximum file size that mu-index considers from its
70 * default (MU_INDEX_MAX_FILE_SIZE). Note that the maximum size is a
71 * protection against mu (or the libraries it uses) allocating too
72 * much memory, which can lead to problems
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
73 *
c76af05 @djcb * make mag-msg-store a configurable parameter; refactor the setting of t...
authored
74 * @param index a mu index object
75 * @param max_size the maximum msg size, or 0 to reset to the default
76 */
77 void mu_index_set_max_msg_size (MuIndex *index, guint max_size);
78
79
80 /**
81 * change batch size for Xapian store transaction (see
82 * 'mu_store_set_batch_size')
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
83 *
c76af05 @djcb * make mag-msg-store a configurable parameter; refactor the setting of t...
authored
84 * @param index a mu index object
85 * @param max_size the batch size, or 0 to reset to the default
86 */
87 void mu_index_set_xbatch_size (MuIndex *index, guint xbatchsize);
88
89
90 /**
2b0aca1 @djcb * initial import of mu - the next generation
authored
91 * callback function for mu_index_(run|stats|cleanup), for each message
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
92 *
93 * @param stats pointer to structure to receive statistics data
2b0aca1 @djcb * initial import of mu - the next generation
authored
94 * @param user_data pointer to user data
95 *
96 * @return MU_OK to continue, MU_STOP to stop, or MU_ERROR in
97 * case of some error.
98 */
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
99 typedef MuError (*MuIndexMsgCallback) (MuIndexStats* stats, void *user_data);
2b0aca1 @djcb * initial import of mu - the next generation
authored
100
101
3fa552a @djcb * mu-index: cosmetics
authored
102 /**
2b0aca1 @djcb * initial import of mu - the next generation
authored
103 * callback function for mu_index_(run|stats|cleanup), for each dir enter/leave
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
104 *
2b0aca1 @djcb * initial import of mu - the next generation
authored
105 * @param path dirpath we just entered / left
106 * @param enter did we enter (TRUE) or leave(FALSE) the dir?
107 * @param user_data pointer to user data
108 *
109 * @return MU_OK to contiue, MU_STOP to stopd or MU_ERROR in
110 * case of some error.
111 */
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
112 typedef MuError (*MuIndexDirCallback) (const char* path, gboolean enter,
3fe6eec @djcb * cosmetics
authored
113 void *user_data);
2b0aca1 @djcb * initial import of mu - the next generation
authored
114
3fa552a @djcb * mu-index: cosmetics
authored
115 /**
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
116 * start the indexing process
117 *
2b0aca1 @djcb * initial import of mu - the next generation
authored
118 * @param index a valid MuIndex instance
8448473 @djcb * enforce that maildir paths are absolute
authored
119 * @param path the path to index. This must be an absolute path
2b0aca1 @djcb * initial import of mu - the next generation
authored
120 * @param force if != 0, force re-indexing already index messages; this is
121 * obviously a lot slower than only indexing new/changed messages
bc03af4 @djcb * mu-index: improve cleanup (still WIP), improve documentation; add mu_i...
authored
122 * @param stats a structure with some statistics about the results;
123 * note that this function does *not* reset the struct values to allow
124 * for cumulative stats from multiple calls. If needed, you can use
125 * @mu_index_stats_clear before calling this function
2b0aca1 @djcb * initial import of mu - the next generation
authored
126 * @param cb_msg a callback function called for every msg indexed;
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
127 * @param cb_dir a callback function called for every dir entered/left or NULL
2b0aca1 @djcb * initial import of mu - the next generation
authored
128 * @param user_data a user pointer that will be passed to the callback function
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
129 *
130 * @return MU_OK if the stats gathering was completed succesfully,
2b0aca1 @djcb * initial import of mu - the next generation
authored
131 * MU_STOP if the user stopped or MU_ERROR in
132 * case of some error.
133 */
3fe6eec @djcb * cosmetics
authored
134 MuError mu_index_run (MuIndex *index, const char *path, gboolean force,
e55eb4e @djcb * MuResult/MuExitCode => MuError
authored
135 MuIndexStats *stats, MuIndexMsgCallback msg_cb,
136 MuIndexDirCallback dir_cb, void *user_data);
2b0aca1 @djcb * initial import of mu - the next generation
authored
137
3fa552a @djcb * mu-index: cosmetics
authored
138 /**
2b0aca1 @djcb * initial import of mu - the next generation
authored
139 * gather some statistics about the Maildir; this is usually much faster
140 * than mu_index_run, and can thus be used to provide some information to the user
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
141 * note though that the statistics may be different from the reality that
2b0aca1 @djcb * initial import of mu - the next generation
authored
142 * mu_index_run sees, when there are updates in the Maildir
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
143 *
2b0aca1 @djcb * initial import of mu - the next generation
authored
144 * @param index a valid MuIndex instance
8448473 @djcb * enforce that maildir paths are absolute
authored
145 * @param path the path to get stats for; this must be an absolute path
146 * @param stats a structure with some statistics about the results;
bc03af4 @djcb * mu-index: improve cleanup (still WIP), improve documentation; add mu_i...
authored
147 * note that this function does *not* reset the struct values to allow
148 * for cumulative stats from multiple calls. If needed, you can use
149 * @mu_index_stats_clear before calling this function
fb7e358 @djcb * implement signal handler for mu index, and document it
authored
150 * @param msg_cb a callback function which will be called for every msg;
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
151 * @param dir_cb a callback function which will be called for every dir or NULL
2b0aca1 @djcb * initial import of mu - the next generation
authored
152 * @param user_data a user pointer that will be passed to the callback function
153 * xb
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
154 * @return MU_OK if the stats gathering was completed succesfully,
2b0aca1 @djcb * initial import of mu - the next generation
authored
155 * MU_STOP if the user stopped or MU_ERROR in
156 * case of some error.
157 */
3fe6eec @djcb * cosmetics
authored
158 MuError mu_index_stats (MuIndex *index, const char *path, MuIndexStats *stats,
e55eb4e @djcb * MuResult/MuExitCode => MuError
authored
159 MuIndexMsgCallback msg_cb, MuIndexDirCallback dir_cb,
160 void *user_data);
2b0aca1 @djcb * initial import of mu - the next generation
authored
161
0dd884f @djcb * WIP: mu_index_cleanup
authored
162
163
3fa552a @djcb * mu-index: cosmetics
authored
164 /**
e55eb4e @djcb * MuResult/MuExitCode => MuError
authored
165 * callback function called for each message
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
166 *
167 * @param MuIndexCleanupCallback
168 *
e55eb4e @djcb * MuResult/MuExitCode => MuError
authored
169 * @return a MuResult
0dd884f @djcb * WIP: mu_index_cleanup
authored
170 */
e55eb4e @djcb * MuResult/MuExitCode => MuError
authored
171 typedef MuError (*MuIndexCleanupDeleteCallback) (MuIndexStats *stats,
3fe6eec @djcb * cosmetics
authored
172 void *user_data);
2b0aca1 @djcb * initial import of mu - the next generation
authored
173
3fa552a @djcb * mu-index: cosmetics
authored
174 /**
2b0aca1 @djcb * initial import of mu - the next generation
authored
175 * cleanup the database; ie. remove entries for which no longer a corresponding
176 * file exists in the maildir
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
177 *
2b0aca1 @djcb * initial import of mu - the next generation
authored
178 * @param index a valid MuIndex instance
bc03af4 @djcb * mu-index: improve cleanup (still WIP), improve documentation; add mu_i...
authored
179 * @param stats a structure with some statistics about the results;
180 * note that this function does *not* reset the struct values to allow
181 * for cumulative stats from multiple calls. If needed, you can use
182 * @mu_index_stats_clear before calling this function
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
183 * @param cb a callback function which will be called for every msg;
2b0aca1 @djcb * initial import of mu - the next generation
authored
184 * @param user_data a user pointer that will be passed to the callback function
520307a @djcb * mu-index: update for the store changes
authored
185 * @param err to receive error info or NULL. err->code is MuError value
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
186 *
187 * @return MU_OK if the stats gathering was completed succesfully,
2b0aca1 @djcb * initial import of mu - the next generation
authored
188 * MU_STOP if the user stopped or MU_ERROR in
189 * case of some error.
190 */
e55eb4e @djcb * MuResult/MuExitCode => MuError
authored
191 MuError mu_index_cleanup (MuIndex *index, MuIndexStats *stats,
192 MuIndexCleanupDeleteCallback cb,
520307a @djcb * mu-index: update for the store changes
authored
193 void *user_data, GError **err);
2b0aca1 @djcb * initial import of mu - the next generation
authored
194
3fa552a @djcb * mu-index: cosmetics
authored
195 /**
bc03af4 @djcb * mu-index: improve cleanup (still WIP), improve documentation; add mu_i...
authored
196 * clear the stats structure
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
197 *
bc03af4 @djcb * mu-index: improve cleanup (still WIP), improve documentation; add mu_i...
authored
198 * @param stats a MuIndexStats object
c1d0ccc @djcb * mu-index: take a MuStore rather than paths as arg
authored
199 *
bc03af4 @djcb * mu-index: improve cleanup (still WIP), improve documentation; add mu_i...
authored
200 * @return TRUE if stats != NULL, FALSE otherwise
201 */
202 gboolean mu_index_stats_clear (MuIndexStats *stats);
203
fade417 @djcb * many changes to the config system
authored
204 G_END_DECLS
205
2b0aca1 @djcb * initial import of mu - the next generation
authored
206 #endif /*__MU_INDEX_H__*/
Something went wrong with that request. Please try again.