Author: ashaposhnikov
Date: Thu Jun 29 14:17:16 2017
New Revision: 75233
URL:
http://svn.reactos.org/svn/reactos?rev=75233&view=rev
Log:
[RAPPS] Update check, license type
* Added LicenseType numeric field in the RAPPS DB files.
Values mean: 1 - open source, 2 - freeware, 3 - trial/demo
The existing License field will be used to contain the license name itself.
* Finished version parser and update check.
Now RAPPS can suggest an update.
* Added new strings to lang/en-US.rc, lang/ru-RU.rc, lang/uk-UA.rc
Modified:
branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp
branches/GSoC_2017/rapps/reactos/base/applications/rapps/lang/en-US.rc
branches/GSoC_2017/rapps/reactos/base/applications/rapps/lang/ru-RU.rc
branches/GSoC_2017/rapps/reactos/base/applications/rapps/lang/uk-UA.rc
branches/GSoC_2017/rapps/reactos/base/applications/rapps/misc.cpp
branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.h
branches/GSoC_2017/rapps/reactos/base/applications/rapps/resource.h
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp [iso-8859-1]
Thu Jun 29 14:17:16 2017
@@ -87,27 +87,59 @@
ShowAvailableAppInfo(INT Index)
{
PAPPLICATION_INFO Info = (PAPPLICATION_INFO) ListViewGetlParam(Index);
- BOOL bIsInstalled = _AppInstallCheck(Info);
- WCHAR szVersion[MAX_PATH];
+ WCHAR szVersion[MAX_PATH] = L"\0";
+ WCHAR szLicense[MAX_PATH] = L"\0";
+ BOOL bIsInstalled = _AppInstallCheck(Info),
+ bHasVersion = _GetInstalledVersion(Info, szVersion, _countof(szVersion));
if (!Info) return FALSE;
NewRichEditText(Info->szName, CFE_BOLD);
+ //installed status
if (bIsInstalled)
{
- _AddTextNewl(IDS_STATUS_INSTALLED, CFE_ITALIC);
- if (_GetInstalledVersion(Info, szVersion, _countof(szVersion)))
+ if (bHasVersion)
{
+ if (CompareVersionsStrings(Info->szVersion, szVersion))
+ _AddTextNewl(IDS_STATUS_UPDATE_AVAILABLE, CFE_ITALIC);
+ else
+ _AddTextNewl(IDS_STATUS_INSTALLED, CFE_ITALIC);
+
_AddText(IDS_AINFO_VERSION, szVersion, CFE_BOLD, 0);
- }
+ }
+ else
+ _AddTextNewl(IDS_STATUS_INSTALLED, CFE_ITALIC);
+
}
else
- {
_AddTextNewl(IDS_STATUS_NOTINSTALLED, CFE_ITALIC);
- }
+
_AddText(IDS_AINFO_AVAILABLEVERSION, Info->szVersion, CFE_BOLD, 0);
- _AddText(IDS_AINFO_LICENSE, Info->szLicense, CFE_BOLD, 0);
+ //license
+ switch (Info->LicenseType)
+ {
+ case LICENSE_TYPE::OpenSource:
+ LoadStringW(hInst, IDS_LICENSE_OPENSOURCE, szLicense, _countof(szLicense));
+ break;
+ case LICENSE_TYPE::Freeware:
+ LoadStringW(hInst, IDS_LICENSE_FREEWARE, szLicense, _countof(szLicense));
+ break;
+ case LICENSE_TYPE::Trial:
+ LoadStringW(hInst, IDS_LICENSE_TRIAL, szLicense, _countof(szLicense));
+ break;
+ default:
+ break;
+ }
+ if (szLicense[0] != '\0')
+ {
+ StringCbPrintfW(szLicense, _countof(szLicense), L"%ls (%ls)",
szLicense, Info->szLicense);
+ _AddText(IDS_AINFO_LICENSE, szLicense, CFE_BOLD, 0);
+ }
+ else
+ {
+ _AddText(IDS_AINFO_LICENSE, Info->szLicense, CFE_BOLD, 0);
+ }
_AddText(IDS_AINFO_SIZE, Info->szSize, CFE_BOLD, 0);
_AddText(IDS_AINFO_URLSITE, Info->szUrlSite, CFE_BOLD, CFE_LINK);
_AddText(IDS_AINFO_DESCRIPTION, Info->szDesc, CFE_BOLD, 0);
@@ -297,6 +329,11 @@
break;
Info->Category = ParserGetInt(L"Category", FindFileData.cFileName);
+ INT IntBuffer = ParserGetInt(L"LicenseType", FindFileData.cFileName);
+ if (IntBuffer < LICENSE_TYPE::Max)
+ {
+ Info->LicenseType = (LICENSE_TYPE) IntBuffer;
+ }
/* copy the cache-related fields for the next time */
RtlCopyMemory(&Info->cFileName, &FindFileData.cFileName, MAX_PATH);
@@ -331,6 +368,7 @@
_GetStringNullFailure(L"Size", Info->szSize,
FindFileData.cFileName);
_GetStringNullFailure(L"URLSite", Info->szUrlSite,
FindFileData.cFileName);
_GetStringNullFailure(L"CDPath", Info->szCDPath,
FindFileData.cFileName);
+ _GetStringNullFailure(L"Language", Info->szRegName,
FindFileData.cFileName);
_GetStringNullFailure(L"SHA1", Info->szSHA1,
FindFileData.cFileName);
}
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/lang/en-US.rc
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/lang/en-US.rc [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/lang/en-US.rc [iso-8859-1]
Thu Jun 29 14:17:16 2017
@@ -217,3 +217,10 @@
IDS_STATUS_DOWNLOADING "Downloadingâ¦"
IDS_STATUS_INSTALLING "Installingâ¦"
END
+
+STRINGTABLE
+BEGIN
+ IDS_LICENSE_OPENSOURCE "Open Source"
+ IDS_LICENSE_FREEWARE "Freeware"
+ IDS_LICENSE_TRIAL "Trial/Demo"
+END
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/lang/ru-RU.rc
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/lang/ru-RU.rc [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/lang/ru-RU.rc [iso-8859-1]
Thu Jun 29 14:17:16 2017
@@ -216,4 +216,11 @@
IDS_STATUS_UPDATE_AVAILABLE "ÐÑÑÑ Ð¾Ð±Ð½Ð¾Ð²Ð»ÐµÐ½Ð¸Ñ"
IDS_STATUS_DOWNLOADING "ÐагÑÑжаеÑÑÑâ¦"
IDS_STATUS_INSTALLING "УÑÑановкаâ¦"
+END
+
+STRINGTABLE
+BEGIN
+ IDS_LICENSE_OPENSOURCE "Свободное ÐÐ"
+ IDS_LICENSE_FREEWARE "ÐеÑплаÑное ÐÐ"
+ IDS_LICENSE_TRIAL "ÐÑÐ¾Ð±Ð½Ð°Ñ Ð²ÐµÑÑиÑ"
END
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/lang/uk-UA.rc
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/lang/uk-UA.rc [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/lang/uk-UA.rc [iso-8859-1]
Thu Jun 29 14:17:16 2017
@@ -215,3 +215,20 @@
IDS_INTERRUPTED_DOWNLOAD "The download was interrupted. Check connection to
Internet."
IDS_UNABLE_TO_WRITE "Unable to write to disk. Disk may be at capacity."
END
+
+STRINGTABLE
+BEGIN
+ IDS_STATUS_INSTALLED "ÐÑÑановлено"
+ IDS_STATUS_NOTINSTALLED "Ðе вÑÑановлено"
+ IDS_STATUS_DOWNLOADED "ÐаванÑажено"
+ IDS_STATUS_UPDATE_AVAILABLE "РоновленнÑ"
+ IDS_STATUS_DOWNLOADING "ÐаванÑажÑÑÑÑÑÑâ¦"
+ IDS_STATUS_INSTALLING "ÐÑÑановлÑÑÑÑÑÑâ¦"
+END
+
+STRINGTABLE
+BEGIN
+ IDS_LICENSE_OPENSOURCE "ÐÑлÑне ÐÐ"
+ IDS_LICENSE_FREEWARE "ÐезкоÑÑовне ÐÐ"
+ IDS_LICENSE_TRIAL "ÐÑобна веÑÑÑÑ"
+END
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/misc.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/misc.cpp [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/misc.cpp [iso-8859-1] Thu Jun
29 14:17:16 2017
@@ -19,6 +19,8 @@
WCHAR szCachedINISectionLocale[MAX_PATH] = L"Section.";
WCHAR szCachedINISectionLocaleNeutral[MAX_PATH] = {0};
BYTE bCachedSectionStatus = FALSE;
+
+#define STR_VERSION_CURRENT L"CURRENT"
typedef struct
{
@@ -500,39 +502,58 @@
return (UINT)Result;
}
-//Parses version string that can be formatted as 1.2.3.4-5
+template<typename XCHAR>
+inline BOOL IsCharNumeric(XCHAR ch)
+{
+ return IsCharAlphaNumeric(ch) && !IsCharAlpha(ch);
+}
+
+
+//Parses version string that can be formatted as 1.2.3-4b (or CURRENT)
//Returns int buffer and it's size
BOOL
-ParseVersion(_In_z_ LPCWSTR szVersion, _Outptr_ INT* parrVersion, _Out_opt_ UINT
iVersionSize)
-{
- ATL::CSimpleArray<int> arrVersionResult;
+ParseVersion(_In_z_ LPCWSTR szVersion, _Outptr_ PVERSION_INFO Version)
+{
ATL::CStringW szVersionSingleInt = L"";
- ATL::CStringW sDelimiters = L".-";
BOOL bHasParsed = TRUE;
- INT iVersionCharCount = 0;
- //INT iVersionSingleCharCount = 0;
- INT iIntResult;
- iVersionSize = 0;
- while(szVersion[iVersionCharCount] != L'\0')
- {
- for (;!sDelimiters.Find(szVersion[iVersionCharCount]); ++iVersionCharCount)
+ INT VersionCharCount = 0;
+ INT VersionLength = lstrlenW(szVersion);
+ StringCbCopyW(Version->szVersion, VersionLength * sizeof(szVersion), szVersion);
+ //CURRENT
+ if (!StrCmpW(szVersion, STR_VERSION_CURRENT))
+ {
+ Version->VersionSize = NULL;
+ return bHasParsed;
+ }
+
+ Version->VersionSize = 0;
+ //int expected every iteration, quit the loop if its not a number
+ while (Version->VersionSize < MAX_VERSION
+ && IsCharNumeric(szVersion[VersionCharCount])
+ && VersionCharCount < VersionLength)
+ {
+ for (; IsCharNumeric(szVersion[VersionCharCount]) && VersionCharCount
< VersionLength; ++VersionCharCount)
{
- szVersionSingleInt += szVersion[iVersionCharCount];
+ szVersionSingleInt += szVersion[VersionCharCount];
}
- szVersionSingleInt += L'\0';
- iIntResult = StrToIntW(szVersionSingleInt.GetBuffer());
- if (iIntResult)
- {
- arrVersionResult.Add(iIntResult);
- iVersionSize++;
- }
- else
+ if (szVersionSingleInt.IsEmpty())
{
bHasParsed = FALSE;
+ continue;
}
- ++iVersionCharCount;
- }
- parrVersion = arrVersionResult.GetData();
+ INT IntResult = StrToIntW(szVersionSingleInt.GetBuffer());
+ Version->arrVersion[Version->VersionSize] = IntResult;
+ ++Version->VersionSize;
+ szVersionSingleInt.Empty();
+ ++VersionCharCount;
+ }
+
+ if (IsCharAlphaW(szVersion[VersionCharCount]))
+ {
+ Version->cVersionSuffix = szVersion[VersionCharCount];
+ }
+ else
+ Version->cVersionSuffix = NULL;
return bHasParsed;
}
@@ -540,27 +561,54 @@
//In: Zero terminated strings of versions
//Out: TRUE if first is bigger than second, FALSE if else
BOOL
-CompareVersionsBigger(_In_z_ LPCWSTR sczVersion1, _In_z_ LPCWSTR sczVersion2, _Out_ BOOL
bResult)
-{
- UINT iVersionSize1 = 0;
- UINT iVersionSize2 = 0;
- INT *parrVersion1 = NULL, *parrVersion2 = NULL;
- bResult = FALSE;
-
- if (!ParseVersion(sczVersion1, parrVersion1, iVersionSize1)
- || !ParseVersion(sczVersion2, parrVersion2, iVersionSize2))
- {
- return FALSE;
- }
-
- for (INT i = 0; i < iVersionSize1 && i < iVersionSize2; ++i)
- {
- if (parrVersion1[i] > parrVersion2[i])
+CompareVersionsStrings(_In_z_ LPCWSTR sczVersionLeft, _In_z_ LPCWSTR sczVersionRight)
+{
+ VERSION_INFO LeftVersion, RightVersion;
+
+ if (!ParseVersion(sczVersionLeft, &LeftVersion)
+ || !ParseVersion(sczVersionRight, &RightVersion))
+ {
+ return FALSE;
+ }
+
+ return CompareVersions(&LeftVersion, &RightVersion);
+}
+
+BOOL
+CompareVersions(_In_ PVERSION_INFO LeftVersion, _In_ PVERSION_INFO RightVersion)
+{
+ //CURRENT
+ if (!LeftVersion->VersionSize || !RightVersion->VersionSize)
+ {
+ return FALSE;
+ }
+ //1.2.3 > 1.2
+ INT SizeDiff = LeftVersion->VersionSize - RightVersion->VersionSize;
+ if (SizeDiff > 0)
+ {
+ return TRUE;
+ }
+ if (SizeDiff < 0)
+ {
+ return FALSE;
+ }
+ //2.0.0 > 1.9.9
+ for (INT i = 0; i < LeftVersion->VersionSize && i <
RightVersion->VersionSize && i < MAX_VERSION; ++i)
+ {
+ if (LeftVersion->arrVersion[i] > RightVersion->arrVersion[i])
{
- bResult = TRUE;
return TRUE;
}
- }
-
- return TRUE;
+ if (LeftVersion->arrVersion[i] < RightVersion->arrVersion[i])
+ {
+ return FALSE;
+ }
+ }
+ //1.2.3b > 1.2.3
+ if (LeftVersion->cVersionSuffix > RightVersion->cVersionSuffix)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
}
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.h [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.h [iso-8859-1] Thu Jun
29 14:17:16 2017
@@ -39,7 +39,7 @@
#define SPLIT_WIDTH 4
#define MAX_STR_LEN 256
-
+#define MAX_VERSION 10
#define LISTVIEW_ICON_SIZE 24
#define TREEVIEW_ICON_SIZE 24
@@ -73,14 +73,24 @@
#define IS_INSTALLED_ENUM(a) (a >= ENUM_INSTALLED_MIN && a <=
ENUM_INSTALLED_MAX)
#define IS_AVAILABLE_ENUM(a) (a >= ENUM_AVAILABLE_MIN && a <=
ENUM_AVAILABLE_MAX)
-
-/* aboutdlg.c */
+typedef enum
+{
+ None,
+ OpenSource,
+ Freeware,
+ Trial,
+ Max = Trial,
+ Min = None
+} LICENSE_TYPE, *PLICENSE_TYPE;
+
+/* aboutdlg.cpp */
VOID ShowAboutDialog(VOID);
-/* available.c */
+/* available.cpp */
typedef struct
{
INT Category;
+ LICENSE_TYPE LicenseType;
WCHAR szName[MAX_PATH];
WCHAR szRegName[MAX_PATH];
WCHAR szVersion[MAX_PATH];
@@ -90,6 +100,7 @@
WCHAR szUrlSite[MAX_PATH];
WCHAR szUrlDownload[MAX_PATH];
WCHAR szCDPath[MAX_PATH];
+ WCHAR szLanguages[MAX_PATH];
/* caching mechanism related entries */
WCHAR cFileName[MAX_PATH];
@@ -129,17 +140,26 @@
} SETTINGS_INFO, *PSETTINGS_INFO;
-/* available.c */
+typedef struct
+{
+ INT arrVersion[MAX_VERSION];
+ UINT VersionSize;
+ WCHAR cVersionSuffix = (WCHAR) NULL;
+ WCHAR szVersion[MAX_PATH];
+} VERSION_INFO, *PVERSION_INFO;
+
+/* available.cpp */
typedef BOOL (CALLBACK *AVAILENUMPROC)(PAPPLICATION_INFO Info);
BOOL EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc);
BOOL ShowAvailableAppInfo(INT Index);
BOOL UpdateAppsDB(VOID);
VOID FreeCachedAvailableEntries(VOID);
-/* installdlg.c */
+
+/* installdlg.cpp */
BOOL InstallApplication(INT Index);
-/* installed.c */
+/* installed.cpp */
typedef BOOL (CALLBACK *APPENUMPROC)(INT ItemIndex, LPWSTR lpName, PINSTALLED_INFO
Info);
BOOL EnumInstalledApplications(INT EnumType, BOOL IsUserKey, APPENUMPROC lpEnumProc);
BOOL GetApplicationString(HKEY hKey, LPCWSTR lpKeyName, LPWSTR lpString);
@@ -150,7 +170,7 @@
BOOL InstalledVersion(LPWSTR szVersionResult, UINT iVersionResultSize, LPCWSTR lpRegName,
BOOL IsUserKey, REGSAM keyWow);
-/* winmain.c */
+/* winmain.cpp */
extern HWND hMainWnd;
extern HINSTANCE hInst;
extern INT SelectedEnumType;
@@ -158,11 +178,11 @@
VOID SaveSettings(HWND hwnd);
VOID FillDefaultSettings(PSETTINGS_INFO pSettingsInfo);
-/* loaddlg.c */
+/* loaddlg.cpp */
BOOL DownloadApplication(INT Index);
VOID DownloadApplicationsDB(LPCWSTR lpUrl);
-/* misc.c */
+/* misc.cpp */
INT GetSystemColorDepth(VOID);
int GetWindowWidth(HWND hwnd);
int GetWindowHeight(HWND hwnd);
@@ -181,11 +201,11 @@
UINT ParserGetString(LPCWSTR lpKeyName, LPWSTR lpReturnedString, UINT nSize, LPCWSTR
lpFileName);
UINT ParserGetInt(LPCWSTR lpKeyName, LPCWSTR lpFileName);
-BOOL ParseVersion(_In_z_ LPCWSTR szVersion, _Outptr_ INT* parrVersion, _Out_opt_ UINT
iVersionSize);
-BOOL FindRegistryKeyByName(_In_ HKEY hKeyBase, _In_ REGSAM keyWow, _In_ LPCWSTR lpcKey,
_Out_opt_ PHKEY hKeyResult);
-BOOL CompareVersionsBigger(_In_z_ LPCWSTR sczVersion1, _In_z_ LPCWSTR sczVersion2, _Out_
BOOL bResult = FALSE);
-
-/* settingsdlg.c */
+BOOL ParseVersion(_In_z_ LPCWSTR szVersion, _Outptr_ PVERSION_INFO parrVersion);
+BOOL CompareVersionsStrings(_In_z_ LPCWSTR sczVersionLeft, _In_z_ LPCWSTR
sczVersionRight);
+BOOL CompareVersions(_In_ PVERSION_INFO LeftVersion, _In_ PVERSION_INFO RightVersion);
+
+/* settingsdlg.cpp */
VOID CreateSettingsDlg(HWND hwnd);
/* gui.cpp */
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/resource.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/resource.h [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/resource.h [iso-8859-1] Thu
Jun 29 14:17:16 2017
@@ -172,6 +172,10 @@
#define IDS_STATUS_DOWNLOADING 804
#define IDS_STATUS_INSTALLING 805
+/* App license names */
+#define IDS_LICENSE_OPENSOURCE 900
+#define IDS_LICENSE_FREEWARE 901
+#define IDS_LICENSE_TRIAL 902
/* Accelerators */
#define HOTKEYS 715