Browse Source

show notification and trigger update

COM-121
Volker Birk 2 years ago
parent
commit
5cc25f8092
6 changed files with 31 additions and 8 deletions
  1. +21
    -3
      CMainWindow.cpp
  2. +4
    -0
      CMainWindow.h
  3. +2
    -3
      GateKeeper.cpp
  4. +1
    -1
      GateKeeper.h
  5. BIN
      pEpCOMServerAdapter.rc
  6. +3
    -1
      stdafx.h

+ 21
- 3
CMainWindow.cpp View File

@ -85,8 +85,8 @@ LRESULT CMainWindow::OnNotification(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
return S_OK;
}
static const auto UPDATE_NOW = 1;
static const auto SCHEDULE_UPDATES = 3;
static const auto UPDATE_NOW = 0;
static const auto SCHEDULE_UPDATES = 2;
LRESULT CMainWindow::OnMenuCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
@ -96,7 +96,8 @@ LRESULT CMainWindow::OnMenuCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
switch (index) {
case UPDATE_NOW:
::MessageBox(NULL, _T("update now"), _T("update now"), MB_ICONINFORMATION);
ShowNotificationInfo(_T("Searching for updates"), _T("p≡p is searching for updates. When an update is available p≡p will start an installer."));
pEp::GateKeeper::gatekeeper()->update_now();
bHandled = true;
break;
@ -107,9 +108,26 @@ LRESULT CMainWindow::OnMenuCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
else
pEp::GateKeeper::gatekeeper()->disable_update();
CheckMenuItem(hMenu, ID_POPUP_SCHEDULEUPDATES, enabled ? MF_CHECKED : MF_UNCHECKED);
bHandled = true;
break;
default:
bHandled = false;
}
return S_OK;
}
void CMainWindow::ShowNotificationInfo(tstring title, tstring text)
{
NOTIFYICONDATA nid = {};
nid.cbSize = sizeof(nid);
nid.uFlags = NIF_GUID | NIF_MESSAGE | NIF_INFO;
nid.dwInfoFlags = NIIF_LARGE_ICON;
nid.hWnd = m_hWnd;
nid.guidItem = nidGUID;
nid.hBalloonIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_LOGO));
StringCchCopy(nid.szInfoTitle, ARRAYSIZE(nid.szInfoTitle), title.substr(0, ARRAYSIZE(nid.szInfoTitle)-1).c_str());
StringCchCopy(nid.szInfo, ARRAYSIZE(nid.szInfo), text.substr(0, ARRAYSIZE(nid.szInfo) - 1).c_str());
nid.uCallbackMessage = WM_PEP_NOTIFICATION;
Shell_NotifyIcon(NIM_MODIFY, &nid);
}

+ 4
- 0
CMainWindow.h View File

@ -26,4 +26,8 @@ public:
LRESULT OnDestroy(UINT /*nMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnNotification(UINT /*nMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnMenuCommand(UINT /*nMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
protected:
typedef std::basic_string<TCHAR> tstring;
void ShowNotificationInfo(tstring title, tstring text);
};

+ 2
- 3
GateKeeper.cpp View File

@ -2,7 +2,6 @@
#include "GateKeeper.h"
#include "pEpCOMServerAdapter.h"
#include "utf8_helper.h"
using namespace std;
@ -183,7 +182,7 @@ namespace pEp {
if (now > next) {
next = now + GateKeeper::cycle;
if (update_enabled())
keep_updated();
update_now();
}
Sleep(waiting);
@ -610,7 +609,7 @@ namespace pEp {
return result;
}
void GateKeeper::keep_updated()
void GateKeeper::update_now()
{
NTSTATUS status = BCryptOpenAlgorithmProvider(&hAES, BCRYPT_AES_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0);
assert(status == 0);


+ 1
- 1
GateKeeper.h View File

@ -42,6 +42,7 @@ namespace pEp {
bool update_enabled();
void enable_update();
void disable_update();
void update_now();
static GateKeeper *gatekeeper() { return the_gatekeeper; }
@ -63,7 +64,6 @@ namespace pEp {
BCRYPT_KEY_HANDLE delivery_key();
string wrapped_delivery_key(BCRYPT_KEY_HANDLE hDeliveryKey);
void keep_updated();
static tstring get_lockFile();
static GateKeeper *the_gatekeeper;


BIN
pEpCOMServerAdapter.rc View File


+ 3
- 1
stdafx.h View File

@ -70,4 +70,6 @@
#include "utf8_helper.h"
#include "pEp_utility.h"
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include "utf8_helper.h"

Loading…
Cancel
Save