summaryrefslogtreecommitdiff
path: root/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp')
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp
index bd44dfd008..13bd17aa8d 100644
--- a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp
@@ -2,7 +2,7 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
- Copyright (C) 2014-24 Miranda NG team (https://miranda-ng.org)
+ Copyright (C) 2014-25 Miranda NG team (https://miranda-ng.org)
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
@@ -38,9 +38,10 @@ int CSendHost_UploadPie::Send()
Exit(ACKRESULT_FAILED);
return !m_bAsync;
}
-
+
m_pRequest.reset(new MHttpRequest(REQUEST_POST));
- char* tmp; tmp = mir_u2a(m_pszFile);
+ T2Utf tmp(m_pszFile);
+
HTTPFormData frm[] = {
{ "MAX_FILE_SIZE", HTTPFORM_INT(3145728) },
{ "upload", HTTPFORM_INT(1) },
@@ -49,10 +50,9 @@ int CSendHost_UploadPie::Send()
};
int error = HTTPFormCreate(m_pRequest.get(), kHostURL, frm, _countof(frm));
- mir_free(tmp);
if (error)
return !m_bAsync;
-
+
// start upload thread
if (m_bAsync) {
mir_forkthread(&CSendHost_UploadPie::SendThread, this);
@@ -62,35 +62,37 @@ int CSendHost_UploadPie::Send()
return 1;
}
-void CSendHost_UploadPie::SendThread(void* obj)
+void CSendHost_UploadPie::SendThread(void *obj)
{
- CSendHost_UploadPie* self = (CSendHost_UploadPie*)obj;
+ CSendHost_UploadPie *self = (CSendHost_UploadPie *)obj;
// send DATA and wait for m_nlreply
NLHR_PTR reply(Netlib_HttpTransaction(g_hNetlibUser, self->m_pRequest.get()));
if (reply) {
if (reply->resultCode >= 200 && reply->resultCode < 300 && reply->body.GetLength()) {
- char* url = reply->body.GetBuffer();
+ char *url = reply->body.GetBuffer();
do {
- char* pos;
+ char *pos;
if ((url = strstr(url, kHostURL))) {
- for (pos = url + _countof(kHostURL)-1; (*pos >= '0'&&*pos <= '9') || (*pos >= 'a'&&*pos <= 'z') || (*pos >= 'A'&&*pos <= 'Z') || *pos == '_' || *pos == '-' || *pos == '"' || *pos == '\''; ++pos) {
- if (*pos == '"' || *pos == '\'') break;
+ for (pos = url + _countof(kHostURL) - 1; (*pos >= '0' && *pos <= '9') || (*pos >= 'a' && *pos <= 'z') || (*pos >= 'A' && *pos <= 'Z') || *pos == '_' || *pos == '-' || *pos == '"' || *pos == '\''; ++pos) {
+ if (*pos == '"' || *pos == '\'')
+ break;
}
- if (url + _countof(kHostURL)-1 != pos && (*pos == '"' || *pos == '\'')) {
+ if (url + _countof(kHostURL) - 1 != pos && (*pos == '"' || *pos == '\'')) {
*pos = '\0';
break;
}
++url;
}
} while (url);
-
+
if (url) {
self->m_URL = url;
- self->svcSendMsgExit(url); return;
+ self->svcSendMsgExit(url);
+ return;
}
else { // check error mess from server
- const char* err = GetHTMLContent(reply->body.GetBuffer(), "<p id=\"error\"", "</p>");
- wchar_t* werr;
+ const char *err = GetHTMLContent(reply->body.GetBuffer(), "<p id=\"error\"", "</p>");
+ wchar_t *werr;
if (err) werr = mir_a2u(err);
else werr = mir_a2u(reply->body);
self->Error(L"%s", werr);