summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-06-03 14:02:02 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-06-03 14:02:02 +0300
commitc1881274c8c431014368f4f5b9b49397e6c579f0 (patch)
tree35534e17812aab00ec9e63b801ccb99a4ee221e9 /protocols
parent240b4b12c1ec026be8a62b7ecd1f4702736b0e1b (diff)
Folders: old TCHAR helpers removed
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Gadu-Gadu/src/gg_proto.cpp2
-rw-r--r--protocols/Gadu-Gadu/src/image.cpp2
-rw-r--r--protocols/MSN/src/msn_misc.cpp4
-rw-r--r--protocols/NewsAggregator/Src/Services.cpp6
-rw-r--r--protocols/Tox/src/main.cpp2
-rw-r--r--protocols/Tox/src/tox_profile.cpp2
-rw-r--r--protocols/Twitter/src/contacts.cpp10
-rw-r--r--protocols/Twitter/src/http.cpp25
-rw-r--r--protocols/Twitter/src/http.h4
-rw-r--r--protocols/Twitter/src/proto.cpp15
-rw-r--r--protocols/Twitter/src/proto.h10
-rw-r--r--protocols/Twitter/src/twitter.cpp11
-rw-r--r--protocols/YAMN/src/main.cpp4
13 files changed, 24 insertions, 73 deletions
diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp
index 53aa06b23f..d4ee9c7520 100644
--- a/protocols/Gadu-Gadu/src/gg_proto.cpp
+++ b/protocols/Gadu-Gadu/src/gg_proto.cpp
@@ -72,7 +72,7 @@ GaduProto::GaduProto(const char *pszProtoName, const wchar_t *tszUserName) :
wchar_t szPath[MAX_PATH];
mir_snwprintf(szPath, L"%s\\%s\\ImageCache", (wchar_t*)VARSW(L"%miranda_userdata%"), m_tszUserName);
- hImagesFolder = FoldersRegisterCustomPathT(LPGEN("Images"), m_szModuleName, szPath, m_tszUserName);
+ hImagesFolder = FoldersRegisterCustomPathW(LPGEN("Images"), m_szModuleName, szPath, m_tszUserName);
DWORD pluginVersion = getDword(GG_PLUGINVERSION, 0);
if (pluginVersion < pluginInfoEx.version)
diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp
index 787cb69c56..3790fbb373 100644
--- a/protocols/Gadu-Gadu/src/image.cpp
+++ b/protocols/Gadu-Gadu/src/image.cpp
@@ -802,7 +802,7 @@ int GaduProto::img_displayasmsg(MCONTACT hContact, void *img)
wchar_t szPath[MAX_PATH], path[MAX_PATH];
size_t tPathLen;
- if (hImagesFolder == nullptr || FoldersGetCustomPathT(hImagesFolder, path, MAX_PATH, L"")) {
+ if (hImagesFolder == nullptr || FoldersGetCustomPathW(hImagesFolder, path, MAX_PATH, L"")) {
wchar_t *tmpPath = Utils_ReplaceVarsW(L"%miranda_userdata%");
tPathLen = mir_snwprintf(szPath, L"%s\\%s\\ImageCache", tmpPath, m_tszUserName);
mir_free(tmpPath);
diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp
index fc9073d73d..cbb853a090 100644
--- a/protocols/MSN/src/msn_misc.cpp
+++ b/protocols/MSN/src/msn_misc.cpp
@@ -93,7 +93,7 @@ void CMsnProto::InitCustomFolders(void)
wchar_t folder[MAX_PATH];
mir_snwprintf(folder, L"%%miranda_avatarcache%%\\%S", m_szModuleName);
- hCustomSmileyFolder = FoldersRegisterCustomPathT(LPGEN("Custom Smileys"), m_szModuleName, folder, m_tszUserName);
+ hCustomSmileyFolder = FoldersRegisterCustomPathW(LPGEN("Custom Smileys"), m_szModuleName, folder, m_tszUserName);
InitCstFldRan = true;
}
@@ -289,7 +289,7 @@ void CMsnProto::MSN_GetCustomSmileyFileName(MCONTACT hContact, wchar_t* pszDest,
InitCustomFolders();
wchar_t* path = (wchar_t*)alloca(cbLen * sizeof(wchar_t));
- if (hCustomSmileyFolder == nullptr || FoldersGetCustomPathT(hCustomSmileyFolder, path, (int)cbLen, L"")) {
+ if (hCustomSmileyFolder == nullptr || FoldersGetCustomPathW(hCustomSmileyFolder, path, (int)cbLen, L"")) {
wchar_t *tmpPath = Utils_ReplaceVarsW(L"%miranda_userdata%");
wchar_t *tszModuleName = mir_a2u(m_szModuleName);
tPathLen = mir_snwprintf(pszDest, cbLen, L"%s\\%s\\CustomSmiley", tmpPath, tszModuleName);
diff --git a/protocols/NewsAggregator/Src/Services.cpp b/protocols/NewsAggregator/Src/Services.cpp
index 9183607841..eda85edfdc 100644
--- a/protocols/NewsAggregator/Src/Services.cpp
+++ b/protocols/NewsAggregator/Src/Services.cpp
@@ -25,14 +25,14 @@ HANDLE hTBButton = nullptr, hNewsAggregatorFolder = nullptr;
int OnFoldersChanged(WPARAM, LPARAM)
{
- FoldersGetCustomPathT(hNewsAggregatorFolder, tszRoot, MAX_PATH, L"");
+ FoldersGetCustomPathW(hNewsAggregatorFolder, tszRoot, MAX_PATH, L"");
return 0;
}
int NewsAggrInit(WPARAM, LPARAM)
{
- if (hNewsAggregatorFolder = FoldersRegisterCustomPathT(LPGEN("Avatars"), LPGEN("News Aggregator"), MIRANDA_USERDATAT L"\\Avatars\\" _A2W(DEFAULT_AVATARS_FOLDER)))
- FoldersGetCustomPathT(hNewsAggregatorFolder, tszRoot, MAX_PATH, L"");
+ if (hNewsAggregatorFolder = FoldersRegisterCustomPathW(LPGEN("Avatars"), LPGEN("News Aggregator"), MIRANDA_USERDATAW L"\\Avatars\\" _A2W(DEFAULT_AVATARS_FOLDER)))
+ FoldersGetCustomPathW(hNewsAggregatorFolder, tszRoot, MAX_PATH, L"");
else
mir_wstrncpy(tszRoot, VARSW(L"%miranda_userdata%\\Avatars\\" _A2W(DEFAULT_AVATARS_FOLDER)), _countof(tszRoot));
diff --git a/protocols/Tox/src/main.cpp b/protocols/Tox/src/main.cpp
index 219c7a07c6..7b509b9378 100644
--- a/protocols/Tox/src/main.cpp
+++ b/protocols/Tox/src/main.cpp
@@ -36,7 +36,7 @@ int OnModulesLoaded(WPARAM, LPARAM)
{
CToxProto::InitIcons();
- hProfileFolderPath = FoldersRegisterCustomPathT("Tox", "ProfilesFolder", MIRANDA_USERDATAT, TranslateT("Profiles folder"));
+ hProfileFolderPath = FoldersRegisterCustomPathW("Tox", "ProfilesFolder", MIRANDA_USERDATAW, TranslateT("Profiles folder"));
if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) {
CreateServiceFunction(MODULE "/ParseUri", CToxProto::ParseToxUri);
diff --git a/protocols/Tox/src/tox_profile.cpp b/protocols/Tox/src/tox_profile.cpp
index 57fbb83a18..2b8ef857c5 100644
--- a/protocols/Tox/src/tox_profile.cpp
+++ b/protocols/Tox/src/tox_profile.cpp
@@ -11,7 +11,7 @@ wchar_t* CToxProto::GetToxProfilePath(const wchar_t *accountName)
{
wchar_t *profilePath = (wchar_t*)mir_calloc(MAX_PATH * sizeof(wchar_t) + 1);
wchar_t profileRootPath[MAX_PATH];
- FoldersGetCustomPathT(hProfileFolderPath, profileRootPath, _countof(profileRootPath), VARSW(L"%miranda_userdata%"));
+ FoldersGetCustomPathW(hProfileFolderPath, profileRootPath, _countof(profileRootPath), VARSW(L"%miranda_userdata%"));
mir_snwprintf(profilePath, MAX_PATH, L"%s\\%s.tox", profileRootPath, accountName);
return profilePath;
}
diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp
index c87dafb226..a64fedb77e 100644
--- a/protocols/Twitter/src/contacts.cpp
+++ b/protocols/Twitter/src/contacts.cpp
@@ -243,14 +243,10 @@ MCONTACT TwitterProto::AddToClientList(const char *name, const char *status)
setWord(hContact, "Status", ID_STATUS_ONLINE);
db_set_utf(hContact, "CList", "StatusMsg", status);
- std::string url = profile_base_url("https://twitter.com/") + http::url_encode(name);
- setString(hContact, "Homepage", url.c_str());
Skin_PlaySound("TwitterNewContact");
- DBVARIANT dbv;
- if (!getWString(TWITTER_KEY_GROUP, &dbv)) {
- db_set_ws(hContact, "CList", "Group", dbv.pwszVal);
- db_free(&dbv);
- }
+ ptrW wszGroup(getWStringA(TWITTER_KEY_GROUP));
+ if (wszGroup)
+ db_set_ws(hContact, "CList", "Group", wszGroup);
return hContact;
}
diff --git a/protocols/Twitter/src/http.cpp b/protocols/Twitter/src/http.cpp
deleted file mode 100644
index 200a3d0adb..0000000000
--- a/protocols/Twitter/src/http.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-Copyright © 2012-19 Miranda NG team
-Copyright © 2009 Jim Porter
-
-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 "http.h"
-
-std::string http::url_encode(const std::string &s)
-{
- return mir_urlEncode(s.c_str());
-}
diff --git a/protocols/Twitter/src/http.h b/protocols/Twitter/src/http.h
index 3568e98c39..b756f4cd71 100644
--- a/protocols/Twitter/src/http.h
+++ b/protocols/Twitter/src/http.h
@@ -35,6 +35,4 @@ namespace http
int code;
std::string data;
};
-
- std::string url_encode(const std::string &);
-} \ No newline at end of file
+}
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp
index 8ff0f75444..3a1b07cc2e 100644
--- a/protocols/Twitter/src/proto.cpp
+++ b/protocols/Twitter/src/proto.cpp
@@ -228,18 +228,11 @@ INT_PTR TwitterProto::ReplyToTweet(WPARAM wParam, LPARAM)
return 0;
}
-INT_PTR TwitterProto::VisitHomepage(WPARAM wParam, LPARAM)
+INT_PTR TwitterProto::VisitHomepage(WPARAM hContact, LPARAM)
{
- MCONTACT hContact = (MCONTACT) wParam;
- DBVARIANT dbv;
- // TODO: remove this
- if (!getString(hContact, TWITTER_KEY_UN, &dbv)) {
- std::string url = profile_base_url("https://twitter.com/") + http::url_encode(dbv.pszVal);
- setString(hContact, "Homepage", url.c_str());
-
- Utils_OpenUrl(url.c_str());
- db_free(&dbv);
- }
+ ptrA szUsername(getStringA(hContact, TWITTER_KEY_UN));
+ if (szUsername)
+ Utils_OpenUrl("https://twitter.com/" + mir_urlEncode(szUsername));
return 0;
}
diff --git a/protocols/Twitter/src/proto.h b/protocols/Twitter/src/proto.h
index b7d05b5686..4fc546d547 100644
--- a/protocols/Twitter/src/proto.h
+++ b/protocols/Twitter/src/proto.h
@@ -135,13 +135,3 @@ struct CMPlugin : public ACCPROTOPLUGIN<TwitterProto>
int Load() override;
};
-
-// TODO: remove this
-inline std::string profile_base_url(const std::string &url)
-{
- size_t x = url.find("://");
- if(x == std::string::npos)
- return url.substr(0,url.find('/')+1);
- else
- return url.substr(0,url.find('/',x+3)+1);
-} \ No newline at end of file
diff --git a/protocols/Twitter/src/twitter.cpp b/protocols/Twitter/src/twitter.cpp
index f86ceac4bc..1b2b98a2e3 100644
--- a/protocols/Twitter/src/twitter.cpp
+++ b/protocols/Twitter/src/twitter.cpp
@@ -105,7 +105,7 @@ bool twitter::get_info(const std::string &name, twitter_user *info)
if (!info)
return false;
- std::string url = base_url_ + "1.1/users/show/" + http::url_encode(name) + ".json";
+ std::string url = base_url_ + "1.1/users/show/" + mir_urlEncode(name.c_str()).c_str() + ".json";
http::response resp = slurp(url, http::get);
if (resp.code != 200)
@@ -129,7 +129,7 @@ bool twitter::get_info_by_email(const std::string &email, twitter_user *info)
if (!info)
return false;
- std::string url = base_url_ + "1.1/users/show.json?email=" + http::url_encode(email);
+ std::string url = base_url_ + "1.1/users/show.json?email=" + mir_urlEncode(email.c_str()).c_str();
http::response resp = slurp(url, http::get);
if (resp.code != 200)
@@ -150,7 +150,7 @@ bool twitter::get_info_by_email(const std::string &email, twitter_user *info)
twitter_user twitter::add_friend(const std::string &name)
{
- std::string url = base_url_ + "1.1/friendships/create/" + http::url_encode(name) + ".json";
+ std::string url = base_url_ + "1.1/friendships/create/" + mir_urlEncode(name.c_str()).c_str() + ".json";
http::response resp = slurp(url, http::post);
if (resp.code != 200)
@@ -176,7 +176,7 @@ twitter_user twitter::add_friend(const std::string &name)
void twitter::remove_friend(const std::string &name)
{
- std::string url = base_url_ + "1.1/friendships/destroy/" + http::url_encode(name) + ".json";
+ std::string url = base_url_ + "1.1/friendships/destroy/" + mir_urlEncode(name.c_str()).c_str() + ".json";
slurp(url, http::post);
}
@@ -300,10 +300,9 @@ std::vector<twitter_user> twitter::get_direct(twitter_id id)
string twitter::urlencode(const string &c)
{
-
string escaped;
size_t max = c.length();
- for (int i = 0; i < max; i++) {
+ for (size_t i = 0; i < max; i++) {
if ((48 <= c[i] && c[i] <= 57) ||//0-9
(65 <= c[i] && c[i] <= 90) ||//ABC...XYZ
(97 <= c[i] && c[i] <= 122) || //abc...xyz
diff --git a/protocols/YAMN/src/main.cpp b/protocols/YAMN/src/main.cpp
index d214f5e982..f1434b332e 100644
--- a/protocols/YAMN/src/main.cpp
+++ b/protocols/YAMN/src/main.cpp
@@ -144,8 +144,8 @@ int SystemModulesLoaded(WPARAM, LPARAM)
CheckMenuItems();
- if (hAccountFolder = FoldersRegisterCustomPathT(LPGEN("YAMN"), LPGEN("YAMN Account Folder"), UserDirectory))
- FoldersGetCustomPathT(hAccountFolder, UserDirectory, MAX_PATH, UserDirectory);
+ if (hAccountFolder = FoldersRegisterCustomPathW(LPGEN("YAMN"), LPGEN("YAMN Account Folder"), UserDirectory))
+ FoldersGetCustomPathW(hAccountFolder, UserDirectory, MAX_PATH, UserDirectory);
RegisterPOP3Plugin(0, 0);
return 0;