text stringlengths 0 357 |
|---|
if (sqlite3_column_type(stmt, 0)==SQLITE_NULL) { |
dc_log_info(context, 0, "[autocrypt] no peerstate for %s", |
sqlite3_column_text(stmt, 1)); |
can_encrypt = 0; |
all_mutual = 0; |
} |
else { |
/* the peerstate exist, so we have either public_key or gossip_key and can encrypt potentially */ |
int prefer_encrypted = sqlite3_column_int(stmt, 0); |
if (prefer_encrypted!=DC_PE_MUTUAL) { |
dc_log_info(context, 0, "[autocrypt] peerstate for %s is %s", |
sqlite3_column_text(stmt, 1), |
prefer_encrypted==DC_PE_NOPREFERENCE? "NOPREFERENCE" : "RESET"); |
all_mutual = 0; |
} |
} |
} |
sqlite3_finalize(stmt); |
stmt = NULL; |
if (can_encrypt) |
{ |
if (all_mutual) { |
do_guarantee_e2ee = 1; |
} |
else { |
if (last_msg_in_chat_encrypted(context->sql, chat->id)) { |
do_guarantee_e2ee = 1; |
} |
} |
} |
} |
if (do_guarantee_e2ee) { |
dc_param_set_int(msg->param, DC_PARAM_GUARANTEE_E2EE, 1); |
} |
dc_param_set(msg->param, DC_PARAM_ERRONEOUS_E2EE, NULL); /* reset eg. on forwarding */ |
// set "In-Reply-To:" to identify the message to which the composed message is a reply; |
// set "References:" to identify the "thread" of the conversation; |
// both according to RFC 5322 3.6.4, page 25 |
// |
// as self-talks are mainly used to transfer data between devices, |
// we do not set In-Reply-To/References in this case. |
if (!dc_chat_is_self_talk(chat) |
&& get_parent_mime_headers(chat, &parent_rfc724_mid, &parent_in_reply_to, &parent_references)) |
{ |
if (parent_rfc724_mid && parent_rfc724_mid[0]) { |
new_in_reply_to = dc_strdup(parent_rfc724_mid); |
} |
// the whole list of messages referenced may be huge; |
// only use the oldest and and the parent message |
if (parent_references) { |
char* space = NULL; |
if ((space=strchr(parent_references, ' '))!=NULL) { |
*space = 0; |
} |
} |
if (parent_references && parent_references[0] |
&& parent_rfc724_mid && parent_rfc724_mid[0]) { |
// angle brackets are added by the mimefactory later |
new_references = dc_mprintf("%s %s", parent_references, parent_rfc724_mid); |
} |
else if (parent_references && parent_references[0]) { |
new_references = dc_strdup(parent_references); |
} |
else if (parent_in_reply_to && parent_in_reply_to[0] |
&& parent_rfc724_mid && parent_rfc724_mid[0]) { |
new_references = dc_mprintf("%s %s", parent_in_reply_to, parent_rfc724_mid); |
} |
else if (parent_in_reply_to && parent_in_reply_to[0]) { |
new_references = dc_strdup(parent_in_reply_to); |
} |
} |
/* add independent location to database */ |
if (dc_param_exists(msg->param, DC_PARAM_SET_LATITUDE)) { |
stmt = dc_sqlite3_prepare(context->sql, |
"INSERT INTO locations " |
" (timestamp,from_id,chat_id, latitude,longitude,independent)" |
" VALUES (?,?,?, ?,?,1);"); |
sqlite3_bind_int64 (stmt, 1, timestamp); |
sqlite3_bind_int (stmt, 2, DC_CONTACT_ID_SELF); |
sqlite3_bind_int (stmt, 3, chat->id); |
sqlite3_bind_double(stmt, 4, dc_param_get_float(msg->param, DC_PARAM_SET_LATITUDE, 0.0)); |
sqlite3_bind_double(stmt, 5, dc_param_get_float(msg->param, DC_PARAM_SET_LONGITUDE, 0.0)); |
sqlite3_step(stmt); |
sqlite3_finalize(stmt); |
stmt = NULL; |
location_id = dc_sqlite3_get_rowid2(context->sql, "locations", |
"timestamp", timestamp, |
"from_id", DC_CONTACT_ID_SELF); |
} |
/* add message to the database */ |
stmt = dc_sqlite3_prepare(context->sql, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.