text
stringlengths
0
357
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC) {
return;
}
int use_network = dc_sqlite3_get_config_int(context->sql, "sentbox_watch", DC_SENTBOX_WATCH_DEFAULT);
dc_jobthread_fetch(&context->sentbox_thread, use_network);
}
/**
* Wait for messages or jobs in the SENTBOX-thread.
* This function and dc_perform_sentbox_fetch()
* must be called from the same thread, typically in a loop.
*
* @memberof dc_context_t
* @param context The context as created by dc_context_new().
* @return None.
*/
void dc_perform_sentbox_idle(dc_context_t* context)
{
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC) {
return;
}
int use_network = dc_sqlite3_get_config_int(context->sql, "sentbox_watch", DC_SENTBOX_WATCH_DEFAULT);
dc_jobthread_idle(&context->sentbox_thread, use_network);
}
/**
* Interrupt waiting for messages or jobs in the SENTBOX-thread.
*
* @memberof dc_context_t
* @param context The context as created by dc_context_new().
* @return None.
*/
void dc_interrupt_sentbox_idle(dc_context_t* context)
{
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC) {
dc_log_warning(context, 0, "Interrupt SENT-IDLE: Bad parameters.");
return;
}
dc_jobthread_interrupt_idle(&context->sentbox_thread);
}
/*******************************************************************************
* User-functions handle SMTP-jobs from the SMTP-thread
******************************************************************************/
/**
* Execute pending smtp-jobs.
* This function and dc_perform_smtp_idle() must be called from the same thread,
* typically in a loop.
*
* Example:
*
* void* smtp_thread_func(void* context)
* {
* while (true) {
* dc_perform_smtp_jobs(context);
* dc_perform_smtp_idle(context);
* }
* }
*
* // start smtp-thread that runs forever
* pthread_t smtp_thread;
* pthread_create(&smtp_thread, NULL, smtp_thread_func, context);
*
* ... program runs ...
*
* // network becomes available again -
* // the interrupt causes dc_perform_smtp_idle() in the thread above
* // to return so that jobs are executed
* dc_maybe_network(context);
*
* @memberof dc_context_t
* @param context The context as created by dc_context_new().
* @return None.
*/
void dc_perform_smtp_jobs(dc_context_t* context)
{
pthread_mutex_lock(&context->smtpidle_condmutex);
int probe_smtp_network = context->probe_smtp_network;
context->probe_smtp_network = 0;
context->perform_smtp_jobs_needed = 0;
if (context->smtp_suspended) {
dc_log_info(context, 0, "SMTP-jobs suspended.");
pthread_mutex_unlock(&context->smtpidle_condmutex);
return;
}
context->smtp_doing_jobs = 1;
pthread_mutex_unlock(&context->smtpidle_condmutex);
dc_log_info(context, 0, "SMTP-jobs started...");
dc_job_perform(context, DC_SMTP_THREAD, probe_smtp_network);
dc_log_info(context, 0, "SMTP-jobs ended.");