Project64: Only show support window once per hour
This commit is contained in:
parent
25dde67f9d
commit
1751b2fd8b
|
@ -1,5 +1,6 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include <Common\md5.h>
|
#include <Common\md5.h>
|
||||||
|
#include <time.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <Wininet.h>
|
#include <Wininet.h>
|
||||||
|
|
||||||
|
@ -106,10 +107,29 @@ std::string CProjectSupport::GenerateMachineID(void)
|
||||||
|
|
||||||
void CProjectSupport::IncrementRunCount()
|
void CProjectSupport::IncrementRunCount()
|
||||||
{
|
{
|
||||||
|
time_t now = time(nullptr);
|
||||||
|
if (m_SupportInfo.LastUpdated <= now && ((now - m_SupportInfo.LastUpdated) / 60) < 60)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_SupportInfo.RunCount += 1;
|
m_SupportInfo.RunCount += 1;
|
||||||
|
m_SupportInfo.LastUpdated = now;
|
||||||
SaveSupportInfo();
|
SaveSupportInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CProjectSupport::ShowSuppotWindow()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
time_t now = time(nullptr);
|
||||||
|
if (m_SupportInfo.LastShown <= now && ((now - m_SupportInfo.LastShown) / 60) < 60)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
m_SupportInfo.LastShown = now;
|
||||||
|
SaveSupportInfo();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool CProjectSupport::PerformRequest(const wchar_t * Url, const std::string & PostData, DWORD & StatusCode, std::vector<std::string> & Headers)
|
bool CProjectSupport::PerformRequest(const wchar_t * Url, const std::string & PostData, DWORD & StatusCode, std::vector<std::string> & Headers)
|
||||||
{
|
{
|
||||||
StatusCode = 0;
|
StatusCode = 0;
|
||||||
|
@ -259,7 +279,7 @@ void CProjectSupport::LoadSupportInfo(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OutData.size() > 0)
|
if (OutData.size() == sizeof(SupportInfo) + 32)
|
||||||
{
|
{
|
||||||
SupportInfo * Info = (SupportInfo *)OutData.data();
|
SupportInfo * Info = (SupportInfo *)OutData.data();
|
||||||
const char * CurrentHash = (const char *)(OutData.data() + sizeof(SupportInfo));
|
const char * CurrentHash = (const char *)(OutData.data() + sizeof(SupportInfo));
|
||||||
|
|
|
@ -11,6 +11,8 @@ class CProjectSupport
|
||||||
char Name[300];
|
char Name[300];
|
||||||
char MachineID[300];
|
char MachineID[300];
|
||||||
uint32_t RunCount;
|
uint32_t RunCount;
|
||||||
|
time_t LastUpdated;
|
||||||
|
time_t LastShown;
|
||||||
bool Validated;
|
bool Validated;
|
||||||
} SupportInfo;
|
} SupportInfo;
|
||||||
|
|
||||||
|
@ -20,6 +22,7 @@ public:
|
||||||
bool RequestCode(const char * Email);
|
bool RequestCode(const char * Email);
|
||||||
bool ValidateCode(const char * Code);
|
bool ValidateCode(const char * Code);
|
||||||
void IncrementRunCount();
|
void IncrementRunCount();
|
||||||
|
bool ShowSuppotWindow();
|
||||||
|
|
||||||
inline uint32_t RunCount() const { return m_SupportInfo.RunCount; }
|
inline uint32_t RunCount() const { return m_SupportInfo.RunCount; }
|
||||||
inline const char * MachineID(void) const { return m_SupportInfo.MachineID; }
|
inline const char * MachineID(void) const { return m_SupportInfo.MachineID; }
|
||||||
|
|
|
@ -33,7 +33,7 @@ void CSupportWindow::Show(HWND hParent, bool Delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Support.IncrementRunCount();
|
m_Support.IncrementRunCount();
|
||||||
if (m_Support.RunCount() < 7)
|
if (m_Support.RunCount() < 7 || !m_Support.ShowSuppotWindow())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ LRESULT CSupportWindow::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*
|
||||||
|
|
||||||
MoveWindow(Left, Top, rcWin.Width(), rcWin.Height(), TRUE);
|
MoveWindow(Left, Top, rcWin.Width(), rcWin.Height(), TRUE);
|
||||||
|
|
||||||
/*if (m_Delay && m_RunCount >= 10)
|
if (m_Delay && m_Support.RunCount() >= 15)
|
||||||
{
|
{
|
||||||
CMenuHandle menu = GetSystemMenu(false);
|
CMenuHandle menu = GetSystemMenu(false);
|
||||||
menu.RemoveMenu(SC_CLOSE, MF_BYCOMMAND);
|
menu.RemoveMenu(SC_CLOSE, MF_BYCOMMAND);
|
||||||
|
@ -127,7 +127,7 @@ LRESULT CSupportWindow::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*
|
||||||
GetDlgItem(IDCANCEL).EnableWindow(false);
|
GetDlgItem(IDCANCEL).EnableWindow(false);
|
||||||
srand ((uint32_t)time(NULL));
|
srand ((uint32_t)time(NULL));
|
||||||
SetTimer(0, 1000, NULL);
|
SetTimer(0, 1000, NULL);
|
||||||
}*/
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue