From 110fdc1157d94f5d787a21c60163681767fdd6c4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 9 Jan 2024 13:13:23 +0300 Subject: more strict constructor of MHttpRequest to avoid quirks --- plugins/SendScreenshotPlus/src/CSend.cpp | 7 ++++--- plugins/SendScreenshotPlus/src/CSend.h | 16 +++++++++------- plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp | 6 +++--- plugins/SendScreenshotPlus/src/CSendHost_ImageShack.h | 6 ++---- plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp | 2 +- plugins/SendScreenshotPlus/src/CSendHost_imgur.h | 1 - plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp | 7 ++++--- plugins/SendScreenshotPlus/src/CSendHost_uploadpie.h | 1 - 8 files changed, 23 insertions(+), 23 deletions(-) (limited to 'plugins/SendScreenshotPlus/src') diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp index 57ea415646..a06829a422 100644 --- a/plugins/SendScreenshotPlus/src/CSend.cpp +++ b/plugins/SendScreenshotPlus/src/CSend.cpp @@ -45,7 +45,8 @@ CSend::CSend(HWND /*Owner*/, MCONTACT hContact, bool bAsync, bool bSilent) : m_hSend(nullptr), m_hOnSend(nullptr), m_ErrorMsg(nullptr), - m_ErrorTitle(nullptr) + m_ErrorTitle(nullptr), + m_nlhr(REQUEST_POST) { SetContact(hContact); } @@ -422,7 +423,7 @@ const char* CSend::GetHTMLContent(char* str, const char* startTag, const char* e return begin; } -int CSend::HTTPFormCreate(MHttpRequest* nlhr, int requestType, const char* url, HTTPFormData* frm, size_t frmNum) +int CSend::HTTPFormCreate(MHttpRequest* nlhr, const char* url, HTTPFormData* frm, size_t frmNum) { char boundary[16]; strcpy(boundary, "--M461C/"); @@ -439,7 +440,7 @@ int CSend::HTTPFormCreate(MHttpRequest* nlhr, int requestType, const char* url, boundary[9 + i * 2] = (chcode < 0x0a ? '0' : 'a' - 0x0a) + chcode; } } - nlhr->requestType = requestType; + nlhr->flags = NLHRF_HTTP11; if (!strncmp(url, "https://", 8)) nlhr->flags |= NLHRF_SSL; diff --git a/plugins/SendScreenshotPlus/src/CSend.h b/plugins/SendScreenshotPlus/src/CSend.h index 5d9e48247b..fc7985574a 100644 --- a/plugins/SendScreenshotPlus/src/CSend.h +++ b/plugins/SendScreenshotPlus/src/CSend.h @@ -65,7 +65,7 @@ public: void SetContact(MCONTACT hContact); const char* GetURL() { return m_URL; } const char* GetURLthumbnail() {return m_URLthumb; } - uint8_t GetEnableItem() {return m_EnableItem;}; + uint8_t GetEnableItem() {return m_EnableItem;}; wchar_t* GetErrorMsg() {return m_ErrorMsg;}; bool m_bDeleteAfterSend; @@ -81,23 +81,25 @@ protected: wchar_t* m_pszSendTyp; // hold string for error mess char* m_pszProto; // Contact Proto Module MCONTACT m_hContact; // Contact handle - uint8_t m_EnableItem; // hold flag for send type - uint8_t m_ChatRoom; // is Contact chatroom + uint8_t m_EnableItem; // hold flag for send type + uint8_t m_ChatRoom; // is Contact chatroom void Error(LPCTSTR pszFormat, ...); void svcSendFileExit(); void svcSendMsgExit(const char* szMessage); void Exit(unsigned int Result); - uint32_t m_cbEventMsg; // sizeof EventMsg(T) buffer + uint32_t m_cbEventMsg; // sizeof EventMsg(T) buffer CMStringA m_szEventMsg; // EventMsg char* HANDLE m_hSend; // protocol send handle HANDLE m_hOnSend; // HookEventObj on ME_PROTO_ACK - + MSGBOX m_box; wchar_t* m_ErrorMsg; wchar_t* m_ErrorTitle; - + + MHttpRequest m_nlhr; + void Unhook(){if(m_hOnSend) {UnhookEvent(m_hOnSend);m_hOnSend = nullptr;}} void DB_EventAdd(uint16_t EventType); @@ -130,7 +132,7 @@ protected: }; static const char* GetHTMLContent(char* str, const char* startTag, const char* endTag); // changes "str", can be successfully used only once - int HTTPFormCreate(MHttpRequest* nlhr, int requestType, const char* url, HTTPFormData* frm, size_t frmNum); // returns "0" on success, Exit() will be called on failure (stop processing) + int HTTPFormCreate(MHttpRequest* nlhr, const char* url, HTTPFormData* frm, size_t frmNum); // returns "0" on success, Exit() will be called on failure (stop processing) }; #endif diff --git a/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp index 2826dd18c2..981c18f399 100644 --- a/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp +++ b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp @@ -30,8 +30,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ///////////////////////////////////////////////////////////////////////////////////////// -CSendHost_ImageShack::CSendHost_ImageShack(HWND Owner, MCONTACT hContact, bool bAsync) - : CSend(Owner, hContact, bAsync) +CSendHost_ImageShack::CSendHost_ImageShack(HWND Owner, MCONTACT hContact, bool bAsync) : + CSend(Owner, hContact, bAsync) { m_EnableItem = SS_DLG_DESCRIPTION | SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND; m_pszSendTyp = LPGENW("Image upload"); @@ -59,7 +59,7 @@ int CSendHost_ImageShack::Send() { "public", "no" }, { "key", HTTPFORM_8BIT(DEVKEY_IMAGESHACK) }, }; - int error = HTTPFormCreate(&m_nlhr, REQUEST_POST, "http://imageshack.us/upload_api.php", frm, sizeof(frm) / sizeof(HTTPFormData)); + int error = HTTPFormCreate(&m_nlhr, "http://imageshack.us/upload_api.php", frm, sizeof(frm) / sizeof(HTTPFormData)); mir_free(tmp); if (error) return !m_bAsync; diff --git a/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.h b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.h index 3b6212eb70..6ba8153342 100644 --- a/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.h +++ b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.h @@ -40,10 +40,8 @@ public: int Send() override; protected: - MHttpRequest m_nlhr; - - void SendThread(); - static void SendThreadWrapper(void * Obj); + void SendThread(); + static void SendThreadWrapper(void * Obj); }; #endif diff --git a/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp b/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp index da8010da07..b5bd858ab5 100644 --- a/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp +++ b/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp @@ -42,7 +42,7 @@ int CSendHost_Imgur::Send() { "image", HTTPFORM_FILE(tmp) }, }; - int error = HTTPFormCreate(&m_nlhr, REQUEST_POST, "https://api.imgur.com/3/image", frm, _countof(frm)); + int error = HTTPFormCreate(&m_nlhr, "https://api.imgur.com/3/image", frm, _countof(frm)); mir_free(tmp); if (error) return !m_bAsync; diff --git a/plugins/SendScreenshotPlus/src/CSendHost_imgur.h b/plugins/SendScreenshotPlus/src/CSendHost_imgur.h index c99aaf8fef..4db1c425ec 100644 --- a/plugins/SendScreenshotPlus/src/CSendHost_imgur.h +++ b/plugins/SendScreenshotPlus/src/CSendHost_imgur.h @@ -24,7 +24,6 @@ class CSendHost_Imgur : public CSend { int Send() override; protected: - MHttpRequest m_nlhr; static void SendThread(void* obj); }; #endif diff --git a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp index e9f975190b..a19d6ebc06 100644 --- a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp +++ b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp @@ -15,8 +15,9 @@ */ #include "stdafx.h" -CSendHost_UploadPie::CSendHost_UploadPie(HWND Owner, MCONTACT hContact, bool bAsync, int expire) - : m_expire(expire), CSend(Owner, hContact, bAsync) +CSendHost_UploadPie::CSendHost_UploadPie(HWND Owner, MCONTACT hContact, bool bAsync, int expire) : + CSend(Owner, hContact, bAsync), + m_expire(expire) { m_EnableItem = SS_DLG_DESCRIPTION | SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND; m_pszSendTyp = LPGENW("Image upload"); @@ -46,7 +47,7 @@ int CSendHost_UploadPie::Send() { "expire", HTTPFORM_INT(m_expire) }, }; - int error = HTTPFormCreate(&m_nlhr, REQUEST_POST, kHostURL, frm, _countof(frm)); + int error = HTTPFormCreate(&m_nlhr, kHostURL, frm, _countof(frm)); mir_free(tmp); if (error) return !m_bAsync; diff --git a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.h b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.h index 7a69e4733e..93f7f33b84 100644 --- a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.h +++ b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.h @@ -24,7 +24,6 @@ class CSendHost_UploadPie : public CSend { protected: int m_expire; - MHttpRequest m_nlhr; static void SendThread(void* obj); }; #endif -- cgit v1.2.3