[RAPPS] Centralize RAPPS exposed names: registry & user local settings (#4214)

Centralize the names of the RAPPS' registry setting sub-key, and
user local settings & offline apps database sub-directories.

- Change the name of the application database sub-directory from
  "rapps\rapps" to "RApps\appdb".

- Adjust the documentation to reflect this.

- Simplify CConfigParser constructor by removing GetINIFullPath().
This commit is contained in:
Hermès Bélusca-Maïto 2021-12-29 01:05:00 +01:00
parent 30bc0b6b7a
commit fefc5f4823
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
9 changed files with 31 additions and 32 deletions

View file

@ -85,16 +85,18 @@ and synced every time RAPPS is launched for the first time.
NOTE: You can find the most current URL in rapps.h, defined as APPLICATION_DATABASE_URL. NOTE: You can find the most current URL in rapps.h, defined as APPLICATION_DATABASE_URL.
To generate a RAPPS database (usually a rappmgr.cab archive), use the included scripts: To generate a RAPPS database (usually a rappmgr.cab/rappmgr2.cab archive), use
the included scripts:
For Windows & other NT-derived: CreateCabFile.bat For Windows & other NT-derived: CreateCabFile.bat
For Linux & other UNIX flavors: CreateCabFile.sh For Linux & other UNIX flavors: CreateCabFile.sh
Once the rappmgr.cab is downloaded to %appdata%\rapps, RAPPS extracts it using cabinet.dll Once the rappmgr.cab is downloaded to the user's local %AppData%\RApps, RAPPS extracts it
inside %appdata%\rapps\rapps, after that, it will parse all the *.txt files contained therein. using cabinet.dll inside %AppData%\RApps\appdb. After that, it will parse all the *.txt
files contained therein.
Every subsequent time the program tries to access the local .txt files Every subsequent time, the program tries to access the local .txt files
until a database update is manually triggered by the user. until a database update is manually triggered by the user.
If the rappmgr.cab file is moved or just missing, RAPPS will download it again. If the rappmgr.cab file is moved or just missing, RAPPS will download it again.

View file

@ -74,7 +74,7 @@ CAppDB::EnumerateFiles()
ClearList(m_Available); ClearList(m_Available);
CPathW AppsPath = m_BasePath; CPathW AppsPath = m_BasePath;
AppsPath += L"rapps"; AppsPath += RAPPS_DATABASE_SUBDIR;
CPathW WildcardPath = AppsPath; CPathW WildcardPath = AppsPath;
WildcardPath += L"*.txt"; WildcardPath += L"*.txt";
@ -95,7 +95,7 @@ CAppDB::EnumerateFiles()
ATLASSERT(Info == NULL); ATLASSERT(Info == NULL);
if (!Info) if (!Info)
{ {
CConfigParser *Parser = new CConfigParser(FindFileData.cFileName); CConfigParser *Parser = new CConfigParser(CPathW(AppsPath) += FindFileData.cFileName);
int Cat; int Cat;
if (!Parser->GetInt(L"Category", Cat)) if (!Parser->GetInt(L"Category", Cat))
Cat = ENUM_INVALID; Cat = ENUM_INVALID;
@ -130,7 +130,7 @@ CAppDB::UpdateAvailable()
SettingsInfo.bUseSource ? SettingsInfo.szSourceURL : APPLICATION_DATABASE_URL, !SettingsInfo.bUseSource); SettingsInfo.bUseSource ? SettingsInfo.szSourceURL : APPLICATION_DATABASE_URL, !SettingsInfo.bUseSource);
CPathW AppsPath = m_BasePath; CPathW AppsPath = m_BasePath;
AppsPath += L"rapps"; AppsPath += RAPPS_DATABASE_SUBDIR;
if (!ExtractFilesFromCab(APPLICATION_DATABASE_NAME, m_BasePath, AppsPath)) if (!ExtractFilesFromCab(APPLICATION_DATABASE_NAME, m_BasePath, AppsPath))
return; return;
@ -243,7 +243,7 @@ CAppDB::RemoveCached()
{ {
// Delete icons // Delete icons
CPathW AppsPath = m_BasePath; CPathW AppsPath = m_BasePath;
AppsPath += L"rapps"; AppsPath += RAPPS_DATABASE_SUBDIR;
CPathW IconPath = AppsPath; CPathW IconPath = AppsPath;
IconPath += L"icons"; IconPath += L"icons";
DeleteWithWildcard(IconPath, L"*.ico"); DeleteWithWildcard(IconPath, L"*.ico");

View file

@ -7,6 +7,7 @@
* Copyright 2017 Alexander Shaposhnikov (sanchaez@reactos.org) * Copyright 2017 Alexander Shaposhnikov (sanchaez@reactos.org)
* Copyright 2021 Mark Jansen <mark.jansen@reactos.org> * Copyright 2021 Mark Jansen <mark.jansen@reactos.org>
*/ */
#include "rapps.h" #include "rapps.h"
#include <debug.h> #include <debug.h>
@ -24,19 +25,7 @@ struct CSectionNames
}; };
static CSectionNames g_Names; static CSectionNames g_Names;
static CStringW CConfigParser::CConfigParser(const CStringW &FilePath) : szConfigPath(FilePath)
GetINIFullPath(const CStringW &FileName)
{
CStringW szDir;
CStringW szBuffer;
GetStorageDirectory(szDir);
szBuffer.Format(L"%ls\\rapps\\%ls", szDir.GetString(), FileName.GetString());
return szBuffer;
}
CConfigParser::CConfigParser(const CStringW &FileName) : szConfigPath(GetINIFullPath(FileName))
{ {
CacheINI(); CacheINI();
} }

View file

@ -13,7 +13,7 @@ class CConfigParser
ReadSection(CStringW &Buffer, const CStringW &Section, BOOL isArch); ReadSection(CStringW &Buffer, const CStringW &Section, BOOL isArch);
public: public:
CConfigParser(const CStringW &FileName); CConfigParser(const CStringW &FilePath);
BOOL BOOL
GetString(const CStringW &KeyName, CStringW &ResultString); GetString(const CStringW &KeyName, CStringW &ResultString);

View file

@ -29,6 +29,15 @@
#include "resource.h" #include "resource.h"
#include "winmain.h" #include "winmain.h"
#define APPLICATION_DATABASE_URL L"https://rapps.reactos.org/rappmgr2.cab" /* Name of the registry sub-key where RAPPS settings are stored, and
#define APPLICATION_DATABASE_NAME L"rappmgr2.cab" * of the local AppData sub-directory where the RAPPS files are stored. */
#define RAPPS_NAME L"RApps"
/* Name of the RAPPS sub-directory where the offline RAPPS database is stored */
#define RAPPS_DATABASE_SUBDIR L"appdb"
/* URL and filename of the online RAPPS database */
#define APPLICATION_DATABASE_URL L"https://rapps.reactos.org/rappmgr2.cab"
#define APPLICATION_DATABASE_NAME L"rappmgr2.cab"
#define MAX_STR_LEN 256 #define MAX_STR_LEN 256

View file

@ -153,7 +153,7 @@ GetStorageDirectory(CStringW &Directory)
BOOL bHasPath = SHGetSpecialFolderPathW(NULL, DirectoryStr, CSIDL_LOCAL_APPDATA, TRUE); BOOL bHasPath = SHGetSpecialFolderPathW(NULL, DirectoryStr, CSIDL_LOCAL_APPDATA, TRUE);
if (bHasPath) if (bHasPath)
{ {
PathAppendW(DirectoryStr, L"rapps"); PathAppendW(DirectoryStr, RAPPS_NAME);
} }
CachedDirectory.ReleaseBuffer(); CachedDirectory.ReleaseBuffer();

View file

@ -218,7 +218,7 @@ BOOL
LoadSettings(PSETTINGS_INFO pSettingsInfo) LoadSettings(PSETTINGS_INFO pSettingsInfo)
{ {
ATL::CRegKey RegKey; ATL::CRegKey RegKey;
if (RegKey.Open(HKEY_CURRENT_USER, L"Software\\ReactOS\\rapps", KEY_READ) != ERROR_SUCCESS) if (RegKey.Open(HKEY_CURRENT_USER, L"Software\\ReactOS\\" RAPPS_NAME, KEY_READ) != ERROR_SUCCESS)
{ {
return FALSE; return FALSE;
} }
@ -245,9 +245,8 @@ SaveSettings(HWND hwnd, PSETTINGS_INFO pSettingsInfo)
(wp.showCmd == SW_MAXIMIZE || (wp.showCmd == SW_SHOWMINIMIZED && (wp.flags & WPF_RESTORETOMAXIMIZED))); (wp.showCmd == SW_MAXIMIZE || (wp.showCmd == SW_SHOWMINIMIZED && (wp.flags & WPF_RESTORETOMAXIMIZED)));
} }
if (RegKey.Create( if (RegKey.Create(HKEY_CURRENT_USER, L"Software\\ReactOS\\" RAPPS_NAME, NULL,
HKEY_CURRENT_USER, L"Software\\ReactOS\\rapps", NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, NULL) != REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, NULL) != ERROR_SUCCESS)
ERROR_SUCCESS)
{ {
return FALSE; return FALSE;
} }

View file

@ -246,7 +246,7 @@ SettingsDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
CStringW szMsgText; CStringW szMsgText;
szMsgText.LoadStringW(IDS_URL_INVALID); szMsgText.LoadStringW(IDS_URL_INVALID);
MessageBoxW(hDlg, szMsgText, NULL, 0); MessageBoxW(hDlg, szMsgText, NULL, MB_OK);
SetFocus(GetDlgItem(hDlg, IDC_SOURCE_URL)); SetFocus(GetDlgItem(hDlg, IDC_SOURCE_URL));
break; break;
} }

View file

@ -241,13 +241,13 @@ ParseCmdAndExecute(LPWSTR lpCmdLine, BOOL bIsFirstLaunch, int nCmdShow)
if (argc == 1) // RAPPS is launched without options if (argc == 1) // RAPPS is launched without options
{ {
// Check for if rapps MainWindow is already launched in another process // Check whether the RAPPS MainWindow is already launched in another process
HANDLE hMutex; HANDLE hMutex;
hMutex = CreateMutexW(NULL, FALSE, szWindowClass); hMutex = CreateMutexW(NULL, FALSE, szWindowClass);
if ((!hMutex) || (GetLastError() == ERROR_ALREADY_EXISTS)) if ((!hMutex) || (GetLastError() == ERROR_ALREADY_EXISTS))
{ {
/* If already started, it is found its window */ /* If already started, find its window */
HWND hWindow = FindWindowW(szWindowClass, NULL); HWND hWindow = FindWindowW(szWindowClass, NULL);
/* Activate window */ /* Activate window */