summaryrefslogtreecommitdiff
path: root/protocols/Skype
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/Skype
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/Skype')
-rw-r--r--protocols/Skype/src/skype_hooks.cpp5
-rw-r--r--protocols/Skype/src/skype_menus.cpp4
-rw-r--r--protocols/Skype/src/skype_proto.cpp5
-rw-r--r--protocols/Skype/src/skype_proto.h15
-rw-r--r--protocols/Skype/src/skype_services.cpp18
-rw-r--r--protocols/Skype/src/skype_utils.cpp44
6 files changed, 14 insertions, 77 deletions
diff --git a/protocols/Skype/src/skype_hooks.cpp b/protocols/Skype/src/skype_hooks.cpp
index a1184cc325..9e8f189863 100644
--- a/protocols/Skype/src/skype_hooks.cpp
+++ b/protocols/Skype/src/skype_hooks.cpp
@@ -6,11 +6,6 @@ void CSkypeProto::InitHookList()
::HookEvent(ME_CLIST_PREBUILDCONTACTMENU, &CSkypeProto::PrebuildContactMenu);
}
-HANDLE CSkypeProto::HookEvent(const char* szEvent, SkypeEventFunc handler)
-{
- return ::HookEventObj(szEvent, (MIRANDAHOOKOBJ)*( void**)&handler, this);
-}
-
void CSkypeProto::InitInstanceHookList()
{
this->HookEvent(ME_OPT_INITIALISE, &CSkypeProto::OnOptionsInit);
diff --git a/protocols/Skype/src/skype_menus.cpp b/protocols/Skype/src/skype_menus.cpp
index d1ca420913..e9d5846fd6 100644
--- a/protocols/Skype/src/skype_menus.cpp
+++ b/protocols/Skype/src/skype_menus.cpp
@@ -256,7 +256,7 @@ void CSkypeProto::OnInitStatusMenu()
// Invite Command
::strcpy(tDest, "/CreateChatRoom");
- this->CreateServiceObj(tDest, &CSkypeProto::CreateChatRoomCommand);
+ this->CreateService(tDest, &CSkypeProto::CreateChatRoomCommand);
mi.ptszName = LPGENT("Create conference");
mi.position = 200000 + SMI_CHAT_CREATE;
mi.icolibItem = CSkypeProto::GetSkinIconHandle("conference");
@@ -264,7 +264,7 @@ void CSkypeProto::OnInitStatusMenu()
// Invite Command
::strcpy(tDest, "/BlockedeList");
- this->CreateServiceObj(tDest, &CSkypeProto::OpenBlockedListCommand);
+ this->CreateService(tDest, &CSkypeProto::OpenBlockedListCommand);
mi.ptszName = LPGENT("Blocked contacts");
mi.position = 200000 + SMI_IGNORE_LIST;
mi.icolibItem = CSkypeProto::GetSkinIconHandle("block");
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp
index 5bb995029d..746e72a473 100644
--- a/protocols/Skype/src/skype_proto.cpp
+++ b/protocols/Skype/src/skype_proto.cpp
@@ -1,11 +1,10 @@
#include "skype.h"
-CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName) :
+CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName) :
+ PROTO<CSkypeProto>(protoName, userName),
Skype(1),
skypeKitPort(8963)
{
- ::ProtoConstructor(this, protoName, userName);
-
this->rememberPassword = false;
::InitializeCriticalSection(&this->contact_search_lock);
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h
index 8629f5b63f..c576d68bbe 100644
--- a/protocols/Skype/src/skype_proto.h
+++ b/protocols/Skype/src/skype_proto.h
@@ -1,10 +1,5 @@
#pragma once
-typedef void (__cdecl CSkypeProto::* SkypeThreadFunc) (void*);
-typedef int (__cdecl CSkypeProto::* SkypeEventFunc)(WPARAM, LPARAM);
-typedef INT_PTR (__cdecl CSkypeProto::* SkypeServiceFunc)(WPARAM, LPARAM);
-typedef INT_PTR (__cdecl CSkypeProto::* SkypeServiceFuncParam)(WPARAM, LPARAM, LPARAM);
-
struct _tag_iconList
{
wchar_t* Description;
@@ -127,7 +122,7 @@ struct PasswordChangeBoxParam
class ChatMember;
class ChatRoom;
-struct CSkypeProto : public PROTO_INTERFACE, private Skype
+struct CSkypeProto : public PROTO<CSkypeProto>, private Skype
{
friend class ChatRoom;
friend class CAccount;
@@ -445,14 +440,8 @@ protected:
int SendBroadcast(int type, int result, HANDLE hProcess, LPARAM lParam);
int SendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam);
- void CreateServiceObj(const char* szService, SkypeServiceFunc serviceProc);
- void CreateServiceObjParam(const char* szService, SkypeServiceFunc serviceProc, LPARAM lParam);
-
HANDLE CreateEvent(const char* szService);
- void ForkThread(SkypeThreadFunc, void*);
- HANDLE ForkThreadEx(SkypeThreadFunc, void*, UINT* threadID = NULL);
-
// netlib
HANDLE hNetLibUser;
@@ -465,8 +454,6 @@ protected:
void InitInstanceServiceList();
// hooks
- HANDLE HookEvent(const char*, SkypeEventFunc);
-
void InitInstanceHookList();
// icons
diff --git a/protocols/Skype/src/skype_services.cpp b/protocols/Skype/src/skype_services.cpp
index 01e598727e..e6bdf123c0 100644
--- a/protocols/Skype/src/skype_services.cpp
+++ b/protocols/Skype/src/skype_services.cpp
@@ -9,17 +9,17 @@ void CSkypeProto::InitServiceList()
void CSkypeProto::InitInstanceServiceList()
{
// Message API
- this->CreateServiceObj(PS_CREATEACCMGRUI, &CSkypeProto::OnAccountManagerInit);
+ this->CreateService(PS_CREATEACCMGRUI, &CSkypeProto::OnAccountManagerInit);
// Chat API
- this->CreateServiceObj(PS_JOINCHAT, &CSkypeProto::OnJoinChat);
- this->CreateServiceObj(PS_LEAVECHAT, &CSkypeProto::OnLeaveChat);
+ this->CreateService(PS_JOINCHAT, &CSkypeProto::OnJoinChat);
+ this->CreateService(PS_LEAVECHAT, &CSkypeProto::OnLeaveChat);
// Own info
- this->CreateServiceObj(PS_SETMYNICKNAME, &CSkypeProto::SetMyNickName);
+ this->CreateService(PS_SETMYNICKNAME, &CSkypeProto::SetMyNickName);
// Avatar API
- this->CreateServiceObj(PS_GETAVATARINFOT, &CSkypeProto::GetAvatarInfo);
- this->CreateServiceObj(PS_GETAVATARCAPS, &CSkypeProto::GetAvatarCaps);
- this->CreateServiceObj(PS_GETMYAVATART, &CSkypeProto::GetMyAvatar);
- this->CreateServiceObj(PS_SETMYAVATART, &CSkypeProto::SetMyAvatar);
+ this->CreateService(PS_GETAVATARINFOT, &CSkypeProto::GetAvatarInfo);
+ this->CreateService(PS_GETAVATARCAPS, &CSkypeProto::GetAvatarCaps);
+ this->CreateService(PS_GETMYAVATART, &CSkypeProto::GetMyAvatar);
+ this->CreateService(PS_SETMYAVATART, &CSkypeProto::SetMyAvatar);
// service to get from protocol chat buddy info
- this->CreateServiceObj(MS_GC_PROTO_GETTOOLTIPTEXT, &CSkypeProto::SkypeGCGetToolTipText);
+ this->CreateService(MS_GC_PROTO_GETTOOLTIPTEXT, &CSkypeProto::SkypeGCGetToolTipText);
}
diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp
index a84804ba59..82fd39404c 100644
--- a/protocols/Skype/src/skype_utils.cpp
+++ b/protocols/Skype/src/skype_utils.cpp
@@ -255,30 +255,6 @@ void CSkypeProto::InitCustomFolders()
// ---
-void CSkypeProto::CreateServiceObj(const char* szService, SkypeServiceFunc serviceProc)
-{
- char moduleName[MAXMODULELABELLENGTH];
-
- ::mir_snprintf(moduleName, sizeof(moduleName), "%s%s", this->m_szModuleName, szService);
- ::CreateServiceFunctionObj(moduleName, (MIRANDASERVICEOBJ)*(void**)&serviceProc, this);
-}
-
-void CSkypeProto::CreateServiceObjParam(const char* szService, SkypeServiceFunc serviceProc, LPARAM lParam)
-{
- char moduleName[MAXMODULELABELLENGTH];
-
- ::mir_snprintf(moduleName, sizeof(moduleName), "%s%s", this->m_szModuleName, szService);
- ::CreateServiceFunctionObjParam(moduleName, (MIRANDASERVICEOBJPARAM)*(void**)&serviceProc, this, lParam);
-}
-
-HANDLE CSkypeProto::CreateEvent(const char* szService)
-{
- char moduleName[MAXMODULELABELLENGTH];
-
- ::mir_snprintf(moduleName, sizeof(moduleName), "%s%s", this->m_szModuleName, szService);
- return ::CreateHookableEvent(moduleName);
-}
-
int CSkypeProto::SendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam)
{
return ::ProtoBroadcastAck(this->m_szModuleName, hContact, type, result, hProcess, lParam);
@@ -289,26 +265,6 @@ int CSkypeProto::SendBroadcast(int type, int result, HANDLE hProcess, LPARAM lPa
return this->SendBroadcast(NULL, type, result, hProcess, lParam);
}
-void CSkypeProto::ForkThread(SkypeThreadFunc pFunc, void *param)
-{
- UINT threadID;
- ::CloseHandle((HANDLE)::mir_forkthreadowner(
- (pThreadFuncOwner)*(void**)&pFunc,
- this,
- param,
- &threadID));
-}
-
-HANDLE CSkypeProto::ForkThreadEx(SkypeThreadFunc pFunc, void *param, UINT* threadID)
-{
- UINT lthreadID;
- return (HANDLE)::mir_forkthreadowner(
- (pThreadFuncOwner)*(void**)&pFunc,
- this,
- param,
- threadID ? threadID : &lthreadID);
-}
-
//
int CSkypeProto::SkypeToMirandaLoginError(CAccount::LOGOUTREASON logoutReason)