1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-06 03:50:08 +02:00

differ between single-direction-verified and dual-verified

This commit is contained in:
B. Petersen 2018-04-18 17:27:59 +02:00
parent 374f790b02
commit f0a3590155
6 changed files with 25 additions and 22 deletions

View file

@ -347,8 +347,9 @@ static void log_contactlist(mrmailbox_t* mailbox, mrarray_t* contacts)
if( (contact=mrmailbox_get_contact(mailbox, contact_id))!=NULL ) { if( (contact=mrmailbox_get_contact(mailbox, contact_id))!=NULL ) {
char* name = mrcontact_get_name(contact); char* name = mrcontact_get_name(contact);
char* addr = mrcontact_get_addr(contact); char* addr = mrcontact_get_addr(contact);
const char* verified = mrcontact_is_verified(contact)? "": ""; int verified_state = mrcontact_is_verified(contact);
line = mr_mprintf("%s%s <%s>", (name&&name[0])? name : "<name unset>", verified, (addr&&addr[0])? addr : "addr unset"); const char* verified_str = verified_state? (verified_state==2? " √√":""): "";
line = mr_mprintf("%s%s <%s>", (name&&name[0])? name : "<name unset>", verified_str, (addr&&addr[0])? addr : "addr unset");
mrsqlite3_lock(mailbox->m_sql); mrsqlite3_lock(mailbox->m_sql);
int peerstate_ok = mrapeerstate_load_by_addr__(peerstate, mailbox->m_sql, addr); int peerstate_ok = mrapeerstate_load_by_addr__(peerstate, mailbox->m_sql, addr);
mrsqlite3_unlock(mailbox->m_sql); mrsqlite3_unlock(mailbox->m_sql);
@ -704,7 +705,7 @@ char* mrmailbox_cmdline(mrmailbox_t* mailbox, const char* cmdline)
char* temp_subtitle = mrchat_get_subtitle(chat); char* temp_subtitle = mrchat_get_subtitle(chat);
char* temp_name = mrchat_get_name(chat); char* temp_name = mrchat_get_name(chat);
const char* verified = mrchat_is_verified(chat)? "": ""; const char* verified = mrchat_is_verified(chat)? "": "";
mrmailbox_log_info(mailbox, 0, "%s#%i: %s%s [%s] [%i fresh]", mrchat_get_type(chat)==MR_CHAT_TYPE_GROUP? "Groupchat" : "Chat", mrmailbox_log_info(mailbox, 0, "%s#%i: %s%s [%s] [%i fresh]", mrchat_get_type(chat)==MR_CHAT_TYPE_GROUP? "Groupchat" : "Chat",
(int)mrchat_get_id(chat), temp_name, verified, temp_subtitle, (int)mrmailbox_get_fresh_msg_count(mailbox, mrchat_get_id(chat))); (int)mrchat_get_id(chat), temp_name, verified, temp_subtitle, (int)mrmailbox_get_fresh_msg_count(mailbox, mrchat_get_id(chat)));
free(temp_subtitle); free(temp_subtitle);

View file

@ -496,6 +496,7 @@ cleanup:
* *
* @param peerstate The peerstate object. * @param peerstate The peerstate object.
* @param fingerprint Fingerprint expected in the object * @param fingerprint Fingerprint expected in the object
* @param verified 1=we verified the contact, 2=contact verfied in both directions
* *
* @return 1=the given fingerprint is equal to the peer's fingerprint and * @return 1=the given fingerprint is equal to the peer's fingerprint and
* the verified-state is set; you should call mrapeerstate_save_to_db__() * the verified-state is set; you should call mrapeerstate_save_to_db__()
@ -503,11 +504,11 @@ cleanup:
* 0=the given fingerprint is not eqial to the peer's fingerprint, * 0=the given fingerprint is not eqial to the peer's fingerprint,
* verified-state not changed. * verified-state not changed.
*/ */
int mrapeerstate_set_verified(mrapeerstate_t* peerstate, const char* fingerprint) int mrapeerstate_set_verified(mrapeerstate_t* peerstate, const char* fingerprint, int verified)
{ {
int verified = 0; int success = 0;
if( peerstate == NULL || fingerprint == NULL ) { if( peerstate == NULL || fingerprint == NULL || verified<1 || verified>2 ) {
goto cleanup; goto cleanup;
} }
@ -521,9 +522,9 @@ int mrapeerstate_set_verified(mrapeerstate_t* peerstate, const char* fingerprint
peerstate->m_to_save |= MRA_SAVE_ALL; peerstate->m_to_save |= MRA_SAVE_ALL;
peerstate->m_prefer_encrypt = MRA_PE_MUTUAL; peerstate->m_prefer_encrypt = MRA_PE_MUTUAL;
peerstate->m_verified = 1; peerstate->m_verified = verified;
verified = 1; success = 1;
cleanup: cleanup:
return verified; return success;
} }

View file

@ -87,7 +87,7 @@ mrkey_t* mrapeerstate_peek_key (const mrapeerstate_t*);
int mrapeerstate_recalc_fingerprint (mrapeerstate_t*); int mrapeerstate_recalc_fingerprint (mrapeerstate_t*);
int mrapeerstate_set_verified (mrapeerstate_t*, const char* fingerprint); int mrapeerstate_set_verified (mrapeerstate_t*, const char* fingerprint, int verfied);
int mrapeerstate_load_by_addr__ (mrapeerstate_t*, mrsqlite3_t*, const char* addr); int mrapeerstate_load_by_addr__ (mrapeerstate_t*, mrsqlite3_t*, const char* addr);
int mrapeerstate_load_by_fingerprint__(mrapeerstate_t*, mrsqlite3_t*, const char* fingerprint); int mrapeerstate_load_by_fingerprint__(mrapeerstate_t*, mrsqlite3_t*, const char* fingerprint);

View file

@ -260,11 +260,8 @@ int mrcontact_is_blocked(mrcontact_t* contact)
* @param contact The contact object. * @param contact The contact object.
* *
* @return 0=contact is not verified. * @return 0=contact is not verified.
* 1=SELF has verified the fingerprint of the contact, it is not clear if the * 2=SELF and contact have verified their fingerprints in both directions; in the UI typically checkmarks are shown.
* contact has verified the fingerprint of SELF; in the UI typically * 1=SELF has verified the contact but not the other way round.
* one checkmark is shown.
* 2=secure join - SELF and contact have verified their fingerprints in both
* directions; in the UI typically two checkmarks are shown.
*/ */
int mrcontact_is_verified(mrcontact_t* contact) int mrcontact_is_verified(mrcontact_t* contact)
{ {

View file

@ -3759,22 +3759,26 @@ mrarray_t* mrmailbox_get_contacts(mrmailbox_t* mailbox, uint32_t listflags, cons
self_addr = mrsqlite3_get_config__(mailbox->m_sql, "configured_addr", ""); /* we add MR_CONTACT_ID_SELF explicitly; so avoid doubles if the address is present as a normal entry for some case */ self_addr = mrsqlite3_get_config__(mailbox->m_sql, "configured_addr", ""); /* we add MR_CONTACT_ID_SELF explicitly; so avoid doubles if the address is present as a normal entry for some case */
if( query ) if( (listflags&MR_GCL_VERIFIED_ONLY) || query )
{ {
if( (s3strLikeCmd=sqlite3_mprintf("%%%s%%", query))==NULL ) { if( (s3strLikeCmd=sqlite3_mprintf("%%%s%%", query? query : ""))==NULL ) {
goto cleanup; goto cleanup;
} }
stmt = mrsqlite3_predefine__(mailbox->m_sql, SELECT_id_FROM_contacts_WHERE_query_ORDER_BY, stmt = mrsqlite3_predefine__(mailbox->m_sql, SELECT_id_FROM_contacts_WHERE_query_ORDER_BY,
"SELECT id FROM contacts" "SELECT c.id FROM contacts c"
" WHERE addr!=? AND id>" MR_STRINGIFY(MR_CONTACT_ID_LAST_SPECIAL) " AND origin>=" MR_STRINGIFY(MR_ORIGIN_MIN_CONTACT_LIST) " AND blocked=0 AND (name LIKE ? OR addr LIKE ?)" /* see comments in mrmailbox_search_msgs() about the LIKE operator */ " LEFT JOIN acpeerstates ps ON c.addr=ps.addr "
" ORDER BY LOWER(name||addr),id;"); " WHERE c.addr!=? AND c.id>" MR_STRINGIFY(MR_CONTACT_ID_LAST_SPECIAL) " AND c.origin>=" MR_STRINGIFY(MR_ORIGIN_MIN_CONTACT_LIST) " AND c.blocked=0 AND (c.name LIKE ? OR c.addr LIKE ?)" /* see comments in mrmailbox_search_msgs() about the LIKE operator */
" AND (ps.verified=2 OR 1=0) "
" ORDER BY LOWER(c.name||c.addr),c.id;");
sqlite3_bind_text(stmt, 1, self_addr, -1, SQLITE_STATIC); sqlite3_bind_text(stmt, 1, self_addr, -1, SQLITE_STATIC);
sqlite3_bind_text(stmt, 2, s3strLikeCmd, -1, SQLITE_STATIC); sqlite3_bind_text(stmt, 2, s3strLikeCmd, -1, SQLITE_STATIC);
sqlite3_bind_text(stmt, 3, s3strLikeCmd, -1, SQLITE_STATIC); sqlite3_bind_text(stmt, 3, s3strLikeCmd, -1, SQLITE_STATIC);
//sqlite3_bind_int (stmt, 4, (listflags&MR_GCL_VERIFIED_ONLY)? 2 : 0);
//sqlite3_bind_int (stmt, 5, (listflags&MR_GCL_VERIFIED_ONLY)? 0 : 1/*force statement being always true*/);
self_name = mrsqlite3_get_config__(mailbox->m_sql, "displayname", ""); self_name = mrsqlite3_get_config__(mailbox->m_sql, "displayname", "");
self_name2 = mrstock_str(MR_STR_SELF); self_name2 = mrstock_str(MR_STR_SELF);
if( mr_str_contains(self_addr, query) || mr_str_contains(self_name, query) || mr_str_contains(self_name2, query) ) { if( query==NULL || mr_str_contains(self_addr, query) || mr_str_contains(self_name, query) || mr_str_contains(self_name2, query) ) {
add_self = 1; add_self = 1;
} }
} }

View file

@ -188,7 +188,7 @@ static int mark_peer_as_verified__(mrmailbox_t* mailbox, const char* fingerprint
goto cleanup; goto cleanup;
} }
if( !mrapeerstate_set_verified(peerstate, fingerprint) ) { if( !mrapeerstate_set_verified(peerstate, fingerprint, 2) ) {
goto cleanup; goto cleanup;
} }