summaryrefslogtreecommitdiff
path: root/protocols/Twitter
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2015-07-03 20:56:56 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2015-07-03 20:56:56 +0000
commitfee85fe9916e603d9fdd7e6c61e1f3380df59d51 (patch)
treeae164d83ae2d503093c5a77aba5b2efc8311ce45 /protocols/Twitter
parente3c473aceee0428a0d4ca80024c65953d43b96bd (diff)
Twitter:
- Fixed retweets (broken after r13248) - minor cleantup git-svn-id: http://svn.miranda-ng.org/main/trunk@14486 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Twitter')
-rw-r--r--protocols/Twitter/src/chat.cpp2
-rw-r--r--protocols/Twitter/src/connection.cpp82
-rw-r--r--protocols/Twitter/src/contacts.cpp39
-rw-r--r--protocols/Twitter/src/proto.cpp17
-rw-r--r--protocols/Twitter/src/proto.h5
-rw-r--r--protocols/Twitter/src/twitter.cpp6
-rw-r--r--protocols/Twitter/src/ui.cpp52
7 files changed, 103 insertions, 100 deletions
diff --git a/protocols/Twitter/src/chat.cpp b/protocols/Twitter/src/chat.cpp
index 6771ce6cd2..dd0ae00377 100644
--- a/protocols/Twitter/src/chat.cpp
+++ b/protocols/Twitter/src/chat.cpp
@@ -168,7 +168,7 @@ void TwitterProto::SetChatStatus(int status)
continue;
DBVARIANT uid, nick;
- if (db_get_s(hContact, m_szModuleName, TWITTER_KEY_UN, &uid))
+ if (getString(hContact, TWITTER_KEY_UN, &uid))
continue;
if (!db_get_s(hContact, "CList", "MyHandle", &nick)) {
diff --git a/protocols/Twitter/src/connection.cpp b/protocols/Twitter/src/connection.cpp
index fcd515f43e..49f4176a69 100644
--- a/protocols/Twitter/src/connection.cpp
+++ b/protocols/Twitter/src/connection.cpp
@@ -64,7 +64,7 @@ void TwitterProto::SignOn(void*)
}
if (NegotiateConnection()) // Could this be? The legendary Go Time??
{
- if (!in_chat_ && db_get_b(0, m_szModuleName, TWITTER_KEY_CHATFEED, 0))
+ if (!in_chat_ && getByte(TWITTER_KEY_CHATFEED))
OnJoinChat(0, true);
SetAllContactStatuses(ID_STATUS_ONLINE);
@@ -89,31 +89,31 @@ bool TwitterProto::NegotiateConnection()
wstring oauthAccessTokenSecret;
string screenName;
- INT_PTR dbTOK = db_get_ws(0, m_szModuleName, TWITTER_KEY_OAUTH_TOK, &dbv);
+ INT_PTR dbTOK = getWString(TWITTER_KEY_OAUTH_TOK, &dbv);
if (!dbTOK) {
oauthToken = dbv.pwszVal;
db_free(&dbv);
//debugLogW("**NegotiateConnection - we have an oauthToken already in the db - %s", oauthToken);
}
- INT_PTR dbTOKSec = db_get_ws(0, m_szModuleName, TWITTER_KEY_OAUTH_TOK_SECRET, &dbv);
+ INT_PTR dbTOKSec = getWString(TWITTER_KEY_OAUTH_TOK_SECRET, &dbv);
if (!dbTOKSec) {
oauthTokenSecret = dbv.pwszVal;
db_free(&dbv);
//debugLogW("**NegotiateConnection - we have an oauthTokenSecret already in the db - %s", oauthTokenSecret);
}
- INT_PTR dbName = db_get_s(0, m_szModuleName, TWITTER_KEY_NICK, &dbv);
+ INT_PTR dbName = getString(TWITTER_KEY_NICK, &dbv);
if (!dbName) {
screenName = dbv.pszVal;
db_free(&dbv);
//debugLogW("**NegotiateConnection - we have a username already in the db - %s", screenName);
}
else {
- dbName = db_get_s(0, m_szModuleName, TWITTER_KEY_UN, &dbv);
+ dbName = getString(TWITTER_KEY_UN, &dbv);
if (!dbName) {
screenName = dbv.pszVal;
- db_set_s(0, m_szModuleName, TWITTER_KEY_NICK, dbv.pszVal);
+ setString(TWITTER_KEY_NICK, dbv.pszVal);
db_free(&dbv);
//debugLogW("**NegotiateConnection - we have a username already in the db - %s", screenName);
}
@@ -122,9 +122,9 @@ bool TwitterProto::NegotiateConnection()
// twitter changed the base URL in v1.1 of the API, I don't think users will need to modify it, so
// i'll be forcing it to the new API URL here. After a while I can get rid of this as users will
// have either had this run at least once, or have reset their miranda profile. 14/10/2012
- if (db_get_b(0, m_szModuleName, "UpgradeBaseURL", 1)) {
- db_set_s(0, m_szModuleName, TWITTER_KEY_BASEURL, "https://api.twitter.com/");
- db_set_b(0, m_szModuleName, "UpgradeBaseURL", 0);
+ if (getByte("UpgradeBaseURL", 1)) {
+ setString(TWITTER_KEY_BASEURL, "https://api.twitter.com/");
+ setByte("UpgradeBaseURL", 0);
}
if ((oauthToken.size() <= 1) || (oauthTokenSecret.size() <= 1)) {
@@ -162,8 +162,8 @@ bool TwitterProto::NegotiateConnection()
}
//write those bitches to the db foe latta
- db_set_ws(0, m_szModuleName, TWITTER_KEY_OAUTH_TOK, oauthToken.c_str());
- db_set_ws(0, m_szModuleName, TWITTER_KEY_OAUTH_TOK_SECRET, oauthTokenSecret.c_str());
+ setTString(TWITTER_KEY_OAUTH_TOK, oauthToken.c_str());
+ setTString(TWITTER_KEY_OAUTH_TOK_SECRET, oauthTokenSecret.c_str());
// this looks like bad code.. can someone clean this up please? or confirm that it's ok
wchar_t buf[1024] = {};
@@ -175,7 +175,7 @@ bool TwitterProto::NegotiateConnection()
ShowPinDialog();
}
- if (!db_get_ts(NULL, m_szModuleName, TWITTER_KEY_GROUP, &dbv)) {
+ if (!getTString(TWITTER_KEY_GROUP, &dbv)) {
CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)dbv.ptszVal);
db_free(&dbv);
}
@@ -184,7 +184,7 @@ bool TwitterProto::NegotiateConnection()
bool realAccessTokSecret = false;
// remember, dbTOK is 0 (false) if the db setting has returned something
- dbTOK = db_get_ws(0, m_szModuleName, TWITTER_KEY_OAUTH_ACCESS_TOK, &dbv);
+ dbTOK = getWString(TWITTER_KEY_OAUTH_ACCESS_TOK, &dbv);
if (!dbTOK) {
oauthAccessToken = dbv.pwszVal;
db_free(&dbv);
@@ -196,7 +196,7 @@ bool TwitterProto::NegotiateConnection()
else { debugLogA("**NegotiateConnection - oauthAccesToken too small? this is.. weird."); }
}
- dbTOKSec = db_get_ws(0, m_szModuleName, TWITTER_KEY_OAUTH_ACCESS_TOK_SECRET, &dbv);
+ dbTOKSec = getWString(TWITTER_KEY_OAUTH_ACCESS_TOK_SECRET, &dbv);
if (!dbTOKSec) {
oauthAccessTokenSecret = dbv.pwszVal;
db_free(&dbv);
@@ -210,7 +210,7 @@ bool TwitterProto::NegotiateConnection()
if (!realAccessTok || !realAccessTokSecret) { // if we don't have one of these beasties then lets go get 'em!
wstring pin;
debugLogA("**NegotiateConnection - either the accessToken or accessTokenSecret was not there..");
- if (!db_get_ws(0, m_szModuleName, TWITTER_KEY_OAUTH_PIN, &dbv)) {
+ if (!getWString(TWITTER_KEY_OAUTH_PIN, &dbv)) {
pin = dbv.pwszVal;
//debugLogW("**NegotiateConnection - we have an pin already in the db - %s", pin);
db_free(&dbv);
@@ -274,14 +274,14 @@ bool TwitterProto::NegotiateConnection()
debugLogA("**NegotiateConnection - screen name is %s", screenName.c_str());
//save em
- db_set_ws(0, m_szModuleName, TWITTER_KEY_OAUTH_ACCESS_TOK, oauthAccessToken.c_str());
- db_set_ws(0, m_szModuleName, TWITTER_KEY_OAUTH_ACCESS_TOK_SECRET, oauthAccessTokenSecret.c_str());
- db_set_s(0, m_szModuleName, TWITTER_KEY_NICK, screenName.c_str());
- db_set_s(0, m_szModuleName, TWITTER_KEY_UN, screenName.c_str());
+ 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());
+ setString(TWITTER_KEY_UN, screenName.c_str());
}
}
- if (!db_get_s(0, m_szModuleName, TWITTER_KEY_BASEURL, &dbv)) {
+ if (!getString(TWITTER_KEY_BASEURL, &dbv)) {
mir_cslock s(twitter_lock_);
twit_.set_base_url(dbv.pszVal);
db_free(&dbv);
@@ -330,13 +330,13 @@ void TwitterProto::MessageLoop(void*)
since_id_ = db_pod_get<twitter_id>(0, m_szModuleName, TWITTER_KEY_SINCEID, 0);
dm_since_id_ = db_pod_get<twitter_id>(0, m_szModuleName, TWITTER_KEY_DMSINCEID, 0);
- bool new_account = db_get_b(0, m_szModuleName, TWITTER_KEY_NEW, 1) != 0;
- bool popups = db_get_b(0, m_szModuleName, TWITTER_KEY_POPUP_SIGNON, 1) != 0;
+ bool new_account = getByte(TWITTER_KEY_NEW, 1) != 0;
+ bool popups = getByte(TWITTER_KEY_POPUP_SIGNON, 1) != 0;
// if this isn't set, it will automatically not turn a tweet into a msg. probably should make the default that it does turn a tweet into a message
- bool tweetToMsg = db_get_b(0, m_szModuleName, TWITTER_KEY_TWEET_TO_MSG, 0) != 0;
+ bool tweetToMsg = getByte(TWITTER_KEY_TWEET_TO_MSG) != 0;
- int poll_rate = db_get_dw(0, m_szModuleName, TWITTER_KEY_POLLRATE, 80);
+ int poll_rate = getDword(TWITTER_KEY_POLLRATE, 80);
for (unsigned int i = 0;; i++) {
@@ -358,7 +358,7 @@ void TwitterProto::MessageLoop(void*)
if (new_account) // Not anymore!
{
new_account = false;
- db_set_b(0, m_szModuleName, TWITTER_KEY_NEW, 0);
+ setByte(TWITTER_KEY_NEW, 0);
}
if (m_iStatus != ID_STATUS_ONLINE)
@@ -396,7 +396,7 @@ void TwitterProto::UpdateAvatarWorker(void *p)
// db_get_s returns 0 when it suceeds, so if this suceeds it will return 0, or false.
// therefore if it returns 1, or true, we want to return as there is no such user.
// as a side effect, dbv now has the username in it i think
- if (db_get_ts(data->hContact, m_szModuleName, TWITTER_KEY_UN, &dbv))
+ if (getTString(data->hContact, TWITTER_KEY_UN, &dbv))
return;
std::string ext = data->url.substr(data->url.rfind('.')); // finds the filetype of the avatar
@@ -424,10 +424,10 @@ void TwitterProto::UpdateAvatarWorker(void *p)
}
if (save_url(hAvatarNetlib_, data->url, filename)) {
- db_set_s(data->hContact, m_szModuleName, TWITTER_KEY_AV_URL, data->url.c_str());
- ProtoBroadcastAck(data->hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, &ai, 0);
+ setString(data->hContact, TWITTER_KEY_AV_URL, data->url.c_str());
+ ProtoBroadcastAck(data->hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, &ai);
}
- else ProtoBroadcastAck(data->hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, &ai, 0);
+ else ProtoBroadcastAck(data->hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, &ai);
debugLogA("***** Done avatar: %s", data->url.c_str());
}
@@ -436,7 +436,7 @@ void TwitterProto::UpdateAvatar(MCONTACT hContact, const std::string &url, bool
{
DBVARIANT dbv = { 0 };
- if (!force && (!db_get_s(hContact, m_szModuleName, TWITTER_KEY_AV_URL, &dbv) && url == dbv.pszVal)) {
+ if (!force && (!getString(hContact, TWITTER_KEY_AV_URL, &dbv) && url == dbv.pszVal)) {
debugLogA("***** Avatar already up-to-date: %s", url.c_str());
}
else {
@@ -445,7 +445,7 @@ void TwitterProto::UpdateAvatar(MCONTACT hContact, const std::string &url, bool
PROTO_AVATAR_INFORMATION ai = { 0 };
ai.hContact = hContact;
- db_set_s(hContact, m_szModuleName, TWITTER_KEY_AV_URL, url.c_str());
+ setString(hContact, TWITTER_KEY_AV_URL, url.c_str());
ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, &ai, 0);
}
else {
@@ -519,23 +519,23 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
void TwitterProto::ShowContactPopup(MCONTACT hContact, const std::string &text, const std::string *url)
{
- if (!ServiceExists(MS_POPUP_ADDPOPUPT) || db_get_b(0, m_szModuleName, TWITTER_KEY_POPUP_SHOW, 0) == 0) {
+ if (!ServiceExists(MS_POPUP_ADDPOPUPT) || getByte(TWITTER_KEY_POPUP_SHOW) == 0) {
return;
}
POPUPDATAT popup = {};
popup.lchContact = hContact;
- popup.iSeconds = db_get_dw(0, m_szModuleName, TWITTER_KEY_POPUP_TIMEOUT, 0);
+ popup.iSeconds = getDword(TWITTER_KEY_POPUP_TIMEOUT);
- popup.colorBack = db_get_dw(0, m_szModuleName, TWITTER_KEY_POPUP_COLBACK, 0);
+ popup.colorBack = getDword(TWITTER_KEY_POPUP_COLBACK);
if (popup.colorBack == 0xFFFFFFFF)
popup.colorBack = GetSysColor(COLOR_WINDOW);
- popup.colorText = db_get_dw(0, m_szModuleName, TWITTER_KEY_POPUP_COLTEXT, 0);
+ popup.colorText = getDword(TWITTER_KEY_POPUP_COLTEXT);
if (popup.colorBack == 0xFFFFFFFF)
popup.colorBack = GetSysColor(COLOR_WINDOWTEXT);
DBVARIANT dbv;
- if (!db_get_ts(hContact, "CList", "MyHandle", &dbv) || !db_get_ts(hContact, m_szModuleName, TWITTER_KEY_UN, &dbv)) {
+ if (!db_get_ts(hContact, "CList", "MyHandle", &dbv) || !getTString(hContact, TWITTER_KEY_UN, &dbv)) {
_tcsncpy(popup.lptzContactName, dbv.ptszVal, MAX_CONTACTNAME);
db_free(&dbv);
}
@@ -655,9 +655,9 @@ void TwitterProto::UpdateMessages(bool pre_read)
void TwitterProto::resetOAuthKeys()
{
- db_unset(0, m_szModuleName, TWITTER_KEY_OAUTH_ACCESS_TOK);
- db_unset(0, m_szModuleName, TWITTER_KEY_OAUTH_ACCESS_TOK_SECRET);
- db_unset(0, m_szModuleName, TWITTER_KEY_OAUTH_TOK);
- db_unset(0, m_szModuleName, TWITTER_KEY_OAUTH_TOK_SECRET);
- db_unset(0, m_szModuleName, TWITTER_KEY_OAUTH_PIN);
+ delSetting(TWITTER_KEY_OAUTH_ACCESS_TOK);
+ delSetting(TWITTER_KEY_OAUTH_ACCESS_TOK_SECRET);
+ delSetting(TWITTER_KEY_OAUTH_TOK);
+ delSetting(TWITTER_KEY_OAUTH_TOK_SECRET);
+ delSetting(TWITTER_KEY_OAUTH_PIN);
}
diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp
index ccae792f37..e9424a040f 100644
--- a/protocols/Twitter/src/contacts.cpp
+++ b/protocols/Twitter/src/contacts.cpp
@@ -55,11 +55,12 @@ MCONTACT TwitterProto::AddToList(int, PROTOSEARCHRESULT *psr)
// *************************
-void TwitterProto::UpdateInfoWorker(void *hContact)
+void TwitterProto::UpdateInfoWorker(void *arg)
{
+ MCONTACT hContact = (MCONTACT) arg;
twitter_user user;
- ptrA username(db_get_sa((MCONTACT)hContact, m_szModuleName, TWITTER_KEY_UN));
+ ptrA username(getStringA(hContact, TWITTER_KEY_UN));
if (username == NULL)
return;
@@ -67,8 +68,8 @@ void TwitterProto::UpdateInfoWorker(void *hContact)
twit_.get_info(std::string(username), &user);
}
- UpdateAvatar((MCONTACT)hContact, user.profile_image_url, true);
- ProtoBroadcastAck((MCONTACT)hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, 0, 0);
+ UpdateAvatar(hContact, user.profile_image_url, true);
+ ProtoBroadcastAck(hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, 0);
}
int TwitterProto::GetInfo(MCONTACT hContact, int info_type)
@@ -152,17 +153,18 @@ HANDLE TwitterProto::SearchByEmail(const TCHAR *email)
// *************************
-void TwitterProto::GetAwayMsgWorker(void *hContact)
+void TwitterProto::GetAwayMsgWorker(void *arg)
{
+ MCONTACT hContact = (MCONTACT) arg;
if (hContact == 0)
return;
DBVARIANT dbv;
- if (!db_get_ts((MCONTACT)hContact, "CList", "StatusMsg", &dbv)) {
- ProtoBroadcastAck((MCONTACT)hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv.ptszVal);
+ if (!db_get_ts(hContact, "CList", "StatusMsg", &dbv)) {
+ ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv.ptszVal);
db_free(&dbv);
}
- else ProtoBroadcastAck((MCONTACT)hContact, ACKTYPE_AWAYMSG, ACKRESULT_FAILED, (HANDLE)1, 0);
+ else ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_FAILED, (HANDLE)1, 0);
}
HANDLE TwitterProto::GetAwayMsg(MCONTACT hContact)
@@ -171,8 +173,9 @@ HANDLE TwitterProto::GetAwayMsg(MCONTACT hContact)
return (HANDLE)1;
}
-int TwitterProto::OnContactDeleted(WPARAM hContact, LPARAM)
+int TwitterProto::OnContactDeleted(WPARAM wParam, LPARAM)
{
+ MCONTACT hContact = (MCONTACT) wParam;
if (m_iStatus != ID_STATUS_ONLINE)
return 0;
@@ -180,7 +183,7 @@ int TwitterProto::OnContactDeleted(WPARAM hContact, LPARAM)
return 0;
DBVARIANT dbv;
- if (!db_get_s(hContact, m_szModuleName, TWITTER_KEY_UN, &dbv)) {
+ if (!getString(hContact, TWITTER_KEY_UN, &dbv)) {
if (in_chat_)
DeleteChatContact(dbv.pszVal);
@@ -207,11 +210,11 @@ bool TwitterProto::IsMyContact(MCONTACT hContact, bool include_chat)
MCONTACT TwitterProto::UsernameToHContact(const char *name)
{
for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
- if (db_get_b(hContact, m_szModuleName, "ChatRoom", 0))
+ if (getByte(hContact, "ChatRoom"))
continue;
DBVARIANT dbv;
- if (!db_get_s(hContact, m_szModuleName, TWITTER_KEY_UN, &dbv)) {
+ if (!getString(hContact, TWITTER_KEY_UN, &dbv)) {
if (mir_strcmp(name, dbv.pszVal) == 0) {
db_free(&dbv);
return hContact;
@@ -238,15 +241,15 @@ MCONTACT TwitterProto::AddToClientList(const char *name, const char *status)
hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
if (hContact) {
if (Proto_AddToContact(hContact, m_szModuleName) == 0) {
- db_set_s(hContact, m_szModuleName, TWITTER_KEY_UN, name);
- db_set_w(hContact, m_szModuleName, "Status", ID_STATUS_ONLINE);
+ setString(hContact, TWITTER_KEY_UN, name);
+ setWord(hContact, "Status", ID_STATUS_ONLINE);
db_set_utf(hContact, "CList", "StatusMsg", status);
std::string url = profile_base_url(twit_.get_base_url()) + http::url_encode(name);
- db_set_s(hContact, m_szModuleName, "Homepage", url.c_str());
+ setString(hContact, "Homepage", url.c_str());
DBVARIANT dbv;
- if (!db_get_ts(NULL, m_szModuleName, TWITTER_KEY_GROUP, &dbv)) {
+ if (!getTString(TWITTER_KEY_GROUP, &dbv)) {
db_set_ts(hContact, "CList", "Group", dbv.ptszVal);
db_free(&dbv);
}
@@ -262,8 +265,8 @@ MCONTACT TwitterProto::AddToClientList(const char *name, const char *status)
void TwitterProto::SetAllContactStatuses(int status)
{
for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
- if (!db_get_b(hContact, m_szModuleName, "ChatRoom", 0))
- db_set_w(hContact, m_szModuleName, "Status", (WORD)status);
+ if (!getByte(hContact, "ChatRoom"))
+ setWord(hContact, "Status", (WORD)status);
SetChatStatus(status);
}
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp
index fa1daf0957..3891325d47 100644
--- a/protocols/Twitter/src/proto.cpp
+++ b/protocols/Twitter/src/proto.cpp
@@ -217,13 +217,14 @@ INT_PTR TwitterProto::GetStatus(WPARAM, LPARAM)
return m_iStatus;
}
-INT_PTR TwitterProto::ReplyToTweet(WPARAM hContact, LPARAM)
+INT_PTR TwitterProto::ReplyToTweet(WPARAM wParam, LPARAM)
{
+ MCONTACT hContact = (MCONTACT) wParam;
// TODO: support replying to tweets instead of just users
HWND hDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_TWEET), 0, tweet_proc, reinterpret_cast<LPARAM>(this));
DBVARIANT dbv;
- if (!db_get_s(hContact, m_szModuleName, TWITTER_KEY_UN, &dbv)) {
+ if (!getString(hContact, TWITTER_KEY_UN, &dbv)) {
SendMessage(hDlg, WM_SETREPLY, reinterpret_cast<WPARAM>(dbv.pszVal), 0);
db_free(&dbv);
}
@@ -233,13 +234,14 @@ INT_PTR TwitterProto::ReplyToTweet(WPARAM hContact, LPARAM)
return 0;
}
-INT_PTR TwitterProto::VisitHomepage(WPARAM hContact, LPARAM)
+INT_PTR TwitterProto::VisitHomepage(WPARAM wParam, LPARAM)
{
+ MCONTACT hContact = (MCONTACT) wParam;
DBVARIANT dbv;
// TODO: remove this
- if (!db_get_s(hContact, m_szModuleName, TWITTER_KEY_UN, &dbv)) {
+ if (!getString(hContact, TWITTER_KEY_UN, &dbv)) {
std::string url = profile_base_url("https://twitter.com/") + http::url_encode(dbv.pszVal);
- db_set_s(hContact, m_szModuleName, "Homepage", url.c_str());
+ setString(hContact, "Homepage", url.c_str());
Utils_OpenUrl(url.c_str());
db_free(&dbv);
@@ -359,8 +361,9 @@ int TwitterProto::OnPreShutdown(WPARAM, LPARAM)
return 0;
}
-int TwitterProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM)
+int TwitterProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM)
{
+ MCONTACT hContact = (MCONTACT) wParam;
if (IsMyContact(hContact))
ShowContactMenus(true);
@@ -432,7 +435,7 @@ void TwitterProto::SendTweetWorker(void *p)
void TwitterProto::UpdateSettings()
{
- if (db_get_b(0, m_szModuleName, TWITTER_KEY_CHATFEED, 0)) {
+ if (getByte(TWITTER_KEY_CHATFEED)) {
if (!in_chat_)
OnJoinChat(0, 0);
}
diff --git a/protocols/Twitter/src/proto.h b/protocols/Twitter/src/proto.h
index fc78347aa9..ac1ae17b7b 100644
--- a/protocols/Twitter/src/proto.h
+++ b/protocols/Twitter/src/proto.h
@@ -26,11 +26,6 @@ public:
TwitterProto(const char*,const TCHAR*);
~TwitterProto();
- inline const char * ModuleName() const
- {
- return m_szModuleName;
- }
-
//PROTO_INTERFACE
virtual MCONTACT __cdecl AddToList(int,PROTOSEARCHRESULT *);
diff --git a/protocols/Twitter/src/twitter.cpp b/protocols/Twitter/src/twitter.cpp
index 5f86e5c64b..ac1cdadbc3 100644
--- a/protocols/Twitter/src/twitter.cpp
+++ b/protocols/Twitter/src/twitter.cpp
@@ -232,9 +232,11 @@ std::vector<twitter_user> twitter::get_statuses(int count, twitter_id id)
// at this point the user will get no tweets and an error popup if the tweet happens to be exactly 140 chars, start with
// "RT @", end in " ...", and notactually be a real retweet. it's possible but unlikely, wish i knew how to get
// the retweet_count variable to work :(
- const JSONNode &pUser2 = pStatus["user"];
+ const JSONNode &pRetweet = pStatus["retweeted_status"];
+ const JSONNode &pUser2 = pRetweet["user"];
+
std::string retweeteesName = pUser2["screen_name"].as_string(); // the user that is being retweeted
- std::string retweetText = pUser2["text"].as_string(); // their tweet in all it's untruncated glory
+ std::string retweetText = pRetweet["text"].as_string(); // their tweet in all it's untruncated glory
// fix "&amp;" in the tweets :(
for (size_t pos = 0; (pos = retweetText.find("&amp;", pos)) != std::string::npos; pos++)
diff --git a/protocols/Twitter/src/ui.cpp b/protocols/Twitter/src/ui.cpp
index dd6cb1a567..d69cfbe44f 100644
--- a/protocols/Twitter/src/ui.cpp
+++ b/protocols/Twitter/src/ui.cpp
@@ -39,13 +39,13 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
DBVARIANT dbv;
- if (!db_get_ts(0, proto->ModuleName(), TWITTER_KEY_GROUP, &dbv)) {
+ if (!proto->getTString(TWITTER_KEY_GROUP, &dbv)) {
SetDlgItemText(hwndDlg, IDC_GROUP, dbv.ptszVal);
db_free(&dbv);
}
else SetDlgItemText(hwndDlg, IDC_GROUP, L"Twitter");
- if (!db_get_s(0, proto->ModuleName(), TWITTER_KEY_UN, &dbv)) {
+ if (!proto->getString(TWITTER_KEY_UN, &dbv)) {
SetDlgItemTextA(hwndDlg, IDC_USERNAME, dbv.pszVal);
db_free(&dbv);
}
@@ -53,7 +53,7 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
for (size_t i = 0; i < _countof(sites); i++)
SendDlgItemMessage(hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(sites[i]));
- if (!db_get_s(0, proto->ModuleName(), TWITTER_KEY_BASEURL, &dbv)) {
+ if (!proto->getString(TWITTER_KEY_BASEURL, &dbv)) {
SetDlgItemTextA(hwndDlg, IDC_SERVER, dbv.pszVal);
db_free(&dbv);
}
@@ -85,10 +85,10 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
GetDlgItemTextA(hwndDlg, IDC_SERVER, str, _countof(str) - 1);
if (str[mir_strlen(str) - 1] != '/')
mir_strncat(str, "/", _countof(str) - mir_strlen(str));
- db_set_s(0, proto->ModuleName(), TWITTER_KEY_BASEURL, str);
+ proto->setString(TWITTER_KEY_BASEURL, str);
GetDlgItemText(hwndDlg, IDC_GROUP, tstr, _countof(tstr));
- db_set_ts(0, proto->ModuleName(), TWITTER_KEY_GROUP, tstr);
+ proto->setTString(TWITTER_KEY_GROUP, tstr);
return true;
}
@@ -174,27 +174,27 @@ INT_PTR CALLBACK options_proc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
proto = reinterpret_cast<TwitterProto*>(lParam);
DBVARIANT dbv;
- if (!db_get_s(0, proto->ModuleName(), TWITTER_KEY_UN, &dbv)) {
+ if (!proto->getString(TWITTER_KEY_UN, &dbv)) {
SetDlgItemTextA(hwndDlg, IDC_UN, dbv.pszVal);
db_free(&dbv);
}
- CheckDlgButton(hwndDlg, IDC_CHATFEED, db_get_b(0, proto->ModuleName(), TWITTER_KEY_CHATFEED, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHATFEED, proto->getByte(TWITTER_KEY_CHATFEED) ? BST_CHECKED : BST_UNCHECKED);
for (size_t i = 0; i < _countof(sites); i++)
SendDlgItemMessage(hwndDlg, IDC_BASEURL, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(sites[i]));
- if (!db_get_s(0, proto->ModuleName(), TWITTER_KEY_BASEURL, &dbv)) {
+ if (!proto->getString(TWITTER_KEY_BASEURL, &dbv)) {
SetDlgItemTextA(hwndDlg, IDC_BASEURL, dbv.pszVal);
db_free(&dbv);
}
else SendDlgItemMessage(hwndDlg, IDC_BASEURL, CB_SETCURSEL, 0, 0);
char pollrate_str[32];
- mir_snprintf(pollrate_str, _countof(pollrate_str), "%d", db_get_dw(0, proto->ModuleName(), TWITTER_KEY_POLLRATE, 80));
+ mir_snprintf(pollrate_str, _countof(pollrate_str), "%d", proto->getDword(TWITTER_KEY_POLLRATE, 80));
SetDlgItemTextA(hwndDlg, IDC_POLLRATE, pollrate_str);
- CheckDlgButton(hwndDlg, IDC_TWEET_MSG, db_get_b(0, proto->ModuleName(), TWITTER_KEY_TWEET_TO_MSG, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_TWEET_MSG, proto->getByte(TWITTER_KEY_TWEET_TO_MSG, 0) ? BST_CHECKED : BST_UNCHECKED);
// Do this last so that any events propagated by pre-filling the form don't
@@ -227,22 +227,22 @@ INT_PTR CALLBACK options_proc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
char str[128];
GetDlgItemTextA(hwndDlg, IDC_UN, str, _countof(str));
- db_set_s(0, proto->ModuleName(), TWITTER_KEY_UN, str);
+ proto->setString(TWITTER_KEY_UN, str);
GetDlgItemTextA(hwndDlg, IDC_BASEURL, str, _countof(str) - 1);
if (str[mir_strlen(str) - 1] != '/')
mir_strncat(str, "/", _countof(str) - mir_strlen(str));
- db_set_s(0, proto->ModuleName(), TWITTER_KEY_BASEURL, str);
+ proto->setString(TWITTER_KEY_BASEURL, str);
- db_set_b(0, proto->ModuleName(), TWITTER_KEY_CHATFEED, IsDlgButtonChecked(hwndDlg, IDC_CHATFEED) != 0);
+ proto->setByte(TWITTER_KEY_CHATFEED, IsDlgButtonChecked(hwndDlg, IDC_CHATFEED) != 0);
GetDlgItemTextA(hwndDlg, IDC_POLLRATE, str, _countof(str));
int rate = atoi(str);
if (rate == 0)
rate = 80;
- db_set_dw(0, proto->ModuleName(), TWITTER_KEY_POLLRATE, rate);
+ proto->setDword(TWITTER_KEY_POLLRATE, rate);
- db_set_b(0, proto->ModuleName(), TWITTER_KEY_TWEET_TO_MSG, IsDlgButtonChecked(hwndDlg, IDC_TWEET_MSG) != 0);
+ proto->setByte(TWITTER_KEY_TWEET_TO_MSG, IsDlgButtonChecked(hwndDlg, IDC_TWEET_MSG) != 0);
proto->UpdateSettings();
return true;
@@ -363,12 +363,12 @@ INT_PTR CALLBACK popup_options_proc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
proto = reinterpret_cast<TwitterProto*>(lParam);
- CheckAndUpdateDlgButton(hwndDlg, IDC_SHOWPOPUPS, db_get_b(0, proto->ModuleName(), TWITTER_KEY_POPUP_SHOW, 0));
- CheckDlgButton(hwndDlg, IDC_NOSIGNONPOPUPS, !db_get_b(0, proto->ModuleName(), TWITTER_KEY_POPUP_SIGNON, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckAndUpdateDlgButton(hwndDlg, IDC_SHOWPOPUPS, proto->getByte(TWITTER_KEY_POPUP_SHOW, 0));
+ CheckDlgButton(hwndDlg, IDC_NOSIGNONPOPUPS, !proto->getByte(TWITTER_KEY_POPUP_SIGNON, 0) ? BST_CHECKED : BST_UNCHECKED);
// ***** Get color information
- back_color = db_get_dw(0, proto->ModuleName(), TWITTER_KEY_POPUP_COLBACK, 0);
- text_color = db_get_dw(0, proto->ModuleName(), TWITTER_KEY_POPUP_COLTEXT, 0);
+ back_color = proto->getDword(TWITTER_KEY_POPUP_COLBACK);
+ text_color = proto->getDword(TWITTER_KEY_POPUP_COLTEXT);
SendDlgItemMessage(hwndDlg, IDC_COLBACK, CPM_SETCOLOUR, 0, RGB(255, 255, 255));
SendDlgItemMessage(hwndDlg, IDC_COLTEXT, CPM_SETCOLOUR, 0, RGB(0, 0, 0));
@@ -384,7 +384,7 @@ INT_PTR CALLBACK popup_options_proc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
}
// ***** Get timeout information
- timeout = db_get_dw(0, proto->ModuleName(), TWITTER_KEY_POPUP_TIMEOUT, 0);
+ timeout = proto->getDword(TWITTER_KEY_POPUP_TIMEOUT);
SetDlgItemTextA(hwndDlg, IDC_TIMEOUT, "5");
if (timeout == 0)
@@ -445,15 +445,15 @@ INT_PTR CALLBACK popup_options_proc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
if (reinterpret_cast<NMHDR*>(lParam)->code == PSN_APPLY) {
proto = reinterpret_cast<TwitterProto*>(GetWindowLongPtr(hwndDlg, GWLP_USERDATA));
- db_set_b(0, proto->ModuleName(), TWITTER_KEY_POPUP_SHOW, IsDlgButtonChecked(hwndDlg, IDC_SHOWPOPUPS) != 0);
- db_set_b(0, proto->ModuleName(), TWITTER_KEY_POPUP_SIGNON, BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_NOSIGNONPOPUPS));
+ proto->setByte(TWITTER_KEY_POPUP_SHOW, IsDlgButtonChecked(hwndDlg, IDC_SHOWPOPUPS) != 0);
+ proto->setByte(TWITTER_KEY_POPUP_SIGNON, BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_NOSIGNONPOPUPS));
// ***** Write color settings
- db_set_dw(0, proto->ModuleName(), TWITTER_KEY_POPUP_COLBACK, get_back_color(hwndDlg, true));
- db_set_dw(0, proto->ModuleName(), TWITTER_KEY_POPUP_COLTEXT, get_text_color(hwndDlg, true));
+ proto->setDword(TWITTER_KEY_POPUP_COLBACK, get_back_color(hwndDlg, true));
+ proto->setDword(TWITTER_KEY_POPUP_COLTEXT, get_text_color(hwndDlg, true));
// ***** Write timeout setting
- db_set_dw(0, proto->ModuleName(), TWITTER_KEY_POPUP_TIMEOUT, get_timeout(hwndDlg));
+ proto->setDword(TWITTER_KEY_POPUP_TIMEOUT, get_timeout(hwndDlg));
return true;
}
@@ -480,7 +480,7 @@ INT_PTR CALLBACK pin_proc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
GetDlgItemTextA(hwndDlg, IDC_PIN, str, _countof(str));
- db_set_s(0, proto->ModuleName(), TWITTER_KEY_OAUTH_PIN, str);
+ proto->setString(TWITTER_KEY_OAUTH_PIN, str);
EndDialog(hwndDlg, wParam);
return true;
}