1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-05 10:39:27 +02:00

Add set-config-function.

This commit is contained in:
B. Petersen 2016-10-11 16:49:18 +02:00
parent 4588f1bee6
commit 148fa1d605
2 changed files with 25 additions and 9 deletions

View file

@ -512,6 +512,22 @@ char* mrmailbox_get_config(mrmailbox_t* ths, const char* key, const char* def)
}
int mrmailbox_set_config_int(mrmailbox_t* ths, const char* key, int32_t value)
{
int ret;
if( ths == NULL || key == NULL ) {
return 0;
}
mrsqlite3_lock(ths->m_sql); /* CAVE: No return until unlock! */
ret = mrsqlite3_set_config_int_(ths->m_sql, key, value);
mrsqlite3_unlock(ths->m_sql); /* /CAVE: No return until unlock! */
return ret;
}
int32_t mrmailbox_get_config_int(mrmailbox_t* ths, const char* key, int32_t def)
{
int32_t ret;

View file

@ -70,7 +70,7 @@ typedef struct mrmailbox_t
/* mrmailbox_new() creates a new mailbox object. After creation it is usually
opened, connected and mails are fetched; the the corresponding functions below.
opened, connected and mails are fetched; see the corresponding functions below.
After usage, the mailbox object must be freed using mrmailbox_unref(). */
mrmailbox_t* mrmailbox_new ();
void mrmailbox_unref (mrmailbox_t*);
@ -83,20 +83,13 @@ int mrmailbox_open (mrmailbox_t*, const char* d
void mrmailbox_close (mrmailbox_t*);
int mrmailbox_is_open (mrmailbox_t*);
/* ImportSpec() imports data from EML-files. if `spec` is a folder, all EML-files are imported, if `spec` is a file,
a single EML-file is imported, if `spec` is NULL, the last import is done again (you may want to call Empty() before)
ImportFile() always imports a single file, publiuc */
int mrmailbox_import_spec (mrmailbox_t*, const char* spec);
int mrmailbox_import_file (mrmailbox_t*, const char* file);
/* Configure (prepare to connect) a mailbox. There is not need to call this every program start,
/* Configure (prepare to connect) a mailbox. There is no need to call this every program start,
the result is saved in the database. However, mrmailbox_configure() should be called after
any settings change.
*/
int mrmailbox_configure (mrmailbox_t*);
int mrmailbox_is_configured (mrmailbox_t*); /* just checks if at least e-mail and password are given, does not check if the connection works */
/* connect to the mailbox. usually, at least here, mrmailbox will create a working thread.
before a mailbox can be opended, it has to be configured. */
int mrmailbox_connect (mrmailbox_t*);
@ -117,8 +110,15 @@ mrmsg_t* mrmailbox_get_msg_by_id (mrmailbox_t*, uint32_t id);
/* Handle configurations. */
int mrmailbox_set_config (mrmailbox_t*, const char* key, const char* value);
char* mrmailbox_get_config (mrmailbox_t*, const char* key, const char* def);
int mrmailbox_set_config_int (mrmailbox_t*, const char* key, int32_t value);
int32_t mrmailbox_get_config_int (mrmailbox_t*, const char* key, int32_t def);
/* ImportSpec() imports data from EML-files. if `spec` is a folder, all EML-files are imported, if `spec` is a file,
a single EML-file is imported, if `spec` is NULL, the last import is done again (you may want to call Empty() before)
ImportFile() always imports a single file, publiuc */
int mrmailbox_import_spec (mrmailbox_t*, const char* spec);
int mrmailbox_import_file (mrmailbox_t*, const char* file);
/* Misc. */
char* mrmailbox_get_info (mrmailbox_t*); /* multi-line output; the returned string must be free()'d, returns NULL on errors */
int mrmailbox_empty_tables (mrmailbox_t*); /* empty all tables but leaves server configuration. */