Browse Source

adding get_own_addresses()

doc_update_sequoia
Volker Birk 6 years ago
parent
commit
eae4c92185
4 changed files with 68 additions and 13 deletions
  1. +4
    -12
      src/keymanagement.c
  2. +51
    -0
      src/pEpEngine.c
  3. +12
    -1
      src/pEpEngine.h
  4. +1
    -0
      src/pEp_internal.h

+ 4
- 12
src/keymanagement.c View File

@ -356,11 +356,12 @@ DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
assert(session);
assert(identity);
assert(!EMPTYSTR(identity->address));
assert(EMPTYSTR(identity->user_id) ||
strcmp(identity->user_id, PEP_OWN_USERID) == 0);
if (!(session && identity &&
if (!(session && identity && !EMPTYSTR(identity->address) &&
(EMPTYSTR(identity->user_id) ||
strcmp(identity->user_id, PEP_OWN_USERID) == 0)))
return PEP_ILLEGAL_VALUE;
@ -377,17 +378,8 @@ DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
return PEP_OUT_OF_MEMORY;
}
if (!identity->address)
{
identity->address = strdup("");
assert(identity->address);
if (!identity->address)
return PEP_OUT_OF_MEMORY;
}
DEBUG_LOG("myself", "debug", EMPTYSTR(identity->address) ?
"<default address>" : identity->address);
DEBUG_LOG("myself", "debug", identity->address);
status = get_identity(session,
identity->address,
identity->user_id,


+ 51
- 0
src/pEpEngine.c View File

@ -38,6 +38,7 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
static const char *sql_crashdump;
static const char *sql_languagelist;
static const char *sql_i18n_token;
static const char *sql_get_own_addresses;
// blacklist
static const char *sql_blacklist_add;
@ -336,6 +337,8 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
sql_i18n_token = "select phrase from i18n_token where lang = lower(?1) and id = ?2 ;";
sql_get_own_addresses = "select address from identity where user_id = '" PEP_OWN_USERID "';";
// blacklist
sql_blacklist_add = "insert or replace into blacklist_keys (fpr) values (upper(replace(?1,' ',''))) ;"
@ -444,6 +447,11 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
(int)strlen(sql_i18n_token), &_session->i18n_token, NULL);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_get_own_addresses,
(int)strlen(sql_get_own_addresses), &_session->get_own_addresses,
NULL);
assert(int_result == SQLITE_OK);
// blacklist
int_result = sqlite3_prepare_v2(_session->db, sql_blacklist_add,
@ -1723,6 +1731,49 @@ DYNAMIC_API PEP_STATUS sequence_value(
return status;
}
DYNAMIC_API PEP_STATUS get_own_addresses(
PEP_SESSION session,
stringlist_t **addresses
)
{
PEP_STATUS status = PEP_STATUS_OK;
assert(session && addresses);
if (!(session && addresses))
return PEP_ILLEGAL_VALUE;
stringlist_t *_addresses = new_stringlist(NULL);
if (!_addresses)
return PEP_OUT_OF_MEMORY;
sqlite3_reset(session->get_own_addresses);
int result;
stringlist_t *_a = _addresses;
do {
result = sqlite3_step(session->get_own_addresses);
char *address;
switch (result) {
case SQLITE_ROW:
sqlite3_bind_text(session->get_own_addresses, 1, address, -1,
SQLITE_STATIC);
_a = stringlist_add(_a, address);
if (!_a) {
free_stringlist(_addresses);
return PEP_OUT_OF_MEMORY;
}
break;
default:
status = PEP_UNKNOWN_ERROR;
}
} while (result == SQLITE_ROW);
sqlite3_reset(session->get_own_addresses);
if (status == PEP_STATUS_OK)
*addresses = _addresses;
return status;
}
DYNAMIC_API PEP_STATUS set_revoked(
PEP_SESSION session,
const char *revoked_fpr,


+ 12
- 1
src/pEpEngine.h View File

@ -868,7 +868,18 @@ DYNAMIC_API PEP_STATUS sequence_value(
int32_t *value
);
// get_own_addresses() - get a list of own addresses
//
// parameters:
// session (in) session handle
// addresses (out) stringlist with addresses
DYNAMIC_API PEP_STATUS get_own_addresses(
PEP_SESSION session,
stringlist_t **addresses
);
// set_revoked() - records relation between a revoked key and its replacement
//
// parameters:


+ 1
- 0
src/pEp_internal.h View File

@ -106,6 +106,7 @@ typedef struct _pEpSession {
sqlite3_stmt *crashdump;
sqlite3_stmt *languagelist;
sqlite3_stmt *i18n_token;
sqlite3_stmt *get_own_addresses;
// blacklist
sqlite3_stmt *blacklist_add;


Loading…
Cancel
Save