GateKeeper.h
author Thomas
Fri, 10 Jul 2020 07:45:52 +0200
changeset 447 18a75cc8b45f
parent 429 2e8e6705baa0
permissions -rw-r--r--
Expose ShowNotification for app
     1 #include "stdafx.h"
     2 
     3 class CpEpCOMServerAdapterModule;
     4 
     5 using namespace std;
     6 
     7 namespace pEp {
     8 
     9 #ifdef UNICODE
    10 	typedef wstring tstring;
    11 	typedef wregex tregex;
    12 	typedef wsmatch tsmatch;
    13 #else
    14 	typedef string tstring;
    15 	typedef regex tregex;
    16 	typedef smatch tsmatch;
    17 #endif
    18 
    19     class GateKeeper {
    20     public:
    21         typedef pair<tstring, tstring> product;
    22         typedef vector< product > product_list;
    23         union aeskey_t {
    24             uint8_t c_key[32];
    25             uint16_t w_key[16];
    26             uint32_t dw_key[8];
    27             uint64_t qw_key[4];
    28         };
    29 
    30         GateKeeper(CpEpCOMServerAdapterModule * self);
    31         ~GateKeeper();
    32 
    33         CpEpCOMServerAdapterModule * const module() const
    34         {
    35             return _self;
    36         }
    37 
    38         void keep();
    39 		product_list registered_products();
    40 		bool update_product(product p, DWORD context = 0);
    41 
    42         bool update_enabled();
    43         void enable_update();
    44         void disable_update();
    45         void update_now();
    46 
    47         void show_notification(tstring title, tstring text);
    48 
    49 		static GateKeeper *gatekeeper() { return the_gatekeeper; }
    50 
    51     protected:
    52         static const LPCTSTR plugin_reg_path;
    53         static const LPCTSTR plugin_reg_value_name;
    54         static const LPCTSTR updater_reg_path;
    55 
    56         static const time_t cycle;
    57         static const time_t fraction;
    58         static const DWORD waiting;
    59 
    60         static time_t time_diff();
    61 
    62         void keep_plugin();
    63 
    64         void execute_file(tstring filename);
    65         string update_key();
    66         BCRYPT_KEY_HANDLE delivery_key();
    67         string wrapped_delivery_key(BCRYPT_KEY_HANDLE hDeliveryKey);
    68 
    69         static tstring get_lockFile();
    70 		static GateKeeper *the_gatekeeper;
    71 
    72     private:
    73         time_t now;
    74         time_t next;
    75         bool cu_open;
    76         HKEY cu;
    77         HKEY hkUpdater;
    78         HINTERNET internet;
    79         BCRYPT_ALG_HANDLE hAES;
    80         BCRYPT_ALG_HANDLE hRSA;
    81 
    82         CpEpCOMServerAdapterModule * _self;
    83     };
    84 }