2017-09-03 20:37:14 +00:00
|
|
|
/*
|
2017-09-09 20:38:06 +00:00
|
|
|
* PROJECT: ReactOS Applications Manager
|
|
|
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
|
|
|
* FILE: base/applications/rapps/unattended.cpp
|
|
|
|
* PURPOSE: Functions to parse command-line flags and process them
|
2017-09-09 20:44:43 +00:00
|
|
|
* COPYRIGHT: Copyright 2017 Alexander Shaposhnikov (sanchaez@reactos.org)
|
2017-09-03 20:37:14 +00:00
|
|
|
*/
|
2017-09-10 22:57:01 +00:00
|
|
|
#include "rapps.h"
|
2017-09-10 23:44:22 +00:00
|
|
|
|
2017-08-15 19:36:23 +00:00
|
|
|
#include "unattended.h"
|
|
|
|
|
2017-09-10 23:44:22 +00:00
|
|
|
#include <setupapi.h>
|
2017-08-15 19:36:23 +00:00
|
|
|
|
2018-06-05 20:08:18 +00:00
|
|
|
#define MIN_ARGS 3
|
2017-09-03 20:37:14 +00:00
|
|
|
|
2017-09-09 19:41:08 +00:00
|
|
|
BOOL UseCmdParameters(LPWSTR lpCmdLine)
|
2017-08-15 19:36:23 +00:00
|
|
|
{
|
|
|
|
INT argc;
|
|
|
|
LPWSTR* argv = CommandLineToArgvW(lpCmdLine, &argc);
|
|
|
|
|
2017-09-03 20:37:14 +00:00
|
|
|
if (!argv || argc < MIN_ARGS)
|
2017-08-15 19:36:23 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: use DB filenames as names because they're shorter
|
|
|
|
ATL::CSimpleArray<ATL::CStringW> arrNames;
|
2018-06-05 20:08:18 +00:00
|
|
|
if (!StrCmpIW(argv[1], CMD_KEY_INSTALL))
|
2017-08-15 19:36:23 +00:00
|
|
|
{
|
2018-06-05 20:08:18 +00:00
|
|
|
for (INT i = 2; i < argc; ++i)
|
2017-08-15 19:36:23 +00:00
|
|
|
{
|
|
|
|
arrNames.Add(argv[i]);
|
2018-02-03 22:42:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2018-06-05 20:08:18 +00:00
|
|
|
if (!StrCmpIW(argv[1], CMD_KEY_SETUP))
|
2017-08-15 19:36:23 +00:00
|
|
|
{
|
2018-06-05 20:08:18 +00:00
|
|
|
HINF InfHandle = SetupOpenInfFileW(argv[2], NULL, INF_STYLE_WIN4, NULL);
|
2017-08-15 19:36:23 +00:00
|
|
|
if (InfHandle == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
INFCONTEXT Context;
|
2017-08-15 22:35:45 +00:00
|
|
|
if (SetupFindFirstLineW(InfHandle, L"RAPPS", L"Install", &Context))
|
2017-08-15 19:36:23 +00:00
|
|
|
{
|
2017-08-15 22:35:45 +00:00
|
|
|
WCHAR szName[MAX_PATH];
|
|
|
|
do
|
2017-08-15 19:36:23 +00:00
|
|
|
{
|
2018-02-03 22:40:58 +00:00
|
|
|
if (SetupGetStringFieldW(&Context, 1, szName, _countof(szName), NULL))
|
2017-08-15 22:35:45 +00:00
|
|
|
{
|
|
|
|
arrNames.Add(szName);
|
|
|
|
}
|
|
|
|
} while (SetupFindNextLine(&Context, &Context));
|
|
|
|
}
|
2017-08-15 20:47:10 +00:00
|
|
|
SetupCloseInfFile(InfHandle);
|
2017-08-15 19:36:23 +00:00
|
|
|
}
|
2017-08-15 21:39:21 +00:00
|
|
|
else
|
2017-08-15 22:35:45 +00:00
|
|
|
{
|
2017-08-15 21:39:21 +00:00
|
|
|
return FALSE;
|
2017-08-15 22:35:45 +00:00
|
|
|
}
|
2017-08-15 19:36:23 +00:00
|
|
|
|
|
|
|
CAvailableApps apps;
|
2017-09-03 20:37:14 +00:00
|
|
|
apps.UpdateAppsDB();
|
|
|
|
apps.Enum(ENUM_ALL_AVAILABLE, NULL);
|
|
|
|
|
2017-10-21 21:00:50 +00:00
|
|
|
ATL::CSimpleArray<CAvailableApplicationInfo> arrAppInfo = apps.FindInfoList(arrNames);
|
2017-08-15 19:36:23 +00:00
|
|
|
if (arrAppInfo.GetSize() > 0)
|
|
|
|
{
|
|
|
|
CDownloadManager::DownloadListOfApplications(arrAppInfo, TRUE);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2018-02-03 22:42:46 +00:00
|
|
|
|
2017-08-15 19:36:23 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|