text stringlengths 0 357 |
|---|
} |
/* get the list of recipients */ |
recipients = dc_param_get(job->param, DC_PARAM_RECIPIENTS, NULL); |
if (!recipients) { |
dc_log_warning(context, 0, "Missing recipients for job %d", job->job_id); |
goto cleanup; |
} |
recipients_list = dc_str_to_clist(recipients, "\x1e"); |
/* if there is a msg-id and it does not exist in the db, cancel sending. |
this happends if dc_delete_msgs() was called |
before the generated mime was sent out */ |
if (job->foreign_id) { |
if(!dc_msg_exists(context, job->foreign_id)) { |
dc_log_warning(context, 0, "Message %i for job %i does not exist", |
job->foreign_id, job->job_id); |
goto cleanup; |
} |
} |
/* send message */ |
{ |
if (!dc_smtp_send_msg(context->smtp, recipients_list, buf, buf_bytes)) { |
if (job->foreign_id && ( |
MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION==context->smtp->error_etpan |
|| MAILSMTP_ERROR_INSUFFICIENT_SYSTEM_STORAGE==context->smtp->error_etpan)) { |
dc_set_msg_failed(context, job->foreign_id, context->smtp->error); |
} |
else { |
dc_smtp_disconnect(context->smtp); |
dc_job_try_again_later(job, DC_AT_ONCE, context->smtp->error); |
} |
goto cleanup; |
} |
} |
/* delete the stores message file */ |
dc_delete_file(context, filename); |
/* an error still means the message is sent, so the rest continues */ |
/* done */ |
if (job->foreign_id) { |
dc_update_msg_state(context, job->foreign_id, DC_STATE_OUT_DELIVERED); |
/* find the chat ID */ |
stmt = dc_sqlite3_prepare(context->sql, "SELECT chat_id FROM msgs WHERE id=?"); |
sqlite3_bind_int(stmt, 1, job->foreign_id); |
/* a deleted message results in an event with chat_id==0, rather than no event at all */ |
int chat_id = sqlite3_step(stmt)==SQLITE_ROW ? sqlite3_column_int(stmt, 0) : 0; |
context->cb(context, DC_EVENT_MSG_DELIVERED, chat_id, job->foreign_id); |
} |
cleanup: |
sqlite3_finalize(stmt); |
if (recipients_list) { |
clist_free_content(recipients_list); |
clist_free(recipients_list); |
} |
free(recipients); |
free(buf); |
free(filename); |
} |
static void dc_send_mdn(dc_context_t* context, uint32_t msg_id) |
{ |
dc_mimefactory_t mimefactory; |
dc_mimefactory_init(&mimefactory, context); |
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC) { |
return; |
} |
if (!dc_mimefactory_load_mdn(&mimefactory, msg_id) |
|| !dc_mimefactory_render(&mimefactory)) { |
goto cleanup; |
} |
//char* t1=dc_null_terminate(mimefactory.out->str,mimefactory.out->len);printf("~~~~~MDN~~~~~\n%s\n~~~~~/MDN~~~~~",t1);free(t1); // DEBUG OUTPUT |
dc_add_smtp_job(context, DC_JOB_SEND_MDN, &mimefactory); |
cleanup: |
dc_mimefactory_empty(&mimefactory); |
} |
static void dc_suspend_smtp_thread(dc_context_t* context, int suspend) |
{ |
pthread_mutex_lock(&context->smtpidle_condmutex); |
context->smtp_suspended = suspend; |
pthread_mutex_unlock(&context->smtpidle_condmutex); |
// if the smtp-thread is currently in dc_perform_smtp_jobs(), |
// wait until the jobs are done. |
// this function is only needed during dc_configure(); |
// for simplicity, we do this by polling a variable. |
if (suspend) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.