Author: ashaposhnikov
Date: Mon Aug 14 17:00:20 2017
New Revision: 75542
URL:
http://svn.reactos.org/svn/reactos?rev=75542&view=rev
Log:
[RAPPS]
- Added /SETUP key support
TODO: use the short names from db files
- Some style changes
- Conditional creation of the dialogs
Modified:
branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp
branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp
branches/GSoC_2017/rapps/reactos/base/applications/rapps/include/available.h
branches/GSoC_2017/rapps/reactos/base/applications/rapps/include/dialogs.h
branches/GSoC_2017/rapps/reactos/base/applications/rapps/installdlg.cpp
branches/GSoC_2017/rapps/reactos/base/applications/rapps/loaddlg.cpp
branches/GSoC_2017/rapps/reactos/base/applications/rapps/winmain.cpp
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]
Mon Aug 14 17:00:20 2017
@@ -292,12 +292,13 @@
CDownloadManager::DownloadApplicationsDB(APPLICATION_DATABASE_URL);
}
-
ExtractFilesFromCab(m_szCabPath, m_szAppsPath);
hFind = FindFirstFileW(m_szSearchPath.GetString(), &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
+ {
return FALSE;
+ }
}
do
@@ -348,13 +349,34 @@
Info->RefreshAppInfo();
- if (!lpEnumProc(static_cast<PAPPLICATION_INFO>(Info),
m_szAppsPath.GetString()))
- break;
+ if (lpEnumProc)
+ lpEnumProc(static_cast<PAPPLICATION_INFO>(Info),
m_szAppsPath.GetString());
} while (FindNextFileW(hFind, &FindFileData) != 0);
FindClose(hFind);
return TRUE;
+}
+
+const PAPPLICATION_INFO CAvailableApps::FindInfo(const ATL::CStringW& szAppName)
+{
+ if (m_InfoList.IsEmpty())
+ {
+ return NULL;
+ }
+
+ // linear search
+ POSITION CurrentListPosition = m_InfoList.GetHeadPosition();
+ PAPPLICATION_INFO info;
+ while (CurrentListPosition != NULL)
+ {
+ info = m_InfoList.GetNext(CurrentListPosition);
+ if (info->szName == szAppName)
+ {
+ return info;
+ }
+ }
+ return NULL;
}
const ATL::CStringW & CAvailableApps::GetFolderPath()
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp [iso-8859-1] Mon Aug
14 17:00:20 2017
@@ -1053,7 +1053,7 @@
{
if (IS_INSTALLED_ENUM(SelectedEnumType))
ShowInstalledAppInfo(ItemIndex);
- if (IS_AVAILABLE_ENUM(SelectedEnumType))
+ if (isAvailableEnum(SelectedEnumType))
CAvailableAppView::ShowAvailableAppInfo(ItemIndex);
}
/* Check if the item is checked */
@@ -1081,7 +1081,7 @@
{
if (IS_INSTALLED_ENUM(SelectedEnumType))
ShowInstalledAppInfo(-1);
- if (IS_AVAILABLE_ENUM(SelectedEnumType))
+ if (isAvailableEnum(SelectedEnumType))
CAvailableAppView::ShowAvailableAppInfo(-1);
}
}
@@ -1463,7 +1463,9 @@
if (EnumType < 0) EnumType = SelectedEnumType;
if (IS_INSTALLED_ENUM(SelectedEnumType))
+ {
FreeInstalledAppList();
+ }
m_ListView->DeleteAllItems();
@@ -1478,21 +1480,21 @@
ImageList_Destroy(hImageListBuf);
}
- if (IS_AVAILABLE_ENUM(EnumType))
+ if (isAvailableEnum(EnumType))
{
/* Enum available applications */
m_AvailableApps.EnumAvailableApplications(EnumType, s_EnumAvailableAppProc);
}
SelectedEnumType = EnumType;
-
UpdateStatusBarText();
-
SetWelcomeText();
- /* set automatic column width for program names if the list is not empty */
+ /* Set automatic column width for program names if the list is not empty */
if (m_ListView->GetItemCount() > 0)
+ {
ListView_SetColumnWidth(m_ListView->GetWindow(), 0, LVSCW_AUTOSIZE);
+ }
bUpdating = FALSE;
m_ListView->SetRedraw(TRUE);
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/include/available.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
---
branches/GSoC_2017/rapps/reactos/base/applications/rapps/include/available.h [iso-8859-1]
(original)
+++
branches/GSoC_2017/rapps/reactos/base/applications/rapps/include/available.h [iso-8859-1]
Mon Aug 14 17:00:20 2017
@@ -5,29 +5,34 @@
#include <atlcoll.h>
/* EnumType flags for EnumAvailableApplications */
-#define ENUM_ALL_AVAILABLE 0
-#define ENUM_CAT_AUDIO 1
-#define ENUM_CAT_VIDEO 2
-#define ENUM_CAT_GRAPHICS 3
-#define ENUM_CAT_GAMES 4
-#define ENUM_CAT_INTERNET 5
-#define ENUM_CAT_OFFICE 6
-#define ENUM_CAT_DEVEL 7
-#define ENUM_CAT_EDU 8
-#define ENUM_CAT_ENGINEER 9
-#define ENUM_CAT_FINANCE 10
-#define ENUM_CAT_SCIENCE 11
-#define ENUM_CAT_TOOLS 12
-#define ENUM_CAT_DRIVERS 13
-#define ENUM_CAT_LIBS 14
-#define ENUM_CAT_OTHER 15
+enum AvailableCategories
+{
+ ENUM_ALL_AVAILABLE,
+ ENUM_CAT_AUDIO,
+ ENUM_CAT_VIDEO,
+ ENUM_CAT_GRAPHICS,
+ ENUM_CAT_GAMES,
+ ENUM_CAT_INTERNET,
+ ENUM_CAT_OFFICE,
+ ENUM_CAT_DEVEL,
+ ENUM_CAT_EDU,
+ ENUM_CAT_ENGINEER,
+ ENUM_CAT_FINANCE,
+ ENUM_CAT_SCIENCE,
+ ENUM_CAT_TOOLS,
+ ENUM_CAT_DRIVERS,
+ ENUM_CAT_LIBS,
+ ENUM_CAT_OTHER,
+ ENUM_AVAILABLE_MIN = ENUM_ALL_AVAILABLE,
+ ENUM_AVAILABLE_MAX = ENUM_CAT_OTHER
+};
-#define ENUM_AVAILABLE_MIN ENUM_ALL_AVAILABLE
-#define ENUM_AVAILABLE_MAX ENUM_CAT_OTHER
+inline BOOL isAvailableEnum(INT x)
+{
+ return (x >= ENUM_AVAILABLE_MIN && x <= ENUM_AVAILABLE_MAX);
+}
-#define IS_AVAILABLE_ENUM(a) (a >= ENUM_AVAILABLE_MIN && a <=
ENUM_AVAILABLE_MAX)
-
-typedef enum
+typedef enum LICENSE_TYPE
{
None,
OpenSource,
@@ -35,7 +40,7 @@
Trial,
Max = Trial,
Min = None
-} LICENSE_TYPE, *PLICENSE_TYPE;
+} *PLICENSE_TYPE;
class CConfigParser
{
@@ -62,7 +67,7 @@
UINT GetInt(const ATL::CStringW& KeyName);
};
-typedef struct
+typedef struct APPLICATION_INFO
{
INT Category;
LICENSE_TYPE LicenseType;
@@ -84,9 +89,7 @@
// Optional integrity checks (SHA-1 digests are 160 bit = 40 characters in hex string
form)
ATL::CStringW szSHA1;
-} APPLICATION_INFO, *PAPPLICATION_INFO;
-
-extern ATL::CAtlList<PAPPLICATION_INFO> InfoList;
+} *PAPPLICATION_INFO;
typedef BOOL(CALLBACK *AVAILENUMPROC)(PAPPLICATION_INFO Info, LPCWSTR szFolderPath);
@@ -113,8 +116,7 @@
BOOL m_HasInstalledVersion = FALSE;
CConfigParser m_Parser;
- inline BOOL GetString(LPCWSTR lpKeyName,
- ATL::CStringW& ReturnedString);
+ inline BOOL GetString(LPCWSTR lpKeyName, ATL::CStringW& ReturnedString);
// Lazily load general info from the file
VOID RetrieveGeneralInfo();
@@ -139,6 +141,7 @@
BOOL DeleteCurrentAppsDB();
BOOL UpdateAppsDB();
BOOL EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc);
+ const PAPPLICATION_INFO FindInfo(const ATL::CStringW& szAppName);
const ATL::CStringW& GetFolderPath();
const ATL::CStringW& GetAppPath();
const ATL::CStringW& GetCabPath();
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/include/dialogs.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
---
branches/GSoC_2017/rapps/reactos/base/applications/rapps/include/dialogs.h [iso-8859-1]
(original)
+++
branches/GSoC_2017/rapps/reactos/base/applications/rapps/include/dialogs.h [iso-8859-1]
Mon Aug 14 17:00:20 2017
@@ -26,9 +26,9 @@
static DWORD WINAPI ThreadFunc(LPVOID Context);
static BOOL DownloadListOfApplications(const
ATL::CSimpleArray<PAPPLICATION_INFO>& AppsList);
- static BOOL DownloadApplication(PAPPLICATION_INFO pAppInfo);
+ static BOOL DownloadApplication(PAPPLICATION_INFO pAppInfo, BOOL modal = FALSE);
static VOID DownloadApplicationsDB(LPCWSTR lpUrl);
- static VOID LaunchDownloadDialog();
+ static VOID LaunchDownloadDialog(BOOL);
};
// Settings dialog (settingsdlg.cpp)
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/installdlg.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/installdlg.cpp [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/installdlg.cpp [iso-8859-1]
Mon Aug 14 17:00:20 2017
@@ -42,7 +42,7 @@
BOOL
InstallApplication(INT Index)
{
- if (!IS_AVAILABLE_ENUM(SelectedEnumType))
+ if (!isAvailableEnum(SelectedEnumType))
return FALSE;
AppInfo = (PAPPLICATION_INFO) ListViewGetlParam(Index);
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/loaddlg.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/loaddlg.cpp [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/loaddlg.cpp [iso-8859-1] Mon
Aug 14 17:00:20 2017
@@ -401,7 +401,7 @@
ShowWindow(Dlg, SW_SHOW);
- //Start new download
+ // Start new download
SendMessageW(Dlg, DL_START_NEW, 0, 0);
return TRUE;
@@ -804,12 +804,12 @@
AppsToInstallList = AppsList;
// Create a dialog and issue a download process
- LaunchDownloadDialog();
+ LaunchDownloadDialog(FALSE);
return TRUE;
}
-BOOL CDownloadManager::DownloadApplication(PAPPLICATION_INFO pAppInfo)
+BOOL CDownloadManager::DownloadApplication(PAPPLICATION_INFO pAppInfo, BOOL modal)
{
if (!pAppInfo)
{
@@ -818,7 +818,7 @@
AppsToInstallList.RemoveAll();
AppsToInstallList.Add(pAppInfo);
- LaunchDownloadDialog();
+ LaunchDownloadDialog(modal);
return TRUE;
}
@@ -832,11 +832,22 @@
}
//TODO: Reuse the dialog
-VOID CDownloadManager::LaunchDownloadDialog()
-{
- CreateDialogW(hInst,
- MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG),
- hMainWnd,
- DownloadDlgProc);
+VOID CDownloadManager::LaunchDownloadDialog(BOOL modal)
+{
+ if (modal)
+ {
+ DialogBoxW(hInst,
+ MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG),
+ hMainWnd,
+ DownloadDlgProc);
+ }
+ else
+ {
+ CreateDialogW(hInst,
+ MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG),
+ hMainWnd,
+ DownloadDlgProc);
+ }
+
}
// CDownloadManager
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/winmain.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/winmain.cpp [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/winmain.cpp [iso-8859-1] Mon
Aug 14 17:00:20 2017
@@ -72,7 +72,7 @@
}
szDownloadDir += L"\\RAPPS Downloads";
- ATL::CStringW::CopyChars(pSettingsInfo->szDownloadDir,
+ ATL::CStringW::CopyChars(pSettingsInfo->szDownloadDir,
_countof(pSettingsInfo->szDownloadDir),
szDownloadDir.GetString(),
szDownloadDir.GetLength() + 1);
@@ -119,13 +119,13 @@
SettingsInfo.Top = wp.rcNormalPosition.top;
SettingsInfo.Width = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
SettingsInfo.Height = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top;
- SettingsInfo.Maximized = (wp.showCmd == SW_MAXIMIZE
- || (wp.showCmd == SW_SHOWMINIMIZED
+ SettingsInfo.Maximized = (wp.showCmd == SW_MAXIMIZE
+ || (wp.showCmd == SW_SHOWMINIMIZED
&& (wp.flags &
WPF_RESTORETOMAXIMIZED)));
}
if (RegKey.Create(HKEY_CURRENT_USER, L"Software\\ReactOS\\rapps", NULL,
- REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, NULL) ==
ERROR_SUCCESS)
+ REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, NULL) == ERROR_SUCCESS)
{
RegKey.SetBinaryValue(L"Settings", (const PVOID) &SettingsInfo,
sizeof(SettingsInfo));
RegKey.Close();
@@ -133,28 +133,38 @@
}
-#define CMD_KEY_SETUP L"//SETUP"
-
-VOID CmdParser(LPWSTR lpCmdLine)
+#define CMD_KEY_SETUP L"/SETUP"
+
+// return TRUE if the SETUP key was valid
+BOOL CmdParser(LPWSTR lpCmdLine)
{
INT argc;
LPWSTR* argv = CommandLineToArgvW(lpCmdLine, &argc);
- if (!argv || argc < 2)
- {
- return;
- }
-
- if (!StrCmpW(argv[0], CMD_KEY_SETUP))
- {
- //TODO: call cmd app installation
- }
+ CAvailableApps apps;
+ PAPPLICATION_INFO appInfo;
+ ATL::CString szName;
+
+ if (!argv || argc < 2 || StrCmpW(argv[0], CMD_KEY_SETUP))
+ {
+ return FALSE;
+ }
+
+ apps.EnumAvailableApplications(ENUM_ALL_AVAILABLE, NULL);
+ appInfo = apps.FindInfo(argv[1]);
+ if (appInfo)
+ {
+ CDownloadManager::DownloadApplication(appInfo, TRUE);
+ return TRUE;
+ }
+
+ return FALSE;
}
INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
nShowCmd)
{
LPCWSTR szWindowClass = L"ROSAPPMGR";
HANDLE hMutex = NULL;
- HACCEL KeyBrd;
+ HACCEL KeyBrd = NULL;
MSG Msg;
InitializeAtlModule(hInstance, TRUE);
@@ -187,27 +197,31 @@
InitCommonControls();
- hMainWnd = CreateMainWindow();
- if (hMainWnd)
- {
- /* Maximize it if we must */
- ShowWindow(hMainWnd, (SettingsInfo.bSaveWndPos && SettingsInfo.Maximized
? SW_MAXIMIZE : nShowCmd));
- UpdateWindow(hMainWnd);
-
- //TODO: get around the ugliness
- if (SettingsInfo.bUpdateAtStart)
- GetAvailableApps()->UpdateAppsDB();
-
- /* Load the menu hotkeys */
- KeyBrd = LoadAcceleratorsW(NULL, MAKEINTRESOURCEW(HOTKEYS));
-
- /* Message Loop */
- while (GetMessageW(&Msg, NULL, 0, 0))
+ //skip window creation if there were some keys
+ if (!CmdParser(lpCmdLine))
+ {
+ hMainWnd = CreateMainWindow();
+ if (hMainWnd)
{
- if (!TranslateAcceleratorW(hMainWnd, KeyBrd, &Msg))
+ /* Maximize it if we must */
+ ShowWindow(hMainWnd, (SettingsInfo.bSaveWndPos &&
SettingsInfo.Maximized ? SW_MAXIMIZE : nShowCmd));
+ UpdateWindow(hMainWnd);
+
+ //TODO: get around the ugliness
+ if (SettingsInfo.bUpdateAtStart)
+ GetAvailableApps()->UpdateAppsDB();
+
+ /* Load the menu hotkeys */
+ KeyBrd = LoadAcceleratorsW(NULL, MAKEINTRESOURCEW(HOTKEYS));
+
+ /* Message Loop */
+ while (GetMessageW(&Msg, NULL, 0, 0))
{
- TranslateMessage(&Msg);
- DispatchMessageW(&Msg);
+ if (!TranslateAcceleratorW(hMainWnd, KeyBrd, &Msg))
+ {
+ TranslateMessage(&Msg);
+ DispatchMessageW(&Msg);
+ }
}
}
}