summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2025-05-22 16:49:26 +0300
committerGeorge Hazan <george.hazan@gmail.com>2025-05-22 16:49:26 +0300
commite0bb11dee76db814a37ecfb155076169d8780878 (patch)
treef4523718abb8350da585d5be55bac9cdafba7cf6
parentee0691d3871c2d95906b5171d2ed6e9a95588dbc (diff)
fixes #1907 (PluginUpdater: move deleting/renaming file rules from plugin to server side)
-rw-r--r--build/rules.txt105
-rw-r--r--plugins/PluginUpdater/src/DlgUpdate.cpp121
-rw-r--r--plugins/PluginUpdater/src/Utils.cpp20
-rw-r--r--plugins/PluginUpdater/src/stdafx.h30
-rw-r--r--tools/build_scripts/z2_PackPluginUpdater.bat3
5 files changed, 155 insertions, 124 deletions
diff --git a/build/rules.txt b/build/rules.txt
new file mode 100644
index 0000000000..6dd33e8b04
--- /dev/null
+++ b/build/rules.txt
@@ -0,0 +1,105 @@
+{
+ "rules": {
+ "svc_dbepp.dll": "Plugins\\dbeditorpp.dll",
+ "svc_crshdmp.dll": "Plugins\\crashdumper.dll",
+ "crashdmp.dll": "Plugins\\crashdumper.dll",
+ "crashrpt.dll": "Plugins\\crashdumper.dll",
+ "attache.dll": "Plugins\\crashdumper.dll",
+ "svc_vi.dll": "Plugins\\crashdumper.dll",
+ "crashrpt.dll": "Plugins\\crashdumper.dll",
+ "versioninfo.dll": "Plugins\\crashdumper.dll",
+ "advsplashscreen.dll": "Plugins\\splashscreen.dll",
+ "import_sa.dll": "Plugins\\import.dll",
+ "newnr.dll": "Plugins\\notesreminders.dll",
+ "dbtool.exe": null,
+ "dbtool_sa.exe": null,
+ "dbchecker.bat": null,
+ "fixme.cmd": null,
+ "mdbx_chk.exe": null,
+ "mdbx_dump.exe": null,
+ "mdbx_load.exe": null,
+ "clist_mw.dll": "Plugins\\clist_nicer.dll",
+ "bclist.dll": "Plugins\\clist_blind.dll",
+ "otr.dll": "Plugins\\mirotr.dll",
+ "ttnotify.dll": "Plugins\\tooltipnotify.dll",
+ "newstatusnotify.dll": "Plugins\\newxstatusnotify.dll",
+ "rss.dll": "Plugins\\newsaggregator.dll",
+ "dbx_3x.dll": "Plugins\\dbx_mmap.dll",
+ "actman30.dll": "Plugins\\actman.dll",
+ "skype.dll": "Plugins\\skypeweb.dll",
+ "skypeclassic.dll": "Plugins\\skypeweb.dll",
+ "historysweeper.dll": "Plugins\\historysweeperlight.dll",
+ "advancedautoaway.dll": "Plugins\\statusmanager.dll",
+ "keepstatus.dll": "Plugins\\statusmanager.dll",
+ "startupstatus.dll": "Plugins\\statusmanager.dll",
+ "dropbox.dll": "Plugins\\cloudfile.dll",
+ "popup.dll": "Plugins\\popupplus.dll",
+ "libaxolotl.mir": "Libs\\libsignal.mir",
+
+ "dbx_mmap_sa.dll": "Plugins\\dbx_mmap.dll",
+ "dbx_tree.dll": "Plugins\\dbx_mmap.dll",
+ "rc4.dll": null,
+ "athena.dll": null,
+ "skypekit.exe": null,
+ "mir_app.dll": null,
+ "mir_core.dll": null,
+ "zlib.dll": null,
+
+ "quotes.dll": "Plugins\\currencyrates.dll",
+ "proto_quotes.dll": "Icons\\proto_currencyrates.dll",
+
+ "proto_newsaggr.dll": "Icons\\proto_newsaggregator.dll",
+ "clienticons_*.dll": "Icons\\fp_icons.dll",
+ "fp_*.dll": "Icons\\fp_icons.dll",
+ "xstatus_icq.dll": null,
+
+ "langpack_*.txt": "Languages\\*",
+
+ "pcre16.dll": null,
+ "clist_classic.dll": null,
+ "chat.dll": null,
+ "srmm.dll": null,
+ "stdchat.dll": null,
+ "stdurl.dll": null,
+ "stdidle.dll": null,
+ "stdfile.dll": null,
+ "stdhelp.dll": null,
+ "stdauth.dll": null,
+ "stdssl.dll": null,
+
+ "advaimg.dll": null,
+ "aim.dll": null,
+ "extraicons.dll": null,
+ "firstrun.dll": null,
+ "flashavatars.dll": null,
+ "gender.dll": null,
+ "gtalkext.dll": null,
+ "icq.dll": null,
+ "importtxt.dll": null,
+ "langman.dll": null,
+ "libcrypto-1_1.mir": null,
+ "libssl-1_1.mir": null,
+ "libtox.dll": null,
+ "lua53.dll": null,
+ "metacontacts.dll": null,
+ "mra.dll": null,
+ "modernopt.dll": null,
+ "msn.dll": null,
+ "msvcp100.dll": null,
+ "msvcr100.dll": null,
+ "mtextcontrol.dll": null,
+ "omegle.dll": null,
+ "openssl.dll": null,
+ "rate.dll": null,
+ "skypestatuschange.dll": null,
+ "skypeweb.dll": null,
+ "spamotron.dll": null,
+ "sms.dll": null,
+ "tlen.dll": null,
+ "xfire.dll": null,
+ "yahoo.dll": null,
+ "yahoogroups.dll": null,
+ "yapp.dll": null,
+ "WART-*.exe": null
+ }
+}
diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp
index dc823ad35d..e04c3561e2 100644
--- a/plugins/PluginUpdater/src/DlgUpdate.cpp
+++ b/plugins/PluginUpdater/src/DlgUpdate.cpp
@@ -466,114 +466,7 @@ LBL_Error:
/////////////////////////////////////////////////////////////////////////////////////////
// building file list in the separate thread
-struct
-{
- wchar_t *oldName, *newName;
-}
-static renameTable[] =
-{
- { L"svc_dbepp.dll", L"Plugins\\dbeditorpp.dll" },
- { L"svc_crshdmp.dll", L"Plugins\\crashdumper.dll" },
- { L"crashdmp.dll", L"Plugins\\crashdumper.dll" },
- { L"crashrpt.dll", L"Plugins\\crashdumper.dll" },
- { L"attache.dll", L"Plugins\\crashdumper.dll" },
- { L"svc_vi.dll", L"Plugins\\crashdumper.dll" },
- { L"crashrpt.dll", L"Plugins\\crashdumper.dll" },
- { L"versioninfo.dll", L"Plugins\\crashdumper.dll" },
- { L"advsplashscreen.dll", L"Plugins\\splashscreen.dll" },
- { L"import_sa.dll", L"Plugins\\import.dll" },
- { L"newnr.dll", L"Plugins\\notesreminders.dll" },
- { L"dbtool.exe", nullptr },
- { L"dbtool_sa.exe", nullptr },
- { L"dbchecker.bat", nullptr },
- { L"fixme.cmd", nullptr },
- { L"mdbx_chk.exe", nullptr },
- { L"mdbx_dump.exe", nullptr },
- { L"mdbx_load.exe", nullptr },
- { L"clist_mw.dll", L"Plugins\\clist_nicer.dll" },
- { L"bclist.dll", L"Plugins\\clist_blind.dll" },
- { L"otr.dll", L"Plugins\\mirotr.dll" },
- { L"ttnotify.dll", L"Plugins\\tooltipnotify.dll" },
- { L"newstatusnotify.dll", L"Plugins\\newxstatusnotify.dll" },
- { L"rss.dll", L"Plugins\\newsaggregator.dll" },
- { L"dbx_3x.dll", L"Plugins\\dbx_mmap.dll" },
- { L"actman30.dll", L"Plugins\\actman.dll" },
- { L"skype.dll", L"Plugins\\skypeweb.dll" },
- { L"skypeclassic.dll", L"Plugins\\skypeweb.dll" },
- { L"historysweeper.dll", L"Plugins\\historysweeperlight.dll" },
- { L"advancedautoaway.dll", L"Plugins\\statusmanager.dll" },
- { L"keepstatus.dll", L"Plugins\\statusmanager.dll" },
- { L"startupstatus.dll", L"Plugins\\statusmanager.dll" },
- { L"dropbox.dll", L"Plugins\\cloudfile.dll" },
- { L"popup.dll", L"Plugins\\popupplus.dll" },
- { L"libaxolotl.mir", L"Libs\\libsignal.mir" },
-
- { L"dbx_mmap_sa.dll", L"Plugins\\dbx_mmap.dll" },
- { L"dbx_tree.dll", L"Plugins\\dbx_mmap.dll" },
- { L"rc4.dll", nullptr },
- { L"athena.dll", nullptr },
- { L"skypekit.exe", nullptr },
- { L"mir_app.dll", nullptr },
- { L"mir_core.dll", nullptr },
- { L"zlib.dll", nullptr },
-
- { L"quotes.dll", L"Plugins\\currencyrates.dll" },
- { L"proto_quotes.dll", L"Icons\\proto_currencyrates.dll" },
-
- { L"proto_newsaggr.dll", L"Icons\\proto_newsaggregator.dll" },
- { L"clienticons_*.dll", L"Icons\\fp_icons.dll" },
- { L"fp_*.dll", L"Icons\\fp_icons.dll" },
- { L"xstatus_icq.dll", nullptr },
-
- { L"langpack_*.txt", L"Languages\\*" },
-
- { L"pcre16.dll", nullptr },
- { L"clist_classic.dll", nullptr },
- { L"chat.dll", nullptr },
- { L"srmm.dll", nullptr },
- { L"stdchat.dll", nullptr },
- { L"stdurl.dll", nullptr },
- { L"stdidle.dll", nullptr },
- { L"stdfile.dll", nullptr },
- { L"stdhelp.dll", nullptr },
- { L"stdauth.dll", nullptr },
- { L"stdssl.dll", nullptr },
-
- { L"advaimg.dll", nullptr },
- { L"aim.dll", nullptr },
- { L"extraicons.dll", nullptr },
- { L"firstrun.dll", nullptr },
- { L"flashavatars.dll", nullptr },
- { L"gender.dll", nullptr },
- { L"gtalkext.dll", nullptr },
- { L"icq.dll", nullptr },
- { L"importtxt.dll", nullptr },
- { L"langman.dll", nullptr },
- { L"libcrypto-1_1.mir", nullptr },
- { L"libssl-1_1.mir", nullptr },
- { L"libtox.dll", nullptr },
- { L"lua53.dll", nullptr },
- { L"metacontacts.dll", nullptr },
- { L"mra.dll", nullptr },
- { L"modernopt.dll", nullptr },
- { L"msn.dll", nullptr },
- { L"msvcp100.dll", nullptr },
- { L"msvcr100.dll", nullptr },
- { L"mtextcontrol.dll", nullptr },
- { L"omegle.dll", nullptr },
- { L"openssl.dll", nullptr },
- { L"rate.dll", nullptr },
- { L"skypestatuschange.dll", nullptr },
- { L"skypeweb.dll", nullptr },
- { L"spamotron.dll", nullptr },
- { L"sms.dll", nullptr },
- { L"tlen.dll", nullptr },
- { L"xfire.dll", nullptr },
- { L"yahoo.dll", nullptr },
- { L"yahoogroups.dll", nullptr },
- { L"yapp.dll", nullptr },
- { L"WART-*.exe", nullptr },
-};
+RENAMETABLE g_arRename(50);
// Checks if file needs to be renamed and copies it in pNewName
// Returns true if smth. was copied
@@ -582,13 +475,13 @@ static bool CheckFileRename(const wchar_t *pwszFolder, const wchar_t *pwszOldNam
MFilePath fullOldPath;
fullOldPath.Format(L"%s\\%s", pwszFolder, pwszOldName);
- for (auto &it : renameTable) {
- if (wildcmpiw(pwszOldName, it.oldName)) {
- if (it.newName == nullptr)
+ for (auto &it : g_arRename) {
+ if (wildcmpiw(pwszOldName, it->wszSearch)) {
+ if (it->wszReplace == nullptr)
*pNewName = 0;
else {
- wcsncpy_s(pNewName, MAX_PATH, it.newName, _TRUNCATE);
- size_t cbLen = wcslen(it.newName) - 1;
+ wcsncpy_s(pNewName, MAX_PATH, it->wszReplace, _TRUNCATE);
+ size_t cbLen = wcslen(it->wszReplace) - 1;
if (pNewName[cbLen] == '*')
wcsncpy_s(pNewName + cbLen, MAX_PATH - cbLen, pwszOldName, _TRUNCATE);
@@ -789,7 +682,7 @@ static void CheckUpdates(void *)
ptrW updateUrl(GetDefaultUrl()), baseUrl;
SERVLIST hashes(50, CompareHashes);
- bool success = ParseHashes(updateUrl, baseUrl, hashes);
+ bool success = ParseHashes(updateUrl, baseUrl, hashes, &g_arRename);
if (success) {
if (hashes.getCount()) {
FILELIST *UpdateFiles = new FILELIST(20);
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp
index 5fbf66192d..ecab59c7a0 100644
--- a/plugins/PluginUpdater/src/Utils.cpp
+++ b/plugins/PluginUpdater/src/Utils.cpp
@@ -29,7 +29,7 @@ int CompareHashes(const ServListEntry *p1, const ServListEntry *p2)
return _wcsicmp(p1->m_name, p2->m_name);
}
-bool ParseHashes(const wchar_t *pwszUrl, ptrW &baseUrl, SERVLIST &arHashes)
+bool ParseHashes(const wchar_t *pwszUrl, ptrW &baseUrl, SERVLIST &arHashes, RENAMETABLE *arRename)
{
REPLACEVARSARRAY vars[2];
vars[0].key.w = L"platform";
@@ -42,6 +42,9 @@ bool ParseHashes(const wchar_t *pwszUrl, ptrW &baseUrl, SERVLIST &arHashes)
baseUrl = Utils_ReplaceVarsW(pwszUrl, 0, vars);
+ if (arRename)
+ arRename->destroy();
+
// Download version info
FILEURL pFileUrl;
mir_snwprintf(pFileUrl.wszDownloadURL, L"%s/hashes.zip", baseUrl.get());
@@ -113,6 +116,21 @@ bool ParseHashes(const wchar_t *pwszUrl, ptrW &baseUrl, SERVLIST &arHashes)
fclose(fp);
DeleteFileW(wszTmpIni);
+ // building table of rules
+ mir_snwprintf(wszTmpIni, L"%s\\rules.txt", g_wszTempPath);
+ if (arRename) {
+ JSONNode root;
+ if (file2json(wszTmpIni, root))
+ for (auto &it : root["rules"]) {
+ Utf2T wszName(it.name());
+ if (it.isnull())
+ arRename->insert(new RenameTableItem(wszName, nullptr));
+ else
+ arRename->insert(new RenameTableItem(wszName, it.as_mstring()));
+ }
+ }
+ DeleteFileW(wszTmpIni);
+
if (bDoNotSwitchToStable) {
g_plugin.setByte(DB_SETTING_DONT_SWITCH_TO_STABLE, 1);
// Reset setting if needed
diff --git a/plugins/PluginUpdater/src/stdafx.h b/plugins/PluginUpdater/src/stdafx.h
index 7053769c59..ca76ba0763 100644
--- a/plugins/PluginUpdater/src/stdafx.h
+++ b/plugins/PluginUpdater/src/stdafx.h
@@ -30,17 +30,17 @@ Boston, MA 02111-1307, USA.
// Miranda header files
#include <newpluginapi.h>
+#include <m_assocmgr.h>
#include <m_clist.h>
-#include <m_skin.h>
+#include <m_icolib.h>
+#include <m_gui.h>
+#include <m_hotkeys.h>
+#include <m_json.h>
#include <m_langpack.h>
+#include <m_netlib.h>
#include <m_options.h>
-#include <m_system.h>
#include <m_popup.h>
-#include <m_hotkeys.h>
-#include <m_netlib.h>
-#include <m_icolib.h>
-#include <m_assocmgr.h>
-#include <m_gui.h>
+#include <m_skin.h>
#include <m_folders.h>
@@ -233,6 +233,20 @@ typedef OBJLIST<ServListEntry> SERVLIST;
///////////////////////////////////////////////////////////////////////////////
+struct RenameTableItem
+{
+ RenameTableItem(const wchar_t *_1, const wchar_t *_2) :
+ wszSearch(mir_wstrdup(_1)),
+ wszReplace(mir_wstrdup(_2))
+ {}
+
+ ptrW wszSearch, wszReplace;
+};
+
+typedef OBJLIST<RenameTableItem> RENAMETABLE;
+
+///////////////////////////////////////////////////////////////////////////////
+
void InitPopupList();
void InitEvents();
@@ -249,7 +263,7 @@ void CALLBACK CheckUpdateOnStartup(void);
int BackupFile(wchar_t *pwszSrcFileName, wchar_t *pwszBackFileName);
-bool ParseHashes(const wchar_t *pwszUrl, ptrW &baseUrl, SERVLIST &arHashes);
+bool ParseHashes(const wchar_t *pwszUrl, ptrW &baseUrl, SERVLIST &arHashes, RENAMETABLE *arRename = nullptr);
int CompareHashes(const ServListEntry *p1, const ServListEntry *p2);
wchar_t* GetDefaultUrl();
diff --git a/tools/build_scripts/z2_PackPluginUpdater.bat b/tools/build_scripts/z2_PackPluginUpdater.bat
index 801079a815..2d93578d07 100644
--- a/tools/build_scripts/z2_PackPluginUpdater.bat
+++ b/tools/build_scripts/z2_PackPluginUpdater.bat
@@ -120,8 +120,9 @@ if /i '%dp%' == 'DEV_N_STABLE' (
echo ;StableAllowed > hashes.txt
)
+copy /y /v %SourceDir%\build\rules.txt .
for /f "tokens=1,2 delims= " %%i in (hash.txt) do call :WriteLine %%i %%j
-%ZipIt% "hashes.zip" hashes.txt
+%ZipIt% "hashes.zip" hashes.txt rules.txt
del /f /q hash*.txt
popd
REM end CRC32