src/pEp_internal.h
changeset 2461 85c8e5aad3bc
parent 2285 367fefec18ea
child 2462 48b526a0daac
     1.1 --- a/src/pEp_internal.h	Mon Jan 15 12:26:14 2018 +0100
     1.2 +++ b/src/pEp_internal.h	Mon Jan 29 12:15:51 2018 +0100
     1.3 @@ -82,7 +82,6 @@
     1.4  #include "sqlite3.h"
     1.5  #endif
     1.6  
     1.7 -#define _EXPORT_PEP_ENGINE_DLL
     1.8  #include "pEpEngine.h"
     1.9  
    1.10  // If not specified, build for GPG
    1.11 @@ -124,7 +123,13 @@
    1.12      sqlite3_stmt *log;
    1.13      sqlite3_stmt *trustword;
    1.14      sqlite3_stmt *get_identity;
    1.15 +    sqlite3_stmt *get_identity_without_trust_check;
    1.16 +    sqlite3_stmt *get_identities_by_address;
    1.17      sqlite3_stmt *replace_identities_fpr;
    1.18 +    sqlite3_stmt *replace_main_user_fpr;
    1.19 +    sqlite3_stmt *get_main_user_fpr;
    1.20 +    sqlite3_stmt *refresh_userid_default_key;
    1.21 +    sqlite3_stmt *remove_fpr_as_default;
    1.22      sqlite3_stmt *set_person;
    1.23      sqlite3_stmt *set_device_group;
    1.24      sqlite3_stmt *get_device_group;
    1.25 @@ -141,6 +146,7 @@
    1.26      sqlite3_stmt *crashdump;
    1.27      sqlite3_stmt *languagelist;
    1.28      sqlite3_stmt *i18n_token;
    1.29 +    sqlite3_stmt *replace_userid;
    1.30  
    1.31      // blacklist
    1.32      sqlite3_stmt *blacklist_add;
    1.33 @@ -152,7 +158,11 @@
    1.34      sqlite3_stmt *own_key_is_listed;
    1.35      sqlite3_stmt *own_identities_retrieve;
    1.36      sqlite3_stmt *own_keys_retrieve;
    1.37 -    sqlite3_stmt *set_own_key;
    1.38 +    sqlite3_stmt *get_user_default_key;
    1.39 +        
    1.40 +    sqlite3_stmt *get_default_own_userid;
    1.41 +
    1.42 +//    sqlite3_stmt *set_own_key;
    1.43  
    1.44      // sequence value
    1.45      sqlite3_stmt *sequence_value1;
    1.46 @@ -163,6 +173,10 @@
    1.47      sqlite3_stmt *set_revoked;
    1.48      sqlite3_stmt *get_revoked;
    1.49  
    1.50 +    // aliases
    1.51 +    sqlite3_stmt *get_userid_alias_default;
    1.52 +    sqlite3_stmt *add_userid_alias;
    1.53 +
    1.54      // callbacks
    1.55      examine_identity_t examine_identity;
    1.56      void *examine_management;
    1.57 @@ -340,13 +354,6 @@
    1.58      return comparison == 0;
    1.59  }
    1.60  
    1.61 -static inline bool _identity_me(
    1.62 -        pEp_identity * identity
    1.63 -    )
    1.64 -{
    1.65 -    return identity->user_id && strcmp(identity->user_id, PEP_OWN_USERID) == 0;
    1.66 -}
    1.67 -
    1.68  // size is the length of the bytestr that's coming in. This is really only intended
    1.69  // for comparing two full strings. If charstr's length is different from bytestr_size,
    1.70  // we'll return a non-zero value.
    1.71 @@ -369,6 +376,32 @@
    1.72  #endif
    1.73  }
    1.74  
    1.75 +static inline bool is_me(PEP_SESSION session, pEp_identity* test_ident) {
    1.76 +    bool retval = false;
    1.77 +    if (test_ident && test_ident->user_id) {
    1.78 +        char* def_id = NULL;
    1.79 +        get_default_own_userid(session, &def_id);
    1.80 +        if (test_ident->me || 
    1.81 +            (def_id && strcmp(def_id, test_ident->user_id) == 0)) {
    1.82 +            retval = true;
    1.83 +        }
    1.84 +        free(def_id);
    1.85 +    }
    1.86 +    return retval;
    1.87 +}
    1.88 +
    1.89 +#ifndef EMPTYSTR
    1.90 +#define EMPTYSTR(STR) ((STR) == NULL || (STR)[0] == '\0')
    1.91 +#endif
    1.92 +
    1.93 +#ifndef _MIN
    1.94 +#define _MIN(A, B) ((B) > (A) ? (A) : (B))
    1.95 +#endif
    1.96 +#ifndef _MAX
    1.97 +#define _MAX(A, B) ((B) > (A) ? (B) : (A))
    1.98 +#endif
    1.99 +
   1.100 +
   1.101  // These are globals used in generating message IDs and should only be
   1.102  // computed once, as they're either really constants or OS-dependent
   1.103