summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-08-11 10:41:37 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-08-11 10:41:37 +0000
commit94dcc72f13094157f344f284aec4edf0c0f5faa1 (patch)
tree74c078daadd4abe5aea9e9e0a73b4dd7c4a7fde1 /include
parent42ff2169dbddd25d06404623dba2fff222d17c73 (diff)
ProtoGetAvatarFormat, ProtoGetAvatarFileFormat, ProtoGetBufferFormat, ProtoGetAvatarExtension - standard helpers for protocol avatars' processing instead of the zoo that existed previously
git-svn-id: http://svn.miranda-ng.org/main/trunk@5645 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'include')
-rw-r--r--include/delphi/m_core.inc17
-rw-r--r--include/m_core.h23
-rw-r--r--include/m_protocols.h16
3 files changed, 46 insertions, 10 deletions
diff --git a/include/delphi/m_core.inc b/include/delphi/m_core.inc
index 94ac1a7089..0bfd0aec8f 100644
--- a/include/delphi/m_core.inc
+++ b/include/delphi/m_core.inc
@@ -534,6 +534,23 @@ function ProtoCallService(const szModule, szName:PAnsiChar; wParam:WPARAM; lPara
function ProtoServiceExists(const szModule, szName:PAnsiChar):int; stdcall;
external CoreDLL name 'ProtoServiceExists';
+// returns image extension by a PA_* constant or empty string for PA_FORMAT_UNKNOWN
+function ProtoGetAvatarExtension(format:int):PWideChar; stdcall;
+ external CoreDLL name 'ProtoGetAvatarExtension';
+
+// detects image format by extension
+function ProtoGetAvatarFormat(const szFileName:PWideChar):int; stdcall;
+ external CoreDLL name 'ProtoGetAvatarFormat';
+
+// detects image format by its contents
+function ProtoGetAvatarFileFormat(const szFileName:PWideChar):int; stdcall;
+ external CoreDLL 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';
+
///////////////////////////////////////////////////////////////////////////////
// sha1 functions
type
diff --git a/include/m_core.h b/include/m_core.h
index b99bbbafb1..9c4461b407 100644
--- a/include/m_core.h
+++ b/include/m_core.h
@@ -615,10 +615,29 @@ MIR_CORE_DLL(void) ProtoHookEvent(struct PROTO_INTERFACE *pThis, const char* s
MIR_CORE_DLL(HANDLE) ProtoCreateHookableEvent(struct PROTO_INTERFACE *pThis, const char* szService);
typedef INT_PTR (__cdecl PROTO_INTERFACE::*ProtoServiceFunc)(WPARAM, LPARAM);
-MIR_CORE_DLL(void) ProtoCreateService(struct PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFunc);
+MIR_CORE_DLL(void) ProtoCreateService(struct PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFunc);
typedef INT_PTR (__cdecl PROTO_INTERFACE::*ProtoServiceFuncParam)(WPARAM, LPARAM, LPARAM);
-MIR_CORE_DLL(void) ProtoCreateServiceParam(struct PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFuncParam, LPARAM);
+MIR_CORE_DLL(void) ProtoCreateServiceParam(struct PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFuncParam, LPARAM);
+#endif
+
+// 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);
+
+// detects image format by extension
+MIR_CORE_DLL(int) ProtoGetAvatarFormat(const TCHAR *ptszFileName);
+
+// detects image format by its contents
+MIR_CORE_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);
+#else
+ MIR_CORE_DLL(int) ProtoGetBufferFormat(const void *buf, const TCHAR **ptszExtension);
#endif
///////////////////////////////////////////////////////////////////////////////
diff --git a/include/m_protocols.h b/include/m_protocols.h
index 483d581401..0604217424 100644
--- a/include/m_protocols.h
+++ b/include/m_protocols.h
@@ -392,14 +392,14 @@ ProtoBroadcastAck(), listeners must hook ME_PROTO_ACK, note that lParam = ACKDAT
*/
-#define PA_FORMAT_UNKNOWN 0 // the protocol can not determine much about the "bitmap"
-#define PA_FORMAT_PNG 1 // the image is PNG
-#define PA_FORMAT_JPEG 2
-#define PA_FORMAT_ICON 3
-#define PA_FORMAT_BMP 4
-#define PA_FORMAT_GIF 5
-#define PA_FORMAT_SWF 6
-#define PA_FORMAT_XML 7
+#define PA_FORMAT_UNKNOWN 0 // the protocol can not determine much about the "bitmap"
+#define PA_FORMAT_PNG 1 // the image is PNG
+#define PA_FORMAT_JPEG 2
+#define PA_FORMAT_ICON 3
+#define PA_FORMAT_BMP 4
+#define PA_FORMAT_GIF 5
+#define PA_FORMAT_SWF 6
+#define PA_FORMAT_XML 7
typedef struct {
int cbSize; // sizeof()