summaryrefslogtreecommitdiff
path: root/protocols/Twitter/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Twitter/src')
-rw-r--r--protocols/Twitter/src/chat.cpp8
-rw-r--r--protocols/Twitter/src/connection.cpp4
-rw-r--r--protocols/Twitter/src/contacts.cpp10
-rw-r--r--protocols/Twitter/src/proto.cpp45
-rw-r--r--protocols/Twitter/src/proto.h26
-rw-r--r--protocols/Twitter/src/theme.cpp2
-rw-r--r--protocols/Twitter/src/ui.cpp2
-rw-r--r--protocols/Twitter/src/utility.h29
8 files changed, 49 insertions, 77 deletions
diff --git a/protocols/Twitter/src/chat.cpp b/protocols/Twitter/src/chat.cpp
index dd2219e6f7..96ad8af6da 100644
--- a/protocols/Twitter/src/chat.cpp
+++ b/protocols/Twitter/src/chat.cpp
@@ -75,7 +75,7 @@ int TwitterProto::OnChatOutgoing(WPARAM wParam,LPARAM lParam)
replaceAll(tweet, "%%", "%"); // the chat plugin will turn "%" into "%%", so we have to change it back :/
char *varTweet = mir_strdup( tweet.c_str());
- ForkThread(&TwitterProto::SendTweetWorker, this, varTweet);
+ ForkThread(&TwitterProto::SendTweetWorker, varTweet);
}
break;
@@ -128,7 +128,7 @@ void TwitterProto::DeleteChatContact(const char *name)
mir_free(const_cast<TCHAR*>(gce.ptszNick));
}
-int TwitterProto::OnJoinChat(WPARAM,LPARAM suppress)
+INT_PTR TwitterProto::OnJoinChat(WPARAM,LPARAM suppress)
{
GCSESSION gcw = {sizeof(gcw)};
@@ -156,7 +156,7 @@ int TwitterProto::OnJoinChat(WPARAM,LPARAM suppress)
CallServiceSync(MS_GC_EVENT,0,reinterpret_cast<LPARAM>(&gce));
// ***** Hook events
- HookProtoEvent(ME_GC_EVENT,&TwitterProto::OnChatOutgoing,this);
+ HookEvent(ME_GC_EVENT, &TwitterProto::OnChatOutgoing);
// Note: Initialization will finish up in SetChatStatus, called separately
if(!suppress)
@@ -166,7 +166,7 @@ int TwitterProto::OnJoinChat(WPARAM,LPARAM suppress)
return 0;
}
-int TwitterProto::OnLeaveChat(WPARAM,LPARAM)
+INT_PTR TwitterProto::OnLeaveChat(WPARAM,LPARAM)
{
in_chat_ = false;
diff --git a/protocols/Twitter/src/connection.cpp b/protocols/Twitter/src/connection.cpp
index 77ed802696..d9a7dc704b 100644
--- a/protocols/Twitter/src/connection.cpp
+++ b/protocols/Twitter/src/connection.cpp
@@ -68,7 +68,7 @@ void TwitterProto::SignOn(void*)
OnJoinChat(0,true);
SetAllContactStatuses(ID_STATUS_ONLINE);
- hMsgLoop_ = ForkThreadEx(&TwitterProto::MessageLoop,this);
+ hMsgLoop_ = ForkThreadEx(&TwitterProto::MessageLoop, NULL, 0);
}
ReleaseMutex(signon_lock_);
@@ -474,7 +474,7 @@ void TwitterProto::UpdateAvatar(HANDLE hContact,const std::string &url,bool forc
}
else
{
- ForkThread(&TwitterProto::UpdateAvatarWorker, this,new update_avatar(hContact,url));
+ ForkThread(&TwitterProto::UpdateAvatarWorker, new update_avatar(hContact,url));
}
}
diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp
index 00dd6c66a8..da9ce0d79c 100644
--- a/protocols/Twitter/src/contacts.cpp
+++ b/protocols/Twitter/src/contacts.cpp
@@ -48,7 +48,7 @@ HANDLE TwitterProto::AddToList(int flags,PROTOSEARCHRESULT *result)
if(m_iStatus != ID_STATUS_ONLINE)
return 0;
- ForkThread(&TwitterProto::AddToListWorker,this,mir_utf8encodeT(result->nick));
+ ForkThread(&TwitterProto::AddToListWorker, mir_utf8encodeT(result->nick));
return AddToClientList( _T2A(result->nick),"");
}
@@ -87,7 +87,7 @@ int TwitterProto::GetInfo(HANDLE hContact,int info_type)
if(info_type == 0) // From clicking "Update" in the Userinfo dialog
{
- ForkThread(&TwitterProto::UpdateInfoWorker,this,hContact);
+ ForkThread(&TwitterProto::UpdateInfoWorker, hContact);
return 0;
}
@@ -152,13 +152,13 @@ void TwitterProto::DoSearch(void *p)
HANDLE TwitterProto::SearchBasic(const TCHAR *username)
{
- ForkThread(&TwitterProto::DoSearch,this,new search_query(username,false));
+ ForkThread(&TwitterProto::DoSearch, new search_query(username,false));
return (HANDLE)1;
}
HANDLE TwitterProto::SearchByEmail(const TCHAR *email)
{
- ForkThread(&TwitterProto::DoSearch,this,new search_query(email,true));
+ ForkThread(&TwitterProto::DoSearch, new search_query(email,true));
return (HANDLE)1;
}
@@ -179,7 +179,7 @@ void TwitterProto::GetAwayMsgWorker(void *hContact)
HANDLE TwitterProto::GetAwayMsg(HANDLE hContact)
{
- ForkThread(&TwitterProto::GetAwayMsgWorker, this,hContact);
+ ForkThread(&TwitterProto::GetAwayMsgWorker, hContact);
return (HANDLE)1;
}
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp
index d39ba23371..46655d8ba8 100644
--- a/protocols/Twitter/src/proto.cpp
+++ b/protocols/Twitter/src/proto.cpp
@@ -31,23 +31,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
static volatile LONG g_msgid = 1;
-TwitterProto::TwitterProto(const char *proto_name,const TCHAR *username)
+TwitterProto::TwitterProto(const char *proto_name,const TCHAR *username) :
+ PROTO<TwitterProto>(proto_name, username)
{
- ProtoConstructor(this, proto_name, username);
+ CreateService(PS_CREATEACCMGRUI, &TwitterProto::SvcCreateAccMgrUI);
+ CreateService(PS_GETNAME, &TwitterProto::GetName);
+ CreateService(PS_GETSTATUS, &TwitterProto::GetStatus);
- CreateProtoService(m_szModuleName,PS_CREATEACCMGRUI, &TwitterProto::SvcCreateAccMgrUI,this);
- CreateProtoService(m_szModuleName,PS_GETNAME, &TwitterProto::GetName, this);
- CreateProtoService(m_szModuleName,PS_GETSTATUS,&TwitterProto::GetStatus, this);
+ CreateService(PS_JOINCHAT, &TwitterProto::OnJoinChat);
+ CreateService(PS_LEAVECHAT, &TwitterProto::OnLeaveChat);
- CreateProtoService(m_szModuleName,PS_JOINCHAT, &TwitterProto::OnJoinChat, this);
- CreateProtoService(m_szModuleName,PS_LEAVECHAT,&TwitterProto::OnLeaveChat,this);
+ CreateService(PS_GETMYAVATAR, &TwitterProto::GetAvatar);
+ CreateService(PS_SETMYAVATAR, &TwitterProto::SetAvatar);
- CreateProtoService(m_szModuleName,PS_GETMYAVATAR,&TwitterProto::GetAvatar,this);
- CreateProtoService(m_szModuleName,PS_SETMYAVATAR,&TwitterProto::SetAvatar,this);
-
- HookProtoEvent(ME_DB_CONTACT_DELETED, &TwitterProto::OnContactDeleted, this);
- HookProtoEvent(ME_CLIST_PREBUILDSTATUSMENU, &TwitterProto::OnBuildStatusMenu, this);
- HookProtoEvent(ME_OPT_INITIALISE, &TwitterProto::OnOptionsInit, this);
+ HookEvent(ME_DB_CONTACT_DELETED, &TwitterProto::OnContactDeleted);
+ HookEvent(ME_CLIST_PREBUILDSTATUSMENU, &TwitterProto::OnBuildStatusMenu);
+ HookEvent(ME_OPT_INITIALISE, &TwitterProto::OnOptionsInit);
tstring defFolder = std::tstring( _T("%miranda_avatarcache%\\")) + m_tszUserName;
hAvatarFolder_ = FoldersRegisterCustomPathT(LPGEN("Avatars"), m_szModuleName, defFolder.c_str(), m_tszUserName);
@@ -173,7 +172,7 @@ int TwitterProto::SendMsg(HANDLE hContact,int flags,const char *msg)
tszMsg = mir_a2t( msg );
int seq = InterlockedIncrement(&g_msgid);
- ForkThread(&TwitterProto::SendSuccess, this,new send_direct(hContact, msg, seq));
+ ForkThread(&TwitterProto::SendSuccess, new send_direct(hContact, msg, seq));
return seq;
}
@@ -235,23 +234,23 @@ int TwitterProto::OnEvent(PROTOEVENTTYPE event,WPARAM wParam,LPARAM lParam)
// *************************
-int TwitterProto::SvcCreateAccMgrUI(WPARAM,LPARAM lParam)
+INT_PTR TwitterProto::SvcCreateAccMgrUI(WPARAM,LPARAM lParam)
{
return (int)CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_TWITTERACCOUNT),(HWND)lParam, first_run_dialog, (LPARAM)this );
}
-int TwitterProto::GetName(WPARAM wParam,LPARAM lParam)
+INT_PTR TwitterProto::GetName(WPARAM wParam,LPARAM lParam)
{
lstrcpynA(reinterpret_cast<char*>(lParam), m_szModuleName, (int)wParam);
return 0;
}
-int TwitterProto::GetStatus(WPARAM,LPARAM)
+INT_PTR TwitterProto::GetStatus(WPARAM,LPARAM)
{
return m_iStatus;
}
-int TwitterProto::ReplyToTweet(WPARAM wParam,LPARAM)
+INT_PTR TwitterProto::ReplyToTweet(WPARAM wParam,LPARAM)
{
// TODO: support replying to tweets instead of just users
HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
@@ -270,7 +269,7 @@ int TwitterProto::ReplyToTweet(WPARAM wParam,LPARAM)
return 0;
}
-int TwitterProto::VisitHomepage(WPARAM wParam,LPARAM)
+INT_PTR TwitterProto::VisitHomepage(WPARAM wParam,LPARAM)
{
HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
@@ -311,7 +310,7 @@ int TwitterProto::OnBuildStatusMenu(WPARAM,LPARAM)
// TODO: Disable this menu item when offline
// "Send Tweet..."
- CreateProtoService(m_szModuleName,"/Tweet",&TwitterProto::OnTweet,this);
+ CreateService("/Tweet", &TwitterProto::OnTweet);
strcpy(tDest,"/Tweet");
mi.ptszName = LPGENT("Send Tweet...");
mi.popupPosition = 200001;
@@ -346,7 +345,7 @@ int TwitterProto::OnOptionsInit(WPARAM wParam,LPARAM)
return 0;
}
-int TwitterProto::OnTweet(WPARAM,LPARAM)
+INT_PTR TwitterProto::OnTweet(WPARAM,LPARAM)
{
if(m_iStatus != ID_STATUS_ONLINE)
return 1;
@@ -520,12 +519,12 @@ std::tstring TwitterProto::GetAvatarFolder()
return path;
}
-int TwitterProto::GetAvatar(WPARAM,LPARAM)
+INT_PTR TwitterProto::GetAvatar(WPARAM,LPARAM)
{
return 0;
}
-int TwitterProto::SetAvatar(WPARAM,LPARAM)
+INT_PTR TwitterProto::SetAvatar(WPARAM,LPARAM)
{
return 0;
} \ No newline at end of file
diff --git a/protocols/Twitter/src/proto.h b/protocols/Twitter/src/proto.h
index 9287ff3636..84a1b1b439 100644
--- a/protocols/Twitter/src/proto.h
+++ b/protocols/Twitter/src/proto.h
@@ -25,10 +25,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <m_protoint.h>
-class TwitterProto : public PROTO_INTERFACE
+class TwitterProto : public PROTO<TwitterProto>
{
public:
- TwitterProto(const char *,const TCHAR *);
+ TwitterProto(const char*,const TCHAR*);
~TwitterProto();
inline const char * ModuleName() const
@@ -87,25 +87,27 @@ public:
void UpdateSettings();
// Services
- int __cdecl SvcCreateAccMgrUI(WPARAM,LPARAM);
- int __cdecl GetName(WPARAM,LPARAM);
- int __cdecl GetStatus(WPARAM,LPARAM);
- int __cdecl ReplyToTweet(WPARAM,LPARAM);
- int __cdecl VisitHomepage(WPARAM,LPARAM);
- int __cdecl GetAvatar(WPARAM,LPARAM);
- int __cdecl SetAvatar(WPARAM,LPARAM);
+ INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM,LPARAM);
+ INT_PTR __cdecl GetName(WPARAM,LPARAM);
+ INT_PTR __cdecl GetStatus(WPARAM,LPARAM);
+ INT_PTR __cdecl ReplyToTweet(WPARAM,LPARAM);
+ INT_PTR __cdecl VisitHomepage(WPARAM,LPARAM);
+ INT_PTR __cdecl GetAvatar(WPARAM,LPARAM);
+ INT_PTR __cdecl SetAvatar(WPARAM,LPARAM);
+
+ INT_PTR __cdecl OnJoinChat(WPARAM,LPARAM);
+ INT_PTR __cdecl OnLeaveChat(WPARAM,LPARAM);
+
+ INT_PTR __cdecl OnTweet(WPARAM,LPARAM);
// Events
int __cdecl OnContactDeleted(WPARAM,LPARAM);
int __cdecl OnBuildStatusMenu(WPARAM,LPARAM);
int __cdecl OnOptionsInit(WPARAM,LPARAM);
- int __cdecl OnTweet(WPARAM,LPARAM);
int __cdecl OnModulesLoaded(WPARAM,LPARAM);
int __cdecl OnPreShutdown(WPARAM,LPARAM);
int __cdecl OnPrebuildContactMenu(WPARAM,LPARAM);
int __cdecl OnChatOutgoing(WPARAM,LPARAM);
- int __cdecl OnJoinChat(WPARAM,LPARAM);
- int __cdecl OnLeaveChat(WPARAM,LPARAM);
void __cdecl SendTweetWorker(void *);
private:
diff --git a/protocols/Twitter/src/theme.cpp b/protocols/Twitter/src/theme.cpp
index b3f886722a..196905b5aa 100644
--- a/protocols/Twitter/src/theme.cpp
+++ b/protocols/Twitter/src/theme.cpp
@@ -65,7 +65,7 @@ static TwitterProto * GetInstanceByHContact(HANDLE hContact)
return 0;
}
-template<int (__cdecl TwitterProto::*Fcn)(WPARAM,LPARAM)>
+template<INT_PTR (__cdecl TwitterProto::*Fcn)(WPARAM,LPARAM)>
INT_PTR GlobalService(WPARAM wParam,LPARAM lParam)
{
TwitterProto *proto = GetInstanceByHContact(reinterpret_cast<HANDLE>(wParam));
diff --git a/protocols/Twitter/src/ui.cpp b/protocols/Twitter/src/ui.cpp
index 4843d8c6e0..97441b186f 100644
--- a/protocols/Twitter/src/ui.cpp
+++ b/protocols/Twitter/src/ui.cpp
@@ -162,7 +162,7 @@ INT_PTR CALLBACK tweet_proc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
ShowWindow(hwndDlg,SW_HIDE);
char *narrow = mir_t2a_cp(msg,CP_UTF8);
- ForkThread(&TwitterProto::SendTweetWorker, proto,narrow);
+ proto->ForkThread(&TwitterProto::SendTweetWorker, narrow);
EndDialog(hwndDlg, wParam);
return true;
diff --git a/protocols/Twitter/src/utility.h b/protocols/Twitter/src/utility.h
index bc94561274..17aa1cb649 100644
--- a/protocols/Twitter/src/utility.h
+++ b/protocols/Twitter/src/utility.h
@@ -21,35 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "http.h"
#include "twitter.h"
-template<typename T>
-void CreateProtoService(const char *module,const char *service,
- int (__cdecl T::*serviceProc)(WPARAM,LPARAM),T *self)
-{
- char temp[MAX_PATH*2];
-
- mir_snprintf(temp,sizeof(temp),"%s%s",module,service);
- CreateServiceFunctionObj(temp,( MIRANDASERVICEOBJ )*(void**)&serviceProc, self );
-}
-
-template<typename T>
-void HookProtoEvent(const char* evt, int (__cdecl T::*eventProc)(WPARAM,LPARAM), T *self)
-{
- ::HookEventObj(evt,(MIRANDAHOOKOBJ)*(void**)&eventProc,self);
-}
-
-template<typename T>
-HANDLE ForkThreadEx(void (__cdecl T::*thread)(void*),T *self,void *data = 0)
-{
- return reinterpret_cast<HANDLE>( mir_forkthreadowner(
- (pThreadFuncOwner)*(void**)&thread,self,data,0));
-}
-
-template<typename T>
-void ForkThread(void (__cdecl T::*thread)(void*),T *self,void *data = 0)
-{
- CloseHandle(ForkThreadEx(thread,self,data));
-}
-
std::string b64encode(const std::string &s);
class mir_twitter : public twitter