Top | ![]() |
![]() |
![]() |
![]() |
#define | CAMEL_DB_ERROR |
enum | CamelDBError |
struct | CamelDB |
#define | CAMEL_DB_FILE |
#define | CAMEL_DB_IN_MEMORY_TABLE |
#define | CAMEL_DB_IN_MEMORY_TABLE_LIMIT |
#define | CAMEL_DB_FREE_CACHE_SIZE |
#define | CAMEL_DB_SLEEP_INTERVAL |
CamelMIRecord | |
CamelFIRecord | |
enum | CamelDBKnownColumnNames |
gint (*CamelDBCollate) (gpointer enc
,gint length1
,gconstpointer data1
,gint length2
,gconstpointer data2
);
A collation callback function.
enc |
a used encoding (SQLITE_UTF8) |
|
length1 |
length of the |
|
data1 |
the first value, of lenth |
|
length2 |
length of the |
|
data2 |
the second value, of lenth |
Since: 2.24
CamelDBKnownColumnNames camel_db_get_column_ident (GHashTable **hash
,gint index
,gint ncols
,gchar **col_names
);
Traverses column name from index index
into an enum
CamelDBKnownColumnNames value. The col_names
contains ncols
columns.
First time this is called is created the hash
from col_names indexes into
the enum, and this is reused for every other call. The function expects
that column names are returned always in the same order. When all rows
are read the hash
table can be freed with g_hash_table_destroy()
.
hash |
a GHashTable. |
[inout] |
index |
an index to start with, between 0 and |
|
ncols |
number of |
|
col_names |
column names to traverse. |
[array length=ncols] |
Since: 3.4
gint (*CamelDBSelectCB) (gpointer user_data
,gint ncol
,gchar **colvalues
,gchar **colnames
);
A callback called for the SELECT statements. The items at the same index of colvalues
and colnames
correspond to each other.
user_data |
a callback user data |
|
ncol |
how many columns is provided |
|
colvalues |
array of column values, as UTF-8 strings. |
[array length=ncol] |
colnames |
array of column names. |
[array length=ncol] |
Since: 2.24
CamelDB * camel_db_new (const gchar *filename
,GError **error
);
filename |
A filename with the database to open/create |
|
error |
return location for a GError, or |
A new CamelDB with filename
as its database file.
Free it with g_object_unref()
when no longer needed.
[transfer full]
Since: 3.24
gint camel_db_command (CamelDB *cdb
,const gchar *stmt
,GError **error
);
Executes an SQLite command.
cdb |
a CamelDB |
|
stmt |
an SQL (SQLite) statement to execute |
|
error |
return location for a GError, or |
Since: 2.24
gint camel_db_transaction_command (CamelDB *cdb
,const GList *qry_list
,GError **error
);
Runs the list of commands as a single transaction.
cdb |
a CamelDB |
|
qry_list |
A GList of querries. |
[element-type utf8][transfer none] |
error |
return location for a GError, or |
Since: 2.24
gint camel_db_begin_transaction (CamelDB *cdb
,GError **error
);
Begins transaction. End it with camel_db_end_transaction()
or camel_db_abort_transaction()
.
Since: 2.24
gint camel_db_add_to_transaction (CamelDB *cdb
,const gchar *query
,GError **error
);
Adds a statement to an ongoing transaction.
cdb |
a CamelDB |
|
query |
an SQL (SQLite) statement |
|
error |
return location for a GError, or |
Since: 2.24
gint camel_db_end_transaction (CamelDB *cdb
,GError **error
);
Ends an ongoing transaction by committing the changes.
Since: 2.24
gint camel_db_abort_transaction (CamelDB *cdb
,GError **error
);
Ends an ongoing transaction by ignoring the changes.
Since: 2.24
gint camel_db_clear_folder_summary (CamelDB *cdb
,const gchar *folder_name
,GError **error
);
Deletes the given folder from the 'folders' table and empties its message info table.
cdb |
a CamelDB |
|
folder_name |
full name of the folder |
|
error |
return location for a GError, or |
Since: 2.24
gint camel_db_rename_folder (CamelDB *cdb
,const gchar *old_folder_name
,const gchar *new_folder_name
,GError **error
);
Renames tables for the old_folder_name
to be used with new_folder_name
.
cdb |
a CamelDB |
|
old_folder_name |
full name of the existing folder |
|
new_folder_name |
full name of the folder to rename it to |
|
error |
return location for a GError, or |
Since: 2.24
gint camel_db_delete_folder (CamelDB *cdb
,const gchar *folder_name
,GError **error
);
Deletes the given folder from the 'folders' table and also drops its message info table.
cdb |
a CamelDB |
|
folder_name |
full name of the folder |
|
error |
return location for a GError, or |
Since: 2.24
gint camel_db_delete_uid (CamelDB *cdb
,const gchar *folder_name
,const gchar *uid
,GError **error
);
Deletes single mesage info in the given folder with the given UID.
cdb |
a CamelDB |
|
folder_name |
full name of the folder |
|
uid |
a message info UID to delete |
|
error |
return location for a GError, or |
Since: 2.24
gint camel_db_delete_uids (CamelDB *cdb
,const gchar *folder_name
,const GList *uids
,GError **error
);
Deletes a list of message UIDs as one transaction.
cdb |
a CamelDB |
|
folder_name |
full name of the folder |
|
uids |
A GList of uids. |
[element-type utf8][transfer none] |
error |
return location for a GError, or |
Since: 2.24
gint camel_db_create_folders_table (CamelDB *cdb
,GError **error
);
Creates a 'folders' table, if it doesn't exist yet.
Since: 2.24
gint camel_db_select (CamelDB *cdb
,const gchar *stmt
,CamelDBSelectCB callback
,gpointer user_data
,GError **error
);
Executes a SELECT staement and calls the callback
for each selected row.
cdb |
a CamelDB |
|
stmt |
a SELECT statment to execute |
|
callback |
a callback to call for each row. |
[scope call][closure user_data] |
user_data |
user data for the |
|
error |
return location for a GError, or |
Since: 2.24
gint camel_db_write_folder_info_record (CamelDB *cdb
,CamelFIRecord *record
,GError **error
);
Write the record
to the 'folders' table.
Since: 2.24
gint camel_db_read_folder_info_record (CamelDB *cdb
,const gchar *folder_name
,CamelFIRecord *record
,GError **error
);
reads folder information for the given folder and stores it into the record
.
cdb |
a CamelDB |
|
folder_name |
full name of the folder |
|
record |
[out caller-allocates] | |
error |
return location for a GError, or |
Since: 2.24
gint camel_db_prepare_message_info_table (CamelDB *cdb
,const gchar *folder_name
,GError **error
);
Prepares message info table for the given folder.
cdb |
a CamelDB |
|
folder_name |
full name of the folder |
|
error |
return location for a GError, or |
Since: 2.24
gint camel_db_write_message_info_record (CamelDB *cdb
,const gchar *folder_name
,CamelMIRecord *record
,GError **error
);
Write the record
to the message info table of the given folder.
cdb |
a CamelDB |
|
folder_name |
full name of the folder |
|
record |
||
error |
return location for a GError, or |
Since: 2.24
gint camel_db_read_message_info_records (CamelDB *cdb
,const gchar *folder_name
,gpointer user_data
,CamelDBSelectCB callback
,GError **error
);
Reads all mesasge info records for the given folder and calls callback
for them.
cdb |
a CamelDB |
|
folder_name |
full name of the folder |
|
user_data |
user data for the |
|
callback |
callback to call for each found row. |
[scope async][closure user_data] |
error |
return location for a GError, or |
Since: 2.24
gint camel_db_read_message_info_record_with_uid (CamelDB *cdb
,const gchar *folder_name
,const gchar *uid
,gpointer user_data
,CamelDBSelectCB callback
,GError **error
);
Selects single message info for the given uid
in folder folder_name
and calls
the callback
for it.
cdb |
a CamelDB |
|
folder_name |
full name of the folder |
|
uid |
a message info UID to read the record for |
|
user_data |
user data of the |
|
callback |
callback to call for the found row. |
[scope call][closure user_data] |
error |
return location for a GError, or |
Since: 2.24
gint camel_db_count_junk_message_info (CamelDB *cdb
,const gchar *table_name
,guint32 *count
,GError **error
);
Counts how many junk messages is stored in the given table.
cdb |
a CamelDB |
|
table_name |
name of the table |
|
count |
where to store the resulting count. |
[out] |
error |
return location for a GError, or |
Since: 2.24
gint camel_db_count_unread_message_info (CamelDB *cdb
,const gchar *table_name
,guint32 *count
,GError **error
);
Counts how many unread messages is stored in the given table.
cdb |
a CamelDB |
|
table_name |
name of the table |
|
count |
where to store the resulting count. |
[out] |
error |
return location for a GError, or |
Since: 2.24
gint camel_db_count_deleted_message_info (CamelDB *cdb
,const gchar *table_name
,guint32 *count
,GError **error
);
Counts how many deleted messages is stored in the given table.
cdb |
a CamelDB |
|
table_name |
name of the table |
|
count |
where to store the resulting count. |
[out] |
error |
return location for a GError, or |
Since: 2.24
gint camel_db_count_total_message_info (CamelDB *cdb
,const gchar *table_name
,guint32 *count
,GError **error
);
Counts how many messages is stored in the given table.
cdb |
a CamelDB |
|
table_name |
name of the table |
|
count |
where to store the resulting count. |
[out] |
error |
return location for a GError, or |
Since: 2.24
gint camel_db_count_visible_message_info (CamelDB *cdb
,const gchar *table_name
,guint32 *count
,GError **error
);
Counts how many visible (not deleted and not junk) messages is stored in the given table.
cdb |
a CamelDB |
|
table_name |
name of the table |
|
count |
where to store the resulting count. |
[out] |
error |
return location for a GError, or |
Since: 2.24
gint camel_db_count_visible_unread_message_info (CamelDB *cdb
,const gchar *table_name
,guint32 *count
,GError **error
);
Counts how many visible (not deleted and not junk) and unread messages is stored in the given table.
cdb |
a CamelDB |
|
table_name |
name of the table |
|
count |
where to store the resulting count. |
[out] |
error |
return location for a GError, or |
Since: 2.24
gint camel_db_count_junk_not_deleted_message_info (CamelDB *cdb
,const gchar *table_name
,guint32 *count
,GError **error
);
gint camel_db_count_message_info (CamelDB *cdb
,const gchar *query
,guint32 *count
,GError **error
);
Executes a COUNT()
query (like "SELECT COUNT(*) FROM table") and provides
the result of it as an unsigned 32-bit integer.
cdb |
a CamelDB |
|
query |
a |
|
count |
the result of the query. |
[out] |
error |
return location for a GError, or |
Since: 2.26
gint camel_db_get_folder_uids (CamelDB *cdb
,const gchar *folder_name
,const gchar *sort_by
,const gchar *collate
,GHashTable *hash
,GError **error
);
Fills hash with uid->GUINT_TO_POINTER (flag). Use camel_pstring_free()
to free the keys of the hash
.
cdb |
a CamelDB |
|
folder_name |
full name of the folder |
|
sort_by |
optional ORDER BY clause (without the "ORDER BY" prefix). |
[nullable] |
collate |
optional collate function name to use. |
[nullable] |
hash |
a hash table to fill. |
[element-type utf8 guint32] |
error |
return location for a GError, or |
Since: 2.24
GPtrArray * camel_db_get_folder_junk_uids (CamelDB *cdb
,const gchar *folder_name
,GError **error
);
cdb |
a CamelDB |
|
folder_name |
full name of the folder |
|
error |
return location for a GError, or |
An array
of the UID-s of the junk messages in the given folder. Use
camel_pstring_free()
to free the elements.
[element-type utf8][transfer full][nullable]
Since: 2.24
GPtrArray * camel_db_get_folder_deleted_uids (CamelDB *cdb
,const gchar *folder_name
,GError **error
);
cdb |
a CamelDB |
|
folder_name |
full name of the folder |
|
error |
return location for a GError, or |
An array
of the UID-s of the deleted messages in the given folder. Use
camel_pstring_free()
to free the elements.
[element-type utf8][transfer full][nullable]
Since: 2.24
gint camel_db_set_collate (CamelDB *cdb
,const gchar *col
,const gchar *collate
,CamelDBCollate func
);
Defines a collation collate
, which can be used in SQL (SQLite)
statement as a collation function. The func
is called when
colation is used.
cdb |
a CamelDB |
|
col |
a column name; currently unused |
|
collate |
collation name |
|
func |
a CamelDBCollate collation function. |
[scope call] |
Since: 2.24
gint camel_db_start_in_memory_transactions (CamelDB *cdb
,GError **error
);
Creates an in-memory table for a batch transactions. Use camel_db_flush_in_memory_transactions()
to commit the changes and free the in-memory table.
Since: 2.26
gint camel_db_flush_in_memory_transactions (CamelDB *cdb
,const gchar *folder_name
,GError **error
);
A pair function for camel_db_start_in_memory_transactions()
,
to commit the changes to folder_name
and free the in-memory table.
cdb |
a CamelDB |
|
folder_name |
full name of the folder |
|
error |
return location for a GError, or |
Since: 2.26
gint camel_db_reset_folder_version (CamelDB *cdb
,const gchar *folder_name
,gint reset_version
,GError **error
);
Sets a version number for the given folder.
cdb |
a CamelDB |
|
folder_name |
full name of the folder |
|
reset_version |
version number to set |
|
error |
return location for a GError, or |
Since: 2.28
gboolean camel_db_maybe_run_maintenance (CamelDB *cdb
,GError **error
);
Runs a cdb
maintenance, which includes vacuum, if necessary.
Since: 3.16
void
camel_db_release_cache_memory (void
);
Instructs sqlite to release its memory, if possible. This can be avoided when CAMEL_SQLITE_FREE_CACHE environment variable is set.
Since: 3.24
gchar *
camel_db_sqlize_string (const gchar *string
);
Converts the string
to be usable in the SQLite statements.
A newly allocated sqlized string
. The returned
value should be freed with camel_db_sqlize_string()
, when no longer needed.
[transfer full]
Since: 2.24
void
camel_db_free_sqlized_string (gchar *string
);
Frees a string previosuly returned by camel_db_sqlize_string()
.
Since: 2.24
gchar *
camel_db_get_column_name (const gchar *raw_name
);
A corresponding column name in the message info table
for the raw_name
, or NULL
, when there is no corresponding column in the summary.
[nullable]
Since: 2.24
void
camel_db_camel_mir_free (CamelMIRecord *record
);
Frees the record
and all of its associated data.
Since: 2.24
typedef struct { const gchar *uid; /* stored in the string pool */ guint32 flags; guint32 msg_type; guint32 dirty; gboolean read; gboolean deleted; gboolean replied; gboolean important; gboolean junk; gboolean attachment; guint32 size; gint64 dsent; /* time_t */ gint64 dreceived; /* time_t */ const gchar *subject; /* stored in the string pool */ const gchar *from; /* stored in the string pool */ const gchar *to; /* stored in the string pool */ const gchar *cc; /* stored in the string pool */ const gchar *mlist; /* stored in the string pool */ gchar *followup_flag; gchar *followup_completed_on; gchar *followup_due_by; gchar *part; gchar *labels; gchar *usertags; gchar *cinfo; gchar *bdata; gchar *userheaders; gchar *preview; } CamelMIRecord;
The extensive DB format, supporting basic searching and sorting.
Message UID |
||
Camel Message info flags |
||
unused |
||
whether the message info requires upload to the server; it corresponds to CAMEL_MESSAGE_FOLDER_FLAGGED |
||
boolean read status |
||
boolean deleted status |
||
boolean replied status |
||
boolean important status |
||
boolean junk status |
||
boolean attachment status |
||
size of the mail |
||
date sent |
||
date received |
||
subject of the mail |
||
sender |
||
recipient |
||
CC members |
||
message list headers |
||
followup flag / also can be queried to see for followup or not |
||
completed date, can be used to see if completed |
||
to see the due by date |
||
part / references / thread id |
||
labels of mails also called as userflags |
||
composite string of user tags |
||
content info string - composite string |
||
provider specific data |
||
value for user-defined message headers; Since: 3.42 |
||
message body preview; Since: 3.42 |
Since: 2.24
typedef struct { gchar *folder_name; guint32 version; guint32 flags; guint32 nextuid; gint64 timestamp; guint32 saved_count; guint32 unread_count; guint32 deleted_count; guint32 junk_count; guint32 visible_count; guint32 jnd_count; /* Junked not deleted */ gchar *bdata; } CamelFIRecord;
Values to store/load for single folder's CamelFolderSummary structure.
name of the folder |
||
version of the saved information |
||
folder flags |
||
next free uid |
||
timestamp of the summary |
||
count of all messages |
||
count of unread messages |
||
count of deleted messages |
||
count of junk messages |
||
count of visible (not deleted and not junk) messages |
||
count of junk and not deleted messages |
||
custom data of the CamelFolderSummary descendants |
Since: 2.24
An enum of all the known columns, which can be used for a quick column lookups.
unknown column name |
||
attachment |
||
bdata |
||
cinfo |
||
deleted |
||
deleted_count |
||
dreceived |
||
dsent |
||
flags |
||
folder_name |
||
followup_completed_on |
||
followup_due_by |
||
followup_flag |
||
important |
||
jnd_count |
||
junk |
||
junk_count |
||
labels |
||
mail_cc |
||
mail_from |
||
mail_to |
||
mlist |
||
nextuid |
||
part |
||
preview |
||
read |
||
replied |
||
saved_count |
||
size |
||
subject |
||
time |
||
uid |
||
unread_count |
||
userheaders |
||
usertags |
||
version |
||
visible_count |
||
vuid |
Since: 3.4