diff options
Diffstat (limited to 'protocols/MRA')
-rw-r--r-- | protocols/MRA/src/Mra.h | 14 | ||||
-rw-r--r-- | protocols/MRA/src/MraAvatars.cpp | 2 | ||||
-rw-r--r-- | protocols/MRA/src/MraFilesQueue.cpp | 4 | ||||
-rw-r--r-- | protocols/MRA/src/MraIcons.cpp | 2 | ||||
-rw-r--r-- | protocols/MRA/src/MraProto.cpp | 70 | ||||
-rw-r--r-- | protocols/MRA/src/MraProto.h | 17 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_proto.cpp | 2 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_svcs.cpp | 3 |
8 files changed, 27 insertions, 87 deletions
diff --git a/protocols/MRA/src/Mra.h b/protocols/MRA/src/Mra.h index 253dbfc9b3..1d6df272b0 100644 --- a/protocols/MRA/src/Mra.h +++ b/protocols/MRA/src/Mra.h @@ -120,18 +120,18 @@ struct MRA_ADDR_LIST // структура содержащая информацию по построению меню или расширеных иконок
struct GUI_DISPLAY_ITEM
{
- LPSTR lpszName; // имя сервиса, оно же имя в иколибе
- LPWSTR lpwszDescr; // текстовое описание отображаемое юзеру
- LONG defIcon; // иконка из ресурсов
- ServiceFunc lpFunc; // функция вызываемая меню
- HANDLE hIconHandle;
+ LPSTR lpszName; // имя сервиса, оно же имя в иколибе
+ LPWSTR lpwszDescr; // текстовое описание отображаемое юзеру
+ LONG defIcon; // иконка из ресурсов
+ CMraProto::MyServiceFunc lpFunc; // функция вызываемая меню
+ HANDLE hIconHandle;
};
// структура содержащая информацию о сервисах/функциях
struct SERVICE_ITEM
{
- LPSTR lpszName; // имя сервиса, оно же имя в иколибе
- ServiceFunc lpFunc; // функция вызываемая
+ LPSTR lpszName; // имя сервиса, оно же имя в иколибе
+ CMraProto::MyServiceFunc lpFunc; // функция вызываемая
};
extern GUI_DISPLAY_ITEM gdiMenuItems[];
diff --git a/protocols/MRA/src/MraAvatars.cpp b/protocols/MRA/src/MraAvatars.cpp index 85f49b4d4d..077489bed1 100644 --- a/protocols/MRA/src/MraAvatars.cpp +++ b/protocols/MRA/src/MraAvatars.cpp @@ -100,7 +100,7 @@ DWORD CMraProto::MraAvatarsQueueInitialize(HANDLE *phAvatarsQueueHandle) if (pmraaqAvatarsQueue->iThreadsCount > MAXIMUM_WAIT_OBJECTS)
pmraaqAvatarsQueue->iThreadsCount = MAXIMUM_WAIT_OBJECTS;
for (int i=0; i < pmraaqAvatarsQueue->iThreadsCount; i++)
- pmraaqAvatarsQueue->hThread[i] = ForkThreadEx(&CMraProto::MraAvatarsThreadProc, pmraaqAvatarsQueue);
+ pmraaqAvatarsQueue->hThread[i] = ForkThreadEx(&CMraProto::MraAvatarsThreadProc, pmraaqAvatarsQueue, 0);
*phAvatarsQueueHandle = (HANDLE)pmraaqAvatarsQueue;
}
diff --git a/protocols/MRA/src/MraFilesQueue.cpp b/protocols/MRA/src/MraFilesQueue.cpp index 8ab83d4a6c..21d853f511 100644 --- a/protocols/MRA/src/MraFilesQueue.cpp +++ b/protocols/MRA/src/MraFilesQueue.cpp @@ -292,7 +292,7 @@ DWORD CMraProto::MraFilesQueueAccept(HANDLE hFilesQueueHandle, DWORD dwIDRequest pmftpp->hFilesQueueHandle = hFilesQueueHandle;
pmftpp->dat = dat;
- dat->hThread = ForkThreadEx(&CMraProto::MraFilesQueueRecvThreadProc, pmftpp);
+ dat->hThread = ForkThreadEx(&CMraProto::MraFilesQueueRecvThreadProc, pmftpp, 0);
}
return dwRetErrorCode;
}
@@ -1002,7 +1002,7 @@ DWORD CMraProto::MraFilesQueueAddSend(HANDLE hFilesQueueHandle, DWORD dwFlags, H MRA_FILES_THREADPROC_PARAMS *pmftpp = (MRA_FILES_THREADPROC_PARAMS*)mir_calloc(sizeof(MRA_FILES_THREADPROC_PARAMS));
pmftpp->hFilesQueueHandle = hFilesQueueHandle;
pmftpp->dat = dat;
- dat->hThread = ForkThreadEx(&CMraProto::MraFilesQueueSendThreadProc, pmftpp);
+ dat->hThread = ForkThreadEx(&CMraProto::MraFilesQueueSendThreadProc, pmftpp, 0);
return NO_ERROR;
}
diff --git a/protocols/MRA/src/MraIcons.cpp b/protocols/MRA/src/MraIcons.cpp index f82ba302c7..0bb4de9214 100644 --- a/protocols/MRA/src/MraIcons.cpp +++ b/protocols/MRA/src/MraIcons.cpp @@ -191,7 +191,7 @@ void CMraProto::CListCreateMenu(LONG lPosition, LONG lPopupPosition, HICON hMain for (size_t i = 0; i < dwCount; i++) {
memmove(pszServiceFunctionName, pgdiItems[i].lpszName, lstrlenA(pgdiItems[i].lpszName)+1);
if (pgdiItems[i].lpFunc)
- CreateObjectSvc(pgdiItems[i].lpszName, pgdiItems[i].lpFunc);
+ CreateService(pgdiItems[i].lpszName, pgdiItems[i].lpFunc);
mi.position = int(lPosition + i);
mi.icolibItem = pgdiItems[i].hIconHandle;
mi.ptszName = pgdiItems[i].lpwszDescr;
diff --git a/protocols/MRA/src/MraProto.cpp b/protocols/MRA/src/MraProto.cpp index 5aa836733f..37321e64e4 100644 --- a/protocols/MRA/src/MraProto.cpp +++ b/protocols/MRA/src/MraProto.cpp @@ -8,29 +8,28 @@ static int MraExtraIconsApplyAll(WPARAM, LPARAM) }
CMraProto::CMraProto(const char* _module, const TCHAR* _displayName) :
+ PROTO<CMraProto>(_module, _displayName),
m_bLoggedIn(false)
{
- ProtoConstructor(this, _module, _displayName);
-
InitializeCriticalSectionAndSpinCount(&csCriticalSectionSend, 0);
MraSendQueueInitialize(0, &hSendQueueHandle);
MraFilesQueueInitialize(0, &hFilesQueueHandle);
MraMPopSessionQueueInitialize(&hMPopSessionQueue);
MraAvatarsQueueInitialize(&hAvatarsQueueHandle);
- CreateObjectSvc(PS_SETCUSTOMSTATUSEX, &CMraProto::MraSetXStatusEx);
- CreateObjectSvc(PS_GETCUSTOMSTATUSEX, &CMraProto::MraGetXStatusEx);
- CreateObjectSvc(PS_GETCUSTOMSTATUSICON, &CMraProto::MraGetXStatusIcon);
+ CreateService(PS_SETCUSTOMSTATUSEX, &CMraProto::MraSetXStatusEx);
+ CreateService(PS_GETCUSTOMSTATUSEX, &CMraProto::MraGetXStatusEx);
+ CreateService(PS_GETCUSTOMSTATUSICON, &CMraProto::MraGetXStatusIcon);
- CreateObjectSvc(PS_SET_LISTENINGTO, &CMraProto::MraSetListeningTo);
+ CreateService(PS_SET_LISTENINGTO, &CMraProto::MraSetListeningTo);
- CreateObjectSvc(PS_CREATEACCMGRUI, &CMraProto::MraCreateAccMgrUI);
- CreateObjectSvc(PS_GETAVATARCAPS, &CMraProto::MraGetAvatarCaps);
- CreateObjectSvc(PS_GETAVATARINFOT, &CMraProto::MraGetAvatarInfo);
- CreateObjectSvc(PS_GETMYAVATART, &CMraProto::MraGetMyAvatar);
+ CreateService(PS_CREATEACCMGRUI, &CMraProto::MraCreateAccMgrUI);
+ CreateService(PS_GETAVATARCAPS, &CMraProto::MraGetAvatarCaps);
+ CreateService(PS_GETAVATARINFOT, &CMraProto::MraGetAvatarInfo);
+ CreateService(PS_GETMYAVATART, &CMraProto::MraGetMyAvatar);
- CreateObjectSvc(MS_ICQ_SENDSMS, &CMraProto::MraSendSMS);
- CreateObjectSvc(MRA_SEND_NUDGE, &CMraProto::MraSendNudge);
+ CreateService(MS_ICQ_SENDSMS, &CMraProto::MraSendSMS);
+ CreateService(MRA_SEND_NUDGE, &CMraProto::MraSendNudge);
if ( ServiceExists(MS_NUDGE_SEND))
heNudgeReceived = CreateHookableEvent(MS_NUDGE);
@@ -52,7 +51,7 @@ CMraProto::CMraProto(const char* _module, const TCHAR* _displayName) : for (size_t i = 0; i < MRA_XSTATUS_COUNT; i++) {
char szServiceName[100];
mir_snprintf(szServiceName, SIZEOF(szServiceName), "/menuXStatus%ld", i);
- CreateObjectSvcParam(szServiceName, &CMraProto::MraXStatusMenu, i);
+ CreateServiceParam(szServiceName, &CMraProto::MraXStatusMenu, i);
}
mir_snprintf(szNewMailSound, SIZEOF(szNewMailSound), "%s: %s", m_szModuleName, MRA_SOUND_NEW_EMAIL);
@@ -94,7 +93,7 @@ INT_PTR CMraProto::MraCreateAccMgrUI(WPARAM wParam,LPARAM lParam) int CMraProto::OnModulesLoaded(WPARAM, LPARAM)
{
- hHookExtraIconsApply = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, &CMraProto::MraExtraIconsApply);
+ HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, &CMraProto::MraExtraIconsApply);
HookEvent(ME_OPT_INITIALISE, &CMraProto::OnOptionsInit);
HookEvent(ME_DB_CONTACT_DELETED, &CMraProto::MraContactDeleted);
HookEvent(ME_DB_CONTACT_SETTINGCHANGED, &CMraProto::MraDbSettingChanged);
@@ -145,49 +144,6 @@ int CMraProto::OnPreShutdown(WPARAM, LPARAM) /////////////////////////////////////////////////////////////////////////////////////////
-void CMraProto::CreateObjectSvc(const char *szService, ServiceFunc serviceProc)
-{
- char str[ MAXMODULELABELLENGTH ];
- strcpy( str, m_szModuleName );
- strcat( str, szService );
- ::CreateServiceFunctionObj( str, ( MIRANDASERVICEOBJ )*( void** )&serviceProc, this );
-}
-
-void CMraProto::CreateObjectSvcParam( const char *szService, ServiceFuncParam serviceProc, LPARAM lParam )
-{
- char str[ MAXMODULELABELLENGTH ];
- strcpy( str, m_szModuleName );
- strcat( str, szService );
- ::CreateServiceFunctionObjParam( str, ( MIRANDASERVICEOBJPARAM )*( void** )&serviceProc, this, lParam );
-}
-
-HANDLE CMraProto::HookEvent(const char* szEvent, EventFunc handler)
-{
- return ::HookEventObj( szEvent, ( MIRANDAHOOKOBJ )*( void** )&handler, this );
-}
-
-HANDLE CMraProto::CreateHookableEvent(const char *szService)
-{
- char str[ MAXMODULELABELLENGTH ];
- strcpy( str, m_szModuleName );
- strcat( str, szService );
- return ::CreateHookableEvent( str );
-}
-
-void CMraProto::ForkThread(ThreadFunc pFunc, void *param)
-{
- UINT threadID;
- CloseHandle(( HANDLE )::mir_forkthreadowner(( pThreadFuncOwner ) *( void** )&pFunc, this, param, &threadID ));
-}
-
-HANDLE CMraProto::ForkThreadEx(ThreadFunc pFunc, void *param, UINT* threadID)
-{
- UINT lthreadID;
- return ( HANDLE )::mir_forkthreadowner(( pThreadFuncOwner ) *( void** )&pFunc, this, param, threadID ? threadID : <hreadID);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
HANDLE CMraProto::AddToListByEmail(LPCTSTR plpsEMail, LPCTSTR plpsNick, LPCTSTR plpsFirstName, LPCTSTR plpsLastName, DWORD dwFlags)
{
if (!plpsEMail)
diff --git a/protocols/MRA/src/MraProto.h b/protocols/MRA/src/MraProto.h index 019401c90d..0037dcb81c 100644 --- a/protocols/MRA/src/MraProto.h +++ b/protocols/MRA/src/MraProto.h @@ -18,12 +18,6 @@ struct MRA_FILES_QUEUE_ITEM;
-struct CMraProto;
-typedef void (__cdecl CMraProto::*ThreadFunc)(void*);
-typedef int (__cdecl CMraProto::*EventFunc)(WPARAM, LPARAM);
-typedef INT_PTR (__cdecl CMraProto::*ServiceFunc)(WPARAM, LPARAM);
-typedef INT_PTR (__cdecl CMraProto::*ServiceFuncParam)(WPARAM, LPARAM, LPARAM);
-
BOOL DB_GetStaticStringA(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, LPSTR lpszRetBuff, size_t dwRetBuffSize, size_t *pdwRetBuffSize);
BOOL DB_GetStaticStringW(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, LPWSTR lpszRetBuff, size_t dwRetBuffSize, size_t *pdwRetBuffSize);
@@ -32,7 +26,7 @@ BOOL DB_SetStringExW(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, L BOOL DB_GetContactSettingBlob(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, LPVOID lpRet, size_t dwRetBuffSize, size_t *pdwRetBuffSize);
-struct CMraProto : public PROTO_INTERFACE
+struct CMraProto : public PROTO<CMraProto>
{
CMraProto(const char*, const TCHAR*);
~CMraProto();
@@ -87,13 +81,6 @@ struct CMraProto : public PROTO_INTERFACE virtual int __cdecl OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam);
- void CreateObjectSvc(const char* szService, ServiceFunc serviceProc);
- void CreateObjectSvcParam(const char* szService, ServiceFuncParam serviceProc, LPARAM lParam);
- HANDLE CreateHookableEvent(const char* szService);
- void ForkThread(ThreadFunc, void*);
- HANDLE ForkThreadEx(ThreadFunc, void*, UINT* threadID = NULL);
- HANDLE HookEvent(const char*, EventFunc);
-
void ShowFormattedErrorMessage(LPWSTR lpwszErrText, DWORD dwErrorCode);
void MraPopupShowW(HANDLE hContact, DWORD dwType, DWORD dwFlags, LPWSTR lpszTitle, LPWSTR lpszMessage);
void MraPopupShowFromContactW(HANDLE hContact, DWORD dwType, DWORD dwFlags, LPWSTR lpszMessage);
@@ -200,7 +187,7 @@ struct CMraProto : public PROTO_INTERFACE HANDLE hSendQueueHandle, hFilesQueueHandle, hMPopSessionQueue;
- HANDLE hNetlibUser, heNudgeReceived, hHookExtraIconsApply;
+ HANDLE hNetlibUser, heNudgeReceived;
HANDLE hThreadWorker;
HANDLE hConnection;
DWORD dwThreadWorkerLastPingTime;
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp index 4f79848d52..8b4a9318ed 100644 --- a/protocols/MRA/src/Mra_proto.cpp +++ b/protocols/MRA/src/Mra_proto.cpp @@ -22,7 +22,7 @@ DWORD CMraProto::StartConnect() if (dwEMailSize > 5 && GetPassDB(szPass, sizeof(szPass), &dwPasswordSize)) {
InterlockedExchange((volatile LONG*)&dwThreadWorkerLastPingTime, GetTickCount());
- hThreadWorker = ForkThreadEx(&CMraProto::MraThreadProc, NULL);
+ hThreadWorker = ForkThreadEx(&CMraProto::MraThreadProc, NULL, 0);
if (hThreadWorker == NULL) {
DWORD dwRetErrorCode = GetLastError();
InterlockedExchange((volatile LONG*)&dwThreadWorkerRunning, FALSE);
diff --git a/protocols/MRA/src/Mra_svcs.cpp b/protocols/MRA/src/Mra_svcs.cpp index 001a526d2a..83ea9a9544 100644 --- a/protocols/MRA/src/Mra_svcs.cpp +++ b/protocols/MRA/src/Mra_svcs.cpp @@ -123,9 +123,6 @@ const LPWSTR lpcszXStatusNameDef[] = void CMraProto::SetExtraIcons(HANDLE hContact)
{
- if (!hHookExtraIconsApply)
- return;
-
DWORD dwID, dwGroupID, dwContactSeverFlags;
if ( GetContactBasicInfoW(hContact, &dwID, &dwGroupID, NULL, &dwContactSeverFlags, NULL, NULL, 0, NULL, NULL, 0, NULL, NULL, 0, NULL))
return;
|