https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7a11c65561d224c688ba3…
commit 7a11c65561d224c688ba371044e52b17e1a70b6d
Author: He Yang <1160386205(a)qq.com>
AuthorDate: Tue Aug 25 17:06:30 2020 +0800
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Sep 6 17:10:18 2020 +0200
[RAPPS] cmdline enhancement (#3087)
* [RAPPS] now command-line option supports begin with both / and -
* [RAPPS] Add help command with /?
* [RAPPS] add /find command
* [RAPPS] add /info option
* [RAPPS] add copyright and contact e-mail
---
base/applications/rapps/CMakeLists.txt | 5 +-
base/applications/rapps/gui.cpp | 15 +-
base/applications/rapps/include/dialogs.h | 2 +-
base/applications/rapps/include/gui.h | 4 +-
base/applications/rapps/include/misc.h | 2 +
base/applications/rapps/include/resource.h | 10 +
base/applications/rapps/include/unattended.h | 12 +-
base/applications/rapps/include/winmain.h | 2 +
base/applications/rapps/lang/bg-BG.rc | 12 ++
base/applications/rapps/lang/cs-CZ.rc | 12 ++
base/applications/rapps/lang/de-DE.rc | 12 ++
base/applications/rapps/lang/en-US.rc | 12 ++
base/applications/rapps/lang/es-ES.rc | 12 ++
base/applications/rapps/lang/et-EE.rc | 12 ++
base/applications/rapps/lang/fr-FR.rc | 12 ++
base/applications/rapps/lang/he-IL.rc | 12 ++
base/applications/rapps/lang/id-ID.rc | 12 ++
base/applications/rapps/lang/it-IT.rc | 12 ++
base/applications/rapps/lang/ja-JP.rc | 12 ++
base/applications/rapps/lang/no-NO.rc | 12 ++
base/applications/rapps/lang/pl-PL.rc | 12 ++
base/applications/rapps/lang/pt-BR.rc | 12 ++
base/applications/rapps/lang/pt-PT.rc | 12 ++
base/applications/rapps/lang/ro-RO.rc | 12 ++
base/applications/rapps/lang/ru-RU.rc | 12 ++
base/applications/rapps/lang/sk-SK.rc | 12 ++
base/applications/rapps/lang/sq-AL.rc | 12 ++
base/applications/rapps/lang/sv-SE.rc | 12 ++
base/applications/rapps/lang/tr-TR.rc | 12 ++
base/applications/rapps/lang/uk-UA.rc | 12 ++
base/applications/rapps/lang/zh-CN.rc | 12 ++
base/applications/rapps/lang/zh-TW.rc | 12 ++
base/applications/rapps/misc.cpp | 8 +
base/applications/rapps/unattended.cpp | 294 ++++++++++++++++++++++++---
base/applications/rapps/winmain.cpp | 46 ++---
35 files changed, 605 insertions(+), 83 deletions(-)
diff --git a/base/applications/rapps/CMakeLists.txt
b/base/applications/rapps/CMakeLists.txt
index 4be7ed458bf..4a0dfabfd7f 100644
--- a/base/applications/rapps/CMakeLists.txt
+++ b/base/applications/rapps/CMakeLists.txt
@@ -4,6 +4,7 @@ set_cpp(WITH_RUNTIME)
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl)
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/cryptlib)
+include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
include_directories(include)
list(APPEND SOURCE
@@ -42,8 +43,8 @@ add_definitions(
file(GLOB_RECURSE rapps_rc_deps res/*.*)
add_rc_deps(rapps.rc ${rapps_rc_deps})
add_executable(rapps ${SOURCE} rapps.rc)
-set_module_type(rapps win32gui UNICODE)
-target_link_libraries(rapps uuid wine)
+set_module_type(rapps win32cui UNICODE)
+target_link_libraries(rapps conutils ${PSEH_LIB} uuid wine)
add_importlibs(rapps advapi32 comctl32 gdi32 wininet user32 shell32 shlwapi ole32
setupapi gdiplus msvcrt kernel32 ntdll)
add_pch(rapps include/rapps.h SOURCE)
add_dependencies(rapps rappsmsg)
diff --git a/base/applications/rapps/gui.cpp b/base/applications/rapps/gui.cpp
index 7732d18e501..50f4b14f810 100644
--- a/base/applications/rapps/gui.cpp
+++ b/base/applications/rapps/gui.cpp
@@ -15,6 +15,7 @@
#include "misc.h"
#include "gui.h"
#include "appview.h"
+#include "winmain.h"
#include <shlobj_undoc.h>
#include <shlguid_undoc.h>
@@ -51,7 +52,7 @@ HTREEITEM CSideTreeView::AddItem(HTREEITEM hParent, ATL::CStringW
&Text, INT Ima
HTREEITEM CSideTreeView::AddCategory(HTREEITEM hRootItem, UINT TextIndex, UINT
IconIndex)
{
ATL::CStringW szText;
- INT Index;
+ INT Index = 0;
HICON hIcon;
hIcon = (HICON)LoadImageW(hInst,
@@ -613,14 +614,6 @@ VOID CMainWindow::OnCommand(WPARAM wParam, LPARAM lParam)
}
}
-BOOL CMainWindow::SearchPatternMatch(LPCWSTR szHaystack, LPCWSTR szNeedle)
-{
- if (!*szNeedle)
- return TRUE;
- /* TODO: Improve pattern search beyond a simple case-insensitive substring search.
*/
- return StrStrIW(szHaystack, szNeedle) != NULL;
-}
-
BOOL CALLBACK CMainWindow::EnumInstalledAppProc(CInstalledApplicationInfo *Info)
{
if (!SearchPatternMatch(Info->szDisplayName.GetString(), szSearchPattern))
@@ -723,7 +716,7 @@ ATL::CWndClassInfo &CMainWindow::GetWndClassInfo()
LoadCursorW(NULL, IDC_ARROW),
(HBRUSH)(COLOR_BTNFACE + 1),
MAKEINTRESOURCEW(IDR_MAINMENU),
- L"RAppsWnd",
+ szWindowClass,
NULL
},
NULL, NULL, IDC_ARROW, TRUE, 0, _T("")
@@ -861,7 +854,7 @@ void CMainWindow::HandleTabOrder(int direction)
-VOID ShowMainWindow(INT nShowCmd)
+VOID MainWindowLoop(INT nShowCmd)
{
HACCEL KeyBrd;
MSG Msg;
diff --git a/base/applications/rapps/include/dialogs.h
b/base/applications/rapps/include/dialogs.h
index aa5afa6ce7c..917effd8c6e 100644
--- a/base/applications/rapps/include/dialogs.h
+++ b/base/applications/rapps/include/dialogs.h
@@ -9,7 +9,7 @@
VOID CreateSettingsDlg(HWND hwnd);
//Main window
-VOID ShowMainWindow(INT nShowCmd);
+VOID MainWindowLoop(INT nShowCmd);
// Download dialogs
VOID DownloadApplicationsDB(LPCWSTR lpUrl, BOOL IsOfficial);
diff --git a/base/applications/rapps/include/gui.h
b/base/applications/rapps/include/gui.h
index 772bd2f71cb..1d8b6141ece 100644
--- a/base/applications/rapps/include/gui.h
+++ b/base/applications/rapps/include/gui.h
@@ -98,8 +98,6 @@ private:
VOID OnCommand(WPARAM wParam, LPARAM lParam);
- static BOOL SearchPatternMatch(LPCWSTR szHaystack, LPCWSTR szNeedle);
-
BOOL CALLBACK EnumInstalledAppProc(CInstalledApplicationInfo *Info);
BOOL CALLBACK EnumAvailableAppProc(CAvailableApplicationInfo *Info, BOOL
bInitialCheckState);
@@ -134,4 +132,4 @@ public:
};
-VOID ShowMainWindow(INT nShowCmd);
+VOID MainWindowLoop(INT nShowCmd);
diff --git a/base/applications/rapps/include/misc.h
b/base/applications/rapps/include/misc.h
index 9f28f267033..58890958f3d 100644
--- a/base/applications/rapps/include/misc.h
+++ b/base/applications/rapps/include/misc.h
@@ -56,3 +56,5 @@ BOOL IsSystem64Bit();
INT GetSystemColorDepth();
void UnixTimeToFileTime(DWORD dwUnixTime, LPFILETIME pFileTime);
+
+BOOL SearchPatternMatch(LPCWSTR szHaystack, LPCWSTR szNeedle);
diff --git a/base/applications/rapps/include/resource.h
b/base/applications/rapps/include/resource.h
index 6ea0ca1a321..023fcdda882 100644
--- a/base/applications/rapps/include/resource.h
+++ b/base/applications/rapps/include/resource.h
@@ -218,6 +218,16 @@
#define IDS_DL_DIALOG_DB_DOWNLOAD_DISP 951
#define IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP 952
+/* Command-line related strings */
+#define IDS_CMD_USAGE 953
+#define IDS_CMD_NEED_PACKAGE_NAME 954
+#define IDS_CMD_NEED_FILE_NAME 955
+#define IDS_CMD_NEED_PARAMS 956
+#define IDS_CMD_INVALID_OPTION 957
+#define IDS_CMD_FIND_RESULT_FOR 958
+#define IDS_CMD_PACKAGE_NOT_FOUND 959
+#define IDS_CMD_PACKAGE_INFO 960
+
/* Accelerators */
#define HOTKEYS 715
diff --git a/base/applications/rapps/include/unattended.h
b/base/applications/rapps/include/unattended.h
index 93d19344260..c5bc8797b01 100644
--- a/base/applications/rapps/include/unattended.h
+++ b/base/applications/rapps/include/unattended.h
@@ -1,7 +1,11 @@
#pragma once
-#define CMD_KEY_INSTALL L"/INSTALL"
-#define CMD_KEY_SETUP L"/SETUP"
+#define CMD_KEY_INSTALL L"INSTALL"
+#define CMD_KEY_SETUP L"SETUP"
+#define CMD_KEY_FIND L"FIND"
+#define CMD_KEY_INFO L"INFO"
+#define CMD_KEY_HELP L"?"
-// return TRUE if the SETUP key was valid
-BOOL UseCmdParameters(LPWSTR lpCmdLine);
+const WCHAR UsageString[] = L"RAPPS [/" CMD_KEY_HELP "] [/"
CMD_KEY_INSTALL " packagename] [/" CMD_KEY_SETUP " filename]";
+
+BOOL ParseCmdAndExecute(LPWSTR lpCmdLine, BOOL bIsFirstLaunch, int nCmdShow);
diff --git a/base/applications/rapps/include/winmain.h
b/base/applications/rapps/include/winmain.h
index cbd9f3727f7..3b9397a0eda 100644
--- a/base/applications/rapps/include/winmain.h
+++ b/base/applications/rapps/include/winmain.h
@@ -2,6 +2,8 @@
#include <windef.h>
#include <wininet.h>
+extern LPCWSTR szWindowClass;
+
//TODO: Separate main and settings related definitions
struct SETTINGS_INFO
{
diff --git a/base/applications/rapps/lang/bg-BG.rc
b/base/applications/rapps/lang/bg-BG.rc
index 4ac81b14652..02cd569901c 100644
--- a/base/applications/rapps/lang/bg-BG.rc
+++ b/base/applications/rapps/lang/bg-BG.rc
@@ -255,3 +255,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Updating Database…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Updating Database… (Unofficial
source)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/cs-CZ.rc
b/base/applications/rapps/lang/cs-CZ.rc
index 965c5b31380..4d1c6d6f20b 100644
--- a/base/applications/rapps/lang/cs-CZ.rc
+++ b/base/applications/rapps/lang/cs-CZ.rc
@@ -256,3 +256,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Updating Database…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Updating Database… (Unofficial
source)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/de-DE.rc
b/base/applications/rapps/lang/de-DE.rc
index 8bd0a0bc36a..8e6a9e60374 100644
--- a/base/applications/rapps/lang/de-DE.rc
+++ b/base/applications/rapps/lang/de-DE.rc
@@ -251,3 +251,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Datenbank-Aktualisierung…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Updating Database… (Unofficial
source)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/en-US.rc
b/base/applications/rapps/lang/en-US.rc
index 869868fd255..876d6675dcc 100644
--- a/base/applications/rapps/lang/en-US.rc
+++ b/base/applications/rapps/lang/en-US.rc
@@ -251,3 +251,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Updating Database…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Updating Database… (Unofficial
source)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/es-ES.rc
b/base/applications/rapps/lang/es-ES.rc
index c9f224c17c3..634e868c375 100644
--- a/base/applications/rapps/lang/es-ES.rc
+++ b/base/applications/rapps/lang/es-ES.rc
@@ -254,3 +254,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Actualizando listado…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Actualizando listado… (Origen no
oficial)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/et-EE.rc
b/base/applications/rapps/lang/et-EE.rc
index 95f2f57a6f9..e1cea69039d 100644
--- a/base/applications/rapps/lang/et-EE.rc
+++ b/base/applications/rapps/lang/et-EE.rc
@@ -259,3 +259,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Andmebaasi uuendamine…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Updating Database… (Unofficial
source)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/fr-FR.rc
b/base/applications/rapps/lang/fr-FR.rc
index 22077326c2e..996ffa5c212 100644
--- a/base/applications/rapps/lang/fr-FR.rc
+++ b/base/applications/rapps/lang/fr-FR.rc
@@ -251,3 +251,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Mise à jour de la base de données…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Mise à jour de la base de données…
(Non officielle)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/he-IL.rc
b/base/applications/rapps/lang/he-IL.rc
index 79a272acb1c..b8054551e94 100644
--- a/base/applications/rapps/lang/he-IL.rc
+++ b/base/applications/rapps/lang/he-IL.rc
@@ -257,3 +257,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "מעדכן את מסד הנתונים..."
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Updating Database… (Unofficial
source)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/id-ID.rc
b/base/applications/rapps/lang/id-ID.rc
index 0a65bcc1605..6da2e240587 100644
--- a/base/applications/rapps/lang/id-ID.rc
+++ b/base/applications/rapps/lang/id-ID.rc
@@ -251,3 +251,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Memperbarui database…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Updating Database… (Unofficial
source)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/it-IT.rc
b/base/applications/rapps/lang/it-IT.rc
index 6321268e6b1..b8567c41293 100644
--- a/base/applications/rapps/lang/it-IT.rc
+++ b/base/applications/rapps/lang/it-IT.rc
@@ -251,3 +251,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Aggiornamento Database…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Updating Database… (Unofficial
source)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/ja-JP.rc
b/base/applications/rapps/lang/ja-JP.rc
index 384eec172de..056c3f83086 100644
--- a/base/applications/rapps/lang/ja-JP.rc
+++ b/base/applications/rapps/lang/ja-JP.rc
@@ -251,3 +251,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "データベースを更新中..."
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Updating Database… (Unofficial
source)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/no-NO.rc
b/base/applications/rapps/lang/no-NO.rc
index 8ce8f1915b3..75d6cd9228d 100644
--- a/base/applications/rapps/lang/no-NO.rc
+++ b/base/applications/rapps/lang/no-NO.rc
@@ -251,3 +251,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Updating Database…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Updating Database… (Unofficial
source)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/pl-PL.rc
b/base/applications/rapps/lang/pl-PL.rc
index ca5b2615153..78ff3c3fc1a 100644
--- a/base/applications/rapps/lang/pl-PL.rc
+++ b/base/applications/rapps/lang/pl-PL.rc
@@ -259,3 +259,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Aktualizowanie bazy programów…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Updating Database… (Unofficial
source)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/pt-BR.rc
b/base/applications/rapps/lang/pt-BR.rc
index f60e57c4557..93bebf7c027 100644
--- a/base/applications/rapps/lang/pt-BR.rc
+++ b/base/applications/rapps/lang/pt-BR.rc
@@ -253,3 +253,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Updating Database…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Updating Database… (Unofficial
source)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/pt-PT.rc
b/base/applications/rapps/lang/pt-PT.rc
index 31d968a260a..e41033d6904 100644
--- a/base/applications/rapps/lang/pt-PT.rc
+++ b/base/applications/rapps/lang/pt-PT.rc
@@ -253,3 +253,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Actualizar base de dados…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "A actualizar Base de dados… (Fonte
não oficial)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/ro-RO.rc
b/base/applications/rapps/lang/ro-RO.rc
index 7e28b9e41d1..2492348948b 100644
--- a/base/applications/rapps/lang/ro-RO.rc
+++ b/base/applications/rapps/lang/ro-RO.rc
@@ -260,3 +260,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Actualizare baza de date…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Updating Database… (Unofficial
source)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/ru-RU.rc
b/base/applications/rapps/lang/ru-RU.rc
index 1ff0dd8651b..75095bb8148 100644
--- a/base/applications/rapps/lang/ru-RU.rc
+++ b/base/applications/rapps/lang/ru-RU.rc
@@ -251,3 +251,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Обновление базы данных…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Updating Database… (Unofficial
source)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/sk-SK.rc
b/base/applications/rapps/lang/sk-SK.rc
index 293028d37d6..9c2adf6c5d5 100644
--- a/base/applications/rapps/lang/sk-SK.rc
+++ b/base/applications/rapps/lang/sk-SK.rc
@@ -256,3 +256,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Updating Database…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Updating Database… (Unofficial
source)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/sq-AL.rc
b/base/applications/rapps/lang/sq-AL.rc
index 51be3ed3eca..0dda1a8d984 100644
--- a/base/applications/rapps/lang/sq-AL.rc
+++ b/base/applications/rapps/lang/sq-AL.rc
@@ -255,3 +255,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Updating Database…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Updating Database… (Unofficial
source)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/sv-SE.rc
b/base/applications/rapps/lang/sv-SE.rc
index d4715ed0b35..5e5bfb233b3 100644
--- a/base/applications/rapps/lang/sv-SE.rc
+++ b/base/applications/rapps/lang/sv-SE.rc
@@ -258,3 +258,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Updating Database…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Updating Database… (Unofficial
source)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/tr-TR.rc
b/base/applications/rapps/lang/tr-TR.rc
index a612fc9b503..597055cd0dc 100644
--- a/base/applications/rapps/lang/tr-TR.rc
+++ b/base/applications/rapps/lang/tr-TR.rc
@@ -253,3 +253,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Veri Tabanı güncelleniyor…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Updating Database… (Unofficial
source)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/uk-UA.rc
b/base/applications/rapps/lang/uk-UA.rc
index 29067f4871f..54a7d402d51 100644
--- a/base/applications/rapps/lang/uk-UA.rc
+++ b/base/applications/rapps/lang/uk-UA.rc
@@ -259,3 +259,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "Оновлення списку програм…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "Updating Database… (Unofficial
source)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/zh-CN.rc
b/base/applications/rapps/lang/zh-CN.rc
index 25a12c4fb1f..a0e025ab3c9 100644
--- a/base/applications/rapps/lang/zh-CN.rc
+++ b/base/applications/rapps/lang/zh-CN.rc
@@ -254,3 +254,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "正在更新数据库…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "正在更新数据库… (非官方源)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/lang/zh-TW.rc
b/base/applications/rapps/lang/zh-TW.rc
index 49f7dfb2c9f..82d2393d634 100644
--- a/base/applications/rapps/lang/zh-TW.rc
+++ b/base/applications/rapps/lang/zh-TW.rc
@@ -253,3 +253,15 @@ BEGIN
IDS_DL_DIALOG_DB_DOWNLOAD_DISP "更新資料庫…"
IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP "正在更新資料庫… (非官方源)"
END
+
+STRINGTABLE
+BEGIN
+ IDS_CMD_USAGE "Usage: "
+ IDS_CMD_NEED_PACKAGE_NAME "Error: option %1 expects one or more package
name.\n"
+ IDS_CMD_NEED_FILE_NAME "Error: option %1 expects a file name.\n"
+ IDS_CMD_NEED_PARAMS "Error: option %1 expects one or more parameters.\n"
+ IDS_CMD_INVALID_OPTION "Error: Unknown or invalid command line option
specified.\n"
+ IDS_CMD_FIND_RESULT_FOR "Find result for %1:\n"
+ IDS_CMD_PACKAGE_NOT_FOUND "Failed to find package %1.\n"
+ IDS_CMD_PACKAGE_INFO "Information about package %1:\n"
+END
diff --git a/base/applications/rapps/misc.cpp b/base/applications/rapps/misc.cpp
index 086adfcfb68..54a965bce13 100644
--- a/base/applications/rapps/misc.cpp
+++ b/base/applications/rapps/misc.cpp
@@ -522,3 +522,11 @@ void UnixTimeToFileTime(DWORD dwUnixTime, LPFILETIME pFileTime)
pFileTime->dwLowDateTime = (DWORD)ll;
pFileTime->dwHighDateTime = ll >> 32;
}
+
+BOOL SearchPatternMatch(LPCWSTR szHaystack, LPCWSTR szNeedle)
+{
+ if (!*szNeedle)
+ return TRUE;
+ /* TODO: Improve pattern search beyond a simple case-insensitive substring search.
*/
+ return StrStrIW(szHaystack, szNeedle) != NULL;
+}
diff --git a/base/applications/rapps/unattended.cpp
b/base/applications/rapps/unattended.cpp
index b37610c4149..839d8a53dcf 100644
--- a/base/applications/rapps/unattended.cpp
+++ b/base/applications/rapps/unattended.cpp
@@ -3,61 +3,100 @@
* LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Functions to parse command-line flags and process them
* COPYRIGHT: Copyright 2017 Alexander Shaposhnikov (sanchaez(a)reactos.org)
+ * Copyright 2020 He Yang (1160386205(a)qq.com)
*/
#include "rapps.h"
#include "unattended.h"
+#include "winmain.h"
+
#include <setupapi.h>
-#define MIN_ARGS 3
+#include <conutils.h>
-BOOL UseCmdParameters(LPWSTR lpCmdLine)
+BOOL MatchCmdOption(LPWSTR argvOption, LPCWSTR szOptToMacth)
{
- INT argc;
- LPWSTR* argv = CommandLineToArgvW(lpCmdLine, &argc);
+ WCHAR FirstCharList[] = { L'-', L'/' };
- if (!argv || argc < MIN_ARGS)
+ for (UINT i = 0; i < _countof(FirstCharList); i++)
{
+ if (argvOption[0] == FirstCharList[i])
+ {
+ if (StrCmpIW(argvOption + 1, szOptToMacth) == 0)
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+BOOL HandleInstallCommand(LPWSTR szCommand, int argcLeft, LPWSTR * argvLeft)
+{
+ if (argcLeft == 0)
+ {
+ ConResMsgPrintf(StdOut, NULL, IDS_CMD_NEED_PACKAGE_NAME, szCommand);
return FALSE;
}
+ FreeConsole();
ATL::CSimpleArray<ATL::CStringW> PkgNameList;
- if (!StrCmpIW(argv[1], CMD_KEY_INSTALL))
+
+ for (int i = 0; i < argcLeft; i++)
{
- for (INT i = 2; i < argc; ++i)
- {
- PkgNameList.Add(argv[i]);
- }
+ PkgNameList.Add(argvLeft[i]);
+ }
+
+ CAvailableApps apps;
+ apps.UpdateAppsDB();
+ apps.Enum(ENUM_ALL_AVAILABLE, NULL, NULL);
+
+ ATL::CSimpleArray<CAvailableApplicationInfo> arrAppInfo =
apps.FindAppsByPkgNameList(PkgNameList);
+ if (arrAppInfo.GetSize() > 0)
+ {
+ DownloadListOfApplications(arrAppInfo, TRUE);
+ return TRUE;
}
else
- if (!StrCmpIW(argv[1], CMD_KEY_SETUP))
{
- HINF InfHandle = SetupOpenInfFileW(argv[2], NULL, INF_STYLE_WIN4, NULL);
- if (InfHandle == INVALID_HANDLE_VALUE)
- {
- return FALSE;
- }
+ return FALSE;
+ }
+}
- INFCONTEXT Context;
- if (SetupFindFirstLineW(InfHandle, L"RAPPS", L"Install",
&Context))
- {
- WCHAR szPkgName[MAX_PATH];
- do
- {
- if (SetupGetStringFieldW(&Context, 1, szPkgName, _countof(szPkgName),
NULL))
- {
- PkgNameList.Add(szPkgName);
- }
- } while (SetupFindNextLine(&Context, &Context));
- }
- SetupCloseInfFile(InfHandle);
+BOOL HandleSetupCommand(LPWSTR szCommand, int argcLeft, LPWSTR * argvLeft)
+{
+ if (argcLeft != 1)
+ {
+ ConResMsgPrintf(StdOut, NULL, IDS_CMD_NEED_FILE_NAME, szCommand);
+ return FALSE;
}
- else
+
+ ATL::CSimpleArray<ATL::CStringW> PkgNameList;
+ HINF InfHandle = SetupOpenInfFileW(argvLeft[0], NULL, INF_STYLE_WIN4, NULL);
+ if (InfHandle == INVALID_HANDLE_VALUE)
{
return FALSE;
}
+ INFCONTEXT Context;
+ if (SetupFindFirstLineW(InfHandle, L"RAPPS", L"Install",
&Context))
+ {
+ WCHAR szPkgName[MAX_PATH];
+ do
+ {
+ if (SetupGetStringFieldW(&Context, 1, szPkgName, _countof(szPkgName),
NULL))
+ {
+ PkgNameList.Add(szPkgName);
+ }
+ } while (SetupFindNextLine(&Context, &Context));
+ }
+ SetupCloseInfFile(InfHandle);
+
CAvailableApps apps;
apps.UpdateAppsDB();
apps.Enum(ENUM_ALL_AVAILABLE, NULL, NULL);
@@ -68,6 +107,199 @@ BOOL UseCmdParameters(LPWSTR lpCmdLine)
DownloadListOfApplications(arrAppInfo, TRUE);
return TRUE;
}
+ else
+ {
+ return FALSE;
+ }
+}
- return FALSE;
+BOOL CALLBACK CmdFindAppEnum(CAvailableApplicationInfo *Info, BOOL bInitialCheckState,
PVOID param)
+{
+ LPCWSTR lpszSearch = (LPCWSTR)param;
+ if (!SearchPatternMatch(Info->m_szName.GetString(), lpszSearch) &&
+ !SearchPatternMatch(Info->m_szDesc.GetString(), lpszSearch))
+ {
+ return TRUE;
+ }
+
+ ConPrintf(StdOut, (LPWSTR)L"%s (%s)\n", (LPCWSTR)(Info->m_szName),
(LPCWSTR)(Info->m_szPkgName));
+ return TRUE;
+}
+
+BOOL HandleFindCommand(LPWSTR szCommand, int argcLeft, LPWSTR *argvLeft)
+{
+ if (argcLeft < 1)
+ {
+ ConResMsgPrintf(StdOut, NULL, IDS_CMD_NEED_PARAMS, szCommand);
+ return FALSE;
+ }
+
+ CAvailableApps apps;
+ apps.UpdateAppsDB();
+
+ for (int i = 0; i < argcLeft; i++)
+ {
+ ConResMsgPrintf(StdOut, NULL, IDS_CMD_FIND_RESULT_FOR, argvLeft[i]);
+ apps.Enum(ENUM_ALL_AVAILABLE, CmdFindAppEnum, argvLeft[i]);
+ ConPrintf(StdOut, (LPWSTR)L"\n");
+ }
+
+ return TRUE;
+}
+
+BOOL HandleInfoCommand(LPWSTR szCommand, int argcLeft, LPWSTR *argvLeft)
+{
+ if (argcLeft < 1)
+ {
+ ConResMsgPrintf(StdOut, NULL, IDS_CMD_NEED_PARAMS, szCommand);
+ return FALSE;
+ }
+
+ CAvailableApps apps;
+ apps.UpdateAppsDB();
+ apps.Enum(ENUM_ALL_AVAILABLE, NULL, NULL);
+
+ for (int i = 0; i < argcLeft; i++)
+ {
+ CAvailableApplicationInfo *AppInfo = apps.FindAppByPkgName(argvLeft[i]);
+ if (!AppInfo)
+ {
+ ConResMsgPrintf(StdOut, NULL, IDS_CMD_PACKAGE_NOT_FOUND, argvLeft[i]);
+ }
+ else
+ {
+ ConResMsgPrintf(StdOut, NULL, IDS_CMD_PACKAGE_INFO, argvLeft[i]);
+ // TODO: code about extracting information from CAvailableApplicationInfo (in
appview.cpp, class CAppRichEdit)
+ // is in a mess. It should be refactored, and should not placed in class
CAppRichEdit.
+ // and the code here should reused that code after refactor.
+
+ ConPuts(StdOut, (LPWSTR)(LPCWSTR)AppInfo->m_szName);
+
+ if (AppInfo->m_szVersion)
+ {
+ ConResPrintf(StdOut, IDS_AINFO_VERSION);
+ ConPuts(StdOut, (LPWSTR)(LPCWSTR)AppInfo->m_szVersion);
+ }
+
+ if (AppInfo->m_szLicense)
+ {
+ ConResPrintf(StdOut, IDS_AINFO_LICENSE);
+ ConPuts(StdOut, (LPWSTR)(LPCWSTR)AppInfo->m_szLicense);
+ }
+
+ if (AppInfo->m_szSize)
+ {
+ ConResPrintf(StdOut, IDS_AINFO_SIZE);
+ ConPuts(StdOut, (LPWSTR)(LPCWSTR)AppInfo->m_szSize);
+ }
+
+ if (AppInfo->m_szUrlSite)
+ {
+ ConResPrintf(StdOut, IDS_AINFO_URLSITE);
+ ConPuts(StdOut, (LPWSTR)(LPCWSTR)AppInfo->m_szUrlSite);
+ }
+
+ if (AppInfo->m_szDesc)
+ {
+ ConResPrintf(StdOut, IDS_AINFO_DESCRIPTION);
+ ConPuts(StdOut, (LPWSTR)(LPCWSTR)AppInfo->m_szDesc);
+ }
+
+ if (AppInfo->m_szUrlDownload)
+ {
+ ConResPrintf(StdOut, IDS_AINFO_URLDOWNLOAD);
+ ConPuts(StdOut, (LPWSTR)(LPCWSTR)AppInfo->m_szUrlDownload);
+ }
+
+ ConPrintf(StdOut, (LPWSTR)L"\n");
+ }
+ ConPrintf(StdOut, (LPWSTR)L"\n");
+ }
+ return TRUE;
+}
+
+BOOL HandleHelpCommand(LPWSTR szCommand, int argcLeft, LPWSTR * argvLeft)
+{
+ if (argcLeft != 0)
+ {
+ return FALSE;
+ }
+
+ ConPrintf(StdOut, (LPWSTR)L"\n");
+ ConResPuts(StdOut, IDS_APPTITLE);
+ ConPrintf(StdOut, (LPWSTR)L"\n\n");
+
+ ConResPuts(StdOut, IDS_CMD_USAGE);
+ ConPrintf(StdOut, (LPWSTR)L"%ls\n", UsageString);
+ return TRUE;
+}
+
+BOOL ParseCmdAndExecute(LPWSTR lpCmdLine, BOOL bIsFirstLaunch, int nCmdShow)
+{
+ INT argc;
+ LPWSTR *argv = CommandLineToArgvW(lpCmdLine, &argc);
+
+ if (!argv)
+ {
+ return FALSE;
+ }
+
+ if (argc == 1) // RAPPS is launched without options
+ {
+ // Close the console, and open MainWindow
+ FreeConsole();
+
+
+ // Check for if rapps MainWindow is already launched in another process
+ HANDLE hMutex;
+
+ hMutex = CreateMutexW(NULL, FALSE, szWindowClass);
+ if ((!hMutex) || (GetLastError() == ERROR_ALREADY_EXISTS))
+ {
+ /* If already started, it is found its window */
+ HWND hWindow = FindWindowW(szWindowClass, NULL);
+
+ /* Activate window */
+ ShowWindow(hWindow, SW_SHOWNORMAL);
+ SetForegroundWindow(hWindow);
+ return FALSE;
+ }
+
+ if (SettingsInfo.bUpdateAtStart || bIsFirstLaunch)
+ CAvailableApps::ForceUpdateAppsDB();
+
+ MainWindowLoop(nCmdShow);
+
+ if (hMutex)
+ CloseHandle(hMutex);
+ }
+ else if (MatchCmdOption(argv[1], CMD_KEY_INSTALL))
+ {
+ return HandleInstallCommand(argv[1], argc - 2, argv + 2);
+ }
+ else if (MatchCmdOption(argv[1], CMD_KEY_SETUP))
+ {
+ return HandleSetupCommand(argv[1], argc - 2, argv + 2);
+ }
+ else if (MatchCmdOption(argv[1], CMD_KEY_FIND))
+ {
+ return HandleFindCommand(argv[1], argc - 2, argv + 2);
+ }
+ else if (MatchCmdOption(argv[1], CMD_KEY_INFO))
+ {
+ return HandleInfoCommand(argv[1], argc - 2, argv + 2);
+ }
+ else if (MatchCmdOption(argv[1], CMD_KEY_HELP))
+ {
+ return HandleHelpCommand(argv[1], argc - 2, argv + 2);
+ }
+ else
+ {
+ // unrecognized/invalid options
+ ConResPuts(StdOut, IDS_CMD_INVALID_OPTION);
+ return FALSE;
+ }
+
+
+ return TRUE;
}
diff --git a/base/applications/rapps/winmain.cpp b/base/applications/rapps/winmain.cpp
index 2f462459113..740e4fa828f 100644
--- a/base/applications/rapps/winmain.cpp
+++ b/base/applications/rapps/winmain.cpp
@@ -14,6 +14,10 @@
#include <gdiplus.h>
+#include <conutils.h>
+
+LPCWSTR szWindowClass = L"ROSAPPMGR";
+
HWND hMainWnd;
HINSTANCE hInst;
SETTINGS_INFO SettingsInfo;
@@ -139,13 +143,13 @@ VOID SaveSettings(HWND hwnd)
}
}
-INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, INT
nShowCmd)
+int wmain(int argc, wchar_t *argv[])
{
- LPCWSTR szWindowClass = L"ROSAPPMGR";
- HANDLE hMutex;
- BOOL bIsFirstLaunch;
+ ConInitStdStreams(); // Initialize the Console Standard Streams
- InitializeAtlModule(hInstance, TRUE);
+ BOOL bIsFirstLaunch;
+
+ InitializeAtlModule(GetModuleHandle(NULL), TRUE);
InitializeGDIPlus(TRUE);
if (GetUserDefaultUILanguage() == MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT))
@@ -153,19 +157,8 @@ INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPWSTR lpCmdLi
SetProcessDefaultLayout(LAYOUT_RTL);
}
- hInst = hInstance;
-
- hMutex = CreateMutexW(NULL, FALSE, szWindowClass);
- if ((!hMutex) || (GetLastError() == ERROR_ALREADY_EXISTS))
- {
- /* If already started, it is found its window */
- HWND hWindow = FindWindowW(szWindowClass, NULL);
+ hInst = GetModuleHandle(NULL);
- /* Activate window */
- ShowWindow(hWindow, SW_SHOWNORMAL);
- SetForegroundWindow(hWindow);
- return 1;
- }
bIsFirstLaunch = !LoadSettings();
if (bIsFirstLaunch)
{
@@ -175,20 +168,11 @@ INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPWSTR lpCmdLi
InitLogs();
InitCommonControls();
- // skip window creation if there were some keys
- if (!UseCmdParameters(GetCommandLineW()))
- {
- if (SettingsInfo.bUpdateAtStart || bIsFirstLaunch)
- CAvailableApps::ForceUpdateAppsDB();
-
- ShowMainWindow(nShowCmd);
- }
-
- if (hMutex)
- CloseHandle(hMutex);
-
+ // parse cmd-line and perform the corresponding operation
+ BOOL bSuccess = ParseCmdAndExecute(GetCommandLineW(), bIsFirstLaunch,
SW_SHOWNORMAL);
+
InitializeGDIPlus(FALSE);
- InitializeAtlModule(hInstance, FALSE);
+ InitializeAtlModule(GetModuleHandle(NULL), FALSE);
- return 0;
+ return bSuccess ? 0 : 1;
}