summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-04-15 17:09:04 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-04-15 17:09:04 +0300
commit23843ef3efa7b02aa04e9a470bb95c118d3a7ceb (patch)
tree5bdbb95e4915eea71aab31ca0b80ce43ffe8cd6b
parent0d5fa74532e70566121270b29308fa0daa943f3e (diff)
Jabber: code cleaning
-rw-r--r--protocols/JabberG/src/jabber_iqid.cpp2
-rw-r--r--protocols/JabberG/src/jabber_proto.h6
-rw-r--r--protocols/JabberG/src/jabber_thread.cpp19
-rw-r--r--protocols/JabberG/src/jabber_ws.cpp11
-rw-r--r--protocols/JabberG/src/jabber_zstream.cpp14
-rw-r--r--protocols/JabberG/src/stdafx.h3
6 files changed, 21 insertions, 34 deletions
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index a0c0d8bdfd..64c1c7d071 100644
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
@@ -1069,7 +1069,7 @@ void CJabberProto::OnIqResultSetVcard(const TiXmlElement *iqNode, CJabberIqInfo*
SendPresence(m_iStatus, false);
}
}
-void CJabberProto::OnIqResultGetOmemodevicelist(const TiXmlElement* iqNode, CJabberIqInfo* pInfo)
+void CJabberProto::OnIqResultGetOmemodevicelist(const TiXmlElement* iqNode, CJabberIqInfo*)
{
auto* itemsNode = XmlGetChildByTag(iqNode, "items", "node", JABBER_FEAT_OMEMO ".devicelist");
auto from = XmlGetAttr(iqNode, "from");
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index 6d7cd09086..823f17feff 100644
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -929,7 +929,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
private:
char *m_szXmlStreamToBeInitialized;
- uint32_t m_lastTicks;
+ uint32_t m_lastTicks;
HANDLE m_hPopupClass;
@@ -945,9 +945,9 @@ private:
JabberFeatCapPairDynamic* FindFeature(const char *szFeature);
public:
- uint32_t STDMETHODCALLTYPE GetFlags() const override; // Set of JIF_* flags.
+ uint32_t STDMETHODCALLTYPE GetFlags() const override; // Set of JIF_* flags.
int STDMETHODCALLTYPE GetVersion() const override; // Returns version of IJabberInterface.
- uint32_t STDMETHODCALLTYPE GetJabberVersion() const override; // Returns Jabber plugin version.
+ uint32_t STDMETHODCALLTYPE GetJabberVersion() const override; // Returns Jabber plugin version.
MCONTACT STDMETHODCALLTYPE ContactFromJID(const char *jid) override; // Returns contact handle for given JID.
char* STDMETHODCALLTYPE ContactToJID(MCONTACT hContact) override; // Returns JID of hContact. You must free the result using mir_free().
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index 78d696d6f4..78f9150aaf 100644
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -1992,25 +1992,15 @@ void ThreadData::shutdown(void)
Netlib_Shutdown(s);
}
-int ThreadData::recvws(char* buf, size_t len, int flags)
+int ThreadData::recv(char* buf, size_t len)
{
if (this == nullptr)
return 0;
- return proto->WsRecv(s, buf, (int)len, flags);
-}
-
-int ThreadData::recv(char* buf, size_t len)
-{
if (useZlib)
return zlibRecv(buf, (long)len);
- return recvws(buf, len, MSG_DUMPASTEXT);
-}
-
-int ThreadData::sendws(char* buf, size_t bufsize, int flags)
-{
- return proto->WsSend(s, buf, (int)bufsize, flags);
+ return proto->WsRecv(s, buf, len, MSG_DUMPASTEXT);
}
int ThreadData::send(char* buf, int bufsize)
@@ -2027,7 +2017,10 @@ int ThreadData::send(char* buf, int bufsize)
if (useZlib)
result = zlibSend(buf, bufsize);
else
- result = sendws(buf, bufsize, MSG_DUMPASTEXT);
+ result = proto->WsSend(s, buf, bufsize, MSG_DUMPASTEXT);
+
+ if (result == SOCKET_ERROR)
+ close();
ReleaseMutex(iomutex);
diff --git a/protocols/JabberG/src/jabber_ws.cpp b/protocols/JabberG/src/jabber_ws.cpp
index 95893f3384..3f70f1d6c1 100644
--- a/protocols/JabberG/src/jabber_ws.cpp
+++ b/protocols/JabberG/src/jabber_ws.cpp
@@ -49,20 +49,17 @@ HNETLIBCONN CJabberProto::WsConnect(char* host, uint16_t port)
int CJabberProto::WsSend(HNETLIBCONN hConn, char* data, int datalen, int flags)
{
m_lastTicks = ::GetTickCount();
- int len;
-
- if ((len = Netlib_Send(hConn, data, datalen, flags)) == SOCKET_ERROR || len != datalen) {
+ int ret = Netlib_Send(hConn, data, datalen, flags);
+ if (ret == SOCKET_ERROR || ret != datalen) {
debugLogA("Netlib_Send() failed, error=%d", WSAGetLastError());
return SOCKET_ERROR;
}
- return len;
+ return ret;
}
int CJabberProto::WsRecv(HNETLIBCONN hConn, char* data, long datalen, int flags)
{
- int ret;
-
- ret = Netlib_Recv(hConn, data, datalen, flags);
+ int ret = Netlib_Recv(hConn, data, datalen, flags);
if (ret == SOCKET_ERROR) {
debugLogA("Netlib_Recv() failed, error=%d", WSAGetLastError());
return 0;
diff --git a/protocols/JabberG/src/jabber_zstream.cpp b/protocols/JabberG/src/jabber_zstream.cpp
index d7d76e471b..ec3a7ca3b7 100644
--- a/protocols/JabberG/src/jabber_zstream.cpp
+++ b/protocols/JabberG/src/jabber_zstream.cpp
@@ -54,7 +54,7 @@ void ThreadData::zlibUninit(void)
int ThreadData::zlibSend(char* data, int datalen)
{
- char send_data[ ZLIB_CHUNK_SIZE ];
+ char send_data[ZLIB_CHUNK_SIZE];
int bytesOut = 0;
zStreamOut.avail_in = datalen;
@@ -71,11 +71,11 @@ int ThreadData::zlibSend(char* data, int datalen)
case Z_MEM_ERROR: proto->debugLogA("Deflate: Z_MEM_ERROR"); break;
}
- int len, send_datalen = ZLIB_CHUNK_SIZE - zStreamOut.avail_out;
-
- if ((len = sendws(send_data, send_datalen, MSG_NODUMP)) == SOCKET_ERROR || len != send_datalen) {
+ int send_datalen = ZLIB_CHUNK_SIZE - zStreamOut.avail_out;
+ int len = proto->WsSend(s, send_data, send_datalen, MSG_NODUMP);
+ if (len == SOCKET_ERROR || len != send_datalen) {
proto->debugLogA("Netlib_Send() failed, error=%d", WSAGetLastError());
- return FALSE;
+ return SOCKET_ERROR;
}
bytesOut += len;
@@ -85,14 +85,14 @@ int ThreadData::zlibSend(char* data, int datalen)
if (db_get_b(0, "Netlib", "DumpSent", TRUE) == TRUE)
proto->debugLogA("(ZLIB) Data sent\n%s\n===OUT: %d(%d) bytes", data, datalen, bytesOut);
- return TRUE;
+ return bytesOut;
}
int ThreadData::zlibRecv(char* data, long datalen)
{
if (zRecvReady) {
retry:
- zRecvDatalen = recvws(zRecvData, ZLIB_CHUNK_SIZE, MSG_NODUMP);
+ zRecvDatalen = proto->WsRecv(s, zRecvData, ZLIB_CHUNK_SIZE, MSG_NODUMP);
if (zRecvDatalen == SOCKET_ERROR) {
proto->debugLogA("Netlib_Recv() failed, error=%d", WSAGetLastError());
return SOCKET_ERROR;
diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h
index e947630cf1..8d56126b59 100644
--- a/protocols/JabberG/src/stdafx.h
+++ b/protocols/JabberG/src/stdafx.h
@@ -386,9 +386,6 @@ struct ThreadData
int send(char* buffer, int bufsize = -1);
int send(TiXmlElement *node);
int send_no_strm_mgmt(TiXmlElement *node);
-
- int recvws(char* buffer, size_t bufsize, int flags);
- int sendws(char* buffer, size_t bufsize, int flags);
};
struct JABBER_MODEMSGS