diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2015-06-07 18:54:38 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2015-06-07 18:54:38 +0000 |
commit | 5d6989883de96e8f0f369dfb8af549963638ac61 (patch) | |
tree | 8fe86f09740268821624c26a6b969c1e2de946c0 | |
parent | e5cb033463036b182fb6e5e3eed50a14987f5300 (diff) |
SkypeWeb: Search -> UTF-8. Code optimization.
git-svn-id: http://svn.miranda-ng.org/main/trunk@14055 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | protocols/SkypeWeb/src/http_request.h | 22 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_mslogin.cpp | 3 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_polling.cpp | 4 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_search.cpp | 10 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_trouter.cpp | 4 |
5 files changed, 31 insertions, 12 deletions
diff --git a/protocols/SkypeWeb/src/http_request.h b/protocols/SkypeWeb/src/http_request.h index f12a5111b1..363ff6ec87 100644 --- a/protocols/SkypeWeb/src/http_request.h +++ b/protocols/SkypeWeb/src/http_request.h @@ -264,4 +264,26 @@ public: }
};
+class NLHR_PTR
+{
+protected:
+ NETLIBHTTPREQUEST *_p;
+
+public:
+ __inline explicit NLHR_PTR(NETLIBHTTPREQUEST *p) : _p(p) {}
+ __inline NETLIBHTTPREQUEST* operator=(NETLIBHTTPREQUEST *p)
+ {
+ if (_p)
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)(NETLIBHTTPREQUEST*)_p);
+ _p = p;
+ return _p;
+ }
+ __inline operator NETLIBHTTPREQUEST*() const { return _p; }
+ __inline NETLIBHTTPREQUEST* operator->() const { return _p; }
+ __inline ~NLHR_PTR()
+ {
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)(NETLIBHTTPREQUEST*)this);
+ }
+};
+
#endif //_HTTP_REQUEST_H_
\ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_mslogin.cpp b/protocols/SkypeWeb/src/skype_mslogin.cpp index b6134d231b..6109fbeba2 100644 --- a/protocols/SkypeWeb/src/skype_mslogin.cpp +++ b/protocols/SkypeWeb/src/skype_mslogin.cpp @@ -176,9 +176,10 @@ void CSkypeProto::OnMSLoginEnd(const NETLIBHTTPREQUEST *response) CMString CSkypeProto::RunConfirmationCode()
{
+ CMString caption(FORMAT, _T("[%s] %s"), _A2T(m_szModuleName), TranslateT("Enter confirmation code"));
ENTER_STRING pForm = { sizeof(pForm) };
pForm.type = ESF_PASSWORD;
- pForm.caption = TranslateT("Enter confirmation code");
+ pForm.caption = caption;
pForm.ptszInitVal = NULL;
pForm.szModuleName = m_szModuleName;
return (!EnterString(&pForm)) ? CMString() : CMString(ptrT(pForm.ptszResult));
diff --git a/protocols/SkypeWeb/src/skype_polling.cpp b/protocols/SkypeWeb/src/skype_polling.cpp index 5bab08dce0..612547b1ee 100644 --- a/protocols/SkypeWeb/src/skype_polling.cpp +++ b/protocols/SkypeWeb/src/skype_polling.cpp @@ -66,7 +66,7 @@ void CSkypeProto::PollingThread(void*) {
PollRequest *request = new PollRequest(m_szRegToken, m_szServer);
request->nlc = m_pollingConnection;
- NETLIBHTTPREQUEST *response = request->Send(m_hNetlibUser);
+ NLHR_PTR response(request->Send(m_hNetlibUser));
if (response == NULL)
{
@@ -99,7 +99,6 @@ void CSkypeProto::PollingThread(void*) int errorCode = error.as_int();
if (errorCode == 729)
{
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response);
delete request;
break;
}
@@ -108,7 +107,6 @@ void CSkypeProto::PollingThread(void*) }
m_pollingConnection = response->nlc;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response);
delete request;
}
diff --git a/protocols/SkypeWeb/src/skype_search.cpp b/protocols/SkypeWeb/src/skype_search.cpp index 16ea1fd67e..3284d4f533 100644 --- a/protocols/SkypeWeb/src/skype_search.cpp +++ b/protocols/SkypeWeb/src/skype_search.cpp @@ -61,13 +61,13 @@ void CSkypeProto::OnSearch(const NETLIBHTTPREQUEST *response) const JSONNode &ContactCards = item["ContactCards"];
const JSONNode &Skype = ContactCards["Skype"];
- CMString tszDisplayName(Skype["DisplayName"].as_mstring());
- CMString tszNick(Skype["SkypeName"].as_mstring());
+ CMStringA displayName(Skype["DisplayName"].as_string().c_str());
+ CMStringA nick(Skype["SkypeName"].as_string().c_str());
PROTOSEARCHRESULT psr = { sizeof(psr) };
- psr.flags = PSR_TCHAR;
- psr.id.t = tszDisplayName.GetBuffer();
- psr.nick.t = tszNick.GetBuffer();
+ psr.flags = PSR_UTF8;
+ psr.id.a = displayName.GetBuffer();
+ psr.nick.a = nick.GetBuffer();
ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)&psr);
}
diff --git a/protocols/SkypeWeb/src/skype_trouter.cpp b/protocols/SkypeWeb/src/skype_trouter.cpp index 8b8d6594d8..2e0a6e27b1 100644 --- a/protocols/SkypeWeb/src/skype_trouter.cpp +++ b/protocols/SkypeWeb/src/skype_trouter.cpp @@ -182,7 +182,7 @@ void CSkypeProto::TRouterThread(void*) {
TrouterPollRequest *request = new TrouterPollRequest(TRouter.socketIo, TRouter.connId, TRouter.st, TRouter.se, TRouter.sig, TRouter.instance, TRouter.ccid, TRouter.sessId);
request->nlc = m_TrouterConnection;
- NETLIBHTTPREQUEST *response = request->Send(m_hNetlibUser);
+ NLHR_PTR response(request->Send(m_hNetlibUser));
if (response == NULL)
{
@@ -209,12 +209,10 @@ void CSkypeProto::TRouterThread(void*) else
{
SendRequest(new HealthTrouterRequest(TRouter.ccid.c_str()), &CSkypeProto::OnHealth);
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response);
delete request;
break;
}
m_TrouterConnection = response->nlc;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response);
delete request;
}
m_hTrouterThread = NULL;
|