|
|
@ -83,7 +83,7 @@ static const char *sql_trustword = |
|
|
|
static const char *sql_get_identity = |
|
|
|
"select fpr, username, comm_type, lang," |
|
|
|
" identity.flags | pgp_keypair.flags," |
|
|
|
" is_own" |
|
|
|
" is_own, pEp_version" |
|
|
|
" from identity" |
|
|
|
" join person on id = identity.user_id" |
|
|
|
" join pgp_keypair on fpr = identity.main_key_id" |
|
|
@ -101,7 +101,7 @@ static const char *sql_get_identity = |
|
|
|
static const char *sql_get_identities_by_main_key_id = |
|
|
|
"select address, identity.user_id, username, comm_type, lang," |
|
|
|
" identity.flags | pgp_keypair.flags," |
|
|
|
" is_own" |
|
|
|
" is_own, pEp_version" |
|
|
|
" from identity" |
|
|
|
" join person on id = identity.user_id" |
|
|
|
" join pgp_keypair on fpr = identity.main_key_id" |
|
|
@ -113,7 +113,7 @@ static const char *sql_get_identities_by_main_key_id = |
|
|
|
|
|
|
|
static const char *sql_get_identity_without_trust_check = |
|
|
|
"select identity.main_key_id, username, lang," |
|
|
|
" identity.flags, is_own" |
|
|
|
" identity.flags, is_own, pEp_version" |
|
|
|
" from identity" |
|
|
|
" join person on id = identity.user_id" |
|
|
|
" where (case when (address = ?1) then (1)" |
|
|
@ -127,7 +127,7 @@ static const char *sql_get_identity_without_trust_check = |
|
|
|
|
|
|
|
static const char *sql_get_identities_by_address = |
|
|
|
"select user_id, identity.main_key_id, username, lang," |
|
|
|
" identity.flags, is_own" |
|
|
|
" identity.flags, is_own, pEp_version" |
|
|
|
" from identity" |
|
|
|
" join person on id = identity.user_id" |
|
|
|
" where (case when (address = ?1) then (1)" |
|
|
@ -141,7 +141,7 @@ static const char *sql_get_identities_by_address = |
|
|
|
static const char *sql_get_identities_by_userid = |
|
|
|
"select address, fpr, username, comm_type, lang," |
|
|
|
" identity.flags | pgp_keypair.flags," |
|
|
|
" is_own" |
|
|
|
" is_own, pEp_version" |
|
|
|
" from identity" |
|
|
|
" join person on id = identity.user_id" |
|
|
|
" join pgp_keypair on fpr = identity.main_key_id" |
|
|
@ -239,20 +239,22 @@ static const char* sql_exists_identity_entry = |
|
|
|
static const char *sql_set_identity_entry = |
|
|
|
"insert into identity (" |
|
|
|
" address, main_key_id, " |
|
|
|
" user_id, flags, is_own" |
|
|
|
" user_id, flags, is_own, pEp_version" |
|
|
|
" ) values (" |
|
|
|
" ?1," |
|
|
|
" upper(replace(?2,' ',''))," |
|
|
|
" ?3," |
|
|
|
" ?4," |
|
|
|
" ?5" |
|
|
|
" ?5," |
|
|
|
" ?6" |
|
|
|
" );"; |
|
|
|
|
|
|
|
static const char* sql_update_identity_entry = |
|
|
|
"update identity " |
|
|
|
" set main_key_id = upper(replace(?2,' ','')), " |
|
|
|
" flags = ?4, " |
|
|
|
" is_own = ?5 " |
|
|
|
" is_own = ?5, " |
|
|
|
" pEp_version = ?6 " |
|
|
|
" where (case when (address = ?1) then (1)" |
|
|
|
" when (lower(address) = lower(?1)) then (1)" |
|
|
|
" when (replace(lower(address),'.','') = replace(lower(?1),'.','')) then (1) " |
|
|
@ -393,7 +395,7 @@ static const char *sql_is_own_address = |
|
|
|
|
|
|
|
static const char *sql_own_identities_retrieve = |
|
|
|
"select address, fpr, identity.user_id, username," |
|
|
|
" lang, identity.flags | pgp_keypair.flags" |
|
|
|
" lang, identity.flags | pgp_keypair.flags, pEp_version" |
|
|
|
" from identity" |
|
|
|
" join person on id = identity.user_id" |
|
|
|
" join pgp_keypair on fpr = identity.main_key_id" |
|
|
@ -965,7 +967,7 @@ DYNAMIC_API PEP_STATUS init( |
|
|
|
" comment text,\n" |
|
|
|
" flags integer default 0,\n" |
|
|
|
" is_own integer default 0,\n" |
|
|
|
" pep_version real default 0,\n" |
|
|
|
" pEp_version real default 0.0,\n" |
|
|
|
" timestamp integer default (datetime('now')),\n" |
|
|
|
" primary key (address, user_id)\n" |
|
|
|
");\n" |
|
|
@ -1071,7 +1073,7 @@ DYNAMIC_API PEP_STATUS init( |
|
|
|
// Sometimes the user_version wasn't set correctly. |
|
|
|
if (version == 1) { |
|
|
|
bool version_changed = true; |
|
|
|
if (table_contains_column(_session, "identity", "pep_version") > 0) { |
|
|
|
if (table_contains_column(_session, "identity", "pEp_version") > 0) { |
|
|
|
version = 12; |
|
|
|
} // N.B. Version 11 was a DB internal fix; there's no identifying information, but this is only one extra exec. |
|
|
|
else if (db_contains_table(_session, "social_graph") > 0) { |
|
|
@ -1431,7 +1433,7 @@ DYNAMIC_API PEP_STATUS init( |
|
|
|
int_result = sqlite3_exec( |
|
|
|
_session->db, |
|
|
|
"alter table identity\n" |
|
|
|
" add column pep_version real default 0;\n", |
|
|
|
" add column pEp_version real default 0.0;\n", |
|
|
|
NULL, |
|
|
|
NULL, |
|
|
|
NULL |
|
|
@ -2466,6 +2468,8 @@ DYNAMIC_API PEP_STATUS get_identity( |
|
|
|
sqlite3_column_int(session->get_identity, 4); |
|
|
|
_identity->me = (unsigned int) |
|
|
|
sqlite3_column_int(session->get_identity, 5); |
|
|
|
_identity->pEp_version = (float) |
|
|
|
sqlite3_column_double(session->get_identity, 6); |
|
|
|
|
|
|
|
*identity = _identity; |
|
|
|
break; |
|
|
@ -2540,6 +2544,8 @@ PEP_STATUS get_identities_by_userid( |
|
|
|
sqlite3_column_int(session->get_identities_by_userid, 5); |
|
|
|
ident->me = (unsigned int) |
|
|
|
sqlite3_column_int(session->get_identities_by_userid, 6); |
|
|
|
ident->pEp_version = (float) |
|
|
|
sqlite3_column_double(session->get_identities_by_userid, 7); |
|
|
|
|
|
|
|
identity_list_add(*identities, ident); |
|
|
|
ident = NULL; |
|
|
@ -2606,6 +2612,8 @@ PEP_STATUS get_identities_by_main_key_id( |
|
|
|
sqlite3_column_int(session->get_identities_by_main_key_id, 5); |
|
|
|
ident->me = (unsigned int) |
|
|
|
sqlite3_column_int(session->get_identities_by_main_key_id, 6); |
|
|
|
ident->pEp_version = (float) |
|
|
|
sqlite3_column_double(session->get_identities_by_main_key_id, 7); |
|
|
|
|
|
|
|
identity_list_add(*identities, ident); |
|
|
|
ident = NULL; |
|
|
@ -2676,6 +2684,8 @@ PEP_STATUS get_identity_without_trust_check( |
|
|
|
sqlite3_column_int(session->get_identity_without_trust_check, 3); |
|
|
|
_identity->me = (unsigned int) |
|
|
|
sqlite3_column_int(session->get_identity_without_trust_check, 4); |
|
|
|
_identity->pEp_version = (float) |
|
|
|
sqlite3_column_double(session->get_identity_without_trust_check, 5); |
|
|
|
|
|
|
|
*identity = _identity; |
|
|
|
break; |
|
|
@ -2741,6 +2751,8 @@ PEP_STATUS get_identities_by_address( |
|
|
|
sqlite3_column_int(session->get_identities_by_address, 4); |
|
|
|
ident->me = (unsigned int) |
|
|
|
sqlite3_column_int(session->get_identities_by_address, 5); |
|
|
|
ident->pEp_version = (float) |
|
|
|
sqlite3_column_double(session->get_identities_by_address, 6); |
|
|
|
|
|
|
|
if (ident_list) |
|
|
|
identity_list_add(ident_list, ident); |
|
|
@ -2897,6 +2909,7 @@ static PEP_STATUS _set_or_update_identity_entry(PEP_SESSION session, |
|
|
|
SQLITE_STATIC); |
|
|
|
sqlite3_bind_int(set_or_update, 4, identity->flags); |
|
|
|
sqlite3_bind_int(set_or_update, 5, identity->me); |
|
|
|
sqlite3_bind_double(set_or_update, 6, identity->pEp_version); |
|
|
|
int result = sqlite3_step(set_or_update); |
|
|
|
sqlite3_reset(set_or_update); |
|
|
|
if (result != SQLITE_DONE) |
|
|
|