text stringlengths 0 357 |
|---|
char* fwdhint = NULL; |
if (afwd_email) { |
fwdhint = dc_strdup("---------- Forwarded message ----------" LINEEND "From: Delta Chat" LINEEND LINEEND); /* do not chage this! expected this way in the simplifier to detect forwarding! */ |
} |
const char* final_text = NULL; |
if (placeholdertext) { |
final_text = placeholdertext; |
} |
else if (msg->text && msg->text[0]) { |
final_text = msg->text; |
} |
char* footer = factory->selfstatus; |
message_text = dc_mprintf("%s%s%s%s%s", |
fwdhint? fwdhint : "", |
final_text? final_text : "", |
(final_text&&footer&&footer[0])? (LINEEND LINEEND) : "", |
(footer&&footer[0])? ("-- " LINEEND) : "", |
(footer&&footer[0])? footer : ""); |
struct mailmime* text_part = build_body_text(message_text); |
mailmime_smart_add_part(message, text_part); |
parts++; |
free(fwdhint); |
free(placeholdertext); |
/* add attachment part */ |
if (DC_MSG_NEEDS_ATTACHMENT(msg->type)) { |
if (!is_file_size_okay(msg)) { |
char* error = dc_mprintf("Message exceeds the recommended %i MB.", DC_MSGSIZE_MAX_RECOMMENDED/1000/1000); |
set_error(factory, error); |
free(error); |
goto cleanup; |
} |
struct mailmime* file_part = build_body_file(msg, NULL, NULL); |
if (file_part) { |
mailmime_smart_add_part(message, file_part); |
parts++; |
} |
} |
if (parts==0) { |
set_error(factory, "Empty message."); |
goto cleanup; |
} |
if (meta_part) { |
mailmime_smart_add_part(message, meta_part); /* meta parts are only added if there are other parts */ |
parts++; |
} |
if (dc_param_exists(msg->param, DC_PARAM_SET_LATITUDE)) { |
double latitude = dc_param_get_float(msg->param, DC_PARAM_SET_LATITUDE, 0.0); |
double longitude = dc_param_get_float(msg->param, DC_PARAM_SET_LONGITUDE, 0.0); |
char* kml_file = dc_get_message_kml(msg->context, msg->timestamp_sort, latitude, longitude); |
if (kml_file) { |
struct mailmime_content* content_type = mailmime_content_new_with_str("application/vnd.google-earth.kml+xml"); |
struct mailmime_fields* mime_fields = mailmime_fields_new_filename(MAILMIME_DISPOSITION_TYPE_ATTACHMENT, |
dc_strdup("message.kml"), MAILMIME_MECHANISM_8BIT); |
struct mailmime* kml_mime_part = mailmime_new_empty(content_type, mime_fields); |
mailmime_set_body_text(kml_mime_part, kml_file, strlen(kml_file)); |
mailmime_smart_add_part(message, kml_mime_part); |
parts++; |
} |
} |
if (dc_is_sending_locations_to_chat(msg->context, msg->chat_id)) { |
uint32_t last_added_location_id = 0; |
char* kml_file = dc_get_location_kml(msg->context, msg->chat_id, |
&last_added_location_id); |
if (kml_file) { |
struct mailmime_content* content_type = mailmime_content_new_with_str("application/vnd.google-earth.kml+xml"); |
struct mailmime_fields* mime_fields = mailmime_fields_new_filename(MAILMIME_DISPOSITION_TYPE_ATTACHMENT, |
dc_strdup("location.kml"), MAILMIME_MECHANISM_8BIT); |
struct mailmime* kml_mime_part = mailmime_new_empty(content_type, mime_fields); |
mailmime_set_body_text(kml_mime_part, kml_file, strlen(kml_file)); |
mailmime_smart_add_part(message, kml_mime_part); |
parts++; |
if (!dc_param_exists(msg->param, DC_PARAM_SET_LATITUDE)) { // otherwise, the independent location is already filed |
factory->out_last_added_location_id = last_added_location_id; |
} |
} |
} |
} |
else if (factory->loaded==DC_MF_MDN_LOADED) |
{ |
/* Render a MDN |
*********************************************************************/ |
struct mailmime* multipart = mailmime_multiple_new("multipart/report"); /* RFC 6522, this also requires the `report-type` parameter which is equal to the MIME subtype of the second body part of the multipart/report */ |
struct mailmime_content* content = multipart->mm_content_type; |
clist_append(content->ct_parameters, mailmime_param_new_with_data("report-type", "disposition-notification")); /* RFC */ |
mailmime_add_part(message, multipart); |
/* first body part: always human-readable, always REQUIRED by RFC 6522 */ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.