summaryrefslogtreecommitdiff
path: root/protocols/Twitter
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Twitter')
-rw-r--r--protocols/Twitter/src/chat.cpp2
-rw-r--r--protocols/Twitter/src/common.h2
-rw-r--r--protocols/Twitter/src/connection.cpp144
-rw-r--r--protocols/Twitter/src/contacts.cpp4
-rw-r--r--protocols/Twitter/src/oauth.cpp65
-rw-r--r--protocols/Twitter/src/proto.cpp18
-rw-r--r--protocols/Twitter/src/proto.h5
-rw-r--r--protocols/Twitter/src/twitter.cpp2
-rw-r--r--protocols/Twitter/src/utility.cpp83
-rw-r--r--protocols/Twitter/src/utility.h6
10 files changed, 152 insertions, 179 deletions
diff --git a/protocols/Twitter/src/chat.cpp b/protocols/Twitter/src/chat.cpp
index 2f0f186f8d..e657414295 100644
--- a/protocols/Twitter/src/chat.cpp
+++ b/protocols/Twitter/src/chat.cpp
@@ -67,7 +67,7 @@ int TwitterProto::OnChatOutgoing(WPARAM wParam,LPARAM lParam)
switch(hook->pDest->iType) {
case GC_USER_MESSAGE:
- LOG ( _T("**Chat - Outgoing message: %s"), hook->ptszText);
+ debugLog( _T("**Chat - Outgoing message: %s"), hook->ptszText);
{
ptrA text( mir_utf8encodeT(hook->ptszText));
diff --git a/protocols/Twitter/src/common.h b/protocols/Twitter/src/common.h
index 1e2111ef18..d28a821032 100644
--- a/protocols/Twitter/src/common.h
+++ b/protocols/Twitter/src/common.h
@@ -43,7 +43,6 @@ using std::min;
#include <m_clist.h>
#include <m_clistint.h>
#include <m_clui.h>
-//#include "m_cluiframes.h"
#include <m_database.h>
#include <m_history.h>
#include <m_langpack.h>
@@ -54,6 +53,7 @@ using std::min;
#include <m_protocols.h>
#include <m_protomod.h>
#include <m_protosvc.h>
+#include <m_protoint.h>
#include <m_skin.h>
#include <statusmodes.h>
#include <m_system.h>
diff --git a/protocols/Twitter/src/connection.cpp b/protocols/Twitter/src/connection.cpp
index 0af2eb2e15..0d86488993 100644
--- a/protocols/Twitter/src/connection.cpp
+++ b/protocols/Twitter/src/connection.cpp
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
void CALLBACK TwitterProto::APC_callback(ULONG_PTR p)
{
- reinterpret_cast<TwitterProto*>(p)->LOG( _T("***** Executing APC"));
+ reinterpret_cast<TwitterProto*>(p)->debugLogA( _T("***** Executing APC"));
}
template<typename T>
@@ -48,16 +48,16 @@ inline static INT_PTR db_pod_set(HANDLE hContact,const char *module,const char *
void TwitterProto::SignOn(void*)
{
- LOG( _T("***** Beginning SignOn process"));
+ debugLogA( _T("***** Beginning SignOn process"));
WaitForSingleObject(&signon_lock_,INFINITE);
// Kill the old thread if it's still around
// this doesn't seem to work.. should we wait infinitely?
if(hMsgLoop_)
{
- LOG( _T("***** Requesting MessageLoop to exit"));
+ debugLogA( _T("***** Requesting MessageLoop to exit"));
QueueUserAPC(APC_callback,hMsgLoop_,(ULONG_PTR)this);
- LOG( _T("***** Waiting for old MessageLoop to exit"));
+ debugLogA( _T("***** Waiting for old MessageLoop to exit"));
//WaitForSingleObject(hMsgLoop_,INFINITE);
WaitForSingleObject(hMsgLoop_,180000);
CloseHandle(hMsgLoop_);
@@ -72,12 +72,12 @@ void TwitterProto::SignOn(void*)
}
ReleaseMutex(signon_lock_);
- LOG( _T("***** SignOn complete"));
+ debugLogA( _T("***** SignOn complete"));
}
bool TwitterProto::NegotiateConnection()
{
- LOG( _T("***** Negotiating connection with Twitter"));
+ debugLogA( _T("***** Negotiating connection with Twitter"));
disconnectionCount = 0;
// saving the current status to a temp var
@@ -94,28 +94,28 @@ bool TwitterProto::NegotiateConnection()
if (!dbTOK) {
oauthToken = dbv.pwszVal;
db_free(&dbv);
- //WLOG("**NegotiateConnection - we have an oauthToken already in the db - %s", oauthToken);
+ //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);
if (!dbTOKSec) {
oauthTokenSecret = dbv.pwszVal;
db_free(&dbv);
- //WLOG("**NegotiateConnection - we have an oauthTokenSecret already in the db - %s", oauthTokenSecret);
+ //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);
if (!dbName) {
screenName = dbv.pszVal;
db_free(&dbv);
- //WLOG("**NegotiateConnection - we have a username already in the db - %s", screenName);
+ //debugLogW("**NegotiateConnection - we have a username already in the db - %s", screenName);
}
else {
dbName = db_get_s(0,m_szModuleName,TWITTER_KEY_UN,&dbv);
if (!dbName) {
screenName = 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);
+ //debugLogW("**NegotiateConnection - we have a username already in the db - %s", screenName);
}
db_free(&dbv);
}
@@ -131,35 +131,35 @@ bool TwitterProto::NegotiateConnection()
if((oauthToken.size() <= 1) || (oauthTokenSecret.size() <= 1)) {
// first, reset all the keys so we can start fresh
resetOAuthKeys();
- LOG( _T("**NegotiateConnection - Reset OAuth Keys"));
+ debugLogA( _T("**NegotiateConnection - Reset OAuth Keys"));
//twit_.set_credentials(ConsumerKey, ConsumerSecret, oauthAccessToken, oauthAccessTokenSecret, L"", false);
// i think i was doin the wrong thing here.. i was setting the credentials as oauthAccessToken instead of oauthToken
// have to test..
- LOG( _T("**NegotiateConnection - Setting Consumer Keys..."));
- /*WLOG("**NegotiateConnection - sending set_cred: consumerKey is %s", ConsumerKey);
- WLOG("**NegotiateConnection - sending set_cred: consumerSecret is %s", ConsumerSecret);
- WLOG("**NegotiateConnection - sending set_cred: oauthToken is %s", oauthToken);
- WLOG("**NegotiateConnection - sending set_cred: oauthTokenSecret is %s", oauthTokenSecret);
- LOG("**NegotiateConnection - sending set_cred: no pin");*/
+ debugLogA( _T("**NegotiateConnection - Setting Consumer Keys..."));
+ /*debugLogW("**NegotiateConnection - sending set_cred: consumerKey is %s", ConsumerKey);
+ debugLogW("**NegotiateConnection - sending set_cred: consumerSecret is %s", ConsumerSecret);
+ debugLogW("**NegotiateConnection - sending set_cred: oauthToken is %s", oauthToken);
+ debugLogW("**NegotiateConnection - sending set_cred: oauthTokenSecret is %s", oauthTokenSecret);
+ debugLogA("**NegotiateConnection - sending set_cred: no pin");*/
twit_.set_credentials("", ConsumerKey, ConsumerSecret, oauthToken, oauthTokenSecret, L"", false);
- LOG( _T("**NegotiateConnection - Requesting oauthTokens"));
+ debugLogA( _T("**NegotiateConnection - Requesting oauthTokens"));
http::response resp = twit_.request_token();
//wstring rdata_WSTR(resp.data.length(),L' ');
//std::copy(resp.data.begin(), resp.data.end(), rdata_WSTR.begin());
wstring rdata_WSTR = UTF8ToWide(resp.data);
- //WLOG("**NegotiateConnection - REQUEST TOKEN IS %s", rdata_WSTR);
+ //debugLogW("**NegotiateConnection - REQUEST TOKEN IS %s", rdata_WSTR);
OAuthParameters response = twit_.ParseQueryString(rdata_WSTR);
oauthToken = response[L"oauth_token"];
oauthTokenSecret = response[L"oauth_token_secret"];
- //WLOG("**NegotiateConnection - oauthToken is %s", oauthToken);
- //WLOG("**NegotiateConnection - oauthTokenSecret is %s", oauthTokenSecret);
+ //debugLogW("**NegotiateConnection - oauthToken is %s", oauthToken);
+ //debugLogW("**NegotiateConnection - oauthTokenSecret is %s", oauthTokenSecret);
if (oauthToken.length() < 1) {
ShowPopup("OAuth Tokens not received, check your internet connection?", 1);
- LOG( _T("**NegotiateConnection - OAuth tokens not received, stopping before we open the web browser.."));
+ debugLogA( _T("**NegotiateConnection - OAuth tokens not received, stopping before we open the web browser.."));
return false;
}
@@ -171,7 +171,7 @@ bool TwitterProto::NegotiateConnection()
wchar_t buf[1024] = {};
mir_snwprintf(buf, SIZEOF(buf), AuthorizeUrl.c_str(), oauthToken.c_str());
- WLOG( _T("**NegotiateConnection - Launching %s"), buf);
+ debugLogW( _T("**NegotiateConnection - Launching %s"), buf);
ShellExecute(NULL, L"open", buf, NULL, NULL, SW_SHOWNORMAL);
ShowPinDialog();
@@ -193,9 +193,9 @@ bool TwitterProto::NegotiateConnection()
// 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;
- //WLOG("**NegotiateConnection - we have an oauthAccessToken already in the db - %s", oauthAccessToken);
+ //debugLogW("**NegotiateConnection - we have an oauthAccessToken already in the db - %s", oauthAccessToken);
}
- else { LOG( _T("**NegotiateConnection - oauthAccesToken too small? this is.. weird.")); }
+ else { debugLogA( _T("**NegotiateConnection - oauthAccesToken too small? this is.. weird.")); }
}
dbTOKSec = db_get_ws(0,m_szModuleName,TWITTER_KEY_OAUTH_ACCESS_TOK_SECRET,&dbv);
@@ -204,22 +204,22 @@ bool TwitterProto::NegotiateConnection()
db_free(&dbv);
if (oauthAccessTokenSecret.size() > 1) {
realAccessTokSecret = true;
- //WLOG("**NegotiateConnection - we have an oauthAccessTokenSecret already in the db - %s", oauthAccessTokenSecret);
+ //debugLogW("**NegotiateConnection - we have an oauthAccessTokenSecret already in the db - %s", oauthAccessTokenSecret);
}
- else { LOG( _T("**NegotiateConnection - oauthAccessTokenSecret too small? weird")); }
+ else { debugLogA( _T("**NegotiateConnection - oauthAccessTokenSecret too small? weird")); }
}
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.."));
+ debugLogA( _T("**NegotiateConnection - either the accessToken or accessTokenSecret was not there.."));
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);
+ //debugLogW("**NegotiateConnection - we have an pin already in the db - %s", pin);
db_free(&dbv);
}
else {
ShowPopup(TranslateT("OAuth variables are out of sequence, they have been reset. Please reconnect and reauthorize 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."));
+ debugLogA( _T("**NegotiateConnection - We don't have a PIN? this doesn't make sense. Resetting OAuth keys and setting offline."));
resetOAuthKeys();
ProtoBroadcastAck(0,ACKTYPE_STATUS,ACKRESULT_FAILED,(HANDLE)old_status,m_iStatus);
@@ -232,19 +232,19 @@ bool TwitterProto::NegotiateConnection()
return false;
}
- LOG( _T("**NegotiateConnection - Setting Consumer Keys and PIN..."));
- /*WLOG("**NegotiateConnection - sending set_cred: consumerKey is %s", ConsumerKey);
- WLOG("**NegotiateConnection - sending set_cred: consumerSecret is %s", ConsumerSecret);
- WLOG("**NegotiateConnection - sending set_cred: oauthToken is %s", oauthToken);
- WLOG("**NegotiateConnection - sending set_cred: oauthTokenSecret is %s", oauthTokenSecret);
- WLOG("**NegotiateConnection - sending set_cred: pin is %s", pin);*/
+ debugLogA( _T("**NegotiateConnection - Setting Consumer Keys and PIN..."));
+ /*debugLogW("**NegotiateConnection - sending set_cred: consumerKey is %s", ConsumerKey);
+ debugLogW("**NegotiateConnection - sending set_cred: consumerSecret is %s", ConsumerSecret);
+ debugLogW("**NegotiateConnection - sending set_cred: oauthToken is %s", oauthToken);
+ debugLogW("**NegotiateConnection - sending set_cred: oauthTokenSecret is %s", oauthTokenSecret);
+ debugLogW("**NegotiateConnection - sending set_cred: pin is %s", pin);*/
twit_.set_credentials("", ConsumerKey, ConsumerSecret, oauthToken, oauthTokenSecret, pin, false);
- LOG( _T("**NegotiateConnection - requesting access tokens..."));
+ debugLogA( _T("**NegotiateConnection - requesting access tokens..."));
http::response accessResp = twit_.request_access_tokens();
if (accessResp.code != 200) {
- LOG( _T("**NegotiateConnection - Failed to get Access Tokens, HTTP response code is: %d"), accessResp.code);
+ debugLogA( _T("**NegotiateConnection - Failed to get Access Tokens, HTTP response code is: %d"), accessResp.code);
ShowPopup(TranslateT("Failed to get Twitter Access Tokens, please go offline and try again. If this keeps happening, check your internet connection."));
resetOAuthKeys();
@@ -259,21 +259,21 @@ bool TwitterProto::NegotiateConnection()
return false;
}
else {
- LOG( _T("**NegotiateConnection - Successfully retrieved Access Tokens"));
+ debugLogA( _T("**NegotiateConnection - Successfully retrieved Access Tokens"));
wstring rdata_WSTR2 = UTF8ToWide(accessResp.data);
- //WLOG("**NegotiateConnection - accessToken STring is %s", rdata_WSTR2);
+ //debugLogW("**NegotiateConnection - accessToken STring is %s", rdata_WSTR2);
OAuthParameters accessTokenParameters = twit_.ParseQueryString(rdata_WSTR2);
oauthAccessToken = accessTokenParameters[L"oauth_token"];
- //WLOG("**NegotiateConnection - oauthAccessToken is %s", oauthAccessToken);
+ //debugLogW("**NegotiateConnection - oauthAccessToken is %s", oauthAccessToken);
oauthAccessTokenSecret = accessTokenParameters[L"oauth_token_secret"];
- //WLOG("**NegotiateConnection - oauthAccessTokenSecret is %s", oauthAccessTokenSecret);
+ //debugLogW("**NegotiateConnection - oauthAccessTokenSecret is %s", oauthAccessTokenSecret);
screenName = WideToUTF8(accessTokenParameters[L"screen_name"]);
- LOG( _T("**NegotiateConnection - screen name is %s"), screenName.c_str());
+ debugLogA( _T("**NegotiateConnection - screen name is %s"), screenName.c_str());
//save em
db_set_ws(0,m_szModuleName,TWITTER_KEY_OAUTH_ACCESS_TOK,oauthAccessToken.c_str());
@@ -301,16 +301,16 @@ bool TwitterProto::NegotiateConnection()
db_free(&dbv);
}
- LOG( _T("**NegotiateConnection - Setting Consumer Keys and verifying creds..."));
- /*WLOG("**NegotiateConnection - sending set_cred: consumerKey is %s", ConsumerKey);
- WLOG("**NegotiateConnection - sending set_cred: consumerSecret is %s", ConsumerSecret);
- WLOG("**NegotiateConnection - sending set_cred: oauthAccessToken is %s", oauthAccessToken);
- WLOG("**NegotiateConnection - sending set_cred: oauthAccessTokenSecret is %s", oauthAccessTokenSecret);
- LOG("**NegotiateConnection - sending set_cred: no pin");*/
+ debugLogA( _T("**NegotiateConnection - Setting Consumer Keys and verifying creds..."));
+ /*debugLogW("**NegotiateConnection - sending set_cred: consumerKey is %s", ConsumerKey);
+ debugLogW("**NegotiateConnection - sending set_cred: consumerSecret is %s", ConsumerSecret);
+ debugLogW("**NegotiateConnection - sending set_cred: oauthAccessToken is %s", oauthAccessToken);
+ debugLogW("**NegotiateConnection - sending set_cred: oauthAccessTokenSecret is %s", oauthAccessTokenSecret);
+ debugLogA("**NegotiateConnection - sending set_cred: no pin");*/
if (screenName.empty()) {
ShowPopup(TranslateT("You're missing the Nick key in the database. This isn't really a big deal, but you'll notice some minor quirks (self contact in list, no group chat outgoing message highlighting, etc). To fix it either add it manually or reset your twitter account in the miranda account options"));
- LOG( _T("**NegotiateConnection - Missing the Nick key in the database. Everything will still work, but it's nice to have"));
+ debugLogA( _T("**NegotiateConnection - Missing the Nick key in the database. Everything will still work, but it's nice to have"));
}
bool success;
@@ -322,7 +322,7 @@ bool TwitterProto::NegotiateConnection()
if(!success) {
//ShowPopup(TranslateT("Something went wrong with authorisation, OAuth keys have been reset. Please try to reconnect. If problems persist, please se your doctor"));
- LOG( _T("**NegotiateConnection - Verifying credentials failed! No internet maybe?"));
+ debugLogA( _T("**NegotiateConnection - Verifying credentials failed! No internet maybe?"));
//resetOAuthKeys();
ProtoBroadcastAck(0,ACKTYPE_STATUS,ACKRESULT_FAILED,(HANDLE)old_status,m_iStatus);
@@ -345,7 +345,7 @@ bool TwitterProto::NegotiateConnection()
void TwitterProto::MessageLoop(void*)
{
- LOG( _T("***** Entering Twitter::MessageLoop"));
+ debugLogA( _T("***** Entering Twitter::MessageLoop"));
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);
@@ -384,10 +384,10 @@ void TwitterProto::MessageLoop(void*)
if(m_iStatus != ID_STATUS_ONLINE)
break;
- LOG( _T("***** TwitterProto::MessageLoop going to sleep..."));
+ debugLogA( _T("***** TwitterProto::MessageLoop going to sleep..."));
if(SleepEx(poll_rate*1000,true) == WAIT_IO_COMPLETION)
break;
- LOG( _T("***** TwitterProto::MessageLoop waking up..."));
+ debugLogA( _T("***** TwitterProto::MessageLoop waking up..."));
popups = true;
}
@@ -396,7 +396,7 @@ void TwitterProto::MessageLoop(void*)
ScopedLock s(twitter_lock_);
twit_.set_credentials("",L"",L"",L"",L"",L"", false);
}
- LOG( _T("***** Exiting TwitterProto::MessageLoop"));
+ debugLogA( _T("***** Exiting TwitterProto::MessageLoop"));
}
struct update_avatar
@@ -429,17 +429,17 @@ void TwitterProto::UpdateAvatarWorker(void *p)
ai.format = ProtoGetAvatarFormat(filename.c_str());
if (ai.format == PA_FORMAT_UNKNOWN) {
- LOG( _T("***** Update avatar: Terminated for this contact, extension format unknown for %s"), data->url.c_str());
+ debugLogA( _T("***** Update avatar: Terminated for this contact, extension format unknown for %s"), data->url.c_str());
return; // lets just ignore unknown formats... if not it crashes miranda. should probably speak to borkra about this.
}
_tcsncpy(ai.filename,filename.c_str(),MAX_PATH); // puts the local file name in the avatar struct, to a max of 260 chars (as of now)
- LOG( _T("***** Updating avatar: %s"), data->url.c_str());
+ debugLogA( _T("***** Updating avatar: %s"), data->url.c_str());
WaitForSingleObjectEx(avatar_lock_,INFINITE,true);
if(CallService(MS_SYSTEM_TERMINATED,0,0)) // if miranda is shutting down...
{
- LOG( _T("***** Terminating avatar update early: %s"),data->url.c_str());
+ debugLogA( _T("***** Terminating avatar update early: %s"),data->url.c_str());
return;
}
@@ -451,7 +451,7 @@ void TwitterProto::UpdateAvatarWorker(void *p)
else
ProtoBroadcastAck(data->hContact,ACKTYPE_AVATAR,ACKRESULT_FAILED, &ai,0);
ReleaseMutex(avatar_lock_);
- LOG( _T("***** Done avatar: %s"),data->url.c_str());
+ debugLogA( _T("***** Done avatar: %s"),data->url.c_str());
}
void TwitterProto::UpdateAvatar(HANDLE hContact,const std::string &url,bool force)
@@ -460,7 +460,7 @@ void TwitterProto::UpdateAvatar(HANDLE hContact,const std::string &url,bool forc
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());
+ debugLogA( _T("***** Avatar already up-to-date: %s"), url.c_str());
}
else
{
@@ -497,21 +497,21 @@ void TwitterProto::UpdateFriends()
UpdateAvatar(hContact,i->profile_image_url);
}
disconnectionCount = 0;
- LOG( _T("***** Friends list updated"));
+ debugLogA( _T("***** Friends list updated"));
}
catch(const bad_response &)
{
++disconnectionCount;
- LOG( _T("***** UpdateFriends - Bad response from server, this has happened %d time(s)"), disconnectionCount);
+ debugLogA( _T("***** UpdateFriends - Bad response from server, this has happened %d time(s)"), disconnectionCount);
if (disconnectionCount > 2) {
- LOG( _T("***** UpdateFriends - Too many bad responses from the server, signing off"));
+ debugLogA( _T("***** UpdateFriends - Too many bad responses from the server, signing off"));
SetStatus(ID_STATUS_OFFLINE);
}
}
catch(const std::exception &e)
{
ShowPopup( (std::string("While updating friends list, an error occurred: ")+e.what()).c_str());
- LOG( _T("***** Error updating friends list: %s"), e.what());
+ debugLogA( _T("***** Error updating friends list: %s"), e.what());
}
}
@@ -588,14 +588,14 @@ void TwitterProto::UpdateStatuses(bool pre_read, bool popups, bool tweetToMsg)
db_pod_set(0,m_szModuleName,TWITTER_KEY_SINCEID,since_id_);
disconnectionCount = 0;
- LOG( _T("***** Status messages updated"));
+ debugLogA( _T("***** Status messages updated"));
}
catch(const bad_response &)
{
++disconnectionCount;
- LOG( _T("***** UpdateStatuses - Bad response from server, this has happened %d time(s)"), disconnectionCount);
+ debugLogA( _T("***** UpdateStatuses - Bad response from server, this has happened %d time(s)"), disconnectionCount);
if (disconnectionCount > 2) {
- LOG( _T("***** UpdateStatuses - Too many bad responses from the server, signing off"));
+ debugLogA( _T("***** UpdateStatuses - Too many bad responses from the server, signing off"));
SetStatus(ID_STATUS_OFFLINE);
}
}
@@ -603,7 +603,7 @@ void TwitterProto::UpdateStatuses(bool pre_read, bool popups, bool tweetToMsg)
{
ShowPopup( (std::string("While updating status messages, an error occurred: ")
+e.what()).c_str());
- LOG( _T("***** Error updating status messages: %s"), e.what());
+ debugLogA( _T("***** Error updating status messages: %s"), e.what());
}
}
@@ -633,21 +633,21 @@ void TwitterProto::UpdateMessages(bool pre_read)
db_pod_set(0,m_szModuleName,TWITTER_KEY_DMSINCEID,dm_since_id_);
disconnectionCount = 0;
- LOG( _T("***** Direct messages updated"));
+ debugLogA( _T("***** Direct messages updated"));
}
catch(const bad_response &)
{
++disconnectionCount;
- LOG( _T("***** UpdateMessages - Bad response from server, this has happened %d time(s)"), disconnectionCount);
+ debugLogA( _T("***** UpdateMessages - Bad response from server, this has happened %d time(s)"), disconnectionCount);
if (disconnectionCount > 2) {
- LOG( _T("***** UpdateMessages - Too many bad responses from the server, signing off"));
+ debugLogA( _T("***** UpdateMessages - Too many bad responses from the server, signing off"));
SetStatus(ID_STATUS_OFFLINE);
}
}
catch(const std::exception &e)
{
ShowPopup( (std::string("While updating direct messages, an error occurred: ")+e.what()).c_str());
- LOG( _T("***** Error updating direct messages: %s"), e.what());
+ debugLogA( _T("***** Error updating direct messages: %s"), e.what());
}
}
diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp
index 763ce1f699..f9772bf7b6 100644
--- a/protocols/Twitter/src/contacts.cpp
+++ b/protocols/Twitter/src/contacts.cpp
@@ -38,7 +38,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());
- LOG( _T("***** Error adding friend: %s"),e.what());
+ debugLogA( _T("***** Error adding friend: %s"),e.what());
}
mir_free(name);
}
@@ -127,7 +127,7 @@ void TwitterProto::DoSearch(void *p)
catch(const std::exception &e)
{
ShowPopup( (std::string("While searching for contacts, an error occurred: ") + e.what()).c_str());
- LOG( _T("***** Error searching for contacts: %s"), e.what());
+ debugLogA( _T("***** Error searching for contacts: %s"), e.what());
found = false;
}
diff --git a/protocols/Twitter/src/oauth.cpp b/protocols/Twitter/src/oauth.cpp
index a0ff221cd2..798f837499 100644
--- a/protocols/Twitter/src/oauth.cpp
+++ b/protocols/Twitter/src/oauth.cpp
@@ -34,7 +34,7 @@ OAuthParameters mir_twitter::BuildSignedOAuthParameters( const OAuthParameters&
// add the request token if found
if (!requestToken.empty())
{
- oauthParameters[L"oauth_token"] = requestToken; /*WLOG("requestToken not empty: %s", requestToken);*/
+ oauthParameters[L"oauth_token"] = requestToken; /*debugLogW("requestToken not empty: %s", requestToken);*/
}
// add the authorization pin if found
@@ -48,7 +48,7 @@ OAuthParameters mir_twitter::BuildSignedOAuthParameters( const OAuthParameters&
OAuthParameters allParameters = requestParameters;
if(Compare(httpMethod, L"POST", false) && postData) {
- //LOG("in post section of buildOAuthParams");
+ //debugLogA("in post section of buildOAuthParams");
allParameters.insert(postData->begin(), postData->end());
}
@@ -57,15 +57,15 @@ OAuthParameters mir_twitter::BuildSignedOAuthParameters( const OAuthParameters&
// prepare a signature base, a carefully formatted string containing
// all of the necessary information needed to generate a valid signature
wstring normalUrl = OAuthNormalizeUrl(url);
- //WLOG("normalURL is %s", normalUrl);
+ //debugLogW("normalURL is %s", normalUrl);
wstring normalizedParameters = OAuthNormalizeRequestParameters(allParameters);
- //WLOG("normalisedparams is %s", normalizedParameters);
+ //debugLogW("normalisedparams is %s", normalizedParameters);
wstring signatureBase = OAuthConcatenateRequestElements(httpMethod, normalUrl, normalizedParameters);
- //WLOG("sigBase is %s", signatureBase);
+ //debugLogW("sigBase is %s", signatureBase);
// obtain a signature and add it to header requestParameters
wstring signature = OAuthCreateSignature(signatureBase, consumerSecret, requestTokenSecret);
- //WLOG("**BuildSignedOAuthParameters - sig is %s", signature);
+ //debugLogW("**BuildSignedOAuthParameters - sig is %s", signature);
oauthParameters[L"oauth_signature"] = signature;
return oauthParameters;
@@ -90,7 +90,7 @@ wstring mir_twitter::UrlGetQuery( const wstring& url )
map<wstring, wstring> brokenURL = CrackURL(url);
query = brokenURL[L"extraInfo"];
- //WLOG("inside crack, url is %s", url);
+ //debugLogW("inside crack, url is %s", url);
wstring::size_type q = query.find_first_of(L'?');
if(q != wstring::npos)
{
@@ -122,9 +122,9 @@ wstring mir_twitter::OAuthWebRequestSubmit(
const wstring& pin
)
{
- //WLOG("URL is %s", url);
+ //debugLogW("URL is %s", url);
wstring query = UrlGetQuery(url);
- //WLOG("query is %s", query);
+ //debugLogW("query is %s", query);
OAuthParameters originalParameters = ParseQueryString(query);
OAuthParameters oauthSignedParameters = BuildSignedOAuthParameters(
@@ -142,7 +142,7 @@ wstring mir_twitter::OAuthWebRequestSubmit(
const wstring& url
)
{
- //WLOG("OAuthWebRequestSubmit(%s)", url);
+ //debugLogW("OAuthWebRequestSubmit(%s)", url);
//wstring oauthHeader = L"Authorization: OAuth ";
wstring oauthHeader = L"OAuth ";
@@ -151,9 +151,9 @@ wstring mir_twitter::OAuthWebRequestSubmit(
it != parameters.end();
++it)
{
- //WLOG("%s = ", it->first);
- //WLOG("%s", it->second);
- //LOG("---------");
+ //debugLogW("%s = ", it->first);
+ //debugLogW("%s", it->second);
+ //debugLogA("---------");
if(it != parameters.begin())
{
@@ -165,7 +165,7 @@ wstring mir_twitter::OAuthWebRequestSubmit(
oauthHeader += pair;
}
- //WLOG("oauthheader is %s", oauthHeader);
+ //debugLogW("oauthheader is %s", oauthHeader);
return oauthHeader;
}
@@ -174,14 +174,14 @@ wstring mir_twitter::OAuthWebRequestSubmit(
std::wstring mir_twitter::BuildQueryString( const OAuthParameters &parameters )
{
wstring query;
- //LOG("do we ever get here?");
+ //debugLogA("do we ever get here?");
for(OAuthParameters::const_iterator it = parameters.begin();
it != parameters.end();
++it)
{
- //LOG("aww como ONNNNNN");
- //LOG("%s = %s", it->first.c_str(), it->second.c_str());
- //WLOG("in buildqueryString bit, first is %s", it->first);
+ //debugLogA("aww como ONNNNNN");
+ //debugLogA("%s = %s", it->first.c_str(), it->second.c_str());
+ //debugLogW("in buildqueryString bit, first is %s", it->first);
if(it != parameters.begin())
{
@@ -198,10 +198,10 @@ std::wstring mir_twitter::BuildQueryString( const OAuthParameters &parameters )
wstring mir_twitter::OAuthConcatenateRequestElements( const wstring& httpMethod, wstring url, const wstring& parameters )
{
wstring escapedUrl = UrlEncode(url);
- //WLOG("before OAUTHConcat, params are %s", parameters);
+ //debugLogW("before OAUTHConcat, params are %s", parameters);
wstring escapedParameters = UrlEncode(parameters);
- //LOG(")))))))))))))))))))))))))))))))))))))))))))))))");
- //WLOG("after url encode, its %s", escapedParameters);
+ //debugLogA(")))))))))))))))))))))))))))))))))))))))))))))))");
+ //debugLogW("after url encode, its %s", escapedParameters);
wstring ret = httpMethod + L"&" + escapedUrl + L"&" + escapedParameters;
return ret;
}
@@ -221,10 +221,10 @@ map<wstring, wstring> mir_twitter::CrackURL(wstring url) {
vector<wstring> urlToks, urlToks2, extraInfoToks;
Split(url, urlToks, L':', false);
- //WLOG("**CRACK - URL to split is %s", url);
+ //debugLogW("**CRACK - URL to split is %s", url);
scheme1 = urlToks[0];
- //WLOG("**CRACK - scheme is %s", scheme1);
+ //debugLogW("**CRACK - scheme is %s", scheme1);
if (urlToks.size() == 2) { // if there is only 1 ":" in the url
if (Compare(scheme1, L"http", false)) {
@@ -234,25 +234,22 @@ map<wstring, wstring> mir_twitter::CrackURL(wstring url) {
port1 = L"443";
}
- //WLOG("**CRACK::2 - port is %s", port1);
+ //debugLogW("**CRACK::2 - port is %s", port1);
Split(urlToks[1], urlToks2, L'/', false);
domain1 = urlToks2[0];
- //WLOG("**CRACK::2 - domain is %s", domain1);
+ //debugLogW("**CRACK::2 - domain is %s", domain1);
explicitPort = L"0";
}
else if (urlToks.size() == 3) { // if there are 2 ":"s in the URL, ie a port is explicitly set
domain1 = urlToks[1].substr(2, urlToks[1].size());
- //WLOG("**CRACK::3 - domain is %s", domain1);
+ //debugLogW("**CRACK::3 - domain is %s", domain1);
Split(urlToks[2], urlToks2, L'/', false);
port1 = urlToks2[0];
- //WLOG("**CRACK::3 - port is %s", port1);
+ //debugLogW("**CRACK::3 - port is %s", port1);
explicitPort = L"1";
}
- else {
- WLOG("**CRACK - not a proper URL? doesn't have a colon. URL is %s", url);
-
- }
+ else ppro_->debugLogW(L"**CRACK - not a proper URL? doesn't have a colon. URL is %s", url);
for (size_t i = 1; i < urlToks2.size(); ++i) {
if (i > 1) {
@@ -260,7 +257,7 @@ map<wstring, wstring> mir_twitter::CrackURL(wstring url) {
}
path1 += urlToks2[i];
}
- //WLOG("**CRACK - path is %s", path1);
+ //debugLogW("**CRACK - path is %s", path1);
wstring::size_type foundHash = path1.find(L"#");
wstring::size_type foundQ = path1.find(L"?");
@@ -285,7 +282,7 @@ map<wstring, wstring> mir_twitter::CrackURL(wstring url) {
extraInfo = L"";
}
- //WLOG("**CRACK - extraInfo is %s", extraInfo);
+ //debugLogW("**CRACK - extraInfo is %s", extraInfo);
map<wstring, wstring> result;
result[L"scheme"] = scheme1;
@@ -342,7 +339,7 @@ wstring mir_twitter::OAuthNormalizeUrl( const wstring& url )
}
normalUrl = brokenURL[L"scheme"] + L"://" + brokenURL[L"domain"] + port + L"/" + pathOnly;
- //WLOG("**OAuthNOrmailseURL - normalUrl is %s", normalUrl);
+ //debugLogW("**OAuthNOrmailseURL - normalUrl is %s", normalUrl);
//}
return normalUrl;
}
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp
index c4279e6bf8..d90c67b6e1 100644
--- a/protocols/Twitter/src/proto.cpp
+++ b/protocols/Twitter/src/proto.cpp
@@ -78,8 +78,8 @@ TwitterProto::~TwitterProto()
{
twit_.Disconnect();
- if(hNetlib_)
- Netlib_CloseHandle(hNetlib_);
+ if(m_hNetlibUser)
+ Netlib_CloseHandle(m_hNetlibUser);
if(hAvatarNetlib_)
Netlib_CloseHandle(hAvatarNetlib_);
@@ -358,8 +358,8 @@ int TwitterProto::OnModulesLoaded(WPARAM,LPARAM)
// Create standard network connection
mir_sntprintf(descr,SIZEOF(descr),TranslateT("%s server connection"),m_tszUserName);
nlu.ptszDescriptiveName = descr;
- hNetlib_ = (HANDLE)CallService(MS_NETLIB_REGISTERUSER,0,(LPARAM)&nlu);
- if(hNetlib_ == 0)
+ m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER,0,(LPARAM)&nlu);
+ if(m_hNetlibUser == 0)
MessageBox(0, TranslateT("Unable to get Netlib connection for Twitter"), TranslateT("Twitter"), 0);
// Create avatar network connection (TODO: probably remove this)
@@ -372,7 +372,7 @@ int TwitterProto::OnModulesLoaded(WPARAM,LPARAM)
if(hAvatarNetlib_ == 0)
MessageBox(0, TranslateT("Unable to get avatar Netlib connection for Twitter"), TranslateT("Twitter"), 0);
- twit_.set_handle(hNetlib_);
+ twit_.set_handle(this, m_hNetlibUser);
GCREGISTER gcr = {sizeof(gcr)};
gcr.pszModule = m_szModuleName;
@@ -391,7 +391,7 @@ int TwitterProto::OnModulesLoaded(WPARAM,LPARAM)
int TwitterProto::OnPreShutdown(WPARAM,LPARAM)
{
- Netlib_Shutdown(hNetlib_);
+ Netlib_Shutdown(m_hNetlibUser);
Netlib_Shutdown(hAvatarNetlib_);
return 0;
}
@@ -447,9 +447,9 @@ void TwitterProto::ShowPopup(const char *text, int Error)
MessageBox(0,popup.lptzText,popup.lptzContactName,0);
}
-void TwitterProto::LOG(TCHAR *fmt,...)
+void TwitterProto::debugLogA(TCHAR *fmt,...)
{
- if (!hNetlib_)
+ if (!m_hNetlibUser)
return;
va_list va;
@@ -459,7 +459,7 @@ void TwitterProto::LOG(TCHAR *fmt,...)
mir_vsntprintf(text,SIZEOF(text),fmt,va);
va_end(va);
- CallService(MS_NETLIB_LOGW, (WPARAM)hNetlib_, (LPARAM)text);
+ CallService(MS_NETLIB_LOGW, (WPARAM)m_hNetlibUser, (LPARAM)text);
}
// TODO: the more I think about it, the more I think all twit.* methods should
diff --git a/protocols/Twitter/src/proto.h b/protocols/Twitter/src/proto.h
index 71b22cd3ea..ff10081aed 100644
--- a/protocols/Twitter/src/proto.h
+++ b/protocols/Twitter/src/proto.h
@@ -135,8 +135,8 @@ private:
HANDLE AddToClientList(const char *,const char *);
void SetAllContactStatuses(int);
- void LOG(TCHAR *fmt,...);
- __inline void WLOG(TCHAR* first, const tstring& last) { LOG(first, last.c_str()); }
+ void debugLogA(TCHAR *fmt,...);
+ __inline void debugLogW(TCHAR* first, const tstring& last) { debugLogA(first, last.c_str()); }
static void CALLBACK APC_callback(ULONG_PTR p);
void UpdateChat(const twitter_user &update);
@@ -152,7 +152,6 @@ private:
HANDLE avatar_lock_;
HANDLE twitter_lock_;
- HANDLE hNetlib_;
HANDLE hAvatarNetlib_;
HANDLE hMsgLoop_;
mir_twitter twit_;
diff --git a/protocols/Twitter/src/twitter.cpp b/protocols/Twitter/src/twitter.cpp
index 81e55a2cad..f5157b8caf 100644
--- a/protocols/Twitter/src/twitter.cpp
+++ b/protocols/Twitter/src/twitter.cpp
@@ -145,7 +145,7 @@ const std::string & twitter::get_base_url() const
// if i will have to parse it myself and add them one by one :(
IDs = retrieve<js::array>(friendIDs,"ids");
for(js::array::const_iterator i=IDs.begin(); i!=IDs.end(); ++i) {
- //LOG("friends ID: " + i);
+ //debugLogA("friends ID: " + i);
// add array to master array
js::object one = boost::any_cast<js::object>(**i);
masterIDs.push_back(one); // i don't understand this. how do we push into the array? should i just use C++ arrays (list?) and bail on boost?
diff --git a/protocols/Twitter/src/utility.cpp b/protocols/Twitter/src/utility.cpp
index ecfc3f9576..7d91be4f67 100644
--- a/protocols/Twitter/src/utility.cpp
+++ b/protocols/Twitter/src/utility.cpp
@@ -25,8 +25,7 @@ std::string b64encode(const std::string &s)
return std::string( ptrA( mir_base64_encode((BYTE*)s.c_str(), (unsigned)s.length())));
}
-http::response mir_twitter::slurp(const std::string &url,http::method meth,
- OAuthParameters postParams)
+http::response mir_twitter::slurp(const std::string &url, http::method meth, OAuthParameters postParams)
{
NETLIBHTTPREQUEST req = {sizeof(req)};
req.requestType = (meth == http::get) ? REQUEST_GET:REQUEST_POST;
@@ -40,16 +39,16 @@ http::response mir_twitter::slurp(const std::string &url,http::method meth,
std::wstring auth;
if (meth == http::get) {
- if (url_WSTR.size()>0) { WLOG("**SLURP::GET - we have a URL: %s", url_WSTR); }
- if (consumerKey_.size()>0) { LOG("**SLURP::GET - we have a consumerKey"); }
- if (consumerSecret_.size()>0) { LOG("**SLURP::GET - we have a consumerSecret"); }
- if (oauthAccessToken_.size()>0) { LOG("**SLURP::GET - we have a oauthAccessToken"); }
- if (oauthAccessTokenSecret_.size()>0) { LOG("**SLURP::GET - we have a oauthAccessTokenSecret"); }
- if (pin_.size()>0) { LOG("**SLURP::GET - we have a pin"); }
- //WLOG("consumerSEcret is %s", consumerSecret_);
- //WLOG("oauthAccessTok is %s", oauthAccessToken_);
- //WLOG("oautAccessTokSEc is %s", oauthAccessTokenSecret_);
- //WLOG("pin is %s", pin_);
+ if (url_WSTR.size()>0) { ppro_->debugLogW(L"**SLURP::GET - we have a URL: %s", url_WSTR); }
+ if (consumerKey_.size()>0) { ppro_->debugLogA("**SLURP::GET - we have a consumerKey"); }
+ if (consumerSecret_.size()>0) { ppro_->debugLogA("**SLURP::GET - we have a consumerSecret"); }
+ if (oauthAccessToken_.size()>0) { ppro_->debugLogA("**SLURP::GET - we have a oauthAccessToken"); }
+ if (oauthAccessTokenSecret_.size()>0) { ppro_->debugLogA("**SLURP::GET - we have a oauthAccessTokenSecret"); }
+ if (pin_.size()>0) { ppro_->debugLogA("**SLURP::GET - we have a pin"); }
+ //debugLogW("consumerSEcret is %s", consumerSecret_);
+ //debugLogW("oauthAccessTok is %s", oauthAccessToken_);
+ //debugLogW("oautAccessTokSEc is %s", oauthAccessTokenSecret_);
+ //debugLogW("pin is %s", pin_);
auth = OAuthWebRequestSubmit(url_WSTR, L"GET", NULL, consumerKey_, consumerSecret_,
oauthAccessToken_, oauthAccessTokenSecret_, pin_);
@@ -57,17 +56,17 @@ http::response mir_twitter::slurp(const std::string &url,http::method meth,
else if (meth == http::post) {
//OAuthParameters postParams;
- if (url_WSTR.size()>0) { WLOG("**SLURP::POST - we have a URL: %s", url_WSTR); }
- if (consumerKey_.size()>0) { LOG("**SLURP::POST - we have a consumerKey"); }
- if (consumerSecret_.size()>0) { LOG("**SLURP::POST - we have a consumerSecret"); }
- if (oauthAccessToken_.size()>0) { LOG("**SLURP::POST - we have a oauthAccessToken"); }
- if (oauthAccessTokenSecret_.size()>0) { LOG("**SLURP::POST - we have a oauthAccessTokenSecret"); }
- if (pin_.size()>0) { LOG("**SLURP::POST - we have a pin"); }
-
- //WLOG("consumerKey is %s", consumerKey_);
- //WLOG("consumerSEcret is %s", consumerSecret_);
- //WLOG("oauthAccessTok is %s", oauthAccessToken_);
- //WLOG("oautAccessTokSEc is %s", oauthAccessTokenSecret_);
+ if (url_WSTR.size()>0) { ppro_->debugLogW(L"**SLURP::POST - we have a URL: %s", url_WSTR); }
+ if (consumerKey_.size()>0) { ppro_->debugLogA("**SLURP::POST - we have a consumerKey"); }
+ if (consumerSecret_.size()>0) { ppro_->debugLogA("**SLURP::POST - we have a consumerSecret"); }
+ if (oauthAccessToken_.size()>0) { ppro_->debugLogA("**SLURP::POST - we have a oauthAccessToken"); }
+ if (oauthAccessTokenSecret_.size()>0) { ppro_->debugLogA("**SLURP::POST - we have a oauthAccessTokenSecret"); }
+ if (pin_.size()>0) { ppro_->debugLogA("**SLURP::POST - we have a pin"); }
+
+ //debugLogW("consumerKey is %s", consumerKey_);
+ //debugLogW("consumerSEcret is %s", consumerSecret_);
+ //debugLogW("oauthAccessTok is %s", oauthAccessToken_);
+ //debugLogW("oautAccessTokSEc is %s", oauthAccessTokenSecret_);
//std::wstring pdata_WSTR(post_data.length(),L' ');
//std::copy(post_data.begin(), post_data.end(), pdata_WSTR.begin());
@@ -77,14 +76,14 @@ http::response mir_twitter::slurp(const std::string &url,http::method meth,
pdata_WSTR = BuildQueryString(postParams);
- WLOG("**SLURP::POST - post data is: %s", pdata_WSTR);
+ ppro_->debugLogW(L"**SLURP::POST - post data is: %s", pdata_WSTR);
auth = OAuthWebRequestSubmit(url_WSTR, L"POST", &postParams, consumerKey_, consumerSecret_,
oauthAccessToken_, oauthAccessTokenSecret_);
- //WLOG("**SLURP::POST auth is %s", auth);
+ //debugLogW("**SLURP::POST auth is %s", auth);
}
else {
- LOG("**SLURP - There is something really wrong.. the http method was neither get or post.. WHY??");
+ ppro_->debugLogA("**SLURP - There is something really wrong.. the http method was neither get or post.. WHY??");
}
//std::string auth_STR(auth.length(), ' ');
@@ -114,19 +113,19 @@ http::response mir_twitter::slurp(const std::string &url,http::method meth,
req.headersCount = 3;
req.dataLength = (int)pdata_STR.size();
req.pData = const_cast<char*>(pdata_STR.c_str());
- LOG("**SLURP::POST - req.pdata is %s", req.pData);
+ ppro_->debugLogA("**SLURP::POST - req.pdata is %s", req.pData);
}
req.flags = NLHRF_HTTP11 | NLHRF_PERSISTENT | NLHRF_REDIRECT;
req.nlc = httpPOST_;
http::response resp_data;
- LOG("**SLURP - just before calling HTTPTRANSACTION");
+ ppro_->debugLogA("**SLURP - just before calling HTTPTRANSACTION");
NETLIBHTTPREQUEST *resp = reinterpret_cast<NETLIBHTTPREQUEST*>(CallService(MS_NETLIB_HTTPTRANSACTION,
reinterpret_cast<WPARAM>(handle_), reinterpret_cast<LPARAM>(&req)));
- LOG("**SLURP - HTTPTRANSACTION complete.");
+ ppro_->debugLogA("**SLURP - HTTPTRANSACTION complete.");
if(resp)
{
- LOG("**SLURP - the server has responded!");
+ ppro_->debugLogA("**SLURP - the server has responded!");
httpPOST_ = resp->nlc;
resp_data.code = resp->resultCode;
resp_data.data = resp->pData ? resp->pData:"";
@@ -135,34 +134,12 @@ http::response mir_twitter::slurp(const std::string &url,http::method meth,
}
else {
httpPOST_ = NULL;
- LOG("SLURP - there was no response!");
+ ppro_->debugLogA("SLURP - there was no response!");
}
return resp_data;
}
-INT_PTR mir_twitter::LOG(const char *fmt,...)
-{
- va_list va;
- char text[1024];
- if (!handle_)
- return 0;
-
- va_start(va,fmt);
- mir_vsnprintf(text,sizeof(text),fmt,va);
- va_end(va);
-
- return CallService(MS_NETLIB_LOG,(WPARAM)handle_,(LPARAM)text);
-}
-
-INT_PTR mir_twitter::WLOG(const char* first, const std::wstring last)
-{
- char *str1 = new char[1024*96];
- mir_snprintf(str1, 1024*96, "%ls", last.c_str());
-
- return LOG(first, str1);
-}
-
bool save_url(HANDLE hNetlib,const std::string &url,const std::tstring &filename)
{
NETLIBHTTPREQUEST req = {sizeof(req)};
diff --git a/protocols/Twitter/src/utility.h b/protocols/Twitter/src/utility.h
index 42d2313002..ba6ecc3651 100644
--- a/protocols/Twitter/src/utility.h
+++ b/protocols/Twitter/src/utility.h
@@ -27,8 +27,9 @@ class mir_twitter : public twitter
{
public:
mir_twitter() : twitter(), handle_(NULL), httpPOST_(NULL) {}
- void set_handle(HANDLE h)
+ void set_handle(PROTO_INTERFACE *ppro, HANDLE h)
{
+ ppro_ = ppro;
handle_ = h;
}
@@ -80,11 +81,10 @@ public:
protected:
http::response slurp(const std::string &,http::method, OAuthParameters );
- INT_PTR LOG(const char *fmt,...);
- INT_PTR WLOG(const char* first, const std::wstring last);
HANDLE httpPOST_;
HANDLE handle_;
+ PROTO_INTERFACE *ppro_;
};
inline void mbcs_to_tcs(UINT code_page,const char *mbstr,TCHAR *tstr,int tlen)