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/GmailNotifier | |
parent | 94667140aeb3886d22e4c1301423fe99aaf3fba4 (diff) |
Netlib:
- NETLIBHTTPHEADER & NETLIBHTTPREQUEST obsoleted;
- NETLIBHTTPREQUEST divided into MHttpRequest & MHttpResponse;
- MHttpHeaders now manager headers both for MHttpRequest & MHttpResponse;
Diffstat (limited to 'protocols/GmailNotifier')
-rw-r--r-- | protocols/GmailNotifier/src/check.cpp | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/protocols/GmailNotifier/src/check.cpp b/protocols/GmailNotifier/src/check.cpp index b5fa2d2dee..df86f3fa0d 100644 --- a/protocols/GmailNotifier/src/check.cpp +++ b/protocols/GmailNotifier/src/check.cpp @@ -67,19 +67,13 @@ void CheckMailInbox(Account *curAcc) szBody.Append("&password="); szBody.Append(curAcc->pass); - NETLIBHTTPHEADER headers[1] = { - { "Content-Type", "application/x-www-form-urlencoded" } - }; - - NETLIBHTTPREQUEST nlr = {}; - nlr.szUrl = szUrl.GetBuffer(); - nlr.requestType = REQUEST_POST; - nlr.headersCount = _countof(headers); - nlr.headers = headers; - nlr.dataLength = szBody.GetLength(); - nlr.pData = szBody.GetBuffer(); - - NLHR_PTR nlu(Netlib_HttpTransaction(hNetlibUser, &nlr)); + MHttpRequest nlhr; + nlhr.m_szUrl = szUrl.GetBuffer(); + nlhr.m_szParam = szBody; + nlhr.requestType = REQUEST_POST; + nlhr.AddHeader("Content-Type", "application/x-www-form-urlencoded"); + + NLHR_PTR nlu(Netlib_HttpTransaction(hNetlibUser, &nlhr)); if (nlu == nullptr || nlu->resultCode != 200) { mir_strcpy(curAcc->results.content, Translate("Can't send account data!")); @@ -99,25 +93,18 @@ void CheckMailInbox(Account *curAcc) else szUrl.Append("/mail/feed/atom"); - NETLIBHTTPHEADER headers[1] = { - { "Authorization", szAuth.GetBuffer() } - }; - - NETLIBHTTPREQUEST nlr = {}; - nlr.szUrl = szUrl.GetBuffer(); - nlr.requestType = REQUEST_GET; - nlr.headers = headers; - nlr.headersCount = _countof(headers); + MHttpRequest nlhr; + nlhr.m_szUrl = szUrl.GetBuffer(); + nlhr.requestType = REQUEST_GET; + nlhr.AddHeader("Authorization", szAuth.GetBuffer()); - NLHR_PTR nlu(Netlib_HttpTransaction(hNetlibUser, &nlr)); + NLHR_PTR nlu(Netlib_HttpTransaction(hNetlibUser, &nlhr)); if (nlu == nullptr) { - mir_snprintf(curAcc->results.content, "%s [%s]", szNick.get(), - (nlr.resultCode == 401) ? Translate("Wrong name or password!") : Translate("Can't get RSS feed!")); - + mir_snprintf(curAcc->results.content, "%s [%s]", szNick.get(), Translate("Wrong name or password!")); curAcc->results_num = -1; } else { - curAcc->results_num = ParsePage(nlu->pData, &curAcc->results); + curAcc->results_num = ParsePage(nlu->body.GetBuffer(), &curAcc->results); mir_snprintf(curAcc->results.content, "%s [%d]", szNick.get(), curAcc->results_num); } |