adding set_identity_flags()

doc_update_sequoia
Volker Birk 7 years ago
parent e767049511
commit ff6283c288

@ -203,6 +203,8 @@ DYNAMIC_API PEP_STATUS update_identity(
identity->lang[1] = stored_identity->lang[1];
identity->lang[2] = 0;
}
identity->flags = stored_identity->flags;
}
else /* stored_identity == NULL */ {
if (!EMPTYSTR(identity->fpr)) {
@ -390,6 +392,8 @@ DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
return PEP_OUT_OF_MEMORY;
}
}
identity->flags = stored_identity->flags;
}
else if (!EMPTYSTR(identity->fpr))
{

@ -18,6 +18,8 @@ extern "C" {
// asynchronous management implementation, so retrieve_next_identity()
// will return this identity later
// at least identity->address must be a non-empty UTF-8 string as input
// update_identity() never writes flags; use set_identity_flags() for
// writing
DYNAMIC_API PEP_STATUS update_identity(
PEP_SESSION session, pEp_identity * identity
@ -40,6 +42,7 @@ DYNAMIC_API PEP_STATUS update_identity(
// it can need a decent amount of time to return
// if you need to do this asynchronous, you need to return an identity
// with retrieve_next_identity() where pEp_identity.me is true
// myself() never writes flags; use set_identity_flags() for writing
DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity);

@ -29,6 +29,7 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
static const char *sql_set_person;
static const char *sql_set_pgp_keypair;
static const char *sql_set_identity;
static const char *sql_set_identity_flags;
static const char *sql_set_trust;
static const char *sql_get_trust;
static const char *sql_least_trust;
@ -295,6 +296,9 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
"user_id, flags) values (?1, upper(replace(?2,' ','')),"
"?3, ?4) ;";
sql_set_identity_flags = "update identity set flags = ?1 "
"where address = ?2 and user_id = ?3 ;";
sql_set_trust = "insert or replace into trust (user_id, pgp_keypair_fpr, comm_type) "
"values (?1, upper(replace(?2,' ','')), ?3) ;";
@ -385,6 +389,10 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
(int)strlen(sql_set_identity), &_session->set_identity, NULL);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_set_identity_flags,
(int)strlen(sql_set_identity_flags), &_session->set_identity_flags, NULL);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_set_trust,
(int)strlen(sql_set_trust), &_session->set_trust, NULL);
assert(int_result == SQLITE_OK);
@ -527,6 +535,8 @@ DYNAMIC_API void release(PEP_SESSION session)
sqlite3_finalize(session->set_pgp_keypair);
if (session->set_identity)
sqlite3_finalize(session->set_identity);
if (session->set_identity_flags)
sqlite3_finalize(session->set_identity_flags);
if (session->set_trust)
sqlite3_finalize(session->set_trust);
if (session->get_trust)
@ -955,7 +965,7 @@ DYNAMIC_API PEP_STATUS set_identity(
SQLITE_STATIC);
sqlite3_bind_text(session->set_identity, 3, identity->user_id, -1,
SQLITE_STATIC);
sqlite3_bind_int(session->set_trust, 4, identity->flags);
sqlite3_bind_int(session->set_identity, 4, identity->flags);
result = sqlite3_step(session->set_identity);
sqlite3_reset(session->set_identity);
if (result != SQLITE_DONE) {
@ -983,6 +993,34 @@ DYNAMIC_API PEP_STATUS set_identity(
return PEP_COMMIT_FAILED;
}
DYNAMIC_API PEP_STATUS set_identity_flags(
PEP_SESSION session, const pEp_identity *identity
)
{
int result;
assert(session);
assert(identity);
assert(identity->address);
assert(identity->user_id);
if (!(session && identity && identity->address && identity->user_id))
return PEP_ILLEGAL_VALUE;
sqlite3_reset(session->set_identity_flags);
sqlite3_bind_int(session->set_identity_flags, 1, identity->flags);
sqlite3_bind_text(session->set_identity_flags, 2, identity->address, -1,
SQLITE_STATIC);
sqlite3_bind_text(session->set_identity_flags, 3, identity->user_id, -1,
SQLITE_STATIC);
result = sqlite3_step(session->set_identity_flags);
sqlite3_reset(session->set_identity_flags);
if (result != SQLITE_DONE)
return PEP_CANNOT_SET_IDENTITY;
return PEP_STATUS_OK;
}
DYNAMIC_API PEP_STATUS mark_as_compromized(
PEP_SESSION session,
const char *fpr

@ -411,7 +411,7 @@ typedef struct _identity_list {
// username (in) UTF-8 string or NULL
//
// return value:
// pEp_identity struct with correct size values or NULL if out of memory
// pEp_identity struct or NULL if out of memory
//
// caveat:
// the strings are copied; the original strings are still being owned by
@ -423,13 +423,13 @@ DYNAMIC_API pEp_identity *new_identity(
);
// identity_dup() - allocate memory and set the string and size fields
// identity_dup() - allocate memory and duplicate
//
// parameters:
// src (in) identity to duplicate
//
// return value:
// pEp_identity struct with correct size values or NULL if out of memory
// pEp_identity struct or NULL if out of memory
//
// caveat:
// the strings are copied; the original strings are still being owned by
@ -486,18 +486,34 @@ DYNAMIC_API PEP_STATUS get_identity(
// PEP_CANNOT_SET_PGP_KEYPAIR writing to table pgp_keypair failed
// PEP_CANNOT_SET_IDENTITY writing to table identity failed
// PEP_COMMIT_FAILED SQL commit failed
// PEP_KEY_BLACKLISTED Key blacklisted, cannot set identity
// PEP_KEY_BLACKLISTED Key blacklisted, cannot set identity
//
// caveat:
// in the identity structure you need to set the const char * fields to
// UTF-8 C strings
// the size fields are ignored
// address, fpr, user_id and username must be given
DYNAMIC_API PEP_STATUS set_identity(
PEP_SESSION session, const pEp_identity *identity
);
// set_identity_flags() - update identity flags on existing identity
//
// parameters:
// session (in) session handle
// identity (in) pointer to pEp_identity structure
//
// return value:
// PEP_STATUS_OK = 0 encryption and signing succeeded
// PEP_CANNOT_SET_IDENTITY update of identity failed
//
// caveat:
// address and user_id must be given
DYNAMIC_API PEP_STATUS set_identity_flags(
PEP_SESSION session, const pEp_identity *identity
);
// mark_as_compromized() - mark key in trust db as compromized
//
// parameters:

@ -97,6 +97,7 @@ typedef struct _pEpSession {
sqlite3_stmt *set_person;
sqlite3_stmt *set_pgp_keypair;
sqlite3_stmt *set_identity;
sqlite3_stmt *set_identity_flags;
sqlite3_stmt *set_trust;
sqlite3_stmt *get_trust;
sqlite3_stmt *least_trust;

Loading…
Cancel
Save