text stringlengths 0 357 |
|---|
} |
/* Create/open sqlite database, this may already use the blobdir */ |
if (!dc_sqlite3_open(context->sql, dbfile, 0)) { |
goto cleanup; |
} |
success = 1; |
cleanup: |
if (!success) { |
dc_close(context); |
} |
return success; |
} |
/** |
* Close context database opened by dc_open(). |
* Before this, connections to SMTP and IMAP are closed; these connections |
* are started automatically as needed eg. by sending for fetching messages. |
* This function is also implicitly called by dc_context_unref(). |
* Multiple calls to this functions are okay, the function takes care not |
* to free objects twice. |
* |
* @memberof dc_context_t |
* @param context The context object as created by dc_context_new(). |
* @return None. |
*/ |
void dc_close(dc_context_t* context) |
{ |
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC) { |
return; |
} |
dc_imap_disconnect(context->inbox); |
dc_imap_disconnect(context->sentbox_thread.imap); |
dc_imap_disconnect(context->mvbox_thread.imap); |
dc_smtp_disconnect(context->smtp); |
if (dc_sqlite3_is_open(context->sql)) { |
dc_sqlite3_close(context->sql); |
} |
free(context->dbfile); |
context->dbfile = NULL; |
free(context->blobdir); |
context->blobdir = NULL; |
} |
/** |
* Check if the context database is open. |
* |
* @memberof dc_context_t |
* @param context The context object as created by dc_context_new(). |
* @return 0=context is not open, 1=context is open. |
*/ |
int dc_is_open(const dc_context_t* context) |
{ |
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC) { |
return 0; /* error - database not opened */ |
} |
return dc_sqlite3_is_open(context->sql); |
} |
/** |
* Get the blob directory. |
* |
* @memberof dc_context_t |
* @param context The context object as created by dc_context_new(). |
* @return Blob directory associated with the context object, empty string if unset or on errors. NULL is never returned. |
* The returned string must be free()'d. |
*/ |
char* dc_get_blobdir(const dc_context_t* context) |
{ |
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC) { |
return dc_strdup(NULL); |
} |
return dc_strdup(context->blobdir); |
} |
/******************************************************************************* |
* INI-handling, Information |
******************************************************************************/ |
static int is_settable_config_key(const char* key) |
{ |
for (int i = 0; i < str_array_len(config_keys); i++) { |
if (strcmp(key, config_keys[i]) == 0) { |
return 1; |
} |
} |
return 0; |
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.