diff options
author | George Hazan <george.hazan@gmail.com> | 2024-01-05 15:54:03 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-01-05 15:54:03 +0300 |
commit | 14c4e44a0a91e1ad701d4ae3c58185d25118e64e (patch) | |
tree | 50f36035466f355c74373e757bc00b6610ce6267 /protocols/ICQ-WIM | |
parent | 94667140aeb3886d22e4c1301423fe99aaf3fba4 (diff) |
Netlib:
- NETLIBHTTPHEADER & NETLIBHTTPREQUEST obsoleted;
- NETLIBHTTPREQUEST divided into MHttpRequest & MHttpResponse;
- MHttpHeaders now manager headers both for MHttpRequest & MHttpResponse;
Diffstat (limited to 'protocols/ICQ-WIM')
-rw-r--r-- | protocols/ICQ-WIM/src/avatars.cpp | 16 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/file.cpp | 5 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/groupchats.cpp | 4 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/http.cpp | 46 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/http.h | 6 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/ignore.cpp | 2 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/mra.cpp | 8 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/options.cpp | 10 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/poll.cpp | 2 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/proto.cpp | 8 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/proto.h | 62 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/server.cpp | 44 |
12 files changed, 91 insertions, 122 deletions
diff --git a/protocols/ICQ-WIM/src/avatars.cpp b/protocols/ICQ-WIM/src/avatars.cpp index 452a9da444..73766e7ec8 100644 --- a/protocols/ICQ-WIM/src/avatars.cpp +++ b/protocols/ICQ-WIM/src/avatars.cpp @@ -106,23 +106,13 @@ INT_PTR __cdecl CIcqProto::SetAvatar(WPARAM, LPARAM lParam) } unsigned dwSize = (unsigned)_filelengthi64(fileId); - char *pData = (char *)mir_alloc(dwSize); - if (pData == nullptr) { - _close(fileId); - delete pReq; - return 2; - } - - _read(fileId, pData, dwSize); + pReq->m_szParam.Truncate(dwSize); + _read(fileId, pReq->m_szParam.GetBuffer(), dwSize); _close(fileId); - pReq->pData = pData; - pReq->dataLength = dwSize; - - int iAvatarType = ProtoGetBufferFormat(pData); + int iAvatarType = ProtoGetBufferFormat(pReq->m_szParam); if (iAvatarType == PA_FORMAT_UNKNOWN) { delete pReq; - delete pData; return 3; } diff --git a/protocols/ICQ-WIM/src/file.cpp b/protocols/ICQ-WIM/src/file.cpp index 1dc58ba06b..eb20c4c18b 100644 --- a/protocols/ICQ-WIM/src/file.cpp +++ b/protocols/ICQ-WIM/src/file.cpp @@ -51,10 +51,9 @@ void IcqFileTransfer::FillHeaders(AsyncHttpRequest *pReq) pReq->AddHeader("Content-Range", CMStringA(FORMAT, "bytes %lld-%lld/%lld", pfts.currentFileProgress, pfts.currentFileProgress + dwPortion - 1, pfts.currentFileSize)); pReq->AddHeader("Content-Length", CMStringA(FORMAT, "%d", dwPortion)); - pReq->dataLength = dwPortion; - pReq->pData = (char *)mir_alloc(dwPortion); + pReq->m_szParam.Truncate(dwPortion); _lseek(m_fileId, pfts.currentFileProgress, SEEK_SET); - _read(m_fileId, pReq->pData, dwPortion); + _read(m_fileId, pReq->m_szParam.GetBuffer(), dwPortion); pfts.currentFileProgress += dwPortion; pfts.totalProgress += dwPortion; diff --git a/protocols/ICQ-WIM/src/groupchats.cpp b/protocols/ICQ-WIM/src/groupchats.cpp index 968182e63b..a765426045 100644 --- a/protocols/ICQ-WIM/src/groupchats.cpp +++ b/protocols/ICQ-WIM/src/groupchats.cpp @@ -60,7 +60,7 @@ INT_PTR CIcqProto::SvcLeaveChat(WPARAM hContact, LPARAM) /////////////////////////////////////////////////////////////////////////////////////////
-void CIcqProto::OnGetChatInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
+void CIcqProto::OnGetChatInfo(MHttpResponse *pReply, AsyncHttpRequest *pReq)
{
RobustReply root(pReply);
if (root.error() != 20000)
@@ -191,7 +191,7 @@ void CIcqProto::InviteUserToChat(SESSION_INFO *si) dlg.DoModal();
}
-void CIcqProto::OnLeaveChat(NETLIBHTTPREQUEST*, AsyncHttpRequest *pReq)
+void CIcqProto::OnLeaveChat(MHttpResponse*, AsyncHttpRequest *pReq)
{
db_delete_contact(INT_PTR(pReq->pUserInfo));
}
diff --git a/protocols/ICQ-WIM/src/http.cpp b/protocols/ICQ-WIM/src/http.cpp index b422c0d57b..97fc58875d 100644 --- a/protocols/ICQ-WIM/src/http.cpp +++ b/protocols/ICQ-WIM/src/http.cpp @@ -147,12 +147,8 @@ AsyncHttpRequest::AsyncHttpRequest(IcqConnection conn, int iType, const char *sz strncpy_s(m_reqId, (char*)szId, _TRUNCATE);
RpcStringFreeA(&szId);
- if (iType == REQUEST_POST) {
+ if (iType == REQUEST_POST)
AddHeader("Content-Type", "application/x-www-form-urlencoded");
-
- dataLength = m_szParam.GetLength();
- pData = m_szParam.Detach();
- }
}
void AsyncHttpRequest::ReplaceJsonParam(const JSONNode &n)
@@ -166,29 +162,15 @@ void AsyncHttpRequest::ReplaceJsonParam(const JSONNode &n) else
root.push_back(n);
m_szParam = root.write().c_str();
-
- replaceStr(pData, nullptr);
- dataLength = 0;
}
bool CIcqProto::ExecuteRequest(AsyncHttpRequest *pReq)
{
- CMStringA str;
-
- pReq->szUrl = pReq->m_szUrl.GetBuffer();
- if (!pReq->m_szParam.IsEmpty()) {
- if (pReq->requestType == REQUEST_GET) {
- str.Format("%s?%s", pReq->m_szUrl.c_str(), pReq->m_szParam.c_str());
- pReq->szUrl = str.GetBuffer();
- }
- else {
- pReq->dataLength = pReq->m_szParam.GetLength();
- pReq->pData = mir_strdup(pReq->m_szParam);
- }
- }
+ if (!pReq->m_szParam.IsEmpty() && pReq->requestType == REQUEST_GET)
+ pReq->m_szUrl.AppendFormat("?%s", pReq->m_szParam.c_str());
// replace credentials inside JSON body for pure RAPI requests
- if (pReq->m_conn == CONN_RAPI && !mir_strcmp(pReq->szUrl, ICQ_ROBUST_SERVER) && !getByte(DB_KEY_PHONEREG)) {
+ if (pReq->m_conn == CONN_RAPI && !mir_strcmp(pReq->m_szUrl, ICQ_ROBUST_SERVER) && !getByte(DB_KEY_PHONEREG)) {
CMStringA szAgent(FORMAT, "%S Mail.ru Windows ICQ (version 10.0.1999)", (wchar_t*)m_szOwnId);
pReq->AddHeader("User-Agent", szAgent);
pReq->AddHeader("Content-Type", "application/json");
@@ -203,11 +185,9 @@ bool CIcqProto::ExecuteRequest(AsyncHttpRequest *pReq) if (m_iRClientId)
pReq->ReplaceJsonParam(JSONNode("clientId", m_iRClientId));
pReq->ReplaceJsonParam(JSONNode("authToken", m_szRToken));
- pReq->dataLength = pReq->m_szParam.GetLength();
- pReq->pData = mir_strdup(pReq->m_szParam);
}
- debugLogA("Executing request %s:\n%s", pReq->m_reqId, pReq->szUrl);
+ debugLogA("Executing request %s:\n%s", pReq->m_reqId, pReq->m_szUrl.c_str());
if (pReq->m_conn != CONN_NONE) {
pReq->flags |= NLHRF_PERSISTENT;
@@ -222,14 +202,14 @@ bool CIcqProto::ExecuteRequest(AsyncHttpRequest *pReq) auto &conn = m_ConnPool[pReq->m_conn];
conn.s = reply->nlc;
conn.timeout = 0;
- if (auto *pszHdr = Netlib_GetHeader(reply, "Keep-Alive")) {
+ if (auto *pszHdr = reply->FindHeader("Keep-Alive")) {
int timeout;
if (1 == sscanf(pszHdr, "timeout=%d", &timeout))
conn.timeout = timeout;
}
}
- if (pReq->m_conn == CONN_RAPI && reply->pData && strstr(reply->pData, "\"code\": 40201")) {
+ if (pReq->m_conn == CONN_RAPI && reply->body.Find("\"code\": 40201") != -1) {
RobustReply r(reply);
if (r.error() == 40201) { // robust token expired
m_szRToken.Empty();
@@ -305,7 +285,7 @@ MHttpRequest* operator<<(MHttpRequest *pReq, const GROUP_PARAM ¶m) /////////////////////////////////////////////////////////////////////////////////////////
-JsonReply::JsonReply(NETLIBHTTPREQUEST *pReply)
+JsonReply::JsonReply(MHttpResponse *pReply)
{
if (pReply == nullptr) {
m_errorCode = 500;
@@ -316,7 +296,7 @@ JsonReply::JsonReply(NETLIBHTTPREQUEST *pReply) if (m_errorCode != 200)
return;
- m_root = json_parse(pReply->pData);
+ m_root = json_parse(pReply->body);
if (m_root == nullptr) {
m_errorCode = 500;
return;
@@ -336,7 +316,7 @@ JsonReply::~JsonReply() /////////////////////////////////////////////////////////////////////////////////////////
-FileReply::FileReply(NETLIBHTTPREQUEST *pReply)
+FileReply::FileReply(MHttpResponse *pReply)
{
if (pReply == nullptr) {
m_errorCode = 500;
@@ -347,7 +327,7 @@ FileReply::FileReply(NETLIBHTTPREQUEST *pReply) if (m_errorCode != 200)
return;
- m_root = json_parse(pReply->pData);
+ m_root = json_parse(pReply->body);
if (m_root == nullptr) {
m_errorCode = 500;
return;
@@ -364,7 +344,7 @@ FileReply::~FileReply() /////////////////////////////////////////////////////////////////////////////////////////
-RobustReply::RobustReply(NETLIBHTTPREQUEST *pReply)
+RobustReply::RobustReply(MHttpResponse *pReply)
{
if (pReply == nullptr) {
m_errorCode = 500;
@@ -375,7 +355,7 @@ RobustReply::RobustReply(NETLIBHTTPREQUEST *pReply) if (m_errorCode != 200)
return;
- m_root = json_parse(pReply->pData);
+ m_root = json_parse(pReply->body);
if (m_root == nullptr) {
m_errorCode = 500;
return;
diff --git a/protocols/ICQ-WIM/src/http.h b/protocols/ICQ-WIM/src/http.h index 5bbccd0be7..1b201d097a 100644 --- a/protocols/ICQ-WIM/src/http.h +++ b/protocols/ICQ-WIM/src/http.h @@ -49,7 +49,7 @@ class JsonReply CMStringA m_requestId; public: - JsonReply(NETLIBHTTPREQUEST*); + JsonReply(MHttpResponse*); ~JsonReply(); __forceinline const CMStringA& requestId() const { return m_requestId; } @@ -65,7 +65,7 @@ class FileReply JSONNode* m_data = nullptr; public: - FileReply(NETLIBHTTPREQUEST*); + FileReply(MHttpResponse*); ~FileReply(); __forceinline JSONNode& data() const { return *m_data; } @@ -80,7 +80,7 @@ class RobustReply JSONNode *m_results = nullptr; public: - RobustReply(NETLIBHTTPREQUEST*); + RobustReply(MHttpResponse*); ~RobustReply(); __forceinline JSONNode &result() const { return *m_result; } diff --git a/protocols/ICQ-WIM/src/ignore.cpp b/protocols/ICQ-WIM/src/ignore.cpp index 6dd86c51fb..a07b5271c7 100644 --- a/protocols/ICQ-WIM/src/ignore.cpp +++ b/protocols/ICQ-WIM/src/ignore.cpp @@ -26,7 +26,7 @@ void CIcqProto::GetPermitDeny() Push(new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, "/preference/getPermitDeny", &CIcqProto::OnGetPermitDeny) << AIMSID(this));
}
-void CIcqProto::OnGetPermitDeny(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*)
+void CIcqProto::OnGetPermitDeny(MHttpResponse *pReply, AsyncHttpRequest*)
{
JsonReply root(pReply);
if (root.error() == 200)
diff --git a/protocols/ICQ-WIM/src/mra.cpp b/protocols/ICQ-WIM/src/mra.cpp index b65ae238dc..751734e43b 100644 --- a/protocols/ICQ-WIM/src/mra.cpp +++ b/protocols/ICQ-WIM/src/mra.cpp @@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h"
-void CIcqProto::SendMrimLogin(NETLIBHTTPREQUEST *pReply)
+void CIcqProto::SendMrimLogin(MHttpResponse *pReply)
{
m_szMraCookie = pReply->GetCookies();
@@ -33,7 +33,7 @@ void CIcqProto::SendMrimLogin(NETLIBHTTPREQUEST *pReply) Push(pReq);
}
-void CIcqProto::OnCheckMrimLogin(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *)
+void CIcqProto::OnCheckMrimLogin(MHttpResponse *pReply, AsyncHttpRequest *)
{
JsonReply root(pReply);
switch (root.error()) {
@@ -98,7 +98,7 @@ void CIcqProto::OnCheckMrimLogin(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *) StartSession();
}
-void CIcqProto::OnCheckMraAuth(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *)
+void CIcqProto::OnCheckMraAuth(MHttpResponse *pReply, AsyncHttpRequest *)
{
JsonReply root(pReply);
switch (root.error()) {
@@ -113,7 +113,7 @@ void CIcqProto::OnCheckMraAuth(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *) }
}
-void CIcqProto::OnCheckMraAuthFinal(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *)
+void CIcqProto::OnCheckMraAuthFinal(MHttpResponse *pReply, AsyncHttpRequest *)
{
switch (pReply->resultCode) {
case 200:
diff --git a/protocols/ICQ-WIM/src/options.cpp b/protocols/ICQ-WIM/src/options.cpp index b06ee210a1..9036ed95c9 100644 --- a/protocols/ICQ-WIM/src/options.cpp +++ b/protocols/ICQ-WIM/src/options.cpp @@ -133,7 +133,7 @@ struct CIcqRegistrationDlg : public CIcqDlgBase }
};
-void CIcqProto::OnCheckPhone(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
+void CIcqProto::OnCheckPhone(MHttpResponse *pReply, AsyncHttpRequest *pReq)
{
if (pReply == nullptr || pReply->resultCode != 200)
return;
@@ -142,7 +142,7 @@ void CIcqProto::OnCheckPhone(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) pDlg->btnSendSms.Disable();
pDlg->edtCode.Disable();
- JSONROOT root(pReply->pData);
+ JSONROOT root(pReply->body);
CMStringW wszStatus((*root)["status"].as_mstring());
if (wszStatus != L"OK") {
pDlg->edtCode.SetText((*root)["printable"].as_mstring());
@@ -159,7 +159,7 @@ void CIcqProto::OnCheckPhone(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) Push(pNew);
}
-void CIcqProto::OnNormalizePhone(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
+void CIcqProto::OnNormalizePhone(MHttpResponse *pReply, AsyncHttpRequest *pReq)
{
CIcqRegistrationDlg *pDlg = (CIcqRegistrationDlg*)pReq->pUserInfo;
@@ -173,7 +173,7 @@ void CIcqProto::OnNormalizePhone(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pR pDlg->btnSendSms.Enable();
}
-void CIcqProto::OnValidateSms(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
+void CIcqProto::OnValidateSms(MHttpResponse *pReply, AsyncHttpRequest *pReq)
{
JsonReply root(pReply);
if (root.error() != 200)
@@ -187,7 +187,7 @@ void CIcqProto::OnValidateSms(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) pDlg->edtCode.SetText(L"");
}
-void CIcqProto::OnLoginViaPhone(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
+void CIcqProto::OnLoginViaPhone(MHttpResponse *pReply, AsyncHttpRequest *pReq)
{
CIcqRegistrationDlg *pDlg = (CIcqRegistrationDlg*)pReq->pUserInfo;
diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp index 2f2d8fdf32..1be03cc30d 100644 --- a/protocols/ICQ-WIM/src/poll.cpp +++ b/protocols/ICQ-WIM/src/poll.cpp @@ -362,7 +362,7 @@ void CIcqProto::ProcessTyping(const JSONNode &ev) }
}
-void CIcqProto::OnFetchEvents(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*)
+void CIcqProto::OnFetchEvents(MHttpResponse *pReply, AsyncHttpRequest*)
{
JsonReply root(pReply);
if (root.error() != 200) {
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index 68567975b1..ac913a8afe 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -242,7 +242,7 @@ void CIcqProto::OnEventDeleted(MCONTACT hContact, MEVENT hEvent) /////////////////////////////////////////////////////////////////////////////////////////
-void CIcqProto::OnFileRecv(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
+void CIcqProto::OnFileRecv(MHttpResponse *pReply, AsyncHttpRequest *pReq)
{
if (pReply->resultCode != 200)
return;
@@ -255,10 +255,10 @@ void CIcqProto::OnFileRecv(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) return;
}
- int cbWritten = _write(fileId, pReply->pData, pReply->dataLength);
+ int cbWritten = _write(fileId, pReply->body, pReply->body.GetLength());
_close(fileId);
- if (cbWritten != pReply->dataLength) {
- debugLogW(L"Error writing data into [%s]: %d instead of %d", ofd->wszPath.c_str(), cbWritten, pReply->dataLength);
+ if (cbWritten != pReply->body.GetLength()) {
+ debugLogW(L"Error writing data into [%s]: %d instead of %d", ofd->wszPath.c_str(), cbWritten, pReply->body.GetLength());
return;
}
diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index 44def39b16..3ca731e905 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -229,7 +229,7 @@ class CIcqProto : public PROTO<CIcqProto> void RetrieveUserCaps(IcqUser *pUser);
void RetrieveUserHistory(MCONTACT, __int64 startMsgId, bool bCreateRead);
void RetrieveUserInfo(MCONTACT hContact);
- void SendMrimLogin(NETLIBHTTPREQUEST *pReply);
+ void SendMrimLogin(MHttpResponse *pReply);
void SendMessageParts(MCONTACT hContact, const JSONNode &parts, IcqOwnMessage *pOwn = nullptr);
void SetOwnId(const CMStringW &wszId);
void SetServerStatus(int iNewStatus);
@@ -263,36 +263,36 @@ class CIcqProto : public PROTO<CIcqProto> __int64 getId(MCONTACT hContact, const char *szSetting);
void setId(MCONTACT hContact, const char *szSetting, __int64 iValue);
- void OnAddBuddy(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnAddClient(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnCheckMraAuth(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnCheckMraAuthFinal(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnCheckMrimLogin(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnCheckPassword(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnCheckPhone(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnFetchEvents(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnFileContinue(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnFileInit(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnFileInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnFileRecv(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnGenToken(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnGetChatInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnGetPatches(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnGetPermitDeny(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnGePresence(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnGetSticker(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnGetUserCaps(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnGetUserHistory(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnGetUserInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnLeaveChat(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnLoginViaPhone(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnNormalizePhone(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnReceiveAvatar(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnSearchResults(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnSendMessage(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnSessionEnd(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnStartSession(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
- void OnValidateSms(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq);
+ void OnAddBuddy(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnAddClient(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnCheckMraAuth(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnCheckMraAuthFinal(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnCheckMrimLogin(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnCheckPassword(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnCheckPhone(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnFetchEvents(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnFileContinue(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnFileInit(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnFileInfo(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnFileRecv(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnGenToken(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnGetChatInfo(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnGetPatches(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnGetPermitDeny(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnGePresence(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnGetSticker(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnGetUserCaps(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnGetUserHistory(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnGetUserInfo(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnLeaveChat(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnLoginViaPhone(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnNormalizePhone(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnReceiveAvatar(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnSearchResults(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnSendMessage(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnSessionEnd(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnStartSession(MHttpResponse *pReply, AsyncHttpRequest *pReq);
+ void OnValidateSms(MHttpResponse *pReply, AsyncHttpRequest *pReq);
void ProcessBuddyList(const JSONNode &pRoot);
void ProcessDiff(const JSONNode &pRoot);
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index 36887220fa..e62a609cc4 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -133,7 +133,7 @@ void CIcqProto::CheckPassword() /////////////////////////////////////////////////////////////////////////////////////////
-void CIcqProto::OnFileInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
+void CIcqProto::OnFileInfo(MHttpResponse *pReply, AsyncHttpRequest *pReq)
{
IcqFileInfo **res = (IcqFileInfo **)pReq->pUserInfo;
*res = nullptr;
@@ -691,7 +691,7 @@ LBL_Error: /////////////////////////////////////////////////////////////////////////////////////////
-void CIcqProto::OnGetUserCaps(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
+void CIcqProto::OnGetUserCaps(MHttpResponse *pReply, AsyncHttpRequest *pReq)
{
JsonReply root(pReply);
if (root.error() != 200)
@@ -718,7 +718,7 @@ void CIcqProto::RetrieveUserCaps(IcqUser *pUser) /////////////////////////////////////////////////////////////////////////////////////////
-void CIcqProto::OnGePresence(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
+void CIcqProto::OnGePresence(MHttpResponse *pReply, AsyncHttpRequest *pReq)
{
JsonReply root(pReply);
if (root.error() != 200)
@@ -744,7 +744,7 @@ void CIcqProto::RetrievePresence(MCONTACT hContact) /////////////////////////////////////////////////////////////////////////////////////////
-void CIcqProto::OnGetUserInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
+void CIcqProto::OnGetUserInfo(MHttpResponse *pReply, AsyncHttpRequest *pReq)
{
RobustReply root(pReply);
if (root.error() != 20000) {
@@ -774,7 +774,7 @@ void CIcqProto::RetrieveUserInfo(MCONTACT hContact) /////////////////////////////////////////////////////////////////////////////////////////
-void CIcqProto::OnGetPatches(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
+void CIcqProto::OnGetPatches(MHttpResponse *pReply, AsyncHttpRequest *pReq)
{
RobustReply root(pReply);
if (root.error() != 20000)
@@ -828,7 +828,7 @@ void CIcqProto::ProcessPatchVersion(MCONTACT hContact, __int64 currPatch) /////////////////////////////////////////////////////////////////////////////////////////
-void CIcqProto::OnGetUserHistory(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
+void CIcqProto::OnGetUserHistory(MHttpResponse *pReply, AsyncHttpRequest *pReq)
{
RobustReply root(pReply);
if (root.error() != 20000)
@@ -998,7 +998,7 @@ void CIcqProto::StartSession() /////////////////////////////////////////////////////////////////////////////////////////
-void CIcqProto::OnAddBuddy(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
+void CIcqProto::OnAddBuddy(MHttpResponse *pReply, AsyncHttpRequest *pReq)
{
JsonReply root(pReply);
if (root.error() != 200)
@@ -1032,7 +1032,7 @@ void CIcqProto::OnAddBuddy(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) }
}
-void CIcqProto::OnAddClient(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
+void CIcqProto::OnAddClient(MHttpResponse *pReply, AsyncHttpRequest *pReq)
{
bool *pRet = (bool*)pReq->pUserInfo;
@@ -1048,7 +1048,7 @@ void CIcqProto::OnAddClient(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) *pRet = true;
}
-void CIcqProto::OnCheckPassword(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*)
+void CIcqProto::OnCheckPassword(MHttpResponse *pReply, AsyncHttpRequest*)
{
JsonReply root(pReply);
switch (root.error()) {
@@ -1087,7 +1087,7 @@ void CIcqProto::OnCheckPassword(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*) StartSession();
}
-void CIcqProto::OnFileContinue(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pOld)
+void CIcqProto::OnFileContinue(MHttpResponse *pReply, AsyncHttpRequest *pOld)
{
IcqFileTransfer *pTransfer = (IcqFileTransfer*)pOld->pUserInfo;
if (pTransfer->m_bCanceled) {
@@ -1155,7 +1155,7 @@ LBL_Error: ProtoBroadcastAck(pTransfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_DATA, pTransfer, (LPARAM)&pTransfer->pfts);
}
-void CIcqProto::OnFileInit(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pOld)
+void CIcqProto::OnFileInit(MHttpResponse *pReply, AsyncHttpRequest *pOld)
{
IcqFileTransfer *pTransfer = (IcqFileTransfer*)pOld->pUserInfo;
if (pTransfer->m_bCanceled) {
@@ -1192,7 +1192,7 @@ LBL_Error: /////////////////////////////////////////////////////////////////////////////////////////
// Support for stickers
-void CIcqProto::OnGetSticker(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
+void CIcqProto::OnGetSticker(MHttpResponse *pReply, AsyncHttpRequest *pReq)
{
if (pReply->resultCode != 200) {
debugLogA("Error getting sticker: %d", pReply->resultCode);
@@ -1204,7 +1204,7 @@ void CIcqProto::OnGetSticker(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) CMStringW wszFileName(FORMAT, L"%s\\STK{%s}.png", wszPath.c_str(), (wchar_t*)pReq->pUserInfo);
FILE *out = _wfopen(wszFileName, L"wb");
- fwrite(pReply->pData, 1, pReply->dataLength, out);
+ fwrite(pReply->body, 1, pReply->body.GetLength(), out);
fclose(out);
SmileyAdd_LoadContactSmileys(SMADD_FILE, m_szModuleName, wszFileName);
@@ -1212,7 +1212,7 @@ void CIcqProto::OnGetSticker(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) /////////////////////////////////////////////////////////////////////////////////////////
-void CIcqProto::OnGenToken(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*)
+void CIcqProto::OnGenToken(MHttpResponse *pReply, AsyncHttpRequest*)
{
RobustReply root(pReply);
if (root.error() != 20000)
@@ -1222,7 +1222,7 @@ void CIcqProto::OnGenToken(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*) m_szRToken = results["authToken"].as_mstring();
}
-void CIcqProto::OnStartSession(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *)
+void CIcqProto::OnStartSession(MHttpResponse *pReply, AsyncHttpRequest *)
{
JsonReply root(pReply);
switch (root.error()) {
@@ -1279,18 +1279,18 @@ void CIcqProto::OnStartSession(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *) ForkThread(&CIcqProto::PollThread);
}
-void CIcqProto::OnReceiveAvatar(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
+void CIcqProto::OnReceiveAvatar(MHttpResponse *pReply, AsyncHttpRequest *pReq)
{
PROTO_AVATAR_INFORMATION ai = {};
ai.hContact = pReq->hContact;
- if (pReply->resultCode != 200 || pReply->pData == nullptr) {
+ if (pReply->resultCode != 200 || pReply->body.IsEmpty()) {
LBL_Error:
ProtoBroadcastAck(pReq->hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, &ai);
return;
}
- const char *szContentType = Netlib_GetHeader(pReply, "Content-Type");
+ const char *szContentType = pReply->FindHeader("Content-Type");
if (szContentType == nullptr)
szContentType = "image/jpeg";
@@ -1302,7 +1302,7 @@ LBL_Error: if (out == nullptr)
goto LBL_Error;
- fwrite(pReply->pData, pReply->dataLength, 1, out);
+ fwrite(pReply->body, pReply->body.GetLength(), 1, out);
fclose(out);
if (pReq->hContact != 0) {
@@ -1312,7 +1312,7 @@ LBL_Error: else ReportSelfAvatarChanged();
}
-void CIcqProto::OnSearchResults(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
+void CIcqProto::OnSearchResults(MHttpResponse *pReply, AsyncHttpRequest *pReq)
{
RobustReply root(pReply);
if (root.error() != 20000) {
@@ -1347,7 +1347,7 @@ void CIcqProto::OnSearchResults(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pRe /////////////////////////////////////////////////////////////////////////////////////////
// Send message
-void CIcqProto::OnSendMessage(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
+void CIcqProto::OnSendMessage(MHttpResponse *pReply, AsyncHttpRequest *pReq)
{
IcqOwnMessage *ownMsg = (IcqOwnMessage *)pReq->pUserInfo;
@@ -1394,7 +1394,7 @@ void CIcqProto::SendMessageParts(MCONTACT hContact, const JSONNode &parts, IcqOw /////////////////////////////////////////////////////////////////////////////////////////
-void CIcqProto::OnSessionEnd(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *)
+void CIcqProto::OnSessionEnd(MHttpResponse *pReply, AsyncHttpRequest *)
{
JsonReply root(pReply);
if (root.error() == 200) {
|