GateKeeper.h
author Thomas
Wed, 02 May 2018 09:46:48 +0200
branchCOM-87
changeset 287 99abd7d70c1e
parent 284 83ad8d765099
child 360 57c7ace37425
permissions -rw-r--r--
Rename flags
     1 class CpEpCOMServerAdapterModule;
     2 
     3 using namespace std;
     4 
     5 namespace pEp {
     6 
     7 #ifdef UNICODE
     8     typedef wstring tstring;
     9 #else
    10     typedef string tstring;
    11 #endif
    12 
    13     class GateKeeper {
    14     public:
    15         typedef pair<tstring, tstring> product;
    16         typedef vector< product > product_list;
    17         union aeskey_t {
    18             uint8_t c_key[32];
    19             uint16_t w_key[16];
    20             uint32_t dw_key[8];
    21             uint64_t qw_key[4];
    22         };
    23 
    24         GateKeeper(CpEpCOMServerAdapterModule * self);
    25         ~GateKeeper();
    26 
    27         CpEpCOMServerAdapterModule * const module() const
    28         {
    29             return _self;
    30         }
    31 
    32         void keep();
    33 
    34         static void update_now();
    35 
    36     protected:
    37         static const LPCTSTR plugin_reg_path;
    38         static const LPCTSTR plugin_reg_value_name;
    39         static const LPCTSTR updater_reg_path;
    40 
    41         static const time_t cycle;
    42         static const time_t fraction;
    43         static const std::chrono::seconds waiting;
    44 
    45         static time_t time_diff();
    46 
    47         void keep_plugin();
    48 
    49         void install_msi(tstring filename);
    50         string update_key();
    51         BCRYPT_KEY_HANDLE delivery_key();
    52         string wrapped_delivery_key(BCRYPT_KEY_HANDLE hDeliveryKey);
    53 
    54         void update_product(product p, DWORD context);
    55         product_list registered_products();
    56         void keep_updated();
    57         static tstring get_lockFile();
    58 
    59     private:
    60         time_t now;
    61         time_t next;
    62         bool cu_open;
    63         HKEY cu;
    64         HKEY hkUpdater;
    65         HINTERNET internet;
    66         BCRYPT_ALG_HANDLE hAES;
    67         BCRYPT_ALG_HANDLE hRSA;
    68 
    69         CpEpCOMServerAdapterModule * _self;
    70 
    71         static std::mutex update_wait_mtx;
    72         static std::condition_variable update_wait_var;
    73         static bool update_wait_forced;
    74     };
    75 }