summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2013-03-18 21:13:09 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2013-03-18 21:13:09 +0000
commit4fb9db65bedad4f25923fb2c0bf25dbabc5227bb (patch)
treee2be66bd62804b8038470a1ff4d6f731b5b735f0
parent840ad3803f3e0a4e51204983c1fad5ff5d6aef8b (diff)
quick fix for the twitter profile URLs
git-svn-id: http://svn.miranda-ng.org/main/trunk@4099 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/Twitter/src/chat.cpp18
-rw-r--r--protocols/Twitter/src/connection.cpp145
-rw-r--r--protocols/Twitter/src/contacts.cpp56
-rw-r--r--protocols/Twitter/src/http.cpp3
-rw-r--r--protocols/Twitter/src/main.cpp3
-rw-r--r--protocols/Twitter/src/proto.cpp87
-rw-r--r--protocols/Twitter/src/theme.cpp9
-rw-r--r--protocols/Twitter/src/ui.cpp102
8 files changed, 178 insertions, 245 deletions
diff --git a/protocols/Twitter/src/chat.cpp b/protocols/Twitter/src/chat.cpp
index cafb46025c..577dfd3be6 100644
--- a/protocols/Twitter/src/chat.cpp
+++ b/protocols/Twitter/src/chat.cpp
@@ -44,10 +44,10 @@ void TwitterProto::UpdateChat(const twitter_user &update)
DBVARIANT nick;
HANDLE hContact = UsernameToHContact(update.username.c_str());
- if(hContact && !DBGetContactSettingString(hContact,"CList","MyHandle",&nick))
+ if(hContact && !db_get_s(hContact,"CList","MyHandle",&nick))
{
gce.ptszNick = mir_a2t(nick.pszVal);
- DBFreeVariant(&nick);
+ db_free(&nick);
}
else
gce.ptszNick = mir_a2t(update.username.c_str());
@@ -197,24 +197,24 @@ void TwitterProto::SetChatStatus(int status)
if(status == ID_STATUS_ONLINE)
{
// Add all friends to contact list
- for(HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
+ for(HANDLE hContact = db_find_first();hContact;hContact = db_find_next(hContact))
{
if(!IsMyContact(hContact))
continue;
DBVARIANT uid,nick;
- if( DBGetContactSettingString(hContact,m_szModuleName,TWITTER_KEY_UN,&uid))
+ if(db_get_s(hContact,m_szModuleName,TWITTER_KEY_UN,&uid))
continue;
- if( !DBGetContactSettingString(hContact,"CList","MyHandle",&nick))
+ if(!db_get_s(hContact,"CList","MyHandle",&nick))
+ {
AddChatContact(uid.pszVal,nick.pszVal);
+ db_free(&nick);
+ }
else
AddChatContact(uid.pszVal);
- DBFreeVariant(&nick);
- DBFreeVariant(&uid);
+ db_free(&uid);
}
// For some reason, I have to send an INITDONE message, even if I'm not actually
diff --git a/protocols/Twitter/src/connection.cpp b/protocols/Twitter/src/connection.cpp
index fe18ae5c76..178357c36b 100644
--- a/protocols/Twitter/src/connection.cpp
+++ b/protocols/Twitter/src/connection.cpp
@@ -25,8 +25,7 @@ void CALLBACK TwitterProto::APC_callback(ULONG_PTR p)
}
template<typename T>
-inline static T db_pod_get(HANDLE hContact,const char *module,const char *setting,
- T errorValue)
+inline static T db_pod_get(HANDLE hContact,const char *module,const char *setting,T errorValue)
{
DBVARIANT dbv;
DBCONTACTGETSETTING cgs;
@@ -47,8 +46,7 @@ inline static T db_pod_get(HANDLE hContact,const char *module,const char *settin
}
template<typename T>
-inline static INT_PTR db_pod_set(HANDLE hContact,const char *module,const char *setting,
- T val)
+inline static INT_PTR db_pod_set(HANDLE hContact,const char *module,const char *setting,T val)
{
DBCONTACTWRITESETTING cws;
@@ -104,42 +102,42 @@ bool TwitterProto::NegotiateConnection()
wstring oauthAccessTokenSecret;
string screenName;
- INT_PTR dbTOK = DBGetContactSettingWString(0,m_szModuleName,TWITTER_KEY_OAUTH_TOK,&dbv);
+ INT_PTR dbTOK = db_get_ws(0,m_szModuleName,TWITTER_KEY_OAUTH_TOK,&dbv);
if (!dbTOK) {
oauthToken = dbv.pwszVal;
- DBFreeVariant(&dbv);
+ db_free(&dbv);
//WLOG("**NegotiateConnection - we have an oauthToken already in the db - %s", oauthToken);
}
- INT_PTR dbTOKSec = DBGetContactSettingWString(0,m_szModuleName,TWITTER_KEY_OAUTH_TOK_SECRET,&dbv);
+ INT_PTR dbTOKSec = db_get_ws(0,m_szModuleName,TWITTER_KEY_OAUTH_TOK_SECRET,&dbv);
if (!dbTOKSec) {
oauthTokenSecret = dbv.pwszVal;
- DBFreeVariant(&dbv);
+ db_free(&dbv);
//WLOG("**NegotiateConnection - we have an oauthTokenSecret already in the db - %s", oauthTokenSecret);
}
- INT_PTR dbName = DBGetContactSettingString(0,m_szModuleName,TWITTER_KEY_NICK,&dbv);
+ INT_PTR dbName = db_get_s(0,m_szModuleName,TWITTER_KEY_NICK,&dbv);
if (!dbName) {
screenName = dbv.pszVal;
- DBFreeVariant(&dbv);
+ db_free(&dbv);
//WLOG("**NegotiateConnection - we have a username already in the db - %s", screenName);
}
else {
- dbName = DBGetContactSettingString(0,m_szModuleName,TWITTER_KEY_UN,&dbv);
+ dbName = db_get_s(0,m_szModuleName,TWITTER_KEY_UN,&dbv);
if (!dbName) {
screenName = dbv.pszVal;
- DBWriteContactSettingString(0,m_szModuleName,TWITTER_KEY_NICK,dbv.pszVal);
+ db_set_s(0,m_szModuleName,TWITTER_KEY_NICK,dbv.pszVal);
//WLOG("**NegotiateConnection - we have a username already in the db - %s", screenName);
}
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
// 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(DBGetContactSettingByte(0,m_szModuleName,"UpgradeBaseURL",1)) {
- DBWriteContactSettingString(0,m_szModuleName,TWITTER_KEY_BASEURL,"https://api.twitter.com/");
- DBWriteContactSettingByte(0,m_szModuleName,"UpgradeBaseURL",0);
+ 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((oauthToken.size() <= 1) || (oauthTokenSecret.size() <= 1)) {
@@ -178,8 +176,8 @@ bool TwitterProto::NegotiateConnection()
}
//write those bitches to the db foe latta
- DBWriteContactSettingWString(0,m_szModuleName,TWITTER_KEY_OAUTH_TOK,oauthToken.c_str());
- DBWriteContactSettingWString(0,m_szModuleName,TWITTER_KEY_OAUTH_TOK_SECRET,oauthTokenSecret.c_str());
+ 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());
// this looks like bad code.. can someone clean this up please? or confirm that it's ok
wchar_t buf[1024] = {};
@@ -191,19 +189,19 @@ bool TwitterProto::NegotiateConnection()
ShowPinDialog();
}
- if (!DBGetContactSettingTString(NULL,m_szModuleName,TWITTER_KEY_GROUP,&dbv)) {
+ if (!db_get_ts(NULL,m_szModuleName,TWITTER_KEY_GROUP,&dbv)) {
CallService( MS_CLIST_GROUPCREATE, 0, (LPARAM)dbv.ptszVal );
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
bool realAccessTok = false;
bool realAccessTokSecret = false;
// remember, dbTOK is 0 (false) if the db setting has returned something
- dbTOK = DBGetContactSettingWString(0,m_szModuleName,TWITTER_KEY_OAUTH_ACCESS_TOK,&dbv);
+ dbTOK = db_get_ws(0,m_szModuleName,TWITTER_KEY_OAUTH_ACCESS_TOK,&dbv);
if (!dbTOK) {
oauthAccessToken = dbv.pwszVal;
- DBFreeVariant(&dbv);
+ db_free(&dbv);
// this bit is saying "if we have found the db key, but it contains no data, then set dbTOK to 1"
if (oauthAccessToken.size() > 1) {
realAccessTok = true;
@@ -212,10 +210,10 @@ bool TwitterProto::NegotiateConnection()
else { LOG( _T("**NegotiateConnection - oauthAccesToken too small? this is.. weird.")); }
}
- dbTOKSec = DBGetContactSettingWString(0,m_szModuleName,TWITTER_KEY_OAUTH_ACCESS_TOK_SECRET,&dbv);
+ dbTOKSec = db_get_ws(0,m_szModuleName,TWITTER_KEY_OAUTH_ACCESS_TOK_SECRET,&dbv);
if (!dbTOKSec) {
oauthAccessTokenSecret = dbv.pwszVal;
- DBFreeVariant(&dbv);
+ db_free(&dbv);
if (oauthAccessTokenSecret.size() > 1) {
realAccessTokSecret = true;
//WLOG("**NegotiateConnection - we have an oauthAccessTokenSecret already in the db - %s", oauthAccessTokenSecret);
@@ -226,24 +224,22 @@ bool TwitterProto::NegotiateConnection()
if (!realAccessTok || !realAccessTokSecret) { // if we don't have one of these beasties then lets go get 'em!
wstring pin;
LOG( _T("**NegotiateConnection - either the accessToken or accessTokenSecret was not there.."));
- if (!DBGetContactSettingWString(0,m_szModuleName,TWITTER_KEY_OAUTH_PIN,&dbv)) {
+ if (!db_get_ws(0,m_szModuleName,TWITTER_KEY_OAUTH_PIN,&dbv)) {
pin = dbv.pwszVal;
//WLOG("**NegotiateConnection - we have an pin already in the db - %s", pin);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
else {
ShowPopup(TranslateT("OAuth variables are out of sequence, they have been reset. Please reconnect and reauthorise Miranda to Twitter.com (do the PIN stuff again)"));
LOG( _T("**NegotiateConnection - We don't have a PIN? this doesn't make sense. Resetting OAuth keys and setting offline."));
resetOAuthKeys();
- ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_STATUS,ACKRESULT_FAILED,
- (HANDLE)old_status,m_iStatus);
+ ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_STATUS,ACKRESULT_FAILED,(HANDLE)old_status,m_iStatus);
// Set to offline
old_status = m_iStatus;
m_iDesiredStatus = m_iStatus = ID_STATUS_OFFLINE;
- ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_STATUS,ACKRESULT_SUCCESS,
- (HANDLE)old_status,m_iStatus);
+ ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)old_status,m_iStatus);
return false;
}
@@ -265,14 +261,12 @@ bool TwitterProto::NegotiateConnection()
resetOAuthKeys();
- ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_STATUS,ACKRESULT_FAILED,
- (HANDLE)old_status,m_iStatus);
+ ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_STATUS,ACKRESULT_FAILED,(HANDLE)old_status,m_iStatus);
// Set to offline
old_status = m_iStatus;
m_iDesiredStatus = m_iStatus = ID_STATUS_OFFLINE;
- ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_STATUS,ACKRESULT_SUCCESS,
- (HANDLE)old_status,m_iStatus);
+ ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)old_status,m_iStatus);
return false;
}
@@ -294,29 +288,29 @@ bool TwitterProto::NegotiateConnection()
LOG( _T("**NegotiateConnection - screen name is %s"), screenName.c_str());
//save em
- DBWriteContactSettingWString(0,m_szModuleName,TWITTER_KEY_OAUTH_ACCESS_TOK,oauthAccessToken.c_str());
- DBWriteContactSettingWString(0,m_szModuleName,TWITTER_KEY_OAUTH_ACCESS_TOK_SECRET,oauthAccessTokenSecret.c_str());
- DBWriteContactSettingString(0,m_szModuleName,TWITTER_KEY_NICK,screenName.c_str());
- DBWriteContactSettingString(0,m_szModuleName,TWITTER_KEY_UN,screenName.c_str());
+ 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());
}
}
-/* if( !DBGetContactSettingString(0,m_szModuleName,TWITTER_KEY_PASS,&dbv)) {
+/* if( !db_get_s(0,m_szModuleName,TWITTER_KEY_PASS,&dbv)) {
CallService(MS_DB_CRYPT_DECODESTRING,strlen(dbv.pszVal)+1,
reinterpret_cast<LPARAM>(dbv.pszVal));
pass = dbv.pszVal;
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
else {
ShowPopup(TranslateT("Please enter a password."));
return false;
}*/
- if( !DBGetContactSettingString(0,m_szModuleName,TWITTER_KEY_BASEURL,&dbv))
+ if( !db_get_s(0,m_szModuleName,TWITTER_KEY_BASEURL,&dbv))
{
ScopedLock s(twitter_lock_);
twit_.set_base_url(dbv.pszVal);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
LOG( _T("**NegotiateConnection - Setting Consumer Keys and verifying creds..."));
@@ -343,22 +337,19 @@ bool TwitterProto::NegotiateConnection()
LOG( _T("**NegotiateConnection - Verifying credentials failed! No internet maybe?"));
//resetOAuthKeys();
- ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_STATUS,ACKRESULT_FAILED,
- (HANDLE)old_status,m_iStatus);
+ ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_STATUS,ACKRESULT_FAILED,(HANDLE)old_status,m_iStatus);
// Set to offline
old_status = m_iStatus;
m_iDesiredStatus = m_iStatus = ID_STATUS_OFFLINE;
- ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_STATUS,ACKRESULT_SUCCESS,
- (HANDLE)old_status,m_iStatus);
+ ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)old_status,m_iStatus);
return false;
}
else {
m_iStatus = m_iDesiredStatus;
- ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_STATUS,ACKRESULT_SUCCESS,
- (HANDLE)old_status,m_iStatus);
+ ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)old_status,m_iStatus);
return true;
}
}
@@ -372,7 +363,7 @@ void TwitterProto::MessageLoop(void*)
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 popups = db_get_b(0,m_szModuleName,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;
@@ -400,7 +391,7 @@ void TwitterProto::MessageLoop(void*)
if(new_account) // Not anymore!
{
new_account = false;
- DBWriteContactSettingByte(0,m_szModuleName,TWITTER_KEY_NEW,0);
+ db_set_b(0,m_szModuleName,TWITTER_KEY_NEW,0);
}
if(m_iStatus != ID_STATUS_ONLINE)
@@ -435,15 +426,15 @@ void TwitterProto::UpdateAvatarWorker(void *p)
std::auto_ptr<update_avatar> data( static_cast<update_avatar*>(p));
DBVARIANT dbv = {0};
- // DBGetContactSettingString returns 0 when it suceeds, so if this suceeds it will return 0, or false.
+ // 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(DBGetContactSettingTString(data->hContact,m_szModuleName,TWITTER_KEY_UN,&dbv))
+ if(db_get_ts(data->hContact,m_szModuleName,TWITTER_KEY_UN,&dbv))
return;
std::string ext = data->url.substr(data->url.rfind('.')); // finds the filetype of the avatar
std::tstring filename = GetAvatarFolder() + _T('\\') + dbv.ptszVal + (TCHAR*)_A2T(ext.c_str()); // local filename and path
- DBFreeVariant(&dbv);
+ db_free(&dbv);
PROTO_AVATAR_INFORMATIONT ai = {sizeof(ai)};
ai.hContact = data->hContact;
@@ -466,14 +457,11 @@ void TwitterProto::UpdateAvatarWorker(void *p)
if(save_url(hAvatarNetlib_,data->url,filename))
{
- DBWriteContactSettingString(data->hContact,m_szModuleName,TWITTER_KEY_AV_URL,
- data->url.c_str());
- ProtoBroadcastAck(m_szModuleName,data->hContact,ACKTYPE_AVATAR,
- ACKRESULT_SUCCESS,&ai,0);
+ db_set_s(data->hContact,m_szModuleName,TWITTER_KEY_AV_URL,data->url.c_str());
+ ProtoBroadcastAck(m_szModuleName,data->hContact,ACKTYPE_AVATAR,ACKRESULT_SUCCESS,&ai,0);
}
else
- ProtoBroadcastAck(m_szModuleName,data->hContact,ACKTYPE_AVATAR,
- ACKRESULT_FAILED, &ai,0);
+ ProtoBroadcastAck(m_szModuleName,data->hContact,ACKTYPE_AVATAR,ACKRESULT_FAILED, &ai,0);
ReleaseMutex(avatar_lock_);
LOG( _T("***** Done avatar: %s"),data->url.c_str());
}
@@ -482,9 +470,7 @@ void TwitterProto::UpdateAvatar(HANDLE hContact,const std::string &url,bool forc
{
DBVARIANT dbv = {0};
- if( !force &&
- ( !DBGetContactSettingString(hContact,m_szModuleName,TWITTER_KEY_AV_URL,&dbv) &&
- url == dbv.pszVal))
+ if( !force && (!db_get_s(hContact,m_szModuleName,TWITTER_KEY_AV_URL,&dbv) && url == dbv.pszVal))
{
LOG( _T("***** Avatar already up-to-date: %s"), url.c_str());
}
@@ -496,17 +482,15 @@ void TwitterProto::UpdateAvatar(HANDLE hContact,const std::string &url,bool forc
PROTO_AVATAR_INFORMATIONT ai = {sizeof(ai),hContact};
db_set_s(hContact,m_szModuleName,TWITTER_KEY_AV_URL,url.c_str());
- ProtoBroadcastAck(m_szModuleName,hContact,ACKTYPE_AVATAR,
- ACKRESULT_SUCCESS,&ai,0);
+ ProtoBroadcastAck(m_szModuleName,hContact,ACKTYPE_AVATAR,ACKRESULT_SUCCESS,&ai,0);
}
else
{
- ForkThread(&TwitterProto::UpdateAvatarWorker, this,
- new update_avatar(hContact,url));
+ ForkThread(&TwitterProto::UpdateAvatarWorker, this,new update_avatar(hContact,url));
}
}
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
void TwitterProto::UpdateFriends()
@@ -538,8 +522,7 @@ void TwitterProto::UpdateFriends()
}
catch(const std::exception &e)
{
- ShowPopup( (std::string("While updating friends list, an error occurred: ")
- +e.what()).c_str());
+ ShowPopup( (std::string("While updating friends list, an error occurred: ")+e.what()).c_str());
LOG( _T("***** Error updating friends list: %s"), e.what());
}
@@ -547,8 +530,7 @@ void TwitterProto::UpdateFriends()
void TwitterProto::ShowContactPopup(HANDLE hContact,const std::string &text)
{
- if(!ServiceExists(MS_POPUP_ADDPOPUPT) || DBGetContactSettingByte(0,
- m_szModuleName,TWITTER_KEY_POPUP_SHOW,0) == 0)
+ if(!ServiceExists(MS_POPUP_ADDPOPUPT) || db_get_b(0,m_szModuleName,TWITTER_KEY_POPUP_SHOW,0) == 0)
{
return;
}
@@ -565,11 +547,10 @@ void TwitterProto::ShowContactPopup(HANDLE hContact,const std::string &text)
popup.colorBack = GetSysColor(COLOR_WINDOWTEXT);
DBVARIANT dbv;
- if( !DBGetContactSettingString(hContact,"CList","MyHandle",&dbv) ||
- !DBGetContactSettingString(hContact,m_szModuleName,TWITTER_KEY_UN,&dbv))
+ if( !db_get_s(hContact,"CList","MyHandle",&dbv) || !db_get_s(hContact,m_szModuleName,TWITTER_KEY_UN,&dbv))
{
mbcs_to_tcs(CP_UTF8,dbv.pszVal,popup.lptzContactName,MAX_CONTACTNAME);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
mbcs_to_tcs(CP_UTF8,text.c_str(),popup.lptzText,MAX_SECONDLINE);
@@ -613,8 +594,7 @@ void TwitterProto::UpdateStatuses(bool pre_read, bool popups, bool tweetToMsg)
CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
}
- DBWriteContactSettingUTF8String(hContact,"CList","StatusMsg",
- i->status.text.c_str());
+ db_set_utf(hContact,"CList","StatusMsg",i->status.text.c_str());
if(!pre_read && popups)
ShowContactPopup(hContact,i->status.text);
@@ -680,16 +660,15 @@ void TwitterProto::UpdateMessages(bool pre_read)
}
catch(const std::exception &e)
{
- ShowPopup( (std::string("While updating direct messages, an error occurred: ")
- +e.what()).c_str());
+ ShowPopup( (std::string("While updating direct messages, an error occurred: ")+e.what()).c_str());
LOG( _T("***** Error updating direct messages: %s"), e.what());
}
}
void TwitterProto::resetOAuthKeys() {
- DBDeleteContactSetting(0,m_szModuleName,TWITTER_KEY_OAUTH_ACCESS_TOK);
- DBDeleteContactSetting(0,m_szModuleName,TWITTER_KEY_OAUTH_ACCESS_TOK_SECRET);
- DBDeleteContactSetting(0,m_szModuleName,TWITTER_KEY_OAUTH_TOK);
- DBDeleteContactSetting(0,m_szModuleName,TWITTER_KEY_OAUTH_TOK_SECRET);
- DBDeleteContactSetting(0,m_szModuleName,TWITTER_KEY_OAUTH_PIN);
+ 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);
}
diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp
index dae818d52b..1eb1314086 100644
--- a/protocols/Twitter/src/contacts.cpp
+++ b/protocols/Twitter/src/contacts.cpp
@@ -37,8 +37,7 @@ void TwitterProto::AddToListWorker(void *p)
}
catch(const std::exception &e)
{
- ShowPopup((std::string("While adding a friend, an error occurred: ")
- +e.what()).c_str());
+ ShowPopup((std::string("While adding a friend, an error occurred: ") + e.what()).c_str());
LOG( _T("***** Error adding friend: %s"),e.what());
}
mir_free(name);
@@ -61,10 +60,10 @@ void TwitterProto::UpdateInfoWorker(void *hContact)
std::string username;
DBVARIANT dbv;
- if( !DBGetContactSettingString(hContact,m_szModuleName,TWITTER_KEY_UN,&dbv))
+ if(!db_get_s(hContact,m_szModuleName,TWITTER_KEY_UN,&dbv))
{
username = dbv.pszVal;
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
else
return;
@@ -112,7 +111,6 @@ void TwitterProto::DoSearch(void *p)
search_query *query = static_cast<search_query*>(p);
twitter_user info;
- PROTOSEARCHRESULT psr = {sizeof(psr)};
bool found = false;
try
@@ -128,15 +126,15 @@ void TwitterProto::DoSearch(void *p)
}
catch(const std::exception &e)
{
- ShowPopup( (std::string("While searching for contacts, an error occurred: ")
- +e.what()).c_str());
+ ShowPopup( (std::string("While searching for contacts, an error occurred: ") + e.what()).c_str());
LOG( _T("***** Error searching for contacts: %s"), e.what());
found = false;
}
if(found) {
- psr.nick = mir_a2t( info.username. c_str());
- psr.firstName = mir_a2t( info.real_name.c_str());
+ PROTOSEARCHRESULT psr = {sizeof(psr)};
+ psr.nick = mir_a2t(info.username. c_str());
+ psr.firstName = mir_a2t(info.real_name.c_str());
ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_SEARCH,ACKRESULT_DATA,(HANDLE)1, (LPARAM)&psr);
ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_SEARCH,ACKRESULT_SUCCESS,(HANDLE)1,0);
@@ -172,9 +170,9 @@ void TwitterProto::GetAwayMsgWorker(void *hContact)
return;
DBVARIANT dbv;
- if( !DBGetContactSettingTString(hContact,"CList","StatusMsg",&dbv)) {
+ if( !db_get_ts(hContact,"CList","StatusMsg",&dbv)) {
ProtoBroadcastAck(m_szModuleName,hContact,ACKTYPE_AWAYMSG,ACKRESULT_SUCCESS, (HANDLE)1,(LPARAM)dbv.ptszVal);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
else ProtoBroadcastAck(m_szModuleName,hContact,ACKTYPE_AWAYMSG,ACKRESULT_FAILED, (HANDLE)1,0);
}
@@ -196,14 +194,14 @@ int TwitterProto::OnContactDeleted(WPARAM wParam,LPARAM lParam)
return 0;
DBVARIANT dbv;
- if( !DBGetContactSettingString(hContact,m_szModuleName,TWITTER_KEY_UN,&dbv))
+ if( !db_get_s(hContact,m_szModuleName,TWITTER_KEY_UN,&dbv))
{
if(in_chat_)
DeleteChatContact(dbv.pszVal);
ScopedLock s(twitter_lock_);
twit_.remove_friend(dbv.pszVal); // Be careful about this until Miranda is fixed
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
return 0;
}
@@ -216,30 +214,28 @@ bool TwitterProto::IsMyContact(HANDLE hContact,bool include_chat)
if(proto && strcmp(m_szModuleName,proto) == 0) {
if(include_chat)
return true;
- return DBGetContactSettingByte(hContact,m_szModuleName,"ChatRoom",0) == 0;
+ return db_get_b(hContact,m_szModuleName,"ChatRoom",0) == 0;
}
else return false;
}
HANDLE TwitterProto::UsernameToHContact(const char *name)
{
- for(HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
+ for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
{
if(!IsMyContact(hContact))
continue;
DBVARIANT dbv;
- if( !DBGetContactSettingString(hContact,m_szModuleName,TWITTER_KEY_UN,&dbv))
+ if( !db_get_s(hContact,m_szModuleName,TWITTER_KEY_UN,&dbv))
{
if(strcmp(name,dbv.pszVal) == 0)
{
- DBFreeVariant(&dbv);
+ db_free(&dbv);
return hContact;
}
else
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
}
@@ -262,18 +258,18 @@ HANDLE TwitterProto::AddToClientList(const char *name,const char *status)
{
if(CallService(MS_PROTO_ADDTOCONTACT,(WPARAM)hContact,(LPARAM)m_szModuleName) == 0)
{
- DBWriteContactSettingString (hContact,m_szModuleName,TWITTER_KEY_UN,name);
- DBWriteContactSettingWord (hContact,m_szModuleName,"Status",ID_STATUS_ONLINE);
- DBWriteContactSettingUTF8String(hContact,"CList","StatusMsg",status);
+ db_set_s(hContact,m_szModuleName,TWITTER_KEY_UN,name);
+ db_set_w(hContact,m_szModuleName,"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);
- DBWriteContactSettingString (hContact,m_szModuleName,"Homepage",url.c_str());
+ db_set_s(hContact,m_szModuleName,"Homepage",url.c_str());
DBVARIANT dbv;
- if( !DBGetContactSettingTString(NULL,m_szModuleName,TWITTER_KEY_GROUP,&dbv))
+ if(!db_get_ts(NULL,m_szModuleName,TWITTER_KEY_GROUP,&dbv))
{
- DBWriteContactSettingTString(hContact,"CList","Group",dbv.ptszVal);
- DBFreeVariant(&dbv);
+ db_set_ts(hContact,"CList","Group",dbv.ptszVal);
+ db_free(&dbv);
}
@@ -288,14 +284,12 @@ HANDLE TwitterProto::AddToClientList(const char *name,const char *status)
void TwitterProto::SetAllContactStatuses(int status)
{
- for(HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
+ for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
{
if(!IsMyContact(hContact))
continue;
- DBWriteContactSettingWord(hContact,m_szModuleName,"Status",status);
+ db_set_w(hContact,m_szModuleName,"Status",status);
}
SetChatStatus(status);
diff --git a/protocols/Twitter/src/http.cpp b/protocols/Twitter/src/http.cpp
index 877399cc11..f953ec1973 100644
--- a/protocols/Twitter/src/http.cpp
+++ b/protocols/Twitter/src/http.cpp
@@ -23,8 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
std::string http::url_encode(const std::string &s)
{
- char *encoded = reinterpret_cast<char*>(CallService( MS_NETLIB_URLENCODE,
- 0,reinterpret_cast<LPARAM>(s.c_str())));
+ char *encoded = reinterpret_cast<char*>(CallService( MS_NETLIB_URLENCODE,0,reinterpret_cast<LPARAM>(s.c_str())));
std::string ret = encoded;
HeapFree(GetProcessHeap(),0,encoded);
diff --git a/protocols/Twitter/src/main.cpp b/protocols/Twitter/src/main.cpp
index 244f0d094b..5f84e69c7e 100644
--- a/protocols/Twitter/src/main.cpp
+++ b/protocols/Twitter/src/main.cpp
@@ -89,8 +89,7 @@ extern "C" int __declspec(dllexport) Load(void)
{
mir_getLP(&pluginInfo);
- pcli = reinterpret_cast<CLIST_INTERFACE*>( CallService(
- MS_CLIST_RETRIEVE_INTERFACE,0,reinterpret_cast<LPARAM>(g_hInstance)));
+ pcli = reinterpret_cast<CLIST_INTERFACE*>( CallService(MS_CLIST_RETRIEVE_INTERFACE,0,reinterpret_cast<LPARAM>(g_hInstance)));
PROTOCOLDESCRIPTOR pd = {sizeof(pd)};
pd.szName = "Twitter";
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp
index 4c9d0db3a9..eca9aea2ff 100644
--- a/protocols/Twitter/src/proto.cpp
+++ b/protocols/Twitter/src/proto.cpp
@@ -95,7 +95,7 @@ TwitterProto::~TwitterProto()
// *************************
-DWORD_PTR TwitterProto::GetCaps(int type,HANDLE hContact)
+DWORD_PTR TwitterProto::GetCaps(int type,HANDLE)
{
switch(type)
{
@@ -142,14 +142,13 @@ void TwitterProto::SendSuccess(void *p)
send_direct *data = static_cast<send_direct*>(p);
DBVARIANT dbv;
- if( !DBGetContactSettingString(data->hContact,m_szModuleName,TWITTER_KEY_UN,&dbv))
+ if( !db_get_s(data->hContact,m_szModuleName,TWITTER_KEY_UN,&dbv))
{
ScopedLock s(twitter_lock_);
twit_.send_direct(dbv.pszVal,data->msg);
- ProtoBroadcastAck(m_szModuleName,data->hContact,ACKTYPE_MESSAGE,ACKRESULT_SUCCESS,
- (HANDLE)1,0);
- DBFreeVariant(&dbv);
+ ProtoBroadcastAck(m_szModuleName,data->hContact,ACKTYPE_MESSAGE,ACKRESULT_SUCCESS,(HANDLE)1,0);
+ db_free(&dbv);
}
delete data;
@@ -198,8 +197,7 @@ int TwitterProto::SetStatus(int new_status)
// i think here we tell the proto interface struct that we're connecting, just so it knows
m_iStatus = ID_STATUS_CONNECTING;
// ok.. here i think we're telling the core that this protocol something.. but why?
- ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_STATUS,ACKRESULT_SUCCESS,
- (HANDLE)old_status,m_iStatus);
+ ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)old_status,m_iStatus);
ForkThread(&TwitterProto::SignOn,this);
}
@@ -209,8 +207,7 @@ int TwitterProto::SetStatus(int new_status)
m_iStatus = m_iDesiredStatus;
SetAllContactStatuses(ID_STATUS_OFFLINE);
- ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_STATUS,ACKRESULT_SUCCESS,
- (HANDLE)old_status,m_iStatus);
+ ProtoBroadcastAck(m_szModuleName,0,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)old_status,m_iStatus);
}
return 0;
@@ -232,10 +229,9 @@ int TwitterProto::OnEvent(PROTOEVENTTYPE event,WPARAM wParam,LPARAM lParam)
// *************************
-int TwitterProto::SvcCreateAccMgrUI(WPARAM wParam,LPARAM lParam)
+int TwitterProto::SvcCreateAccMgrUI(WPARAM,LPARAM lParam)
{
- return (int)CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_TWITTERACCOUNT),
- (HWND)lParam, first_run_dialog, (LPARAM)this );
+ return (int)CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_TWITTERACCOUNT),(HWND)lParam, first_run_dialog, (LPARAM)this );
}
int TwitterProto::GetName(WPARAM wParam,LPARAM lParam)
@@ -244,24 +240,23 @@ int TwitterProto::GetName(WPARAM wParam,LPARAM lParam)
return 0;
}
-int TwitterProto::GetStatus(WPARAM wParam,LPARAM lParam)
+int TwitterProto::GetStatus(WPARAM,LPARAM)
{
return m_iStatus;
}
-int TwitterProto::ReplyToTweet(WPARAM wParam,LPARAM lParam)
+int TwitterProto::ReplyToTweet(WPARAM wParam,LPARAM)
{
// TODO: support replying to tweets instead of just users
HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
- HWND hDlg = CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_TWEET),
- (HWND)0,tweet_proc,reinterpret_cast<LPARAM>(this));
+ HWND hDlg = CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_TWEET),0,tweet_proc,reinterpret_cast<LPARAM>(this));
DBVARIANT dbv;
- if( !DBGetContactSettingString(hContact,m_szModuleName,TWITTER_KEY_UN,&dbv))
+ if(!db_get_s(hContact,m_szModuleName,TWITTER_KEY_UN,&dbv))
{
SendMessage(hDlg,WM_SETREPLY,reinterpret_cast<WPARAM>(dbv.pszVal),0);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
ShowWindow(hDlg,SW_SHOW);
@@ -269,28 +264,19 @@ int TwitterProto::ReplyToTweet(WPARAM wParam,LPARAM lParam)
return 0;
}
-int TwitterProto::VisitHomepage(WPARAM wParam,LPARAM lParam)
+int TwitterProto::VisitHomepage(WPARAM wParam,LPARAM)
{
HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
DBVARIANT dbv;
- if( !DBGetContactSettingString(hContact,m_szModuleName,"Homepage",&dbv))
+ // TODO: remove this
+ if( !db_get_s(hContact,m_szModuleName,TWITTER_KEY_UN,&dbv))
{
- CallService(MS_UTILS_OPENURL,1,reinterpret_cast<LPARAM>(dbv.pszVal));
- DBFreeVariant(&dbv);
- }
- else
- {
- // TODO: remove this
- if( !DBGetContactSettingString(hContact,m_szModuleName,TWITTER_KEY_UN,&dbv))
- {
- std::string url = profile_base_url(twit_.get_base_url())+
- http::url_encode(dbv.pszVal);
- DBWriteContactSettingString(hContact,m_szModuleName,"Homepage",url.c_str());
+ std::string url = profile_base_url("https://twitter.com/") + http::url_encode(dbv.pszVal);
+ db_set_s(hContact,m_szModuleName,"Homepage",url.c_str());
- CallService(MS_UTILS_OPENURL,1,reinterpret_cast<LPARAM>(url.c_str()));
- DBFreeVariant(&dbv);
- }
+ CallService(MS_UTILS_OPENURL,1,reinterpret_cast<LPARAM>(url.c_str()));
+ db_free(&dbv);
}
return 0;
@@ -298,7 +284,7 @@ int TwitterProto::VisitHomepage(WPARAM wParam,LPARAM lParam)
// *************************
-int TwitterProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam)
+int TwitterProto::OnBuildStatusMenu(WPARAM,LPARAM)
{
HGENMENU hRoot = pcli->pfnGetProtocolMenu(m_szModuleName);
if (hRoot == NULL)
@@ -328,7 +314,7 @@ int TwitterProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam)
return 0;
}
-int TwitterProto::OnOptionsInit(WPARAM wParam,LPARAM lParam)
+int TwitterProto::OnOptionsInit(WPARAM wParam,LPARAM)
{
OPTIONSDIALOGPAGE odp = {sizeof(odp)};
odp.position = 271828;
@@ -354,18 +340,17 @@ int TwitterProto::OnOptionsInit(WPARAM wParam,LPARAM lParam)
return 0;
}
-int TwitterProto::OnTweet(WPARAM wParam,LPARAM lParam)
+int TwitterProto::OnTweet(WPARAM,LPARAM)
{
if(m_iStatus != ID_STATUS_ONLINE)
return 1;
- HWND hDlg = CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_TWEET),
- 0,tweet_proc,reinterpret_cast<LPARAM>(this));
+ HWND hDlg = CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_TWEET), 0,tweet_proc,reinterpret_cast<LPARAM>(this));
ShowWindow(hDlg,SW_SHOW);
return 0;
}
-int TwitterProto::OnModulesLoaded(WPARAM wParam,LPARAM lParam)
+int TwitterProto::OnModulesLoaded(WPARAM,LPARAM)
{
TCHAR descr[512];
NETLIBUSER nlu = {sizeof(nlu)};
@@ -425,14 +410,14 @@ int TwitterProto::OnModulesLoaded(WPARAM wParam,LPARAM lParam)
return 0;
}
-int TwitterProto::OnPreShutdown(WPARAM wParam,LPARAM lParam)
+int TwitterProto::OnPreShutdown(WPARAM,LPARAM)
{
Netlib_Shutdown(hNetlib_);
Netlib_Shutdown(hAvatarNetlib_);
return 0;
}
-int TwitterProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam)
+int TwitterProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM)
{
HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
if(IsMyContact(hContact))
@@ -443,8 +428,7 @@ int TwitterProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam)
int TwitterProto::ShowPinDialog()
{
- HWND hDlg = (HWND)DialogBoxParam(g_hInstance,MAKEINTRESOURCE(IDD_TWITTERPIN),
- 0,pin_proc,reinterpret_cast<LPARAM>(this));
+ HWND hDlg = (HWND)DialogBoxParam(g_hInstance,MAKEINTRESOURCE(IDD_TWITTERPIN),0,pin_proc,reinterpret_cast<LPARAM>(this));
ShowWindow(hDlg,SW_SHOW);
return 0;
}
@@ -452,7 +436,7 @@ int TwitterProto::ShowPinDialog()
void TwitterProto::ShowPopup(const wchar_t *text, int Error)
{
POPUPDATAT popup = {};
- _sntprintf(popup.lptzContactName,MAX_CONTACTNAME,TranslateT("%s Protocol"),m_tszUserName);
+ mir_sntprintf(popup.lptzContactName,MAX_CONTACTNAME,TranslateT("%s Protocol"),m_tszUserName);
wcs_to_tcs(CP_UTF8,text,popup.lptzText,MAX_SECONDLINE);
if (Error) {
@@ -470,7 +454,7 @@ void TwitterProto::ShowPopup(const wchar_t *text, int Error)
void TwitterProto::ShowPopup(const char *text, int Error)
{
POPUPDATAT popup = {};
- _sntprintf(popup.lptzContactName,MAX_CONTACTNAME,TranslateT("%s Protocol"),m_tszUserName);
+ mir_sntprintf(popup.lptzContactName,MAX_CONTACTNAME,TranslateT("%s Protocol"),m_tszUserName);
mbcs_to_tcs(CP_UTF8,text,popup.lptzText,MAX_SECONDLINE);
if (Error) {
popup.iSeconds = -1;
@@ -496,7 +480,7 @@ void TwitterProto::LOG(TCHAR *fmt,...)
mir_vsntprintf(text,SIZEOF(text),fmt,va);
va_end(va);
- CallService(MS_NETLIB_LOG, (WPARAM)hNetlib_, (LPARAM)( char* )_T2A(text));
+ CallService(MS_NETLIB_LOGW, (WPARAM)hNetlib_, (LPARAM)text);
}
// TODO: the more I think about it, the more I think all twit.* methods should
@@ -508,10 +492,9 @@ void TwitterProto::SendTweetWorker(void *p)
char *text = static_cast<char*>(p);
if (strlen(text) > 140) { // looks like the chat max outgoing msg thing doesn't work, so i'll do it here.
- char * errorPopup = new char[280]; // i hate c strings ... i should use std::string here. why did i use char* ??? need to delete[] or use std::String
- sprintf(errorPopup, "Don't be crazy! Everyone knows the max tweet size is 140, and you're trying to fit %d chars in there?", strlen(text));
+ TCHAR errorPopup[280];
+ mir_sntprintf(errorPopup,SIZEOF(errorPopup), _T("Don't be crazy! Everyone knows the max tweet size is 140, and you're trying to fit %d chars in there?"), strlen(text));
ShowPopup(errorPopup, 1);
- delete[] errorPopup;
return;
}
@@ -533,9 +516,7 @@ void TwitterProto::UpdateSettings()
if(in_chat_)
OnLeaveChat(0,0);
- for(HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
+ for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
{
if(!IsMyContact(hContact,true))
continue;
diff --git a/protocols/Twitter/src/theme.cpp b/protocols/Twitter/src/theme.cpp
index d1d212fbfe..5d866160aa 100644
--- a/protocols/Twitter/src/theme.cpp
+++ b/protocols/Twitter/src/theme.cpp
@@ -82,8 +82,7 @@ static int PrebuildContactMenu(WPARAM wParam,LPARAM lParam)
void InitContactMenus()
{
- g_hMenuEvts[0] = HookEvent(ME_CLIST_PREBUILDCONTACTMENU,
- PrebuildContactMenu);
+ g_hMenuEvts[0] = HookEvent(ME_CLIST_PREBUILDCONTACTMENU,PrebuildContactMenu);
CLISTMENUITEM mi = {sizeof(mi)};
mi.flags = CMIF_NOTOFFLINE | CMIF_ICONFROMICOLIB | CMIF_TCHAR;
@@ -99,8 +98,7 @@ void InitContactMenus()
mi.icolibItem = GetIconHandle("homepage");
mi.ptszName = LPGENT("Visit Homepage");
mi.pszService = "Twitter/VisitHomepage";
- g_hMenuEvts[2] = CreateServiceFunction(mi.pszService,
- GlobalService<&TwitterProto::VisitHomepage>);
+ g_hMenuEvts[2] = CreateServiceFunction(mi.pszService, GlobalService<&TwitterProto::VisitHomepage>);
g_hMenuItems[1] = Menu_AddContactMenuItem(&mi);
}
@@ -123,7 +121,6 @@ void ShowContactMenus(bool show)
if(!show)
item.flags |= CMIF_HIDDEN;
- CallService(MS_CLIST_MODIFYMENUITEM,reinterpret_cast<WPARAM>(g_hMenuItems[i]),
- reinterpret_cast<LPARAM>(&item));
+ CallService(MS_CLIST_MODIFYMENUITEM,reinterpret_cast<WPARAM>(g_hMenuItems[i]),reinterpret_cast<LPARAM>(&item));
}
} \ No newline at end of file
diff --git a/protocols/Twitter/src/ui.cpp b/protocols/Twitter/src/ui.cpp
index ada3fd5ae5..eb0a8b2543 100644
--- a/protocols/Twitter/src/ui.cpp
+++ b/protocols/Twitter/src/ui.cpp
@@ -42,39 +42,38 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lPa
DBVARIANT dbv;
- if( !DBGetContactSettingTString(0,proto->ModuleName(),TWITTER_KEY_GROUP,&dbv))
+ if(!db_get_ts(0,proto->ModuleName(),TWITTER_KEY_GROUP,&dbv))
{
SetDlgItemText(hwndDlg,IDC_GROUP,dbv.ptszVal);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
else
{
SetDlgItemText(hwndDlg,IDC_GROUP,L"Twitter");
}
- if( !DBGetContactSettingString(0,proto->ModuleName(),TWITTER_KEY_UN,&dbv))
+ if(!db_get_s(0,proto->ModuleName(),TWITTER_KEY_UN,&dbv))
{
SetDlgItemTextA(hwndDlg,IDC_USERNAME,dbv.pszVal);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
- /*if ( !DBGetContactSettingString(0,proto->ModuleName(),TWITTER_KEY_PASS,&dbv))
+ /*if ( !db_get_s(0,proto->ModuleName(),TWITTER_KEY_PASS,&dbv))
{
CallService(MS_DB_CRYPT_DECODESTRING,strlen(dbv.pszVal)+1,
reinterpret_cast<LPARAM>(dbv.pszVal));
SetDlgItemTextA(hwndDlg,IDC_PW,dbv.pszVal);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}*/
for(size_t i=0; i<SIZEOF(sites); i++)
{
- SendDlgItemMessage(hwndDlg,IDC_SERVER,CB_ADDSTRING,0,
- reinterpret_cast<LPARAM>(sites[i]));
+ SendDlgItemMessage(hwndDlg,IDC_SERVER,CB_ADDSTRING,0,reinterpret_cast<LPARAM>(sites[i]));
}
- if( !DBGetContactSettingString(0,proto->ModuleName(),TWITTER_KEY_BASEURL,&dbv))
+ if(!db_get_s(0,proto->ModuleName(),TWITTER_KEY_BASEURL,&dbv))
{
SetDlgItemTextA(hwndDlg,IDC_SERVER,dbv.pszVal);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
else
{
@@ -85,8 +84,7 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lPa
case WM_COMMAND:
if(LOWORD(wParam) == IDC_NEWACCOUNTLINK)
{
- CallService(MS_UTILS_OPENURL,1,reinterpret_cast<LPARAM>
- ("http://twitter.com/signup"));
+ CallService(MS_UTILS_OPENURL,1,reinterpret_cast<LPARAM>("https://twitter.com/signup"));
return true;
}
@@ -111,20 +109,20 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lPa
/*
GetDlgItemTextA(hwndDlg,IDC_UN,str,sizeof(str));
- DBWriteContactSettingString(0,proto->ModuleName(),TWITTER_KEY_UN,str);
+ db_set_s(0,proto->ModuleName(),TWITTER_KEY_UN,str);
GetDlgItemTextA(hwndDlg,IDC_PW,str,sizeof(str));
CallService(MS_DB_CRYPT_ENCODESTRING,sizeof(str),reinterpret_cast<LPARAM>(str));
- DBWriteContactSettingString(0,proto->ModuleName(),TWITTER_KEY_PASS,str);
+ db_set_s(0,proto->ModuleName(),TWITTER_KEY_PASS,str);
*/
GetDlgItemTextA(hwndDlg,IDC_SERVER,str,sizeof(str)-1);
if(str[strlen(str)-1] != '/')
strncat(str,"/",sizeof(str));
- DBWriteContactSettingString(0,proto->ModuleName(),TWITTER_KEY_BASEURL,str);
+ db_set_s(0,proto->ModuleName(),TWITTER_KEY_BASEURL,str);
GetDlgItemText(hwndDlg,IDC_GROUP,tstr,SIZEOF(tstr));
- DBWriteContactSettingTString(0,proto->ModuleName(),TWITTER_KEY_GROUP,tstr);
+ db_set_ts(0,proto->ModuleName(),TWITTER_KEY_GROUP,tstr);
return true;
}
@@ -178,7 +176,7 @@ INT_PTR CALLBACK tweet_proc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
size_t len = SendDlgItemMessage(hwndDlg,IDC_TWEETMSG,WM_GETTEXTLENGTH,0,0);
char str[4];
- _snprintf(str,sizeof(str),"%d",140-len);
+ mir_snprintf(str,sizeof(str),"%d",140-len);
SetDlgItemTextA(hwndDlg,IDC_CHARACTERS,str);
return true;
@@ -188,14 +186,14 @@ INT_PTR CALLBACK tweet_proc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
case WM_SETREPLY:
{
char foo[512];
- _snprintf(foo,sizeof(foo),"@%s ",(char*)wParam);
+ mir_snprintf(foo,sizeof(foo),"@%s ",(char*)wParam);
size_t len = strlen(foo);
SetDlgItemTextA(hwndDlg,IDC_TWEETMSG,foo);
SendDlgItemMessage(hwndDlg,IDC_TWEETMSG,EM_SETSEL,len,len);
char str[4];
- _snprintf(str,sizeof(str),"%d",140-len);
+ mir_snprintf(str,sizeof(str),"%d",140-len);
SetDlgItemTextA(hwndDlg,IDC_CHARACTERS,str);
return true;
@@ -218,33 +216,31 @@ INT_PTR CALLBACK options_proc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
proto = reinterpret_cast<TwitterProto*>(lParam);
DBVARIANT dbv;
- if( !DBGetContactSettingString(0,proto->ModuleName(),TWITTER_KEY_UN,&dbv))
+ if(!db_get_s(0,proto->ModuleName(),TWITTER_KEY_UN,&dbv))
{
SetDlgItemTextA(hwndDlg,IDC_UN,dbv.pszVal);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
- /*if( !DBGetContactSettingString(0,proto->ModuleName(),TWITTER_KEY_PASS,&dbv))
+ /*if( !db_get_s(0,proto->ModuleName(),TWITTER_KEY_PASS,&dbv))
{
CallService(MS_DB_CRYPT_DECODESTRING,strlen(dbv.pszVal)+1,
reinterpret_cast<LPARAM>(dbv.pszVal));
SetDlgItemTextA(hwndDlg,IDC_PW,dbv.pszVal);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}*/
- CheckDlgButton(hwndDlg,IDC_CHATFEED,DBGetContactSettingByte(0,
- proto->ModuleName(),TWITTER_KEY_CHATFEED,0));
+ CheckDlgButton(hwndDlg,IDC_CHATFEED,db_get_b(0,proto->ModuleName(),TWITTER_KEY_CHATFEED,0));
for(size_t i=0; i<SIZEOF(sites); i++)
{
- SendDlgItemMessage(hwndDlg,IDC_BASEURL,CB_ADDSTRING,0,
- reinterpret_cast<LPARAM>(sites[i]));
+ SendDlgItemMessage(hwndDlg,IDC_BASEURL,CB_ADDSTRING,0,reinterpret_cast<LPARAM>(sites[i]));
}
- if( !DBGetContactSettingString(0,proto->ModuleName(),TWITTER_KEY_BASEURL,&dbv))
+ if(!db_get_s(0,proto->ModuleName(),TWITTER_KEY_BASEURL,&dbv))
{
SetDlgItemTextA(hwndDlg,IDC_BASEURL,dbv.pszVal);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
else
{
@@ -252,12 +248,10 @@ INT_PTR CALLBACK options_proc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
}
char pollrate_str[32];
- mir_snprintf(pollrate_str,sizeof(pollrate_str),"%d",
- DBGetContactSettingDword(0,proto->ModuleName(),TWITTER_KEY_POLLRATE,80));
+ mir_snprintf(pollrate_str,sizeof(pollrate_str),"%d",db_get_dw(0,proto->ModuleName(),TWITTER_KEY_POLLRATE,80));
SetDlgItemTextA(hwndDlg,IDC_POLLRATE,pollrate_str);
- CheckDlgButton(hwndDlg,IDC_TWEET_MSG,DBGetContactSettingByte(0,
- proto->ModuleName(),TWITTER_KEY_TWEET_TO_MSG,0));
+ CheckDlgButton(hwndDlg,IDC_TWEET_MSG,db_get_b(0,proto->ModuleName(),TWITTER_KEY_TWEET_TO_MSG,0));
// Do this last so that any events propagated by pre-filling the form don't
@@ -293,28 +287,26 @@ INT_PTR CALLBACK options_proc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
char str[128];
GetDlgItemTextA(hwndDlg,IDC_UN,str,sizeof(str));
- DBWriteContactSettingString(0,proto->ModuleName(),TWITTER_KEY_UN,str);
+ db_set_s(0,proto->ModuleName(),TWITTER_KEY_UN,str);
/*GetDlgItemTextA(hwndDlg,IDC_PW,str,sizeof(str));
CallService(MS_DB_CRYPT_ENCODESTRING,sizeof(str),reinterpret_cast<LPARAM>(str));
- DBWriteContactSettingString(0,proto->ModuleName(),TWITTER_KEY_PASS,str);*/
+ db_set_s(0,proto->ModuleName(),TWITTER_KEY_PASS,str);*/
GetDlgItemTextA(hwndDlg,IDC_BASEURL,str,sizeof(str)-1);
if(str[strlen(str)-1] != '/')
strncat(str,"/",sizeof(str));
- DBWriteContactSettingString(0,proto->ModuleName(),TWITTER_KEY_BASEURL,str);
+ db_set_s(0,proto->ModuleName(),TWITTER_KEY_BASEURL,str);
- DBWriteContactSettingByte(0,proto->ModuleName(),TWITTER_KEY_CHATFEED,
- IsDlgButtonChecked(hwndDlg,IDC_CHATFEED));
+ db_set_b(0,proto->ModuleName(),TWITTER_KEY_CHATFEED,IsDlgButtonChecked(hwndDlg,IDC_CHATFEED));
GetDlgItemTextA(hwndDlg,IDC_POLLRATE,str,sizeof(str));
int rate = atoi(str);
if(rate == 0)
rate = 80;
- DBWriteContactSettingDword(0,proto->ModuleName(),TWITTER_KEY_POLLRATE,rate);
+ db_set_dw(0,proto->ModuleName(),TWITTER_KEY_POLLRATE,rate);
- DBWriteContactSettingByte(0,proto->ModuleName(),TWITTER_KEY_TWEET_TO_MSG,
- IsDlgButtonChecked(hwndDlg,IDC_TWEET_MSG));
+ db_set_b(0,proto->ModuleName(),TWITTER_KEY_TWEET_TO_MSG,IsDlgButtonChecked(hwndDlg,IDC_TWEET_MSG));
proto->UpdateSettings();
return true;
@@ -439,10 +431,8 @@ INT_PTR CALLBACK popup_options_proc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM l
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));
+ 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));
// ***** Get color information
@@ -474,7 +464,7 @@ INT_PTR CALLBACK popup_options_proc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM l
else
{
char str[32];
- _snprintf(str,sizeof(str),"%d",timeout);
+ mir_snprintf(str,sizeof(str),"%d",timeout);
SetDlgItemTextA(hwndDlg,IDC_TIMEOUT,str);
CheckAndUpdateDlgButton(hwndDlg,IDC_TIMEOUT_CUSTOM,true);
}
@@ -490,8 +480,7 @@ INT_PTR CALLBACK popup_options_proc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM l
switch(LOWORD(wParam))
{
case IDC_SHOWPOPUPS:
- EnableWindow(GetDlgItem(hwndDlg,IDC_NOSIGNONPOPUPS),
- IsDlgButtonChecked(hwndDlg,IDC_SHOWPOPUPS));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_NOSIGNONPOPUPS),IsDlgButtonChecked(hwndDlg,IDC_SHOWPOPUPS));
break;
case IDC_COL_CUSTOM:
@@ -529,20 +518,15 @@ INT_PTR CALLBACK popup_options_proc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM l
{
proto = reinterpret_cast<TwitterProto*>(GetWindowLongPtr(hwndDlg,GWLP_USERDATA));
- DBWriteContactSettingByte(0,proto->ModuleName(),TWITTER_KEY_POPUP_SHOW,
- IsDlgButtonChecked(hwndDlg,IDC_SHOWPOPUPS));
- DBWriteContactSettingByte(0,proto->ModuleName(),TWITTER_KEY_POPUP_SIGNON,
- !IsDlgButtonChecked(hwndDlg,IDC_NOSIGNONPOPUPS));
+ db_set_b(0,proto->ModuleName(),TWITTER_KEY_POPUP_SHOW,IsDlgButtonChecked(hwndDlg,IDC_SHOWPOPUPS));
+ db_set_b(0,proto->ModuleName(),TWITTER_KEY_POPUP_SIGNON,!IsDlgButtonChecked(hwndDlg,IDC_NOSIGNONPOPUPS));
// ***** Write color settings
- DBWriteContactSettingDword(0,proto->ModuleName(),TWITTER_KEY_POPUP_COLBACK,
- get_back_color(hwndDlg,true));
- DBWriteContactSettingDword(0,proto->ModuleName(),TWITTER_KEY_POPUP_COLTEXT,
- get_text_color(hwndDlg,true));
+ 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));
// ***** Write timeout setting
- DBWriteContactSettingDword(0,proto->ModuleName(),TWITTER_KEY_POPUP_TIMEOUT,
- get_timeout(hwndDlg));
+ db_set_dw(0,proto->ModuleName(),TWITTER_KEY_POPUP_TIMEOUT,get_timeout(hwndDlg));
return true;
}
@@ -573,7 +557,7 @@ INT_PTR CALLBACK pin_proc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
GetDlgItemTextA(hwndDlg,IDC_PIN,str,sizeof(str));
- DBWriteContactSettingString(0,proto->ModuleName(),TWITTER_KEY_OAUTH_PIN,str);
+ db_set_s(0,proto->ModuleName(),TWITTER_KEY_OAUTH_PIN,str);
EndDialog(hwndDlg, wParam);
return true;
}