updatable management.db

doc_update_sequoia
Volker Birk 7 years ago
parent 2a10cd2f6c
commit 58ea3b10be

@ -6,6 +6,19 @@
static int init_count = -1;
static int user_version(void *_version, int count, char **text, char **name)
{
assert(_version);
assert(count == 1);
assert(text && text[0]);
if (!(_version && count == 1 && text && text[0]))
return -1;
int *version = (int *) _version;
*version = atoi(text[0]);
return 0;
}
DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
{
PEP_STATUS status = PEP_STATUS_OK;
@ -112,15 +125,37 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
sqlite3_busy_timeout(_session->system_db, 1000);
// increment this when patching DDL
#define _DDL_USER_VERSION "1"
if (in_first) {
int_result = sqlite3_exec(
_session->db,
"create table if not exists version_info (\n"
"create table version_info (\n"
" id integer primary key,\n"
" timestamp integer default (datetime('now')) ,\n"
" version text,\n"
" comment text\n"
");\n"
");\n",
NULL,
NULL,
NULL
);
if (int_result == SQLITE_OK) {
int_result = sqlite3_exec(
_session->db,
"pragma user_version = "_DDL_USER_VERSION";\n"
"insert or replace into version_info (id, version)"
"values (1, '" PEP_ENGINE_VERSION "');",
NULL,
NULL,
NULL
);
assert(int_result == SQLITE_OK);
}
int_result = sqlite3_exec(
_session->db,
"create table if not exists log (\n"
" timestamp integer default (datetime('now')) ,\n"
" title text not null,\n"
@ -160,6 +195,7 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
" references pgp_keypair (fpr)\n"
" on delete set null,\n"
" comment text,\n"
" flags integer default (0),"
" primary key (address, user_id)\n"
");\n"
"create table if not exists trust (\n"
@ -196,15 +232,41 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
);
assert(int_result == SQLITE_OK);
int version;
int_result = sqlite3_exec(
_session->db,
"insert or replace into version_info (id, version) values (1, '1.1');",
NULL,
NULL,
"pragma user_version;",
user_version,
&version,
NULL
);
assert(int_result == SQLITE_OK);
if (version < 1) {
int_result = sqlite3_exec(
_session->db,
"alter table identity\n"
" add column flags integer default (0);",
NULL,
NULL,
NULL
);
assert(int_result == SQLITE_OK);
}
if (version < atoi(_DDL_USER_VERSION)) {
int_result = sqlite3_exec(
_session->db,
"pragma user_version = "_DDL_USER_VERSION";\n"
"insert or replace into version_info (id, version)"
"values (1, '" PEP_ENGINE_VERSION "');",
NULL,
NULL,
NULL
);
assert(int_result == SQLITE_OK);
}
sql_log = "insert into log (title, entity, description, comment)"
"values (?1, ?2, ?3, ?4);";

@ -379,6 +379,11 @@ typedef enum _PEP_comm_type {
PEP_ct_pEp = 0xff
} PEP_comm_type;
typedef enum _identity_flags {
PEP_idf_NOT_FOR_SYNC = 1, // don't use this identity for sync
PEP_idf_GROUP = 2 // identity of group of persons
} identity_flags;
typedef struct _pEp_identity {
char *address; // C string with address UTF-8 encoded
char *fpr; // C string with fingerprint UTF-8 encoded
@ -388,6 +393,7 @@ typedef struct _pEp_identity {
char lang[3]; // language of conversation
// ISO 639-1 ALPHA-2, last byte is 0
bool me; // if this is the local user herself/himself
unsigned int flags; // identity_flag1 | identity_flag2 | ...
} pEp_identity;
typedef struct _identity_list {

@ -1,4 +1,4 @@
#define PEP_ENGINE_VERSION "0.7.0"
#define PEP_ENGINE_VERSION "0.8.0"
// maximum attachment size to import as key 1MB, maximum of 20 attachments

Loading…
Cancel
Save