diff options
-rw-r--r-- | plugins/PluginUpdater/PluginUpdaterIM_10.vcxproj | 2 | ||||
-rw-r--r-- | plugins/PluginUpdater/PluginUpdaterIM_10.vcxproj.filters | 6 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Compat/compat.cpp | 42 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Compat/compat.h | 59 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/DlgUpdate.cpp | 26 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/PluginUpdater.cpp | 4 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Utils.cpp | 13 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/stdafx.h | 6 |
8 files changed, 124 insertions, 34 deletions
diff --git a/plugins/PluginUpdater/PluginUpdaterIM_10.vcxproj b/plugins/PluginUpdater/PluginUpdaterIM_10.vcxproj index 894efc4922..9ea8032e37 100644 --- a/plugins/PluginUpdater/PluginUpdaterIM_10.vcxproj +++ b/plugins/PluginUpdater/PluginUpdaterIM_10.vcxproj @@ -218,7 +218,7 @@ <None Include="res\menu.ico" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\..\libs\zlib\zlib.vcxproj">
+ <ProjectReference Include="..\zlib\zlib_10.vcxproj">
<Project>{e2a369cd-eda3-414f-8ad0-e732cd7ee68c}</Project>
</ProjectReference>
</ItemGroup>
diff --git a/plugins/PluginUpdater/PluginUpdaterIM_10.vcxproj.filters b/plugins/PluginUpdater/PluginUpdaterIM_10.vcxproj.filters index a684e48e85..f0cb02749b 100644 --- a/plugins/PluginUpdater/PluginUpdaterIM_10.vcxproj.filters +++ b/plugins/PluginUpdater/PluginUpdaterIM_10.vcxproj.filters @@ -32,9 +32,6 @@ <ClInclude Include="src\Version.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\Common.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\Notifications.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -62,6 +59,9 @@ <ClInclude Include="src\Compat\compat.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="src\stdafx.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\Notifications.cpp">
diff --git a/plugins/PluginUpdater/src/Compat/compat.cpp b/plugins/PluginUpdater/src/Compat/compat.cpp index 2cd1a58815..1da442ee41 100644 --- a/plugins/PluginUpdater/src/Compat/compat.cpp +++ b/plugins/PluginUpdater/src/Compat/compat.cpp @@ -69,17 +69,53 @@ char *rtrim(char *str) return str;
}
-void CreatePathToFileT(TCHAR *tszFilePath)
+wchar_t* strdelw(wchar_t *str, size_t len)
+{
+ wchar_t* p;
+ for (p = str + len; *p != 0; p++)
+ *(p - len) = *p;
+
+ *(p - len) = '\0';
+ return str;
+}
+
+void CreatePathToFileW(WCHAR *tszFilePath)
{
TCHAR *pszLastBackslash = _tcsrchr(tszFilePath, '\\');
if (pszLastBackslash != NULL){
*pszLastBackslash = '\0';
- CreateDirectoryTreeT(tszFilePath);
+ CreateDirectoryTreeW(tszFilePath);
*pszLastBackslash = '\\';
}
}
-int wildcmpit(const WCHAR *name, const WCHAR *mask)
+int mir_snwprintf(WCHAR *buffer, size_t count, const WCHAR* fmt, ...)
+{
+ va_list va;
+ va_start(va, fmt);
+ int len = _vsntprintf(buffer, count-1, fmt, va);
+ va_end(va);
+ buffer[count-1] = 0;
+ return len;
+}
+
+int mir_vsnwprintf(WCHAR *buffer, size_t count, const WCHAR* fmt, va_list va)
+{
+ int len = _vsntprintf(buffer, count-1, fmt, va);
+ buffer[count-1] = 0;
+ return len;
+}
+
+int mir_wstrcmpi(const wchar_t *p1, const wchar_t *p2)
+{
+ if (p1 == NULL)
+ return (p2 == NULL) ? 0 : -1;
+ if (p2 == NULL)
+ return 1;
+ return _wcsicmp(p1, p2);
+}
+
+int wildcmpiw(const WCHAR *name, const WCHAR *mask)
{
if (name == NULL || mask == NULL)
return false;
diff --git a/plugins/PluginUpdater/src/Compat/compat.h b/plugins/PluginUpdater/src/Compat/compat.h index 4c0d0849eb..40bee6b259 100644 --- a/plugins/PluginUpdater/src/Compat/compat.h +++ b/plugins/PluginUpdater/src/Compat/compat.h @@ -16,6 +16,7 @@ #define db_set_dw(A,B,C,D) DBWriteContactSettingDword(A,B,C,D)
#define db_set_s(A,B,C,D) DBWriteContactSettingString(A,B,C,D)
#define db_set_ts(A,B,C,D) DBWriteContactSettingTString(A,B,C,D)
+#define db_set_ws(A,B,C,D) DBWriteContactSettingWString(A,B,C,D)
#define db_get_sa DBGetStringA
#define db_get_wsa DBGetStringW
@@ -27,6 +28,8 @@ #define NETLIB_USER_AGENT "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)"
typedef HANDLE MCONTACT;
+typedef HANDLE HNETLIBUSER;
+typedef HANDLE HNETLIBCONN;
template<class T> class mir_ptr
{
@@ -44,11 +47,12 @@ public: typedef mir_ptr<char> ptrA;
typedef mir_ptr<TCHAR> ptrT;
+typedef mir_ptr<WCHAR> ptrW;
-struct VARST : public ptrT
+struct VARSW : public ptrT
{
- __forceinline VARST(const TCHAR *str) :
- ptrT( Utils_ReplaceVarsT(str))
+ __forceinline VARSW(const WCHAR *str) :
+ ptrW( Utils_ReplaceVarsT(str))
{}
};
@@ -93,12 +97,51 @@ static iconList[] = { "plg_list", LPGEN("Component list"), IDI_PLGLIST }
};
+__forceinline void Thread_SetName(const char*) {}
+__forceinline void Skin_PlaySound(const char*) {}
+
+__forceinline void Window_FreeIcon_IcoLib(HWND) {}
+
+__forceinline int Clist_TrayNotifyW(const char *szProto, const wchar_t *wszInfoTitle, const wchar_t *wszInfo, DWORD dwInfoFlags, UINT uTimeout)
+{
+ return 1;
+}
+
+__forceinline HNETLIBUSER Netlib_RegisterUser(NETLIBUSER *nlu)
+{
+ return (HNETLIBUSER)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)nlu);
+}
+
+__forceinline NETLIBHTTPREQUEST* Netlib_HttpTransaction(HNETLIBUSER nlu, NETLIBHTTPREQUEST *nlhr)
+{
+ return (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)nlu, (LPARAM)nlhr);
+}
+
+__forceinline int Netlib_FreeHttpRequest(NETLIBHTTPREQUEST *nlhr)
+{
+ return CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhr);
+}
char *bin2hex(const void *pData, size_t len, char *dest);
char *rtrim(char *str);
-void CreatePathToFileT(TCHAR *ptszPath);
-int wildcmpit(const WCHAR *name, const WCHAR *mask);
+void CreatePathToFileW(WCHAR *ptszPath);
+int wildcmpiw(const WCHAR *name, const WCHAR *mask);
void InitIcoLib();
+wchar_t* strdelw(wchar_t *str, size_t len);
+
+int mir_vsnwprintf(wchar_t *buffer, size_t count, const wchar_t* fmt, va_list va);
+int mir_snwprintf(WCHAR *buffer, size_t count, const WCHAR* fmt, ...);
+int mir_wstrcmpi(const wchar_t *p1, const wchar_t *p2);
+
+template <size_t _Size>
+inline int mir_snwprintf(wchar_t(&buffer)[_Size], const wchar_t* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ int ret = mir_vsnwprintf(buffer, _Size, fmt, args);
+ va_end(args);
+ return ret;
+}
#define NEWTSTR_ALLOCA(A) (A == NULL)?NULL:_tcscpy((TCHAR*)alloca((_tcslen(A)+1) *sizeof(TCHAR)), A)
@@ -142,11 +185,11 @@ __forceinline INT_PTR Hotkey_Register(HOTKEYDESC *hk) { return CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)hk);
}
-__forceinline INT_PTR CreateDirectoryTreeT(const TCHAR *ptszPath) {
- return CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)ptszPath);
+__forceinline INT_PTR CreateDirectoryTreeW(const WCHAR *ptszPath) {
+ return CallService(MS_UTILS_CREATEDIRTREEW, 0, (LPARAM)ptszPath);
}
-__forceinline TCHAR *Utils_ReplaceVarsT(const TCHAR *szData, MCONTACT hContact, REPLACEVARSARRAY *variables) {
+__forceinline WCHAR* Utils_ReplaceVarsW(const WCHAR *szData, MCONTACT hContact, REPLACEVARSARRAY *variables) {
REPLACEVARSDATA vars;
vars.cbSize = sizeof(vars);
vars.dwFlags = RVF_TCHAR;
diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp index 8aada80df1..0e832f41f9 100644 --- a/plugins/PluginUpdater/src/DlgUpdate.cpp +++ b/plugins/PluginUpdater/src/DlgUpdate.cpp @@ -109,7 +109,7 @@ static void ApplyUpdates(void *param) else {
// if file name differs, we also need to backup the old file here
// otherwise it would be replaced by unzip
- if ( wcsicmp(p.tszOldName, p.tszNewName)) {
+ if (_wcsicmp(p.tszOldName, p.tszNewName)) {
wchar_t tszSrcPath[MAX_PATH], tszBackFile[MAX_PATH];
mir_snwprintf(tszSrcPath, L"%s\\%s", tszMirandaPath, p.tszOldName);
mir_snwprintf(tszBackFile, L"%s\\%s", tszFileBack, p.tszOldName);
@@ -132,8 +132,10 @@ static void ApplyUpdates(void *param) db_set_b(NULL, MODNAME, DB_SETTING_RESTART_COUNT, 5);
+#if MIRANDA_VER >= 0x0A00
if (opts.bBackup)
- CallService(MS_AB_BACKUP);
+ CallService(MS_AB_BACKUP, 0, 0);
+#endif
if (opts.bChangePlatform) {
wchar_t mirandaPath[MAX_PATH];
@@ -459,7 +461,7 @@ static void DlgUpdateSilent(void *param) else {
// if file name differs, we also need to backup the old file here
// otherwise it would be replaced by unzip
- if (wcsicmp(p.tszOldName, p.tszNewName)) {
+ if (_wcsicmp(p.tszOldName, p.tszNewName)) {
wchar_t tszSrcPath[MAX_PATH], tszBackFile[MAX_PATH];
mir_snwprintf(tszSrcPath, L"%s\\%s", tszMirandaPath, p.tszOldName);
mir_snwprintf(tszBackFile, L"%s\\%s", tszFileBack, p.tszOldName);
@@ -478,7 +480,7 @@ static void DlgUpdateSilent(void *param) #if MIRANDA_VER < 0x0A00
// 4) Change title of clist
ptrW title = db_get_wsa(NULL, "CList", "TitleText");
- if (!wcsicmp(title, L"Miranda IM"))
+ if (!_wcsicmp(title, L"Miranda IM"))
db_set_ws(NULL, "CList", "TitleText", L"Miranda NG");
#endif
@@ -564,6 +566,9 @@ static renameTable[] = { L"rc4.dll", NULL },
{ L"athena.dll", NULL },
{ L"skypekit.exe", NULL },
+ { L"mir_app.dll", NULL },
+ { L"mir_core.dll", NULL },
+ { L"zlib.dll", NULL },
#endif
{ L"proto_newsaggr.dll", L"Icons\\proto_newsaggregator.dll" },
@@ -572,9 +577,6 @@ static renameTable[] = { L"langpack_*.txt", L"Languages\\*" },
- { L"mir_app.dll", NULL },
- { L"mir_core.dll", NULL },
- { L"zlib.dll", NULL },
{ L"pcre16.dll", NULL },
{ L"clist_classic.dll", NULL },
{ L"chat.dll", NULL },
@@ -623,13 +625,13 @@ static bool isValidExtension(const wchar_t *ptszFileName) {
const wchar_t *pExt = wcsrchr(ptszFileName, '.');
- return (pExt != NULL) && (!wcsicmp(pExt, L".dll") || !wcsicmp(pExt, L".exe") || !wcsicmp(pExt, L".txt"));
+ return (pExt != NULL) && (!_wcsicmp(pExt, L".dll") || !_wcsicmp(pExt, L".exe") || !_wcsicmp(pExt, L".txt"));
}
// We only scan subfolders "Plugins", "Icons", "Languages", "Libs", "Core"
static bool isValidDirectory(const wchar_t *ptszDirName)
{
- return !wcsicmp(ptszDirName, L"Plugins") || !wcsicmp(ptszDirName, L"Icons") || !wcsicmp(ptszDirName, L"Languages") || !wcsicmp(ptszDirName, L"Libs") || !wcsicmp(ptszDirName, L"Core");
+ return !_wcsicmp(ptszDirName, L"Plugins") || !_wcsicmp(ptszDirName, L"Icons") || !_wcsicmp(ptszDirName, L"Languages") || !_wcsicmp(ptszDirName, L"Libs") || !_wcsicmp(ptszDirName, L"Core");
}
// Scans folders recursively
@@ -753,7 +755,7 @@ static int ScanFolder(const wchar_t *tszFolder, size_t cbBaseLen, const wchar_t if (p) *p = 0;
p = wcsrchr(tszBuf, '\\');
p = (p) ? p + 1 : tszBuf;
- wcslwr(p);
+ _wcslwr(p);
mir_snwprintf(FileInfo->File.tszDiskPath, L"%s\\Temp\\%s.zip", g_tszRoot, p);
mir_snwprintf(FileInfo->File.tszDownloadURL, L"%s/%s.zip", tszBaseUrl, tszBuf);
@@ -828,7 +830,7 @@ static void DoCheck(bool bSilent = true) #if MIRANDA_VER >= 0x0A00
db_set_dw(NULL, MODNAME, DB_SETTING_LAST_UPDATE, time(NULL));
#endif
- hCheckThread = mir_forkthread(CheckUpdates);
+ hCheckThread = mir_forkthread(CheckUpdates, 0);
}
}
@@ -943,5 +945,5 @@ void InitTimer(void *type) void CreateTimer() {
hTimer = CreateWaitableTimer(NULL, FALSE, NULL);
- mir_forkthread(InitTimer);
+ mir_forkthread(InitTimer, 0);
}
\ No newline at end of file diff --git a/plugins/PluginUpdater/src/PluginUpdater.cpp b/plugins/PluginUpdater/src/PluginUpdater.cpp index 49507acd15..fdc39c3695 100644 --- a/plugins/PluginUpdater/src/PluginUpdater.cpp +++ b/plugins/PluginUpdater/src/PluginUpdater.cpp @@ -111,7 +111,6 @@ extern "C" __declspec(dllexport) int Load(void) Menu_AddMainMenuItem(&mi);
InitOptions();
-#endif
// Add hotkey
HOTKEYDESC hkd = {};
@@ -122,14 +121,15 @@ extern "C" __declspec(dllexport) int Load(void) hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, VK_F10) | HKF_MIRANDA_LOCAL;
hkd.lParam = FALSE;
Hotkey_Register(&hkd);
+#endif
InitEvents();
+#if MIRANDA_VER >= 0x0A00
// add sounds
Skin_AddSound("updatecompleted", LPGENW("Plugin Updater"), LPGENW("Update completed"));
Skin_AddSound("updatefailed", LPGENW("Plugin Updater"), LPGENW("Update failed"));
-#if MIRANDA_VER >= 0x0A00
// Upgrade old settings
if (-1 == db_get_b(0, MODNAME, DB_SETTING_UPDATE_MODE, -1)) {
ptrW dbvUpdateURL(db_get_wsa(0, MODNAME, DB_SETTING_UPDATE_URL));
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index 7554c723ef..ba52be0285 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -59,7 +59,12 @@ void InitNetlib() {
NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_UNICODE;
- nlu.szDescriptiveName.w = TranslateT("Plugin Updater HTTP connections");
+ #if MIRANDA_VER >= 0x0A00
+ nlu.szDescriptiveName.w = TranslateT("Plugin Updater HTTP connections");
+ #else
+ nlu.cbSize = sizeof(nlu);
+ nlu.ptszDescriptiveName = TranslateT("Plugin Updater HTTP connections");
+ #endif
nlu.szSettingsModule = MODNAME;
hNetlibUser = Netlib_RegisterUser(&nlu);
}
@@ -125,7 +130,7 @@ int Get_CRC(unsigned char* buffer, ULONG bufsize) int CompareHashes(const ServListEntry *p1, const ServListEntry *p2)
{
- return wcsicmp(p1->m_name, p2->m_name);
+ return _wcsicmp(p1->m_name, p2->m_name);
}
bool ParseHashes(const wchar_t *ptszUrl, ptrW &baseUrl, SERVLIST &arHashes)
@@ -316,7 +321,9 @@ bool DownloadFile(FILEURL *pFileURL, HNETLIBCONN &nlc) void __stdcall OpenPluginOptions(void*)
{
- Options_Open(NULL, L"Plugins");
+ #if MIRANDA_VER >= 0x0A00
+ Options_Open(NULL, L"Plugins");
+ #endif
}
// FUNCTION: IsRunAsAdmin()
diff --git a/plugins/PluginUpdater/src/stdafx.h b/plugins/PluginUpdater/src/stdafx.h index 82fe43cc18..a621662ce5 100644 --- a/plugins/PluginUpdater/src/stdafx.h +++ b/plugins/PluginUpdater/src/stdafx.h @@ -39,7 +39,6 @@ Boston, MA 02111-1307, USA. #include <m_assocmgr.h>
#include <win2k.h>
#include <m_pluginupdater.h>
-#include <m_autobackups.h>
#include <m_folders.h>
@@ -47,7 +46,10 @@ Boston, MA 02111-1307, USA. #include "resource.h"
#if MIRANDA_VER < 0x0A00
-#include "Compat/compat.h"
+ #include <m_system_cpp.h>
+ #include "Compat/compat.h"
+#else
+ #include <m_autobackups.h>
#endif
#include "Notifications.h"
|