From 47daa65b633626f8e902f00a769639b088b60726 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Tue, 29 Jul 2014 14:50:23 +0000 Subject: FlashAvatars moved to deprrecated git-svn-id: http://svn.miranda-ng.org/main/trunk@9982 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- .../FlashAvatars/FlashAvatars_10.vcxproj | 207 ++++++ .../FlashAvatars/FlashAvatars_10.vcxproj.filters | 52 ++ .../FlashAvatars/FlashAvatars_12.vcxproj | 210 ++++++ .../FlashAvatars/FlashAvatars_12.vcxproj.filters | 52 ++ .../!Deprecated/FlashAvatars/docs/changelog.txt | 81 +++ .../!Deprecated/FlashAvatars/res/FlashAvatars.rc | 65 ++ plugins/!Deprecated/FlashAvatars/res/Version.rc | 38 ++ plugins/!Deprecated/FlashAvatars/src/TigerHash.cpp | 760 +++++++++++++++++++++ plugins/!Deprecated/FlashAvatars/src/TigerHash.h | 108 +++ plugins/!Deprecated/FlashAvatars/src/Version.h | 14 + plugins/!Deprecated/FlashAvatars/src/cflash.cpp | 641 +++++++++++++++++ .../!Deprecated/FlashAvatars/src/criticalsection.h | 112 +++ plugins/!Deprecated/FlashAvatars/src/flash.tlb | Bin 0 -> 14160 bytes plugins/!Deprecated/FlashAvatars/src/resource.h | 15 + plugins/!Deprecated/FlashAvatars/src/stdafx.cpp | 7 + plugins/!Deprecated/FlashAvatars/src/stdafx.h | 78 +++ 16 files changed, 2440 insertions(+) create mode 100644 plugins/!Deprecated/FlashAvatars/FlashAvatars_10.vcxproj create mode 100644 plugins/!Deprecated/FlashAvatars/FlashAvatars_10.vcxproj.filters create mode 100644 plugins/!Deprecated/FlashAvatars/FlashAvatars_12.vcxproj create mode 100644 plugins/!Deprecated/FlashAvatars/FlashAvatars_12.vcxproj.filters create mode 100644 plugins/!Deprecated/FlashAvatars/docs/changelog.txt create mode 100644 plugins/!Deprecated/FlashAvatars/res/FlashAvatars.rc create mode 100644 plugins/!Deprecated/FlashAvatars/res/Version.rc create mode 100644 plugins/!Deprecated/FlashAvatars/src/TigerHash.cpp create mode 100644 plugins/!Deprecated/FlashAvatars/src/TigerHash.h create mode 100644 plugins/!Deprecated/FlashAvatars/src/Version.h create mode 100644 plugins/!Deprecated/FlashAvatars/src/cflash.cpp create mode 100644 plugins/!Deprecated/FlashAvatars/src/criticalsection.h create mode 100644 plugins/!Deprecated/FlashAvatars/src/flash.tlb create mode 100644 plugins/!Deprecated/FlashAvatars/src/resource.h create mode 100644 plugins/!Deprecated/FlashAvatars/src/stdafx.cpp create mode 100644 plugins/!Deprecated/FlashAvatars/src/stdafx.h (limited to 'plugins/!Deprecated') diff --git a/plugins/!Deprecated/FlashAvatars/FlashAvatars_10.vcxproj b/plugins/!Deprecated/FlashAvatars/FlashAvatars_10.vcxproj new file mode 100644 index 0000000000..bbbee617ed --- /dev/null +++ b/plugins/!Deprecated/FlashAvatars/FlashAvatars_10.vcxproj @@ -0,0 +1,207 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + FlashAvatars + {914B61B9-3383-4FA1-9BA9-350200B734B5} + + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + Disabled + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + _DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + stdafx.h + Level3 + EditAndContinue + false + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + version.lib;%(AdditionalDependencies) + true + 0x25000000 + false + $(IntDir)$(TargetName).lib + Windows + $(ProfileDir)..\..\bin10\lib + + + + + Disabled + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + _DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Use + stdafx.h + Level3 + false + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + version.lib;%(AdditionalDependencies) + true + 0x25000000 + false + $(IntDir)$(TargetName).lib + Windows + $(ProfileDir)..\..\bin10\lib + + + + + Full + OnlyExplicitInline + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + true + Level3 + Size + Use + false + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + version.lib;%(AdditionalDependencies) + true + false + $(IntDir)$(TargetName).lib + true + true + Windows + 0x25000000 + $(ProfileDir)..\..\bin10\lib + /PDBALTPATH:%_PDB% + + + + + Full + OnlyExplicitInline + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + true + Level3 + Size + Use + false + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + version.lib;%(AdditionalDependencies) + true + false + $(IntDir)$(TargetName).lib + true + true + Windows + 0x25000000 + $(ProfileDir)..\..\bin10\lib + /PDBALTPATH:%_PDB% + + + + + + + + + + + + + + + + Create + + + + + + + + \ No newline at end of file diff --git a/plugins/!Deprecated/FlashAvatars/FlashAvatars_10.vcxproj.filters b/plugins/!Deprecated/FlashAvatars/FlashAvatars_10.vcxproj.filters new file mode 100644 index 0000000000..84595578e0 --- /dev/null +++ b/plugins/!Deprecated/FlashAvatars/FlashAvatars_10.vcxproj.filters @@ -0,0 +1,52 @@ + + + + + {baed73f6-6413-4a48-81f1-44736cdf7d50} + h;hpp;hxx;hm;inl + + + {a22eadc9-ed9b-4e56-8e1e-350ce8875bef} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + {e502d69e-3182-4849-8a80-09df8b3f5ce5} + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/plugins/!Deprecated/FlashAvatars/FlashAvatars_12.vcxproj b/plugins/!Deprecated/FlashAvatars/FlashAvatars_12.vcxproj new file mode 100644 index 0000000000..534445879e --- /dev/null +++ b/plugins/!Deprecated/FlashAvatars/FlashAvatars_12.vcxproj @@ -0,0 +1,210 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + FlashAvatars + {914B61B9-3383-4FA1-9BA9-350200B734B5} + + + + DynamicLibrary + Unicode + true + v120_xp + + + DynamicLibrary + Unicode + true + v120_xp + + + DynamicLibrary + Unicode + v120_xp + + + DynamicLibrary + Unicode + v120_xp + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + Disabled + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + _DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + stdafx.h + Level3 + EditAndContinue + false + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + version.lib;%(AdditionalDependencies) + true + 0x25000000 + false + $(IntDir)$(TargetName).lib + Windows + $(ProfileDir)..\..\bin12\lib + false + + + + + Disabled + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + _DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Use + stdafx.h + Level3 + false + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + version.lib;%(AdditionalDependencies) + true + 0x25000000 + false + $(IntDir)$(TargetName).lib + Windows + $(ProfileDir)..\..\bin12\lib + + + + + Full + OnlyExplicitInline + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + true + Level3 + Size + Use + false + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + version.lib;%(AdditionalDependencies) + true + false + $(IntDir)$(TargetName).lib + true + true + Windows + 0x25000000 + $(ProfileDir)..\..\bin12\lib + + + + + Full + OnlyExplicitInline + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + true + Level3 + Size + Use + false + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + version.lib;%(AdditionalDependencies) + true + false + $(IntDir)$(TargetName).lib + true + true + Windows + 0x25000000 + $(ProfileDir)..\..\bin12\lib + + + + + + + + + + + + + + + + Create + + + + + + + + \ No newline at end of file diff --git a/plugins/!Deprecated/FlashAvatars/FlashAvatars_12.vcxproj.filters b/plugins/!Deprecated/FlashAvatars/FlashAvatars_12.vcxproj.filters new file mode 100644 index 0000000000..84595578e0 --- /dev/null +++ b/plugins/!Deprecated/FlashAvatars/FlashAvatars_12.vcxproj.filters @@ -0,0 +1,52 @@ + + + + + {baed73f6-6413-4a48-81f1-44736cdf7d50} + h;hpp;hxx;hm;inl + + + {a22eadc9-ed9b-4e56-8e1e-350ce8875bef} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + {e502d69e-3182-4849-8a80-09df8b3f5ce5} + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/plugins/!Deprecated/FlashAvatars/docs/changelog.txt b/plugins/!Deprecated/FlashAvatars/docs/changelog.txt new file mode 100644 index 0000000000..79a9b5a972 --- /dev/null +++ b/plugins/!Deprecated/FlashAvatars/docs/changelog.txt @@ -0,0 +1,81 @@ +* 0.0.0.1 + initial version + +* 0.0.1.1 + changed service functions + avatars should work correctly + +* 0.0.1.2 + better switching when user changes flash avatar to another flash avatar + avatar faces on status change + support/service constants are now in separate file (m_flash.h) + shutdown cleanup + +* 0.0.1.3 + FLASHAVATAR structure is used to post more information in service functions + flash object is created for each flash avatar, it solves many problems + +* 0.0.1.4 + avatar faces on standard ICQ emoticon + invalidate parent object after creating flash object + changed services' names (for the last time!) + +* 0.0.1.5 + added support to have displayed more flash avatars for same contact at one time + added message when flash.ocx isn't registered + +* 0.0.1.6 + fixed a crash when xml file doesn't exist + used standard protocol service to get avatar path + made thread safe + +* 0.0.1.7 + default protocol is ICQ for contact with unknown protocol + added support for own flash avatars (requires small change in tabsrmm and icq plugins) + fixed creating more avatars for one contact + fixed crash with invalid xml file + support for flashavatar background color per contact (set in message window) + +* 0.0.1.8 + changed project settings to decrease library size + +* 0.0.1.9 + using STLPort + removed ATL dependency + fixed iterator corruption when deleting flash avatar + fixed avatar smileys + +* 0.0.1.10 + added tZers support + using hash_multimap + +* 0.0.1.11 + added bad flash version check + disabled tZers support + using multimap instead of hash_multimap again + MS_FAVATAR_RESIZE function supports changing flash position + hopefully fixed crash when flash.ocx is not registered + added MS_FAVATAR_SETBKCOLOR service to allow setting flash background color + +* 0.0.1.12 + fixed disappeared flash avatar when resizing + added MS_FAVATAR_SETPOS service to set avatar position + +* 0.0.1.13 + code cleanup + not displaying ICQ flash avatar for unknown protocol + definitely removed tZers support + added reserved memory space to FLASHAVATAR structure, so we could extend it in the future + added flash default width and height macros to m_flash.h + added own downloading routine, so it respects Miranda's NetLib settings + added flash avatar caching + flash avatar downloading/loading routine moved to own thread + fixed invalid XML parsing + KNOWN PROBLEM: some icq5 self-made flash avatars (from Devil factory) can't be loaded from cache and in thread, so it uses default way for them + fixed thread handle leak + strings are translatable + +* 0.0.1.14 + added support for folders plugin + really fixed the thread handle leak + some code cleanup \ No newline at end of file diff --git a/plugins/!Deprecated/FlashAvatars/res/FlashAvatars.rc b/plugins/!Deprecated/FlashAvatars/res/FlashAvatars.rc new file mode 100644 index 0000000000..2282ceecf7 --- /dev/null +++ b/plugins/!Deprecated/FlashAvatars/res/FlashAvatars.rc @@ -0,0 +1,65 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\src\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Czech resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CSY) +#ifdef _WIN32 +LANGUAGE LANG_CZECH, SUBLANG_DEFAULT +#pragma code_page(1250) +#endif //_WIN32 + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,14,251 + PRODUCTVERSION 1,0,14,251 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040504b0" + BEGIN + VALUE "CompanyName", "Big Muscle" + VALUE "FileDescription", "FlashAvatars" + VALUE "FileVersion", "1, 0, 14, 251" + VALUE "InternalName", "FlashAvatars" + VALUE "LegalCopyright", "Copyright (C) 2006-2009" + VALUE "OriginalFilename", "FlashAvatars" + VALUE "ProductName", "FlashAvatars" + VALUE "ProductVersion", "1, 0, 14, 251" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x405, 1200 + END +END + +#endif // Czech resources +///////////////////////////////////////////////////////////////////////////// + diff --git a/plugins/!Deprecated/FlashAvatars/res/Version.rc b/plugins/!Deprecated/FlashAvatars/res/Version.rc new file mode 100644 index 0000000000..5bfbab4754 --- /dev/null +++ b/plugins/!Deprecated/FlashAvatars/res/Version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script. +// +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include "afxres.h" +#include "..\src\version.h" + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", __DESCRIPTION + VALUE "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END diff --git a/plugins/!Deprecated/FlashAvatars/src/TigerHash.cpp b/plugins/!Deprecated/FlashAvatars/src/TigerHash.cpp new file mode 100644 index 0000000000..094ba444ed --- /dev/null +++ b/plugins/!Deprecated/FlashAvatars/src/TigerHash.cpp @@ -0,0 +1,760 @@ +/* + * Copyright (C) 2001-2006 Jacek Sieka, arnetheduck on gmail point com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "stdafx.h" + +#ifdef _WIN32 +#if defined(_M_X64) +#define TIGER_ARCH64 +#endif +#if !(defined(_M_IX86) || defined(_M_X64)) +#define TIGER_BIG_ENDIAN +#endif +#else // _WIN32 +#if defined(__x86_64__) || defined(__alpha) +#define TIGER_ARCH64 +#endif +#if !(defined(__i386__) || defined(__x86_64__) || defined(__alpha)) +#define TIGER_BIG_ENDIAN +#endif +#endif // _WIN32 + +#define PASSES 3 + +#define t1 (table) +#define t2 (table+256) +#define t3 (table+256*2) +#define t4 (table+256*3) + +#define save_abc \ + aa = a; \ + bb = b; \ + cc = c; + +#ifdef TIGER_ARCH64 +#define round(a,b,c,x,mul) \ + c ^= x; \ + a -= t1[((c)>>(0*8))&0xFF] ^ t2[((c)>>(2*8))&0xFF] ^ \ + t3[((c)>>(4*8))&0xFF] ^ t4[((c)>>(6*8))&0xFF] ; \ + b += t4[((c)>>(1*8))&0xFF] ^ t3[((c)>>(3*8))&0xFF] ^ \ + t2[((c)>>(5*8))&0xFF] ^ t1[((c)>>(7*8))&0xFF] ; \ + b *= mul; +#else +#define round(a,b,c,x,mul) \ + c ^= x; \ + a -= t1[(uint8_t)(c)] ^ \ + t2[(uint8_t)(((uint32_t)(c))>>(2*8))] ^ \ + t3[(uint8_t)(((uint64_t)(c))>>(4*8))] ^ \ + t4[(uint8_t)(((uint32_t)(((uint64_t)(c))>>(4*8)))>>(2*8))] ; \ + b += t4[(uint8_t)(((uint32_t)(c))>>(1*8))] ^ \ + t3[(uint8_t)(((uint32_t)(c))>>(3*8))] ^ \ + t2[(uint8_t)(((uint32_t)(((uint64_t)(c))>>(4*8)))>>(1*8))] ^ \ + t1[(uint8_t)(((uint32_t)(((uint64_t)(c))>>(4*8)))>>(3*8))]; \ + b *= mul; +#endif + +#define pass(a,b,c,mul) \ + round(a,b,c,x0,mul) \ + round(b,c,a,x1,mul) \ + round(c,a,b,x2,mul) \ + round(a,b,c,x3,mul) \ + round(b,c,a,x4,mul) \ + round(c,a,b,x5,mul) \ + round(a,b,c,x6,mul) \ + round(b,c,a,x7,mul) + +#define key_schedule \ + x0 -= x7 ^ _ULL(0xA5A5A5A5A5A5A5A5); \ + x1 ^= x0; \ + x2 += x1; \ + x3 -= x2 ^ ((~x1)<<19); \ + x4 ^= x3; \ + x5 += x4; \ + x6 -= x5 ^ ((~x4)>>23); \ + x7 ^= x6; \ + x0 += x7; \ + x1 -= x0 ^ ((~x7)<<19); \ + x2 ^= x1; \ + x3 += x2; \ + x4 -= x3 ^ ((~x2)>>23); \ + x5 ^= x4; \ + x6 += x5; \ + x7 -= x6 ^ _ULL(0x0123456789ABCDEF); + +#define feedforward \ + a ^= aa; \ + b -= bb; \ + c += cc; + +#ifdef TIGER_ARCH64 +#define compress \ + save_abc \ + pass(a,b,c,5) \ + key_schedule \ + pass(c,a,b,7) \ + key_schedule \ + pass(b,c,a,9) \ + for(pass_no=3; pass_no 0) { + size_t n = min(length, BLOCK_SIZE-tmppos); + memcpy(tmp + tmppos, str, n); + str += n; + pos += n; + length -= n; + + if ((tmppos + n) == BLOCK_SIZE) { +#ifdef TIGER_BIG_ENDIAN + for(j=0; j=BLOCK_SIZE) { +#ifdef TIGER_BIG_ENDIAN + for(j=0; j (BLOCK_SIZE - sizeof(uint64_t))) { + memset(tmp + tmppos, 0, BLOCK_SIZE - tmppos); +#ifdef TIGER_BIG_ENDIAN + for(j=0; j 3) { + word = (uint8_t)(hash[i] & (0xFF >> index)); + index = (index + 5) % 8; + word <<= index; + if ((i + 1) < HASH_SIZE) + word |= hash[i + 1] >> (8 - index); + + i++; + } else { + word = (uint8_t)(hash[i] >> (8 - (index + 5))) & 0x1F; + index = (index + 5) % 8; + if (index == 0) + i++; + } + + //dcassert(word < 32); + dst[j] = base32Alphabet[word]; + } + dst[39] = NULL; + return dst; + } + + /** Calculates the Tiger hash of the data. */ + void update(const void* data, size_t len); + /** Call once all data has been processed. */ + uint8_t* finalize(); + +private: + enum { BLOCK_SIZE = 512/8 }; + /** 512 bit blocks for the compress function */ + uint8_t tmp[512/8]; + /** State / final hash value */ + uint64_t res[3]; + /** Total number of bytes compressed */ + uint64_t pos; + /** S boxes */ + static uint64_t table[]; + + void tigerCompress(const uint64_t* data, uint64_t state[3]); +}; + +#endif // !defined(TIGER_HASH_H) + +/** + * @file + * $Id: TigerHash.h,v 1.10 2006/10/13 20:04:32 bigmuscle Exp $ + */ diff --git a/plugins/!Deprecated/FlashAvatars/src/Version.h b/plugins/!Deprecated/FlashAvatars/src/Version.h new file mode 100644 index 0000000000..7ab5bbae86 --- /dev/null +++ b/plugins/!Deprecated/FlashAvatars/src/Version.h @@ -0,0 +1,14 @@ +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 0 +#define __RELEASE_NUM 1 +#define __BUILD_NUM 14 + +#include + +#define __PLUGIN_NAME "Flash avatars" +#define __FILENAME "FlashAvatars.dll" +#define __DESCRIPTION "Loads and displays Flash avatars." +#define __AUTHOR "Big Muscle" +#define __AUTHOREMAIL "" +#define __AUTHORWEB "http://miranda-ng.org/p/FlashAvatars/" +#define __COPYRIGHT "© 2000-2009 Miranda-IM project" diff --git a/plugins/!Deprecated/FlashAvatars/src/cflash.cpp b/plugins/!Deprecated/FlashAvatars/src/cflash.cpp new file mode 100644 index 0000000000..134b896758 --- /dev/null +++ b/plugins/!Deprecated/FlashAvatars/src/cflash.cpp @@ -0,0 +1,641 @@ +#include "stdafx.h" + +#import "Flash.tlb" no_namespace exclude("IServiceProvider") + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // {72765A6F-B017-42F1-B30F-5E0941273A3F} + {0x72765a6f, 0xb017, 0x42f1, {0xb3, 0xf, 0x5e, 0x9, 0x41, 0x27, 0x3a, 0x3f}} +}; + + +/* a strcmp() that likes NULL */ +int __fastcall strcmpnull(const char *str1, const char *str2) { + if (str1 && str2) + return strcmp(str1, str2); + + if (!str1 && !str2) + return 0; + + return 1; +} + + +struct flash_avatar_item : public MZeroedObject +{ + MCONTACT hContact; + FLASHAVATAR hFA; + IShockwaveFlash* pFlash; + + char* getProto() { return (hFA.cProto) ? hFA.cProto : GetContactProto(hFA.hContact); } + + flash_avatar_item(MCONTACT contact, FLASHAVATAR& fa, IShockwaveFlash *flash) { hContact = contact; hFA = fa; pFlash = flash; } +}; + +static int CompareFlashItems(const flash_avatar_item* p1, const flash_avatar_item* p2) { + if (p1->hContact < p2->hContact) + return -1; + + if (p1->hContact > p2->hContact) + return 1; + + int cProto = strcmpnull(p1->hFA.cProto, p2->hFA.cProto); + if (cProto) + return cProto; + + return (p1->hFA.id > p2->hFA.id) ? -1 : (p1->hFA.id == p2->hFA.id) ? 0 : 1; +}; + +HINSTANCE g_hInst = 0; + + +int hLangpack; +CLIST_INTERFACE *pcli; + +HANDLE hNetlibUser; + +static char pluginName[64]; + +static CriticalSection cs; + +static HANDLE hAvatarsFolder = NULL; + +static LIST FlashList(5, CompareFlashItems); + +typedef HRESULT (WINAPI *LPAtlAxAttachControl)(IUnknown* pControl, HWND hWnd, IUnknown** ppUnkContainer); +LPAtlAxAttachControl MyAtlAxAttachControl; + + +#define getFace() \ + char* face;\ + switch (status) {\ + case ID_STATUS_OFFLINE:\ + face = AV_OFFLINE;\ + break;\ + case ID_STATUS_ONLINE:\ + case ID_STATUS_INVISIBLE:\ + face = AV_NORMAL;\ + break;\ + default:\ + face = AV_BUSY;\ + break;\ + } + +static bool DownloadFlashFile(char *url, const TCHAR* save_file, int recurse_count /*=0*/) +{ + if (!url || recurse_count > 5) + return false; + + NETLIBHTTPREQUEST req = {0}; + req.cbSize = sizeof(req); + req.requestType = REQUEST_GET; + req.szUrl = url; + req.flags = 0;//NLHRF_HTTP11; + + NETLIBHTTPREQUEST *resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&req); + if(resp) { + if(resp->resultCode == 200) { + HANDLE hSaveFile = CreateFile(save_file, GENERIC_WRITE, FILE_SHARE_WRITE, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); + if(hSaveFile != INVALID_HANDLE_VALUE) { + unsigned long bytes_written = 0; + if(WriteFile(hSaveFile, resp->pData, resp->dataLength, &bytes_written, NULL)) { + CloseHandle(hSaveFile); + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp); + resp = 0; + return true; + } + CloseHandle(hSaveFile); + } + } else if(resp->resultCode >= 300 && resp->resultCode < 400) { + // get new location + bool ret = false; + for(int i = 0; i < resp->headersCount; i++) { + if(strcmpnull(resp->headers[i].szName, "Location") == 0) { + ret = DownloadFlashFile(resp->headers[i].szValue, save_file, recurse_count + 1); + break; + } + } + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp); + resp = 0; + return ret; + } + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp); + resp = 0; + } + + return false; +} +/* +static wchar_t *u2w(const char *utfs) { + if(utfs) { + int size = MultiByteToWideChar(CP_UTF8, 0, utfs, -1, 0, 0); + wchar_t *buff = new wchar_t[size]; + MultiByteToWideChar(CP_UTF8, 0, utfs, -1, buff, size); + return buff; + } else + return 0; +} +*/ + +static void __cdecl loadFlash_Thread(void *p) { + debug("Avatar thread executed...\n"); + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE); + + flash_avatar_item* fai = (flash_avatar_item*)p; + IShockwaveFlash* flash = fai->pFlash; + + if ( _tcschr(fai->hFA.cUrl, '?') == NULL) { + // make hash of url + debug("Making TTH hash from URL...\n"); + TigerHash th; + th.update(fai->hFA.cUrl, _tcslen(fai->hFA.cUrl)); + th.finalize(); + + // create local path name + TCHAR name[MAX_PATH], path[MAX_PATH]; + TCHAR tth[((TigerHash::HASH_SIZE * 8) / 5) + 2]; + FOLDERSGETDATA fgd = {0}; + + fgd.cbSize = sizeof(FOLDERSGETDATA); + fgd.nMaxPathSize = MAX_PATH; + fgd.szPathT = path; + fgd.flags = FF_TCHAR; + if (!hAvatarsFolder || CallService(MS_FOLDERS_GET_PATH, (WPARAM)hAvatarsFolder, (LPARAM)&fgd)) { + if(ServiceExists(MS_UTILS_REPLACEVARS)) + mir_sntprintf(path, MAX_PATH, _T("%s\\%s"), VARST(_T("%miranda_avatarcache%")), _T("Flash")); + else + PathToAbsoluteT( _T("Flash"), path); + } + else { + if(_tcslen(path) && path[_tcslen(path)-1]=='\\') + path[_tcslen(path)-1] = 0; + } + + CreateDirectory(path, NULL); // create directory if it doesn't exist + mir_sntprintf(name, MAX_PATH, _T("%s\\%s.swf"), path, th.toBase32(tth)); + + // download remote file if it doesn't exist + if (GetFileAttributes(name) == 0xFFFFFFFF) { + debug("Downloading flash file...\n"); + DownloadFlashFile( _T2A(fai->hFA.cUrl), name, 0); + } + + // load and play local flash movie + debug("Loading flash movie...\n"); + flash->LoadMovie(0, _bstr_t(name).copy()); + } + Sleep(100); + flash->Play(); + + // change flash frame according user's status + int status; + if (fai->hFA.hContact) + status = db_get_w(fai->hFA.hContact, fai->getProto(), "Status", ID_STATUS_OFFLINE); + else + status = CallProtoService(fai->getProto(), PS_GETSTATUS, 0, 0); + + getFace(); + flash->SetVariable(L"face.emotion", _bstr_t(face).copy()); + flash->Release(); +} + +static void ShowBalloon(TCHAR *title, TCHAR *msg, int icon) +{ + MIRANDASYSTRAYNOTIFY msn = {0}; + msn.cbSize = sizeof(MIRANDASYSTRAYNOTIFY); + msn.dwInfoFlags = icon | NIIF_INTERN_UNICODE; + msn.tszInfo = TranslateTS(msg); + msn.tszInfoTitle = TranslateTS(title); + msn.uTimeout = 5000; + pcli->pfnCListTrayNotify(&msn); +} + +static void prepareFlash(char* pProto, const TCHAR* pUrl, FLASHAVATAR& fa, IShockwaveFlash* flash) +{ + debug("Preparing flash...\n"); + if(flash == NULL) { + // Flash component is not registered in the system + ShowBalloon(LPGENT("Flash.ocx not registered!"), LPGENT("You don't have installed Shockwave Flash interface in your system."), NIIF_ERROR); + + DestroyWindow(fa.hWindow); + fa.hWindow = 0; + return; + } + + if(flash->FlashVersion() == 0x80000) { + // Flash Version 8 has a bug which causes random crashes :( + ShowBalloon(LPGENT("Bugged Flash detected!"), LPGENT("You have installed Flash 8.\r\nThis version of Flash contains a bug which can cause random crashes.\r\nIt is recommended to upgrade or downgrade your Flash library"), NIIF_WARNING); + } + + // attach flash object to window + debug("Attaching flash to its window...\n"); + MyAtlAxAttachControl(flash, fa.hWindow, 0); + + // store avatar info + debug("Storing avatar info...\n"); + fa.cProto = pProto; + fa.cUrl = mir_tstrdup(pUrl); + + // create flash record + flash_avatar_item *flash_item = new flash_avatar_item(fa.hContact, fa, flash); + { + Lock l(cs); + FlashList.insert(flash_item); + } + + // avatar contains parameter, load it from remote place + if ( _tcschr(fa.cUrl, '?')) { + debug("Flash with parameters, loading...\n"); + flash->LoadMovie(0, fa.cUrl); + } + _bstr_t + // refresh avatar's parent window + // InvalidateRect(fa.hParentWindow, NULL, FALSE); + + // create thread to download/load flash avatar + debug("Creating avatar thread...\n"); + flash->AddRef(); + mir_forkthread(&loadFlash_Thread, (void*)flash_item); + //loadFlash(new FlashPair(make_pair(fa, flash))); +} + +static INT_PTR destroyAvatar(WPARAM wParam, LPARAM) +{ + flash_avatar_item key(((FLASHAVATAR*)wParam)->hContact, *(FLASHAVATAR*)wParam, NULL); + + Lock l(cs); + + flash_avatar_item *item = FlashList.find(&key); + if (item) { + if (item->pFlash) + item->pFlash->Release(); + if (item->hFA.hWindow) + DestroyWindow(item->hFA.hWindow); + mir_free(item->hFA.cUrl); + FlashList.remove(item); + delete item; + } + return 0; +} + +static INT_PTR makeAvatar(WPARAM wParam, LPARAM) +{ + debug("Searching for flash avatar...\n"); + FLASHAVATAR* hFA = (FLASHAVATAR*)wParam; + + PROTO_AVATAR_INFORMATIONT AI = {0}; + AI.cbSize = sizeof(AI); + AI.hContact = hFA->hContact; + AI.format = PA_FORMAT_UNKNOWN; + + flash_avatar_item key(hFA->hContact, *hFA, NULL); + + bool avatarOK = false; + if(hFA->hContact) + avatarOK = (int)CallProtoService(key.getProto(), PS_GETAVATARINFOT, 0, (LPARAM)&AI) == GAIR_SUCCESS; + else { + avatarOK = (int)CallProtoService(key.getProto(), PS_GETMYAVATART, (WPARAM)AI.filename, (LPARAM)255) == 0; + if(avatarOK) { + TCHAR* ext = _tcsrchr(AI.filename, _T('.')); + if(ext && (_tcsicmp(ext, _T(".xml")) == 0)) + AI.format = PA_FORMAT_XML; + } + } + + if (!avatarOK) return 0; + debug("Avatar found...\n"); + + TCHAR url[MAX_PATH]; + switch(AI.format) { + case PA_FORMAT_SWF: + _tcsncpy(url, AI.filename, SIZEOF(url)); + break; + case PA_FORMAT_XML: { + int src = _topen(AI.filename, _O_BINARY | _O_RDONLY); + if(src != -1) { + char pBuf[2048]; + char* urlBuf; + _read(src, pBuf, sizeof(pBuf)); + _close(src); + + urlBuf = strstr(pBuf, ""); + if(urlBuf) + _tcsncpy(url, _A2T(strtok(urlBuf + 5, "\r\n <")), SIZEOF(url)); + else + return 0; + } else { + return 0; + } + break; + } + default: + destroyAvatar(wParam, 0); + return 0; + } + + Lock l(cs); + flash_avatar_item *item = FlashList.find(&key); + if (item) { + debug("Flash already exists...\n"); + hFA->hWindow = item->hFA.hWindow; + ShowWindow(hFA->hWindow, SW_SHOW); + + if ( _tcsicmp(item->hFA.cUrl, url) != 0) { + debug("Refreshing flash...\n"); + IShockwaveFlash* flash = item->pFlash; + mir_free(item->hFA.cUrl); + FlashList.remove(item); + delete item; + + prepareFlash(key.getProto(), url, *hFA, flash); + } + } + else { + debug("Creating new flash...\n"); + RECT rc; + GetWindowRect(hFA->hParentWindow, &rc); + hFA->hWindow = CreateWindowEx(WS_EX_TOPMOST, _T("AtlAxWin"), _T(""), WS_VISIBLE | WS_CHILD, 0, 0, rc.right - rc.left, rc.bottom - rc.top, hFA->hParentWindow, (HMENU) 0, g_hInst, NULL); + + IShockwaveFlash* flash = NULL; + debug("Creating flash instance...\n"); + CoCreateInstance(__uuidof(ShockwaveFlash),0,CLSCTX_ALL, __uuidof(IShockwaveFlash), (void **)&flash); + debug("Initialized.\n"); + + prepareFlash(key.getProto(), url, *hFA, flash); + } + return 0; +} + +static INT_PTR resizeAvatar(WPARAM wParam, LPARAM lParam) +{ + FLASHAVATAR* hFA = (FLASHAVATAR*)wParam; + RECT rc = *((LPRECT)lParam); + flash_avatar_item key(hFA->hContact, *hFA, NULL); + + Lock l(cs); + flash_avatar_item *item = FlashList.find(&key); + if (item) + SetWindowPos(item->hFA.hWindow, HWND_TOP, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_SHOWWINDOW); + + return 0; +} + +static INT_PTR setPos(WPARAM wParam, LPARAM lParam) +{ + FLASHAVATAR* hFA = (FLASHAVATAR*)wParam; + RECT rc = *((LPRECT)lParam); + flash_avatar_item key(hFA->hContact, *hFA, NULL); + + Lock l(cs); + flash_avatar_item *item = FlashList.find(&key); + if (item) + SetWindowPos(item->hFA.hWindow, HWND_TOP, rc.left, rc.top, rc.right, rc.bottom, SWP_SHOWWINDOW); + + return 0; +} + +static INT_PTR getInfo(WPARAM wParam, LPARAM) +{ + FLASHAVATAR* hFA = (FLASHAVATAR*)wParam; + flash_avatar_item key(hFA->hContact, *hFA, NULL); + + Lock l(cs); + flash_avatar_item *item = FlashList.find(&key); + if (item) { + //IShockwaveFlash* flash = item->pFlash; + hFA->hWindow = item->hFA.hWindow; + hFA->cUrl = item->hFA.cUrl; + hFA->cProto = item->hFA.cProto; + } + return 0; +} + +static INT_PTR setEmoFace(WPARAM wParam, LPARAM lParam) +{ + FLASHAVATAR* hFA = (FLASHAVATAR*)wParam; + flash_avatar_item key(hFA->hContact, *hFA, NULL); + + Lock l(cs); + flash_avatar_item *item = FlashList.find(&key); + if (item && item->pFlash) { + IShockwaveFlash* flash = item->pFlash; + flash->SetVariable(L"face.emotion", (BSTR)lParam); + } + return 0; +} + +static INT_PTR setBkColor(WPARAM wParam, LPARAM lParam) +{ + FLASHAVATAR* hFA = (FLASHAVATAR*)wParam; + COLORREF clr = (COLORREF)lParam; + flash_avatar_item key(hFA->hContact, *hFA, NULL); + + Lock l(cs); + flash_avatar_item *item = FlashList.find(&key); + if (item && item->pFlash) { + IShockwaveFlash* flash = item->pFlash; + + char buf[10]; + mir_snprintf(buf, sizeof(buf), "%02X%02X%02X", LOBYTE(LOWORD(clr)), HIBYTE(LOWORD(clr)), LOBYTE(HIWORD(clr))); + flash->put_BGColor(_bstr_t(buf)); + } + return 0; +} + +static int ownStatusChanged(WPARAM wParam, LPARAM lParam) +{ + WORD status = (WORD)wParam; + const char* proto = (char*)lParam; + + Lock l(cs); + for(int i = 0; i < FlashList.getCount(); i++) { + flash_avatar_item *item = FlashList[i]; + if(item->hContact == NULL && (!proto || (strcmpnull(item->hFA.cProto, proto) == 0))) { + IShockwaveFlash* flash = item->pFlash; + if (flash) { + getFace(); + flash->SetVariable(L"face.emotion", _bstr_t(face).copy()); + } + } else if (item->hContact) + break; // the list is sorted by hContact + } + return 0; +} + +static int statusChanged(WPARAM wParam, LPARAM lParam) +{ + WORD status = HIWORD(lParam); + + Lock l(cs); + for(int i = 0; i < FlashList.getCount(); i++) { + flash_avatar_item *item = FlashList[i]; + if (item->hContact == wParam) { + IShockwaveFlash* flash = item->pFlash; + if (flash) { + getFace(); + flash->SetVariable(L"face.emotion", _bstr_t(face).copy()); + } + } else if (item->hContact > wParam) + break; // the list is sorted by hContact + } + return 0; +} + +static int eventAdded(WPARAM wParam, LPARAM lParam) +{ + DBEVENTINFO dbei = { sizeof(dbei) }; + dbei.cbBlob = db_event_getBlobSize((HANDLE)lParam); + if (dbei.cbBlob == 0xFFFFFFFF) + return 0; + + dbei.pBlob = new BYTE[dbei.cbBlob]; + db_event_get((HANDLE)lParam, &dbei); + + if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_READ)) { + Lock l(cs); + if(FlashList.getCount() > 0) { + //size_t aLen = strlen((char *)dbei.pBlob)+1; + char* face = NULL; + + if ( (strstr((char*)dbei.pBlob, (char*)":-)") != NULL) || + (strstr((char*)dbei.pBlob, (char*)":)") != NULL) || + (strstr((char*)dbei.pBlob, (char*)";)") != NULL) || + (strstr((char*)dbei.pBlob, (char*)";-)") != NULL) || + (strstr((char*)dbei.pBlob, (char*)"*THUMBS UP*") != NULL) || + (strstr((char*)dbei.pBlob, (char*)"O:-)") != NULL) || + (strstr((char*)dbei.pBlob, (char*)":P") != NULL) || + (strstr((char*)dbei.pBlob, (char*)":-P") != NULL) || + (strstr((char*)dbei.pBlob, (char*)"*Drink*") != NULL)) { face = AV_SMILE; } + else + if ( (strstr((char*)dbei.pBlob, (char*)":-(") != NULL) || + (strstr((char*)dbei.pBlob, (char*)":-$") != NULL) || + (strstr((char*)dbei.pBlob, (char*)":-!") != NULL) || + (strstr((char*)dbei.pBlob, (char*)":-X") != NULL)) { face = AV_SAD; } + else + if ( (strstr((char*)dbei.pBlob, (char*)"*JOKINGLY*") != NULL) || + (strstr((char*)dbei.pBlob, (char*)":-D") != NULL)) { face = AV_LAUGH; } + else + if ( (strstr((char*)dbei.pBlob, (char*)":'(") != NULL) || + (strstr((char*)dbei.pBlob, (char*)":'-(") != NULL)) { face = AV_CRY; } + else + if ( (strstr((char*)dbei.pBlob, (char*)">:o") != NULL) || + (strstr((char*)dbei.pBlob, (char*)":-@") != NULL) || + (strstr((char*)dbei.pBlob, (char*)"*STOP*") != NULL) || + (strstr((char*)dbei.pBlob, (char*)"]:->") != NULL) || + (strstr((char*)dbei.pBlob, (char*)"@=") != NULL)) { face = AV_MAD; } + else + if ( (strstr((char*)dbei.pBlob, (char*)":-*") != NULL) || + (strstr((char*)dbei.pBlob, (char*)":-[") != NULL) || + (strstr((char*)dbei.pBlob, (char*)"*KISSED*") != NULL) || + (strstr((char*)dbei.pBlob, (char*)"*KISSING*") != NULL) || + (strstr((char*)dbei.pBlob, (char*)"@}->--") != NULL) || + (strstr((char*)dbei.pBlob, (char*)"*IN LOVE*") != NULL)) { face = AV_LOVE; } + else { + face = AV_NORMAL; + } + + MCONTACT hContact = (dbei.flags & DBEF_SENT) ? 0 : wParam; + for(int i=0; ihContact == hContact && !strcmpnull(dbei.szModule, item->getProto())) { + IShockwaveFlash* flash = item->pFlash; + flash->SetVariable(L"face.emotion", _bstr_t(face).copy()); + //break; + } else if (item->hContact > hContact) + break; // the list is sorted + } + } + } + + delete[] dbei.pBlob; + return 0; +} + +typedef BOOL (__stdcall *pfnAtlAxWinInit)( void ); + +static int systemModulesLoaded(WPARAM /*wParam*/, LPARAM /*lParam*/) +{ + HMODULE hAtl = LoadLibrary(_T("atl")); + pfnAtlAxWinInit init = (pfnAtlAxWinInit)GetProcAddress(hAtl, "AtlAxWinInit"); + if (init) + init(); + MyAtlAxAttachControl = (LPAtlAxAttachControl)GetProcAddress(hAtl, "AtlAxAttachControl"); + + CreateServiceFunction(MS_FAVATAR_DESTROY, destroyAvatar); + CreateServiceFunction(MS_FAVATAR_MAKE, makeAvatar); + CreateServiceFunction(MS_FAVATAR_RESIZE, resizeAvatar); + CreateServiceFunction(MS_FAVATAR_SETPOS, setPos); + CreateServiceFunction(MS_FAVATAR_GETINFO, getInfo); + CreateServiceFunction(MS_FAVATAR_SETEMOFACE, setEmoFace); + CreateServiceFunction(MS_FAVATAR_SETBKCOLOR, setBkColor); + + HookEvent(ME_DB_EVENT_ADDED, eventAdded); + HookEvent("Miranda/StatusChange/ContactStatusChanged", statusChanged); // NewStatusNotify + HookEvent(ME_CLIST_STATUSMODECHANGE, ownStatusChanged); + + NETLIBUSER nl_user = {0}; + nl_user.cbSize = sizeof(nl_user); + nl_user.szSettingsModule = "FlashAvatars"; + nl_user.flags = NUF_OUTGOING | NUF_HTTPCONNS; + nl_user.szDescriptiveName = Translate("Flash avatars"); + + hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nl_user); + + TCHAR path[MAX_PATH]; + mir_sntprintf(path, MAX_PATH, _T("%s\\%s\\"), VARST(_T("%miranda_avatarcache%")), _T("Flash")); + hAvatarsFolder = FoldersRegisterCustomPathT(LPGEN("Avatars"), LPGEN("Flash avatars"), path); + return 0; +} + + +extern "C" __declspec(dllexport) PLUGININFOEX * MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" int __declspec(dllexport) Load(void) +{ + mir_getLP(&pluginInfo); + mir_getCLI(); + + HookEvent(ME_SYSTEM_MODULESLOADED, systemModulesLoaded); + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + // Shutdown cleanup + { + Lock l(cs); + for (int i = FlashList.getCount()-1; i >= 0; i--) + { + flash_avatar_item *item = FlashList[i]; + if (item->pFlash) + item->pFlash->Release(); + if (item->hFA.hWindow) + DestroyWindow(item->hFA.hWindow); + mir_free(item->hFA.cUrl); + delete item; + } + FlashList.destroy(); + } + + if (hNetlibUser) + CallService(MS_NETLIB_CLOSEHANDLE, (WPARAM)hNetlibUser, 0); + + return 0; +} + +extern "C" BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD /*dwReason*/, LPVOID /*reserved*/) +{ + g_hInst = hInstDLL; + return TRUE; +} diff --git a/plugins/!Deprecated/FlashAvatars/src/criticalsection.h b/plugins/!Deprecated/FlashAvatars/src/criticalsection.h new file mode 100644 index 0000000000..7c9bcdaa9a --- /dev/null +++ b/plugins/!Deprecated/FlashAvatars/src/criticalsection.h @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2001-2006 Jacek Sieka, arnetheduck on gmail point com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#if !defined(CRITICAL_SECTION_H) +#define CRITICAL_SECTION_H + +#pragma once + +class CriticalSection +{ +public: + void enter() throw() { + EnterCriticalSection(&cs); + } + void leave() throw() { + LeaveCriticalSection(&cs); + } + CriticalSection() throw() { + InitializeCriticalSection(&cs); + } + ~CriticalSection() throw() { + DeleteCriticalSection(&cs); + } +private: + CRITICAL_SECTION cs; + + CriticalSection(const CriticalSection&); + CriticalSection& operator=(const CriticalSection&); +}; + +template +class LockBase { +public: + LockBase(T& aCs) throw() : cs(aCs) { cs.enter(); } + ~LockBase() throw() { cs.leave(); } +private: + LockBase& operator=(const LockBase&); + T& cs; +}; +typedef LockBase Lock; + +/* +template +class RWLock +{ +public: + RWLock() throw() : cs(), readers(0) { } + ~RWLock() throw() { } + + void enterRead() throw() { + cs.enter(); + InterlockedIncrement(&readers); + cs.leave(); + } + void leaveRead() throw() { + InterlockedDecrement(&readers); + } + void enterWrite() throw() { + cs.enter(); + while(readers > 0) { + ::Sleep(1); + } + } + void leaveWrite() { + cs.leave(); + } +private: + T cs; + volatile long readers; +}; + +template +class RLock { +public: + RLock(RWLock& aRwl) throw() : rwl(aRwl) { rwl.enterRead(); } + ~RLock() throw() { rwl.leaveRead(); } +private: + RLock& operator=(const RLock&); + RWLock& rwl; +}; + +template +class WLock { +public: + WLock(RWLock& aRwl) throw() : rwl(aRwl) { rwl.enterWrite(); } + ~WLock() throw() { rwl.leaveWrite(); } +private: + WLock& operator=(const WLock&); + RWLock& rwl; +}; +*/ +#endif // !defined(CRITICAL_SECTION_H) + +/** + * @file + * $Id: CriticalSection.h,v 1.20 2006/03/05 10:17:03 bigmuscle Exp $ + */ diff --git a/plugins/!Deprecated/FlashAvatars/src/flash.tlb b/plugins/!Deprecated/FlashAvatars/src/flash.tlb new file mode 100644 index 0000000000..489608c08b Binary files /dev/null and b/plugins/!Deprecated/FlashAvatars/src/flash.tlb differ diff --git a/plugins/!Deprecated/FlashAvatars/src/resource.h b/plugins/!Deprecated/FlashAvatars/src/resource.h new file mode 100644 index 0000000000..cbedd28229 --- /dev/null +++ b/plugins/!Deprecated/FlashAvatars/src/resource.h @@ -0,0 +1,15 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by FlashAvatars.rc +// + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/!Deprecated/FlashAvatars/src/stdafx.cpp b/plugins/!Deprecated/FlashAvatars/src/stdafx.cpp new file mode 100644 index 0000000000..a70d8726c6 --- /dev/null +++ b/plugins/!Deprecated/FlashAvatars/src/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// cflash.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/plugins/!Deprecated/FlashAvatars/src/stdafx.h b/plugins/!Deprecated/FlashAvatars/src/stdafx.h new file mode 100644 index 0000000000..f571759135 --- /dev/null +++ b/plugins/!Deprecated/FlashAvatars/src/stdafx.h @@ -0,0 +1,78 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently + +#define _CRT_SECURE_NO_WARNINGS + +#pragma once +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#define BZ_NO_STDIO + +#ifdef _WIN32 +# define _WIN32_WINNT 0x0500 +# define _WIN32_IE 0x0501 +#endif + +#ifdef _DEBUG +# define _STLP_DEBUG 1 +#endif + +#ifndef _WIN64 + #define _USE_32BIT_TIME_T +#endif + +#define _STLP_DONT_USE_SHORT_STRING_OPTIM 1 // Uses small string buffer, so it saves memory for a lot of strings +#define _STLP_USE_PTR_SPECIALIZATIONS 1 // Reduces some code bloat +#define _STLP_USE_TEMPLATE_EXPRESSION 1 // Speeds up string concatenation +#define _STLP_NO_ANACHRONISMS 1 + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "CriticalSection.h" +#include "TigerHash.h" +#include "Version.h" +#include "resource.h" + +#ifdef _DEBUG + +inline void _cdecl debugTrace(const char* format, ...) +{ + va_list args; + va_start(args, format); + + char buf[512]; + + mir_vsnprintf(buf, sizeof(buf), format, args); + OutputDebugStringA(buf); + va_end(args); +} + +# define debug debugTrace +#define assert(exp) \ +do { if (!(exp)) { \ + debug("Assertion hit in %s(%d): " #exp "\n", __FILE__, __LINE__); \ + if(1 == _CrtDbgReport(_CRT_ASSERT, __FILE__, __LINE__, NULL, #exp)) \ +_CrtDbgBreak(); } } while(false) + +#else +# define debug +# define assert +#endif + + -- cgit v1.2.3