From ae30cd958593fae5c4d385045f5ba669b9dd4b50 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 18 Jun 2015 18:29:39 +0000 Subject: protocol platform-independent code moved back to mir_app git-svn-id: http://svn.miranda-ng.org/main/trunk@14247 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/delphi/m_core.inc | 41 ++++++++++++----------------------------- include/m_core.h | 41 +++++++---------------------------------- include/m_gui.h | 2 +- include/m_protocols.h | 2 +- include/m_protoint.h | 40 +++++++++++++++++++++++++++++++++++++++- 5 files changed, 60 insertions(+), 66 deletions(-) (limited to 'include') diff --git a/include/delphi/m_core.inc b/include/delphi/m_core.inc index fb3a57e2be..7a3cb5d8e7 100644 --- a/include/delphi/m_core.inc +++ b/include/delphi/m_core.inc @@ -404,63 +404,46 @@ function mir_vsnwprintf(buffer:PWideChar;count:size_t;fmt:PWideChar;va:va_list): // protocol functions function ProtoBroadcastAck(const szModule:PAnsiChar; hContact:TMCONTACT; type_:int; result_:int; hProcess:THANDLE; lParam:LPARAM): int_ptr; stdcall; - external CoreDLL name 'ProtoBroadcastAck'; + external AppDLL name 'ProtoBroadcastAck'; function ProtoServiceExists(const szModule, szName:PAnsiChar):int; stdcall; external AppDLL name 'ProtoServiceExists'; procedure ProtoWindowAdd(pThis:pointer; wnd:HWND); stdcall; - external CoreDLL name 'ProtoWindowAdd'; + external AppDLL name 'ProtoWindowAdd'; procedure ProtoWindowRemove(pThis:pointer; wnd:HWND); stdcall; - external CoreDLL name 'ProtoWindowRemove'; + external AppDLL name 'ProtoWindowRemove'; // Call it in the very beginning of your proto's constructor -procedure ProtoConstructor(pThis:pointer{PPROTO_INTERFACE}; const pszModuleName:PAnsiChar; - ptszUserName:PWideChar); stdcall; - external CoreDLL name 'ProtoConstructor'; +procedure ProtoConstructor(pThis:pointer{PPROTO_INTERFACE}; const pszModuleName:PAnsiChar; ptszUserName:PWideChar); stdcall; + external AppDLL name 'ProtoConstructor'; // Call it in the very end of your proto's destructor procedure ProtoDestructor(pThis:pointer{PPROTO_INTERFACE}); stdcall; - external CoreDLL name 'ProtoDestructor'; - -{!! -typedef void (__cdecl PROTO_INTERFACE::*ProtoThreadFunc)(void*); -procedure ProtoForkThread(PROTO_INTERFACE *pThis, ProtoThreadFunc, void *param); -function ProtoForkThreadEx(PROTO_INTERFACE *pThis, ProtoThreadFunc, void *param, uint* threadID):THANDLE; - -typedef int (__cdecl PROTO_INTERFACE::*ProtoEventFunc)(WPARAM, LPARAM); -procedure ProtoHookEvent(PROTO_INTERFACE *pThis, const char* szName, ProtoEventFunc pFunc); -function ProtoCreateHookableEvent(PROTO_INTERFACE *pThis, const char* szService):THANDLE; - -typedef INT_PTR (__cdecl PROTO_INTERFACE::*ProtoServiceFunc)(WPARAM, LPARAM); -procedure ProtoCreateService(PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFunc); - -typedef INT_PTR (__cdecl PROTO_INTERFACE::*ProtoServiceFuncParam)(WPARAM, LPARAM, LPARAM); -procedure ProtoCreateServiceParam(PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFuncParam, LPARAM); -} + external AppDLL name 'ProtoDestructor'; procedure ProtoLogA(pThis:pointer{PPROTO_INTERFACE}; szFormat :PAnsiChar; args:va_list); stdcall; - external CoreDLL name 'ProtoLogA'; + external AppDLL name 'ProtoLogA'; procedure ProtoLogW(pThis:pointer{PPROTO_INTERFACE}; wszFormat:PWideChar; args:va_list); stdcall; - external CoreDLL name 'ProtoLogW'; + external AppDLL name 'ProtoLogW'; // returns image extension by a PA_* constant or empty string for PA_FORMAT_UNKNOWN function ProtoGetAvatarExtension(format:int):PWideChar; stdcall; - external CoreDLL name 'ProtoGetAvatarExtension'; + external AppDLL name 'ProtoGetAvatarExtension'; // detects image format by extension function ProtoGetAvatarFormat(const szFileName:PWideChar):int; stdcall; - external CoreDLL name 'ProtoGetAvatarFormat'; + external AppDLL name 'ProtoGetAvatarFormat'; // detects image format by its contents function ProtoGetAvatarFileFormat(const szFileName:PWideChar):int; stdcall; - external CoreDLL name 'ProtoGetAvatarFileFormat'; + external AppDLL name 'ProtoGetAvatarFileFormat'; // returns the image format and extension by the first bytes of picture // ptszExtension might be NULL function ProtoGetBufferFormat(const buf:PByte; var ext:PWideChar):int; stdcall; - external CoreDLL name 'ProtoGetBufferFormat'; + external AppDLL name 'ProtoGetBufferFormat'; /////////////////////////////////////////////////////////////////////////////// diff --git a/include/m_core.h b/include/m_core.h index 5133ecbd6f..52bef5ddd8 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -41,7 +41,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define MIR_C_CORE_DLL(T) MIR_CORE_EXPORT T __cdecl #ifdef MIR_APP_EXPORTS - #define MIR_APP_EXPORT + #define MIR_APP_EXPORT __declspec(dllexport) #else #define MIR_APP_EXPORT __declspec(dllimport) #endif @@ -342,52 +342,25 @@ MIR_CORE_DLL(int) mir_vsnwprintf(wchar_t *buffer, size_t count, const wchar_t struct PROTO_INTERFACE; -MIR_CORE_DLL(INT_PTR) ProtoBroadcastAck(LPCSTR szModule, MCONTACT hContact, int type, int result, HANDLE hProcess, LPARAM lParam); - -// Call it in the very beginning of your proto's constructor -MIR_CORE_DLL(void) ProtoConstructor(PROTO_INTERFACE *pThis, const char *pszModuleName, const TCHAR *ptszUserName); - -// Call it in the very end of your proto's destructor -MIR_CORE_DLL(void) ProtoDestructor(PROTO_INTERFACE *pThis); - -#if defined( __cplusplus ) -typedef void (__cdecl PROTO_INTERFACE::*ProtoThreadFunc)(void*); -MIR_CORE_DLL(void) ProtoForkThread(PROTO_INTERFACE *pThis, ProtoThreadFunc, void *param); -MIR_CORE_DLL(HANDLE) ProtoForkThreadEx(PROTO_INTERFACE *pThis, ProtoThreadFunc, void *param, UINT* threadID); -MIR_CORE_DLL(void) ProtoWindowAdd(PROTO_INTERFACE *pThis, HWND hwnd); -MIR_CORE_DLL(void) ProtoWindowRemove(PROTO_INTERFACE *pThis, HWND hwnd); - -typedef int (__cdecl PROTO_INTERFACE::*ProtoEventFunc)(WPARAM, LPARAM); -MIR_CORE_DLL(void) ProtoHookEvent(PROTO_INTERFACE *pThis, const char* szName, ProtoEventFunc pFunc); -MIR_CORE_DLL(HANDLE) ProtoCreateHookableEvent(PROTO_INTERFACE *pThis, const char* szService); - -typedef INT_PTR (__cdecl PROTO_INTERFACE::*ProtoServiceFunc)(WPARAM, LPARAM); -MIR_CORE_DLL(void) ProtoCreateService(PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFunc); - -typedef INT_PTR (__cdecl PROTO_INTERFACE::*ProtoServiceFuncParam)(WPARAM, LPARAM, LPARAM); -MIR_CORE_DLL(void) ProtoCreateServiceParam(PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFuncParam, LPARAM); -#endif - -MIR_CORE_DLL(void) ProtoLogA(PROTO_INTERFACE *pThis, LPCSTR szFormat, va_list args); -MIR_CORE_DLL(void) ProtoLogW(PROTO_INTERFACE *pThis, LPCWSTR wszFormat, va_list args); +MIR_APP_DLL(INT_PTR) ProtoBroadcastAck(LPCSTR szModule, MCONTACT hContact, int type, int result, HANDLE hProcess, LPARAM lParam); // avatar support functions // returns image extension by a PA_* constant or empty string for PA_FORMAT_UNKNOWN -MIR_CORE_DLL(const TCHAR*) ProtoGetAvatarExtension(int format); +MIR_APP_DLL(const TCHAR*) ProtoGetAvatarExtension(int format); // detects image format by extension -MIR_CORE_DLL(int) ProtoGetAvatarFormat(const TCHAR *ptszFileName); +MIR_APP_DLL(int) ProtoGetAvatarFormat(const TCHAR *ptszFileName); // detects image format by its contents -MIR_CORE_DLL(int) ProtoGetAvatarFileFormat(const TCHAR *ptszFileName); +MIR_APP_DLL(int) ProtoGetAvatarFileFormat(const TCHAR *ptszFileName); // returns the image format and extension by the first bytes of picture // ptszExtension might be NULL #if defined( __cplusplus ) - MIR_CORE_DLL(int) ProtoGetBufferFormat(const void *buf, const TCHAR **ptszExtension = NULL); + MIR_APP_DLL(int) ProtoGetBufferFormat(const void *buf, const TCHAR **ptszExtension = NULL); #else - MIR_CORE_DLL(int) ProtoGetBufferFormat(const void *buf, const TCHAR **ptszExtension); + MIR_APP_DLL(int) ProtoGetBufferFormat(const void *buf, const TCHAR **ptszExtension); #endif /////////////////////////////////////////////////////////////////////////////// diff --git a/include/m_gui.h b/include/m_gui.h index 3994cb4645..5ab3ed3026 100644 --- a/include/m_gui.h +++ b/include/m_gui.h @@ -1123,7 +1123,7 @@ public: struct PROTO_INTERFACE; -class MIR_CORE_EXPORT CProtoIntDlgBase : public CDlgBase +class MIR_APP_EXPORT CProtoIntDlgBase : public CDlgBase { typedef CDlgBase CSuper; diff --git a/include/m_protocols.h b/include/m_protocols.h index cb6fd2ac38..0a024340e8 100644 --- a/include/m_protocols.h +++ b/include/m_protocols.h @@ -225,7 +225,7 @@ typedef struct { #ifdef __cplusplus extern "C" #endif -MIR_CORE_DLL(PROTOCOLDESCRIPTOR*) Proto_IsProtocolLoaded(const char *szProtoName); +MIR_APP_DLL(PROTOCOLDESCRIPTOR*) Proto_IsProtocolLoaded(const char *szProtoName); // gets the network-level protocol associated with a contact // wParam = (MCONTACT)hContact diff --git a/include/m_protoint.h b/include/m_protoint.h index 1e75d08e15..fc2171ad32 100644 --- a/include/m_protoint.h +++ b/include/m_protoint.h @@ -30,6 +30,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include +///////////////////////////////////////////////////////////////////////////////////////// +// data types + typedef enum { EV_PROTO_ONLOAD, @@ -44,7 +47,42 @@ typedef enum } PROTOEVENTTYPE; -struct MIR_CORE_EXPORT PROTO_INTERFACE : public MZeroedObject +///////////////////////////////////////////////////////////////////////////////////////// +// protocol helpers + +struct PROTO_INTERFACE; + +// Call it in the very beginning of your proto's constructor +EXTERN_C MIR_APP_DLL(void) ProtoConstructor(PROTO_INTERFACE *pThis, const char *pszModuleName, const TCHAR *ptszUserName); + +// Call it in the very end of your proto's destructor +EXTERN_C MIR_APP_DLL(void) ProtoDestructor(PROTO_INTERFACE *pThis); + +#if defined( __cplusplus ) +typedef void (__cdecl PROTO_INTERFACE::*ProtoThreadFunc)(void*); +EXTERN_C MIR_APP_DLL(void) ProtoForkThread(PROTO_INTERFACE *pThis, ProtoThreadFunc, void *param); +EXTERN_C MIR_APP_DLL(HANDLE) ProtoForkThreadEx(PROTO_INTERFACE *pThis, ProtoThreadFunc, void *param, UINT* threadID); +EXTERN_C MIR_APP_DLL(void) ProtoWindowAdd(PROTO_INTERFACE *pThis, HWND hwnd); +EXTERN_C MIR_APP_DLL(void) ProtoWindowRemove(PROTO_INTERFACE *pThis, HWND hwnd); + +typedef int (__cdecl PROTO_INTERFACE::*ProtoEventFunc)(WPARAM, LPARAM); +EXTERN_C MIR_APP_DLL(void) ProtoHookEvent(PROTO_INTERFACE *pThis, const char* szName, ProtoEventFunc pFunc); +EXTERN_C MIR_APP_DLL(HANDLE) ProtoCreateHookableEvent(PROTO_INTERFACE *pThis, const char* szService); + +typedef INT_PTR (__cdecl PROTO_INTERFACE::*ProtoServiceFunc)(WPARAM, LPARAM); +EXTERN_C MIR_APP_DLL(void) ProtoCreateService(PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFunc); + +typedef INT_PTR (__cdecl PROTO_INTERFACE::*ProtoServiceFuncParam)(WPARAM, LPARAM, LPARAM); +EXTERN_C MIR_APP_DLL(void) ProtoCreateServiceParam(PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFuncParam, LPARAM); +#endif + +EXTERN_C MIR_APP_DLL(void) ProtoLogA(PROTO_INTERFACE *pThis, LPCSTR szFormat, va_list args); +EXTERN_C MIR_APP_DLL(void) ProtoLogW(PROTO_INTERFACE *pThis, LPCWSTR wszFormat, va_list args); + +///////////////////////////////////////////////////////////////////////////////////////// +// interface declaration + +struct MIR_APP_EXPORT PROTO_INTERFACE : public MZeroedObject { int m_iStatus, // current protocol status m_iDesiredStatus, // status to be set after logging in -- cgit v1.2.3