text
stringlengths
0
357
}
}
if (dc_imap_set_seen(context->inbox, folder, uid)==0) {
dc_job_try_again_later(job, DC_STANDARD_DELAY, NULL);
}
if (dc_param_get_int(job->param, DC_PARAM_ALSO_MOVE, 0))
{
if (dc_sqlite3_get_config_int(context->sql, "folders_configured", 0)<DC_FOLDERS_CONFIGURED_VERSION) {
dc_configure_folders(context, context->inbox, DC_CREATE_MVBOX);
}
dest_folder = dc_sqlite3_get_config(context->sql, "configured_mvbox_folder", NULL);
switch (dc_imap_move(context->inbox, folder, uid, dest_folder, &dest_uid)) {
case DC_FAILED: goto cleanup;
case DC_RETRY_LATER: dc_job_try_again_later(job, DC_STANDARD_DELAY, NULL); break;
default: break;
}
}
cleanup:
free(folder);
free(dest_folder);
}
/*******************************************************************************
* SMTP-jobs
******************************************************************************/
/**
* Store the MIME message in a file and send it later with a new SMTP job.
*
* @param context The context object as created by dc_context_new()
* @param action One of the DC_JOB_SEND_ constants
* @param mimefactory An instance of dc_mimefactory_t with a loaded and rendered message or MDN
* @return 1=success, 0=error
*/
static int dc_add_smtp_job(dc_context_t* context, int action, dc_mimefactory_t* mimefactory)
{
char* pathNfilename = NULL;
int success = 0;
char* recipients = NULL;
dc_param_t* param = dc_param_new();
// find a free file name in the blob directory
pathNfilename = dc_get_fine_pathNfilename(context, "$BLOBDIR", mimefactory->rfc724_mid);
if (!pathNfilename) {
dc_log_error(context, 0, "Could not find free file name for message with ID <%s>.", mimefactory->rfc724_mid);
goto cleanup;
}
// write the file
if (!dc_write_file(context, pathNfilename, mimefactory->out->str, mimefactory->out->len)) {
dc_log_error(context, 0, "Could not write message <%s> to \"%s\".", mimefactory->rfc724_mid, pathNfilename);
goto cleanup;
}
// store recipients in job param
recipients = dc_str_from_clist(mimefactory->recipients_addr, "\x1e");
dc_param_set(param, DC_PARAM_FILE, pathNfilename);
dc_param_set(param, DC_PARAM_RECIPIENTS, recipients);
dc_job_add(context, action, mimefactory->loaded==DC_MF_MSG_LOADED ? mimefactory->msg->id : 0, param->packed, 0);
success = 1;
cleanup:
dc_param_unref(param);
free(recipients);
free(pathNfilename);
return success;
}
/**
* Create an SMTP job to send a message from the DB
*
* @param context The context object as created by dc_context_new()
* @param msg_id The ID of the message to send
* @return 1=success, 0=error
*/
int dc_job_send_msg(dc_context_t* context, uint32_t msg_id)
{
int success = 0;
dc_mimefactory_t mimefactory;
dc_mimefactory_init(&mimefactory, context);
/* load message data */
if (!dc_mimefactory_load_msg(&mimefactory, msg_id)
|| mimefactory.from_addr==NULL) {
dc_log_warning(context, 0, "Cannot load data to send, maybe the message is deleted in between.");
goto cleanup; // no redo, no IMAP. moreover, as the data does not exist, there is no need in calling dc_set_msg_failed()
}
/* set width/height of images, if not yet done */
if (DC_MSG_NEEDS_ATTACHMENT(mimefactory.msg->type)) {