mirror of
https://github.com/reactos/reactos.git
synced 2025-06-04 08:50:27 +00:00
[RAPPS]
- Added /SETUP key support TODO: use the short names from db files - Some style changes - Conditional creation of the dialogs svn path=/branches/GSoC_2017/rapps/; revision=75542
This commit is contained in:
parent
9293dbee23
commit
69d1dbb371
7 changed files with 131 additions and 79 deletions
|
@ -292,12 +292,13 @@ BOOL CAvailableApps::EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnu
|
|||
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,8 +349,8 @@ skip_if_cached:
|
|||
|
||||
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);
|
||||
|
||||
|
@ -357,6 +358,27 @@ skip_if_cached:
|
|||
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()
|
||||
{
|
||||
return m_szPath;
|
||||
|
|
|
@ -1053,7 +1053,7 @@ private:
|
|||
{
|
||||
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 @@ private:
|
|||
{
|
||||
if (IS_INSTALLED_ENUM(SelectedEnumType))
|
||||
ShowInstalledAppInfo(-1);
|
||||
if (IS_AVAILABLE_ENUM(SelectedEnumType))
|
||||
if (isAvailableEnum(SelectedEnumType))
|
||||
CAvailableAppView::ShowAvailableAppInfo(-1);
|
||||
}
|
||||
}
|
||||
|
@ -1463,7 +1463,9 @@ private:
|
|||
if (EnumType < 0) EnumType = SelectedEnumType;
|
||||
|
||||
if (IS_INSTALLED_ENUM(SelectedEnumType))
|
||||
{
|
||||
FreeInstalledAppList();
|
||||
}
|
||||
|
||||
m_ListView->DeleteAllItems();
|
||||
|
||||
|
@ -1478,21 +1480,21 @@ private:
|
|||
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);
|
||||
|
|
|
@ -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 @@ typedef enum
|
|||
Trial,
|
||||
Max = Trial,
|
||||
Min = None
|
||||
} LICENSE_TYPE, *PLICENSE_TYPE;
|
||||
} *PLICENSE_TYPE;
|
||||
|
||||
class CConfigParser
|
||||
{
|
||||
|
@ -62,7 +67,7 @@ public:
|
|||
UINT GetInt(const ATL::CStringW& KeyName);
|
||||
};
|
||||
|
||||
typedef struct
|
||||
typedef struct APPLICATION_INFO
|
||||
{
|
||||
INT Category;
|
||||
LICENSE_TYPE LicenseType;
|
||||
|
@ -84,9 +89,7 @@ typedef struct
|
|||
// 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 @@ private:
|
|||
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 @@ public:
|
|||
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();
|
||||
|
|
|
@ -26,9 +26,9 @@ public:
|
|||
|
||||
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)
|
||||
|
|
|
@ -42,7 +42,7 @@ InstallDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|||
BOOL
|
||||
InstallApplication(INT Index)
|
||||
{
|
||||
if (!IS_AVAILABLE_ENUM(SelectedEnumType))
|
||||
if (!isAvailableEnum(SelectedEnumType))
|
||||
return FALSE;
|
||||
|
||||
AppInfo = (PAPPLICATION_INFO) ListViewGetlParam(Index);
|
||||
|
|
|
@ -401,7 +401,7 @@ INT_PTR CALLBACK CDownloadManager::DownloadDlgProc(HWND Dlg, UINT uMsg, WPARAM w
|
|||
|
||||
ShowWindow(Dlg, SW_SHOW);
|
||||
|
||||
//Start new download
|
||||
// Start new download
|
||||
SendMessageW(Dlg, DL_START_NEW, 0, 0);
|
||||
|
||||
return TRUE;
|
||||
|
@ -804,12 +804,12 @@ BOOL CDownloadManager::DownloadListOfApplications(const ATL::CSimpleArray<PAPPLI
|
|||
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 @@ BOOL CDownloadManager::DownloadApplication(PAPPLICATION_INFO pAppInfo)
|
|||
|
||||
AppsToInstallList.RemoveAll();
|
||||
AppsToInstallList.Add(pAppInfo);
|
||||
LaunchDownloadDialog();
|
||||
LaunchDownloadDialog(modal);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -832,11 +832,22 @@ VOID CDownloadManager::DownloadApplicationsDB(LPCWSTR lpUrl)
|
|||
}
|
||||
|
||||
//TODO: Reuse the dialog
|
||||
VOID CDownloadManager::LaunchDownloadDialog()
|
||||
VOID CDownloadManager::LaunchDownloadDialog(BOOL modal)
|
||||
{
|
||||
CreateDialogW(hInst,
|
||||
MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG),
|
||||
hMainWnd,
|
||||
DownloadDlgProc);
|
||||
if (modal)
|
||||
{
|
||||
DialogBoxW(hInst,
|
||||
MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG),
|
||||
hMainWnd,
|
||||
DownloadDlgProc);
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateDialogW(hInst,
|
||||
MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG),
|
||||
hMainWnd,
|
||||
DownloadDlgProc);
|
||||
}
|
||||
|
||||
}
|
||||
// CDownloadManager
|
||||
|
|
|
@ -72,7 +72,7 @@ VOID FillDefaultSettings(PSETTINGS_INFO pSettingsInfo)
|
|||
}
|
||||
|
||||
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 @@ VOID SaveSettings(HWND hwnd)
|
|||
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 @@ VOID SaveSettings(HWND hwnd)
|
|||
}
|
||||
|
||||
|
||||
#define CMD_KEY_SETUP L"//SETUP"
|
||||
#define CMD_KEY_SETUP L"/SETUP"
|
||||
|
||||
VOID CmdParser(LPWSTR lpCmdLine)
|
||||
// return TRUE if the SETUP key was valid
|
||||
BOOL CmdParser(LPWSTR lpCmdLine)
|
||||
{
|
||||
INT argc;
|
||||
LPWSTR* argv = CommandLineToArgvW(lpCmdLine, &argc);
|
||||
if (!argv || argc < 2)
|
||||
CAvailableApps apps;
|
||||
PAPPLICATION_INFO appInfo;
|
||||
ATL::CString szName;
|
||||
|
||||
if (!argv || argc < 2 || StrCmpW(argv[0], CMD_KEY_SETUP))
|
||||
{
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!StrCmpW(argv[0], CMD_KEY_SETUP))
|
||||
|
||||
apps.EnumAvailableApplications(ENUM_ALL_AVAILABLE, NULL);
|
||||
appInfo = apps.FindInfo(argv[1]);
|
||||
if (appInfo)
|
||||
{
|
||||
//TODO: call cmd app installation
|
||||
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 @@ INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi
|
|||
|
||||
InitCommonControls();
|
||||
|
||||
hMainWnd = CreateMainWindow();
|
||||
if (hMainWnd)
|
||||
//skip window creation if there were some keys
|
||||
if (!CmdParser(lpCmdLine))
|
||||
{
|
||||
/* 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))
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue