Browse Source

...

doc_update_sequoia
Volker Birk 6 years ago
parent
commit
c8fd579fca
6 changed files with 89 additions and 48 deletions
  1. +52
    -25
      src/keymanagement.c
  2. +5
    -5
      src/keymanagement.h
  3. +12
    -11
      src/pEpEngine.c
  4. +1
    -1
      src/pEp_internal.h
  5. +12
    -0
      src/sync_send_actions.c
  6. +7
    -6
      sync/gen_actions_skeleton.ysl2

+ 52
- 25
src/keymanagement.c View File

@ -659,10 +659,10 @@ DYNAMIC_API PEP_STATUS trust_personal_key(
}
DYNAMIC_API PEP_STATUS own_key_is_listed(
PEP_SESSION session,
const char *fpr,
bool *listed
)
PEP_SESSION session,
const char *fpr,
bool *listed
)
{
PEP_STATUS status = PEP_STATUS_OK;
int count;
@ -695,37 +695,63 @@ DYNAMIC_API PEP_STATUS own_key_is_listed(
return status;
}
DYNAMIC_API PEP_STATUS own_key_retrieve(
PEP_SESSION session,
stringlist_t **own_key
)
DYNAMIC_API PEP_STATUS own_identities_retrieve(
PEP_SESSION session,
identity_list **own_identities
)
{
PEP_STATUS status = PEP_STATUS_OK;
assert(session);
assert(own_key);
if (!(session && own_key))
assert(session && own_identities);
if (!(session && own_identities))
return PEP_ILLEGAL_VALUE;
*own_key = NULL;
stringlist_t *_own_key = new_stringlist(NULL);
if (_own_key == NULL)
*own_identities = NULL;
identity_list *_own_identities = new_identity_list(NULL);
if (_own_identities == NULL)
goto enomem;
sqlite3_reset(session->own_key_retrieve);
sqlite3_reset(session->own_identities_retrieve);
int result;
// address, fpr, username, user_id, comm_type, lang, flags
const char *address = NULL;
const char *fpr = NULL;
const char *username = NULL;
const char *user_id = NULL;
PEP_comm_type comm_type = PEP_ct_unknown;
const char *lang = NULL;
unsigned int flags = 0;
stringlist_t *_bl = _own_key;
identity_list *_bl = _own_identities;
do {
result = sqlite3_step(session->own_key_retrieve);
result = sqlite3_step(session->own_identities_retrieve);
switch (result) {
case SQLITE_ROW:
fpr = (const char *) sqlite3_column_text(session->own_key_retrieve, 0);
_bl = stringlist_add(_bl, fpr);
address = (const char *)
sqlite3_column_text(session->own_identities_retrieve, 0);
fpr = (const char *)
sqlite3_column_text(session->own_identities_retrieve, 1);
username = (const char *)
sqlite3_column_text(session->own_identities_retrieve, 2);
user_id = (const char *)
sqlite3_column_text(session->own_identities_retrieve, 3);
comm_type = (PEP_comm_type)
sqlite3_column_int(session->own_key_is_listed, 4);
lang = (const char *)
sqlite3_column_text(session->own_identities_retrieve, 5);
flags = (unsigned int)
sqlite3_column_int(session->own_key_is_listed, 6);
pEp_identity *ident = new_identity(address, fpr, username, user_id);
ident->comm_type = comm_type;
if (lang && lang[0]) {
ident->lang[0] = lang[0];
ident->lang[1] = lang[1];
}
ident->flags = flags;
_bl = identity_list_add(_bl, ident);
if (_bl == NULL)
goto enomem;
@ -740,18 +766,19 @@ DYNAMIC_API PEP_STATUS own_key_retrieve(
}
} while (result != SQLITE_DONE);
sqlite3_reset(session->own_key_retrieve);
sqlite3_reset(session->own_identities_retrieve);
if (status == PEP_STATUS_OK)
*own_key = _own_key;
*own_identities = _own_identities;
else
free_stringlist(_own_key);
free_identity_list(_own_identities);
goto the_end;
enomem:
free_stringlist(_own_key);
free_identity_list(_own_identities);
status = PEP_OUT_OF_MEMORY;
the_end:
return status;
}

+ 5
- 5
src/keymanagement.h View File

@ -170,18 +170,18 @@ DYNAMIC_API PEP_STATUS own_key_is_listed(
);
// own_key_retrieve() - retrieve all own keys fingerprints
// own_identities_retrieve() - retrieve all own identities
//
// parameters:
// session (in) session to use
// own_key (out) copy of own_key
// session (in) session to use
// own_identities (out) list of own identities
//
// caveat:
// the ownership of the copy of own_key goes to the caller
DYNAMIC_API PEP_STATUS own_key_retrieve(
DYNAMIC_API PEP_STATUS own_identities_retrieve(
PEP_SESSION session,
stringlist_t **own_key
identity_list **own_identities
);
#ifdef __cplusplus


+ 12
- 11
src/pEpEngine.c View File

@ -47,7 +47,7 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
// Own keys
static const char *sql_own_key_is_listed;
static const char *sql_own_key_retrieve;
static const char *sql_own_identities_retrieve;
// Sequence
static const char *sql_sequence_value1;
@ -360,13 +360,14 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
" where main_key_id = upper(replace(?1,' ',''))"
" and user_id = '" PEP_OWN_USERID "' );";
sql_own_key_retrieve = "select main_key_id from person "
" where main_key_id is not null"
" and id = '" PEP_OWN_USERID "' "
"union "
" select main_key_id from identity "
" where main_key_id is not null"
" and user_id = '" PEP_OWN_USERID "' ;";
sql_own_identities_retrieve = "select address, fpr, username, '" PEP_OWN_USERID "',"
" comm_type, lang, identity.flags | pgp_keypair.flags"
" from identity"
" join person on id = identity.user_id"
" join pgp_keypair on fpr = identity.main_key_id"
" join trust on id = trust.user_id"
" and pgp_keypair_fpr = identity.main_key_id"
" where identity.user_id = '" PEP_OWN_USERID "';";
sql_sequence_value1 = "insert or replace into sequences (name, value) "
"values (?1, "
@ -471,9 +472,9 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
NULL);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_own_key_retrieve,
(int)strlen(sql_own_key_retrieve), &_session->own_key_retrieve,
NULL);
int_result = sqlite3_prepare_v2(_session->db, sql_own_identities_retrieve,
(int)strlen(sql_own_identities_retrieve),
&_session->own_identities_retrieve, NULL);
assert(int_result == SQLITE_OK);
// Sequence


+ 1
- 1
src/pEp_internal.h View File

@ -115,7 +115,7 @@ typedef struct _pEpSession {
// Own keys
sqlite3_stmt *own_key_is_listed;
sqlite3_stmt *own_key_retrieve;
sqlite3_stmt *own_identities_retrieve;
// sequence value
sqlite3_stmt *sequence_value1;


+ 12
- 0
src/sync_send_actions.c View File

@ -113,6 +113,7 @@ error:
free(payload);
free_message(_message);
free_identity(me);
free_identity(partner);
return status;
}
@ -218,6 +219,7 @@ error:
free(payload);
free_message(_message);
free_identity(me);
free_identity(partner);
return status;
}
@ -244,6 +246,7 @@ PEP_STATUS sendGroupKeys(
char *payload = NULL;
message *_message = NULL;
pEp_identity *me = NULL;
identity_list *kl = NULL;
assert(session);
assert(!partner);
@ -289,6 +292,12 @@ PEP_STATUS sendGroupKeys(
if (Identity_from_Struct(me, &msg->header.me) == NULL)
goto enomem;
status = own_identities_retrieve(session, &kl);
if (status != PEP_STATUS_OK)
goto error;
if (IdentityList_from_identity_list(kl, &msg->ownIdentities) == NULL)
goto enomem;
if (asn_check_constraints(&asn_DEF_GroupKeys, msg, NULL, NULL)) {
status = PEP_CONTRAINTS_VIOLATED;
goto error;
@ -314,6 +323,7 @@ PEP_STATUS sendGroupKeys(
free_message(_message);
ASN_STRUCT_FREE(asn_DEF_GroupKeys, msg);
free_identity(partner);
free_identity_list(kl);
return status;
enomem:
@ -323,6 +333,8 @@ error:
free(payload);
free_message(_message);
free_identity(me);
free_identity(partner);
free_identity_list(kl);
return status;
}

+ 7
- 6
sync/gen_actions_skeleton.ysl2 View File

@ -157,6 +157,7 @@ tstylesheet {
char *payload = NULL;
message *_message = NULL;
pEp_identity *me = NULL;
`` if "$name='GroupKeys'" |> identity_list *kl = NULL;
`` call "paramcheck" with "partner", "parm/partner";
@ -199,13 +200,12 @@ tstylesheet {
if (Identity_from_Struct(me, &msg->header.me) == NULL)
goto enomem;
||
if "$name='OwnKeys'" {
if "$name='GroupKeys'" {
|
|> identity_list *kl;
|> status = own_key_retrieve(session, &kl);
|> status = own_identities_retrieve(session, &kl);
|> if (status != PEP_STATUS_OK)
|>> goto error;
|> if (KeyList_from_stringlist(kl, &msg->keylist) == NULL)
|> if (IdentityList_from_identity_list(kl, &msg->ownIdentities) == NULL)
|>> goto enomem;
}
||
@ -235,7 +235,7 @@ tstylesheet {
free_message(_message);
ASN_STRUCT_FREE(asn_DEF_«$name», msg);
free_identity(partner);
`` if "$name='OwnKeys'" |> free_identity_list(kl);
`` if "$name='GroupKeys'" |> free_identity_list(kl);
return status;
enomem:
@ -245,7 +245,8 @@ tstylesheet {
free(payload);
free_message(_message);
free_identity(me);
`` if "$name='OwnKeys'" |> free_identity_list(kl);
free_identity(partner);
`` if "$name='GroupKeys'" |> free_identity_list(kl);
return status;
}


Loading…
Cancel
Save