From 40203d30ad1a569cfea61442782393b200e9fbe3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 1 Dec 2016 20:51:12 +0300 Subject: warning fix --- protocols/WhatsApp/src/WASocketConnection.cpp | 17 +++++++---------- protocols/WhatsApp/src/WASocketConnection.h | 4 ---- protocols/WhatsApp/src/WhatsAPI++/MediaUploader.cpp | 3 +-- protocols/WhatsApp/src/proto.cpp | 5 ++--- protocols/WhatsApp/src/stdafx.h | 1 + 5 files changed, 11 insertions(+), 19 deletions(-) (limited to 'protocols/WhatsApp') diff --git a/protocols/WhatsApp/src/WASocketConnection.cpp b/protocols/WhatsApp/src/WASocketConnection.cpp index e6b53aa419..b6ec0c0998 100644 --- a/protocols/WhatsApp/src/WASocketConnection.cpp +++ b/protocols/WhatsApp/src/WASocketConnection.cpp @@ -1,11 +1,11 @@ #include "stdafx.h" #include "WASocketConnection.h" -HANDLE WASocketConnection::hNetlibUser = NULL; +HANDLE g_hNetlibUser = NULL; void WASocketConnection::initNetwork(HANDLE hNetlibUser) throw (WAException) { - WASocketConnection::hNetlibUser = hNetlibUser; + g_hNetlibUser = hNetlibUser; } void WASocketConnection::quitNetwork() @@ -18,8 +18,7 @@ WASocketConnection::WASocketConnection(const std::string &dir, int port) throw ( noc.szHost = dir.c_str(); noc.wPort = port; noc.flags = NLOCF_V2; // | NLOCF_SSL; - this->hConn = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, reinterpret_cast(this->hNetlibUser), - reinterpret_cast(&noc)); + this->hConn = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, WPARAM(g_hNetlibUser), LPARAM(&noc)); if (this->hConn == NULL) throw WAException(getLastErrorMsg(), WAException::SOCKET_EX, WAException::SOCKET_EX_OPEN); @@ -36,10 +35,9 @@ void WASocketConnection::write(int i) nlb.len = 1; nlb.flags = MSG_NOHTTPGATEWAYWRAP | MSG_NODUMP; - int result = CallService(MS_NETLIB_SEND, reinterpret_cast(this->hConn), reinterpret_cast(&nlb)); - if (result < 1) { + int result = CallService(MS_NETLIB_SEND, WPARAM(this->hConn), LPARAM(&nlb)); + if (result < 1) throw WAException(getLastErrorMsg(), WAException::SOCKET_EX, WAException::SOCKET_EX_SEND); - } } void WASocketConnection::makeNonBlock() @@ -58,9 +56,8 @@ void WASocketConnection::write(const std::vector &bytes, int leng nlb.flags = MSG_NODUMP; int result = CallService(MS_NETLIB_SEND, WPARAM(hConn), LPARAM(&nlb)); - if (result < length) { + if (result < length) throw WAException(getLastErrorMsg(), WAException::SOCKET_EX, WAException::SOCKET_EX_SEND); - } } unsigned char WASocketConnection::read() @@ -107,7 +104,7 @@ void WASocketConnection::forceShutdown() void WASocketConnection::log(const char *prefix, const char *str) { - Netlib_Logf(WASocketConnection::hNetlibUser, "%s%s", prefix, str); + Netlib_Logf(g_hNetlibUser, "%s%s", prefix, str); } WASocketConnection::~WASocketConnection() diff --git a/protocols/WhatsApp/src/WASocketConnection.h b/protocols/WhatsApp/src/WASocketConnection.h index 802ba911b3..8770582ce7 100644 --- a/protocols/WhatsApp/src/WASocketConnection.h +++ b/protocols/WhatsApp/src/WASocketConnection.h @@ -6,10 +6,6 @@ class WASocketConnection : public ISocketConnection { -public: - static HANDLE hNetlibUser; - -private: int readSize; int maxBufRead; bool connected; diff --git a/protocols/WhatsApp/src/WhatsAPI++/MediaUploader.cpp b/protocols/WhatsApp/src/WhatsAPI++/MediaUploader.cpp index ef8fec4bb3..b2fa8ff091 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/MediaUploader.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/MediaUploader.cpp @@ -55,8 +55,7 @@ namespace MediaUploader nlhr.pData = (char*)allVector.data(); nlhr.dataLength = (int)allVector.size(); - NETLIBHTTPREQUEST* pnlhr = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, - (WPARAM)WASocketConnection::hNetlibUser, (LPARAM)&nlhr); + NETLIBHTTPREQUEST *pnlhr = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)g_hNetlibUser, (LPARAM)&nlhr); string data = pnlhr->pData; diff --git a/protocols/WhatsApp/src/proto.cpp b/protocols/WhatsApp/src/proto.cpp index 1045d73536..05954b7809 100644 --- a/protocols/WhatsApp/src/proto.cpp +++ b/protocols/WhatsApp/src/proto.cpp @@ -231,7 +231,7 @@ bool WhatsAppProto::Register(int state, const string &cc, const string &number, string idx; DBVARIANT dbv; - if (WASocketConnection::hNetlibUser == NULL) { + if (g_hNetlibUser == NULL) { NotifyEvent(m_tszUserName, TranslateT("Network connection error."), NULL, WHATSAPP_EVENT_CLIENT); return false; } @@ -261,8 +261,7 @@ bool WhatsAppProto::Register(int state, const string &cc, const string &number, nlhr.headersCount = _countof(s_registerHeaders); nlhr.flags = NLHRF_HTTP11 | NLHRF_SSL; - NETLIBHTTPREQUEST* pnlhr = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, - (WPARAM)WASocketConnection::hNetlibUser, (LPARAM)&nlhr); + NETLIBHTTPREQUEST* pnlhr = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)g_hNetlibUser, (LPARAM)&nlhr); const wchar_t *ptszTitle = TranslateT("Registration"); if (pnlhr == NULL) { diff --git a/protocols/WhatsApp/src/stdafx.h b/protocols/WhatsApp/src/stdafx.h index e10a495874..6fd6adbc8b 100644 --- a/protocols/WhatsApp/src/stdafx.h +++ b/protocols/WhatsApp/src/stdafx.h @@ -88,3 +88,4 @@ Copyright extern HINSTANCE g_hInstance; extern std::string g_strUserAgent; extern DWORD g_mirandaVersion; +extern HANDLE g_hNetlibUser; -- cgit v1.2.3