summaryrefslogtreecommitdiff
path: root/plugins/CurrencyRates/src/HTTPSession.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-20 22:57:35 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-20 22:57:35 +0300
commita144aedf745f07beed2257b77839ad7c979b9eec (patch)
treee712d8c6a0c7617fb9c1c08a373fa71837b711c9 /plugins/CurrencyRates/src/HTTPSession.cpp
parent713d02facf10fb187f7f74c32942d18e817a7934 (diff)
CurrencyRates:
- fixes #1857 (rate limit error); - code cleaning; - version bump
Diffstat (limited to 'plugins/CurrencyRates/src/HTTPSession.cpp')
-rw-r--r--plugins/CurrencyRates/src/HTTPSession.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/plugins/CurrencyRates/src/HTTPSession.cpp b/plugins/CurrencyRates/src/HTTPSession.cpp
index 06f1d5409d..e32aac7eab 100644
--- a/plugins/CurrencyRates/src/HTTPSession.cpp
+++ b/plugins/CurrencyRates/src/HTTPSession.cpp
@@ -1,13 +1,21 @@
#include "StdAfx.h"
+#define ERROR_MSG LPGENW("This plugin requires a personal key. Press Yes to obtain it at the site and then enter the result in the Options dialog, otherwise this plugin will fail")
+
+void CALLBACK waitStub()
+{
+ if (IDYES == MessageBox(0, TranslateW(ERROR_MSG), _A2W(CURRENCYRATES_MODULE_NAME), MB_YESNOCANCEL))
+ Utils_OpenUrl("https://free.currencyconverterapi.com/free-api-key");
+}
+
class CHTTPSession::CImpl
{
public:
CImpl() {}
virtual ~CImpl() {}
- virtual bool OpenURL(const tstring& rsURL) = 0;
- virtual bool ReadResponce(tstring& rsResponce)const = 0;
+ virtual bool OpenURL(const tstring &rsURL) = 0;
+ virtual bool ReadResponce(tstring &rsResponce)const = 0;
};
int find_header(const NETLIBHTTPREQUEST* pRequest, const char* hdr)
@@ -32,6 +40,10 @@ public:
{
assert(nullptr == g_hNetLib);
+ ptrA szApiKey(g_plugin.getStringA(DB_KEY_ApiKey));
+ if (szApiKey == nullptr)
+ Miranda_WaitOnHandle(waitStub);
+
NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_NOHTTPSOPTION | NUF_UNICODE;
nlu.szSettingsModule = CURRENCYRATES_PROTOCOL_NAME;