CDownloadManager::DownloadApplicationsDB(APPLICATION_DATABASE_URL);
}
-
ExtractFilesFromCab(m_szCabPath, m_szAppsPath);
hFind = FindFirstFileW(m_szSearchPath.GetString(), &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
+ {
return FALSE;
+ }
}
do
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);
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;
{
if (IS_INSTALLED_ENUM(SelectedEnumType))
ShowInstalledAppInfo(ItemIndex);
- if (IS_AVAILABLE_ENUM(SelectedEnumType))
+ if (isAvailableEnum(SelectedEnumType))
CAvailableAppView::ShowAvailableAppInfo(ItemIndex);
}
/* Check if the item is checked */
{
if (IS_INSTALLED_ENUM(SelectedEnumType))
ShowInstalledAppInfo(-1);
- if (IS_AVAILABLE_ENUM(SelectedEnumType))
+ if (isAvailableEnum(SelectedEnumType))
CAvailableAppView::ShowAvailableAppInfo(-1);
}
}
if (EnumType < 0) EnumType = SelectedEnumType;
if (IS_INSTALLED_ENUM(SelectedEnumType))
+ {
FreeInstalledAppList();
+ }
m_ListView->DeleteAllItems();
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);
#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
-
-#define ENUM_AVAILABLE_MIN ENUM_ALL_AVAILABLE
-#define ENUM_AVAILABLE_MAX ENUM_CAT_OTHER
-
-#define IS_AVAILABLE_ENUM(a) (a >= ENUM_AVAILABLE_MIN && a <= ENUM_AVAILABLE_MAX)
-
-typedef enum
+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
+};
+
+inline BOOL isAvailableEnum(INT x)
+{
+ return (x >= ENUM_AVAILABLE_MIN && x <= ENUM_AVAILABLE_MAX);
+}
+
+typedef enum LICENSE_TYPE
{
None,
OpenSource,
Trial,
Max = Trial,
Min = None
-} LICENSE_TYPE, *PLICENSE_TYPE;
+} *PLICENSE_TYPE;
class CConfigParser
{
UINT GetInt(const ATL::CStringW& KeyName);
};
-typedef struct
+typedef struct APPLICATION_INFO
{
INT Category;
LICENSE_TYPE LicenseType;
// 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);
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();
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();
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)
BOOL
InstallApplication(INT Index)
{
- if (!IS_AVAILABLE_ENUM(SelectedEnumType))
+ if (!isAvailableEnum(SelectedEnumType))
return FALSE;
AppInfo = (PAPPLICATION_INFO) ListViewGetlParam(Index);
ShowWindow(Dlg, SW_SHOW);
- //Start new download
+ // Start new download
SendMessageW(Dlg, DL_START_NEW, 0, 0);
return TRUE;
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)
{
AppsToInstallList.RemoveAll();
AppsToInstallList.Add(pAppInfo);
- LaunchDownloadDialog();
+ LaunchDownloadDialog(modal);
return TRUE;
}
}
//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
}
szDownloadDir += L"\\RAPPS Downloads";
- ATL::CStringW::CopyChars(pSettingsInfo->szDownloadDir,
+ ATL::CStringW::CopyChars(pSettingsInfo->szDownloadDir,
_countof(pSettingsInfo->szDownloadDir),
szDownloadDir.GetString(),
szDownloadDir.GetLength() + 1);
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();
}
-#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);
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);
+ 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();
+ //TODO: get around the ugliness
+ if (SettingsInfo.bUpdateAtStart)
+ GetAvailableApps()->UpdateAppsDB();
- /* Load the menu hotkeys */
- KeyBrd = LoadAcceleratorsW(NULL, MAKEINTRESOURCEW(HOTKEYS));
+ /* Load the menu hotkeys */
+ KeyBrd = LoadAcceleratorsW(NULL, MAKEINTRESOURCEW(HOTKEYS));
- /* Message Loop */
- while (GetMessageW(&Msg, NULL, 0, 0))
- {
- if (!TranslateAcceleratorW(hMainWnd, KeyBrd, &Msg))
+ /* Message Loop */
+ while (GetMessageW(&Msg, NULL, 0, 0))
{
- TranslateMessage(&Msg);
- DispatchMessageW(&Msg);
+ if (!TranslateAcceleratorW(hMainWnd, KeyBrd, &Msg))
+ {
+ TranslateMessage(&Msg);
+ DispatchMessageW(&Msg);
+ }
}
}
}