text
stringlengths
0
357
* @return None.
*/
void dc_maybe_network(dc_context_t* context)
{
// the following flags are forwarded to dc_job_perform() and make sure,
// sending is tried independingly of retry-count or timeouts.
// if the first messages comes through, the others are be retried as well.
pthread_mutex_lock(&context->smtpidle_condmutex);
context->probe_smtp_network = 1;
pthread_mutex_unlock(&context->smtpidle_condmutex);
pthread_mutex_lock(&context->inboxidle_condmutex);
context->probe_imap_network = 1;
pthread_mutex_unlock(&context->inboxidle_condmutex);
dc_interrupt_smtp_idle(context);
dc_interrupt_imap_idle(context);
dc_interrupt_mvbox_idle(context);
dc_interrupt_sentbox_idle(context);
}
void dc_empty_server(dc_context_t* context, int flags)
{
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC
|| (flags&(DC_EMPTY_INBOX|DC_EMPTY_MVBOX))==0) {
return;
}
dc_job_kill_action(context, DC_JOB_EMPTY_SERVER);
dc_job_add(context, DC_JOB_EMPTY_SERVER, flags, NULL, 0);
}
```
Filename: dc_jobthread.c
```c
#include <stdarg.h>
#include <unistd.h>
#include "dc_context.h"
#include "dc_imap.h"
/*******************************************************************************
* init, exit, suspend-for-configure
******************************************************************************/
void dc_jobthread_init(dc_jobthread_t* jobthread, dc_context_t* context, const char* name,
const char* folder_config_name)
{
if (jobthread==NULL || context==NULL || name==NULL) {
return;
}
jobthread->context = context;
jobthread->name = dc_strdup(name);
jobthread->folder_config_name = dc_strdup(folder_config_name);
jobthread->imap = NULL;
pthread_mutex_init(&jobthread->mutex, NULL);
pthread_cond_init(&jobthread->idle_cond, NULL);
jobthread->idle_condflag = 0;
jobthread->jobs_needed = 0;
jobthread->suspended = 0;
jobthread->using_handle = 0;
}
void dc_jobthread_exit(dc_jobthread_t* jobthread)
{
if (jobthread==NULL) {
return;
}
pthread_cond_destroy(&jobthread->idle_cond);
pthread_mutex_destroy(&jobthread->mutex);
free(jobthread->name);
jobthread->name = NULL;
free(jobthread->folder_config_name);
jobthread->folder_config_name = NULL;
}
void dc_jobthread_suspend(dc_jobthread_t* jobthread, int suspend)
{
if (jobthread==NULL) {
return;
}
if (suspend)
{
dc_log_info(jobthread->context, 0, "Suspending %s-thread.", jobthread->name);
pthread_mutex_lock(&jobthread->mutex);
jobthread->suspended = 1;