text stringlengths 0 357 |
|---|
/** |
* Wait for messages or jobs. |
* This function and dc_perform_imap_jobs() and dc_perform_imap_fetch() must be called from the same thread, |
* typically in a loop. |
* |
* You should call this function directly after calling dc_perform_imap_fetch(). |
* |
* See dc_perform_imap_jobs() for an example. |
* |
* @memberof dc_context_t |
* @param context The context as created by dc_context_new(). |
* @return None. |
*/ |
void dc_perform_imap_idle(dc_context_t* context) |
{ |
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC) { |
return; |
} |
// also idle if connection fails because of not-configured, |
// no-network, whatever. dc_imap_idle() will handle this by the fake-idle and log a warning |
connect_to_inbox(context); |
pthread_mutex_lock(&context->inboxidle_condmutex); |
if (context->perform_inbox_jobs_needed) { |
dc_log_info(context, 0, "INBOX-IDLE will not be started because of waiting jobs."); |
pthread_mutex_unlock(&context->inboxidle_condmutex); |
return; |
} |
pthread_mutex_unlock(&context->inboxidle_condmutex); |
// TODO: optimisation: inbox_watch should also be regarded here to save some bytes. |
// however, the thread and the imap connection are needed even if inbox_watch is disabled |
// as the jobs are happending here. |
// anyway, the best way would be to switch this thread also to dc_jobthread_t |
// which has all the needed capabilities. |
dc_log_info(context, 0, "INBOX-IDLE started..."); |
dc_imap_idle(context->inbox); |
dc_log_info(context, 0, "INBOX-IDLE ended."); |
} |
/** |
* Interrupt waiting for imap-jobs. |
* If dc_perform_imap_jobs(), dc_perform_imap_fetch() and dc_perform_imap_idle() are called in a loop, |
* calling this function causes imap-jobs to be executed and messages to be fetched. |
* |
* dc_interrupt_imap_idle() does _not_ interrupt dc_perform_imap_jobs() or dc_perform_imap_fetch(). |
* If the imap-thread is inside one of these functions when dc_interrupt_imap_idle() is called, however, |
* the next call of the imap-thread to dc_perform_imap_idle() is interrupted immediately. |
* |
* Internally, this function is called whenever a imap-jobs should be processed |
* (delete message, markseen etc.). |
* |
* When you need to call this function just because to get jobs done after network changes, |
* use dc_maybe_network() instead. |
* |
* @memberof dc_context_t |
* @param context The context as created by dc_context_new(). |
* @return None. |
*/ |
void dc_interrupt_imap_idle(dc_context_t* context) |
{ |
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC || context->inbox==NULL) { |
dc_log_warning(context, 0, "Interrupt IMAP-IDLE: Bad parameters."); |
return; |
} |
dc_log_info(context, 0, "Interrupting IMAP-IDLE..."); |
pthread_mutex_lock(&context->inboxidle_condmutex); |
// when this function is called, it might be that the idle-thread is in |
// perform_idle_jobs() instead of idle(). if so, added jobs will be performed after the _next_ idle-jobs loop. |
// setting the flag perform_imap_jobs_needed makes sure, idle() returns immediately in this case. |
context->perform_inbox_jobs_needed = 1; |
pthread_mutex_unlock(&context->inboxidle_condmutex); |
dc_imap_interrupt_idle(context->inbox); |
} |
/******************************************************************************* |
* User-functions to handle IMAP-jobs in the secondary IMAP-thread |
******************************************************************************/ |
/** |
* Fetch new messages from the MVBOX, if any. |
* The MVBOX is a folder on the account where chat messages are moved to. |
* The moving is done to not disturb shared accounts that are used by both, |
* Delta Chat and a classical MUA. |
* |
* This function and dc_perform_mvbox_idle() |
* must be called from the same thread, typically in a loop. |
* |
* Example: |
* |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.