summaryrefslogtreecommitdiff
path: root/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp')
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp
index ec4c9203f1..b6b131cca9 100644
--- a/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp
@@ -2,7 +2,7 @@
Miranda NG: the free IM client for Microsoft* Windows*
-Copyright (C) 2012-24 Miranda NG team (https://miranda-ng.org),
+Copyright (C) 2012-25 Miranda NG team (https://miranda-ng.org),
Copyright (c) 2000-09 Miranda ICQ/IM project,
This file is part of Send Screenshot Plus, a Miranda IM plugin.
@@ -46,24 +46,40 @@ CSendHost_ImageShack::~CSendHost_ImageShack()
int CSendHost_ImageShack::Send()
{
if (!g_hNetlibUser) { // check Netlib
+LBL_Error:
Error(SS_ERR_INIT, m_pszSendTyp);
Exit(ACKRESULT_FAILED);
return !m_bAsync;
}
+ CMStringA szKey(g_plugin.getMStringA("Key"));
+ if (szKey.IsEmpty()) {
+ ENTER_STRING es = {};
+ es.szModuleName = MODULENAME;
+ es.caption = TranslateT("Enter your personal API key from Imageshack");
+ if (!EnterString(&es)) {
+ m_pszSendTyp = LPGENW("API key is missing");
+ goto LBL_Error;
+ }
+
+ szKey = es.ptszResult;
+ g_plugin.setString("Key", szKey);
+ }
+
m_pRequest.reset(new MHttpRequest(REQUEST_POST));
- char* tmp; tmp = mir_u2a(m_pszFile);
+ T2Utf tmp(m_pszFile);
HTTPFormData frm[] = {
// { "Referer", HTTPFORM_HEADER("http://www.imageshack.us/upload_api.php") },
{ "fileupload", HTTPFORM_FILE(tmp) },
// { "rembar", "yes" },// no info bar on thumb
{ "public", "no" },
- { "key", HTTPFORM_8BIT(DEVKEY_IMAGESHACK) },
+ { "key", szKey.c_str() },
};
+
int error = HTTPFormCreate(m_pRequest.get(), "http://imageshack.us/upload_api.php", frm, sizeof(frm) / sizeof(HTTPFormData));
- mir_free(tmp);
if (error)
return !m_bAsync;
+
// start upload thread
if (m_bAsync) {
mir_forkthread(&CSendHost_ImageShack::SendThreadWrapper, this);
@@ -79,7 +95,7 @@ void CSendHost_ImageShack::SendThread()
NLHR_PTR reply(Netlib_HttpTransaction(g_hNetlibUser, m_pRequest.get()));
if (reply) {
if (reply->resultCode >= 200 && reply->resultCode < 300 && reply->body.GetLength()) {
- const char* url = nullptr;
+ const char *url = nullptr;
url = GetHTMLContent(reply->body.GetBuffer(), "<image_link>", "</image_link>");
if (url && *url) {
m_URLthumb = m_URL = url;
@@ -87,7 +103,7 @@ void CSendHost_ImageShack::SendThread()
int idx = m_URLthumb.ReverseFind('.');
if (idx != -1 && m_URLthumb.GetLength() - idx > 2)
m_URLthumb.Insert(idx + 1, "th");
- else
+ else
m_URLthumb.Empty();
svcSendMsgExit(url);
@@ -95,7 +111,7 @@ void CSendHost_ImageShack::SendThread()
}
url = GetHTMLContent(reply->body.GetBuffer(), "<error ", "</error>");
- wchar_t* err = nullptr;
+ wchar_t *err = nullptr;
if (url) err = mir_a2u(url);
if (!err || !*err) { // fallback to server response mess
mir_free(err);
@@ -111,7 +127,7 @@ void CSendHost_ImageShack::SendThread()
Exit(ACKRESULT_FAILED);
}
-void CSendHost_ImageShack::SendThreadWrapper(void * Obj)
+void CSendHost_ImageShack::SendThreadWrapper(void *Obj)
{
- reinterpret_cast<CSendHost_ImageShack*>(Obj)->SendThread();
+ reinterpret_cast<CSendHost_ImageShack *>(Obj)->SendThread();
}