diff options
-rw-r--r-- | protocols/Twitter/src/connection.cpp | 10 | ||||
-rw-r--r-- | protocols/Twitter/src/contacts.cpp | 1 | ||||
-rw-r--r-- | protocols/Twitter/src/oauth.cpp | 6 | ||||
-rw-r--r-- | protocols/Twitter/src/proto.cpp | 16 | ||||
-rw-r--r-- | protocols/Twitter/src/proto.h | 8 | ||||
-rw-r--r-- | protocols/Twitter/src/version.h | 2 |
6 files changed, 16 insertions, 27 deletions
diff --git a/protocols/Twitter/src/connection.cpp b/protocols/Twitter/src/connection.cpp index 096ef0bb4c..251d901cf5 100644 --- a/protocols/Twitter/src/connection.cpp +++ b/protocols/Twitter/src/connection.cpp @@ -130,7 +130,7 @@ bool TwitterProto::NegotiateConnection() debugLogA("**NegotiateConnection - Reset OAuth Keys");
debugLogA("**NegotiateConnection - Setting Consumer Keys...");
- twit_.set_credentials("", ConsumerKey, ConsumerSecret, oauthToken, oauthTokenSecret, L"", false);
+ twit_.set_credentials("", OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, oauthToken, oauthTokenSecret, L"", false);
debugLogA("**NegotiateConnection - Requesting oauthTokens");
http::response resp = twit_.request_token();
@@ -152,7 +152,7 @@ bool TwitterProto::NegotiateConnection() // this looks like bad code.. can someone clean this up please? or confirm that it's ok
wchar_t buf[1024] = {};
- mir_snwprintf(buf, _countof(buf), AuthorizeUrl.c_str(), oauthToken.c_str());
+ mir_snwprintf(buf, L"https://api.twitter.com/oauth/authorize?oauth_token=%s", oauthToken.c_str());
debugLogW(L"**NegotiateConnection - Launching %s", buf);
ShellExecute(nullptr, L"open", buf, nullptr, nullptr, SW_SHOWNORMAL);
@@ -213,7 +213,7 @@ bool TwitterProto::NegotiateConnection() debugLogA("**NegotiateConnection - Setting Consumer Keys and PIN...");
- twit_.set_credentials("", ConsumerKey, ConsumerSecret, oauthToken, oauthTokenSecret, pin, false);
+ twit_.set_credentials("", OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, oauthToken, oauthTokenSecret, pin, false);
debugLogA("**NegotiateConnection - requesting access tokens...");
http::response accessResp = twit_.request_access_tokens();
@@ -243,7 +243,7 @@ bool TwitterProto::NegotiateConnection() screenName = WideToUTF8(accessTokenParameters[L"screen_name"]);
debugLogA("**NegotiateConnection - screen name is %s", screenName.c_str());
- //save em
+ // save em
setWString(TWITTER_KEY_OAUTH_ACCESS_TOK, oauthAccessToken.c_str());
setWString(TWITTER_KEY_OAUTH_ACCESS_TOK_SECRET, oauthAccessTokenSecret.c_str());
setString(TWITTER_KEY_NICK, screenName.c_str());
@@ -267,7 +267,7 @@ bool TwitterProto::NegotiateConnection() bool success;
{
mir_cslock s(twitter_lock_);
- success = twit_.set_credentials(screenName, ConsumerKey, ConsumerSecret, oauthAccessToken, oauthAccessTokenSecret, L"", true);
+ success = twit_.set_credentials(screenName, OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, oauthAccessToken, oauthAccessTokenSecret, L"", true);
}
if (!success) {
diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp index a64fedb77e..7f22e8e700 100644 --- a/protocols/Twitter/src/contacts.cpp +++ b/protocols/Twitter/src/contacts.cpp @@ -240,6 +240,7 @@ MCONTACT TwitterProto::AddToClientList(const char *name, const char *status) if (hContact) {
if (Proto_AddToContact(hContact, m_szModuleName) == 0) {
setString(hContact, TWITTER_KEY_UN, name);
+ setString(hContact, "Homepage", "https://twitter.com/" + CMStringA(name));
setWord(hContact, "Status", ID_STATUS_ONLINE);
db_set_utf(hContact, "CList", "StatusMsg", status);
diff --git a/protocols/Twitter/src/oauth.cpp b/protocols/Twitter/src/oauth.cpp index d2e8fbcc5a..afdb23413a 100644 --- a/protocols/Twitter/src/oauth.cpp +++ b/protocols/Twitter/src/oauth.cpp @@ -252,7 +252,7 @@ wstring mir_twitter::OAuthNormalizeUrl(const wstring& url) if (Compare(brokenURL[L"scheme"], L"http", false) && !(Compare(brokenURL[L"port"], L"80", false)) ||
(Compare(brokenURL[L"scheme"], L"https", false) && !(Compare(brokenURL[L"port"], L"443", false))))
{
- mir_snwprintf(port, _countof(port), L":%s", brokenURL[L"port"].c_str());
+ mir_snwprintf(port, L":%s", brokenURL[L"port"].c_str());
}
// InternetCrackUrl includes ? and # elements in the path,
@@ -322,7 +322,7 @@ wstring mir_twitter::OAuthCreateTimestamp() _ASSERTE(utcNow != -1);
wchar_t buf[100] = {};
- mir_snwprintf(buf, _countof(buf), L"%I64u", utcNow);
+ mir_snwprintf(buf, L"%I64u", utcNow);
return buf;
}
@@ -339,7 +339,7 @@ wstring mir_twitter::OAuthCreateSignature(const wstring& signatureBase, const ws BYTE digest[MIR_SHA1_HASH_SIZE];
unsigned int len;
string data = WideToUTF8(signatureBase);
- HMAC(EVP_sha1(), keyBytes.c_str(), keyBytes.size(), (PBYTE)data.c_str(), data.size(), digest, &len);
+ HMAC(EVP_sha1(), keyBytes.c_str(), (int)keyBytes.size(), (PBYTE)data.c_str(), data.size(), digest, &len);
ptrA encoded(mir_base64_encode(digest, sizeof(digest)));
return UrlEncode((wchar_t*)_A2T(encoded));
}
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp index 7db3a47156..0496409e9b 100644 --- a/protocols/Twitter/src/proto.cpp +++ b/protocols/Twitter/src/proto.cpp @@ -22,7 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "utility.h"
#include "theme.h"
#include "ui.h"
-#include "..\..\..\..\miranda-private-keys\Twitter\oauth.dev.h"
static volatile LONG g_msgid = 1;
@@ -85,11 +84,9 @@ TwitterProto::TwitterProto(const char *proto_name, const wchar_t *username) : twit_.set_handle(this, m_hNetlibUser);
- // mirandas keys
- ConsumerKey = OAUTH_CONSUMER_KEY;
- ConsumerSecret = OAUTH_CONSUMER_SECRET;
-
- AuthorizeUrl = L"https://api.twitter.com/oauth/authorize?oauth_token=%s";
+ db_set_resident(m_szModuleName, "Homepage");
+ for (auto &it : AccContacts())
+ setString(it, "Homepage", "https://twitter.com/" + getMStringA(it, TWITTER_KEY_UN));
}
TwitterProto::~TwitterProto()
@@ -230,10 +227,7 @@ INT_PTR TwitterProto::ReplyToTweet(WPARAM wParam, LPARAM) INT_PTR TwitterProto::VisitHomepage(WPARAM hContact, LPARAM)
{
- ptrA szUsername(getStringA(hContact, TWITTER_KEY_UN));
- if (szUsername)
- Utils_OpenUrl("https://twitter.com/" + mir_urlEncode(szUsername));
-
+ Utils_OpenUrl(getMStringA(MCONTACT(hContact), "Homepage"));
return 0;
}
@@ -396,7 +390,7 @@ void TwitterProto::UpdateSettings() std::wstring TwitterProto::GetAvatarFolder()
{
wchar_t path[MAX_PATH];
- mir_snwprintf(path, L"%s\\%s", VARSW(L"%miranda_avatarcache%"), m_tszUserName);
+ mir_snwprintf(path, L"%s\\%s", VARSW(L"%miranda_avatarcache%").get(), m_tszUserName);
return path;
}
diff --git a/protocols/Twitter/src/proto.h b/protocols/Twitter/src/proto.h index 4fc546d547..4c7f08deed 100644 --- a/protocols/Twitter/src/proto.h +++ b/protocols/Twitter/src/proto.h @@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #pragma once
#include "utility.h"
+#include "..\..\..\..\miranda-private-keys\Twitter\oauth.dev.h"
class TwitterProto : public PROTO<TwitterProto>
{
@@ -120,13 +121,6 @@ private: bool in_chat_;
int disconnectionCount;
-
- //mirandas keys
- wstring ConsumerKey;
- wstring ConsumerSecret;
-
- // various twitter api URLs
- wstring AuthorizeUrl;
};
struct CMPlugin : public ACCPROTOPLUGIN<TwitterProto>
diff --git a/protocols/Twitter/src/version.h b/protocols/Twitter/src/version.h index 71b76e1830..6023a8ef8f 100644 --- a/protocols/Twitter/src/version.h +++ b/protocols/Twitter/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 1
#define __MINOR_VERSION 3
#define __RELEASE_NUM 0
-#define __BUILD_NUM 2
+#define __BUILD_NUM 3
#include <stdver.h>
|