summaryrefslogtreecommitdiff
path: root/protocols/AimOscar/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-07-08 22:10:14 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-07-08 22:10:14 +0000
commitbb952e431866d131bae95c08e579ec8a00f00343 (patch)
tree60881668cf328b50906346c5f66ce47da2d9ad88 /protocols/AimOscar/src
parentc181af64bab27eb50e684c64c0a3caa49f8bbe39 (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/AimOscar/src')
-rw-r--r--protocols/AimOscar/src/chat.cpp4
-rw-r--r--protocols/AimOscar/src/proto.cpp38
-rw-r--r--protocols/AimOscar/src/proto.h14
-rw-r--r--protocols/AimOscar/src/theme.cpp14
-rw-r--r--protocols/AimOscar/src/utility.cpp21
5 files changed, 29 insertions, 62 deletions
diff --git a/protocols/AimOscar/src/chat.cpp b/protocols/AimOscar/src/chat.cpp
index 1c9f329486..033643f915 100644
--- a/protocols/AimOscar/src/chat.cpp
+++ b/protocols/AimOscar/src/chat.cpp
@@ -31,8 +31,8 @@ void CAimProto::chat_register(void)
gcr.pszModule = m_szModuleName;
CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr);
- HookProtoEvent(ME_GC_EVENT, &CAimProto::OnGCEvent);
- HookProtoEvent(ME_GC_BUILDMENU, &CAimProto::OnGCMenuHook );
+ HookEvent(ME_GC_EVENT, &CAimProto::OnGCEvent);
+ HookEvent(ME_GC_BUILDMENU, &CAimProto::OnGCMenuHook );
}
void CAimProto::chat_start(const char* id, unsigned short exchange)
diff --git a/protocols/AimOscar/src/proto.cpp b/protocols/AimOscar/src/proto.cpp
index 6f9815a8a7..2d13a60e8b 100644
--- a/protocols/AimOscar/src/proto.cpp
+++ b/protocols/AimOscar/src/proto.cpp
@@ -17,35 +17,35 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "aim.h"
-CAimProto::CAimProto(const char* aProtoName, const TCHAR* aUserName)
- : chat_rooms(5)
+CAimProto::CAimProto(const char* aProtoName, const TCHAR* aUserName) :
+ PROTO<CAimProto>(aProtoName, aUserName),
+ chat_rooms(5)
{
- ProtoConstructor(this, aProtoName, aUserName);
LOG("Setting protocol/module name to '%s'", m_szModuleName);
//create some events
hAvatarEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
hChatNavEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
- hAdminEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ hAdminEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
InitializeCriticalSection(&SendingMutex);
InitializeCriticalSection(&connMutex);
- CreateProtoService(PS_CREATEACCMGRUI, &CAimProto::SvcCreateAccMgrUI);
+ CreateService(PS_CREATEACCMGRUI, &CAimProto::SvcCreateAccMgrUI);
- CreateProtoService(PS_GETMYAWAYMSG, &CAimProto::GetMyAwayMsg);
+ CreateService(PS_GETMYAWAYMSG, &CAimProto::GetMyAwayMsg);
- CreateProtoService(PS_GETAVATARINFOT, &CAimProto::GetAvatarInfo);
- CreateProtoService(PS_GETMYAVATART, &CAimProto::GetAvatar);
- CreateProtoService(PS_SETMYAVATART, &CAimProto::SetAvatar);
- CreateProtoService(PS_GETAVATARCAPS, &CAimProto::GetAvatarCaps);
+ CreateService(PS_GETAVATARINFOT, &CAimProto::GetAvatarInfo);
+ CreateService(PS_GETMYAVATART, &CAimProto::GetAvatar);
+ CreateService(PS_SETMYAVATART, &CAimProto::SetAvatar);
+ CreateService(PS_GETAVATARCAPS, &CAimProto::GetAvatarCaps);
- CreateProtoService(PS_JOINCHAT, &CAimProto::OnJoinChat);
- CreateProtoService(PS_LEAVECHAT, &CAimProto::OnLeaveChat);
+ CreateService(PS_JOINCHAT, &CAimProto::OnJoinChat);
+ CreateService(PS_LEAVECHAT, &CAimProto::OnLeaveChat);
- HookProtoEvent(ME_CLIST_PREBUILDCONTACTMENU, &CAimProto::OnPreBuildContactMenu);
- HookProtoEvent(ME_CLIST_GROUPCHANGE, &CAimProto::OnGroupChange);
- HookProtoEvent(ME_OPT_INITIALISE, &CAimProto::OnOptionsInit);
+ HookEvent(ME_CLIST_PREBUILDCONTACTMENU, &CAimProto::OnPreBuildContactMenu);
+ HookEvent(ME_CLIST_GROUPCHANGE, &CAimProto::OnGroupChange);
+ HookEvent(ME_OPT_INITIALISE, &CAimProto::OnOptionsInit);
init_custom_folders();
offline_contacts();
@@ -109,8 +109,6 @@ CAimProto::~CAimProto()
mir_free(CHATNAV_COOKIE);
mir_free(ADMIN_COOKIE);
mir_free(username);
-
- ProtoDestructor(this);
}
////////////////////////////////////////////////////////////////////////////////////////
@@ -118,9 +116,9 @@ CAimProto::~CAimProto()
int CAimProto::OnModulesLoaded(WPARAM wParam, LPARAM lParam)
{
- HookProtoEvent(ME_USERINFO_INITIALISE, &CAimProto::OnUserInfoInit);
- HookProtoEvent(ME_IDLE_CHANGED, &CAimProto::OnIdleChanged);
- HookProtoEvent(ME_MSG_WINDOWEVENT, &CAimProto::OnWindowEvent);
+ HookEvent(ME_USERINFO_INITIALISE, &CAimProto::OnUserInfoInit);
+ HookEvent(ME_IDLE_CHANGED, &CAimProto::OnIdleChanged);
+ HookEvent(ME_MSG_WINDOWEVENT, &CAimProto::OnWindowEvent);
chat_register();
InitContactMenus();
diff --git a/protocols/AimOscar/src/proto.h b/protocols/AimOscar/src/proto.h
index 5c8aa0bde9..3cb22c28d2 100644
--- a/protocols/AimOscar/src/proto.h
+++ b/protocols/AimOscar/src/proto.h
@@ -19,15 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef _AIM_PROTO_H_
#define _AIM_PROTO_H_
-struct CAimProto;
-typedef void ( __cdecl CAimProto::*AimThreadFunc )( void* );
-typedef int ( __cdecl CAimProto::*AimEventFunc )( WPARAM, LPARAM );
-typedef INT_PTR ( __cdecl CAimProto::*AimServiceFunc )( WPARAM, LPARAM );
-typedef INT_PTR ( __cdecl CAimProto::*AimServiceFuncParam )( WPARAM, LPARAM, LPARAM );
-
-struct CAimProto : public PROTO_INTERFACE
+struct CAimProto : public PROTO<CAimProto>
{
- CAimProto( const char*, const TCHAR* );
+ CAimProto(const char*, const TCHAR*);
~CAimProto();
//====================================================================================
@@ -461,10 +455,6 @@ struct CAimProto : public PROTO_INTERFACE
//////////////////////////////////////////////////////////////////////////////////////
HANDLE CreateProtoEvent(const char* szEvent);
- void CreateProtoService(const char* szService, AimServiceFunc serviceProc);
- void CreateProtoServiceParam(const char* szService, AimServiceFuncParam serviceProc, LPARAM lParam);
- void HookProtoEvent(const char* szEvent, AimEventFunc pFunc);
- void ForkThread(AimThreadFunc, void*);
int deleteSetting(HANDLE hContact, const char* setting);
diff --git a/protocols/AimOscar/src/theme.cpp b/protocols/AimOscar/src/theme.cpp
index 5f595d2cc6..02e1f652bd 100644
--- a/protocols/AimOscar/src/theme.cpp
+++ b/protocols/AimOscar/src/theme.cpp
@@ -270,21 +270,21 @@ void CAimProto::InitMainMenus(void)
mi.flags = CMIF_CHILDPOPUP;
mir_snprintf(service_name, sizeof(service_name), "%s%s", m_szModuleName, "/ManageAccount");
- CreateProtoService("/ManageAccount", &CAimProto::ManageAccount);
+ CreateService("/ManageAccount", &CAimProto::ManageAccount);
mi.position = 201001;
mi.icolibItem = GetIconHandle("aim");
mi.pszName = LPGEN("Manage Account");
hMainMenu[0] = Menu_AddProtoMenuItem(&mi);
mir_snprintf(service_name, sizeof(service_name), "%s%s", m_szModuleName, "/InstantIdle");
- CreateProtoService("/InstantIdle",&CAimProto::InstantIdle);
+ CreateService("/InstantIdle",&CAimProto::InstantIdle);
mi.position = 201002;
mi.icolibItem = GetIconHandle("idle");
mi.pszName = LPGEN("Instant Idle");
hMainMenu[1] = Menu_AddProtoMenuItem(&mi);
mir_snprintf(service_name, sizeof(service_name), "%s%s", m_szModuleName, "/JoinChatRoom");
- CreateProtoService("/JoinChatRoom", &CAimProto::JoinChatUI);
+ CreateService("/JoinChatRoom", &CAimProto::JoinChatUI);
mi.position = 201003;
mi.icolibItem = GetIconHandle("aol");
mi.pszName = LPGEN( "Join Chat Room" );
@@ -301,7 +301,7 @@ void CAimProto::InitContactMenus(void)
mi.pszContactOwner = m_szModuleName;
mir_snprintf(service_name, sizeof(service_name), "%s%s", m_szModuleName, "/GetHTMLAwayMsg");
- CreateProtoService("/GetHTMLAwayMsg",&CAimProto::GetHTMLAwayMsg);
+ CreateService("/GetHTMLAwayMsg",&CAimProto::GetHTMLAwayMsg);
mi.position = -2000006000;
mi.icolibItem = GetIconHandle("away");
mi.pszName = LPGEN("Read &HTML Away Message");
@@ -309,7 +309,7 @@ void CAimProto::InitContactMenus(void)
hHTMLAwayContextMenuItem = Menu_AddContactMenuItem(&mi);
mir_snprintf(service_name, sizeof(service_name), "%s%s", m_szModuleName, "/GetProfile");
- CreateProtoService("/GetProfile", &CAimProto::GetProfile);
+ CreateService("/GetProfile", &CAimProto::GetProfile);
mi.position = -2000005090;
mi.icolibItem = GetIconHandle("profile");
mi.pszName = LPGEN("Read Profile");
@@ -317,7 +317,7 @@ void CAimProto::InitContactMenus(void)
hReadProfileMenuItem = Menu_AddContactMenuItem(&mi);
mir_snprintf(service_name, sizeof(service_name), "%s%s", m_szModuleName, "/AddToServerList");
- CreateProtoService("/AddToServerList", &CAimProto::AddToServerList);
+ CreateService("/AddToServerList", &CAimProto::AddToServerList);
mi.position = -2000005080;
mi.icolibItem = GetIconHandle("add");
mi.pszName = LPGEN("Add To Server List");
@@ -325,7 +325,7 @@ void CAimProto::InitContactMenus(void)
hAddToServerListContextMenuItem = Menu_AddContactMenuItem(&mi);
mir_snprintf(service_name, sizeof(service_name), "%s%s", m_szModuleName, "/BlockCommand");
- CreateProtoService("/BlockCommand", &CAimProto::BlockBuddy);
+ CreateService("/BlockCommand", &CAimProto::BlockBuddy);
mi.position = -2000005060;
mi.icolibItem = GetIconHandle("block");
mi.pszName = LPGEN("&Block");
diff --git a/protocols/AimOscar/src/utility.cpp b/protocols/AimOscar/src/utility.cpp
index f43e88aa63..be6ac0b388 100644
--- a/protocols/AimOscar/src/utility.cpp
+++ b/protocols/AimOscar/src/utility.cpp
@@ -804,24 +804,3 @@ void CAimProto::setWord(const char* name, WORD value)
void CAimProto::setWord(HANDLE hContact, const char* name, WORD value)
{ db_set_w(hContact, m_szModuleName, name, value);
}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-void CAimProto::CreateProtoService(const char* szService, AimServiceFunc serviceProc)
-{
- char temp[MAX_PATH*2];
-
- mir_snprintf(temp, sizeof(temp), "%s%s", m_szModuleName, szService);
- CreateServiceFunctionObj(temp, (MIRANDASERVICEOBJ)*(void**)&serviceProc, this);
-}
-
-void CAimProto::HookProtoEvent(const char* szEvent, AimEventFunc pFunc)
-{
- ::HookEventObj(szEvent, (MIRANDAHOOKOBJ)*(void**)&pFunc, this);
-}
-
-void CAimProto::ForkThread(AimThreadFunc pFunc, void* param)
-{
- UINT threadID;
- CloseHandle((HANDLE)mir_forkthreadowner((pThreadFuncOwner)*(void**)&pFunc, this, param, &threadID));
-}