mirror of
https://github.com/winscp/winscp.git
synced 2026-10-24 02:28:55 +03:00
Reporting first run date and package name when checking for application updates + Enforcing check for 3rd party packages + Store installations can display messages from updates check too
(cherry picked from commit ce65d95fa7)
# Conflicts:
# source/core/Common.cpp
Source commit: 24a8d70a715242bc66bee6e16401f5aa3e8b38be
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include <tlhelp32.h>
|
||||
#include <psapi.h>
|
||||
#include <CoreMain.h>
|
||||
#include <SessionInfo.h>
|
||||
#include <openssl/pkcs12.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/err.h>
|
||||
@@ -38,6 +39,7 @@ const wchar_t TokenReplacement = wchar_t(true);
|
||||
const UnicodeString LocalInvalidChars(TraceInitStr(L"/\\:*?\"<>|"));
|
||||
const UnicodeString PasswordMask(TraceInitStr(L"***"));
|
||||
const UnicodeString Ellipsis(TraceInitStr(L"..."));
|
||||
const UnicodeString OfficialPackage(TraceInitStr(L"MartinPikryl.WinSCP_tvv458r3h9r5m"));
|
||||
//---------------------------------------------------------------------------
|
||||
UnicodeString ReplaceChar(UnicodeString Str, wchar_t A, wchar_t B)
|
||||
{
|
||||
@@ -3052,6 +3054,7 @@ static void NeedUWPData()
|
||||
(GetCurrentPackageFamilyName(&NameLen, NULL) == ERROR_INSUFFICIENT_BUFFER))
|
||||
{
|
||||
GIsUWP = 1;
|
||||
AppLog(L"Is UWP application");
|
||||
GPackageName.SetLength(NameLen);
|
||||
if (GetCurrentPackageFamilyName(&NameLen, GPackageName.c_str()) == ERROR_SUCCESS)
|
||||
{
|
||||
@@ -3061,6 +3064,11 @@ static void NeedUWPData()
|
||||
{
|
||||
GPackageName = L"err";
|
||||
}
|
||||
AppLogFmt(L"Package name: %s", (GPackageName));
|
||||
}
|
||||
else
|
||||
{
|
||||
AppLog(L"Is not UWP application");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3077,6 +3085,11 @@ UnicodeString GetPackageName()
|
||||
return GPackageName;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
bool IsOfficialPackage()
|
||||
{
|
||||
return (GetPackageName() == OfficialPackage);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
LCID __fastcall GetDefaultLCID()
|
||||
{
|
||||
return GetUserDefaultLCID();
|
||||
|
||||
@@ -145,6 +145,7 @@ bool IsWin11();
|
||||
bool __fastcall IsWine();
|
||||
bool __fastcall IsUWP();
|
||||
UnicodeString GetPackageName();
|
||||
bool IsOfficialPackage();
|
||||
TLibModule * __fastcall FindModule(void * Instance);
|
||||
__int64 __fastcall Round(double Number);
|
||||
bool __fastcall TryRelativeStrToDateTime(UnicodeString S, TDateTime & DateTime, bool Add);
|
||||
|
||||
@@ -979,6 +979,7 @@ void TCustomScpExplorerForm::CheckStoreTransition()
|
||||
else if ((WinConfiguration->StoreTransition == stStandard) && IsUWP())
|
||||
{
|
||||
WinConfiguration->StoreTransition = stStoreMigrated;
|
||||
WinConfiguration->FirstRun = WinConfiguration->FirstRun + L"=>" + StandardDatestamp();
|
||||
AppLog(L"Standard installation migrated to store installation");
|
||||
}
|
||||
|
||||
@@ -8933,40 +8934,59 @@ void __fastcall TCustomScpExplorerForm::StartUpdates()
|
||||
// first run after installation
|
||||
if (double(Updates.LastCheck) == 0)
|
||||
{
|
||||
AppLog(L"First run, scheduling updates check for the next run");
|
||||
// make sure next time there will be an update (if enabled)
|
||||
Updates.LastCheck = TDateTime(1);
|
||||
WinConfiguration->Updates = Updates;
|
||||
}
|
||||
else if ((double(Updates.Period) > 0) &&
|
||||
(Now() - Updates.LastCheck >= Updates.Period))
|
||||
else
|
||||
{
|
||||
TThreadMethod OnUpdatesChecked = NULL;
|
||||
if (!IsUWP())
|
||||
TDateTime Period;
|
||||
if (IsUWP() && !IsOfficialPackage())
|
||||
{
|
||||
OnUpdatesChecked = UpdatesChecked;
|
||||
Period = DefaultUpdatesPeriod;
|
||||
AppLog(L"Thirdparty UWP package, using default updates check period");
|
||||
}
|
||||
else
|
||||
{
|
||||
Period = Updates.Period;
|
||||
}
|
||||
AppLogFmt(L"Updates check period: %.2f", (double(Period)));
|
||||
if (double(Period) > 0)
|
||||
{
|
||||
TDateTime Interval = Now() - Updates.LastCheck;
|
||||
AppLogFmt(L"Interval since the last updates check: %.2f", (double(Interval)));
|
||||
if (Interval >= Period)
|
||||
{
|
||||
StartUpdateThread(UpdatesChecked);
|
||||
}
|
||||
}
|
||||
StartUpdateThread(OnUpdatesChecked);
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TCustomScpExplorerForm::UpdatesChecked()
|
||||
{
|
||||
AppLog(L"Updates check done");
|
||||
UnicodeString Message;
|
||||
bool New;
|
||||
TQueryType Type;
|
||||
GetUpdatesMessage(Message, New, Type, false);
|
||||
if (!Message.IsEmpty())
|
||||
{
|
||||
AppLogFmt(L"Updates check message: %s", (Message));
|
||||
if (New)
|
||||
{
|
||||
AppLog(L"New version detected");
|
||||
Message = FMTLOAD(NEW_VERSION_CLICK, (Message));
|
||||
}
|
||||
if (!New && (Type != qtWarning))
|
||||
{
|
||||
AppLog(L"Posting non-critical updates note");
|
||||
PostNote(UnformatMessage(Message), 0, UpdatesNoteClicked, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
AppLog(L"Posting new version or critical message notification");
|
||||
Notify(NULL, Message, Type, true, UpdatesNoteClicked);
|
||||
}
|
||||
|
||||
|
||||
@@ -939,7 +939,7 @@ void __fastcall TPreferencesDialog::SaveConfiguration()
|
||||
{
|
||||
if (Updates.Period == TDateTime(0))
|
||||
{
|
||||
Updates.Period = 7;
|
||||
Updates.Period = DefaultUpdatesPeriod;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -901,14 +901,23 @@ static bool __fastcall DoQueryUpdates(TUpdatesConfiguration & Updates, bool Coll
|
||||
URL += L"&localever=" + LocaleVersion;
|
||||
URL += L"&localecompl=" + LoadStr(TRANSLATION_COMPLETENESS);
|
||||
}
|
||||
// Even if donor email is inherited from normal installation,
|
||||
// do not use it as this all is merely to report usage statistics, not to check for updates, in UWP.
|
||||
if (!Updates.AuthenticationEmail.IsEmpty() && !IsUWP())
|
||||
URL += L"&firstrun=" + EncodeUrlString(WinConfiguration->FirstRun);
|
||||
if (!IsUWP())
|
||||
{
|
||||
RawByteString AuthenticationEmailBuf = RawByteString(UTF8String(Updates.AuthenticationEmail.LowerCase()));
|
||||
URL += L"&authentication=" + Sha256(AuthenticationEmailBuf.c_str(), AuthenticationEmailBuf.Length()).LowerCase();
|
||||
// Even if donor email is inherited from normal installation,
|
||||
// do not use it as this all is merely to report usage statistics, not to check for updates, in UWP.
|
||||
if (!Updates.AuthenticationEmail.IsEmpty())
|
||||
{
|
||||
RawByteString AuthenticationEmailBuf = RawByteString(UTF8String(Updates.AuthenticationEmail.LowerCase()));
|
||||
URL += L"&authentication=" + Sha256(AuthenticationEmailBuf.c_str(), AuthenticationEmailBuf.Length()).LowerCase();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
URL += L"&package=" + EncodeUrlString(GetPackageName());
|
||||
}
|
||||
|
||||
AppLogFmt(L"Updates check URL: %s", (URL));
|
||||
CheckForUpdatesHTTP->URL = URL;
|
||||
// sanity check
|
||||
CheckForUpdatesHTTP->ResponseLimit = 102400;
|
||||
@@ -934,6 +943,7 @@ static bool __fastcall DoQueryUpdates(TUpdatesConfiguration & Updates, bool Coll
|
||||
throw;
|
||||
}
|
||||
Response = CheckForUpdatesHTTP->Response;
|
||||
AppLogFmt(L"Updates check response: %s", (Response));
|
||||
}
|
||||
__finally
|
||||
{
|
||||
@@ -1148,19 +1158,26 @@ void __fastcall GetUpdatesMessage(UnicodeString & Message, bool & New,
|
||||
}
|
||||
else
|
||||
{
|
||||
New = (Updates.Results.Version > 0);
|
||||
if (New)
|
||||
if (IsUWP())
|
||||
{
|
||||
UnicodeString Version = VersionStrFromCompoundVersion(Updates.Results.Version);
|
||||
if (!Updates.Results.Release.IsEmpty())
|
||||
{
|
||||
Version = FORMAT(L"%s %s", (Version, Updates.Results.Release));
|
||||
}
|
||||
Message = FMTLOAD(NEW_VERSION4, (Version));
|
||||
New = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Message = LoadStr(NO_NEW_VERSION);
|
||||
New = (Updates.Results.Version > 0);
|
||||
if (New)
|
||||
{
|
||||
UnicodeString Version = VersionStrFromCompoundVersion(Updates.Results.Version);
|
||||
if (!Updates.Results.Release.IsEmpty())
|
||||
{
|
||||
Version = FORMAT(L"%s %s", (Version, Updates.Results.Release));
|
||||
}
|
||||
Message = FMTLOAD(NEW_VERSION4, (Version));
|
||||
}
|
||||
else
|
||||
{
|
||||
Message = LoadStr(NO_NEW_VERSION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1175,7 +1192,7 @@ void __fastcall GetUpdatesMessage(UnicodeString & Message, bool & New,
|
||||
FMTLOAD(UPDATE_MESSAGE, (FormatUpdatesMessage(Updates.Results.Message, Updates)));
|
||||
}
|
||||
|
||||
if (!Updates.Results.AuthenticationError.IsEmpty())
|
||||
if (!Updates.Results.AuthenticationError.IsEmpty() && !IsUWP())
|
||||
{
|
||||
Message +=
|
||||
FMTLOAD(UPDATE_MESSAGE, (FormatUpdatesMessage(Updates.Results.AuthenticationError, Updates)));
|
||||
|
||||
@@ -30,6 +30,7 @@ TWinConfiguration * WinConfiguration = NULL;
|
||||
static UnicodeString NotepadName(L"notepad.exe");
|
||||
static UnicodeString ToolbarsLayoutKey(L"ToolbarsLayout2");
|
||||
static UnicodeString ToolbarsLayoutOldKey(L"ToolbarsLayout");
|
||||
TDateTime DefaultUpdatesPeriod(7);
|
||||
//---------------------------------------------------------------------------
|
||||
static const wchar_t FileColorDataSeparator = L':';
|
||||
TFileColorData::TFileColorData() :
|
||||
@@ -623,6 +624,7 @@ void __fastcall TWinConfiguration::Default()
|
||||
UseIconUpdateThread = true;
|
||||
AllowWindowPrint = false;
|
||||
StoreTransition = stInit;
|
||||
FirstRun = StandardDatestamp();
|
||||
|
||||
FEditor.Font.FontName = DefaultFixedWidthFontName;
|
||||
FEditor.Font.FontSize = DefaultFixedWidthFontSize;
|
||||
@@ -1072,6 +1074,7 @@ THierarchicalStorage * TWinConfiguration::CreateScpStorage(bool & SessionList)
|
||||
KEY(Bool, UseIconUpdateThread); \
|
||||
KEY(Bool, AllowWindowPrint); \
|
||||
KEY(Integer, StoreTransition); \
|
||||
KEY(String, FirstRun); \
|
||||
); \
|
||||
BLOCK(L"Interface\\Editor", CANCREATE, \
|
||||
KEYEX(String, Editor.Font.FontName, L"FontName2"); \
|
||||
@@ -2743,6 +2746,11 @@ void TWinConfiguration::SetStoreTransition(TStoreTransition value)
|
||||
SET_CONFIG_PROPERTY(StoreTransition);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void TWinConfiguration::SetFirstRun(const UnicodeString & value)
|
||||
{
|
||||
SET_CONFIG_PROPERTY(FirstRun);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
TStringList * __fastcall TWinConfiguration::LoadJumpList(
|
||||
THierarchicalStorage * Storage, UnicodeString Name)
|
||||
{
|
||||
|
||||
@@ -207,6 +207,7 @@ struct TUpdatesData
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
enum TConnectionType { ctDirect, ctAuto, ctProxy };
|
||||
extern TDateTime DefaultUpdatesPeriod;
|
||||
//---------------------------------------------------------------------------
|
||||
struct TUpdatesConfiguration
|
||||
{
|
||||
@@ -466,6 +467,7 @@ private:
|
||||
bool FUseIconUpdateThread;
|
||||
bool FAllowWindowPrint;
|
||||
TStoreTransition FStoreTransition;
|
||||
UnicodeString FFirstRun;
|
||||
int FDontDecryptPasswords;
|
||||
int FMasterPasswordSession;
|
||||
bool FMasterPasswordSessionAsked;
|
||||
@@ -581,6 +583,7 @@ private:
|
||||
void __fastcall SetUseIconUpdateThread(bool value);
|
||||
void __fastcall SetAllowWindowPrint(bool value);
|
||||
void SetStoreTransition(TStoreTransition value);
|
||||
void SetFirstRun(const UnicodeString & value);
|
||||
int __fastcall GetLocaleCompletenessTreshold();
|
||||
|
||||
bool __fastcall GetDDExtInstalled();
|
||||
@@ -777,6 +780,7 @@ public:
|
||||
__property bool UseIconUpdateThread = { read = FUseIconUpdateThread, write = SetUseIconUpdateThread };
|
||||
__property bool AllowWindowPrint = { read = FAllowWindowPrint, write = SetAllowWindowPrint };
|
||||
__property TStoreTransition StoreTransition = { read = FStoreTransition, write = SetStoreTransition };
|
||||
__property UnicodeString FirstRun = { read = FFirstRun, write = SetFirstRun };
|
||||
__property LCID DefaultLocale = { read = FDefaultLocale };
|
||||
__property int LocaleCompletenessTreshold = { read = GetLocaleCompletenessTreshold };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user