summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-07 13:25:07 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-07 13:25:07 +0300
commite6edc1ba036f66f07878779d4d7a973c80d30efb (patch)
treec310656e2e9aaa4811e264ef2f811e79b5f582e4 /protocols
parenta9fbe9a81a6777b4b358d93116ee15f9f07dfb6e (diff)
hopefully last custom UrlDecode implementation removed
Diffstat (limited to 'protocols')
-rw-r--r--protocols/ICQ-WIM/src/options.cpp2
-rw-r--r--protocols/ICQ-WIM/src/server.cpp2
-rw-r--r--protocols/MSN/src/msn.cpp7
-rw-r--r--protocols/MSN/src/msn_auth.cpp7
-rw-r--r--protocols/MSN/src/msn_commands.cpp4
-rw-r--r--protocols/MSN/src/msn_libstr.cpp36
-rw-r--r--protocols/MSN/src/msn_links.cpp139
-rw-r--r--protocols/MSN/src/stdafx.h2
8 files changed, 7 insertions, 192 deletions
diff --git a/protocols/ICQ-WIM/src/options.cpp b/protocols/ICQ-WIM/src/options.cpp
index 000cf891c1..68b3ea8520 100644
--- a/protocols/ICQ-WIM/src/options.cpp
+++ b/protocols/ICQ-WIM/src/options.cpp
@@ -140,7 +140,7 @@ void CIcqProto::OnLoginViaPhone(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pRe
const JSONNode &data = root.data();
m_szAToken = data["token"]["a"].as_mstring();
- m_szAToken = mir_urlDecode(m_szAToken);
+ mir_urlDecode(m_szAToken.GetBuffer());
setString(DB_KEY_ATOKEN, m_szAToken);
m_szSessionKey = data["sessionKey"].as_mstring();
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp
index 06a2f12d33..3a5004addf 100644
--- a/protocols/ICQ-WIM/src/server.cpp
+++ b/protocols/ICQ-WIM/src/server.cpp
@@ -594,7 +594,7 @@ void CIcqProto::OnCheckPassword(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*)
JSONNode &data = root.data();
m_szAToken = data["token"]["a"].as_mstring();
- m_szAToken = mir_urlDecode(m_szAToken);
+ mir_urlDecode(m_szAToken.GetBuffer());
setString(DB_KEY_ATOKEN, m_szAToken);
CMStringA szSessionSecret = data["sessionSecret"].as_mstring();
diff --git a/protocols/MSN/src/msn.cpp b/protocols/MSN/src/msn.cpp
index 2cdd6f5ff3..e11b6d59bc 100644
--- a/protocols/MSN/src/msn.cpp
+++ b/protocols/MSN/src/msn.cpp
@@ -27,11 +27,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
CMPlugin g_plugin;
/////////////////////////////////////////////////////////////////////////////////////////
-// Initialization routines
-
-void MsnLinks_Init(void);
-
-/////////////////////////////////////////////////////////////////////////////////////////
// Global variables
bool g_bTerminated = false;
@@ -71,8 +66,6 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC
static int OnModulesLoaded(WPARAM, LPARAM)
{
avsPresent = ServiceExists(MS_AV_SETMYAVATARW) != 0;
-
- MsnLinks_Init();
return 0;
}
diff --git a/protocols/MSN/src/msn_auth.cpp b/protocols/MSN/src/msn_auth.cpp
index 02da53e8c9..39d1d0cc98 100644
--- a/protocols/MSN/src/msn_auth.cpp
+++ b/protocols/MSN/src/msn_auth.cpp
@@ -1104,7 +1104,6 @@ int CMsnProto::MSN_AuthOAuth(void)
*pEnd = 0;
pAccessToken += 13;
- UrlDecode(pAccessToken);
/* Extract refresh token */
if (pRefreshToken && (pEnd = strchr(pRefreshToken + 14, '&'))) {
@@ -1122,7 +1121,7 @@ int CMsnProto::MSN_AuthOAuth(void)
authTokenExpiretime += atoi(pExpires);
}
else authTokenExpiretime += 86400;
- authSkypeComToken.SetToken(pAccessToken, authTokenExpiretime);
+ authSkypeComToken.SetToken(mir_urlDecode(pAccessToken), authTokenExpiretime);
/* Copy auth Cookies to class for other web requests like contact list fetching to avoid ActiveSync */
if (nlhrReply) {
@@ -1172,8 +1171,8 @@ int CMsnProto::MSN_AuthOAuth(void)
(pEnd = strchr(pMappingContainer + 20, '"'))) {
*pEnd = 0;
pMappingContainer += 20;
- UrlDecode(pMappingContainer);
- replaceStr(authUIC, pMappingContainer);
+
+ replaceStr(authUIC, mir_urlDecode(pMappingContainer));
replaceStr(authUser, MyOptions.szEmail);
authMethod = retVal = 2;
}
diff --git a/protocols/MSN/src/msn_commands.cpp b/protocols/MSN/src/msn_commands.cpp
index 2eb7a6cad3..8eb13696b8 100644
--- a/protocols/MSN/src/msn_commands.cpp
+++ b/protocols/MSN/src/msn_commands.cpp
@@ -102,7 +102,7 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para
msgBytes = atol(data.strMsgBytes);
nick = data.fromNick;
email = data.fromEmail;
- UrlDecode(nick);
+ mir_urlDecode(nick);
}
stripBBCode(nick);
stripColorCode(nick);
@@ -543,7 +543,7 @@ void CMsnProto::MSN_ProcessYFind(char* buf, size_t len)
void CMsnProto::MSN_ProcessNLN(const char *userStatus, const char *wlid, char *userNick, const char *objid, char *cmdstring)
{
if (userNick) {
- UrlDecode(userNick);
+ mir_urlDecode(userNick);
stripBBCode(userNick);
stripColorCode(userNick);
}
diff --git a/protocols/MSN/src/msn_libstr.cpp b/protocols/MSN/src/msn_libstr.cpp
index 77890a1075..ef2413f11a 100644
--- a/protocols/MSN/src/msn_libstr.cpp
+++ b/protocols/MSN/src/msn_libstr.cpp
@@ -107,42 +107,6 @@ void parseWLID(char* wlid, char** net, char** email, char** inst)
*inst = nullptr;
}
-/////////////////////////////////////////////////////////////////////////////////////////
-// UrlDecode - converts URL chars like %20 into printable characters
-
-static int SingleHexToDecimal(char c)
-{
- if (c >= '0' && c <= '9') return c - '0';
- if (c >= 'a' && c <= 'f') return c - 'a' + 10;
- if (c >= 'A' && c <= 'F') return c - 'A' + 10;
- return -1;
-}
-
-template void UrlDecode(char* str);
-template void UrlDecode(wchar_t* str);
-
-template <class chartype> void UrlDecode(chartype* str)
-{
- chartype* s = str, *d = str;
-
- while (*s) {
- if (*s == '%') {
- int digit1 = SingleHexToDecimal(s[1]);
- if (digit1 != -1) {
- int digit2 = SingleHexToDecimal(s[2]);
- if (digit2 != -1) {
- s += 3;
- *d++ = (char)((digit1 << 4) | digit2);
- continue;
- }
- }
- }
- *d++ = *s++;
- }
-
- *d = 0;
-}
-
void HtmlDecode(char *str)
{
if (str == nullptr)
diff --git a/protocols/MSN/src/msn_links.cpp b/protocols/MSN/src/msn_links.cpp
deleted file mode 100644
index 559e7a9e89..0000000000
--- a/protocols/MSN/src/msn_links.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
-Plugin of Miranda IM for communicating with users of the MSN Messenger protocol.
-
-Copyright (c) 2012-2019 Miranda NG team
-Copyright (c) 2008-2012 Boris Krasnovskiy.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "stdafx.h"
-#include "msn_proto.h"
-
-#include "m_assocmgr.h"
-
-static MCONTACT GetContact(wchar_t *arg, wchar_t **pemail, CMsnProto *proto)
-{
- wchar_t* email = nullptr;
- do {
- wchar_t *tok = wcschr(arg, '&'); /* next token */
- if (tok != nullptr) *tok++ = '\0';
-
- if (wcsnicmp(arg, L"contact=", 8) == 0) {
- arg += 8;
- UrlDecode(arg);
- email = arg;
- }
- arg = tok;
- } while (arg != nullptr);
-
- if (email == nullptr || email[0] == '\0') {
- if (pemail) *pemail = nullptr;
- return NULL;
- }
- if (pemail) *pemail = email;
- MCONTACT hContact = proto->MSN_HContactFromEmail(UTF8(email), nullptr, true, true);
- return hContact;
-}
-
-/*
- add user: msnim:add?contact=netpassport@emailaddress.com
- send message: msnim:chat?contact=netpassport@emailaddress.com
- voice chat: msnim:voice?contact=netpassport@emailaddress.com
- video chat: msnim:video?contact=netpassport@emailaddress.com
- */
-
-static INT_PTR ServiceParseMsnimLink(WPARAM, LPARAM lParam)
-{
- if (lParam == 0) return 1; /* sanity check */
-
- wchar_t *arg = (wchar_t*)lParam;
-
- /* skip leading prefix */
- arg = wcschr(arg, ':');
- if (arg == nullptr) return 1; /* parse failed */
-
- for (++arg; *arg == '/'; ++arg) {}
-
- arg = NEWWSTR_ALLOCA(arg);
-
- if (CMPlugin::g_arInstances.getCount() == 0) return 0;
-
- CMsnProto *proto = &CMPlugin::g_arInstances[0];
- for (auto &it : CMPlugin::g_arInstances)
- if (it->m_iStatus > ID_STATUS_OFFLINE) {
- proto = it;
- break;
- }
-
- if (proto == nullptr)
- return 1;
-
- /* add a contact to the list */
- if (wcsnicmp(arg, L"add?", 4) == 0) {
- arg += 4;
-
- wchar_t *email;
- MCONTACT hContact = GetContact(arg, &email, proto);
- if (email == nullptr) return 1;
-
- /* does not yet check if email is current user */
- if (hContact == NULL) {
- PROTOSEARCHRESULT psr = { sizeof(psr) };
- psr.flags = PSR_UNICODE;
- psr.nick.w = email;
- psr.email.w = email;
- Contact_AddBySearch(proto->m_szModuleName, &psr);
- }
- return 0;
- }
- /* send a message to a contact */
- /* "voice" and "video" not yet implemented, perform same action as "chat" */
- else if (wcsnicmp(arg, L"chat?", 5) == 0) {
- arg += 5;
-
- MCONTACT hContact = GetContact(arg, nullptr, proto);
- if (hContact != NULL) {
- CallService(MS_MSG_SENDMESSAGE, hContact, 0);
- return 0;
- }
- }
- else if (wcsnicmp(arg, L"voice?", 6) == 0) {
- arg += 6;
-
- MCONTACT hContact = GetContact(arg, nullptr, proto);
- if (hContact != NULL) {
- CallService(MS_MSG_SENDMESSAGE, hContact, 0);
- return 0;
- }
- }
- else if (wcsnicmp(arg, L"video?", 6) == 0) {
- arg += 6;
-
- MCONTACT hContact = GetContact(arg, nullptr, proto);
- if (hContact != NULL) {
- CallService(MS_MSG_SENDMESSAGE, hContact, 0);
- return 0;
- }
- }
- return 1; /* parse failed */
-}
-
-void MsnLinks_Init(void)
-{
- static const char szService[] = "MSN/ParseMsnimLink";
-
- CreateServiceFunction(szService, ServiceParseMsnimLink);
- AssocMgr_AddNewUrlTypeW("msnim:", TranslateT("MSN Link Protocol"), g_plugin.getInst(), IDI_MSN, szService, 0);
-}
diff --git a/protocols/MSN/src/stdafx.h b/protocols/MSN/src/stdafx.h
index 0155d6e8e8..bbc01ec445 100644
--- a/protocols/MSN/src/stdafx.h
+++ b/protocols/MSN/src/stdafx.h
@@ -215,8 +215,6 @@ void parseWLID(char* wlid, char** net, char** email, char** inst);
char* GetGlobalIp(void);
-template <class chartype> void UrlDecode(chartype* str);
-
char* MSN_GetAvatarHash(char* szContext, char** pszUrl = nullptr);
bool MSN_MsgWndExist(MCONTACT hContact);