diff options
author | George Hazan <george.hazan@gmail.com> | 2013-07-08 22:10:14 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-07-08 22:10:14 +0000 |
commit | bb952e431866d131bae95c08e579ec8a00f00343 (patch) | |
tree | 60881668cf328b50906346c5f66ce47da2d9ad88 /protocols/FacebookRM/src | |
parent | c181af64bab27eb50e684c64c0a3caa49f8bbe39 (diff) |
core protocol helpers for creating protocol evengs, services & threads
git-svn-id: http://svn.miranda-ng.org/main/trunk@5286 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src')
-rw-r--r-- | protocols/FacebookRM/src/avatars.cpp | 11 | ||||
-rw-r--r-- | protocols/FacebookRM/src/chat.cpp | 6 | ||||
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 29 | ||||
-rw-r--r-- | protocols/FacebookRM/src/connection.cpp | 19 | ||||
-rw-r--r-- | protocols/FacebookRM/src/dialogs.cpp | 6 | ||||
-rw-r--r-- | protocols/FacebookRM/src/events.cpp | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/src/messages.cpp | 6 | ||||
-rw-r--r-- | protocols/FacebookRM/src/process.cpp | 3 | ||||
-rw-r--r-- | protocols/FacebookRM/src/proto.cpp | 72 | ||||
-rw-r--r-- | protocols/FacebookRM/src/proto.h | 42 | ||||
-rw-r--r-- | protocols/FacebookRM/src/theme.cpp | 12 | ||||
-rw-r--r-- | protocols/FacebookRM/src/utils.h | 29 |
12 files changed, 97 insertions, 140 deletions
diff --git a/protocols/FacebookRM/src/avatars.cpp b/protocols/FacebookRM/src/avatars.cpp index 11c812fd0d..77802300f0 100644 --- a/protocols/FacebookRM/src/avatars.cpp +++ b/protocols/FacebookRM/src/avatars.cpp @@ -140,7 +140,7 @@ std::tstring FacebookProto::GetAvatarFolder() return path;
}
-int FacebookProto::GetAvatarCaps(WPARAM wParam, LPARAM lParam)
+INT_PTR FacebookProto::GetAvatarCaps(WPARAM wParam, LPARAM lParam)
{
int res = 0;
@@ -177,7 +177,7 @@ int FacebookProto::GetAvatarCaps(WPARAM wParam, LPARAM lParam) return res;
}
-int FacebookProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam)
+INT_PTR FacebookProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam)
{
if (!lParam)
return GAIR_NOAVATAR;
@@ -203,7 +203,7 @@ int FacebookProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) bool is_empty = avatar_queue.empty();
avatar_queue.push_back(AI->hContact);
if (is_empty)
- ForkThread(&FacebookProto::UpdateAvatarWorker, this, NULL);
+ ForkThread(&FacebookProto::UpdateAvatarWorker, NULL);
}
return GAIR_WAITFOR;
}
@@ -214,7 +214,7 @@ int FacebookProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) return GAIR_NOAVATAR;
}
-int FacebookProto::GetMyAvatar(WPARAM wParam, LPARAM lParam)
+INT_PTR FacebookProto::GetMyAvatar(WPARAM wParam, LPARAM lParam)
{
LOG("***** GetMyAvatar");
@@ -225,8 +225,7 @@ int FacebookProto::GetMyAvatar(WPARAM wParam, LPARAM lParam) int size = (int)lParam;
PROTO_AVATAR_INFORMATIONT ai = {sizeof(ai)};
- switch (GetAvatarInfo(0, (LPARAM)&ai))
- {
+ switch (GetAvatarInfo(0, (LPARAM)&ai)) {
case GAIR_SUCCESS:
_tcsncpy(buf, ai.filename, size);
buf[size-1] = 0;
diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp index 01279a9df9..bd7ad7d553 100644 --- a/protocols/FacebookRM/src/chat.cpp +++ b/protocols/FacebookRM/src/chat.cpp @@ -71,7 +71,7 @@ int FacebookProto::OnChatOutgoing(WPARAM wParam,LPARAM lParam) if (isOnline()) {
LOG("**Chat - Outgoing message: %s", text);
- ForkThread(&FacebookProto::SendChatMsgWorker, this, new send_chat(chat_id, msg));
+ ForkThread(&FacebookProto::SendChatMsgWorker, new send_chat(chat_id, msg));
}
break;
@@ -228,7 +228,7 @@ void FacebookProto::AddChat(const char *id, const char *name) }
*/
-int FacebookProto::OnJoinChat(WPARAM,LPARAM suppress)
+INT_PTR FacebookProto::OnJoinChat(WPARAM,LPARAM suppress)
{
/* GCSESSION gcw = {sizeof(gcw)};
@@ -268,7 +268,7 @@ int FacebookProto::OnJoinChat(WPARAM,LPARAM suppress) return 0;
}
-int FacebookProto::OnLeaveChat(WPARAM,LPARAM)
+INT_PTR FacebookProto::OnLeaveChat(WPARAM,LPARAM)
{
GCDEST gcd = { m_szModuleName };
gcd.ptszID = NULL;
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 619f082a45..2a79fa8e87 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -950,14 +950,10 @@ bool facebook_client::buddy_list() // Process result data
validate_response(&resp);
- switch (resp.code)
- {
+ switch (resp.code) {
case HTTP_CODE_OK:
- {
- std::string* response_data = new std::string(resp.data);
- ForkThread(&FacebookProto::ProcessBuddyList, this->parent, (void*)response_data);
+ parent->ForkThread(&FacebookProto::ProcessBuddyList, new std::string(resp.data));
return handle_success("buddy_list");
- }
case HTTP_CODE_FAKE_ERROR:
case HTTP_CODE_FAKE_DISCONNECTED:
@@ -976,14 +972,11 @@ bool facebook_client::load_friends() // Process result data
validate_response(&resp);
- switch (resp.code)
- {
+ switch (resp.code) {
case HTTP_CODE_OK:
- {
- std::string* response_data = new std::string(resp.data);
- ForkThread(&FacebookProto::ProcessFriendList, this->parent, (void*)response_data);
+ parent->ForkThread(&FacebookProto::ProcessFriendList, new std::string(resp.data));
return handle_success("load_friends");
- }
+
case HTTP_CODE_FAKE_ERROR:
case HTTP_CODE_FAKE_DISCONNECTED:
default:
@@ -1001,13 +994,11 @@ bool facebook_client::feeds() // Process result data
validate_response(&resp);
- switch (resp.code)
- {
+ switch (resp.code) {
case HTTP_CODE_OK:
- if (resp.data.find("\"num_stories\":0") == std::string::npos) {
- std::string* response_data = new std::string(resp.data);
- ForkThread(&FacebookProto::ProcessFeeds, this->parent, (void*)response_data);
- }
+ if (resp.data.find("\"num_stories\":0") == std::string::npos)
+ parent->ForkThread(&FacebookProto::ProcessFeeds, new std::string(resp.data));
+
return handle_success("feeds");
case HTTP_CODE_FAKE_ERROR:
@@ -1062,7 +1053,7 @@ bool facebook_client::channel() } else {
// Something has been received, throw to new thread to process
std::string* response_data = new std::string(resp.data);
- ForkThread(&FacebookProto::ProcessMessages, this->parent, (void*)response_data);
+ parent->ForkThread(&FacebookProto::ProcessMessages, response_data);
// Increment sequence number
this->chat_sequence_num_ = utils::text::source_get_value2(&resp.data, "\"seq\":", ",}");
diff --git a/protocols/FacebookRM/src/connection.cpp b/protocols/FacebookRM/src/connection.cpp index 27908aa019..c1692a6cca 100644 --- a/protocols/FacebookRM/src/connection.cpp +++ b/protocols/FacebookRM/src/connection.cpp @@ -84,23 +84,22 @@ void FacebookProto::ChangeStatus(void*) facy.load_friends();
// Process Friends requests
- ForkThread(&FacebookProto::ProcessFriendRequests, this, NULL);
+ ForkThread(&FacebookProto::ProcessFriendRequests, NULL);
// Get unread messages
- ForkThread(&FacebookProto::ProcessUnreadMessages, this);
+ ForkThread(&FacebookProto::ProcessUnreadMessages, NULL);
// Get notifications
- ForkThread(&FacebookProto::ProcessNotifications, this);
+ ForkThread(&FacebookProto::ProcessNotifications, NULL);
setDword("LogonTS", (DWORD)time(NULL));
- ForkThread(&FacebookProto::UpdateLoop, this);
- ForkThread(&FacebookProto::MessageLoop, this);
+ ForkThread(&FacebookProto::UpdateLoop, NULL);
+ ForkThread(&FacebookProto::MessageLoop, NULL);
if (getByte(FACEBOOK_KEY_SET_MIRANDA_STATUS, DEFAULT_SET_MIRANDA_STATUS))
- {
- ForkThread(&FacebookProto::SetAwayMsgWorker, this, NULL);
- }
- } else {
+ ForkThread(&FacebookProto::SetAwayMsgWorker, NULL);
+ }
+ else {
ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_FAILED, (HANDLE)old_status, m_iStatus);
if (facy.hFcbCon)
@@ -212,7 +211,7 @@ void FacebookProto::UpdateLoop(void *) break;
if (i == 49)
- ForkThread(&FacebookProto::ProcessFriendRequests, this, NULL);
+ ForkThread(&FacebookProto::ProcessFriendRequests, NULL);
LOG("***** FacebookProto::UpdateLoop[%d] going to sleep...", tim);
if (WaitForSingleObjectEx(update_loop_lock_, GetPollRate() * 1000, true) != WAIT_TIMEOUT)
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp index 9d8dfaae53..166c0c3f12 100644 --- a/protocols/FacebookRM/src/dialogs.cpp +++ b/protocols/FacebookRM/src/dialogs.cpp @@ -182,7 +182,7 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara utils::mem::detract(narrow);
//char *narrow = mir_t2a_cp(mindMessage,CP_UTF8);
- ForkThread(&FacebookProto::SetAwayMsgWorker, proto, NULL);
+ proto->ForkThread(&FacebookProto::SetAwayMsgWorker, NULL);
EndDialog(hwnd, wparam);
return TRUE;
@@ -368,9 +368,7 @@ INT_PTR CALLBACK FBOptionsAdvancedProc(HWND hwnd, UINT message, WPARAM wparam, L {
db_set_b(NULL, proto->m_szModuleName, FACEBOOK_KEY_SET_MIRANDA_STATUS, setStatus);
if (setStatus && proto->isOnline())
- {
- ForkThread(&FacebookProto::SetAwayMsgWorker, proto, NULL);
- }
+ proto->ForkThread(&FacebookProto::SetAwayMsgWorker, NULL);
}
return TRUE;
diff --git a/protocols/FacebookRM/src/events.cpp b/protocols/FacebookRM/src/events.cpp index 14596477d7..bbab7df928 100644 --- a/protocols/FacebookRM/src/events.cpp +++ b/protocols/FacebookRM/src/events.cpp @@ -53,7 +53,7 @@ LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa popup_data *data = (popup_data *)PUGetPluginData(hwnd);
if (data != NULL) {
if (!data->notification_id.empty())
- ForkThread(&FacebookProto::ReadNotificationWorker, data->proto, new std::string(data->notification_id));
+ data->proto->ForkThread(&FacebookProto::ReadNotificationWorker, new std::string(data->notification_id));
if (message == WM_COMMAND && !data->url.empty())
data->proto->OpenUrl(data->url);
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp index 1c31312263..d801fefe35 100644 --- a/protocols/FacebookRM/src/messages.cpp +++ b/protocols/FacebookRM/src/messages.cpp @@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. int FacebookProto::RecvMsg(HANDLE hContact, PROTORECVEVENT *pre)
{
- ForkThread(&FacebookProto::ReadMessageWorker, this, hContact);
+ ForkThread(&FacebookProto::ReadMessageWorker, hContact);
CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, (LPARAM)PROTOTYPE_CONTACTTYPING_OFF);
return Proto_RecvMessage(hContact, pre);
@@ -112,14 +112,14 @@ int FacebookProto::SendMsg(HANDLE hContact, int flags, const char *msg) msg = mir_utf8encode(msg);
facy.msgid_ = (facy.msgid_ % 1024)+1;
- ForkThread(&FacebookProto::SendMsgWorker, this, new send_direct(hContact, msg, (HANDLE)facy.msgid_));
+ ForkThread(&FacebookProto::SendMsgWorker, new send_direct(hContact, msg, (HANDLE)facy.msgid_));
return facy.msgid_;
}
int FacebookProto::UserIsTyping(HANDLE hContact,int type)
{
if (hContact && isOnline())
- ForkThread(&FacebookProto::SendTypingWorker, this, new send_typing(hContact, type));
+ ForkThread(&FacebookProto::SendTypingWorker, new send_typing(hContact, type));
return 0;
}
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index ab77ddb50d..fa13cc2b86 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -293,8 +293,7 @@ void FacebookProto::ProcessUnreadMessages(void*) if (tid.empty())
continue;
- std::string* data = new std::string(tid);
- ForkThread(&FacebookProto::ProcessUnreadMessage, this, (void*)data);
+ ForkThread(&FacebookProto::ProcessUnreadMessage, new std::string(tid));
}
page = utils::text::source_get_value(&items, 3, "id=\"see_older_threads\"", "page=", "&");
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index ab0f3a6e3d..7a7e02608b 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -22,10 +22,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "common.h"
-FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username)
+FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) :
+ PROTO<FacebookProto>(proto_name, username)
{
- ProtoConstructor(this, proto_name, username);
-
facy.parent = this;
signon_lock_ = CreateMutex(NULL, FALSE, NULL);
@@ -36,22 +35,22 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) facy.send_message_lock_ = CreateMutex(NULL, FALSE, NULL);
facy.fcb_conn_lock_ = CreateMutex(NULL, FALSE, NULL);
- CreateProtoService(m_szModuleName, PS_CREATEACCMGRUI, &FacebookProto::SvcCreateAccMgrUI, this);
- CreateProtoService(m_szModuleName, PS_GETMYAWAYMSG, &FacebookProto::GetMyAwayMsg, this);
- CreateProtoService(m_szModuleName, PS_GETMYAVATART, &FacebookProto::GetMyAvatar, this);
- CreateProtoService(m_szModuleName, PS_GETAVATARINFOT, &FacebookProto::GetAvatarInfo, this);
- CreateProtoService(m_szModuleName, PS_GETAVATARCAPS, &FacebookProto::GetAvatarCaps, this);
+ CreateService(PS_CREATEACCMGRUI, &FacebookProto::SvcCreateAccMgrUI);
+ CreateService(PS_GETMYAWAYMSG, &FacebookProto::GetMyAwayMsg);
+ CreateService(PS_GETMYAVATART, &FacebookProto::GetMyAvatar);
+ CreateService(PS_GETAVATARINFOT, &FacebookProto::GetAvatarInfo);
+ CreateService(PS_GETAVATARCAPS, &FacebookProto::GetAvatarCaps);
- CreateProtoService(m_szModuleName, PS_JOINCHAT, &FacebookProto::OnJoinChat, this);
- CreateProtoService(m_szModuleName, PS_LEAVECHAT, &FacebookProto::OnLeaveChat, this);
+ CreateService(PS_JOINCHAT, &FacebookProto::OnJoinChat);
+ CreateService(PS_LEAVECHAT, &FacebookProto::OnLeaveChat);
- CreateProtoService(m_szModuleName, "/Mind", &FacebookProto::OnMind, this);
+ CreateService("/Mind", &FacebookProto::OnMind);
- HookProtoEvent(ME_CLIST_PREBUILDSTATUSMENU, &FacebookProto::OnBuildStatusMenu, this);
- HookProtoEvent(ME_OPT_INITIALISE, &FacebookProto::OnOptionsInit, this);
- HookProtoEvent(ME_GC_EVENT, &FacebookProto::OnChatOutgoing, this);
- HookProtoEvent(ME_IDLE_CHANGED, &FacebookProto::OnIdleChanged, this);
- HookProtoEvent(ME_TTB_MODULELOADED, &FacebookProto::OnToolbarInit, this);
+ HookEvent(ME_CLIST_PREBUILDSTATUSMENU, &FacebookProto::OnBuildStatusMenu);
+ HookEvent(ME_OPT_INITIALISE, &FacebookProto::OnOptionsInit);
+ HookEvent(ME_GC_EVENT, &FacebookProto::OnChatOutgoing);
+ HookEvent(ME_IDLE_CHANGED, &FacebookProto::OnIdleChanged);
+ HookEvent(ME_TTB_MODULELOADED, &FacebookProto::OnToolbarInit);
char module[512];
mir_snprintf(module, sizeof(module), "%s/Mind", m_szModuleName);
@@ -201,7 +200,7 @@ int FacebookProto::SetAwayMsg(int status, const PROTOCHAR *msg) utils::mem::detract(narrow);
if (isOnline() && getByte(FACEBOOK_KEY_SET_MIRANDA_STATUS, DEFAULT_SET_MIRANDA_STATUS))
- ForkThread(&FacebookProto::SetAwayMsgWorker, this, NULL);
+ ForkThread(&FacebookProto::SetAwayMsgWorker, NULL);
return 0;
}
@@ -218,8 +217,7 @@ HANDLE FacebookProto::SearchBasic(const PROTOCHAR* id) return 0;
TCHAR* email = mir_tstrdup(id);
- ForkThread(&FacebookProto::SearchAckThread, this, (void*)email);
-
+ ForkThread(&FacebookProto::SearchAckThread, email);
return email;
}
@@ -303,7 +301,7 @@ int FacebookProto::AuthDeny(HANDLE hDbEvent, const PROTOCHAR *reason) //////////////////////////////////////////////////////////////////////////////
// SERVICES
-int FacebookProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam)
+INT_PTR FacebookProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam)
{
DBVARIANT dbv = { DBVT_TCHAR };
if (!getTString("StatusMsg", &dbv) && lstrlen(dbv.ptszVal) != 0)
@@ -363,7 +361,7 @@ int FacebookProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam) //////////////////////////////////////////////////////////////////////////////
// EVENTS
-int FacebookProto::SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam)
+INT_PTR FacebookProto::SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam)
{
return (int)CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_FACEBOOKACCOUNT),
(HWND)lParam, FBAccountProc, (LPARAM)this);
@@ -438,7 +436,7 @@ int FacebookProto::OnToolbarInit(WPARAM, LPARAM) return 0;
}
-int FacebookProto::OnMind(WPARAM, LPARAM)
+INT_PTR FacebookProto::OnMind(WPARAM, LPARAM)
{
if (isOnline()) {
HWND hDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_MIND), (HWND)0, FBMindProc, reinterpret_cast<LPARAM>(this));
@@ -448,7 +446,7 @@ int FacebookProto::OnMind(WPARAM, LPARAM) return 0;
}
-int FacebookProto::CheckNewsfeeds(WPARAM, LPARAM)
+INT_PTR FacebookProto::CheckNewsfeeds(WPARAM, LPARAM)
{
if (!isOffline()) {
facy.client_notify(TranslateT("Loading newsfeeds..."));
@@ -457,7 +455,7 @@ int FacebookProto::CheckNewsfeeds(WPARAM, LPARAM) return 0;
}
-int FacebookProto::CheckFriendRequests(WPARAM, LPARAM)
+INT_PTR FacebookProto::CheckFriendRequests(WPARAM, LPARAM)
{
if (!isOffline()) {
facy.client_notify(TranslateT("Checking friend requests..."));
@@ -466,7 +464,7 @@ int FacebookProto::CheckFriendRequests(WPARAM, LPARAM) return 0;
}
-int FacebookProto::RefreshBuddyList(WPARAM, LPARAM)
+INT_PTR FacebookProto::RefreshBuddyList(WPARAM, LPARAM)
{
if (!isOffline()) {
facy.client_notify(TranslateT("Refreshing buddy list..."));
@@ -476,7 +474,7 @@ int FacebookProto::RefreshBuddyList(WPARAM, LPARAM) }
-int FacebookProto::VisitProfile(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::VisitProfile(WPARAM wParam,LPARAM lParam)
{
HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
@@ -501,7 +499,7 @@ int FacebookProto::VisitProfile(WPARAM wParam,LPARAM lParam) return 0;
}
-int FacebookProto::VisitFriendship(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::VisitFriendship(WPARAM wParam,LPARAM lParam)
{
HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
@@ -518,7 +516,7 @@ int FacebookProto::VisitFriendship(WPARAM wParam,LPARAM lParam) return 0;
}
-int FacebookProto::Poke(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::Poke(WPARAM wParam,LPARAM lParam)
{
if (wParam == NULL || isOffline())
return 1;
@@ -529,11 +527,11 @@ int FacebookProto::Poke(WPARAM wParam,LPARAM lParam) if (id == NULL)
return 1;
- ForkThread(&FacebookProto::SendPokeWorker, this, new std::string(id));
+ ForkThread(&FacebookProto::SendPokeWorker, new std::string(id));
return 0;
}
-int FacebookProto::CancelFriendship(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::CancelFriendship(WPARAM wParam,LPARAM lParam)
{
if (wParam == NULL || isOffline())
return 1;
@@ -567,13 +565,13 @@ int FacebookProto::CancelFriendship(WPARAM wParam,LPARAM lParam) fbu->handle = NULL;
}
- ForkThread(&FacebookProto::DeleteContactFromServer, this, (void*)val);
+ ForkThread(&FacebookProto::DeleteContactFromServer, val);
}
return 0;
}
-int FacebookProto::RequestFriendship(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::RequestFriendship(WPARAM wParam,LPARAM lParam)
{
if (wParam == NULL || isOffline())
return 1;
@@ -584,29 +582,29 @@ int FacebookProto::RequestFriendship(WPARAM wParam,LPARAM lParam) if (id == NULL)
return 1;
- ForkThread(&FacebookProto::AddContactToServer, this, new std::string(id));
+ ForkThread(&FacebookProto::AddContactToServer, new std::string(id));
return 0;
}
-int FacebookProto::ApproveFriendship(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::ApproveFriendship(WPARAM wParam,LPARAM lParam)
{
if (wParam == NULL || isOffline())
return 1;
HANDLE *hContact = new HANDLE(reinterpret_cast<HANDLE>(wParam));
- ForkThread(&FacebookProto::ApproveContactToServer, this, (void*)hContact);
+ ForkThread(&FacebookProto::ApproveContactToServer, hContact);
return 0;
}
-int FacebookProto::OnCancelFriendshipRequest(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::OnCancelFriendshipRequest(WPARAM wParam,LPARAM lParam)
{
if (wParam == NULL || isOffline())
return 1;
HANDLE *hContact = new HANDLE(reinterpret_cast<HANDLE>(wParam));
- ForkThread(&FacebookProto::CancelFriendsRequest, this, (void*)hContact);
+ ForkThread(&FacebookProto::CancelFriendsRequest, hContact);
return 0;
}
diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h index 1fe140a966..e36af93199 100644 --- a/protocols/FacebookRM/src/proto.h +++ b/protocols/FacebookRM/src/proto.h @@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #pragma once
-class FacebookProto : public PROTO_INTERFACE
+class FacebookProto : public PROTO<FacebookProto>
{
public:
FacebookProto(const char *proto_name, const TCHAR *username);
@@ -101,22 +101,27 @@ public: ////////////////////////
// Services
- int __cdecl GetMyAwayMsg(WPARAM, LPARAM);
- int __cdecl SetMyAwayMsg(WPARAM, LPARAM);
- int __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM);
- int __cdecl GetMyAvatar(WPARAM, LPARAM);
- int __cdecl GetAvatarInfo(WPARAM, LPARAM);
- int __cdecl GetAvatarCaps(WPARAM, LPARAM);
- int __cdecl VisitProfile(WPARAM, LPARAM);
- int __cdecl VisitFriendship(WPARAM, LPARAM);
- int __cdecl Poke(WPARAM, LPARAM);
- int __cdecl CancelFriendship(WPARAM, LPARAM);
- int __cdecl RequestFriendship(WPARAM, LPARAM);
- int __cdecl ApproveFriendship(WPARAM, LPARAM);
- int __cdecl OnCancelFriendshipRequest(WPARAM, LPARAM);
- int __cdecl CheckNewsfeeds(WPARAM, LPARAM);
- int __cdecl CheckFriendRequests(WPARAM, LPARAM);
- int __cdecl RefreshBuddyList(WPARAM, LPARAM);
+ INT_PTR __cdecl GetMyAwayMsg(WPARAM, LPARAM);
+ INT_PTR __cdecl SetMyAwayMsg(WPARAM, LPARAM);
+ INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM);
+ INT_PTR __cdecl GetMyAvatar(WPARAM, LPARAM);
+ INT_PTR __cdecl GetAvatarInfo(WPARAM, LPARAM);
+ INT_PTR __cdecl GetAvatarCaps(WPARAM, LPARAM);
+ INT_PTR __cdecl VisitProfile(WPARAM, LPARAM);
+ INT_PTR __cdecl VisitFriendship(WPARAM, LPARAM);
+ INT_PTR __cdecl Poke(WPARAM, LPARAM);
+ INT_PTR __cdecl CancelFriendship(WPARAM, LPARAM);
+ INT_PTR __cdecl RequestFriendship(WPARAM, LPARAM);
+ INT_PTR __cdecl ApproveFriendship(WPARAM, LPARAM);
+ INT_PTR __cdecl OnCancelFriendshipRequest(WPARAM, LPARAM);
+ INT_PTR __cdecl CheckNewsfeeds(WPARAM, LPARAM);
+ INT_PTR __cdecl CheckFriendRequests(WPARAM, LPARAM);
+ INT_PTR __cdecl RefreshBuddyList(WPARAM, LPARAM);
+
+ INT_PTR __cdecl OnJoinChat(WPARAM,LPARAM);
+ INT_PTR __cdecl OnLeaveChat(WPARAM,LPARAM);
+
+ INT_PTR __cdecl OnMind(WPARAM,LPARAM);
// Events
int __cdecl OnModulesLoaded(WPARAM, LPARAM);
@@ -124,13 +129,10 @@ public: int __cdecl OnToolbarInit(WPARAM, LPARAM);
int __cdecl OnBuildStatusMenu(WPARAM,LPARAM);
int __cdecl OnContactDeleted(WPARAM,LPARAM);
- int __cdecl OnMind(WPARAM,LPARAM);
int __cdecl OnPreShutdown(WPARAM,LPARAM);
int __cdecl OnPrebuildContactMenu(WPARAM,LPARAM);
int __cdecl OnIdleChanged(WPARAM,LPARAM);
int __cdecl OnChatOutgoing(WPARAM,LPARAM);
- int __cdecl OnJoinChat(WPARAM,LPARAM);
- int __cdecl OnLeaveChat(WPARAM,LPARAM);
// Loops
bool NegotiateConnection();
diff --git a/protocols/FacebookRM/src/theme.cpp b/protocols/FacebookRM/src/theme.cpp index f01dcd616e..c67474a25a 100644 --- a/protocols/FacebookRM/src/theme.cpp +++ b/protocols/FacebookRM/src/theme.cpp @@ -66,7 +66,7 @@ static FacebookProto * GetInstanceByHContact(HANDLE hContact) return 0;
}
-template<int (__cdecl FacebookProto::*Fcn)(WPARAM,LPARAM)>
+template<INT_PTR (__cdecl FacebookProto::*Fcn)(WPARAM,LPARAM)>
INT_PTR GlobalService(WPARAM wParam,LPARAM lParam)
{
FacebookProto *proto = GetInstanceByHContact(reinterpret_cast<HANDLE>(wParam));
@@ -193,14 +193,14 @@ int FacebookProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam) mi.flags = CMIF_CHILDPOPUP | (this->isOnline() ? 0 : CMIF_GRAYED);
mi.position = 201001;
- //CreateProtoService(m_szModuleName,"/Mind",&FacebookProto::OnMind,this);
+ //CreateService(m_szModuleName,"/Mind",&FacebookProto::OnMind,this);
strcpy(tDest,"/Mind");
mi.hParentMenu = hRoot;
mi.pszName = LPGEN("Mind...");
mi.icolibItem = GetIconHandle("mind");
m_hStatusMind = Menu_AddProtoMenuItem(&mi);
- CreateProtoService(m_szModuleName,"/VisitProfile",&FacebookProto::VisitProfile,this);
+ CreateService("/VisitProfile",&FacebookProto::VisitProfile);
strcpy(tDest,"/VisitProfile");
mi.flags = CMIF_CHILDPOPUP;
mi.pszName = LPGEN("Visit profile");
@@ -215,7 +215,7 @@ int FacebookProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam) mi.icolibItem = NULL;
m_hMenuServicesRoot = Menu_AddProtoMenuItem(&mi);
- CreateProtoService(m_szModuleName,"/RefreshBuddyList",&FacebookProto::RefreshBuddyList,this);
+ CreateService("/RefreshBuddyList",&FacebookProto::RefreshBuddyList);
strcpy(tDest,"/RefreshBuddyList");
mi.flags = CMIF_ROOTHANDLE;
mi.pszName = LPGEN("Refresh Buddy List");
@@ -224,7 +224,7 @@ int FacebookProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam) mi.hParentMenu = m_hMenuServicesRoot;
Menu_AddProtoMenuItem(&mi);
- CreateProtoService(m_szModuleName,"/CheckFriendRequests",&FacebookProto::CheckFriendRequests,this);
+ CreateService("/CheckFriendRequests",&FacebookProto::CheckFriendRequests);
strcpy(tDest,"/CheckFriendRequests");
mi.flags = CMIF_ROOTHANDLE;
mi.pszName = LPGEN("Check Friends Requests");
@@ -232,7 +232,7 @@ int FacebookProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam) mi.hParentMenu = m_hMenuServicesRoot;
Menu_AddProtoMenuItem(&mi);
- CreateProtoService(m_szModuleName,"/CheckNewsfeeds",&FacebookProto::CheckNewsfeeds,this);
+ CreateService("/CheckNewsfeeds",&FacebookProto::CheckNewsfeeds);
strcpy(tDest,"/CheckNewsfeeds");
mi.flags = CMIF_ROOTHANDLE;
mi.pszName = LPGEN("Check Newsfeeds");
diff --git a/protocols/FacebookRM/src/utils.h b/protocols/FacebookRM/src/utils.h index eef3907004..c0c8e680d3 100644 --- a/protocols/FacebookRM/src/utils.h +++ b/protocols/FacebookRM/src/utils.h @@ -31,35 +31,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. // miscellaneous
#define UTILS_CONV_TIME_T 0x0040 // 1234567890
-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));
-}
-
namespace utils
{
namespace url
|