1 /* Srinivasa Ragavan - <sragavan@novell.com> - GPL v2 or later */
3 #if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
4 #error "Only <camel/camel.h> can be included directly."
18 #define CAMEL_DB_FILE "folders.db"
20 /* Hopefully no one will create a folder named EVO_IN_meM_hAnDlE */
23 * CAMEL_DB_IN_MEMORY_TABLE:
27 #define CAMEL_DB_IN_MEMORY_TABLE "EVO_IN_meM_hAnDlE.temp"
30 * CAMEL_DB_IN_MEMORY_DB:
34 #define CAMEL_DB_IN_MEMORY_DB "EVO_IN_meM_hAnDlE"
37 * CAMEL_DB_IN_MEMORY_TABLE_LIMIT:
41 #define CAMEL_DB_IN_MEMORY_TABLE_LIMIT 100000
43 typedef struct _CamelDBPrivate CamelDBPrivate;
50 typedef gint (*CamelDBCollate)(gpointer, gint, gconstpointer, gint, gconstpointer );
59 /* this lock has been replaced with a rw lock which sits inside priv.
60 * This is currently unused. Keeping it, not to break the ABI */
66 * CAMEL_DB_FREE_CACHE_SIZE:
70 #define CAMEL_DB_FREE_CACHE_SIZE 2 * 1024 * 1024
73 * CAMEL_DB_SLEEP_INTERVAL:
77 #define CAMEL_DB_SLEEP_INTERVAL 1*10*10
80 * CAMEL_DB_RELEASE_SQLITE_MEMORY:
84 #define CAMEL_DB_RELEASE_SQLITE_MEMORY if(!g_getenv("CAMEL_SQLITE_FREE_CACHE")) sqlite3_release_memory(CAMEL_DB_FREE_CACHE_SIZE);
87 * CAMEL_DB_USE_SHARED_CACHE:
91 #define CAMEL_DB_USE_SHARED_CACHE if(g_getenv("CAMEL_SQLITE_SHARED_CACHE")) sqlite3_enable_shared_cache(TRUE);
98 * Camel Message info flags
102 * boolean read status
104 * boolean deleted status
106 * boolean replied status
108 * boolean important status
110 * boolean junk status
112 * boolean attachment status
120 * subject of the mail
128 * message list headers
130 * followup flag / also can be queried to see for followup or not
131 * @followup_completed_on:
132 * completed date, can be used to see if completed
134 * to see the due by date
136 * part / references / thread id
138 * labels of mails also called as userflags
140 * composite string of user tags
142 * content info string - composite string
144 * provider specific data
147 * The extensive DB format, supporting basic searching and sorting.
151 typedef struct _CamelMIRecord {
170 gchar *followup_flag;
171 gchar *followup_completed_on;
172 gchar *followup_due_by;
178 gchar *bodystructure;
186 typedef struct _CamelFIRecord {
193 guint32 unread_count;
194 guint32 deleted_count;
196 guint32 visible_count;
197 guint32 jnd_count; /* Junked not deleted */
201 typedef struct _CamelDB CamelDB;
204 * CamelDBKnownColumnNames:
209 CAMEL_DB_COLUMN_UNKNOWN = -1,
210 CAMEL_DB_COLUMN_ATTACHMENT,
211 CAMEL_DB_COLUMN_BDATA,
212 CAMEL_DB_COLUMN_BODYSTRUCTURE,
213 CAMEL_DB_COLUMN_CINFO,
214 CAMEL_DB_COLUMN_DELETED,
215 CAMEL_DB_COLUMN_DELETED_COUNT,
216 CAMEL_DB_COLUMN_DRECEIVED,
217 CAMEL_DB_COLUMN_DSENT,
218 CAMEL_DB_COLUMN_FLAGS,
219 CAMEL_DB_COLUMN_FOLDER_NAME,
220 CAMEL_DB_COLUMN_FOLLOWUP_COMPLETED_ON,
221 CAMEL_DB_COLUMN_FOLLOWUP_DUE_BY,
222 CAMEL_DB_COLUMN_FOLLOWUP_FLAG,
223 CAMEL_DB_COLUMN_IMPORTANT,
224 CAMEL_DB_COLUMN_JND_COUNT,
225 CAMEL_DB_COLUMN_JUNK,
226 CAMEL_DB_COLUMN_JUNK_COUNT,
227 CAMEL_DB_COLUMN_LABELS,
228 CAMEL_DB_COLUMN_MAIL_CC,
229 CAMEL_DB_COLUMN_MAIL_FROM,
230 CAMEL_DB_COLUMN_MAIL_TO,
231 CAMEL_DB_COLUMN_MLIST,
232 CAMEL_DB_COLUMN_NEXTUID,
233 CAMEL_DB_COLUMN_PART,
234 CAMEL_DB_COLUMN_PREVIEW,
235 CAMEL_DB_COLUMN_READ,
236 CAMEL_DB_COLUMN_REPLIED,
237 CAMEL_DB_COLUMN_SAVED_COUNT,
238 CAMEL_DB_COLUMN_SIZE,
239 CAMEL_DB_COLUMN_SUBJECT,
240 CAMEL_DB_COLUMN_TIME,
242 CAMEL_DB_COLUMN_UNREAD_COUNT,
243 CAMEL_DB_COLUMN_USERTAGS,
244 CAMEL_DB_COLUMN_VERSION,
245 CAMEL_DB_COLUMN_VISIBLE_COUNT,
247 } CamelDBKnownColumnNames;
249 CamelDBKnownColumnNames camel_db_get_column_ident (GHashTable **hash, gint index, gint ncols, gchar **col_names);
256 typedef gint (*CamelDBSelectCB) (gpointer data, gint ncol, gchar **colvalues, gchar **colnames);
258 CamelDB * camel_db_open (const gchar *path, GError **error);
259 CamelDB * camel_db_clone (CamelDB *cdb, GError **error);
260 void camel_db_close (CamelDB *cdb);
261 gint camel_db_command (CamelDB *cdb, const gchar *stmt, GError **error);
263 gint camel_db_transaction_command (CamelDB *cdb, GList *qry_list, GError **error);
265 gint camel_db_begin_transaction (CamelDB *cdb, GError **error);
266 gint camel_db_add_to_transaction (CamelDB *cdb, const gchar *query, GError **error);
267 gint camel_db_end_transaction (CamelDB *cdb, GError **error);
268 gint camel_db_abort_transaction (CamelDB *cdb, GError **error);
269 gint camel_db_clear_folder_summary (CamelDB *cdb, const gchar *folder, GError **error);
270 gint camel_db_rename_folder (CamelDB *cdb, const gchar *old_folder, const gchar *new_folder, GError **error);
272 gint camel_db_delete_folder (CamelDB *cdb, const gchar *folder, GError **error);
273 gint camel_db_delete_uid (CamelDB *cdb, const gchar *folder, const gchar *uid, GError **error);
274 /*int camel_db_delete_uids (CamelDB *cdb, GError **error, gint nargs, ... );*/
275 gint camel_db_delete_uids (CamelDB *cdb, const gchar * folder_name, GList *uids, GError **error);
277 gint camel_db_create_folders_table (CamelDB *cdb, GError **error);
278 gint camel_db_select (CamelDB *cdb, const gchar * stmt, CamelDBSelectCB callback, gpointer data, GError **error);
280 gint camel_db_write_folder_info_record (CamelDB *cdb, CamelFIRecord *record, GError **error);
281 gint camel_db_read_folder_info_record (CamelDB *cdb, const gchar *folder_name, CamelFIRecord *record, GError **error);
283 gint camel_db_prepare_message_info_table (CamelDB *cdb, const gchar *folder_name, GError **error);
285 gint camel_db_write_message_info_record (CamelDB *cdb, const gchar *folder_name, CamelMIRecord *record, GError **error);
286 gint camel_db_write_fresh_message_info_record (CamelDB *cdb, const gchar *folder_name, CamelMIRecord *record, GError **error);
287 gint camel_db_read_message_info_records (CamelDB *cdb, const gchar *folder_name, gpointer p, CamelDBSelectCB read_mir_callback, GError **error);
288 gint camel_db_read_message_info_record_with_uid (CamelDB *cdb, const gchar *folder_name, const gchar *uid, gpointer p, CamelDBSelectCB read_mir_callback, GError **error);
290 gint camel_db_count_junk_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, GError **error);
291 gint camel_db_count_unread_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, GError **error);
292 gint camel_db_count_deleted_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, GError **error);
293 gint camel_db_count_total_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, GError **error);
295 gint camel_db_count_visible_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, GError **error);
296 gint camel_db_count_visible_unread_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, GError **error);
298 gint camel_db_count_junk_not_deleted_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, GError **error);
299 gint camel_db_count_message_info (CamelDB *cdb, const gchar *query, guint32 *count, GError **error);
300 void camel_db_camel_mir_free (CamelMIRecord *record);
302 gint camel_db_get_folder_uids (CamelDB *db, const gchar *folder_name, const gchar *sort_by, const gchar *collate, GHashTable *hash, GError **error);
304 GPtrArray * camel_db_get_folder_junk_uids (CamelDB *db, gchar *folder_name, GError **error);
305 GPtrArray * camel_db_get_folder_deleted_uids (CamelDB *db, const gchar *folder_name, GError **error);
307 gchar * camel_db_sqlize_string (const gchar *string);
308 void camel_db_free_sqlized_string (gchar *string);
310 gchar * camel_db_get_column_name (const gchar *raw_name);
311 gint camel_db_set_collate (CamelDB *cdb, const gchar *col, const gchar *collate, CamelDBCollate func);
313 gint camel_db_start_in_memory_transactions (CamelDB *cdb, GError **error);
314 gint camel_db_flush_in_memory_transactions (CamelDB *cdb, const gchar * folder_name, GError **error);
317 camel_db_get_folder_preview (CamelDB *db, const gchar *folder_name, GError **error);
318 gint camel_db_write_preview_record (CamelDB *db, const gchar *folder_name, const gchar *uid, const gchar *msg, GError **error);
321 camel_db_reset_folder_version (CamelDB *cdb, const gchar *folder_name, gint reset_version, GError **error);