summaryrefslogtreecommitdiff
path: root/protocols/Twitter/src
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/Twitter/src
parent240b4b12c1ec026be8a62b7ecd1f4702736b0e1b (diff)
Folders: old TCHAR helpers removed
Diffstat (limited to 'protocols/Twitter/src')
-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
6 files changed, 13 insertions, 62 deletions
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