diff options
106 files changed, 379 insertions, 462 deletions
diff --git a/bin10/lib/mir_app.lib b/bin10/lib/mir_app.lib Binary files differindex ce0d8b07db..29880a94d1 100644 --- a/bin10/lib/mir_app.lib +++ b/bin10/lib/mir_app.lib diff --git a/bin10/lib/mir_app64.lib b/bin10/lib/mir_app64.lib Binary files differindex 03c4754582..89bfa8bed0 100644 --- a/bin10/lib/mir_app64.lib +++ b/bin10/lib/mir_app64.lib diff --git a/bin12/lib/mir_app.lib b/bin12/lib/mir_app.lib Binary files differindex ce0d8b07db..29880a94d1 100644 --- a/bin12/lib/mir_app.lib +++ b/bin12/lib/mir_app.lib diff --git a/bin12/lib/mir_app64.lib b/bin12/lib/mir_app64.lib Binary files differindex 03c4754582..89bfa8bed0 100644 --- a/bin12/lib/mir_app64.lib +++ b/bin12/lib/mir_app64.lib diff --git a/bin14/lib/mir_app.lib b/bin14/lib/mir_app.lib Binary files differindex ce0d8b07db..29880a94d1 100644 --- a/bin14/lib/mir_app.lib +++ b/bin14/lib/mir_app.lib diff --git a/bin14/lib/mir_app64.lib b/bin14/lib/mir_app64.lib Binary files differindex 03c4754582..89bfa8bed0 100644 --- a/bin14/lib/mir_app64.lib +++ b/bin14/lib/mir_app64.lib diff --git a/include/delphi/m_helpers.inc b/include/delphi/m_helpers.inc index 0c98ecd947..dd81e8e534 100644 --- a/include/delphi/m_helpers.inc +++ b/include/delphi/m_helpers.inc @@ -16,8 +16,6 @@ function CreateVersionStringPlugin(pluginInfo:PPluginInfoEx;buf:PAnsiChar):PAnsi function PLUGIN_MAKE_VERSION(a,b,c,d: Cardinal): int;
function PLUGIN_CMP_VERSION(verA: LongInt; verB: LongInt): int;
-procedure Netlib_Log(hNetLib: THANDLE; const sz: PAnsiChar);
-
function mir_hashstr (const key:PAnsiChar):uint; {inline;}
function mir_hashstrW(const key:PWideChar):uint; {inline;}
function lrtrim (str:PAnsiChar):PAnsiChar; {inline}
@@ -173,13 +171,6 @@ begin Inc(Result, (verA and $FF000000) - (verB and $FF000000));
end;
-procedure Netlib_Log(hNetLib: THANDLE; const sz: PAnsiChar);
- {$IFDEF AllowInline}inline;{$ENDIF}
-begin
- CallService(MS_NETLIB_LOG, hNetLib, lParam(sz));
-end;
-
-
function mir_hashstr(const key:PAnsiChar):uint; {inline;}
var
len:int;
diff --git a/include/delphi/m_netlib.inc b/include/delphi/m_netlib.inc index 3a9512cb49..7772113a94 100644 --- a/include/delphi/m_netlib.inc +++ b/include/delphi/m_netlib.inc @@ -187,7 +187,6 @@ type PNETLIBUSER = ^TNETLIBUSER;
TNETLIBUSER = record
- cbSize: int;
szSettingsModule: PAnsiChar; // used for DB settings and log, 'NL' stuff
szDescriptiveName: TChar; // shows a descriptive name for which different proxy settings can be defined
flags: dword; // see NUF_* constants above
@@ -293,10 +292,7 @@ type buffer : PByte; // contains the read data
end;
-const
{
- wParam : 0
- lParam : Pointer to an initalised TNETLIBUSER structure
Affects: Initialises the netlib for a set of connections, see notes
Returns: Returns a handle for future netlib calls, NULL on failure.
Notes : Netlib is loaded AFTER all plugins, thus a call to this service
@@ -311,8 +307,8 @@ const Version: v0.1.2.2+
Errors : ERROR_INVALID_PARAMETER, ERROR_OUTOFMEMORY, ERROR_DUP_NAME
}
- MS_NETLIB_REGISTERUSER:PAnsiChar = 'Netlib/RegisterUser';
+function Netlib_RegisterUser(pInfo:PNETLIBUSER) : THANDLE; stdcall; external AppDll;
{
wParam : HANDLE
@@ -326,10 +322,11 @@ const Version: v0.1.2.2+
Errors : ERROR_INVALID_PARAMETER
}
+
+const
MS_NETLIB_GETUSERSETTINGS:PAnsiChar = 'Netlib/GetUserSettings';
+
{
- wParam : HANDLE / SOCKET
- lParam : 0
Affects: Closes a handle, see notes
Returns: Returns [non zero] on success, NULL(0) on failure
Notes : All netlib handles should be closed once they're finished with,
@@ -681,8 +678,6 @@ const MS_NETLIB_GETMOREPACKETS:PAnsiChar = 'Netlib/GetMorePackets';
{
- wParam : HANDLE
- lParam : Pointer to null terminated string to uh, log.
Affect : Add a message to the log (if it's running) see notes
Returns: non zeror on success, NULL(0) on failure
Notes : Don't include \r\n or #13#10 it's not needed,
@@ -692,17 +687,9 @@ const if you want that.
Errors : ERROR_INVALID_PARAMETER
}
- MS_NETLIB_LOG:PAnsiChar = 'Netlib/Log';
- MS_NETLIB_LOGW:PAnsiChar = 'Netlib/LogW';
- {
- Sets a gateway polling timeout interval
- wParam=(WPARAM)(HANDLE)hConn
- lParam=(LPARAM)timeout
- Returns previous timeout value
- Errors: -1
- }
- MS_NETLIB_SETPOLLINGTIMEOUT:PAnsiChar = 'Netlib/SetPollingTimeout';
+function Netlib_Log(nlu:THANDLE; str:PAnsiChar) : int; stdcall; external AppDll;
+function Netlib_LogW(nlu:THANDLE; str:PWideChar) : int; stdcall; external AppDll;
{
Makes connection SSL
@@ -710,6 +697,8 @@ const lParam=0
Returns 0 on failure 1 on success
}
+
+const
MS_NETLIB_STARTSSL:PAnsiChar = 'Netlib/StartSsl';
type
@@ -719,7 +708,7 @@ type flags :int; // Reserved
end;
- const
+const
/////////////////////////////////////////////////////////////////////////////////////////
// Security providers (0.6+)
diff --git a/include/m_core.h b/include/m_core.h index 30ba841309..efd7e6ba7c 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -43,8 +43,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifdef MIR_APP_EXPORTS
#define MIR_APP_EXPORT __declspec(dllexport)
+ typedef struct NetlibUser* HNETLIBUSER;
#else
#define MIR_APP_EXPORT __declspec(dllimport)
+ DECLARE_HANDLE(HNETLIBUSER);
#endif
#define MIR_APP_DLL(T) MIR_APP_EXPORT T __stdcall
diff --git a/include/m_netlib.h b/include/m_netlib.h index 51b18adc48..99a728ec0a 100644 --- a/include/m_netlib.h +++ b/include/m_netlib.h @@ -46,9 +46,7 @@ struct NETLIBOPENCONNECTION; /////////////////////////////////////////////////////////////////////////////////////////
// Initialises the netlib for a set of connections
-// wParam = 0
-// lParam = (LPARAM)(NETLIBUSER*)&nu
-// Returns a HANDLE to be used for future netlib calls, NULL on failure
+// Returns a HNETLIBUSER to be used for future netlib calls, NULL on failure
// NOTE: Netlib is loaded after any plugins, so you need to wait until
// ME_SYSTEM_MODULESLOADED before calling this function
// Netlib settings are stored under the module szSettingsModule
@@ -66,7 +64,6 @@ typedef PBYTE (*NETLIBHTTPGATEWAYUNWRAPRECVPROC)(NETLIBHTTPREQUEST *nlhr, PBYTE struct NETLIBUSER
{
- int cbSize;
char *szSettingsModule; // used for db settings and log
union {
char *szDescriptiveName; // used in options dialog, already translated
@@ -88,8 +85,9 @@ struct NETLIBUSER #define NUF_NOOPTIONS 0x08 // don't create an options page for this. szDescriptiveName is never used.
#define NUF_HTTPCONNS 0x10 // at least some connections are made for HTTP communication. Enables the HTTP proxy option in options.
#define NUF_NOHTTPSOPTION 0x20 // disable the HTTPS proxy option in options. Use this if all communication is HTTP.
-#define NUF_UNICODE 0x40 // if set ptszDescriptiveName points to Unicode, otherwise it points to ANSI string
-#define MS_NETLIB_REGISTERUSER "Netlib/RegisterUser"
+#define NUF_UNICODE 0x40 // if set ptszDescriptiveName points to Unicode, otherwise it points to ANSI string
+
+EXTERN_C MIR_APP_DLL(HNETLIBUSER) Netlib_RegisterUser(const NETLIBUSER *pDescr);
/////////////////////////////////////////////////////////////////////////////////////////
// Assign a Netlib user handle a set of dynamic HTTP headers to be used with all
@@ -735,17 +733,6 @@ struct NETLIBPACKETRECVER #define MS_NETLIB_GETMOREPACKETS "Netlib/GetMorePackets"
/////////////////////////////////////////////////////////////////////////////////////////
-// Add a message to the log (if it's running)
-// wParam = (WPARAM)(HANDLE)hUser
-// lParam = (LPARAM)(const char *)szMessage
-// Returns nonzero on success, 0 on failure (!! this is different to most of the rest of Miranda, but consistent with netlib)
-// Do not include a final line ending in szMessage.
-// Errors: ERROR_INVALID_PARAMETER
-
-#define MS_NETLIB_LOG "Netlib/Log"
-#define MS_NETLIB_LOGW "Netlib/LogW"
-
-/////////////////////////////////////////////////////////////////////////////////////////
// Sets a gateway polling timeout interval
// wParam = (WPARAM)(HANDLE)hConn
// lParam = (LPARAM)timeout
@@ -770,35 +757,13 @@ struct NETLIBSSL };
/////////////////////////////////////////////////////////////////////////////////////////
-// here's a handy piece of code to let you log using printf-style specifiers:
-// #include <stdarg.h> and <stdio.h> before including this header in order to
-// use it.
-
-#if defined va_start && (defined _STDIO_DEFINED || defined _STDIO_H_ || defined _INC_STDIO) && (!defined NETLIB_NOLOGGING)
-#pragma warning(disable:4505)
+// netlib log funcitons
-__inline INT_PTR Netlib_Logf(HANDLE hUser, const char *fmt, ...)
-{
- va_list va;
- va_start(va, fmt);
- char szText[1024];
- mir_vsnprintf(szText, _countof(szText), fmt, va);
- va_end(va);
- return CallService(MS_NETLIB_LOG, (WPARAM)hUser, (LPARAM)szText);
-}
-
-__inline INT_PTR Netlib_LogfW(HANDLE hUser, const wchar_t *fmt, ...)
-{
- va_list va;
- va_start(va, fmt);
- wchar_t szText[1024];
- mir_vsnwprintf(szText, _countof(szText), fmt, va);
- va_end(va);
- return CallService(MS_NETLIB_LOGW, (WPARAM)hUser, (LPARAM)szText);
-}
+EXTERN_C MIR_APP_DLL(int) Netlib_Log(HNETLIBUSER hUser, const char *pszStr);
+EXTERN_C MIR_APP_DLL(int) Netlib_LogW(HNETLIBUSER hUser, const wchar_t *pwszStr);
-#define Netlib_LogfT Netlib_LogfW
-#endif // defined va_start
+EXTERN_C MIR_APP_DLL(int) Netlib_Logf(HNETLIBUSER hUser, const char *fmt, ...);
+EXTERN_C MIR_APP_DLL(int) Netlib_LogfW(HNETLIBUSER hUser, const wchar_t *fmt, ...);
/////////////////////////////////////////////////////////////////////////////////////////
// Security providers (0.6+)
diff --git a/include/m_protoint.h b/include/m_protoint.h index 0f33c206b0..bef636a157 100644 --- a/include/m_protoint.h +++ b/include/m_protoint.h @@ -89,10 +89,10 @@ struct MIR_APP_EXPORT PROTO_INTERFACE : public MZeroedObject m_iDesiredStatus, // status to be set after logging in
m_iXStatus, // extanded status
m_iVersion; // version 2 or higher designate support of Unicode services
- wchar_t* m_tszUserName; // human readable protocol's name
+ wchar_t* m_tszUserName; // human readable protocol's name
char* m_szModuleName; // internal protocol name, also its database module name
HANDLE m_hProtoIcon; // icon to be displayed in the account manager
- HANDLE m_hNetlibUser; // network agent
+ HNETLIBUSER m_hNetlibUser; // network agent
MWindowList m_hWindowList; // list of all windows which belong to this protocol's instance
HGENMENU m_hMainMenuItem; // if protocol menus are displayed in the main menu, this is the root
diff --git a/plugins/ClientChangeNotify/src/stdafx.h b/plugins/ClientChangeNotify/src/stdafx.h index 1b8d6404f6..3fae08172e 100644 --- a/plugins/ClientChangeNotify/src/stdafx.h +++ b/plugins/ClientChangeNotify/src/stdafx.h @@ -28,6 +28,7 @@ #include <stdlib.h>
#include <crtdbg.h>
#include <shellapi.h>
+#include <WinSock.h>
#include <commdlg.h>
#include "newpluginapi.h"
@@ -47,6 +48,7 @@ #include "m_genmenu.h"
#include "win2k.h"
#include "m_metacontacts.h"
+#include "m_netlib.h"
#include "m_fingerprint.h"
@@ -118,7 +120,7 @@ static __inline CString LogMessage(const char *Format, ...) va_start(va, Format);
mir_vsnprintf(szText + _countof(LOG_PREFIX)-1, _countof(szText) - (_countof(LOG_PREFIX)-1), Format, va);
va_end(va);
- CallService(MS_NETLIB_LOG, NULL, (LPARAM)szText);
+ Netlib_Log(NULL, szText);
return CString(szText);
}
diff --git a/plugins/CrashDumper/src/upload.cpp b/plugins/CrashDumper/src/upload.cpp index dd7583cf79..dc95363449 100644 --- a/plugins/CrashDumper/src/upload.cpp +++ b/plugins/CrashDumper/src/upload.cpp @@ -214,11 +214,11 @@ void __cdecl VersionInfoUploadThread(void* arg) void UploadInit(void)
{
- NETLIBUSER nlu = { sizeof(nlu) };
+ NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_NOHTTPSOPTION | NUF_UNICODE;
nlu.szSettingsModule = (char*)PluginName;
nlu.ptszDescriptiveName = TranslateT("Crash Dumper HTTP connections");
- hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ hNetlibUser = Netlib_RegisterUser(&nlu);
}
void UploadClose(void)
diff --git a/plugins/CryptoPP/src/commonheaders.h b/plugins/CryptoPP/src/commonheaders.h index 3da70a4494..ff27ce934c 100644 --- a/plugins/CryptoPP/src/commonheaders.h +++ b/plugins/CryptoPP/src/commonheaders.h @@ -74,7 +74,7 @@ std::string base64decode(const std::string&); std::string base64decode(const char *);
#if defined(_DEBUG) || defined(NETLIB_LOG)
-extern HANDLE hNetlibUser;
+extern HNETLIBUSER hNetlibUser;
void InitNetlib();
void DeinitNetlib();
int Sent_NetLog(const char *,...);
diff --git a/plugins/CryptoPP/src/main.cpp b/plugins/CryptoPP/src/main.cpp index 62a75b02b3..3b2c814f29 100644 --- a/plugins/CryptoPP/src/main.cpp +++ b/plugins/CryptoPP/src/main.cpp @@ -115,17 +115,15 @@ size_t rtrim(LPCSTR str) #if defined(_DEBUG) || defined(NETLIB_LOG)
-HANDLE hNetlibUser;
+HNETLIBUSER hNetlibUser;
void InitNetlib()
{
- NETLIBUSER nl_user;
- memset(&nl_user, 0, sizeof(nl_user));
- nl_user.cbSize = sizeof(nl_user);
+ NETLIBUSER nl_user = {};
nl_user.szSettingsModule = (LPSTR)szModuleName;
nl_user.szDescriptiveName = (LPSTR)szModuleName;
nl_user.flags = NUF_NOOPTIONS;
- hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nl_user);
+ hNetlibUser = Netlib_RegisterUser(&nl_user);
}
void DeinitNetlib()
@@ -142,7 +140,7 @@ int Sent_NetLog(const char *fmt, ...) mir_vsnprintf(szText, sizeof(szText), fmt, va);
va_end(va);
if (hNetlibUser)
- return CallService(MS_NETLIB_LOG, (WPARAM)hNetlibUser, (LPARAM)szText);
+ return Netlib_Log(hNetlibUser, szText);
return 0;
}
#endif
diff --git a/plugins/Dbx_mdb/src/dbintf.cpp b/plugins/Dbx_mdb/src/dbintf.cpp index 36a91d650e..1d82a7fe58 100644 --- a/plugins/Dbx_mdb/src/dbintf.cpp +++ b/plugins/Dbx_mdb/src/dbintf.cpp @@ -242,7 +242,7 @@ EXTERN_C void LMDB_Log(const char *fmt, ...) {
va_list args;
va_start(args, fmt);
- CallService(MS_NETLIB_LOG, 0, (LPARAM)(CMStringA().FormatV(fmt, args)));
+ Netlib_Log(0, CMStringA().FormatV(fmt, args));
va_end(args);
}
diff --git a/plugins/Dropbox/src/dropbox.h b/plugins/Dropbox/src/dropbox.h index b6dcb340e6..32a58691ec 100644 --- a/plugins/Dropbox/src/dropbox.h +++ b/plugins/Dropbox/src/dropbox.h @@ -26,7 +26,7 @@ public: virtual ~CDropbox();
private:
- HANDLE hNetlibConnection;
+ HNETLIBUSER hNetlibConnection;
ULONG hMessageProcess;
HANDLE hUploadedEventHook;
diff --git a/plugins/Dropbox/src/dropbox_events.cpp b/plugins/Dropbox/src/dropbox_events.cpp index 0d5c915006..0384bb127c 100644 --- a/plugins/Dropbox/src/dropbox_events.cpp +++ b/plugins/Dropbox/src/dropbox_events.cpp @@ -23,11 +23,11 @@ int CDropbox::OnModulesLoaded(WPARAM, LPARAM) HookEventObj(ME_MSG_WINDOWEVENT, GlobalEvent<&CDropbox::OnSrmmWindowOpened>, this);
HookEventObj(ME_FILEDLG_CANCELED, GlobalEvent<&CDropbox::OnFileDialogCancelled>, this);
- NETLIBUSER nlu = { sizeof(nlu) };
+ NETLIBUSER nlu = {};
nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE;
nlu.szSettingsModule = MODULE;
nlu.ptszDescriptiveName = L"Dropbox";
- hNetlibConnection = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ hNetlibConnection = Netlib_RegisterUser(&nlu);
GetDefaultContact();
diff --git a/plugins/HTTPServer/src/Glob.h b/plugins/HTTPServer/src/Glob.h index c556f73786..7d21925204 100644 --- a/plugins/HTTPServer/src/Glob.h +++ b/plugins/HTTPServer/src/Glob.h @@ -60,7 +60,7 @@ using namespace std; extern HINSTANCE hInstance;
-extern HANDLE hNetlibUser;
+extern HNETLIBUSER hNetlibUser;
extern bool bShutdownInProgress;
bool bWriteConfigurationFile();
diff --git a/plugins/HTTPServer/src/main.cpp b/plugins/HTTPServer/src/main.cpp index 3f52469e90..1f9c89dc22 100644 --- a/plugins/HTTPServer/src/main.cpp +++ b/plugins/HTTPServer/src/main.cpp @@ -45,7 +45,7 @@ const char* pszDefaultShares[] = { void ConnectionOpen(HANDLE hNewConnection, DWORD dwRemoteIP);
int PreShutdown(WPARAM /*wparam*/, LPARAM /*lparam*/);
-HANDLE hNetlibUser;
+HNETLIBUSER hNetlibUser;
HANDLE hDirectBoundPort;
HINSTANCE hInstance = NULL;
@@ -740,12 +740,11 @@ int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/) bWriteConfigurationFile();
}
- NETLIBUSER nlu = { 0 };
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_INCOMING;
nlu.szSettingsModule = MODULE;
nlu.szDescriptiveName = Translate("HTTP Server");
- hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)& nlu);
+ hNetlibUser = Netlib_RegisterUser(& nlu);
if (!hNetlibUser) {
MessageBox(NULL, "Failed to register NetLib user", MSG_BOX_TITEL, MB_OK);
return 0;
diff --git a/plugins/LotusNotify/src/debug.cpp b/plugins/LotusNotify/src/debug.cpp index 8acf5c0a63..e814d6f508 100644 --- a/plugins/LotusNotify/src/debug.cpp +++ b/plugins/LotusNotify/src/debug.cpp @@ -1,16 +1,15 @@ #include "stdafx.h"
#include "debug.h"
-HANDLE netlibHandle;
+HNETLIBUSER netlibHandle;
void logRegister(){
// Register netlib user for logging function
- NETLIBUSER nlu = { 0 };
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = {};
nlu.flags = NUF_UNICODE | NUF_NOOPTIONS;
nlu.szSettingsModule = PLUGINNAME;
nlu.ptszDescriptiveName = mir_a2u(PLUGINNAME);
- netlibHandle = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ netlibHandle = Netlib_RegisterUser(&nlu);
}
void logUnregister(){
@@ -21,7 +20,7 @@ void logUnregister(){ void log(const wchar_t* szText){
if (netlibHandle) {
- CallService(MS_NETLIB_LOGW, (WPARAM)netlibHandle, (LPARAM)szText);
+ Netlib_LogW(netlibHandle, szText);
}
#ifdef _DEBUG
diff --git a/plugins/MirFox/src/MirandaUtils.cpp b/plugins/MirFox/src/MirandaUtils.cpp index dfaf7d73f0..4ce2bf8165 100644 --- a/plugins/MirFox/src/MirandaUtils.cpp +++ b/plugins/MirFox/src/MirandaUtils.cpp @@ -20,7 +20,7 @@ void MirandaUtils::netlibLog(const wchar_t* szText){ void MirandaUtils::netlibLog_int(const wchar_t* szText){
if (netlibHandle) {
- CallService(MS_NETLIB_LOGW, (WPARAM)netlibHandle, (LPARAM)szText);
+ Netlib_LogfW(netlibHandle, szText);
}
#ifdef _DEBUG
OutputDebugString(szText);
@@ -29,13 +29,12 @@ void MirandaUtils::netlibLog_int(const wchar_t* szText){ void MirandaUtils::netlibRegister(){
// Register netlib user for logging function
- NETLIBUSER nlu = { 0 };
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = {};
nlu.flags = NUF_UNICODE | NUF_NOOPTIONS;
nlu.szSettingsModule = PLUGIN_DB_ID;
nlu.ptszDescriptiveName = TranslateT("MirFox log");
- netlibHandle = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ netlibHandle = Netlib_RegisterUser(&nlu);
}
void MirandaUtils::netlibUnregister(){
diff --git a/plugins/MirFox/src/MirandaUtils.h b/plugins/MirFox/src/MirandaUtils.h index f08b90da5f..47ee0ed1db 100644 --- a/plugins/MirFox/src/MirandaUtils.h +++ b/plugins/MirFox/src/MirandaUtils.h @@ -91,7 +91,7 @@ private: static void ForceForegroundWindow(HWND hWnd);
- HANDLE netlibHandle;
+ HNETLIBUSER netlibHandle;
std::wstring profileName;
std::wstring displayName;
diff --git a/plugins/MirLua/src/main.cpp b/plugins/MirLua/src/main.cpp index ce2d3aa589..0539404a7d 100644 --- a/plugins/MirLua/src/main.cpp +++ b/plugins/MirLua/src/main.cpp @@ -9,7 +9,7 @@ CMLua *g_mLua; HANDLE g_hCLibsFolder;
HANDLE g_hScriptsFolder;
-HANDLE hNetlib = NULL;
+HNETLIBUSER hNetlib = NULL;
PLUGININFOEX pluginInfo =
{
@@ -60,12 +60,11 @@ extern "C" int __declspec(dllexport) Load(void) HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
- NETLIBUSER nlu = { 0 };
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = {};
nlu.flags = NUF_NOOPTIONS;
nlu.szDescriptiveName = MODULE;
nlu.szSettingsModule = MODULE;
- hNetlib = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ hNetlib = Netlib_RegisterUser(&nlu);
PROTOCOLDESCRIPTOR pd = { 0 };
pd.cbSize = sizeof(pd);
diff --git a/plugins/MirLua/src/mlua_utils.cpp b/plugins/MirLua/src/mlua_utils.cpp index 7323755ea5..5c84fb5c74 100644 --- a/plugins/MirLua/src/mlua_utils.cpp +++ b/plugins/MirLua/src/mlua_utils.cpp @@ -4,7 +4,7 @@ void Log(const char *format, ...) {
va_list args;
va_start(args, format);
- CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)(CMStringA().FormatV(format, args)));
+ Netlib_Log(hNetlib, CMStringA().FormatV(format, args));
va_end(args);
}
@@ -12,7 +12,7 @@ void Log(const wchar_t *format, ...) {
va_list args;
va_start(args, format);
- CallService(MS_NETLIB_LOGW, (WPARAM)hNetlib, (LPARAM)(CMStringW().FormatV(format, args)));
+ Netlib_LogW(hNetlib, CMStringW().FormatV(format, args));
va_end(args);
}
diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h index 645e30c906..dda365dd82 100644 --- a/plugins/MirLua/src/stdafx.h +++ b/plugins/MirLua/src/stdafx.h @@ -98,7 +98,7 @@ LUAMOD_API int (luaopen_m_sounds)(lua_State *L); /* utils */
-extern HANDLE hNetlib;
+extern HNETLIBUSER hNetlib;
void Log(const char *format, ...);
void Log(const wchar_t *format, ...);
diff --git a/plugins/NewAwaySysMod/src/stdafx.h b/plugins/NewAwaySysMod/src/stdafx.h index 1c2966b9be..466f31ffd9 100644 --- a/plugins/NewAwaySysMod/src/stdafx.h +++ b/plugins/NewAwaySysMod/src/stdafx.h @@ -321,7 +321,7 @@ static __inline int LogMessage(const char *Format, ...) va_start(va, Format);
mir_vsnprintf(szText + (_countof(LOG_PREFIX) - 1), sizeof(szText) - (_countof(LOG_PREFIX) - 1), Format, va);
va_end(va);
- return CallService(MS_NETLIB_LOG, NULL, (LPARAM)szText);
+ return Netlib_Log(NULL, szText);
}
__inline int CallAllowedPS_SETAWAYMSG(const char *szProto, int iMode, const wchar_t *szMsg)
diff --git a/plugins/NewsAggregator/Src/CheckFeed.cpp b/plugins/NewsAggregator/Src/CheckFeed.cpp index 96d80c6298..7435337b2d 100644 --- a/plugins/NewsAggregator/Src/CheckFeed.cpp +++ b/plugins/NewsAggregator/Src/CheckFeed.cpp @@ -21,7 +21,7 @@ Boston, MA 02111-1307, USA. LPCTSTR CheckFeed(wchar_t *tszURL, HWND hwndDlg)
{
- Netlib_LogfT(hNetlibUser, L"Started validating feed %s.", tszURL);
+ Netlib_LogfW(hNetlibUser, L"Started validating feed %s.", tszURL);
char *szData = NULL;
GetNewsData(tszURL, &szData, NULL, hwndDlg);
if (szData) {
@@ -91,7 +91,7 @@ LPCTSTR CheckFeed(wchar_t *tszURL, HWND hwndDlg) }
xmlDestroyNode(hXml);
}
- Netlib_LogfT(hNetlibUser, L"%s is not a valid feed's address.", tszURL);
+ Netlib_LogfW(hNetlibUser, L"%s is not a valid feed's address.", tszURL);
wchar_t mes[MAX_PATH];
mir_snwprintf(mes, TranslateT("%s\nis not a valid feed's address."), tszURL);
MessageBox(hwndDlg, mes, TranslateT("News Aggregator"), MB_OK | MB_ICONERROR);
@@ -187,7 +187,7 @@ void CheckCurrentFeed(MCONTACT hContact) if (szURL == NULL)
return;
- Netlib_LogfT(hNetlibUser, L"Started checking feed %s.", szURL);
+ Netlib_LogfW(hNetlibUser, L"Started checking feed %s.", szURL);
char *szData = NULL;
GetNewsData(szURL, &szData, hContact, NULL);
diff --git a/plugins/NewsAggregator/Src/Utils.cpp b/plugins/NewsAggregator/Src/Utils.cpp index dc7302c2e3..0f16b5664e 100644 --- a/plugins/NewsAggregator/Src/Utils.cpp +++ b/plugins/NewsAggregator/Src/Utils.cpp @@ -19,7 +19,8 @@ Boston, MA 02111-1307, USA. #include "stdafx.h"
-HANDLE hNetlibUser = NULL, hNetlibHttp;
+HNETLIBUSER hNetlibUser = NULL;
+HANDLE hNetlibHttp;
bool UpdateListFlag = FALSE;
bool IsMyContact(MCONTACT hContact)
@@ -30,11 +31,11 @@ bool IsMyContact(MCONTACT hContact) void NetlibInit()
{
- NETLIBUSER nlu = { sizeof(nlu) };
+ NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_UNICODE; // | NUF_HTTPGATEWAY;
nlu.ptszDescriptiveName = TranslateT("NewsAggregator HTTP connection");
nlu.szSettingsModule = MODULE;
- hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ hNetlibUser = Netlib_RegisterUser(&nlu);
}
void NetlibUnInit()
@@ -45,7 +46,7 @@ void NetlibUnInit() void GetNewsData(wchar_t *tszUrl, char **szData, MCONTACT hContact, HWND hwndDlg)
{
- Netlib_LogfT(hNetlibUser, L"Getting feed data %s.", tszUrl);
+ Netlib_LogfW(hNetlibUser, L"Getting feed data %s.", tszUrl);
NETLIBHTTPREQUEST nlhr = { 0 };
// initialize the netlib request
@@ -84,26 +85,25 @@ void GetNewsData(wchar_t *tszUrl, char **szData, MCONTACT hContact, HWND hwndDlg if (nlhrReply) {
// if the recieved code is 200 OK
if (nlhrReply->resultCode == 200 && nlhrReply->dataLength > 0) {
- Netlib_LogfT(hNetlibUser, L"Code 200: Succeeded getting feed data %s.", tszUrl);
+ Netlib_LogfW(hNetlibUser, L"Code 200: Succeeded getting feed data %s.", tszUrl);
// allocate memory and save the retrieved data
*szData = (char *)mir_alloc((size_t)(nlhrReply->dataLength + 2));
memcpy(*szData, nlhrReply->pData, (size_t)nlhrReply->dataLength);
(*szData)[nlhrReply->dataLength] = 0;
}
else if (nlhrReply->resultCode == 401) {
- Netlib_LogfT(hNetlibUser, L"Code 401: feed %s needs auth data.", tszUrl);
+ Netlib_LogfW(hNetlibUser, L"Code 401: feed %s needs auth data.", tszUrl);
ItemInfo SelItem = { 0 };
SelItem.hwndList = hwndDlg;
SelItem.hContact = hContact;
if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_AUTHENTICATION), hwndDlg, AuthenticationProc, (LPARAM)&SelItem) == IDOK)
GetNewsData(tszUrl, szData, hContact, hwndDlg);
}
- else
- Netlib_LogfT(hNetlibUser, L"Code %d: Failed getting feed data %s.", nlhrReply->resultCode, tszUrl);
+ else Netlib_LogfW(hNetlibUser, L"Code %d: Failed getting feed data %s.", nlhrReply->resultCode, tszUrl);
+
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
}
- else
- Netlib_LogfT(hNetlibUser, L"Failed getting feed data %s, no response.", tszUrl);
+ else Netlib_LogfW(hNetlibUser, L"Failed getting feed data %s, no response.", tszUrl);
mir_free(szUrl);
}
diff --git a/plugins/NewsAggregator/Src/stdafx.h b/plugins/NewsAggregator/Src/stdafx.h index 2636e380b0..c1091c1f63 100644 --- a/plugins/NewsAggregator/Src/stdafx.h +++ b/plugins/NewsAggregator/Src/stdafx.h @@ -57,7 +57,7 @@ Boston, MA 02111-1307, USA. extern HINSTANCE hInst;
extern HWND hAddFeedDlg;
extern MWindowList hChangeFeedDlgList;
-extern HANDLE hNetlibUser;
+extern HNETLIBUSER hNetlibUser;
extern UINT_PTR timerId;
// check if Feeds is currently updating
extern bool ThreadRunning;
diff --git a/plugins/Non-IM Contact/src/http.cpp b/plugins/Non-IM Contact/src/http.cpp index 9ffaf1383d..e63521df09 100644 --- a/plugins/Non-IM Contact/src/http.cpp +++ b/plugins/Non-IM Contact/src/http.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. char *szInfo;
char *szData;
-HANDLE hNetlibUser;
+HNETLIBUSER hNetlibUser;
// function to download webpage from the internet
// szUrl = URL of the webpage to be retrieved
@@ -73,7 +73,7 @@ int InternetDownloadFile(char *szUrl) }
}
// log the new url into netlib log
- CallService(MS_NETLIB_LOG, (WPARAM)hNetlibUser, (LPARAM)szData);
+ Netlib_Log(hNetlibUser, szData);
}
}
// if the data does not downloaded successfully (ie. disconnected), then return 1 as error code
@@ -92,10 +92,9 @@ int InternetDownloadFile(char *szUrl) void NetlibInit()
{
- NETLIBUSER nlu = { 0 };
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_NOHTTPSOPTION | NUF_UNICODE;
nlu.szSettingsModule = MODNAME;
nlu.ptszDescriptiveName = TranslateT("Non-IM Contacts");
- hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ hNetlibUser = Netlib_RegisterUser(&nlu);
}
diff --git a/plugins/Non-IM Contact/src/stdafx.h b/plugins/Non-IM Contact/src/stdafx.h index dcacf5841c..ce265a31bd 100644 --- a/plugins/Non-IM Contact/src/stdafx.h +++ b/plugins/Non-IM Contact/src/stdafx.h @@ -116,7 +116,7 @@ void NetlibInit(); int InternetDownloadFile (CHAR *szUrl);
extern char *szInfo;
extern char *szData;
-extern HANDLE hNetlibUser;
+extern HNETLIBUSER hNetlibUser;
#endif
diff --git a/plugins/PackUpdater/Src/Utils.cpp b/plugins/PackUpdater/Src/Utils.cpp index 59ee647c3a..84827faa0b 100644 --- a/plugins/PackUpdater/Src/Utils.cpp +++ b/plugins/PackUpdater/Src/Utils.cpp @@ -48,12 +48,11 @@ void IcoLibInit() BOOL NetlibInit()
{
- NETLIBUSER nlu = { 0 };
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_UNICODE; // | NUF_HTTPGATEWAY;
nlu.ptszDescriptiveName = TranslateT("Pack Updater HTTP connection");
nlu.szSettingsModule = MODNAME;
- hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ hNetlibUser = Netlib_RegisterUser(&nlu);
return hNetlibUser != NULL;
}
diff --git a/plugins/PasteIt/src/PasteIt.cpp b/plugins/PasteIt/src/PasteIt.cpp index c36034cd26..6c0ca19da0 100644 --- a/plugins/PasteIt/src/PasteIt.cpp +++ b/plugins/PasteIt/src/PasteIt.cpp @@ -22,8 +22,8 @@ PasteToWeb* pasteToWebs[PasteToWeb::pages]; std::map<MCONTACT, HWND>* contactWindows;
DWORD gMirandaVersion;
+HNETLIBUSER g_hNetlibUser;
HANDLE hModulesLoaded, hTabsrmmButtonPressed;
-HANDLE g_hNetlibUser;
HANDLE hPrebuildContactMenu;
HANDLE hServiceContactMenu;
HGENMENU hContactMenu;
@@ -392,12 +392,11 @@ extern "C" int __declspec(dllexport) Load(void) Icon_Register(hInst, LPGEN("Paste It"), &icon, 1);
- NETLIBUSER nlu = { 0 };
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = {};
nlu.flags = NUF_UNICODE | NUF_OUTGOING | NUF_HTTPCONNS;
nlu.szSettingsModule = MODULE;
nlu.ptszDescriptiveName = TranslateT("Paste It HTTP connections");
- g_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ g_hNetlibUser = Netlib_RegisterUser(&nlu);
pasteToWebs[0] = new PasteToWeb1();
pasteToWebs[0]->pageIndex = 0;
diff --git a/plugins/PasteIt/src/PasteToWeb.cpp b/plugins/PasteIt/src/PasteToWeb.cpp index 3e62035de1..ec6cdd9878 100644 --- a/plugins/PasteIt/src/PasteToWeb.cpp +++ b/plugins/PasteIt/src/PasteToWeb.cpp @@ -498,7 +498,7 @@ void PasteToWeb::FromFile(std::wstring file) }
}
-extern HANDLE g_hNetlibUser;
+extern HNETLIBUSER g_hNetlibUser;
wchar_t* PasteToWeb::SendToWeb(char* url, std::map<std::string, std::string>& headers, std::wstring content)
{
diff --git a/plugins/Ping/src/ping.cpp b/plugins/Ping/src/ping.cpp index 8c7f9497ab..45096e79c7 100644 --- a/plugins/Ping/src/ping.cpp +++ b/plugins/Ping/src/ping.cpp @@ -4,7 +4,7 @@ CLIST_INTERFACE *pcli; HINSTANCE hInst;
int hLangpack = 0;
-HANDLE hNetlibUser = 0;
+HNETLIBUSER hNetlibUser = 0;
HANDLE hFillListEvent = 0;
bool use_raw_ping = true;
@@ -83,8 +83,7 @@ int OnShutdown(WPARAM, LPARAM) { int OnModulesLoaded(WPARAM, LPARAM)
{
- NETLIBUSER nl_user = { 0 };
- nl_user.cbSize = sizeof(nl_user);
+ NETLIBUSER nl_user = {};
nl_user.szSettingsModule = PLUG;
nl_user.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE;
nl_user.ptszDescriptiveName = TranslateT("Ping Plugin");
@@ -94,7 +93,7 @@ int OnModulesLoaded(WPARAM, LPARAM) nl_user.pfnHttpGatewayWrapSend = 0;
nl_user.pfnHttpGatewayUnwrapRecv = 0;
- hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nl_user);
+ hNetlibUser = Netlib_RegisterUser(&nl_user);
InitUtils();
diff --git a/plugins/Ping/src/stdafx.h b/plugins/Ping/src/stdafx.h index 1e92a443d8..7bdfa5be69 100644 --- a/plugins/Ping/src/stdafx.h +++ b/plugins/Ping/src/stdafx.h @@ -107,7 +107,7 @@ typedef std::list<PINGADDRESS> PINGLIST; typedef std::list<PINGADDRESS>::iterator pinglist_it;
-extern HANDLE hNetlibUser;
+extern HNETLIBUSER hNetlibUser;
extern HINSTANCE hInst;
extern bool use_raw_ping;
diff --git a/plugins/PluginUpdater/src/DlgListNew.cpp b/plugins/PluginUpdater/src/DlgListNew.cpp index dab99d6d36..9706ea2af1 100644 --- a/plugins/PluginUpdater/src/DlgListNew.cpp +++ b/plugins/PluginUpdater/src/DlgListNew.cpp @@ -368,7 +368,7 @@ static FILEINFO* ServerEntryToFileInfo(const ServListEntry &hash, const wchar_t* *tp++ = '/';
FileInfo->File.CRCsum = hash.m_crc;
// Load list of checked Plugins from database
- Netlib_LogfT(hNetlibUser, L"File %s found", FileInfo->tszOldName);
+ Netlib_LogfW(hNetlibUser, L"File %s found", FileInfo->tszOldName);
FileInfo->bEnabled = db_get_b(NULL, DB_MODULE_NEW_FILES, _T2A(FileInfo->tszOldName)) != 0;
return FileInfo;
}
diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp index 9f4cb5cf32..3cc172fca8 100644 --- a/plugins/PluginUpdater/src/DlgUpdate.cpp +++ b/plugins/PluginUpdater/src/DlgUpdate.cpp @@ -641,7 +641,7 @@ static int ScanFolder(const wchar_t *tszFolder, size_t cbBaseLen, const wchar_t if (hFind == INVALID_HANDLE_VALUE)
return 0;
- Netlib_LogfT(hNetlibUser,L"Scanning folder %s", tszFolder);
+ Netlib_LogfW(hNetlibUser,L"Scanning folder %s", tszFolder);
int count = 0;
do {
@@ -656,7 +656,7 @@ static int ScanFolder(const wchar_t *tszFolder, size_t cbBaseLen, const wchar_t // calculate the current file's relative name and store it into tszNewName
wchar_t tszNewName[MAX_PATH];
if (CheckFileRename(ffd.cFileName, tszNewName)) {
- Netlib_LogfT(hNetlibUser, L"File %s will be renamed to %s.", ffd.cFileName, tszNewName);
+ Netlib_LogfW(hNetlibUser, L"File %s will be renamed to %s.", ffd.cFileName, tszNewName);
// Yes, we need the old file name, because this will be hashed later
mir_snwprintf(tszBuf, L"%s\\%s", tszFolder, ffd.cFileName);
}
@@ -684,7 +684,7 @@ static int ScanFolder(const wchar_t *tszFolder, size_t cbBaseLen, const wchar_t if (item == NULL) {
wchar_t *p = wcsrchr(tszNewName, '.');
if (p[-1] != 'w' && p[-1] != 'W') {
- Netlib_LogfT(hNetlibUser, L"File %s: Not found on server, skipping", ffd.cFileName);
+ Netlib_LogfW(hNetlibUser, L"File %s: Not found on server, skipping", ffd.cFileName);
continue;
}
@@ -692,7 +692,7 @@ static int ScanFolder(const wchar_t *tszFolder, size_t cbBaseLen, const wchar_t int iPos = int(p - tszNewName) - 1;
strdelw(p - 1, 1);
if ((item = hashes.find((ServListEntry*)&pName)) == NULL) {
- Netlib_LogfT(hNetlibUser, L"File %s: Not found on server, skipping", ffd.cFileName);
+ Netlib_LogfW(hNetlibUser, L"File %s: Not found on server, skipping", ffd.cFileName);
continue;
}
@@ -708,11 +708,11 @@ static int ScanFolder(const wchar_t *tszFolder, size_t cbBaseLen, const wchar_t CalculateModuleHash(tszBuf, szMyHash);
// hashes are the same, skipping
if (strcmp(szMyHash, item->m_szHash) == 0) {
- Netlib_LogfT(hNetlibUser, L"File %s: Already up-to-date, skipping", ffd.cFileName);
+ Netlib_LogfW(hNetlibUser, L"File %s: Already up-to-date, skipping", ffd.cFileName);
continue;
}
else
- Netlib_LogfT(hNetlibUser, L"File %s: Update available", ffd.cFileName);
+ Netlib_LogfW(hNetlibUser, L"File %s: Update available", ffd.cFileName);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
@@ -720,7 +720,7 @@ static int ScanFolder(const wchar_t *tszFolder, size_t cbBaseLen, const wchar_t }
}
else
- Netlib_LogfT(hNetlibUser, L"File %s: Forcing redownload", ffd.cFileName);
+ Netlib_LogfW(hNetlibUser, L"File %s: Forcing redownload", ffd.cFileName);
#endif
ptszUrl = item->m_name;
@@ -728,7 +728,7 @@ static int ScanFolder(const wchar_t *tszFolder, size_t cbBaseLen, const wchar_t }
else {
// file was marked for deletion, add it to the list anyway
- Netlib_LogfT(hNetlibUser, L"File %s: Marked for deletion", ffd.cFileName);
+ Netlib_LogfW(hNetlibUser, L"File %s: Marked for deletion", ffd.cFileName);
ptszUrl = L"";
MyCRC = 0;
}
@@ -778,7 +778,7 @@ static int ScanFolder(const wchar_t *tszFolder, size_t cbBaseLen, const wchar_t // Thread checks for updates
static void CheckUpdates(void *)
{
- Netlib_LogfT(hNetlibUser, L"Checking for updates");
+ Netlib_LogfW(hNetlibUser, L"Checking for updates");
Thread_SetName("PluginUpdater: CheckUpdates");
wchar_t tszTempPath[MAX_PATH];
@@ -841,7 +841,7 @@ void UninitCheck() // menu item command
static INT_PTR MenuCommand(WPARAM, LPARAM)
{
- Netlib_LogfT(hNetlibUser, L"Update started manually!");
+ Netlib_LogfW(hNetlibUser, L"Update started manually!");
DoCheck(false);
return 0;
}
@@ -867,7 +867,7 @@ void CheckUpdateOnStartup() if ((now - was) < 86400)
return;
}
- Netlib_LogfT(hNetlibUser, L"Update on startup started!");
+ Netlib_LogfW(hNetlibUser, L"Update on startup started!");
DoCheck();
}
}
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index 6513d66218..7e2555d86e 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -19,7 +19,8 @@ Boston, MA 02111-1307, USA. #include "stdafx.h"
-HANDLE hNetlibUser = NULL, hPipe = NULL;
+HNETLIBUSER hNetlibUser = NULL;
+HANDLE hPipe = NULL;
/////////////////////////////////////////////////////////////////////////////////////
void LoadOptions()
@@ -56,12 +57,11 @@ void InitIcoLib() void InitNetlib()
{
- NETLIBUSER nlu = {0};
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_UNICODE; // | NUF_HTTPGATEWAY;
nlu.ptszDescriptiveName = TranslateT("Plugin Updater HTTP connections");
nlu.szSettingsModule = MODNAME;
- hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ hNetlibUser = Netlib_RegisterUser(&nlu);
}
void UnloadNetlib()
@@ -161,14 +161,14 @@ bool ParseHashes(const wchar_t *ptszUrl, ptrW &baseUrl, SERVLIST &arHashes) Netlib_CloseHandle(nlc);
if (!ret) {
- Netlib_LogfT(hNetlibUser,L"Downloading list of available updates from %s failed",baseUrl);
+ Netlib_LogfW(hNetlibUser,L"Downloading list of available updates from %s failed",baseUrl);
ShowPopup(TranslateT("Plugin Updater"), TranslateT("An error occurred while checking for new updates."), POPUP_TYPE_ERROR);
SkinPlaySound("updatefailed");
return false;
}
if(!unzip(pFileUrl.tszDiskPath, g_tszTempPath, NULL,true)) {
- Netlib_LogfT(hNetlibUser,L"Unzipping list of available updates from %s failed",baseUrl);
+ Netlib_LogfW(hNetlibUser,L"Unzipping list of available updates from %s failed",baseUrl);
ShowPopup(TranslateT("Plugin Updater"), TranslateT("An error occurred while checking for new updates."), POPUP_TYPE_ERROR);
SkinPlaySound("updatefailed");
return false;
@@ -180,7 +180,7 @@ bool ParseHashes(const wchar_t *ptszUrl, ptrW &baseUrl, SERVLIST &arHashes) mir_snwprintf(tszTmpIni, L"%s\\hashes.txt", g_tszTempPath);
FILE *fp = _wfopen(tszTmpIni, L"r");
if (!fp) {
- Netlib_LogfT(hNetlibUser,L"Opening %s failed", g_tszTempPath);
+ Netlib_LogfW(hNetlibUser,L"Opening %s failed", g_tszTempPath);
ShowPopup(TranslateT("Plugin Updater"), TranslateT("An error occurred while checking for new updates."), POPUP_TYPE_ERROR);
return false;
}
@@ -258,7 +258,7 @@ bool DownloadFile(FILEURL *pFileURL, HANDLE &nlc) bool ret = false;
for (int i = 0; !ret && i < MAX_RETRIES; i++) {
- Netlib_LogfT(hNetlibUser,L"Downloading file %s to %s (attempt %d)",pFileURL->tszDownloadURL,pFileURL->tszDiskPath, i+1);
+ Netlib_LogfW(hNetlibUser,L"Downloading file %s to %s (attempt %d)",pFileURL->tszDownloadURL,pFileURL->tszDiskPath, i+1);
NETLIBHTTPREQUEST *pReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&nlhr);
if (pReply) {
nlc = pReply->nlc;
@@ -269,7 +269,7 @@ bool DownloadFile(FILEURL *pFileURL, HANDLE &nlc) int crc = Get_CRC((unsigned char*)pReply->pData, pReply->dataLength);
if (crc != pFileURL->CRCsum) {
// crc check failed, try again
- Netlib_LogfT(hNetlibUser,L"crc check failed for file %s",pFileURL->tszDiskPath);
+ Netlib_LogfW(hNetlibUser,L"crc check failed for file %s",pFileURL->tszDiskPath);
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)pReply);
continue;
}
@@ -297,16 +297,16 @@ bool DownloadFile(FILEURL *pFileURL, HANDLE &nlc) ret = true;
}
else
- Netlib_LogfT(hNetlibUser,L"Downloading file %s failed with error %d",pFileURL->tszDownloadURL,pReply->resultCode);
+ Netlib_LogfW(hNetlibUser,L"Downloading file %s failed with error %d",pFileURL->tszDownloadURL,pReply->resultCode);
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)pReply);
}
else {
- Netlib_LogfT(hNetlibUser,L"Downloading file %s failed, host is propably temporary down.",pFileURL->tszDownloadURL);
+ Netlib_LogfW(hNetlibUser,L"Downloading file %s failed, host is propably temporary down.",pFileURL->tszDownloadURL);
nlc = NULL;
}
}
if(!ret)
- Netlib_LogfT(hNetlibUser,L"Downloading file %s failed, giving up",pFileURL->tszDownloadURL);
+ Netlib_LogfW(hNetlibUser,L"Downloading file %s failed, giving up",pFileURL->tszDownloadURL);
mir_free(szUrl);
mir_free(nlhr.headers);
diff --git a/plugins/PluginUpdater/src/stdafx.h b/plugins/PluginUpdater/src/stdafx.h index 096ef9e247..182ba3d22f 100644 --- a/plugins/PluginUpdater/src/stdafx.h +++ b/plugins/PluginUpdater/src/stdafx.h @@ -160,7 +160,8 @@ extern HINSTANCE hInst; extern DWORD g_mirandaVersion;
extern wchar_t g_tszRoot[MAX_PATH], g_tszTempPath[MAX_PATH];
extern aPopups PopupsList[POPUPS];
-extern HANDLE hPipe, hNetlibUser;
+extern HANDLE hPipe;
+extern HNETLIBUSER hNetlibUser;
#if MIRANDA_VER >= 0x0A00
extern IconItemT iconList[];
#endif
diff --git a/plugins/Quotes/src/HTTPSession.cpp b/plugins/Quotes/src/HTTPSession.cpp index 1d201389ca..ae0679b758 100644 --- a/plugins/Quotes/src/HTTPSession.cpp +++ b/plugins/Quotes/src/HTTPSession.cpp @@ -32,12 +32,11 @@ public: {
assert(NULL == g_hNetLib);
- NETLIBUSER nlu = { 0 };
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_NOHTTPSOPTION | NUF_UNICODE;
nlu.szSettingsModule = QUOTES_PROTOCOL_NAME;
nlu.ptszDescriptiveName = TranslateT("Quotes HTTP connections");
- g_hNetLib = reinterpret_cast<HANDLE>(CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu));
+ g_hNetLib = reinterpret_cast<HANDLE>(Netlib_RegisterUser(&nlu));
return (NULL != g_hNetLib);
}
diff --git a/plugins/SecureIM/src/commonheaders.cpp b/plugins/SecureIM/src/commonheaders.cpp index 0ac3f749e3..199942925c 100644 --- a/plugins/SecureIM/src/commonheaders.cpp +++ b/plugins/SecureIM/src/commonheaders.cpp @@ -93,16 +93,16 @@ void CopyToClipboard(HWND hwnd, LPSTR msg) }
}
-HANDLE hNetlibUser;
+HNETLIBUSER hNetlibUser;
void InitNetlib()
{
- NETLIBUSER nl_user = { sizeof(nl_user) };
+ NETLIBUSER nl_user = {};
nl_user.szSettingsModule = (LPSTR)MODULENAME;
nl_user.szDescriptiveName = (LPSTR)MODULENAME;
nl_user.flags = NUF_NOOPTIONS;
- hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nl_user);
+ hNetlibUser = Netlib_RegisterUser(&nl_user);
}
void DeinitNetlib()
@@ -118,5 +118,5 @@ int Sent_NetLog(const char *fmt, ...) va_start(va, fmt);
mir_vsnprintf(szText, sizeof(szText), fmt, va);
va_end(va);
- return CallService(MS_NETLIB_LOG, (WPARAM)hNetlibUser, (LPARAM)szText);
+ return Netlib_Log(hNetlibUser, szText);
}
diff --git a/plugins/SecureIM/src/commonheaders.h b/plugins/SecureIM/src/commonheaders.h index cc629fa102..4afa278eee 100644 --- a/plugins/SecureIM/src/commonheaders.h +++ b/plugins/SecureIM/src/commonheaders.h @@ -89,7 +89,7 @@ __forceinline int SendBroadcast(MCONTACT hContact, int type, int result, HANDLE return ProtoBroadcastAck( GetContactProto(hContact), hContact, type, result, hProcess, lParam);
}
-extern HANDLE hNetlibUser;
+extern HNETLIBUSER hNetlibUser;
void InitNetlib();
void DeinitNetlib();
int Sent_NetLog(const char *,...);
diff --git a/plugins/SendScreenshotPlus/src/Main.cpp b/plugins/SendScreenshotPlus/src/Main.cpp index 4c289bde45..9ad0d286f5 100644 --- a/plugins/SendScreenshotPlus/src/Main.cpp +++ b/plugins/SendScreenshotPlus/src/Main.cpp @@ -32,11 +32,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Prototypes /////////////////////////////////////////////////////////////////////////// CHAT_MANAGER *pci; CLIST_INTERFACE *pcli; -HINSTANCE g_hSendSS; -MGLOBAL g_myGlobals; -HANDLE g_hNetlibUser=0;//!< Netlib Register User -FI_INTERFACE* FIP=NULL; -int hLangpack;//Miranda NG langpack used by translate functions, filled by mir_getLP() +HINSTANCE g_hSendSS; +MGLOBAL g_myGlobals; +HNETLIBUSER g_hNetlibUser=0;//!< Netlib Register User +FI_INTERFACE *FIP=NULL; +int hLangpack;//Miranda NG langpack used by translate functions, filled by mir_getLP() IconItem ICONS[ICO_END_] = { @@ -232,11 +232,11 @@ int hook_ModulesLoaded(WPARAM, LPARAM) g_myGlobals.PluginFTPExist = ServiceExists(MS_FTPFILE_UPLOAD); g_myGlobals.PluginDropboxExist = ServiceExists(MS_DROPBOX_UPLOAD); // Netlib register - NETLIBUSER nlu = { sizeof(nlu) }; + NETLIBUSER nlu = {}; nlu.szSettingsModule = __PLUGIN_NAME; nlu.ptszDescriptiveName = TranslateT("SendSS HTTP connections"); nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE; //|NUF_NOHTTPSOPTION; - g_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); + g_hNetlibUser = Netlib_RegisterUser(&nlu); // load my button class / or use UInfoEx CtrlButtonLoadModule(); // Folders plugin support diff --git a/plugins/SendScreenshotPlus/src/stdafx.h b/plugins/SendScreenshotPlus/src/stdafx.h index 5cdeed4d41..a9f907c99d 100644 --- a/plugins/SendScreenshotPlus/src/stdafx.h +++ b/plugins/SendScreenshotPlus/src/stdafx.h @@ -117,10 +117,9 @@ typedef struct _MGLOBAL { #define SZ_SENDSS "SendSS" extern ATOM g_clsTargetHighlighter; -extern HINSTANCE g_hSendSS; -extern MGLOBAL g_myGlobals; -extern HANDLE g_hNetlibUser; - +extern HINSTANCE g_hSendSS; +extern MGLOBAL g_myGlobals; +extern HNETLIBUSER g_hNetlibUser; enum{ ICO_MAIN=0, diff --git a/plugins/SmileyAdd/src/download.cpp b/plugins/SmileyAdd/src/download.cpp index 1a68a8c86b..dd5e1e05a2 100644 --- a/plugins/SmileyAdd/src/download.cpp +++ b/plugins/SmileyAdd/src/download.cpp @@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h"
-HANDLE hNetlibUser;
+HNETLIBUSER hNetlibUser;
static HANDLE hFolder;
struct QueueElem
@@ -218,11 +218,11 @@ void GetSmileyCacheFolder(void) void DownloadInit(void)
{
- NETLIBUSER nlu = { sizeof(nlu) };
+ NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_NOHTTPSOPTION | NUF_UNICODE;
nlu.szSettingsModule = MODULENAME;
nlu.ptszDescriptiveName = TranslateT("SmileyAdd HTTP connections");
- hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ hNetlibUser = Netlib_RegisterUser(&nlu);
GetSmileyCacheFolder();
g_hDlMutex = CreateMutex(NULL, FALSE, NULL);
diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp index 09066d74f0..65b8ed9564 100644 --- a/plugins/SmileyAdd/src/smileys.cpp +++ b/plugins/SmileyAdd/src/smileys.cpp @@ -520,7 +520,7 @@ bool SmileyPackType::LoadSmileyFileMSL(CMStringW &tbuf, bool onlyInfo, CMStringW static const wchar_t errmsg[] = LPGENW("Smiley #%u in file %s for smiley pack %s not found.");
wchar_t msgtxt[1024];
mir_snwprintf(msgtxt, TranslateW(errmsg), smnum, resname.c_str(), modpath.c_str());
- CallService(MS_NETLIB_LOG, (WPARAM)hNetlibUser, _T2A(msgtxt));
+ Netlib_LogW(hNetlibUser, msgtxt);
errorFound = true;
}
smnum++;
@@ -1078,7 +1078,7 @@ SmileyLookup::SmileyLookup(const CMStringW &str, const bool regexs, const int in }
if (!m_valid)
- CallService(MS_NETLIB_LOG, (WPARAM)hNetlibUser, _T2A(msgtxt));
+ Netlib_LogW(hNetlibUser, msgtxt);
}
else {
m_text = str;
diff --git a/plugins/SmileyAdd/src/stdafx.h b/plugins/SmileyAdd/src/stdafx.h index f467be8697..754d4078db 100644 --- a/plugins/SmileyAdd/src/stdafx.h +++ b/plugins/SmileyAdd/src/stdafx.h @@ -92,7 +92,7 @@ typedef WCMatcher _TMatcher; extern FI_INTERFACE *fei;
extern HINSTANCE g_hInst;
-extern HANDLE hNetlibUser;
+extern HNETLIBUSER hNetlibUser;
extern HANDLE hEvent1;
extern HGENMENU hContactMenuItem;
extern SmileyCategoryListType g_SmileyCategories;
diff --git a/plugins/Utils.pas/mirutils.pas b/plugins/Utils.pas/mirutils.pas index 4ede3640a2..5b3e87a33b 100644 --- a/plugins/Utils.pas/mirutils.pas +++ b/plugins/Utils.pas/mirutils.pas @@ -434,10 +434,9 @@ begin if hNetLib=0 then
begin
FillChar(nlu,SizeOf(nlu),0);
- nlu.cbSize :=SizeOf(nlu);
- nlu.flags :=NUF_HTTPCONNS or NUF_NOHTTPSOPTION or NUF_OUTGOING or NUF_NOOPTIONS;
+ nlu.flags :=NUF_HTTPCONNS or NUF_NOHTTPSOPTION or NUF_OUTGOING or NUF_NOOPTIONS;
nlu.szSettingsModule:='dummy';
- hTmpNetLib:=CallService(MS_NETLIB_REGISTERUSER,0,lparam(@nlu));
+ hTmpNetLib:=Netlib_RegisterUser(@nlu);
end
else
hTmpNetLib:=hNetLib;
@@ -457,7 +456,7 @@ begin CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,lparam(resp));
end;
- if (hNetLib=0) and (nlu.cbSize<>0) then
+ if (hNetLib=0) and (nlu.flags<>0) then
Netlib_CloseHandle(hTmpNetLib);
end;
@@ -466,8 +465,7 @@ static int __inline NLog(AnsiChar *msg) { return CallService(MS_NETLIB_LOG, (WPARAM)hNetlibUser, (LPARAM)msg);
}
*)
-function GetFile(url:PAnsiChar;save_file:PAnsiChar;
- hNetLib:THANDLE=0;recurse_count:integer=0):bool;
+function GetFile(url:PAnsiChar; save_file:PAnsiChar; hNetLib:THANDLE=0; recurse_count:integer=0):bool;
var
nlu:TNETLIBUSER;
req :TNETLIBHTTPREQUEST;
@@ -491,10 +489,9 @@ begin FillChar(nlu,SizeOf(nlu),0);
if hNetLib=0 then
begin
- nlu.cbSize :=SizeOf(nlu);
- nlu.flags :=NUF_HTTPCONNS or NUF_NOHTTPSOPTION or NUF_OUTGOING or NUF_NOOPTIONS;
+ nlu.flags := NUF_HTTPCONNS or NUF_NOHTTPSOPTION or NUF_OUTGOING or NUF_NOOPTIONS;
nlu.szSettingsModule:='dummy';
- hNetLib:=CallService(MS_NETLIB_REGISTERUSER,0,lparam(@nlu));
+ hNetLib:=Netlib_RegisterUser(@nlu);
end;
resp:=pointer(CallService(MS_NETLIB_HTTPTRANSACTION,hNetLib,lparam(@req)));
@@ -536,7 +533,7 @@ begin end;
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,lparam(resp));
- if nlu.cbSize<>0 then
+ if nlu.flags<>0 then
Netlib_CloseHandle(hNetLib);
end;
end;
@@ -619,10 +616,9 @@ begin req.flags :=NLHRF_NODUMP;
FillChar(nlu,SizeOf(nlu),0);
- nlu.cbSize :=SizeOf(nlu);
- nlu.flags :=NUF_HTTPCONNS or NUF_NOHTTPSOPTION or NUF_OUTGOING or NUF_NOOPTIONS;
+ nlu.flags := NUF_HTTPCONNS or NUF_NOHTTPSOPTION or NUF_OUTGOING or NUF_NOOPTIONS;
nlu.szSettingsModule:='dummy';
- hNetLib:=CallService(MS_NETLIB_REGISTERUSER,0,lparam(@nlu));
+ hNetLib:=Netlib_RegisterUser(@nlu);
resp:=pointer(CallService(MS_NETLIB_HTTPTRANSACTION,hNetLib,lparam(@req)));
diff --git a/plugins/Watrack/myshows/i_cookies.inc b/plugins/Watrack/myshows/i_cookies.inc index 3241134cf3..62563e7afc 100644 --- a/plugins/Watrack/myshows/i_cookies.inc +++ b/plugins/Watrack/myshows/i_cookies.inc @@ -62,13 +62,11 @@ begin end;
FillChar(nlu,SizeOf(nlu),0);
- nlu.cbSize :=SizeOf(nlu);
- nlu.flags :=NUF_HTTPCONNS or NUF_NOHTTPSOPTION or NUF_OUTGOING or NUF_NOOPTIONS;
+ nlu.flags := NUF_HTTPCONNS or NUF_NOHTTPSOPTION or NUF_OUTGOING or NUF_NOOPTIONS;
nlu.szSettingsModule:='dummy';
- hTmpNetLib:=CallService(MS_NETLIB_REGISTERUSER,0,lparam(@nlu));
+ hTmpNetLib:=Netlib_RegisterUser(@nlu);
resp:=pointer(CallService(MS_NETLIB_HTTPTRANSACTION,hTmpNetLib,lparam(@req)));
-
if resp<>nil then
begin
if resp^.resultCode=200 then
diff --git a/plugins/Watrack_MPD/src/init.cpp b/plugins/Watrack_MPD/src/init.cpp index eedf62bd0c..2d2989289c 100755 --- a/plugins/Watrack_MPD/src/init.cpp +++ b/plugins/Watrack_MPD/src/init.cpp @@ -21,7 +21,7 @@ BOOL bWatrackService = FALSE; int hLangpack = 0;
wchar_t *gbHost, *gbPassword;
WORD gbPort;
-HANDLE ghNetlibUser;
+HNETLIBUSER ghNetlibUser;
PLUGININFOEX pluginInfo={
sizeof(PLUGININFOEX),
@@ -57,12 +57,11 @@ void InitVars() static int OnModulesLoaded(WPARAM, LPARAM)
{
- NETLIBUSER nlu = {0};
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE;
nlu.ptszDescriptiveName = TranslateT("Watrack MPD connection");
nlu.szSettingsModule = __PLUGIN_NAME;
- ghNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ ghNetlibUser = Netlib_RegisterUser(&nlu);
InitVars();
if (ServiceExists(MS_WAT_PLAYER))
bWatrackService = TRUE;
diff --git a/plugins/Watrack_MPD/src/stdafx.h b/plugins/Watrack_MPD/src/stdafx.h index f339704541..8d40410cd9 100755 --- a/plugins/Watrack_MPD/src/stdafx.h +++ b/plugins/Watrack_MPD/src/stdafx.h @@ -34,7 +34,7 @@ #define szModuleName "Watrack_MPD"
extern HINSTANCE hInst;
-extern HANDLE ghNetlibUser;
+extern HNETLIBUSER ghNetlibUser;
extern BOOL bWatrackService;
extern wchar_t *gbHost, *gbPassword;
extern WORD gbPort;
diff --git a/plugins/Weather/src/stdafx.h b/plugins/Weather/src/stdafx.h index 73a3eb9a60..677cca67d1 100644 --- a/plugins/Weather/src/stdafx.h +++ b/plugins/Weather/src/stdafx.h @@ -357,7 +357,8 @@ extern unsigned status, old_status; extern MWindowList hDataWindowList, hWindowList;
-extern HANDLE hNetlibUser, hNetlibHttp, hHookWeatherUpdated, hHookWeatherError, hTBButton, hUpdateMutex;
+extern HNETLIBUSER hNetlibUser;
+extern HANDLE hNetlibHttp, hHookWeatherUpdated, hHookWeatherError, hTBButton, hUpdateMutex;
extern UINT_PTR timerId;
extern HGENMENU hMwinMenu;
diff --git a/plugins/Weather/src/weather_http.cpp b/plugins/Weather/src/weather_http.cpp index 82b9707d80..5fdf2cb22f 100644 --- a/plugins/Weather/src/weather_http.cpp +++ b/plugins/Weather/src/weather_http.cpp @@ -25,7 +25,8 @@ from the web using netlib #include "stdafx.h"
-HANDLE hNetlibUser, hNetlibHttp;
+HNETLIBUSER hNetlibUser;
+HANDLE hNetlibHttp;
static int findHeader(const NETLIBHTTPREQUEST *nlhrReply, const char *hdr)
{
@@ -152,12 +153,11 @@ int InternetDownloadFile(char *szUrl, char *cookie, char *userAgent, wchar_t **s // initialize netlib support for weather protocol
void NetlibInit(void)
{
- NETLIBUSER nlu = { 0 };
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_NOHTTPSOPTION | NUF_UNICODE;
nlu.szSettingsModule = WEATHERPROTONAME;
nlu.ptszDescriptiveName = TranslateT("Weather HTTP connections");
- hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ hNetlibUser = Netlib_RegisterUser(&nlu);
}
void NetlibHttpDisconnect(void)
diff --git a/plugins/Weather/src/weather_update.cpp b/plugins/Weather/src/weather_update.cpp index 578bec0a8d..5331c2be74 100644 --- a/plugins/Weather/src/weather_update.cpp +++ b/plugins/Weather/src/weather_update.cpp @@ -44,10 +44,10 @@ int UpdateWeather(MCONTACT hContact) dbv.pszVal = "";
// log to netlib log for debug purpose
- Netlib_LogfT(hNetlibUser, L"************************************************************************");
+ Netlib_LogfW(hNetlibUser, L"************************************************************************");
int dbres = db_get_ws(hContact, WEATHERPROTONAME, "Nick", &dbv);
- Netlib_LogfT(hNetlibUser, L"<-- Start update for station -->");
+ Netlib_LogfW(hNetlibUser, L"<-- Start update for station -->");
// download the info and parse it
// result are stored in database
@@ -65,8 +65,8 @@ int UpdateWeather(MCONTACT hContact) mir_free(tszError);
}
// log to netlib
- Netlib_LogfT(hNetlibUser, L"Error! Update cannot continue... Start to free memory");
- Netlib_LogfT(hNetlibUser, L"<-- Error occurs while updating station: %s -->", dbv.ptszVal);
+ Netlib_LogfW(hNetlibUser, L"Error! Update cannot continue... Start to free memory");
+ Netlib_LogfW(hNetlibUser, L"<-- Error occurs while updating station: %s -->", dbv.ptszVal);
if (!dbres) db_free(&dbv);
return 1;
}
@@ -203,8 +203,8 @@ int UpdateWeather(MCONTACT hContact) NotifyEventHooks(hHookWeatherUpdated, hContact, (LPARAM)Ch);
}
- Netlib_LogfT(hNetlibUser, L"Update Completed - Start to free memory");
- Netlib_LogfT(hNetlibUser, L"<-- Update successful for station -->");
+ Netlib_LogfW(hNetlibUser, L"Update Completed - Start to free memory");
+ Netlib_LogfW(hNetlibUser, L"<-- Update successful for station -->");
// Update frame data
UpdateMwinData(hContact);
diff --git a/plugins/WebView/src/main.cpp b/plugins/WebView/src/main.cpp index e8b7bfd899..bcb0c4a2e2 100644 --- a/plugins/WebView/src/main.cpp +++ b/plugins/WebView/src/main.cpp @@ -24,7 +24,7 @@ #include "webview.h"
MWindowList hWindowList;
-HANDLE hNetlibUser;
+HNETLIBUSER hNetlibUser;
HANDLE hHookDisplayDataAlert, hHookAlertPopup, hHookAlertWPopup, hHookErrorPopup, hHookAlertOSD;
int hLangpack = 0;
@@ -147,11 +147,11 @@ extern "C" int __declspec(dllexport) Load() char tempNdesc[50];
mir_snprintf(tempNdesc, "%s connection settings", MODULENAME);
- NETLIBUSER nlu = { sizeof(nlu) };
- nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS;
- nlu.szSettingsModule = MODULENAME;
- nlu.szDescriptiveName = tempNdesc;
- hNetlibUser = (HANDLE) CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM) & nlu);
+ NETLIBUSER nlu = {};
+ nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS;
+ nlu.szSettingsModule = MODULENAME;
+ nlu.szDescriptiveName = tempNdesc;
+ hNetlibUser = Netlib_RegisterUser(&nlu);
// register webview protocol
PROTOCOLDESCRIPTOR pd = { 0 };
diff --git a/plugins/WebView/src/webview.h b/plugins/WebView/src/webview.h index 837fa18083..28a897de58 100644 --- a/plugins/WebView/src/webview.h +++ b/plugins/WebView/src/webview.h @@ -144,7 +144,7 @@ extern HWND ContactHwnd; extern HINSTANCE hInst;
extern HMENU hMenu;
extern int bpStatus;
-extern HANDLE hNetlibUser;
+extern HNETLIBUSER hNetlibUser;
extern MWindowList hWindowList;
extern HGENMENU hMenuItem1, hMenuItemCountdown;
extern char optionsname[80];
diff --git a/plugins/YAMN/src/proto/netlib.cpp b/plugins/YAMN/src/proto/netlib.cpp index cc8f73a602..df4dc150e6 100644 --- a/plugins/YAMN/src/proto/netlib.cpp +++ b/plugins/YAMN/src/proto/netlib.cpp @@ -10,7 +10,7 @@ //--------------------------------------------------------------------------------------------------
BOOL SSLLoaded = FALSE;
-HANDLE hNetlibUser = NULL;
+HNETLIBUSER hNetlibUser = NULL;
void __stdcall SSL_DebugLog(const char *fmt, ...)
{
@@ -27,13 +27,12 @@ void __stdcall SSL_DebugLog(const char *fmt, ...) else
str[sizeof(str) - 1] = 0;
- CallService(MS_NETLIB_LOG, (WPARAM)hNetlibUser, (LPARAM)str);
+ Netlib_Log(hNetlibUser, str);
va_end(vararg);
}
HANDLE RegisterNLClient(const char *name)
{
- static NETLIBUSER nlu = { 0 };
char desc[128];
mir_snprintf(desc, Translate("%s connection"), name);
@@ -41,11 +40,12 @@ HANDLE RegisterNLClient(const char *name) #ifdef DEBUG_COMM
DebugLog(CommFile, "<Register PROXY support>");
#endif
- nlu.cbSize = sizeof(nlu);
+
+ NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS;
nlu.szDescriptiveName = desc;
nlu.szSettingsModule = (char *)name;
- hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ hNetlibUser = Netlib_RegisterUser(&nlu);
#ifdef DEBUG_COMM
if (NULL == hNetlibUser)
@@ -227,7 +227,7 @@ char* CNLClient::Recv(char *buf, int buflen) throw(DWORD) void CNLClient::Disconnect()
{
Netlib_CloseHandle(hConnection);
- hConnection = (HANDLE)NULL;
+ hConnection = NULL;
}
//Uninitializes netlib library
@@ -238,7 +238,7 @@ void UnregisterNLClient() #endif
Netlib_CloseHandle(hNetlibUser);
- hNetlibUser = (HANDLE)NULL;
+ hNetlibUser = NULL;
#ifdef DEBUG_COMM
DebugLog(CommFile, "</Unregister PROXY support>\n");
#endif
diff --git a/plugins/helpers/gen_helpers.cpp b/plugins/helpers/gen_helpers.cpp index c397936b37..76c7491280 100644 --- a/plugins/helpers/gen_helpers.cpp +++ b/plugins/helpers/gen_helpers.cpp @@ -63,16 +63,7 @@ wchar_t *Hlp_GetWindowText(HWND hwndDlg) // Logging
static int WriteToDebugLogA(const char *szMsg)
{
-
- int res = 0;
- if (ServiceExists(MS_NETLIB_LOG))
- res = CallService(MS_NETLIB_LOG, 0, (LPARAM)szMsg);
- else {
- OutputDebugStringA(szMsg);
- OutputDebugStringA("\r\n");
- }
-
- return res;
+ return Netlib_Log(0, szMsg);
}
int AddDebugLogMessageA(const char* fmt, ...)
diff --git a/plugins/mRadio/mradio.dpr b/plugins/mRadio/mradio.dpr index 3c3a5c3050..28ee6d3e9c 100644 --- a/plugins/mRadio/mradio.dpr +++ b/plugins/mRadio/mradio.dpr @@ -79,10 +79,9 @@ begin StrCopy(szTemp,Translate('%s server connection'));
StrReplace(szTemp,'%s',PluginName);
nlu.szDescriptiveName.a:=szTemp;
- nlu.cbSize :=SizeOf(nlu);
nlu.flags :=NUF_HTTPCONNS or NUF_NOHTTPSOPTION or NUF_OUTGOING;
nlu.szSettingsModule :=PluginName;
- hNetLib:=CallService(MS_NETLIB_REGISTERUSER,0,tlparam(@nlu));
+ hNetLib:=Netlib_RegisterUser(@nlu);
// CallService(MS_RADIO_COMMAND,MRC_RECORD,2); record off - not so necessary
diff --git a/protocols/AimOscar/src/proto.cpp b/protocols/AimOscar/src/proto.cpp index f3dbb61265..a670de6faa 100644 --- a/protocols/AimOscar/src/proto.cpp +++ b/protocols/AimOscar/src/proto.cpp @@ -48,13 +48,12 @@ CAimProto::CAimProto(const char* aProtoName, const wchar_t* aUserName) : wchar_t descr[MAX_PATH];
- NETLIBUSER nlu = { 0 };
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE;
nlu.szSettingsModule = m_szModuleName;
mir_snwprintf(descr, TranslateT("%s server connection"), m_tszUserName);
nlu.ptszDescriptiveName = descr;
- m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ m_hNetlibUser = Netlib_RegisterUser(&nlu);
char szP2P[128];
mir_snprintf(szP2P, "%sP2P", m_szModuleName);
@@ -62,7 +61,7 @@ CAimProto::CAimProto(const char* aProtoName, const wchar_t* aUserName) : mir_snwprintf(descr, TranslateT("%s client-to-client connections"), m_tszUserName);
nlu.szSettingsModule = szP2P;
nlu.minIncomingPorts = 1;
- m_hNetlibPeer = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ m_hNetlibPeer = Netlib_RegisterUser(&nlu);
}
CAimProto::~CAimProto()
diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp index ea3975a983..427fba67d2 100644 --- a/protocols/Discord/src/proto.cpp +++ b/protocols/Discord/src/proto.cpp @@ -68,20 +68,20 @@ CDiscordProto::CDiscordProto(const char *proto_name, const wchar_t *username) : // Network initialization CMStringW descr; - NETLIBUSER nlu = { sizeof(nlu) }; + NETLIBUSER nlu = {}; nlu.szSettingsModule = m_szModuleName; nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE; descr.Format(TranslateT("%s server connection"), m_tszUserName); nlu.ptszDescriptiveName = descr.GetBuffer(); - m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); + m_hNetlibUser = Netlib_RegisterUser(&nlu); CMStringA module(FORMAT, "%s.Gateway", m_szModuleName); nlu.szSettingsModule = module.GetBuffer(); nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_UNICODE; descr.Format(TranslateT("%s gateway connection"), m_tszUserName); nlu.ptszDescriptiveName = descr.GetBuffer(); - m_hGatewayNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); + m_hGatewayNetlibUser = Netlib_RegisterUser(&nlu); } CDiscordProto::~CDiscordProto() diff --git a/protocols/FacebookRM/src/http_request.h b/protocols/FacebookRM/src/http_request.h index ceab52b405..634b24605a 100644 --- a/protocols/FacebookRM/src/http_request.h +++ b/protocols/FacebookRM/src/http_request.h @@ -287,9 +287,7 @@ public: dataLength = (int)mir_strlen(pData); } - char message[1024]; - mir_snprintf(message, "Send request to %s", szUrl); - CallService(MS_NETLIB_LOG, (WPARAM)hConnection, (LPARAM)&message); + Netlib_Logf(NULL, "Send request to %s", szUrl); return (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hConnection, (LPARAM)(NETLIBHTTPREQUEST*)this); } diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 98c301eb21..73ff55b9c0 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -84,12 +84,12 @@ FacebookProto::FacebookProto(const char* proto_name, const wchar_t* username) : // Create standard network connection wchar_t descr[512]; - NETLIBUSER nlu = { sizeof(nlu) }; + NETLIBUSER nlu = {}; nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE; nlu.szSettingsModule = m_szModuleName; mir_snwprintf(descr, TranslateT("%s server connection"), m_tszUserName); nlu.ptszDescriptiveName = descr; - m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); + m_hNetlibUser = Netlib_RegisterUser(&nlu); if (m_hNetlibUser == NULL) { wchar_t error[200]; mir_snwprintf(error, TranslateT("Unable to initialize Netlib for %s."), m_tszUserName); diff --git a/protocols/Gadu-Gadu/src/gg.cpp b/protocols/Gadu-Gadu/src/gg.cpp index b9c0fd0610..cf2ec94613 100644 --- a/protocols/Gadu-Gadu/src/gg.cpp +++ b/protocols/Gadu-Gadu/src/gg.cpp @@ -442,7 +442,7 @@ void gg_debughandler(int level, const char *format, va_list ap) memcpy(szText, prefix, PREFIXLEN);
mir_vsnprintf(szText + mir_strlen(szText), sizeof(szText) - mir_strlen(szText), szFormat, ap);
- CallService(MS_NETLIB_LOG, NULL, (LPARAM)szText);
+ Netlib_Log(NULL, szText);
free(szFormat);
}
#endif
diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp index 1001112208..5606f0a398 100644 --- a/protocols/Gadu-Gadu/src/gg_proto.cpp +++ b/protocols/Gadu-Gadu/src/gg_proto.cpp @@ -42,13 +42,12 @@ GGPROTO::GGPROTO(const char *pszProtoName, const wchar_t *tszUserName) : wchar_t name[128];
mir_snwprintf(name, TranslateT("%s connection"), m_tszUserName);
- NETLIBUSER nlu = { 0 };
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = {};
nlu.flags = NUF_UNICODE | NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS;
nlu.szSettingsModule = m_szModuleName;
nlu.ptszDescriptiveName = name;
- m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ m_hNetlibUser = Netlib_RegisterUser(&nlu);
// Register services
CreateProtoService(PS_GETAVATARCAPS, &GGPROTO::getavatarcaps);
diff --git a/protocols/IRCG/src/ircproto.cpp b/protocols/IRCG/src/ircproto.cpp index de31e447f3..440359e82a 100644 --- a/protocols/IRCG/src/ircproto.cpp +++ b/protocols/IRCG/src/ircproto.cpp @@ -173,17 +173,16 @@ static int sttCheckPerform(const char *szSetting, LPARAM lParam) int CIrcProto::OnModulesLoaded(WPARAM, LPARAM)
{
- NETLIBUSER nlu = { 0 };
wchar_t name[128];
+ mir_snwprintf(name, TranslateT("%s server connection"), m_tszUserName);
db_unset(NULL, m_szModuleName, "JTemp");
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_UNICODE;
nlu.szSettingsModule = m_szModuleName;
- mir_snwprintf(name, TranslateT("%s server connection"), m_tszUserName);
nlu.ptszDescriptiveName = name;
- m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ m_hNetlibUser = Netlib_RegisterUser(&nlu);
nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_UNICODE;
char szTemp2[256];
@@ -191,7 +190,7 @@ int CIrcProto::OnModulesLoaded(WPARAM, LPARAM) nlu.szSettingsModule = szTemp2;
mir_snwprintf(name, TranslateT("%s client-to-client connections"), m_tszUserName);
nlu.ptszDescriptiveName = name;
- hNetlibDCC = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ hNetlibDCC = Netlib_RegisterUser(&nlu);
GCREGISTER gcr = {};
gcr.dwFlags = GC_CHANMGR | GC_BOLD | GC_ITALICS | GC_UNDERLINE | GC_COLOR | GC_BKGCOLOR;
diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp index d9ed1b32dd..e385a13aec 100644 --- a/protocols/IcqOscarJ/src/icq_proto.cpp +++ b/protocols/IcqOscarJ/src/icq_proto.cpp @@ -156,10 +156,10 @@ CIcqProto::CIcqProto(const char* aProtoName, const wchar_t* aUserName) : HookProtoEvent(ME_CLIST_PREBUILDSTATUSMENU, &CIcqProto::OnPreBuildStatusMenu);
// Register netlib users
- NETLIBUSER nlu = { 0 };
wchar_t szBuffer[MAX_PATH + 64];
mir_snwprintf(szBuffer, TranslateT("%s server connection"), m_tszUserName);
- nlu.cbSize = sizeof(nlu);
+
+ NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE;
nlu.ptszDescriptiveName = szBuffer;
nlu.szSettingsModule = m_szModuleName;
@@ -169,7 +169,7 @@ CIcqProto::CIcqProto(const char* aProtoName, const wchar_t* aUserName) : nlu.pfnHttpGatewayBegin = icq_httpGatewayBegin;
nlu.pfnHttpGatewayWrapSend = icq_httpGatewayWrapSend;
nlu.pfnHttpGatewayUnwrapRecv = icq_httpGatewayUnwrapRecv;
- m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ m_hNetlibUser = Netlib_RegisterUser(&nlu);
char szP2PModuleName[MAX_PATH];
mir_snprintf(szP2PModuleName, "%sP2P", m_szModuleName);
@@ -178,7 +178,7 @@ CIcqProto::CIcqProto(const char* aProtoName, const wchar_t* aUserName) : nlu.ptszDescriptiveName = szBuffer;
nlu.szSettingsModule = szP2PModuleName;
nlu.minIncomingPorts = 1;
- m_hDirectNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ m_hDirectNetlibUser = Netlib_RegisterUser(&nlu);
// Register custom database events
DBEVENTTYPEDESCR eventType = { sizeof(eventType) };
@@ -211,8 +211,8 @@ CIcqProto::~CIcqProto() delete m_arAvatars[i];
// NetLib clean-up
- NetLib_SafeCloseHandle(&m_hDirectNetlibUser);
- NetLib_SafeCloseHandle(&m_hNetlibUser);
+ Netlib_CloseHandle(m_hDirectNetlibUser);
+ Netlib_CloseHandle(m_hNetlibUser);
// Destroy hookable events
if (m_modeMsgsEvent)
diff --git a/protocols/IcqOscarJ/src/icq_proto.h b/protocols/IcqOscarJ/src/icq_proto.h index 3c5da05d35..7fa039a78b 100644 --- a/protocols/IcqOscarJ/src/icq_proto.h +++ b/protocols/IcqOscarJ/src/icq_proto.h @@ -140,7 +140,7 @@ struct CIcqProto : public PROTO<CIcqProto> int __cdecl OnPreBuildStatusMenu(WPARAM, LPARAM);
//====| Data |========================================================================
- HANDLE m_hDirectNetlibUser;
+ HNETLIBUSER m_hDirectNetlibUser;
BYTE m_bGatewayMode;
BYTE m_bSecureLogin;
diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp index 49ef420754..7ad7f12dbf 100644 --- a/protocols/IcqOscarJ/src/utilities.cpp +++ b/protocols/IcqOscarJ/src/utilities.cpp @@ -1361,7 +1361,7 @@ DWORD ICQWaitForSingleObject(HANDLE hObject, DWORD dwMilliseconds, int bWaitAlwa }
-HANDLE NetLib_OpenConnection(HANDLE hUser, const char* szIdent, NETLIBOPENCONNECTION* nloc)
+HANDLE NetLib_OpenConnection(HNETLIBUSER hUser, const char* szIdent, NETLIBOPENCONNECTION* nloc)
{
Netlib_Logf(hUser, "%sConnecting to %s:%u", szIdent ? szIdent : "", nloc->szHost, nloc->wPort);
@@ -1417,7 +1417,7 @@ int CIcqProto::NetLog_Direct(const char *fmt, ...) va_start(va, fmt);
mir_vsnprintf(szText, sizeof(szText), fmt, va);
va_end(va);
- return CallService(MS_NETLIB_LOG, (WPARAM)m_hDirectNetlibUser, (LPARAM)szText);
+ return Netlib_Log(m_hDirectNetlibUser, szText);
}
int CIcqProto::NetLog_Uni(BOOL bDC, const char *fmt, ...)
@@ -1428,8 +1428,8 @@ int CIcqProto::NetLog_Uni(BOOL bDC, const char *fmt, ...) mir_vsnprintf(szText, sizeof(szText), fmt, va);
va_end(va);
- HANDLE hNetlib = (bDC) ? m_hDirectNetlibUser : m_hNetlibUser;
- return CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)szText);
+ HNETLIBUSER hNetlib = (bDC) ? m_hDirectNetlibUser : m_hNetlibUser;
+ return Netlib_Log(hNetlib, szText);
}
char* __fastcall ICQTranslateUtf(const char *src)
diff --git a/protocols/IcqOscarJ/src/utilities.h b/protocols/IcqOscarJ/src/utilities.h index 119ebe79eb..ad5907c1bb 100644 --- a/protocols/IcqOscarJ/src/utilities.h +++ b/protocols/IcqOscarJ/src/utilities.h @@ -95,7 +95,7 @@ __inline static void SAFE_FREE(WCHAR** str) { SAFE_FREE((void**)str); } DWORD ICQWaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds, int bWaitAlways = FALSE);
-HANDLE NetLib_OpenConnection(HANDLE hUser, const char* szIdent, NETLIBOPENCONNECTION* nloc);
+HANDLE NetLib_OpenConnection(HNETLIBUSER hUser, const char* szIdent, NETLIBOPENCONNECTION* nloc);
void NetLib_CloseConnection(HANDLE *hConnection, int bServerConn);
void NetLib_SafeCloseHandle(HANDLE *hConnection);
diff --git a/protocols/JabberG/src/jabber_ws.cpp b/protocols/JabberG/src/jabber_ws.cpp index 208a55c37f..986d1620c1 100644 --- a/protocols/JabberG/src/jabber_ws.cpp +++ b/protocols/JabberG/src/jabber_ws.cpp @@ -31,11 +31,11 @@ BOOL CJabberProto::WsInit(void) wchar_t name[128];
mir_snwprintf(name, TranslateT("%s connection"), m_tszUserName);
- NETLIBUSER nlu = { sizeof(nlu) };
+ NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_UNICODE; // | NUF_HTTPGATEWAY;
nlu.ptszDescriptiveName = name;
nlu.szSettingsModule = m_szModuleName;
- m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ m_hNetlibUser = Netlib_RegisterUser(&nlu);
return m_hNetlibUser != NULL;
}
diff --git a/protocols/MRA/src/MraAvatars.cpp b/protocols/MRA/src/MraAvatars.cpp index 74c8009b29..6fb91f4131 100644 --- a/protocols/MRA/src/MraAvatars.cpp +++ b/protocols/MRA/src/MraAvatars.cpp @@ -58,11 +58,11 @@ DWORD CMraProto::MraAvatarsQueueInitialize(HANDLE *phAvatarsQueueHandle) wchar_t szBuffer[MAX_PATH];
mir_snwprintf(szBuffer, L"%s %s", m_tszUserName, TranslateT("Avatars' plugin connections"));
- NETLIBUSER nlu = { sizeof(nlu) };
+ NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE;
nlu.szSettingsModule = MRA_AVT_SECT_NAME;
nlu.ptszDescriptiveName = szBuffer;
- pmraaqAvatarsQueue->hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ pmraaqAvatarsQueue->hNetlibUser = Netlib_RegisterUser(&nlu);
if (pmraaqAvatarsQueue->hNetlibUser) {
pmraaqAvatarsQueue->iThreadsCount = db_get_dw(NULL, MRA_AVT_SECT_NAME, "WorkThreadsCount", MRA_AVT_DEFAULT_WRK_THREAD_COUNTS);
if (pmraaqAvatarsQueue->iThreadsCount == 0)
diff --git a/protocols/MRA/src/MraProto.cpp b/protocols/MRA/src/MraProto.cpp index a8daef4625..71b3f23c66 100644 --- a/protocols/MRA/src/MraProto.cpp +++ b/protocols/MRA/src/MraProto.cpp @@ -38,11 +38,11 @@ CMraProto::CMraProto(const char* _module, const wchar_t* _displayName) : wchar_t name[MAX_PATH];
mir_snwprintf(name, TranslateT("%s connection"), m_tszUserName);
- NETLIBUSER nlu = { sizeof(nlu) };
+ NETLIBUSER nlu = {};
nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE;
nlu.szSettingsModule = m_szModuleName;
nlu.ptszDescriptiveName = name;
- m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ m_hNetlibUser = Netlib_RegisterUser(&nlu);
InitMenus();
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp index 1efe0b33d9..61eab09889 100644 --- a/protocols/MSN/src/msn_proto.cpp +++ b/protocols/MSN/src/msn_proto.cpp @@ -137,18 +137,16 @@ CMsnProto::CMsnProto(const char* aProtoName, const wchar_t* aUserName) : wchar_t szBuffer[MAX_PATH];
char szDbsettings[64];
- NETLIBUSER nlu1 = { 0 };
- nlu1.cbSize = sizeof(nlu1);
+ NETLIBUSER nlu1 = {};
nlu1.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE;
nlu1.szSettingsModule = szDbsettings;
nlu1.ptszDescriptiveName = szBuffer;
mir_snprintf(szDbsettings, "%s_HTTPS", m_szModuleName);
mir_snwprintf(szBuffer, TranslateT("%s plugin HTTPS connections"), m_tszUserName);
- hNetlibUserHttps = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu1);
+ hNetlibUserHttps = Netlib_RegisterUser(&nlu1);
- NETLIBUSER nlu = { 0 };
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = {};
nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE;
nlu.szSettingsModule = m_szModuleName;
nlu.ptszDescriptiveName = szBuffer;
@@ -159,7 +157,7 @@ CMsnProto::CMsnProto(const char* aProtoName, const wchar_t* aUserName) : nlu.pfnHttpGatewayUnwrapRecv = msn_httpGatewayUnwrapRecv;
mir_snwprintf(szBuffer, TranslateT("%s plugin connections"), m_tszUserName);
- m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ m_hNetlibUser = Netlib_RegisterUser(&nlu);
m_DisplayNameCache = NULL;
}
diff --git a/protocols/MSN/src/msn_proto.h b/protocols/MSN/src/msn_proto.h index 8af3bed21c..5f75cb3ea1 100644 --- a/protocols/MSN/src/msn_proto.h +++ b/protocols/MSN/src/msn_proto.h @@ -183,7 +183,7 @@ struct CMsnProto : public PROTO<CMsnProto> clock_t mStatusMsgTS;
HANDLE msnSearchId;
- HANDLE hNetlibUserHttps;
+ HNETLIBUSER hNetlibUserHttps;
HANDLE hHttpsConnection;
HANDLE hMSNNudge;
HANDLE hPopupError, hPopupHotmail, hPopupNotify;
diff --git a/protocols/MinecraftDynmap/src/proto.cpp b/protocols/MinecraftDynmap/src/proto.cpp index e57fa44308..a29f44c89a 100644 --- a/protocols/MinecraftDynmap/src/proto.cpp +++ b/protocols/MinecraftDynmap/src/proto.cpp @@ -43,12 +43,12 @@ MinecraftDynmapProto::MinecraftDynmapProto(const char* proto_name, const wchar_t // Create standard network connection wchar_t descr[512]; - NETLIBUSER nlu = {sizeof(nlu)}; + NETLIBUSER nlu = {}; nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE; nlu.szSettingsModule = m_szModuleName; mir_snwprintf(descr, TranslateT("%s server connection"), m_tszUserName); nlu.ptszDescriptiveName = descr; - m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); + m_hNetlibUser = Netlib_RegisterUser(&nlu); if (m_hNetlibUser == NULL) { wchar_t error[200]; mir_snwprintf(error, TranslateT("Unable to initialize Netlib for %s."), m_tszUserName); diff --git a/protocols/Omegle/src/proto.cpp b/protocols/Omegle/src/proto.cpp index 05932348e3..57434aa3b1 100644 --- a/protocols/Omegle/src/proto.cpp +++ b/protocols/Omegle/src/proto.cpp @@ -43,12 +43,12 @@ PROTO<OmegleProto>(proto_name, username) // Create standard network connection
wchar_t descr[512];
- NETLIBUSER nlu = { sizeof(nlu) };
+ NETLIBUSER nlu = {};
nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE;
nlu.szSettingsModule = m_szModuleName;
mir_snwprintf(descr, TranslateT("%s server connection"), m_tszUserName);
nlu.ptszDescriptiveName = descr;
- m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ m_hNetlibUser = Netlib_RegisterUser(&nlu);
if (m_hNetlibUser == NULL) {
wchar_t error[200];
mir_snwprintf(error, TranslateT("Unable to initialize Netlib for %s."), m_tszUserName);
diff --git a/protocols/Sametime/src/sametime_proto.cpp b/protocols/Sametime/src/sametime_proto.cpp index 690636b4dd..3890deb053 100644 --- a/protocols/Sametime/src/sametime_proto.cpp +++ b/protocols/Sametime/src/sametime_proto.cpp @@ -16,12 +16,12 @@ CSametimeProto::CSametimeProto(const char* pszProtoName, const wchar_t* tszUserN // Register m_hNetlibUser user
wchar_t name[128];
mir_snwprintf(name, TranslateT("%s connection"), m_tszUserName);
- NETLIBUSER nlu = { 0 };
- nlu.cbSize = sizeof(nlu);
+
+ NETLIBUSER nlu = {};
nlu.flags = NUF_UNICODE | NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS;
nlu.szSettingsModule = m_szModuleName;
nlu.ptszDescriptiveName = name;
- m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ m_hNetlibUser = Netlib_RegisterUser(&nlu);
RegisterGLibLogger();
debugLogW(L"CSametimeProto::CSametimeProto() start m_szModuleName=[%s], m_tszUserName=[%s]", _A2T(m_szModuleName), m_tszUserName);
diff --git a/protocols/SkypeWeb/src/http_request.h b/protocols/SkypeWeb/src/http_request.h index c597065e7e..ab4a556bcd 100644 --- a/protocols/SkypeWeb/src/http_request.h +++ b/protocols/SkypeWeb/src/http_request.h @@ -274,9 +274,7 @@ public: dataLength = (int)mir_strlen(pData);
}
- char message[1024];
- mir_snprintf(message, "Send request to %s", szUrl);
- CallService(MS_NETLIB_LOG, (WPARAM)hConnection, (LPARAM)&message);
+ Netlib_Logf(NULL, "Send request to %s", szUrl);
return (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hConnection, (LPARAM)(NETLIBHTTPREQUEST*)this);
}
diff --git a/protocols/SkypeWeb/src/skype_network.cpp b/protocols/SkypeWeb/src/skype_network.cpp index cad76e2866..de12a06b7b 100644 --- a/protocols/SkypeWeb/src/skype_network.cpp +++ b/protocols/SkypeWeb/src/skype_network.cpp @@ -21,12 +21,11 @@ void CSkypeProto::InitNetwork() {
CMStringW name(FORMAT, TranslateT("%s connection"), m_tszUserName);
- NETLIBUSER nlu = { 0 };
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_UNICODE;
nlu.ptszDescriptiveName = name.GetBuffer();
nlu.szSettingsModule = m_szModuleName;
- m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ m_hNetlibUser = Netlib_RegisterUser(&nlu);
}
void CSkypeProto::UnInitNetwork()
diff --git a/protocols/Steam/src/http_request.h b/protocols/Steam/src/http_request.h index 357e6f5a45..402185048d 100644 --- a/protocols/Steam/src/http_request.h +++ b/protocols/Steam/src/http_request.h @@ -144,9 +144,7 @@ public: { szUrl = m_url.GetBuffer(); - char message[1024]; - mir_snprintf(message, "Send request to %s", szUrl); - CallService(MS_NETLIB_LOG, (WPARAM)hConnection, (LPARAM)&message); + Netlib_Logf(NULL, "Send request to %s", szUrl); NETLIBHTTPREQUEST* response = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hConnection, (LPARAM)this); HttpResponse* result = new HttpResponse(response, this); diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp index 3acfe40114..fb6d7e31f3 100644 --- a/protocols/Steam/src/steam_proto.cpp +++ b/protocols/Steam/src/steam_proto.cpp @@ -68,11 +68,11 @@ CSteamProto::CSteamProto(const char* protoName, const wchar_t* userName) wchar_t name[128]; mir_snwprintf(name, TranslateT("%s connection"), m_tszUserName); - NETLIBUSER nlu = { sizeof(nlu) }; + NETLIBUSER nlu = {}; nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE; nlu.ptszDescriptiveName = name; nlu.szSettingsModule = m_szModuleName; - m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); + m_hNetlibUser = Netlib_RegisterUser(&nlu); requestQueue = new RequestQueue(m_hNetlibUser); } diff --git a/protocols/Tlen/src/tlen_ws.cpp b/protocols/Tlen/src/tlen_ws.cpp index c9008cd2ee..1bed6c9865 100644 --- a/protocols/Tlen/src/tlen_ws.cpp +++ b/protocols/Tlen/src/tlen_ws.cpp @@ -25,22 +25,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. BOOL TlenWsInit(TlenProtocol *proto)
{
- NETLIBUSER nlu = {0};
- NETLIBUSERSETTINGS nlus = {0};
wchar_t name[128];
+ NETLIBUSER nlu = {};
+ nlu.ptszDescriptiveName = name;
+ nlu.szSettingsModule = proto->m_szModuleName;
- nlu.cbSize = sizeof(nlu);
nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_UNICODE; // | NUF_HTTPGATEWAY;
mir_snwprintf(name, TranslateT("%s connection"), proto->m_tszUserName);
- nlu.ptszDescriptiveName = name;
- nlu.szSettingsModule = proto->m_szModuleName;
- proto->m_hNetlibUser = (HANDLE) CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM) &nlu);
+ proto->m_hNetlibUser = Netlib_RegisterUser(&nlu);
nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_NOOPTIONS | NUF_UNICODE;
mir_snwprintf(name, TranslateT("%s SOCKS connection"), proto->m_tszUserName);
- nlu.ptszDescriptiveName = name;
- proto->hFileNetlibUser = (HANDLE) CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM) &nlu);
+ proto->hFileNetlibUser = Netlib_RegisterUser(&nlu);
+
+ NETLIBUSERSETTINGS nlus = {0};
nlus.cbSize = sizeof(nlus);
nlus.useProxy = 0;
CallService(MS_NETLIB_SETUSERSETTINGS, (WPARAM) proto->hFileNetlibUser, (LPARAM) &nlus);
diff --git a/protocols/Tox/src/tox_netlib.cpp b/protocols/Tox/src/tox_netlib.cpp index 82153c743a..3376697df5 100644 --- a/protocols/Tox/src/tox_netlib.cpp +++ b/protocols/Tox/src/tox_netlib.cpp @@ -5,12 +5,11 @@ void CToxProto::InitNetlib() wchar_t name[128];
mir_snwprintf(name, TranslateT("%s connection"), m_tszUserName);
- NETLIBUSER nlu = {0};
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_UNICODE;
nlu.ptszDescriptiveName = name;
nlu.szSettingsModule = m_szModuleName;
- m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ m_hNetlibUser = Netlib_RegisterUser(&nlu);
debugLogA(__FUNCTION__":Setting protocol / module name to '%s'", m_szModuleName);
}
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp index 4d00afc349..8446207d64 100644 --- a/protocols/Twitter/src/proto.cpp +++ b/protocols/Twitter/src/proto.cpp @@ -301,14 +301,14 @@ INT_PTR TwitterProto::OnTweet(WPARAM, LPARAM) int TwitterProto::OnModulesLoaded(WPARAM, LPARAM)
{
wchar_t descr[512];
- NETLIBUSER nlu = { sizeof(nlu) };
+ NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_UNICODE;
nlu.szSettingsModule = m_szModuleName;
// Create standard network connection
mir_snwprintf(descr, TranslateT("%s server connection"), m_tszUserName);
nlu.ptszDescriptiveName = descr;
- m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ m_hNetlibUser = Netlib_RegisterUser(&nlu);
if (m_hNetlibUser == NULL) {
wchar_t error[200];
mir_snwprintf(error, TranslateT("Unable to initialize Netlib for %s."), m_tszUserName);
@@ -321,7 +321,7 @@ int TwitterProto::OnModulesLoaded(WPARAM, LPARAM) nlu.szSettingsModule = module;
mir_snwprintf(descr, TranslateT("%s avatar connection"), m_tszUserName);
nlu.ptszDescriptiveName = descr;
- hAvatarNetlib_ = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ hAvatarNetlib_ = Netlib_RegisterUser(&nlu);
if (hAvatarNetlib_ == NULL) {
wchar_t error[200];
mir_snwprintf(error, TranslateT("Unable to initialize Netlib for %s."), TranslateT("Twitter (avatars)"));
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 94bef34949..a4d1e4f1b8 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -64,11 +64,11 @@ CVkProto::CVkProto(const char *szModuleName, const wchar_t *pwszUserName) : wchar_t descr[512];
mir_snwprintf(descr, TranslateT("%s server connection"), m_tszUserName);
- NETLIBUSER nlu = {sizeof(nlu)};
+ NETLIBUSER nlu = {};
nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE;
nlu.szSettingsModule = m_szModuleName;
nlu.ptszDescriptiveName = descr;
- m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ m_hNetlibUser = Netlib_RegisterUser(&nlu);
Clist_GroupCreate(NULL, m_vkOptions.pwszDefaultGroup);
diff --git a/protocols/WhatsApp/src/WASocketConnection.cpp b/protocols/WhatsApp/src/WASocketConnection.cpp index 03ebf84ea7..78957b21c6 100644 --- a/protocols/WhatsApp/src/WASocketConnection.cpp +++ b/protocols/WhatsApp/src/WASocketConnection.cpp @@ -1,9 +1,9 @@ #include "stdafx.h"
#include "WASocketConnection.h"
-HANDLE g_hNetlibUser = NULL;
+HNETLIBUSER g_hNetlibUser = NULL;
-void WASocketConnection::initNetwork(HANDLE hNetlibUser) throw (WAException)
+void WASocketConnection::initNetwork(HNETLIBUSER hNetlibUser) throw (WAException)
{
g_hNetlibUser = hNetlibUser;
}
diff --git a/protocols/WhatsApp/src/WASocketConnection.h b/protocols/WhatsApp/src/WASocketConnection.h index 8770582ce7..23beac6ef2 100644 --- a/protocols/WhatsApp/src/WASocketConnection.h +++ b/protocols/WhatsApp/src/WASocketConnection.h @@ -28,7 +28,7 @@ public: virtual void log(const char *prefix, const char *str);
- static void initNetwork(HANDLE hNetlibUser) throw (WAException);
+ static void initNetwork(HNETLIBUSER hNetlibUser) throw (WAException);
static void quitNetwork();
};
diff --git a/protocols/WhatsApp/src/proto.cpp b/protocols/WhatsApp/src/proto.cpp index 05954b7809..69b91de842 100644 --- a/protocols/WhatsApp/src/proto.cpp +++ b/protocols/WhatsApp/src/proto.cpp @@ -35,11 +35,11 @@ WhatsAppProto::WhatsAppProto(const char *proto_name, const wchar_t *username) wchar_t descr[512];
mir_snwprintf(descr, TranslateT("%s server connection"), m_tszUserName);
- NETLIBUSER nlu = { sizeof(nlu) };
+ NETLIBUSER nlu = {};
nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE;
nlu.szSettingsModule = m_szModuleName;
nlu.ptszDescriptiveName = descr;
- m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ m_hNetlibUser = Netlib_RegisterUser(&nlu);
if (m_hNetlibUser == NULL) {
wchar_t error[200];
mir_snwprintf(error, TranslateT("Unable to initialize Netlib for %s."), m_tszUserName);
diff --git a/protocols/WhatsApp/src/stdafx.h b/protocols/WhatsApp/src/stdafx.h index 6fd6adbc8b..0472849de9 100644 --- a/protocols/WhatsApp/src/stdafx.h +++ b/protocols/WhatsApp/src/stdafx.h @@ -88,4 +88,4 @@ Copyright © 2013-14 Uli Hecht extern HINSTANCE g_hInstance;
extern std::string g_strUserAgent;
extern DWORD g_mirandaVersion;
-extern HANDLE g_hNetlibUser;
+extern HNETLIBUSER g_hNetlibUser;
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 5c5bd98036..3c24d69dc5 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -348,3 +348,8 @@ Srmm_CreateToolbarIcons @348 Netlib_CloseHandle @349
Netlib_Recv @350
Netlib_Send @351
+Netlib_RegisterUser @352
+Netlib_Log @353
+Netlib_LogW @354
+Netlib_Logf @355
+Netlib_LogfW @356
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index f0a887610b..b7a8c032e1 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -348,3 +348,8 @@ Srmm_CreateToolbarIcons @348 Netlib_CloseHandle @349
Netlib_Recv @350
Netlib_Send @351
+Netlib_RegisterUser @352
+Netlib_Log @353
+Netlib_LogW @354
+Netlib_Logf @355
+Netlib_LogfW @356
diff --git a/src/mir_app/src/netlib.cpp b/src/mir_app/src/netlib.cpp index 269c4ca5bf..71f1d5ea85 100644 --- a/src/mir_app/src/netlib.cpp +++ b/src/mir_app/src/netlib.cpp @@ -133,18 +133,16 @@ static char *GetNetlibUserSettingString(const char *szUserModule, const char *sz return szRet;
}
-static INT_PTR NetlibRegisterUser(WPARAM, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_APP_DLL(HNETLIBUSER) Netlib_RegisterUser(const NETLIBUSER *nlu)
{
- NETLIBUSER *nlu = (NETLIBUSER*)lParam;
- if (nlu == NULL || nlu->cbSize != sizeof(NETLIBUSER) || nlu->szSettingsModule == NULL ||
- (!(nlu->flags & NUF_NOOPTIONS) && nlu->szDescriptiveName == NULL) ||
- (nlu->flags & NUF_HTTPGATEWAY && (nlu->pfnHttpGatewayInit == NULL)))
- {
+ if (nlu == NULL || nlu->szSettingsModule == NULL || (!(nlu->flags & NUF_NOOPTIONS) && nlu->szDescriptiveName == NULL) || (nlu->flags & NUF_HTTPGATEWAY && (nlu->pfnHttpGatewayInit == NULL))) {
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
- NetlibUser *thisUser = (NetlibUser*)mir_calloc(sizeof(NetlibUser));
+ HNETLIBUSER thisUser = (HNETLIBUSER)mir_calloc(sizeof(NetlibUser));
thisUser->handleType = NLH_USER;
thisUser->user = *nlu;
@@ -201,9 +199,11 @@ static INT_PTR NetlibRegisterUser(WPARAM, LPARAM lParam) mir_cslock lck(csNetlibUser);
netlibUser.insert(thisUser);
- return (INT_PTR)thisUser;
+ return thisUser;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
static INT_PTR NetlibGetUserSettings(WPARAM wParam, LPARAM lParam)
{
NETLIBUSERSETTINGS *nlus = (NETLIBUSERSETTINGS*)lParam;
@@ -234,7 +234,7 @@ void NetlibDoClose(NetlibConnection *nlc, bool noShutdown) {
if (nlc->s == INVALID_SOCKET) return;
- NetlibLogf(nlc->nlu, "(%p:%u) Connection closed internal", nlc, nlc->s);
+ Netlib_Logf(nlc->nlu, "(%p:%u) Connection closed internal", nlc, nlc->s);
if (nlc->hSsl) {
if (!noShutdown) sslApi.shutdown(nlc->hSsl);
sslApi.sfree(nlc->hSsl);
@@ -293,7 +293,7 @@ MIR_APP_DLL(int) Netlib_CloseHandle(HANDLE hNetlib) return 0;
}
- NetlibLogf(nlc->nlu, "(%p:%u) Connection closed", nlc, nlc->s);
+ Netlib_Logf(nlc->nlu, "(%p:%u) Connection closed", nlc, nlc->s);
delete nlc;
}
}
@@ -479,7 +479,6 @@ int LoadNetlibModule(void) hConnectionOpenMutex = connectionTimeout ? CreateMutex(NULL, FALSE, NULL) : NULL;
g_LastConnectionTick = GetTickCount();
- CreateServiceFunction(MS_NETLIB_REGISTERUSER, NetlibRegisterUser);
CreateServiceFunction(MS_NETLIB_GETUSERSETTINGS, NetlibGetUserSettings);
CreateServiceFunction(MS_NETLIB_SETUSERSETTINGS, NetlibSetUserSettings);
CreateServiceFunction(MS_NETLIB_BINDPORT, NetlibBindPort);
diff --git a/src/mir_app/src/netlib.h b/src/mir_app/src/netlib.h index dddb69c7ed..0e6281a935 100644 --- a/src/mir_app/src/netlib.h +++ b/src/mir_app/src/netlib.h @@ -234,7 +234,6 @@ INT_PTR NetlibHttpSetSticky(WPARAM wParam, LPARAM lParam); //netliblog.c
void NetlibLogShowOptions(void);
void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int flags);
-void NetlibLogf(NetlibUser* nlu, const char *fmt, ...);
void NetlibLogInit(void);
void NetlibLogShutdown(void);
diff --git a/src/mir_app/src/netlibautoproxy.cpp b/src/mir_app/src/netlibautoproxy.cpp index 186d8de4df..3e2e070df9 100644 --- a/src/mir_app/src/netlibautoproxy.cpp +++ b/src/mir_app/src/netlibautoproxy.cpp @@ -282,12 +282,12 @@ static void NetlibIeProxyThread(void *arg) BOOL res;
char *loc = strstr(szAutoUrlStr, "file://");
if (loc || strstr(szAutoUrlStr, "://") == NULL) {
- NetlibLogf(NULL, "Autoproxy Init file: %s", loc);
+ Netlib_Logf(NULL, "Autoproxy Init file: %s", loc);
loc = loc ? loc + 7 : szAutoUrlStr;
res = pInternetInitializeAutoProxyDll(0, loc, NULL, NULL /*&HelperFunctions*/, NULL);
}
else {
- NetlibLogf(NULL, "Autoproxy Init %d", abuf.dwScriptBufferSize);
+ Netlib_Logf(NULL, "Autoproxy Init %d", abuf.dwScriptBufferSize);
if (abuf.dwScriptBufferSize)
res = pInternetInitializeAutoProxyDll(0, NULL, NULL, NULL /*&HelperFunctions*/, &abuf);
else
@@ -303,10 +303,10 @@ static void NetlibIeProxyThread(void *arg) param->szHost, (DWORD)mir_strlen(param->szHost), &proxy, &dwProxyLen))
param->szProxy = mir_strdup(lrtrim(proxy));
- NetlibLogf(NULL, "Autoproxy got response %s, Param: %s %s", param->szProxy, param->szUrl, param->szHost);
+ Netlib_Logf(NULL, "Autoproxy got response %s, Param: %s %s", param->szProxy, param->szUrl, param->szHost);
pInternetDeInitializeAutoProxyDll(NULL, 0);
}
- else NetlibLogf(NULL, "Autoproxy init failed");
+ else Netlib_Logf(NULL, "Autoproxy init failed");
}
char* NetlibGetIeProxy(char *szUrl)
diff --git a/src/mir_app/src/netlibbind.cpp b/src/mir_app/src/netlibbind.cpp index bf11f4737a..802c51b561 100644 --- a/src/mir_app/src/netlibbind.cpp +++ b/src/mir_app/src/netlibbind.cpp @@ -115,7 +115,7 @@ int NetlibFreeBoundPort(struct NetlibBoundPort *nlbp) closesocket(nlbp->s6);
if (nlbp->hThread)
WaitForSingleObject(nlbp->hThread, INFINITE);
- NetlibLogf(nlbp->nlu, "(%u) Port %u closed for incoming connections", nlbp->s, nlbp->wPort);
+ Netlib_Logf(nlbp->nlu, "(%u) Port %u closed for incoming connections", nlbp->s, nlbp->wPort);
mir_free(nlbp);
return 1;
}
@@ -123,7 +123,7 @@ int NetlibFreeBoundPort(struct NetlibBoundPort *nlbp) static void NetlibBindAcceptThread(void* param)
{
NetlibBoundPort *nlbp = (NetlibBoundPort*)param;
- NetlibLogf(nlbp->nlu, "(%u) Port %u opened for incoming connections", nlbp->s, nlbp->wPort);
+ Netlib_Logf(nlbp->nlu, "(%u) Port %u opened for incoming connections", nlbp->s, nlbp->wPort);
while (true) {
fd_set r;
@@ -133,7 +133,7 @@ static void NetlibBindAcceptThread(void* param) if (nlbp->s6 != INVALID_SOCKET)
FD_SET(nlbp->s6, &r);
if (select(0, &r, NULL, NULL, NULL) == SOCKET_ERROR) {
- NetlibLogf(nlbp->nlu, "NetlibBindAcceptThread (%p): select failed (%d)", nlbp->s, GetLastError());
+ Netlib_Logf(nlbp->nlu, "NetlibBindAcceptThread (%p): select failed (%d)", nlbp->s, GetLastError());
break;
}
@@ -145,20 +145,20 @@ static void NetlibBindAcceptThread(void* param) if (FD_ISSET(nlbp->s, &r)) {
s = accept(nlbp->s, (sockaddr*)&sin, &sinLen);
if (s == INVALID_SOCKET) {
- NetlibLogf(nlbp->nlu, "NetlibBindAcceptThread (%p): accept V4 failed (%d)", nlbp->s, GetLastError());
+ Netlib_Logf(nlbp->nlu, "NetlibBindAcceptThread (%p): accept V4 failed (%d)", nlbp->s, GetLastError());
break;
}
}
else if (FD_ISSET(nlbp->s6, &r)) {
s = accept(nlbp->s6, (sockaddr*)&sin, &sinLen);
if (s == INVALID_SOCKET) {
- NetlibLogf(nlbp->nlu, "NetlibBindAcceptThread (%p): accept V6 failed (%d)", nlbp->s, GetLastError());
+ Netlib_Logf(nlbp->nlu, "NetlibBindAcceptThread (%p): accept V6 failed (%d)", nlbp->s, GetLastError());
break;
}
}
else s = NULL;
- NetlibLogf(nlbp->nlu, "New incoming connection on port %u from %s (%p)", nlbp->wPort, ptrA(NetlibAddressToString(&sin)), s);
+ Netlib_Logf(nlbp->nlu, "New incoming connection on port %u from %s (%p)", nlbp->wPort, ptrA(NetlibAddressToString(&sin)), s);
NetlibConnection *nlc = new NetlibConnection();
nlc->nlu = nlbp->nlu;
@@ -171,7 +171,7 @@ static void NetlibBindAcceptThread(void* param) NetlibUPnPDeletePortMapping(nlbp->wExPort, "TCP");
nlbp->hThread = 0;
- NetlibLogf(nlbp->nlu, "NetlibBindAcceptThread: (%p) thread for port %u closed", nlbp->s, nlbp->wPort);
+ Netlib_Logf(nlbp->nlu, "NetlibBindAcceptThread: (%p) thread for port %u closed", nlbp->s, nlbp->wPort);
}
INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam)
@@ -200,7 +200,7 @@ INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam) nlbp->s6 = socket(PF_INET6, SOCK_STREAM, 0);
nlbp->pExtra = nlb->pExtra;
if (nlbp->s == INVALID_SOCKET && nlbp->s6 == INVALID_SOCKET) {
- NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "socket", WSAGetLastError());
+ Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "socket", WSAGetLastError());
mir_free(nlbp);
return 0;
}
@@ -211,7 +211,7 @@ INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam) they better have given wPort == 0, let's hope so */
if (nlu->settings.specifyIncomingPorts && nlu->settings.szIncomingPorts && nlb->wPort == 0) {
if (!BindSocketToPort(nlu->settings.szIncomingPorts, nlbp->s, nlbp->s6, &nlu->outportnum)) {
- NetlibLogf(nlu, "Netlib bind: Not enough ports for incoming connections specified");
+ Netlib_Logf(nlu, "Netlib bind: Not enough ports for incoming connections specified");
SetLastError(WSAEADDRINUSE);
}
else foundPort = 1;
@@ -220,7 +220,7 @@ INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam) /* if ->wPort == 0 then they'll get any free port, otherwise they'll
be asking for whatever was in nlb->wPort*/
if (nlb->wPort != 0) {
- NetlibLogf(nlu, "%s %d: trying to bind port %d, this 'feature' can be abused, please be sure you want to allow it.", __FILE__, __LINE__, nlb->wPort);
+ Netlib_Logf(nlu, "%s %d: trying to bind port %d, this 'feature' can be abused, please be sure you want to allow it.", __FILE__, __LINE__, nlb->wPort);
sin.sin_port = htons(nlb->wPort);
sin6.sin6_port = htons(nlb->wPort);
}
@@ -239,7 +239,7 @@ INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam) foundPort = 1;
}
if (!foundPort) {
- NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "bind", WSAGetLastError());
+ Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "bind", WSAGetLastError());
LBL_Error:
closesocket(nlbp->s);
closesocket(nlbp->s6);
@@ -248,12 +248,12 @@ LBL_Error: }
if (nlbp->s != INVALID_SOCKET && listen(nlbp->s, 5)) {
- NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "listen", WSAGetLastError());
+ Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "listen", WSAGetLastError());
goto LBL_Error;
}
if (nlbp->s6 != INVALID_SOCKET && listen(nlbp->s6, 5)) {
- NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "listen", WSAGetLastError());
+ Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "listen", WSAGetLastError());
goto LBL_Error;
}
@@ -266,7 +266,7 @@ LBL_Error: else if (!getsockname(nlbp->s6, (PSOCKADDR)&sinm, &len))
nlb->wPort = ntohs(sinm.Ipv6.sin6_port);
else {
- NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "getsockname", WSAGetLastError());
+ Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "getsockname", WSAGetLastError());
goto LBL_Error;
}
nlbp->wPort = nlb->wPort;
@@ -282,15 +282,15 @@ LBL_Error: DWORD extIP;
if (nlu->settings.enableUPnP && NetlibUPnPAddPortMapping(nlb->wPort, "TCP", &nlbp->wExPort, &extIP, true)) {
- NetlibLogf(NULL, "UPnP port mapping succeeded. Internal Port: %u External Port: %u\n", nlb->wPort, nlbp->wExPort);
+ Netlib_Logf(NULL, "UPnP port mapping succeeded. Internal Port: %u External Port: %u\n", nlb->wPort, nlbp->wExPort);
nlb->wExPort = nlbp->wExPort;
nlb->dwExternalIP = extIP;
}
else {
if (nlu->settings.enableUPnP)
- NetlibLogf(NULL, "UPnP port mapping failed. Internal Port: %u\n", nlb->wPort);
+ Netlib_Logf(NULL, "UPnP port mapping failed. Internal Port: %u\n", nlb->wPort);
else
- NetlibLogf(NULL, "UPnP disabled. Internal Port: %u\n", nlb->wPort);
+ Netlib_Logf(NULL, "UPnP disabled. Internal Port: %u\n", nlb->wPort);
nlbp->wExPort = 0;
nlb->wExPort = nlb->wPort;
diff --git a/src/mir_app/src/netlibhttp.cpp b/src/mir_app/src/netlibhttp.cpp index 4eaeb33475..e04e8a21d0 100644 --- a/src/mir_app/src/netlibhttp.cpp +++ b/src/mir_app/src/netlibhttp.cpp @@ -246,7 +246,7 @@ struct HttpSecurityContext PHOSTENT host = (ip == INADDR_NONE) ? gethostbyname(szHost) : gethostbyaddr((char*)&ip, 4, AF_INET);
szSpnStr.Format("HTTP/%s", host && host->h_name ? host->h_name : szHost);
_strlwr(szSpnStr.GetBuffer() + 5);
- NetlibLogf(nlu, "Host SPN: %s", szSpnStr);
+ Netlib_Logf(nlu, "Host SPN: %s", szSpnStr);
}
m_hNtlmSecurity = NetlibInitSecurityProvider(szProvider, szSpnStr.IsEmpty() ? NULL : szSpnStr.c_str());
if (m_hNtlmSecurity) {
@@ -267,7 +267,7 @@ struct HttpSecurityContext szAuthHdr = NtlmCreateResponseFromChallenge(m_hNtlmSecurity, szChallenge, szLogin, szPassw, true, complete);
if (!szAuthHdr)
- NetlibLogf(NULL, "Security login %s failed, user: %S pssw: %S", szProvider, szLogin ? szLogin.get() : L"(no user)", szPassw ? L"(exist)" : L"(no psw)");
+ Netlib_Logf(NULL, "Security login %s failed, user: %S pssw: %S", szProvider, szLogin ? szLogin.get() : L"(no user)", szPassw ? L"(exist)" : L"(no psw)");
else if (justCreated)
proxyAuthList.add(m_szHost, m_szProvider);
}
@@ -522,7 +522,7 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam) DWORD dwTimeOutTime = hdrTimeout < 0 ? -1 : GetTickCount() + hdrTimeout;
if (!HttpPeekFirstResponseLine(nlc, dwTimeOutTime, fflags, &nlhr->resultCode, NULL, NULL)) {
DWORD err = GetLastError();
- NetlibLogf(nlu, "%s %d: %s Failed (%u %u)", __FILE__, __LINE__, "HttpPeekFirstResponseLine", err, count);
+ Netlib_Logf(nlu, "%s %d: %s Failed (%u %u)", __FILE__, __LINE__, "HttpPeekFirstResponseLine", err, count);
// connection died while we were waiting
if (GetNetlibHandleType(nlc) != NLH_CONNECTION) {
diff --git a/src/mir_app/src/netlibhttpproxy.cpp b/src/mir_app/src/netlibhttpproxy.cpp index 6caa8631bf..75c714a1c7 100644 --- a/src/mir_app/src/netlibhttpproxy.cpp +++ b/src/mir_app/src/netlibhttpproxy.cpp @@ -307,11 +307,11 @@ int NetlibHttpGatewayRecv(NetlibConnection *nlc, char *buf, int len, int flags) NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
if (nlc->nlhpi.szHttpGetUrl && resultCode != 404) {
- NetlibLogf(nlu, "Error received from proxy, retrying");
+ Netlib_Logf(nlu, "Error received from proxy, retrying");
continue;
}
else {
- NetlibLogf(nlu, "Error received from proxy, retry attempts exceeded (%u)", retryCount);
+ Netlib_Logf(nlu, "Error received from proxy, retry attempts exceeded (%u)", retryCount);
SetLastError(ERROR_GEN_FAILURE);
return SOCKET_ERROR;
}
diff --git a/src/mir_app/src/netliblog.cpp b/src/mir_app/src/netliblog.cpp index d73c075a8a..d61f3ebe00 100644 --- a/src/mir_app/src/netliblog.cpp +++ b/src/mir_app/src/netliblog.cpp @@ -350,39 +350,58 @@ int NetlibLog_Worker(NetlibUser *nlu, const char *pszMsg, int flags) return 1;
}
-static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_APP_DLL(void) ProtoLogA(PROTO_INTERFACE *pThis, LPCSTR szFormat, va_list args)
{
- NetlibUser *nlu = (NetlibUser*)wParam;
- const char *pszMsg = (const char*)lParam;
- return NetlibLog_Worker(nlu, pszMsg, 0);
+ char buf[4096];
+ int res = _vsnprintf(buf, _countof(buf), szFormat, args);
+ NetlibLog_Worker(pThis ? pThis->m_hNetlibUser : NULL, (res != -1) ? buf : CMStringA().FormatV(szFormat, args), 0);
}
-static INT_PTR NetlibLogW(WPARAM wParam, LPARAM lParam)
+MIR_APP_DLL(void) ProtoLogW(PROTO_INTERFACE *pThis, LPCWSTR wszFormat, va_list args)
{
- NetlibUser *nlu = (NetlibUser*)wParam;
- const wchar_t *pwszMsg = (const wchar_t*)lParam;
- return NetlibLog_Worker(nlu, ptrA(Utf8EncodeW(pwszMsg)), 0);
+ WCHAR buf[4096];
+ int res = _vsnwprintf(buf, _countof(buf), wszFormat, args);
+ NetlibLog_Worker(pThis ? pThis->m_hNetlibUser : NULL, ptrA(Utf8EncodeW((res != -1) ? buf : CMStringW().FormatV(wszFormat, args))), 0);
}
-void NetlibLogf(NetlibUser* nlu, const char *fmt, ...)
-{
- if (nlu == NULL) {
- if (!logOptions.toLog)
- return;
- }
- else if (!nlu->toLog)
- return;
+/////////////////////////////////////////////////////////////////////////////////////////
+MIR_APP_DLL(int) Netlib_Logf(HNETLIBUSER hUser, const char *fmt, ...)
+{
va_list va;
- char szText[1024];
+ va_start(va, fmt);
+ char szText[8000];
+ mir_vsnprintf(szText, _countof(szText), fmt, va);
+ va_end(va);
+ return NetlibLog_Worker(hUser, szText, 0);
+}
+MIR_APP_DLL(int) Netlib_LogfW(HNETLIBUSER hUser, const wchar_t *fmt, ...)
+{
+ va_list va;
va_start(va, fmt);
- mir_vsnprintf(szText, sizeof(szText), fmt, va);
+ wchar_t szText[8000];
+ mir_vsnwprintf(szText, _countof(szText), fmt, va);
va_end(va);
+ return NetlibLog_Worker(hUser, ptrA(Utf8EncodeW(szText)), 0);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
- NetlibLog_Worker(nlu, szText, 0);
+MIR_APP_DLL(int) Netlib_Log(HNETLIBUSER hUser, const char *pszStr)
+{
+ return NetlibLog_Worker(hUser, pszStr, 0);
}
+MIR_APP_DLL(int) Netlib_LogW(HNETLIBUSER hUser, const wchar_t *pwszStr)
+{
+ return NetlibLog_Worker(hUser, ptrA(Utf8EncodeW(pwszStr)), 0);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int flags)
{
char szTitleLine[128];
@@ -504,8 +523,6 @@ void NetlibLogInit(void) mirandaStartTime = li.QuadPart;
CreateServiceFunction(MS_NETLIB_LOGWIN, ShowOptions);
- CreateServiceFunction(MS_NETLIB_LOG, NetlibLog);
- CreateServiceFunction(MS_NETLIB_LOGW, NetlibLogW);
hLogEvent = CreateHookableEvent(ME_NETLIB_FASTDUMP);
logOptions.dumpRecv = db_get_b(NULL, "Netlib", "DumpRecv", 1);
diff --git a/src/mir_app/src/netlibopenconn.cpp b/src/mir_app/src/netlibopenconn.cpp index 65482350ea..cbbf885d28 100644 --- a/src/mir_app/src/netlibopenconn.cpp +++ b/src/mir_app/src/netlibopenconn.cpp @@ -47,7 +47,7 @@ DWORD DnsLookup(NetlibUser *nlu, const char *szHost) if (host) return *(u_long*)host->h_addr_list[0]; - NetlibLogf(nlu, "%s %d: %s() for host %s failed (%u)", __FILE__, __LINE__, "gethostbyname", szHost, WSAGetLastError()); + Netlib_Logf(nlu, "%s %d: %s() for host %s failed (%u)", __FILE__, __LINE__, "gethostbyname", szHost, WSAGetLastError()); } __except(EXCEPTION_EXECUTE_HANDLER) {} @@ -136,13 +136,13 @@ static int NetlibInitSocks4Connection(NetlibConnection *nlc, NetlibUser *nlu, NE } if (Netlib_Send(nlc, pInit, (int)len, MSG_DUMPPROXY) == SOCKET_ERROR) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); return 0; } char reply[8]; if (!RecvUntilTimeout(nlc, reply, sizeof(reply), MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); return 0; } @@ -153,7 +153,7 @@ static int NetlibInitSocks4Connection(NetlibConnection *nlc, NetlibUser *nlu, NE case 93: SetLastError(ERROR_INVALID_ACCESS); break; default: SetLastError(ERROR_INVALID_DATA); break; } - NetlibLogf(nlu, "%s %d: Proxy connection failed (%x %u)", __FILE__, __LINE__, (BYTE)reply[1], GetLastError()); + Netlib_Logf(nlu, "%s %d: Proxy connection failed (%x %u)", __FILE__, __LINE__, (BYTE)reply[1], GetLastError()); return 0; } @@ -166,18 +166,18 @@ static int NetlibInitSocks5Connection(NetlibConnection *nlc, NetlibUser *nlu, NE buf[1] = 1; //one auth method buf[2] = nlu->settings.useProxyAuth?2:0; if (Netlib_Send(nlc, (char*)buf, 3, MSG_DUMPPROXY) == SOCKET_ERROR) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); return 0; } //confirmation of auth method if (!RecvUntilTimeout(nlc, (char*)buf, 2, MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); return 0; } if ((buf[1] != 0 && buf[1] != 2)) { SetLastError(ERROR_INVALID_ID_AUTHORITY); - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Recv", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Recv", GetLastError()); return 0; } @@ -191,19 +191,19 @@ static int NetlibInitSocks5Connection(NetlibConnection *nlc, NetlibUser *nlu, NE pAuthBuf[2 + nUserLen] = (BYTE)nPassLen; memcpy(pAuthBuf + 3 + nUserLen, nlu->settings.szProxyAuthPassword, nPassLen); if (Netlib_Send(nlc, (char*)pAuthBuf, int(3 + nUserLen + nPassLen), MSG_DUMPPROXY) == SOCKET_ERROR) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); mir_free(pAuthBuf); return 0; } mir_free(pAuthBuf); if (!RecvUntilTimeout(nlc, (char*)buf, 2, MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); return 0; } if (buf[1]) { SetLastError(ERROR_ACCESS_DENIED); - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); return 0; } } @@ -236,14 +236,14 @@ static int NetlibInitSocks5Connection(NetlibConnection *nlc, NetlibUser *nlu, NE } *(PWORD)(pInit + 4 + nHostLen) = htons(nloc->wPort); if (Netlib_Send(nlc, (char*)pInit, int(6 + nHostLen), MSG_DUMPPROXY) == SOCKET_ERROR) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); mir_free(pInit); return 0; } mir_free(pInit); if (!RecvUntilTimeout(nlc, (char*)buf, 5, MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); return 0; } @@ -264,7 +264,7 @@ static int NetlibInitSocks5Connection(NetlibConnection *nlc, NetlibUser *nlu, NE default: SetLastError(ERROR_INVALID_DATA); break; } } - NetlibLogf(nlu, "%s %d: Proxy conection failed. %s.", __FILE__, __LINE__, err); + Netlib_Logf(nlu, "%s %d: Proxy conection failed. %s.", __FILE__, __LINE__, err); return 0; } @@ -280,11 +280,11 @@ static int NetlibInitSocks5Connection(NetlibConnection *nlc, NetlibUser *nlu, NE nRecvSize = 17; break; default: - NetlibLogf(nlu, "%s %d: %s() unknown address type (%u)", __FILE__, __LINE__, "NetlibInitSocks5Connection", (int)buf[3]); + Netlib_Logf(nlu, "%s %d: %s() unknown address type (%u)", __FILE__, __LINE__, "NetlibInitSocks5Connection", (int)buf[3]); return 0; } if (!RecvUntilTimeout(nlc, (char*)buf, nRecvSize, MSG_DUMPPROXY, RECV_DEFAULT_TIMEOUT)) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "RecvUntilTimeout", GetLastError()); return 0; } @@ -330,7 +330,7 @@ static bool NetlibInitHttpsConnection(NetlibConnection *nlc, NetlibUser *nlu, NE } NetlibHttpSetLastErrorUsingHttpResult(nlhrReply->resultCode); - NetlibLogf(nlu, "%s %d: %s request failed (%u %s)", __FILE__, __LINE__, nlu->settings.proxyType == PROXYTYPE_HTTP ? "HTTP" : "HTTPS", nlhrReply->resultCode, nlhrReply->szResultDescr); + Netlib_Logf(nlu, "%s %d: %s request failed (%u %s)", __FILE__, __LINE__, nlu->settings.proxyType == PROXYTYPE_HTTP ? "HTTP" : "HTTPS", nlhrReply->resultCode, nlhrReply->szResultDescr); NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply); return 0; } @@ -378,16 +378,16 @@ static bool my_connectIPv4(NetlibConnection *nlc, NETLIBOPENCONNECTION *nloc) if (!nlc->szProxyServer) return false; if (nloc) - NetlibLogf(nlc->nlu, "(%p) Connecting to proxy %s:%d for %s:%d ....", nlc, nlc->szProxyServer, nlc->wProxyPort, nloc->szHost, nloc->wPort); + Netlib_Logf(nlc->nlu, "(%p) Connecting to proxy %s:%d for %s:%d ....", nlc, nlc->szProxyServer, nlc->wProxyPort, nloc->szHost, nloc->wPort); else - NetlibLogf(nlc->nlu, "(%p) Connecting to proxy %s:%d ....", nlc, nlc->szProxyServer, nlc->wProxyPort); + Netlib_Logf(nlc->nlu, "(%p) Connecting to proxy %s:%d ....", nlc, nlc->szProxyServer, nlc->wProxyPort); sin.sin_port = htons(nlc->wProxyPort); he = gethostbyname(nlc->szProxyServer); } else { if (!nloc || !nloc->szHost || nloc->szHost[0] == '[' || strchr(nloc->szHost, ':')) return false; - NetlibLogf(nlc->nlu, "(%p) Connecting to server %s:%d....", nlc, nloc->szHost, nloc->wPort); + Netlib_Logf(nlc->nlu, "(%p) Connecting to server %s:%d....", nlc, nloc->szHost, nloc->wPort); sin.sin_port = htons(nloc->wPort); he = gethostbyname(nloc->szHost); @@ -397,7 +397,7 @@ static bool my_connectIPv4(NetlibConnection *nlc, NETLIBOPENCONNECTION *nloc) sin.sin_addr.s_addr = *(u_long*)*har; char* szIp = NetlibAddressToString((SOCKADDR_INET_M*)&sin); - NetlibLogf(nlc->nlu, "(%p) Connecting to ip %s ....", nlc, szIp); + Netlib_Logf(nlc->nlu, "(%p) Connecting to ip %s ....", nlc, szIp); mir_free(szIp); retry: @@ -411,7 +411,7 @@ retry: if (nlc->nlu->settings.specifyOutgoingPorts && nlc->nlu->settings.szOutgoingPorts && nlc->nlu->settings.szOutgoingPorts[0]) { if (!BindSocketToPort(nlc->nlu->settings.szOutgoingPorts, nlc->s, INVALID_SOCKET, &nlc->nlu->inportnum)) - NetlibLogf(nlc->nlu, "Netlib connect: Not enough ports for outgoing connections specified"); + Netlib_Logf(nlc->nlu, "Netlib connect: Not enough ports for outgoing connections specified"); } // try a connect @@ -531,11 +531,11 @@ static bool my_connectIPv6(NetlibConnection *nlc, NETLIBOPENCONNECTION *nloc) if (!nlc->szProxyServer) return false; - NetlibLogf(nlc->nlu, "(%p) Connecting to proxy %s:%d for %s:%d ....", nlc, nlc->szProxyServer, nlc->wProxyPort, nloc->szHost, nloc->wPort); + Netlib_Logf(nlc->nlu, "(%p) Connecting to proxy %s:%d for %s:%d ....", nlc, nlc->szProxyServer, nlc->wProxyPort, nloc->szHost, nloc->wPort); _itoa(nlc->wProxyPort, szPort, 10); if (GetAddrInfoA(nlc->szProxyServer, szPort, &hints, &air)) { - NetlibLogf(nlc->nlu, "%s %d: %s() for host %s failed (%u)", __FILE__, __LINE__, "getaddrinfo", nlc->szProxyServer, WSAGetLastError()); + Netlib_Logf(nlc->nlu, "%s %d: %s() for host %s failed (%u)", __FILE__, __LINE__, "getaddrinfo", nlc->szProxyServer, WSAGetLastError()); return false; } } @@ -543,18 +543,18 @@ static bool my_connectIPv6(NetlibConnection *nlc, NETLIBOPENCONNECTION *nloc) if (!nloc->szHost) return false; - NetlibLogf(nlc->nlu, "(%p) Connecting to server %s:%d....", nlc, nloc->szHost, nloc->wPort); + Netlib_Logf(nlc->nlu, "(%p) Connecting to server %s:%d....", nlc, nloc->szHost, nloc->wPort); _itoa(nlc->nloc.wPort, szPort, 10); if (GetAddrInfoA(nlc->nloc.szHost, szPort, &hints, &air)) { - NetlibLogf(nlc->nlu, "%s %d: %s() for host %s failed (%u)", __FILE__, __LINE__, "getaddrinfo", nlc->nloc.szHost, WSAGetLastError()); + Netlib_Logf(nlc->nlu, "%s %d: %s() for host %s failed (%u)", __FILE__, __LINE__, "getaddrinfo", nlc->nloc.szHost, WSAGetLastError()); return false; } } for (ai = air; ai && !Miranda_IsTerminated(); ai = ai->ai_next) { - NetlibLogf(nlc->nlu, "(%p) Connecting to ip %s ....", nlc, ptrA(NetlibAddressToString((SOCKADDR_INET_M*)ai->ai_addr))); + Netlib_Logf(nlc->nlu, "(%p) Connecting to ip %s ....", nlc, ptrA(NetlibAddressToString((SOCKADDR_INET_M*)ai->ai_addr))); retry: nlc->s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); if (nlc->s == INVALID_SOCKET) { @@ -572,7 +572,7 @@ retry: SOCKET s = ai->ai_family == AF_INET ? nlc->s : INVALID_SOCKET; SOCKET s6 = ai->ai_family == AF_INET6 ? nlc->s : INVALID_SOCKET; if (!BindSocketToPort(nlc->nlu->settings.szOutgoingPorts, s, s6, &nlc->nlu->inportnum)) - NetlibLogf(nlc->nlu, "Netlib connect: Not enough ports for outgoing connections specified"); + Netlib_Logf(nlc->nlu, "Netlib connect: Not enough ports for outgoing connections specified"); } // try a connect @@ -662,13 +662,13 @@ static int NetlibHttpFallbackToDirect(NetlibConnection *nlc, NetlibUser *nlu, NE { NetlibDoClose(nlc, true); - NetlibLogf(nlu, "Fallback to direct connection"); + Netlib_Logf(nlu, "Fallback to direct connection"); nlc->proxyAuthNeeded = false; nlc->proxyType = 0; replaceStr(nlc->szProxyServer, NULL); if (!my_connect(nlc, nloc)) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "connect", WSAGetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "connect", WSAGetLastError()); return false; } return true; @@ -703,7 +703,7 @@ bool NetlibDoConnect(NetlibConnection *nlc) if (usingProxy && (nlc->proxyType == PROXYTYPE_HTTPS || nlc->proxyType == PROXYTYPE_HTTP)) { usingProxy = false; nlc->proxyType = 0; - NetlibLogf(nlu, "Fallback to direct connection"); + Netlib_Logf(nlu, "Fallback to direct connection"); continue; } if (nlu->settings.useProxy && !usingProxy && nlu->settings.proxyType == PROXYTYPE_IE && !forceHttps) { @@ -713,7 +713,7 @@ bool NetlibDoConnect(NetlibConnection *nlc) continue; } } - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "connect", WSAGetLastError()); + Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "connect", WSAGetLastError()); return false; } @@ -768,7 +768,7 @@ bool NetlibDoConnect(NetlibConnection *nlc) nlc->usingDirectHttpGateway = true; } - NetlibLogf(nlu, "(%d) Connected to %s:%d", nlc->s, nloc->szHost, nloc->wPort); + Netlib_Logf(nlu, "(%d) Connected to %s:%d", nlc->s, nloc->szHost, nloc->wPort); if (NLOCF_SSL & nloc->flags) return NetlibStartSsl((WPARAM)nlc, 0) != 0; @@ -828,7 +828,7 @@ INT_PTR NetlibOpenConnection(WPARAM wParam, LPARAM lParam) if (GetNetlibHandleType(nlu) != NLH_USER || !(nlu->user.flags & NUF_OUTGOING)) return 0; - NetlibLogf(nlu, "Connection request to %s:%d (Flags %x)....", nloc->szHost, nloc->wPort, nloc->flags); + Netlib_Logf(nlu, "Connection request to %s:%d (Flags %x)....", nloc->szHost, nloc->wPort, nloc->flags); NetlibConnection *nlc = new NetlibConnection(); nlc->nlu = nlu; @@ -861,13 +861,13 @@ INT_PTR NetlibStartSsl(WPARAM wParam, LPARAM lParam) NETLIBSSL *sp = (NETLIBSSL*)lParam; const char *szHost = sp ? sp->host : nlc->nloc.szHost; - NetlibLogf(nlc->nlu, "(%d %s) Starting SSL negotiation", nlc->s, szHost); + Netlib_Logf(nlc->nlu, "(%d %s) Starting SSL negotiation", nlc->s, szHost); nlc->hSsl = sslApi.connect(nlc->s, szHost, nlc->nlu->settings.validateSSL); if (nlc->hSsl == NULL) - NetlibLogf(nlc->nlu, "(%d %s) Failure to negotiate SSL connection", nlc->s, szHost); + Netlib_Logf(nlc->nlu, "(%d %s) Failure to negotiate SSL connection", nlc->s, szHost); else - NetlibLogf(nlc->nlu, "(%d %s) SSL negotiation successful", nlc->s, szHost); + Netlib_Logf(nlc->nlu, "(%d %s) SSL negotiation successful", nlc->s, szHost); return nlc->hSsl != NULL; } diff --git a/src/mir_app/src/netlibpktrecver.cpp b/src/mir_app/src/netlibpktrecver.cpp index 5281cc5dab..fafee80be3 100644 --- a/src/mir_app/src/netlibpktrecver.cpp +++ b/src/mir_app/src/netlibpktrecver.cpp @@ -66,7 +66,7 @@ INT_PTR NetlibPacketRecverGetMore(WPARAM wParam, LPARAM lParam) if (nlprParam->bytesUsed == 0) {
if (nlpr->packetRecver.bytesAvailable == nlpr->packetRecver.bufferSize) {
nlpr->packetRecver.bytesAvailable = 0;
- NetlibLogf(nlpr->nlc->nlu, "Packet recver: packet overflowed buffer, ditching");
+ Netlib_Logf(nlpr->nlc->nlu, "Packet recver: packet overflowed buffer, ditching");
}
}
else {
diff --git a/src/mir_app/src/netlibsecurity.cpp b/src/mir_app/src/netlibsecurity.cpp index 436dcdd78e..2cc0ba9f73 100644 --- a/src/mir_app/src/netlibsecurity.cpp +++ b/src/mir_app/src/netlibsecurity.cpp @@ -70,7 +70,7 @@ static void ReportSecError(SECURITY_STATUS scRet, int line) char *p = strchr(szMsgBuf, 13); if (p) *p = 0;
- NetlibLogf(NULL, "Security error 0x%x on line %u (%s)", scRet, line, szMsgBuf);
+ Netlib_Logf(NULL, "Security error 0x%x on line %u (%s)", scRet, line, szMsgBuf);
}
HANDLE NetlibInitSecurityProvider(const wchar_t* szProvider, const wchar_t* szPrincipal)
@@ -275,7 +275,7 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge, if (login != NULL && login[0] != '\0') {
memset(&auth, 0, sizeof(auth));
- NetlibLogf(NULL, "Security login requested, user: %S pssw: %s", login, psw ? "(exist)" : "(no psw)");
+ Netlib_Logf(NULL, "Security login requested, user: %S pssw: %s", login, psw ? "(exist)" : "(no psw)");
const wchar_t* loginName = login;
const wchar_t* domainName = wcschr(login, '\\');
diff --git a/src/mir_app/src/netlibupnp.cpp b/src/mir_app/src/netlibupnp.cpp index 38ef8b6406..776b0574f6 100644 --- a/src/mir_app/src/netlibupnp.cpp +++ b/src/mir_app/src/netlibupnp.cpp @@ -192,7 +192,7 @@ void parseURL(char* szUrl, char* szHost, unsigned short* sPort, char* szPath) static void LongLog(char* szData)
{
- CallService(MS_NETLIB_LOG, 0, (LPARAM)szData);
+ Netlib_Logf(0, szData);
}
static void closeRouterConnection(void)
@@ -297,7 +297,7 @@ retrycon: enetaddr.sin_addr.s_addr = *(unsigned*)he->h_addr_list[0];
}
- NetlibLogf(NULL, "UPnP HTTP connection Host: %s Port: %u", szHost, sPort);
+ Netlib_Logf(NULL, "UPnP HTTP connection Host: %s Port: %u", szHost, sPort);
FD_ZERO(&rfd); FD_ZERO(&wfd); FD_ZERO(&efd);
FD_SET(sock, &rfd); FD_SET(sock, &wfd); FD_SET(sock, &efd);
@@ -315,18 +315,18 @@ retrycon: // Socket connection failed
if (err != WSAEWOULDBLOCK) {
closeRouterConnection();
- NetlibLogf(NULL, "UPnP connect failed %d", err);
+ Netlib_Logf(NULL, "UPnP connect failed %d", err);
break;
}
// Wait for socket to connect
else if (select(1, &rfd, &wfd, &efd, &tv) != 1) {
closeRouterConnection();
- NetlibLogf(NULL, "UPnP connect timeout");
+ Netlib_Logf(NULL, "UPnP connect timeout");
break;
}
else if (!FD_ISSET(sock, &wfd)) {
closeRouterConnection();
- NetlibLogf(NULL, "UPnP connect failed");
+ Netlib_Logf(NULL, "UPnP connect failed");
break;
}
}
@@ -362,7 +362,7 @@ retrycon: // Wait for the next packet
if (select(1, &rfd, NULL, NULL, &tv) != 1) {
closeRouterConnection();
- NetlibLogf(NULL, "UPnP recieve timeout");
+ Netlib_Logf(NULL, "UPnP recieve timeout");
break;
}
@@ -458,7 +458,7 @@ retry: goto retrycon;
}
else
- NetlibLogf(NULL, "UPnP send failed %d", WSAGetLastError());
+ Netlib_Logf(NULL, "UPnP send failed %d", WSAGetLastError());
}
}
txtParseParam(szResult, "HTTP", " ", " ", szRes, sizeof(szRes));
@@ -655,7 +655,7 @@ static bool findUPnPGateway(void) discoverUPnP();
lastDiscTime = curTime;
- NetlibLogf(NULL, "UPnP Gateway detected %d, Control URL: %s", gatewayFound, szCtlUrl);
+ Netlib_Logf(NULL, "UPnP Gateway detected %d, Control URL: %s", gatewayFound, szCtlUrl);
}
ReleaseMutex(portListMutex);
diff --git a/src/mir_app/src/proto_utils.cpp b/src/mir_app/src/proto_utils.cpp index e2b58dea08..94e54a0ed3 100644 --- a/src/mir_app/src/proto_utils.cpp +++ b/src/mir_app/src/proto_utils.cpp @@ -54,22 +54,6 @@ MIR_APP_DLL(void) Proto_EnumProtocols(int *nProtos, PROTOCOLDESCRIPTOR ***pProto /////////////////////////////////////////////////////////////////////////////////////////
-MIR_APP_DLL(void) ProtoLogA(struct PROTO_INTERFACE *pThis, LPCSTR szFormat, va_list args)
-{
- char buf[4096];
- int res = _vsnprintf(buf, _countof(buf), szFormat, args);
- CallService(MS_NETLIB_LOG, (WPARAM)(pThis ? pThis->m_hNetlibUser : NULL), (LPARAM)((res != -1) ? buf : CMStringA().FormatV(szFormat, args)));
-}
-
-MIR_APP_DLL(void) ProtoLogW(struct PROTO_INTERFACE *pThis, LPCWSTR wszFormat, va_list args)
-{
- WCHAR buf[4096];
- int res = _vsnwprintf(buf, _countof(buf), wszFormat, args);
- CallService(MS_NETLIB_LOGW, (WPARAM)(pThis ? pThis->m_hNetlibUser : NULL), (LPARAM)((res != -1) ? buf : CMStringW().FormatV(wszFormat, args)));
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
MIR_APP_DLL(INT_PTR) ProtoBroadcastAck(const char *szModule, MCONTACT hContact, int type, int result, HANDLE hProcess, LPARAM lParam)
{
ACKDATA ack = { sizeof(ACKDATA), szModule, hContact, type, result, hProcess, lParam };
|