From f82091b2af907fb1d120c305da75c57b09cb0e7b Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Fri, 5 Sep 2014 12:08:52 +0000 Subject: SkypeKit based Skype plugin is moved to deprecated and will be deleted from Plugins folder by PluginUpdater git-svn-id: http://svn.miranda-ng.org/main/trunk@10372 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/!Deprecated/Skype/Skype_10.vcxproj | 284 ++++ plugins/!Deprecated/Skype/Skype_10.vcxproj.filters | 219 +++ plugins/!Deprecated/Skype/Skype_12.vcxproj | 286 ++++ plugins/!Deprecated/Skype/Skype_12.vcxproj.filters | 219 +++ plugins/!Deprecated/Skype/docs/readme.txt | 44 + plugins/!Deprecated/Skype/docs/todo_list.txt | 4 + plugins/!Deprecated/Skype/keypacker/aes/aes.c | 765 +++++++++ plugins/!Deprecated/Skype/keypacker/aes/aes.h | 24 + plugins/!Deprecated/Skype/keypacker/keypacker.cpp | 222 +++ .../!Deprecated/Skype/keypacker/keypacker_10.sln | 23 + .../Skype/keypacker/keypacker_10.vcxproj | 79 + .../Skype/keypacker/keypacker_10.vcxproj.filters | 27 + .../!Deprecated/Skype/keypacker/keypacker_11.sln | 20 + .../Skype/keypacker/keypacker_12.vcxproj | 81 + .../Skype/keypacker/keypacker_12.vcxproj.filters | 27 + plugins/!Deprecated/Skype/keypacker/stdafx.h | 8 + .../proto_conn_skype/Proto_conn_Skype_10.vcxproj | 124 ++ .../Proto_conn_Skype_10.vcxproj.filters | 14 + .../proto_conn_skype/Proto_conn_Skype_12.vcxproj | 128 ++ .../Proto_conn_Skype_12.vcxproj.filters | 14 + .../!Deprecated/Skype/proto_conn_skype/res/1.ico | Bin 0 -> 1150 bytes .../!Deprecated/Skype/proto_conn_skype/res/2.ico | Bin 0 -> 1150 bytes .../!Deprecated/Skype/proto_conn_skype/res/3.ico | Bin 0 -> 1150 bytes .../Skype/proto_conn_skype/res/resource.rc | 34 + .../Skype/proto_skype/Proto_Skype_10.vcxproj | 131 ++ .../proto_skype/Proto_Skype_10.vcxproj.filters | 23 + .../Skype/proto_skype/Proto_Skype_12.vcxproj | 135 ++ .../proto_skype/Proto_Skype_12.vcxproj.filters | 23 + plugins/!Deprecated/Skype/proto_skype/res/Away.ico | Bin 0 -> 5430 bytes plugins/!Deprecated/Skype/proto_skype/res/DND.ico | Bin 0 -> 5430 bytes .../Skype/proto_skype/res/Invisible.ico | Bin 0 -> 5430 bytes .../!Deprecated/Skype/proto_skype/res/Offline.ico | Bin 0 -> 5430 bytes .../!Deprecated/Skype/proto_skype/res/Online.ico | Bin 0 -> 5430 bytes .../!Deprecated/Skype/proto_skype/res/Phone.ico | Bin 0 -> 5430 bytes .../Skype/proto_skype/res/Proto_Skype.rc | 74 + .../!Deprecated/Skype/proto_skype/src/resource.h | 21 + plugins/!Deprecated/Skype/res/Resource.rc | 492 ++++++ plugins/!Deprecated/Skype/res/Version.rc | 42 + plugins/!Deprecated/Skype/res/add_contacts.ico | Bin 0 -> 5430 bytes plugins/!Deprecated/Skype/res/block.ico | Bin 0 -> 5430 bytes plugins/!Deprecated/Skype/res/call.ico | Bin 0 -> 5430 bytes plugins/!Deprecated/Skype/res/conference.ico | Bin 0 -> 5430 bytes plugins/!Deprecated/Skype/res/contact.ico | Bin 0 -> 5430 bytes plugins/!Deprecated/Skype/res/delete.ico | Bin 0 -> 5430 bytes plugins/!Deprecated/Skype/res/send_contacts.ico | Bin 0 -> 5430 bytes plugins/!Deprecated/Skype/res/skype.ico | Bin 0 -> 5430 bytes plugins/!Deprecated/Skype/src/aes/aes.cpp | 493 ++++++ plugins/!Deprecated/Skype/src/aes/aes.h | 15 + plugins/!Deprecated/Skype/src/resource.h | 123 ++ plugins/!Deprecated/Skype/src/skype.cpp | 213 +++ plugins/!Deprecated/Skype/src/skype.h | 101 ++ plugins/!Deprecated/Skype/src/skype_account.cpp | 354 ++++ plugins/!Deprecated/Skype/src/skype_avatars.cpp | 196 +++ plugins/!Deprecated/Skype/src/skype_blocked.cpp | 369 +++++ plugins/!Deprecated/Skype/src/skype_bookmarks.cpp | 203 +++ plugins/!Deprecated/Skype/src/skype_chat.cpp | 1735 ++++++++++++++++++++ plugins/!Deprecated/Skype/src/skype_chat.h | 204 +++ plugins/!Deprecated/Skype/src/skype_contacts.cpp | 538 ++++++ plugins/!Deprecated/Skype/src/skype_database.cpp | 112 ++ plugins/!Deprecated/Skype/src/skype_dialogs.cpp | 859 ++++++++++ plugins/!Deprecated/Skype/src/skype_events.cpp | 284 ++++ plugins/!Deprecated/Skype/src/skype_hooks.cpp | 17 + plugins/!Deprecated/Skype/src/skype_icons.cpp | 66 + .../!Deprecated/Skype/src/skype_ignore_list.cpp | 271 +++ plugins/!Deprecated/Skype/src/skype_instances.cpp | 88 + plugins/!Deprecated/Skype/src/skype_menus.cpp | 268 +++ plugins/!Deprecated/Skype/src/skype_messages.cpp | 315 ++++ plugins/!Deprecated/Skype/src/skype_netlib.cpp | 22 + plugins/!Deprecated/Skype/src/skype_own_info.cpp | 136 ++ plugins/!Deprecated/Skype/src/skype_profile.cpp | 321 ++++ plugins/!Deprecated/Skype/src/skype_proto.cpp | 672 ++++++++ plugins/!Deprecated/Skype/src/skype_proto.h | 560 +++++++ plugins/!Deprecated/Skype/src/skype_runtime.cpp | 162 ++ plugins/!Deprecated/Skype/src/skype_services.cpp | 25 + plugins/!Deprecated/Skype/src/skype_settings.cpp | 141 ++ plugins/!Deprecated/Skype/src/skype_skype.cpp | 41 + plugins/!Deprecated/Skype/src/skype_transfers.cpp | 191 +++ plugins/!Deprecated/Skype/src/skype_utils.cpp | 542 ++++++ plugins/!Deprecated/Skype/src/skypekit/account.cpp | 32 + plugins/!Deprecated/Skype/src/skypekit/account.h | 20 + plugins/!Deprecated/Skype/src/skypekit/common.h | 8 + plugins/!Deprecated/Skype/src/skypekit/contact.cpp | 65 + plugins/!Deprecated/Skype/src/skypekit/contact.h | 21 + .../Skype/src/skypekit/conversation.cpp | 20 + .../!Deprecated/Skype/src/skypekit/conversation.h | 23 + plugins/!Deprecated/Skype/src/skypekit/group.cpp | 13 + plugins/!Deprecated/Skype/src/skypekit/group.h | 19 + plugins/!Deprecated/Skype/src/skypekit/message.cpp | 7 + plugins/!Deprecated/Skype/src/skypekit/message.h | 12 + .../!Deprecated/Skype/src/skypekit/participant.cpp | 27 + .../!Deprecated/Skype/src/skypekit/participant.h | 25 + plugins/!Deprecated/Skype/src/skypekit/search.cpp | 36 + plugins/!Deprecated/Skype/src/skypekit/search.h | 29 + .../!Deprecated/Skype/src/skypekit/transfer.cpp | 13 + plugins/!Deprecated/Skype/src/skypekit/transfer.h | 17 + plugins/!Deprecated/Skype/src/stdafx.cpp | 1 + plugins/!Deprecated/Skype/src/string_list.h | 61 + plugins/!Deprecated/Skype/src/version.h | 15 + plugins/PluginUpdater/src/DlgUpdate.cpp | 2 + 99 files changed, 13690 insertions(+) create mode 100644 plugins/!Deprecated/Skype/Skype_10.vcxproj create mode 100644 plugins/!Deprecated/Skype/Skype_10.vcxproj.filters create mode 100644 plugins/!Deprecated/Skype/Skype_12.vcxproj create mode 100644 plugins/!Deprecated/Skype/Skype_12.vcxproj.filters create mode 100644 plugins/!Deprecated/Skype/docs/readme.txt create mode 100644 plugins/!Deprecated/Skype/docs/todo_list.txt create mode 100644 plugins/!Deprecated/Skype/keypacker/aes/aes.c create mode 100644 plugins/!Deprecated/Skype/keypacker/aes/aes.h create mode 100644 plugins/!Deprecated/Skype/keypacker/keypacker.cpp create mode 100644 plugins/!Deprecated/Skype/keypacker/keypacker_10.sln create mode 100644 plugins/!Deprecated/Skype/keypacker/keypacker_10.vcxproj create mode 100644 plugins/!Deprecated/Skype/keypacker/keypacker_10.vcxproj.filters create mode 100644 plugins/!Deprecated/Skype/keypacker/keypacker_11.sln create mode 100644 plugins/!Deprecated/Skype/keypacker/keypacker_12.vcxproj create mode 100644 plugins/!Deprecated/Skype/keypacker/keypacker_12.vcxproj.filters create mode 100644 plugins/!Deprecated/Skype/keypacker/stdafx.h create mode 100644 plugins/!Deprecated/Skype/proto_conn_skype/Proto_conn_Skype_10.vcxproj create mode 100644 plugins/!Deprecated/Skype/proto_conn_skype/Proto_conn_Skype_10.vcxproj.filters create mode 100644 plugins/!Deprecated/Skype/proto_conn_skype/Proto_conn_Skype_12.vcxproj create mode 100644 plugins/!Deprecated/Skype/proto_conn_skype/Proto_conn_Skype_12.vcxproj.filters create mode 100644 plugins/!Deprecated/Skype/proto_conn_skype/res/1.ico create mode 100644 plugins/!Deprecated/Skype/proto_conn_skype/res/2.ico create mode 100644 plugins/!Deprecated/Skype/proto_conn_skype/res/3.ico create mode 100644 plugins/!Deprecated/Skype/proto_conn_skype/res/resource.rc create mode 100644 plugins/!Deprecated/Skype/proto_skype/Proto_Skype_10.vcxproj create mode 100644 plugins/!Deprecated/Skype/proto_skype/Proto_Skype_10.vcxproj.filters create mode 100644 plugins/!Deprecated/Skype/proto_skype/Proto_Skype_12.vcxproj create mode 100644 plugins/!Deprecated/Skype/proto_skype/Proto_Skype_12.vcxproj.filters create mode 100644 plugins/!Deprecated/Skype/proto_skype/res/Away.ico create mode 100644 plugins/!Deprecated/Skype/proto_skype/res/DND.ico create mode 100644 plugins/!Deprecated/Skype/proto_skype/res/Invisible.ico create mode 100644 plugins/!Deprecated/Skype/proto_skype/res/Offline.ico create mode 100644 plugins/!Deprecated/Skype/proto_skype/res/Online.ico create mode 100644 plugins/!Deprecated/Skype/proto_skype/res/Phone.ico create mode 100644 plugins/!Deprecated/Skype/proto_skype/res/Proto_Skype.rc create mode 100644 plugins/!Deprecated/Skype/proto_skype/src/resource.h create mode 100644 plugins/!Deprecated/Skype/res/Resource.rc create mode 100644 plugins/!Deprecated/Skype/res/Version.rc create mode 100644 plugins/!Deprecated/Skype/res/add_contacts.ico create mode 100644 plugins/!Deprecated/Skype/res/block.ico create mode 100644 plugins/!Deprecated/Skype/res/call.ico create mode 100644 plugins/!Deprecated/Skype/res/conference.ico create mode 100644 plugins/!Deprecated/Skype/res/contact.ico create mode 100644 plugins/!Deprecated/Skype/res/delete.ico create mode 100644 plugins/!Deprecated/Skype/res/send_contacts.ico create mode 100644 plugins/!Deprecated/Skype/res/skype.ico create mode 100644 plugins/!Deprecated/Skype/src/aes/aes.cpp create mode 100644 plugins/!Deprecated/Skype/src/aes/aes.h create mode 100644 plugins/!Deprecated/Skype/src/resource.h create mode 100644 plugins/!Deprecated/Skype/src/skype.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype.h create mode 100644 plugins/!Deprecated/Skype/src/skype_account.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_avatars.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_blocked.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_bookmarks.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_chat.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_chat.h create mode 100644 plugins/!Deprecated/Skype/src/skype_contacts.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_database.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_dialogs.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_events.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_hooks.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_icons.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_ignore_list.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_instances.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_menus.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_messages.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_netlib.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_own_info.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_profile.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_proto.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_proto.h create mode 100644 plugins/!Deprecated/Skype/src/skype_runtime.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_services.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_settings.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_skype.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_transfers.cpp create mode 100644 plugins/!Deprecated/Skype/src/skype_utils.cpp create mode 100644 plugins/!Deprecated/Skype/src/skypekit/account.cpp create mode 100644 plugins/!Deprecated/Skype/src/skypekit/account.h create mode 100644 plugins/!Deprecated/Skype/src/skypekit/common.h create mode 100644 plugins/!Deprecated/Skype/src/skypekit/contact.cpp create mode 100644 plugins/!Deprecated/Skype/src/skypekit/contact.h create mode 100644 plugins/!Deprecated/Skype/src/skypekit/conversation.cpp create mode 100644 plugins/!Deprecated/Skype/src/skypekit/conversation.h create mode 100644 plugins/!Deprecated/Skype/src/skypekit/group.cpp create mode 100644 plugins/!Deprecated/Skype/src/skypekit/group.h create mode 100644 plugins/!Deprecated/Skype/src/skypekit/message.cpp create mode 100644 plugins/!Deprecated/Skype/src/skypekit/message.h create mode 100644 plugins/!Deprecated/Skype/src/skypekit/participant.cpp create mode 100644 plugins/!Deprecated/Skype/src/skypekit/participant.h create mode 100644 plugins/!Deprecated/Skype/src/skypekit/search.cpp create mode 100644 plugins/!Deprecated/Skype/src/skypekit/search.h create mode 100644 plugins/!Deprecated/Skype/src/skypekit/transfer.cpp create mode 100644 plugins/!Deprecated/Skype/src/skypekit/transfer.h create mode 100644 plugins/!Deprecated/Skype/src/stdafx.cpp create mode 100644 plugins/!Deprecated/Skype/src/string_list.h create mode 100644 plugins/!Deprecated/Skype/src/version.h (limited to 'plugins') diff --git a/plugins/!Deprecated/Skype/Skype_10.vcxproj b/plugins/!Deprecated/Skype/Skype_10.vcxproj new file mode 100644 index 0000000000..763fcd9f65 --- /dev/null +++ b/plugins/!Deprecated/Skype/Skype_10.vcxproj @@ -0,0 +1,284 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {F5282DBC-756B-4071-B186-3E82C0E8E1F7} + Skype + + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + false + true + Unicode + + + DynamicLibrary + false + true + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.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 + + + + Level3 + Disabled + _DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + ..\..\include;..\..\plugins\ExternalAPI;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\api;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\ipc;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\types;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading\win;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\VideoBuffers;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\platform\se;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include\openssl;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\ctaocrypt\include;%(AdditionalIncludeDirectories) + false + true + 4996;%(DisableSpecificWarnings) + MultiThreadedDebugDLL + $(IntDir)\%(RelativeDir)\ + skype.h + Use + + + Windows + true + $(ProfileDir)..\..\bin10\lib;$(ProfileDir)..\..\..\miranda-private-keys\SkypeKit\SDK\lib\Debug + $(IntDir)$(TargetName).lib + comctl32.lib;Shlwapi.lib;Ws2_32.lib;Advapi32.lib;skypekit-cyassl_lib_x86.lib;skypekit-cppwrapper_2_lib_x86.lib;%(AdditionalDependencies) + false + /PDBALTPATH:%_PDB% %(AdditionalOptions) + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + Level3 + Disabled + _DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + ..\..\include;..\..\plugins\ExternalAPI;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\api;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\ipc;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\types;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading\win;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\VideoBuffers;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\platform\se;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include\openssl;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\ctaocrypt\include;%(AdditionalIncludeDirectories) + false + true + 4996;%(DisableSpecificWarnings) + MultiThreadedDebugDLL + $(IntDir)\%(RelativeDir)\ + Use + skype.h + + + Windows + true + $(ProfileDir)..\..\bin10\lib;$(ProfileDir)..\..\..\miranda-private-keys\SkypeKit\SDK\lib\Debug + $(IntDir)$(TargetName).lib + comctl32.lib;Shlwapi.lib;Ws2_32.lib;Advapi32.lib;skypekit-cyassl_lib_x64.lib;skypekit-cppwrapper_2_lib_x64.lib;%(AdditionalDependencies) + false + /PDBALTPATH:%_PDB% %(AdditionalOptions) + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + Level3 + Full + true + true + NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + ..\..\include;..\..\plugins\ExternalAPI;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\api;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\ipc;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\types;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading\win;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\VideoBuffers;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\platform\se;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include\openssl;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\ctaocrypt\include;%(AdditionalIncludeDirectories) + 4996;%(DisableSpecificWarnings) + $(IntDir)\%(RelativeDir)\ + Use + skype.h + + + Windows + true + true + true + false + /PDBALTPATH:%_PDB% + comctl32.lib;Shlwapi.lib;Ws2_32.lib;Advapi32.lib;skypekit-cyassl_lib_x86.lib;skypekit-cppwrapper_2_lib_x86.lib;%(AdditionalDependencies) + $(ProfileDir)..\..\bin10\lib;$(ProfileDir)..\..\..\miranda-private-keys\SkypeKit\SDK\lib\Release + $(IntDir)$(TargetName).lib + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + Level3 + Full + true + true + NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + ..\..\include;..\..\plugins\ExternalAPI;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\api;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\ipc;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\types;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading\win;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\VideoBuffers;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\platform\se;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include\openssl;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\ctaocrypt\include;%(AdditionalIncludeDirectories) + 4996;%(DisableSpecificWarnings) + $(IntDir)\%(RelativeDir)\ + Use + skype.h + + + Windows + true + true + true + false + /PDBALTPATH:%_PDB% + comctl32.lib;Shlwapi.lib;Ws2_32.lib;Advapi32.lib;skypekit-cyassl_lib_x64.lib;skypekit-cppwrapper_2_lib_x64.lib;%(AdditionalDependencies) + $(ProfileDir)..\..\bin10\lib;$(ProfileDir)..\..\..\miranda-private-keys\SkypeKit\SDK\lib\Release + $(IntDir)$(TargetName).lib + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + + + + + + + + + + + + + + + + + + + NotUsing + + + + ..\skype.h + + + ..\skype.h + + + ..\skype.h + + + ..\skype.h + + + ..\skype.h + + + ..\skype.h + + + ..\skype.h + + + ..\skype.h + + + + + + + + + + + + + + + + + + + + + + + + + Create + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/Skype_10.vcxproj.filters b/plugins/!Deprecated/Skype/Skype_10.vcxproj.filters new file mode 100644 index 0000000000..f44a2b7302 --- /dev/null +++ b/plugins/!Deprecated/Skype/Skype_10.vcxproj.filters @@ -0,0 +1,219 @@ + + + + + {13e9b105-554f-4080-b7de-8adf0f43b9f6} + + + {b14a0070-da9c-49e8-8a47-d93df5eed672} + + + {901463af-0f59-4125-b874-1662b095d403} + + + {092ce045-936d-405a-abaf-200a3abba159} + + + {f1aeb5a2-f105-4b8c-a656-08dbe6dc7b2e} + + + {a39a08d1-b79a-47eb-8433-1351f9f01401} + + + {171bef99-1ab9-424f-835d-9e47ab62365c} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\skypekit + + + Source Files\skypekit + + + Source Files\skypekit + + + Source Files\skypekit + + + Source Files\skypekit + + + Source Files\skypekit + + + Source Files\skypekit + + + Source Files\skypekit + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files\skypekit + + + Header Files\skypekit + + + Header Files\skypekit + + + Header Files\skypekit + + + Header Files\skypekit + + + Header Files\skypekit + + + Header Files\skypekit + + + Header Files\skypekit + + + Header Files\skypekit + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + + + Resource Files\Bin + + + Resource Files\Bin + + + + + Resource Files\Icons + + + Resource Files\Icons + + + Resource Files\Icons + + + Resource Files\Icons + + + Resource Files\Icons + + + Resource Files\Icons + + + Resource Files\Icons + + + Resource Files\Icons + + + \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/Skype_12.vcxproj b/plugins/!Deprecated/Skype/Skype_12.vcxproj new file mode 100644 index 0000000000..2106fee3ae --- /dev/null +++ b/plugins/!Deprecated/Skype/Skype_12.vcxproj @@ -0,0 +1,286 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {F5282DBC-756B-4071-B186-3E82C0E8E1F7} + Skype + + + + DynamicLibrary + true + Unicode + v120_xp + + + DynamicLibrary + true + Unicode + v120_xp + + + DynamicLibrary + false + true + Unicode + v120_xp + + + DynamicLibrary + false + true + Unicode + v120_xp + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.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 + + + + Level3 + Disabled + _DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + ..\..\include;..\..\plugins\ExternalAPI;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\api;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\ipc;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\types;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading\win;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\VideoBuffers;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\platform\se;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include\openssl;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\ctaocrypt\include;%(AdditionalIncludeDirectories) + false + true + 4996;%(DisableSpecificWarnings) + MultiThreadedDebugDLL + $(IntDir)\%(RelativeDir)\ + skype.h + Use + + + Windows + true + $(ProfileDir)..\..\bin12\lib;$(ProfileDir)..\..\..\miranda-private-keys\SkypeKit\SDK\lib2013\Debug + $(IntDir)$(TargetName).lib + comctl32.lib;Shlwapi.lib;Ws2_32.lib;Advapi32.lib;skypekit-cyassl_lib_x86.lib;skypekit-cppwrapper_2_lib_x86.lib;%(AdditionalDependencies) + false + /PDBALTPATH:%_PDB% %(AdditionalOptions) + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + Level3 + Disabled + _DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + ..\..\include;..\..\plugins\ExternalAPI;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\api;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\ipc;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\types;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading\win;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\VideoBuffers;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\platform\se;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include\openssl;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\ctaocrypt\include;%(AdditionalIncludeDirectories) + false + true + 4996;%(DisableSpecificWarnings) + MultiThreadedDebugDLL + $(IntDir)\%(RelativeDir)\ + Use + skype.h + + + Windows + true + $(ProfileDir)..\..\bin12\lib;$(ProfileDir)..\..\..\miranda-private-keys\SkypeKit\SDK\lib2013\Debug + $(IntDir)$(TargetName).lib + comctl32.lib;Shlwapi.lib;Ws2_32.lib;Advapi32.lib;skypekit-cyassl_lib_x64.lib;skypekit-cppwrapper_2_lib_x64.lib;%(AdditionalDependencies) + false + /PDBALTPATH:%_PDB% %(AdditionalOptions) + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + Level3 + Full + true + true + NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + ..\..\include;..\..\plugins\ExternalAPI;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\api;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\ipc;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\types;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading\win;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\VideoBuffers;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\platform\se;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include\openssl;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\ctaocrypt\include;%(AdditionalIncludeDirectories) + 4996;%(DisableSpecificWarnings) + $(IntDir)\%(RelativeDir)\ + Use + skype.h + + + Windows + true + true + true + false + comctl32.lib;Shlwapi.lib;Ws2_32.lib;Advapi32.lib;skypekit-cyassl_lib_x86.lib;skypekit-cppwrapper_2_lib_x86.lib;%(AdditionalDependencies) + $(ProfileDir)..\..\bin12\lib;$(ProfileDir)..\..\..\miranda-private-keys\SkypeKit\SDK\lib2013\Release + $(IntDir)$(TargetName).lib + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + Level3 + Full + true + true + NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + ..\..\include;..\..\plugins\ExternalAPI;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\api;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\ipc;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\types;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading;..\..\..\miranda-private-keys\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading\win;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\VideoBuffers;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\platform\se;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include\openssl;..\..\..\miranda-private-keys\SkypeKit\SDK\ipc\cpp\ssl\cyassl\ctaocrypt\include;%(AdditionalIncludeDirectories) + 4996;%(DisableSpecificWarnings) + $(IntDir)\%(RelativeDir)\ + Use + skype.h + + + Windows + true + true + true + false + comctl32.lib;Shlwapi.lib;Ws2_32.lib;Advapi32.lib;skypekit-cyassl_lib_x64.lib;skypekit-cppwrapper_2_lib_x64.lib;%(AdditionalDependencies) + $(ProfileDir)..\..\bin12\lib;$(ProfileDir)..\..\..\miranda-private-keys\SkypeKit\SDK\lib2013\Release + $(IntDir)$(TargetName).lib + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + + + + + + + + + + + + + + + + + + + NotUsing + + + + ..\skype.h + + + ..\skype.h + + + ..\skype.h + + + ..\skype.h + + + ..\skype.h + + + ..\skype.h + + + ..\skype.h + + + ..\skype.h + + + + + + + + + + + + + + + + + + + + + + + + + Create + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/Skype_12.vcxproj.filters b/plugins/!Deprecated/Skype/Skype_12.vcxproj.filters new file mode 100644 index 0000000000..f44a2b7302 --- /dev/null +++ b/plugins/!Deprecated/Skype/Skype_12.vcxproj.filters @@ -0,0 +1,219 @@ + + + + + {13e9b105-554f-4080-b7de-8adf0f43b9f6} + + + {b14a0070-da9c-49e8-8a47-d93df5eed672} + + + {901463af-0f59-4125-b874-1662b095d403} + + + {092ce045-936d-405a-abaf-200a3abba159} + + + {f1aeb5a2-f105-4b8c-a656-08dbe6dc7b2e} + + + {a39a08d1-b79a-47eb-8433-1351f9f01401} + + + {171bef99-1ab9-424f-835d-9e47ab62365c} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\skypekit + + + Source Files\skypekit + + + Source Files\skypekit + + + Source Files\skypekit + + + Source Files\skypekit + + + Source Files\skypekit + + + Source Files\skypekit + + + Source Files\skypekit + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files\skypekit + + + Header Files\skypekit + + + Header Files\skypekit + + + Header Files\skypekit + + + Header Files\skypekit + + + Header Files\skypekit + + + Header Files\skypekit + + + Header Files\skypekit + + + Header Files\skypekit + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + + + Resource Files\Bin + + + Resource Files\Bin + + + + + Resource Files\Icons + + + Resource Files\Icons + + + Resource Files\Icons + + + Resource Files\Icons + + + Resource Files\Icons + + + Resource Files\Icons + + + Resource Files\Icons + + + Resource Files\Icons + + + \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/docs/readme.txt b/plugins/!Deprecated/Skype/docs/readme.txt new file mode 100644 index 0000000000..8a6e71cea5 --- /dev/null +++ b/plugins/!Deprecated/Skype/docs/readme.txt @@ -0,0 +1,44 @@ +how to compile skypekit libs: +1) download skypekit from skype site. +2) create folders structure like this: + d:\MirandaNG + d:\SkypeKit + d:\SkypeKit\SDK +3) extract skypekit archive in d:\SkypeKit\SDK. You need have structure like this: + d:\SkypeKit\SDK\bin + d:\SkypeKit\SDK\buildfiles + d:\SkypeKit\SDK\examples + etc. +4) download and install cmake from here: http://www.cmake.org/ (Note: when installing cmake make sure that it registers in system PATH). +5) start d:\SkypeKit\SDK\build_all.bat and wait when it finished. Note: if you have more than one version of MSVC installed - cmake will use the one that was installed last. +You can specify the compiler by editing build_all.bat and adding '-G' key to command line (cmake -G "Visual Studio 10" - for MSVC 2010). +6) go to d:\SkypeKit\SDK\build_all_cmake\build_cmake\ and copy skypekit.sln to skypekit_libs.sln +7) run skypekit_libs.sln and remove all not needed projects, you need save only: + reference_opengl_lib + skypekit-avtransport + skypekit-cppwrapper_2_lib + skypekit-cyassl_lib + skypekit-ipccpp + skypekit-videobuffers + skypekit-voicepcm +8) edit each project: + 8.1) remove not needed configurations: + select solution skypekit_libs + open Configuration Manager + remove MinSizeRel and RelWithDebInfo configurations from solution and each projects + 8.2) add x64 platform: + add new platform x64 with coping settings from Win32 select item create new platform for projects + 8.3) change in each projects lib output name by adding _x86 or _x64 at the end. depends on selected platform + 8.3.1) need to copy Output directory from Win32 configuration and for Win32 add Intermediate directory _x86 and for x64 add _x64 + 8.3.2) for vc2012 need to set Platform Toolset to Visual Studio 2012 - Windows XP (v110_xp) + 8.3.3) for x64 platform edit Preprocessor by changing 32 to 64 + 8.3.4) edit C/C++-Output files- pdb file name. I set default for parent name +9) try to compile full solution + +you need to create Original_key.h with defining like that +#define MY_KEY "MY_KEY" +then you need create keypair.bin file. for this you need: +1) download keypair.crt from skype site and put in to d:\SkypeKit\keypair.crt +2) compile keypacker utility from here: d:\MNG orig\protocols\Skype\keypacker\. No difference debug or release. +3) copy keypacker.exe to d:\SkypeKit\ and run it. Utility create 3 files: keypair.bin and keypair.crt.decrypted and key.h +Now you can compile Skype protocol. \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/docs/todo_list.txt b/plugins/!Deprecated/Skype/docs/todo_list.txt new file mode 100644 index 0000000000..581db42afa --- /dev/null +++ b/plugins/!Deprecated/Skype/docs/todo_list.txt @@ -0,0 +1,4 @@ +Features: +- voice +- video +- run skype runtime from resources directly \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/keypacker/aes/aes.c b/plugins/!Deprecated/Skype/keypacker/aes/aes.c new file mode 100644 index 0000000000..7e15f1547b --- /dev/null +++ b/plugins/!Deprecated/Skype/keypacker/aes/aes.c @@ -0,0 +1,765 @@ +/* + * FIPS-197 compliant AES implementation + * + * Copyright (C) 2001-2004 Christophe Devine + * + * 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 "aes.h" + +/* uncomment the following line to run the test suite */ + +/* #define TEST */ + +/* uncomment the following line to use pre-computed tables */ +/* otherwise the tables will be generated at the first run */ + +/* #define FIXED_TABLES */ + +#ifndef FIXED_TABLES + +/* forward S-box & tables */ + +uint32 FSb[256]; +uint32 FT0[256]; +uint32 FT1[256]; +uint32 FT2[256]; +uint32 FT3[256]; + +/* reverse S-box & tables */ + +uint32 RSb[256]; +uint32 RT0[256]; +uint32 RT1[256]; +uint32 RT2[256]; +uint32 RT3[256]; + +/* round constants */ + +uint32 RCON[10]; + +/* tables generation flag */ + +int do_init = 1; + +/* tables generation routine */ + +#define ROTR8(x) ( ( ( x << 24 ) & 0xFFFFFFFF ) | \ + ( ( x & 0xFFFFFFFF ) >> 8 ) ) + +#define XTIME(x) ( ( x << 1 ) ^ ( ( x & 0x80 ) ? 0x1B : 0x00 ) ) +#define MUL(x,y) ( ( x && y ) ? pow[(log[x] + log[y]) % 255] : 0 ) + +void aes_gen_tables( void ) +{ + int i; + uint8 x, y; + uint8 pow[256]; + uint8 log[256]; + + /* compute pow and log tables over GF(2^8) */ + + for( i = 0, x = 1; i < 256; i++, x ^= XTIME( x ) ) + { + pow[i] = x; + log[x] = i; + } + + /* calculate the round constants */ + + for( i = 0, x = 1; i < 10; i++, x = XTIME( x ) ) + { + RCON[i] = (uint32) x << 24; + } + + /* generate the forward and reverse S-boxes */ + + FSb[0x00] = 0x63; + RSb[0x63] = 0x00; + + for( i = 1; i < 256; i++ ) + { + x = pow[255 - log[i]]; + + y = x; y = ( y << 1 ) | ( y >> 7 ); + x ^= y; y = ( y << 1 ) | ( y >> 7 ); + x ^= y; y = ( y << 1 ) | ( y >> 7 ); + x ^= y; y = ( y << 1 ) | ( y >> 7 ); + x ^= y ^ 0x63; + + FSb[i] = x; + RSb[x] = i; + } + + /* generate the forward and reverse tables */ + + for( i = 0; i < 256; i++ ) + { + x = (unsigned char) FSb[i]; y = XTIME( x ); + + FT0[i] = (uint32) ( x ^ y ) ^ + ( (uint32) x << 8 ) ^ + ( (uint32) x << 16 ) ^ + ( (uint32) y << 24 ); + + FT0[i] &= 0xFFFFFFFF; + + FT1[i] = ROTR8( FT0[i] ); + FT2[i] = ROTR8( FT1[i] ); + FT3[i] = ROTR8( FT2[i] ); + + y = (unsigned char) RSb[i]; + + RT0[i] = ( (uint32) MUL( 0x0B, y ) ) ^ + ( (uint32) MUL( 0x0D, y ) << 8 ) ^ + ( (uint32) MUL( 0x09, y ) << 16 ) ^ + ( (uint32) MUL( 0x0E, y ) << 24 ); + + RT0[i] &= 0xFFFFFFFF; + + RT1[i] = ROTR8( RT0[i] ); + RT2[i] = ROTR8( RT1[i] ); + RT3[i] = ROTR8( RT2[i] ); + } +} + +#else + +/* forward S-box */ + +static const uint32 FSb[256] = +{ + 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, + 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, + 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, + 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, + 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, + 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15, + 0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, + 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75, + 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0, + 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84, + 0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B, + 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF, + 0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85, + 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8, + 0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5, + 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2, + 0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17, + 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73, + 0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88, + 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB, + 0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C, + 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79, + 0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9, + 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08, + 0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, + 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A, + 0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E, + 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E, + 0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94, + 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF, + 0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, + 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16 +}; + +/* forward tables */ + +#define FT \ +\ + V(C6,63,63,A5), V(F8,7C,7C,84), V(EE,77,77,99), V(F6,7B,7B,8D), \ + V(FF,F2,F2,0D), V(D6,6B,6B,BD), V(DE,6F,6F,B1), V(91,C5,C5,54), \ + V(60,30,30,50), V(02,01,01,03), V(CE,67,67,A9), V(56,2B,2B,7D), \ + V(E7,FE,FE,19), V(B5,D7,D7,62), V(4D,AB,AB,E6), V(EC,76,76,9A), \ + V(8F,CA,CA,45), V(1F,82,82,9D), V(89,C9,C9,40), V(FA,7D,7D,87), \ + V(EF,FA,FA,15), V(B2,59,59,EB), V(8E,47,47,C9), V(FB,F0,F0,0B), \ + V(41,AD,AD,EC), V(B3,D4,D4,67), V(5F,A2,A2,FD), V(45,AF,AF,EA), \ + V(23,9C,9C,BF), V(53,A4,A4,F7), V(E4,72,72,96), V(9B,C0,C0,5B), \ + V(75,B7,B7,C2), V(E1,FD,FD,1C), V(3D,93,93,AE), V(4C,26,26,6A), \ + V(6C,36,36,5A), V(7E,3F,3F,41), V(F5,F7,F7,02), V(83,CC,CC,4F), \ + V(68,34,34,5C), V(51,A5,A5,F4), V(D1,E5,E5,34), V(F9,F1,F1,08), \ + V(E2,71,71,93), V(AB,D8,D8,73), V(62,31,31,53), V(2A,15,15,3F), \ + V(08,04,04,0C), V(95,C7,C7,52), V(46,23,23,65), V(9D,C3,C3,5E), \ + V(30,18,18,28), V(37,96,96,A1), V(0A,05,05,0F), V(2F,9A,9A,B5), \ + V(0E,07,07,09), V(24,12,12,36), V(1B,80,80,9B), V(DF,E2,E2,3D), \ + V(CD,EB,EB,26), V(4E,27,27,69), V(7F,B2,B2,CD), V(EA,75,75,9F), \ + V(12,09,09,1B), V(1D,83,83,9E), V(58,2C,2C,74), V(34,1A,1A,2E), \ + V(36,1B,1B,2D), V(DC,6E,6E,B2), V(B4,5A,5A,EE), V(5B,A0,A0,FB), \ + V(A4,52,52,F6), V(76,3B,3B,4D), V(B7,D6,D6,61), V(7D,B3,B3,CE), \ + V(52,29,29,7B), V(DD,E3,E3,3E), V(5E,2F,2F,71), V(13,84,84,97), \ + V(A6,53,53,F5), V(B9,D1,D1,68), V(00,00,00,00), V(C1,ED,ED,2C), \ + V(40,20,20,60), V(E3,FC,FC,1F), V(79,B1,B1,C8), V(B6,5B,5B,ED), \ + V(D4,6A,6A,BE), V(8D,CB,CB,46), V(67,BE,BE,D9), V(72,39,39,4B), \ + V(94,4A,4A,DE), V(98,4C,4C,D4), V(B0,58,58,E8), V(85,CF,CF,4A), \ + V(BB,D0,D0,6B), V(C5,EF,EF,2A), V(4F,AA,AA,E5), V(ED,FB,FB,16), \ + V(86,43,43,C5), V(9A,4D,4D,D7), V(66,33,33,55), V(11,85,85,94), \ + V(8A,45,45,CF), V(E9,F9,F9,10), V(04,02,02,06), V(FE,7F,7F,81), \ + V(A0,50,50,F0), V(78,3C,3C,44), V(25,9F,9F,BA), V(4B,A8,A8,E3), \ + V(A2,51,51,F3), V(5D,A3,A3,FE), V(80,40,40,C0), V(05,8F,8F,8A), \ + V(3F,92,92,AD), V(21,9D,9D,BC), V(70,38,38,48), V(F1,F5,F5,04), \ + V(63,BC,BC,DF), V(77,B6,B6,C1), V(AF,DA,DA,75), V(42,21,21,63), \ + V(20,10,10,30), V(E5,FF,FF,1A), V(FD,F3,F3,0E), V(BF,D2,D2,6D), \ + V(81,CD,CD,4C), V(18,0C,0C,14), V(26,13,13,35), V(C3,EC,EC,2F), \ + V(BE,5F,5F,E1), V(35,97,97,A2), V(88,44,44,CC), V(2E,17,17,39), \ + V(93,C4,C4,57), V(55,A7,A7,F2), V(FC,7E,7E,82), V(7A,3D,3D,47), \ + V(C8,64,64,AC), V(BA,5D,5D,E7), V(32,19,19,2B), V(E6,73,73,95), \ + V(C0,60,60,A0), V(19,81,81,98), V(9E,4F,4F,D1), V(A3,DC,DC,7F), \ + V(44,22,22,66), V(54,2A,2A,7E), V(3B,90,90,AB), V(0B,88,88,83), \ + V(8C,46,46,CA), V(C7,EE,EE,29), V(6B,B8,B8,D3), V(28,14,14,3C), \ + V(A7,DE,DE,79), V(BC,5E,5E,E2), V(16,0B,0B,1D), V(AD,DB,DB,76), \ + V(DB,E0,E0,3B), V(64,32,32,56), V(74,3A,3A,4E), V(14,0A,0A,1E), \ + V(92,49,49,DB), V(0C,06,06,0A), V(48,24,24,6C), V(B8,5C,5C,E4), \ + V(9F,C2,C2,5D), V(BD,D3,D3,6E), V(43,AC,AC,EF), V(C4,62,62,A6), \ + V(39,91,91,A8), V(31,95,95,A4), V(D3,E4,E4,37), V(F2,79,79,8B), \ + V(D5,E7,E7,32), V(8B,C8,C8,43), V(6E,37,37,59), V(DA,6D,6D,B7), \ + V(01,8D,8D,8C), V(B1,D5,D5,64), V(9C,4E,4E,D2), V(49,A9,A9,E0), \ + V(D8,6C,6C,B4), V(AC,56,56,FA), V(F3,F4,F4,07), V(CF,EA,EA,25), \ + V(CA,65,65,AF), V(F4,7A,7A,8E), V(47,AE,AE,E9), V(10,08,08,18), \ + V(6F,BA,BA,D5), V(F0,78,78,88), V(4A,25,25,6F), V(5C,2E,2E,72), \ + V(38,1C,1C,24), V(57,A6,A6,F1), V(73,B4,B4,C7), V(97,C6,C6,51), \ + V(CB,E8,E8,23), V(A1,DD,DD,7C), V(E8,74,74,9C), V(3E,1F,1F,21), \ + V(96,4B,4B,DD), V(61,BD,BD,DC), V(0D,8B,8B,86), V(0F,8A,8A,85), \ + V(E0,70,70,90), V(7C,3E,3E,42), V(71,B5,B5,C4), V(CC,66,66,AA), \ + V(90,48,48,D8), V(06,03,03,05), V(F7,F6,F6,01), V(1C,0E,0E,12), \ + V(C2,61,61,A3), V(6A,35,35,5F), V(AE,57,57,F9), V(69,B9,B9,D0), \ + V(17,86,86,91), V(99,C1,C1,58), V(3A,1D,1D,27), V(27,9E,9E,B9), \ + V(D9,E1,E1,38), V(EB,F8,F8,13), V(2B,98,98,B3), V(22,11,11,33), \ + V(D2,69,69,BB), V(A9,D9,D9,70), V(07,8E,8E,89), V(33,94,94,A7), \ + V(2D,9B,9B,B6), V(3C,1E,1E,22), V(15,87,87,92), V(C9,E9,E9,20), \ + V(87,CE,CE,49), V(AA,55,55,FF), V(50,28,28,78), V(A5,DF,DF,7A), \ + V(03,8C,8C,8F), V(59,A1,A1,F8), V(09,89,89,80), V(1A,0D,0D,17), \ + V(65,BF,BF,DA), V(D7,E6,E6,31), V(84,42,42,C6), V(D0,68,68,B8), \ + V(82,41,41,C3), V(29,99,99,B0), V(5A,2D,2D,77), V(1E,0F,0F,11), \ + V(7B,B0,B0,CB), V(A8,54,54,FC), V(6D,BB,BB,D6), V(2C,16,16,3A) + +#define V(a,b,c,d) 0x##a##b##c##d +static const uint32 FT0[256] = { FT }; +#undef V + +#define V(a,b,c,d) 0x##d##a##b##c +static const uint32 FT1[256] = { FT }; +#undef V + +#define V(a,b,c,d) 0x##c##d##a##b +static const uint32 FT2[256] = { FT }; +#undef V + +#define V(a,b,c,d) 0x##b##c##d##a +static const uint32 FT3[256] = { FT }; +#undef V + +#undef FT + +/* reverse S-box */ + +static const uint32 RSb[256] = +{ + 0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, + 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB, + 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87, + 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB, + 0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D, + 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E, + 0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2, + 0x76, 0x5B, 0xA2, 0x49, 0x6D, 0x8B, 0xD1, 0x25, + 0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16, + 0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92, + 0x6C, 0x70, 0x48, 0x50, 0xFD, 0xED, 0xB9, 0xDA, + 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84, + 0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A, + 0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06, + 0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02, + 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B, + 0x3A, 0x91, 0x11, 0x41, 0x4F, 0x67, 0xDC, 0xEA, + 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73, + 0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85, + 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E, + 0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89, + 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B, + 0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20, + 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4, + 0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, + 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F, + 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, + 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF, + 0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0, + 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61, + 0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, + 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D +}; + +/* reverse tables */ + +#define RT \ +\ + V(51,F4,A7,50), V(7E,41,65,53), V(1A,17,A4,C3), V(3A,27,5E,96), \ + V(3B,AB,6B,CB), V(1F,9D,45,F1), V(AC,FA,58,AB), V(4B,E3,03,93), \ + V(20,30,FA,55), V(AD,76,6D,F6), V(88,CC,76,91), V(F5,02,4C,25), \ + V(4F,E5,D7,FC), V(C5,2A,CB,D7), V(26,35,44,80), V(B5,62,A3,8F), \ + V(DE,B1,5A,49), V(25,BA,1B,67), V(45,EA,0E,98), V(5D,FE,C0,E1), \ + V(C3,2F,75,02), V(81,4C,F0,12), V(8D,46,97,A3), V(6B,D3,F9,C6), \ + V(03,8F,5F,E7), V(15,92,9C,95), V(BF,6D,7A,EB), V(95,52,59,DA), \ + V(D4,BE,83,2D), V(58,74,21,D3), V(49,E0,69,29), V(8E,C9,C8,44), \ + V(75,C2,89,6A), V(F4,8E,79,78), V(99,58,3E,6B), V(27,B9,71,DD), \ + V(BE,E1,4F,B6), V(F0,88,AD,17), V(C9,20,AC,66), V(7D,CE,3A,B4), \ + V(63,DF,4A,18), V(E5,1A,31,82), V(97,51,33,60), V(62,53,7F,45), \ + V(B1,64,77,E0), V(BB,6B,AE,84), V(FE,81,A0,1C), V(F9,08,2B,94), \ + V(70,48,68,58), V(8F,45,FD,19), V(94,DE,6C,87), V(52,7B,F8,B7), \ + V(AB,73,D3,23), V(72,4B,02,E2), V(E3,1F,8F,57), V(66,55,AB,2A), \ + V(B2,EB,28,07), V(2F,B5,C2,03), V(86,C5,7B,9A), V(D3,37,08,A5), \ + V(30,28,87,F2), V(23,BF,A5,B2), V(02,03,6A,BA), V(ED,16,82,5C), \ + V(8A,CF,1C,2B), V(A7,79,B4,92), V(F3,07,F2,F0), V(4E,69,E2,A1), \ + V(65,DA,F4,CD), V(06,05,BE,D5), V(D1,34,62,1F), V(C4,A6,FE,8A), \ + V(34,2E,53,9D), V(A2,F3,55,A0), V(05,8A,E1,32), V(A4,F6,EB,75), \ + V(0B,83,EC,39), V(40,60,EF,AA), V(5E,71,9F,06), V(BD,6E,10,51), \ + V(3E,21,8A,F9), V(96,DD,06,3D), V(DD,3E,05,AE), V(4D,E6,BD,46), \ + V(91,54,8D,B5), V(71,C4,5D,05), V(04,06,D4,6F), V(60,50,15,FF), \ + V(19,98,FB,24), V(D6,BD,E9,97), V(89,40,43,CC), V(67,D9,9E,77), \ + V(B0,E8,42,BD), V(07,89,8B,88), V(E7,19,5B,38), V(79,C8,EE,DB), \ + V(A1,7C,0A,47), V(7C,42,0F,E9), V(F8,84,1E,C9), V(00,00,00,00), \ + V(09,80,86,83), V(32,2B,ED,48), V(1E,11,70,AC), V(6C,5A,72,4E), \ + V(FD,0E,FF,FB), V(0F,85,38,56), V(3D,AE,D5,1E), V(36,2D,39,27), \ + V(0A,0F,D9,64), V(68,5C,A6,21), V(9B,5B,54,D1), V(24,36,2E,3A), \ + V(0C,0A,67,B1), V(93,57,E7,0F), V(B4,EE,96,D2), V(1B,9B,91,9E), \ + V(80,C0,C5,4F), V(61,DC,20,A2), V(5A,77,4B,69), V(1C,12,1A,16), \ + V(E2,93,BA,0A), V(C0,A0,2A,E5), V(3C,22,E0,43), V(12,1B,17,1D), \ + V(0E,09,0D,0B), V(F2,8B,C7,AD), V(2D,B6,A8,B9), V(14,1E,A9,C8), \ + V(57,F1,19,85), V(AF,75,07,4C), V(EE,99,DD,BB), V(A3,7F,60,FD), \ + V(F7,01,26,9F), V(5C,72,F5,BC), V(44,66,3B,C5), V(5B,FB,7E,34), \ + V(8B,43,29,76), V(CB,23,C6,DC), V(B6,ED,FC,68), V(B8,E4,F1,63), \ + V(D7,31,DC,CA), V(42,63,85,10), V(13,97,22,40), V(84,C6,11,20), \ + V(85,4A,24,7D), V(D2,BB,3D,F8), V(AE,F9,32,11), V(C7,29,A1,6D), \ + V(1D,9E,2F,4B), V(DC,B2,30,F3), V(0D,86,52,EC), V(77,C1,E3,D0), \ + V(2B,B3,16,6C), V(A9,70,B9,99), V(11,94,48,FA), V(47,E9,64,22), \ + V(A8,FC,8C,C4), V(A0,F0,3F,1A), V(56,7D,2C,D8), V(22,33,90,EF), \ + V(87,49,4E,C7), V(D9,38,D1,C1), V(8C,CA,A2,FE), V(98,D4,0B,36), \ + V(A6,F5,81,CF), V(A5,7A,DE,28), V(DA,B7,8E,26), V(3F,AD,BF,A4), \ + V(2C,3A,9D,E4), V(50,78,92,0D), V(6A,5F,CC,9B), V(54,7E,46,62), \ + V(F6,8D,13,C2), V(90,D8,B8,E8), V(2E,39,F7,5E), V(82,C3,AF,F5), \ + V(9F,5D,80,BE), V(69,D0,93,7C), V(6F,D5,2D,A9), V(CF,25,12,B3), \ + V(C8,AC,99,3B), V(10,18,7D,A7), V(E8,9C,63,6E), V(DB,3B,BB,7B), \ + V(CD,26,78,09), V(6E,59,18,F4), V(EC,9A,B7,01), V(83,4F,9A,A8), \ + V(E6,95,6E,65), V(AA,FF,E6,7E), V(21,BC,CF,08), V(EF,15,E8,E6), \ + V(BA,E7,9B,D9), V(4A,6F,36,CE), V(EA,9F,09,D4), V(29,B0,7C,D6), \ + V(31,A4,B2,AF), V(2A,3F,23,31), V(C6,A5,94,30), V(35,A2,66,C0), \ + V(74,4E,BC,37), V(FC,82,CA,A6), V(E0,90,D0,B0), V(33,A7,D8,15), \ + V(F1,04,98,4A), V(41,EC,DA,F7), V(7F,CD,50,0E), V(17,91,F6,2F), \ + V(76,4D,D6,8D), V(43,EF,B0,4D), V(CC,AA,4D,54), V(E4,96,04,DF), \ + V(9E,D1,B5,E3), V(4C,6A,88,1B), V(C1,2C,1F,B8), V(46,65,51,7F), \ + V(9D,5E,EA,04), V(01,8C,35,5D), V(FA,87,74,73), V(FB,0B,41,2E), \ + V(B3,67,1D,5A), V(92,DB,D2,52), V(E9,10,56,33), V(6D,D6,47,13), \ + V(9A,D7,61,8C), V(37,A1,0C,7A), V(59,F8,14,8E), V(EB,13,3C,89), \ + V(CE,A9,27,EE), V(B7,61,C9,35), V(E1,1C,E5,ED), V(7A,47,B1,3C), \ + V(9C,D2,DF,59), V(55,F2,73,3F), V(18,14,CE,79), V(73,C7,37,BF), \ + V(53,F7,CD,EA), V(5F,FD,AA,5B), V(DF,3D,6F,14), V(78,44,DB,86), \ + V(CA,AF,F3,81), V(B9,68,C4,3E), V(38,24,34,2C), V(C2,A3,40,5F), \ + V(16,1D,C3,72), V(BC,E2,25,0C), V(28,3C,49,8B), V(FF,0D,95,41), \ + V(39,A8,01,71), V(08,0C,B3,DE), V(D8,B4,E4,9C), V(64,56,C1,90), \ + V(7B,CB,84,61), V(D5,32,B6,70), V(48,6C,5C,74), V(D0,B8,57,42) + +#define V(a,b,c,d) 0x##a##b##c##d +static const uint32 RT0[256] = { RT }; +#undef V + +#define V(a,b,c,d) 0x##d##a##b##c +static const uint32 RT1[256] = { RT }; +#undef V + +#define V(a,b,c,d) 0x##c##d##a##b +static const uint32 RT2[256] = { RT }; +#undef V + +#define V(a,b,c,d) 0x##b##c##d##a +static const uint32 RT3[256] = { RT }; +#undef V + +#undef RT + +/* round constants */ + +static const uint32 RCON[10] = +{ + 0x01000000, 0x02000000, 0x04000000, 0x08000000, + 0x10000000, 0x20000000, 0x40000000, 0x80000000, + 0x1B000000, 0x36000000 +}; + +int do_init = 0; + +void aes_gen_tables( void ) +{ +} + +#endif + +/* platform-independant 32-bit integer manipulation macros */ + +#define GET_UINT32(n,b,i) \ +{ \ + (n) = ( (uint32) (b)[(i) ] << 24 ) \ + | ( (uint32) (b)[(i) + 1] << 16 ) \ + | ( (uint32) (b)[(i) + 2] << 8 ) \ + | ( (uint32) (b)[(i) + 3] ); \ +} + +#define PUT_UINT32(n,b,i) \ +{ \ + (b)[(i) ] = (uint8) ( (n) >> 24 ); \ + (b)[(i) + 1] = (uint8) ( (n) >> 16 ); \ + (b)[(i) + 2] = (uint8) ( (n) >> 8 ); \ + (b)[(i) + 3] = (uint8) ( (n) ); \ +} + +/* decryption key schedule tables */ + +int KT_init = 1; + +uint32 KT0[256]; +uint32 KT1[256]; +uint32 KT2[256]; +uint32 KT3[256]; + +/* AES key scheduling routine */ + +int aes_set_key( aes_context *ctx, uint8 *key, int nbits ) +{ + int i; + uint32 *RK, *SK; + + if( do_init ) + { + aes_gen_tables(); + + do_init = 0; + } + + switch( nbits ) + { + case 128: ctx->nr = 10; break; + case 192: ctx->nr = 12; break; + case 256: ctx->nr = 14; break; + default : return( 1 ); + } + + RK = ctx->erk; + + for( i = 0; i < (nbits >> 5); i++ ) + { + GET_UINT32( RK[i], key, i * 4 ); + } + + /* setup encryption round keys */ + + switch( nbits ) + { + case 128: + + for( i = 0; i < 10; i++, RK += 4 ) + { + RK[4] = RK[0] ^ RCON[i] ^ + ( FSb[ (uint8) ( RK[3] >> 16 ) ] << 24 ) ^ + ( FSb[ (uint8) ( RK[3] >> 8 ) ] << 16 ) ^ + ( FSb[ (uint8) ( RK[3] ) ] << 8 ) ^ + ( FSb[ (uint8) ( RK[3] >> 24 ) ] ); + + RK[5] = RK[1] ^ RK[4]; + RK[6] = RK[2] ^ RK[5]; + RK[7] = RK[3] ^ RK[6]; + } + break; + + case 192: + + for( i = 0; i < 8; i++, RK += 6 ) + { + RK[6] = RK[0] ^ RCON[i] ^ + ( FSb[ (uint8) ( RK[5] >> 16 ) ] << 24 ) ^ + ( FSb[ (uint8) ( RK[5] >> 8 ) ] << 16 ) ^ + ( FSb[ (uint8) ( RK[5] ) ] << 8 ) ^ + ( FSb[ (uint8) ( RK[5] >> 24 ) ] ); + + RK[7] = RK[1] ^ RK[6]; + RK[8] = RK[2] ^ RK[7]; + RK[9] = RK[3] ^ RK[8]; + RK[10] = RK[4] ^ RK[9]; + RK[11] = RK[5] ^ RK[10]; + } + break; + + case 256: + + for( i = 0; i < 7; i++, RK += 8 ) + { + RK[8] = RK[0] ^ RCON[i] ^ + ( FSb[ (uint8) ( RK[7] >> 16 ) ] << 24 ) ^ + ( FSb[ (uint8) ( RK[7] >> 8 ) ] << 16 ) ^ + ( FSb[ (uint8) ( RK[7] ) ] << 8 ) ^ + ( FSb[ (uint8) ( RK[7] >> 24 ) ] ); + + RK[9] = RK[1] ^ RK[8]; + RK[10] = RK[2] ^ RK[9]; + RK[11] = RK[3] ^ RK[10]; + + RK[12] = RK[4] ^ + ( FSb[ (uint8) ( RK[11] >> 24 ) ] << 24 ) ^ + ( FSb[ (uint8) ( RK[11] >> 16 ) ] << 16 ) ^ + ( FSb[ (uint8) ( RK[11] >> 8 ) ] << 8 ) ^ + ( FSb[ (uint8) ( RK[11] ) ] ); + + RK[13] = RK[5] ^ RK[12]; + RK[14] = RK[6] ^ RK[13]; + RK[15] = RK[7] ^ RK[14]; + } + break; + } + + /* setup decryption round keys */ + + if( KT_init ) + { + for( i = 0; i < 256; i++ ) + { + KT0[i] = RT0[ FSb[i] ]; + KT1[i] = RT1[ FSb[i] ]; + KT2[i] = RT2[ FSb[i] ]; + KT3[i] = RT3[ FSb[i] ]; + } + + KT_init = 0; + } + + SK = ctx->drk; + + *SK++ = *RK++; + *SK++ = *RK++; + *SK++ = *RK++; + *SK++ = *RK++; + + for( i = 1; i < ctx->nr; i++ ) + { + RK -= 8; + + *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^ + KT1[ (uint8) ( *RK >> 16 ) ] ^ + KT2[ (uint8) ( *RK >> 8 ) ] ^ + KT3[ (uint8) ( *RK ) ]; RK++; + + *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^ + KT1[ (uint8) ( *RK >> 16 ) ] ^ + KT2[ (uint8) ( *RK >> 8 ) ] ^ + KT3[ (uint8) ( *RK ) ]; RK++; + + *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^ + KT1[ (uint8) ( *RK >> 16 ) ] ^ + KT2[ (uint8) ( *RK >> 8 ) ] ^ + KT3[ (uint8) ( *RK ) ]; RK++; + + *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^ + KT1[ (uint8) ( *RK >> 16 ) ] ^ + KT2[ (uint8) ( *RK >> 8 ) ] ^ + KT3[ (uint8) ( *RK ) ]; RK++; + } + + RK -= 8; + + *SK++ = *RK++; + *SK++ = *RK++; + *SK++ = *RK++; + *SK++ = *RK++; + + return( 0 ); +} + +/* AES 128-bit block encryption routine */ + +void aes_encrypt( aes_context *ctx, uint8 input[16], uint8 output[16] ) +{ + uint32 *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3; + + RK = ctx->erk; + + GET_UINT32( X0, input, 0 ); X0 ^= RK[0]; + GET_UINT32( X1, input, 4 ); X1 ^= RK[1]; + GET_UINT32( X2, input, 8 ); X2 ^= RK[2]; + GET_UINT32( X3, input, 12 ); X3 ^= RK[3]; + +#define AES_FROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \ +{ \ + RK += 4; \ + \ + X0 = RK[0] ^ FT0[ (uint8) ( Y0 >> 24 ) ] ^ \ + FT1[ (uint8) ( Y1 >> 16 ) ] ^ \ + FT2[ (uint8) ( Y2 >> 8 ) ] ^ \ + FT3[ (uint8) ( Y3 ) ]; \ + \ + X1 = RK[1] ^ FT0[ (uint8) ( Y1 >> 24 ) ] ^ \ + FT1[ (uint8) ( Y2 >> 16 ) ] ^ \ + FT2[ (uint8) ( Y3 >> 8 ) ] ^ \ + FT3[ (uint8) ( Y0 ) ]; \ + \ + X2 = RK[2] ^ FT0[ (uint8) ( Y2 >> 24 ) ] ^ \ + FT1[ (uint8) ( Y3 >> 16 ) ] ^ \ + FT2[ (uint8) ( Y0 >> 8 ) ] ^ \ + FT3[ (uint8) ( Y1 ) ]; \ + \ + X3 = RK[3] ^ FT0[ (uint8) ( Y3 >> 24 ) ] ^ \ + FT1[ (uint8) ( Y0 >> 16 ) ] ^ \ + FT2[ (uint8) ( Y1 >> 8 ) ] ^ \ + FT3[ (uint8) ( Y2 ) ]; \ +} + + AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 1 */ + AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 2 */ + AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 3 */ + AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 4 */ + AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 5 */ + AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 6 */ + AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 7 */ + AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 8 */ + AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 9 */ + + if( ctx->nr > 10 ) + { + AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 10 */ + AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 11 */ + } + + if( ctx->nr > 12 ) + { + AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 12 */ + AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 13 */ + } + + /* last round */ + + RK += 4; + + X0 = RK[0] ^ ( FSb[ (uint8) ( Y0 >> 24 ) ] << 24 ) ^ + ( FSb[ (uint8) ( Y1 >> 16 ) ] << 16 ) ^ + ( FSb[ (uint8) ( Y2 >> 8 ) ] << 8 ) ^ + ( FSb[ (uint8) ( Y3 ) ] ); + + X1 = RK[1] ^ ( FSb[ (uint8) ( Y1 >> 24 ) ] << 24 ) ^ + ( FSb[ (uint8) ( Y2 >> 16 ) ] << 16 ) ^ + ( FSb[ (uint8) ( Y3 >> 8 ) ] << 8 ) ^ + ( FSb[ (uint8) ( Y0 ) ] ); + + X2 = RK[2] ^ ( FSb[ (uint8) ( Y2 >> 24 ) ] << 24 ) ^ + ( FSb[ (uint8) ( Y3 >> 16 ) ] << 16 ) ^ + ( FSb[ (uint8) ( Y0 >> 8 ) ] << 8 ) ^ + ( FSb[ (uint8) ( Y1 ) ] ); + + X3 = RK[3] ^ ( FSb[ (uint8) ( Y3 >> 24 ) ] << 24 ) ^ + ( FSb[ (uint8) ( Y0 >> 16 ) ] << 16 ) ^ + ( FSb[ (uint8) ( Y1 >> 8 ) ] << 8 ) ^ + ( FSb[ (uint8) ( Y2 ) ] ); + + PUT_UINT32( X0, output, 0 ); + PUT_UINT32( X1, output, 4 ); + PUT_UINT32( X2, output, 8 ); + PUT_UINT32( X3, output, 12 ); +} + +/* AES 128-bit block decryption routine */ + +void aes_decrypt( aes_context *ctx, uint8 input[16], uint8 output[16] ) +{ + uint32 *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3; + + RK = ctx->drk; + + GET_UINT32( X0, input, 0 ); X0 ^= RK[0]; + GET_UINT32( X1, input, 4 ); X1 ^= RK[1]; + GET_UINT32( X2, input, 8 ); X2 ^= RK[2]; + GET_UINT32( X3, input, 12 ); X3 ^= RK[3]; + +#define AES_RROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \ +{ \ + RK += 4; \ + \ + X0 = RK[0] ^ RT0[ (uint8) ( Y0 >> 24 ) ] ^ \ + RT1[ (uint8) ( Y3 >> 16 ) ] ^ \ + RT2[ (uint8) ( Y2 >> 8 ) ] ^ \ + RT3[ (uint8) ( Y1 ) ]; \ + \ + X1 = RK[1] ^ RT0[ (uint8) ( Y1 >> 24 ) ] ^ \ + RT1[ (uint8) ( Y0 >> 16 ) ] ^ \ + RT2[ (uint8) ( Y3 >> 8 ) ] ^ \ + RT3[ (uint8) ( Y2 ) ]; \ + \ + X2 = RK[2] ^ RT0[ (uint8) ( Y2 >> 24 ) ] ^ \ + RT1[ (uint8) ( Y1 >> 16 ) ] ^ \ + RT2[ (uint8) ( Y0 >> 8 ) ] ^ \ + RT3[ (uint8) ( Y3 ) ]; \ + \ + X3 = RK[3] ^ RT0[ (uint8) ( Y3 >> 24 ) ] ^ \ + RT1[ (uint8) ( Y2 >> 16 ) ] ^ \ + RT2[ (uint8) ( Y1 >> 8 ) ] ^ \ + RT3[ (uint8) ( Y0 ) ]; \ +} + + AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 1 */ + AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 2 */ + AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 3 */ + AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 4 */ + AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 5 */ + AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 6 */ + AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 7 */ + AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 8 */ + AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 9 */ + + if( ctx->nr > 10 ) + { + AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 10 */ + AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 11 */ + } + + if( ctx->nr > 12 ) + { + AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 12 */ + AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 13 */ + } + + /* last round */ + + RK += 4; + + X0 = RK[0] ^ ( RSb[ (uint8) ( Y0 >> 24 ) ] << 24 ) ^ + ( RSb[ (uint8) ( Y3 >> 16 ) ] << 16 ) ^ + ( RSb[ (uint8) ( Y2 >> 8 ) ] << 8 ) ^ + ( RSb[ (uint8) ( Y1 ) ] ); + + X1 = RK[1] ^ ( RSb[ (uint8) ( Y1 >> 24 ) ] << 24 ) ^ + ( RSb[ (uint8) ( Y0 >> 16 ) ] << 16 ) ^ + ( RSb[ (uint8) ( Y3 >> 8 ) ] << 8 ) ^ + ( RSb[ (uint8) ( Y2 ) ] ); + + X2 = RK[2] ^ ( RSb[ (uint8) ( Y2 >> 24 ) ] << 24 ) ^ + ( RSb[ (uint8) ( Y1 >> 16 ) ] << 16 ) ^ + ( RSb[ (uint8) ( Y0 >> 8 ) ] << 8 ) ^ + ( RSb[ (uint8) ( Y3 ) ] ); + + X3 = RK[3] ^ ( RSb[ (uint8) ( Y3 >> 24 ) ] << 24 ) ^ + ( RSb[ (uint8) ( Y2 >> 16 ) ] << 16 ) ^ + ( RSb[ (uint8) ( Y1 >> 8 ) ] << 8 ) ^ + ( RSb[ (uint8) ( Y0 ) ] ); + + PUT_UINT32( X0, output, 0 ); + PUT_UINT32( X1, output, 4 ); + PUT_UINT32( X2, output, 8 ); + PUT_UINT32( X3, output, 12 ); +} + diff --git a/plugins/!Deprecated/Skype/keypacker/aes/aes.h b/plugins/!Deprecated/Skype/keypacker/aes/aes.h new file mode 100644 index 0000000000..af81401a0f --- /dev/null +++ b/plugins/!Deprecated/Skype/keypacker/aes/aes.h @@ -0,0 +1,24 @@ +#ifndef _AES_H +#define _AES_H + +#ifndef uint8 +#define uint8 unsigned char +#endif + +#ifndef uint32 +#define uint32 unsigned long int +#endif + +typedef struct +{ + uint32 erk[64]; /* encryption round keys */ + uint32 drk[64]; /* decryption round keys */ + int nr; /* number of rounds */ +} +aes_context; + +int aes_set_key( aes_context *ctx, uint8 *key, int nbits ); +void aes_encrypt( aes_context *ctx, uint8 input[16], uint8 output[16] ); +void aes_decrypt( aes_context *ctx, uint8 input[16], uint8 output[16] ); + +#endif /* aes.h */ diff --git a/plugins/!Deprecated/Skype/keypacker/keypacker.cpp b/plugins/!Deprecated/Skype/keypacker/keypacker.cpp new file mode 100644 index 0000000000..c9833a41ac --- /dev/null +++ b/plugins/!Deprecated/Skype/keypacker/keypacker.cpp @@ -0,0 +1,222 @@ +#include "stdafx.h" + +void *buf; + +static const char base64Fillchar = '='; // used to mark partial words at the end + +// this lookup table defines the base64 encoding +char *base64EncodeTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +const unsigned char base64DecodeTable[] = { + 99, 98, 98, 98, 98, 98, 98, 98, 98, 97, 97, 98, 98, 97, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, //00 -29 + 98, 98, 97, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 62, 98, 98, 98, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 98, 98, //30 -59 + 98, 96, 98, 98, 98, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, //60 -89 + 25, 98, 98, 98, 98, 98, 98, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, //90 -119 + 49, 50, 51, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, //120 -149 + 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, //150 -179 + 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, //180 -209 + 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, //210 -239 + 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98 //240 -255 +}; + +int encodeLength(int inlen, char formatted) +{ + unsigned int i = ((inlen-1)/3*4+4+1); + if (formatted) i+=inlen/54; + return i; +} + +char * encode(unsigned char *inbuf, unsigned int inlen, char formatted) +{ + int i = encodeLength(inlen, formatted), k = 17, eLen = inlen/3, j; + malloc(i); + char * curr = (char *)buf; + for (i=0;i>18 ]; + *(curr++) = base64EncodeTable[(j>>12)&0x3f]; + *(curr++) = base64EncodeTable[(j>> 6)&0x3f]; + *(curr++) = base64EncodeTable[(j)&0x3f]; + if (formatted) { if ( !k) { *(curr++) = '\n'; k = 18; } k--; } + } + eLen = inlen-eLen*3; // 0 - 2. + if (eLen == 1) + { + *(curr++) = base64EncodeTable[ inbuf[0]>>2 ]; + *(curr++) = base64EncodeTable[(inbuf[0]<<4)&0x3F]; + *(curr++) = base64Fillchar; + *(curr++) = base64Fillchar; + } else if (eLen == 2) + { + j = (inbuf[0]<<8)|inbuf[1]; + *(curr++) = base64EncodeTable[ j>>10 ]; + *(curr++) = base64EncodeTable[(j>> 4)&0x3f]; + *(curr++) = base64EncodeTable[(j<< 2)&0x3f]; + *(curr++) = base64Fillchar; + } + *(curr++) = 0; + return (char *)buf; +} + +unsigned int decodeSize(char * data) +{ + if ( !data) return 0; + int size = 0; + unsigned char c; + //skip any extra characters (e.g. newlines or spaces) + while (*data) + { + if (*data>255) { return 0; } + c = base64DecodeTable[(unsigned char)(*data)]; + if (c<97) size++; + else if (c == 98) { return 0; } + data++; + } + if (size == 0) return 0; + do { data--; size--; } while (*data == base64Fillchar); size++; + return (unsigned int)((size*3)/4); +} + +unsigned char decode(char * data, unsigned char *buf, int len) +{ + if ( !data) return 0; + int i=0, p = 0; + unsigned char d, c; + for (;;) + { + + #define BASE64DECODE_READ_NEXT_CHAR(c) \ + do { \ + if (data[i]>255) { c = 98; break; } \ + c = base64DecodeTable[(unsigned char)data[i++]]; \ + }while (c == 97); \ + if(c == 98) { return 0; } + + BASE64DECODE_READ_NEXT_CHAR(c) + if (c == 99) { return 2; } + if (c == 96) + { + if (p == (int)len) return 2; + return 1; + } + + BASE64DECODE_READ_NEXT_CHAR(d) + if ((d == 99) || (d == 96)) { return 1; } + if (p == (int)len) { return 0; } + buf[p++] = (unsigned char)((c<<2)|((d>>4)&0x3)); + + BASE64DECODE_READ_NEXT_CHAR(c) + if (c == 99) { return 1; } + if (p == (int)len) + { + if (c == 96) return 2; + return 0; + } + if (c == 96) { return 1; } + buf[p++] = (unsigned char)(((d<<4)&0xf0)|((c>>2)&0xf)); + + BASE64DECODE_READ_NEXT_CHAR(d) + if (d == 99) { return 1; } + if (p == (int)len) + { + if (d == 96) return 2; + return 0; + } + if (d == 96) { return 1; } + buf[p++] = (unsigned char)(((c<<6)&0xc0)|d); + } +} +#undef BASE64DECODE_READ_NEXT_CHAR + +unsigned char *decode(char * data, int *outlen) +{ + if ( !data) { *outlen = 0; return (unsigned char*)""; } + unsigned int len = decodeSize(data); + if (outlen) *outlen = len; + if ( !len) return NULL; + malloc(len+1); + if( !decode(data, (unsigned char*)buf, len)) { return NULL; } + return (unsigned char*)buf; +} + +int main() +{ + aes_context ctx; + FILE *fin, *fout; + + int t = strlen(MY_KEY); + int basecodedkey = encodeLength(strlen(MY_KEY), false); + buf = malloc(basecodedkey + 1); + unsigned char *tmpk = (unsigned char *)malloc(basecodedkey + 1); + tmpk = (unsigned char *)encode((unsigned char*)MY_KEY, strlen(MY_KEY), false); + tmpk[basecodedkey] = 0; + char *output = (char*)malloc(basecodedkey + 17); + strcpy(output, "#define MY_KEY \""); + strcat(output, (const char*)tmpk); + strcat(output, "\""); + fout = fopen("key.h", "wb"); + fputs((const char*)output, fout); + fclose(fout); + free(buf); + + aes_set_key( &ctx, (BYTE*)MY_KEY, 128); + + //encrypt + fin = fopen("keypair.crt", "rb"); + fseek(fin, 0, SEEK_END); + long fileSize = ftell(fin); + rewind (fin); + int needbyte = 16 - fileSize%16; + int corsize = fileSize + needbyte; + unsigned char *inBuf = (unsigned char*)malloc(corsize + 1); + unsigned char *locbuf = (unsigned char*)malloc(corsize + 1); + fread(inBuf, fileSize, 1, fin); + fclose(fin); + memset(inBuf+fileSize, 0, needbyte); + inBuf[corsize] = 0; + for (int i = 0; i < corsize; i+=16) { + aes_encrypt(&ctx, inBuf+i, locbuf+i); + } + free(inBuf); + locbuf[corsize] = 0; //cert should be null terminated + int basecoded = encodeLength(corsize, false); + buf = malloc(basecoded + 1); + unsigned char *tmp = (unsigned char *)malloc(basecoded + 1); + tmp = (unsigned char *)encode(locbuf, corsize, false); + tmp[basecoded] = 0; + free(locbuf); + fout = fopen("keypair.bin", "wb"); + fputs((const char*)tmp, fout); + fclose(fout); + free(buf); + //free(tmp); todo:fix + + //decrypt + fin = fopen("keypair.bin", "rb"); + fseek(fin, 0, SEEK_END); + long fileSizeD = ftell(fin); + rewind(fin); + unsigned char *inBufD = (unsigned char*)malloc(fileSizeD); + fread(inBufD, fileSizeD, 1, fin); + fclose(fin); + inBufD[fileSizeD] = 0; + int basedecoded = decodeSize((char*)inBufD); + unsigned char *bufD = (unsigned char*)malloc(basedecoded + 1); + unsigned char *tmpD = (unsigned char*)malloc(basedecoded + 1); + decode((char*)inBufD, tmpD, basedecoded); + for (int i = 0; i < basedecoded; i += 16) { + aes_decrypt(&ctx, tmpD+i, bufD+i); + } + bufD[basedecoded] = 0; //cert should be null terminated + //free(inBufD); todo:fix + free(tmpD); + fout = fopen("keypair.crt.decrypted", "wb"); + fputs((const char*)bufD, fout); + fclose(fout); + free(bufD); + + return 0; +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/keypacker/keypacker_10.sln b/plugins/!Deprecated/Skype/keypacker/keypacker_10.sln new file mode 100644 index 0000000000..a84639cde2 --- /dev/null +++ b/plugins/!Deprecated/Skype/keypacker/keypacker_10.sln @@ -0,0 +1,23 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "keypacker", "keypacker_10.vcxproj", "{826A98BD-CDC2-4D4F-BC20-310F415F9FFB}" +EndProject +Global + GlobalSection(DPCodeReviewSolutionGUID) = preSolution + DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {826A98BD-CDC2-4D4F-BC20-310F415F9FFB}.Debug|Win32.ActiveCfg = Debug|Win32 + {826A98BD-CDC2-4D4F-BC20-310F415F9FFB}.Debug|Win32.Build.0 = Debug|Win32 + {826A98BD-CDC2-4D4F-BC20-310F415F9FFB}.Release|Win32.ActiveCfg = Release|Win32 + {826A98BD-CDC2-4D4F-BC20-310F415F9FFB}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/plugins/!Deprecated/Skype/keypacker/keypacker_10.vcxproj b/plugins/!Deprecated/Skype/keypacker/keypacker_10.vcxproj new file mode 100644 index 0000000000..0db7de2c58 --- /dev/null +++ b/plugins/!Deprecated/Skype/keypacker/keypacker_10.vcxproj @@ -0,0 +1,79 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {826A98BD-CDC2-4D4F-BC20-310F415F9FFB} + keypacker + + + + Application + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + + + + + Level3 + Full + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + Size + + + Console + true + true + true + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/keypacker/keypacker_10.vcxproj.filters b/plugins/!Deprecated/Skype/keypacker/keypacker_10.vcxproj.filters new file mode 100644 index 0000000000..e2b466d4e0 --- /dev/null +++ b/plugins/!Deprecated/Skype/keypacker/keypacker_10.vcxproj.filters @@ -0,0 +1,27 @@ + + + + + Source Files + + + Source Files + + + + + {66b7c02a-1ddc-42a1-9979-8b109c0d5e39} + + + {22eb2a43-df72-4aa2-9503-cb25b3faf955} + + + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/keypacker/keypacker_11.sln b/plugins/!Deprecated/Skype/keypacker/keypacker_11.sln new file mode 100644 index 0000000000..505fc4ea89 --- /dev/null +++ b/plugins/!Deprecated/Skype/keypacker/keypacker_11.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "keypacker", "keypacker_11.vcxproj", "{826A98BD-CDC2-4D4F-BC20-310F415F9FFB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {826A98BD-CDC2-4D4F-BC20-310F415F9FFB}.Debug|Win32.ActiveCfg = Debug|Win32 + {826A98BD-CDC2-4D4F-BC20-310F415F9FFB}.Debug|Win32.Build.0 = Debug|Win32 + {826A98BD-CDC2-4D4F-BC20-310F415F9FFB}.Release|Win32.ActiveCfg = Release|Win32 + {826A98BD-CDC2-4D4F-BC20-310F415F9FFB}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/plugins/!Deprecated/Skype/keypacker/keypacker_12.vcxproj b/plugins/!Deprecated/Skype/keypacker/keypacker_12.vcxproj new file mode 100644 index 0000000000..ee84077558 --- /dev/null +++ b/plugins/!Deprecated/Skype/keypacker/keypacker_12.vcxproj @@ -0,0 +1,81 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {826A98BD-CDC2-4D4F-BC20-310F415F9FFB} + keypacker + + + + Application + true + Unicode + v120_xp + + + Application + false + true + Unicode + v120_xp + + + + + + + + + + + + + + + + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + + + + + Level3 + Full + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + Size + + + Console + true + true + true + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/keypacker/keypacker_12.vcxproj.filters b/plugins/!Deprecated/Skype/keypacker/keypacker_12.vcxproj.filters new file mode 100644 index 0000000000..e2b466d4e0 --- /dev/null +++ b/plugins/!Deprecated/Skype/keypacker/keypacker_12.vcxproj.filters @@ -0,0 +1,27 @@ + + + + + Source Files + + + Source Files + + + + + {66b7c02a-1ddc-42a1-9979-8b109c0d5e39} + + + {22eb2a43-df72-4aa2-9503-cb25b3faf955} + + + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/keypacker/stdafx.h b/plugins/!Deprecated/Skype/keypacker/stdafx.h new file mode 100644 index 0000000000..d63a19340e --- /dev/null +++ b/plugins/!Deprecated/Skype/keypacker/stdafx.h @@ -0,0 +1,8 @@ +#include +#include + +extern "C" +{ +#include "..\src\aes\aes.h" +} +#include "..\..\..\..\SkypeKit\original_key.h" diff --git a/plugins/!Deprecated/Skype/proto_conn_skype/Proto_conn_Skype_10.vcxproj b/plugins/!Deprecated/Skype/proto_conn_skype/Proto_conn_Skype_10.vcxproj new file mode 100644 index 0000000000..6d2347b5fd --- /dev/null +++ b/plugins/!Deprecated/Skype/proto_conn_skype/Proto_conn_Skype_10.vcxproj @@ -0,0 +1,124 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + Proto_conn_Skype + {A3A599DF-AE0F-DAFC-106D-7E3769E18E6D} + + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\Icons\ + $(SolutionDir)$(Configuration)64\Icons\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Icons\ + $(SolutionDir)$(Configuration)64\Icons\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + true + false + Windows + $(SolutionDir)\lib + + + ..\..\..\include\msapi + _DEBUG;%(PreprocessorDefinitions) + + + + + true + false + Windows + $(SolutionDir)\lib + + + ..\..\..\include\msapi + _DEBUG;%(PreprocessorDefinitions) + + + + + true + false + Windows + $(SolutionDir)\lib + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi + + + + + true + false + Windows + $(SolutionDir)\lib + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi + + + + + + + + + \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/proto_conn_skype/Proto_conn_Skype_10.vcxproj.filters b/plugins/!Deprecated/Skype/proto_conn_skype/Proto_conn_Skype_10.vcxproj.filters new file mode 100644 index 0000000000..876836c2da --- /dev/null +++ b/plugins/!Deprecated/Skype/proto_conn_skype/Proto_conn_Skype_10.vcxproj.filters @@ -0,0 +1,14 @@ + + + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Resource Files + + + \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/proto_conn_skype/Proto_conn_Skype_12.vcxproj b/plugins/!Deprecated/Skype/proto_conn_skype/Proto_conn_Skype_12.vcxproj new file mode 100644 index 0000000000..7a513c66d5 --- /dev/null +++ b/plugins/!Deprecated/Skype/proto_conn_skype/Proto_conn_Skype_12.vcxproj @@ -0,0 +1,128 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + Proto_conn_Skype + {A3A599DF-AE0F-DAFC-106D-7E3769E18E6D} + + + + DynamicLibrary + Unicode + v120_xp + + + DynamicLibrary + Unicode + v120_xp + + + DynamicLibrary + Unicode + v120_xp + + + DynamicLibrary + Unicode + v120_xp + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\Icons\ + $(SolutionDir)$(Configuration)64\Icons\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Icons\ + $(SolutionDir)$(Configuration)64\Icons\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + true + false + Windows + $(SolutionDir)\lib + + + ..\..\..\include\msapi + _DEBUG;%(PreprocessorDefinitions) + + + + + true + false + Windows + $(SolutionDir)\lib + + + ..\..\..\include\msapi + _DEBUG;%(PreprocessorDefinitions) + + + + + true + false + Windows + $(SolutionDir)\lib + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi + + + + + true + false + Windows + $(SolutionDir)\lib + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi + + + + + + + + + \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/proto_conn_skype/Proto_conn_Skype_12.vcxproj.filters b/plugins/!Deprecated/Skype/proto_conn_skype/Proto_conn_Skype_12.vcxproj.filters new file mode 100644 index 0000000000..876836c2da --- /dev/null +++ b/plugins/!Deprecated/Skype/proto_conn_skype/Proto_conn_Skype_12.vcxproj.filters @@ -0,0 +1,14 @@ + + + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Resource Files + + + \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/proto_conn_skype/res/1.ico b/plugins/!Deprecated/Skype/proto_conn_skype/res/1.ico new file mode 100644 index 0000000000..9175679a3d Binary files /dev/null and b/plugins/!Deprecated/Skype/proto_conn_skype/res/1.ico differ diff --git a/plugins/!Deprecated/Skype/proto_conn_skype/res/2.ico b/plugins/!Deprecated/Skype/proto_conn_skype/res/2.ico new file mode 100644 index 0000000000..41508e7829 Binary files /dev/null and b/plugins/!Deprecated/Skype/proto_conn_skype/res/2.ico differ diff --git a/plugins/!Deprecated/Skype/proto_conn_skype/res/3.ico b/plugins/!Deprecated/Skype/proto_conn_skype/res/3.ico new file mode 100644 index 0000000000..e87888acd8 Binary files /dev/null and b/plugins/!Deprecated/Skype/proto_conn_skype/res/3.ico differ diff --git a/plugins/!Deprecated/Skype/proto_conn_skype/res/resource.rc b/plugins/!Deprecated/Skype/proto_conn_skype/res/resource.rc new file mode 100644 index 0000000000..649c7f7e9b --- /dev/null +++ b/plugins/!Deprecated/Skype/proto_conn_skype/res/resource.rc @@ -0,0 +1,34 @@ +//Microsoft Developer Studio generated resource script. +// + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +1 ICON "1.ico" +2 ICON "2.ico" +3 ICON "3.ico" + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/proto_skype/Proto_Skype_10.vcxproj b/plugins/!Deprecated/Skype/proto_skype/Proto_Skype_10.vcxproj new file mode 100644 index 0000000000..7a3e7f8208 --- /dev/null +++ b/plugins/!Deprecated/Skype/proto_skype/Proto_Skype_10.vcxproj @@ -0,0 +1,131 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {DA3CD2B3-5DAC-4F6A-BC9F-05DE39EFF4C3} + Proto_Skype + + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + false + Unicode + + + DynamicLibrary + false + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\Icons\ + $(SolutionDir)$(Configuration)64\Icons\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Icons\ + $(SolutionDir)$(Configuration)64\Icons\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + Windows + true + false + $(SolutionDir)\lib + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi + + + + + Windows + true + false + $(SolutionDir)\lib + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi + + + + + Windows + true + false + $(SolutionDir)\lib + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi + + + + + Windows + true + false + $(SolutionDir)\lib + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/proto_skype/Proto_Skype_10.vcxproj.filters b/plugins/!Deprecated/Skype/proto_skype/Proto_Skype_10.vcxproj.filters new file mode 100644 index 0000000000..05bc2ab938 --- /dev/null +++ b/plugins/!Deprecated/Skype/proto_skype/Proto_Skype_10.vcxproj.filters @@ -0,0 +1,23 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/proto_skype/Proto_Skype_12.vcxproj b/plugins/!Deprecated/Skype/proto_skype/Proto_Skype_12.vcxproj new file mode 100644 index 0000000000..f2afa9a94f --- /dev/null +++ b/plugins/!Deprecated/Skype/proto_skype/Proto_Skype_12.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {DA3CD2B3-5DAC-4F6A-BC9F-05DE39EFF4C3} + Proto_Skype + + + + DynamicLibrary + true + Unicode + v120_xp + + + DynamicLibrary + true + Unicode + v120_xp + + + DynamicLibrary + false + Unicode + v120_xp + + + DynamicLibrary + false + Unicode + v120_xp + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\Icons\ + $(SolutionDir)$(Configuration)64\Icons\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Icons\ + $(SolutionDir)$(Configuration)64\Icons\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + Windows + true + false + $(SolutionDir)\lib + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi + + + + + Windows + true + false + $(SolutionDir)\lib + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi + + + + + Windows + true + false + $(SolutionDir)\lib + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi + + + + + Windows + true + false + $(SolutionDir)\lib + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/proto_skype/Proto_Skype_12.vcxproj.filters b/plugins/!Deprecated/Skype/proto_skype/Proto_Skype_12.vcxproj.filters new file mode 100644 index 0000000000..05bc2ab938 --- /dev/null +++ b/plugins/!Deprecated/Skype/proto_skype/Proto_Skype_12.vcxproj.filters @@ -0,0 +1,23 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/proto_skype/res/Away.ico b/plugins/!Deprecated/Skype/proto_skype/res/Away.ico new file mode 100644 index 0000000000..3d53035e78 Binary files /dev/null and b/plugins/!Deprecated/Skype/proto_skype/res/Away.ico differ diff --git a/plugins/!Deprecated/Skype/proto_skype/res/DND.ico b/plugins/!Deprecated/Skype/proto_skype/res/DND.ico new file mode 100644 index 0000000000..2646d9ba60 Binary files /dev/null and b/plugins/!Deprecated/Skype/proto_skype/res/DND.ico differ diff --git a/plugins/!Deprecated/Skype/proto_skype/res/Invisible.ico b/plugins/!Deprecated/Skype/proto_skype/res/Invisible.ico new file mode 100644 index 0000000000..d76c3c0eb9 Binary files /dev/null and b/plugins/!Deprecated/Skype/proto_skype/res/Invisible.ico differ diff --git a/plugins/!Deprecated/Skype/proto_skype/res/Offline.ico b/plugins/!Deprecated/Skype/proto_skype/res/Offline.ico new file mode 100644 index 0000000000..09a98487a0 Binary files /dev/null and b/plugins/!Deprecated/Skype/proto_skype/res/Offline.ico differ diff --git a/plugins/!Deprecated/Skype/proto_skype/res/Online.ico b/plugins/!Deprecated/Skype/proto_skype/res/Online.ico new file mode 100644 index 0000000000..140b9704af Binary files /dev/null and b/plugins/!Deprecated/Skype/proto_skype/res/Online.ico differ diff --git a/plugins/!Deprecated/Skype/proto_skype/res/Phone.ico b/plugins/!Deprecated/Skype/proto_skype/res/Phone.ico new file mode 100644 index 0000000000..8903209986 Binary files /dev/null and b/plugins/!Deprecated/Skype/proto_skype/res/Phone.ico differ diff --git a/plugins/!Deprecated/Skype/proto_skype/res/Proto_Skype.rc b/plugins/!Deprecated/Skype/proto_skype/res/Proto_Skype.rc new file mode 100644 index 0000000000..3506f4708d --- /dev/null +++ b/plugins/!Deprecated/Skype/proto_skype/res/Proto_Skype.rc @@ -0,0 +1,74 @@ + // 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 + +///////////////////////////////////////////////////////////////////////////// +// Russian (Russia) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\\src\\resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_ICON1 ICON "Offline.ico" +IDI_ICON2 ICON "Online.ico" +IDI_ICON3 ICON "DND.ico" +IDI_ICON4 ICON "Invisible.ico" +IDI_ICON5 ICON "Away.ico" +IDI_ICON6 ICON "Phone.ico" +#endif // Russian (Russia) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/!Deprecated/Skype/proto_skype/src/resource.h b/plugins/!Deprecated/Skype/proto_skype/src/resource.h new file mode 100644 index 0000000000..e206585288 --- /dev/null +++ b/plugins/!Deprecated/Skype/proto_skype/src/resource.h @@ -0,0 +1,21 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Proto_NewsAggr.rc +// +#define IDI_ICON1 105 +#define IDI_ICON2 104 +#define IDI_ICON3 158 +#define IDI_ICON4 130 +#define IDI_ICON5 128 +#define IDI_ICON6 1002 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#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/Skype/res/Resource.rc b/plugins/!Deprecated/Skype/res/Resource.rc new file mode 100644 index 0000000000..1b1e0bca3c --- /dev/null +++ b/plugins/!Deprecated/Skype/res/Resource.rc @@ -0,0 +1,492 @@ +// 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 + +///////////////////////////////////////////////////////////////////////////// +// Neutral (Default) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUD) +LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT +#pragma code_page(1251) + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_SKYPE ICON "skype.ico" +IDI_CALL ICON "call.ico" +IDI_ADD_CONTACTS ICON "add_contacts.ico" +IDI_SEND_CONTACTS ICON "send_contacts.ico" +IDI_DELETE ICON "delete.ico" +IDI_BLOCK ICON "block.ico" +IDI_CONFERENCE ICON "conference.ico" +IDI_CONTACT ICON "contact.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// BIN +// + +IDR_RUNTIME BIN "..\\..\\..\\..\\miranda-private-keys\\SkypeKit\\SDK\\bin\\windows-x86\\windows-x86-skypekit.exe" +IDR_KEY BIN "..\\..\\..\\..\\miranda-private-keys\\SkypeKit\\keypair.bin" + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_CHATROOM_INVITE DIALOGEX 0, 0, 190, 179 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_TOPMOST +CAPTION "Invite contacts to conference" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + LTEXT "Skype name:",-1,7,128,43,9 + PUSHBUTTON "&Invite",IDOK,29,159,46,14 + PUSHBUTTON "&Cancel",IDCANCEL,112,159,45,14 + CONTROL "",IDC_CCLIST,"CListControl",WS_TABSTOP | 0x16f,7,4,174,119,WS_EX_CLIENTEDGE + EDITTEXT IDC_EDITSCR,7,138,121,12,ES_AUTOHSCROLL + PUSHBUTTON "Add",IDC_ADDSCR,133,136,49,14 +END + +IDD_CHATROOM_CREATE DIALOGEX 0, 0, 377, 229 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_TOPMOST +CAPTION "Create conference" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + LTEXT "Skype name:",IDC_STATIC,6,201,43,9 + PUSHBUTTON "&Create",IDOK,273,209,46,14 + PUSHBUTTON "&Cancel",IDCANCEL,323,209,45,14 + CONTROL "",IDC_CCLIST,"CListControl",WS_TABSTOP | 0x16f,7,4,174,192,WS_EX_CLIENTEDGE + EDITTEXT IDC_EDITSCR,6,211,121,12,ES_AUTOHSCROLL + PUSHBUTTON "Add",IDC_ADDSCR,132,209,49,14 + LTEXT "Topic:",IDC_STATIC,188,4,180,8 + EDITTEXT IDC_CHAT_TOPIC,188,14,180,14,ES_AUTOHSCROLL + LTEXT "Guideline:",IDC_STATIC,188,31,180,8 + EDITTEXT IDC_CHAT_GUIDLINE,188,41,180,14,ES_AUTOHSCROLL + CONTROL "Enable joining",IDC_CHAT_JOINING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,188,58,180,10 + LTEXT "New members join with role:",IDC_STATIC,188,73,180,8 + COMBOBOX IDC_CHAT_ROLES,188,83,180,30,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP + CONTROL "Create with password",IDC_CHAT_SECURED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,188,98,180,10 + LTEXT "Password:",IDC_STATIC,197,111,171,8 + EDITTEXT IDC_CHAT_PASSWORD,198,122,170,14,ES_PASSWORD | ES_AUTOHSCROLL | WS_DISABLED + LTEXT "Confirmation:",IDC_STATIC,197,139,171,8 + EDITTEXT IDC_CHAT_CONFIRMATION,198,150,170,14,ES_PASSWORD | ES_AUTOHSCROLL | WS_DISABLED + LTEXT "Password hint:",IDC_STATIC,198,166,170,8 + EDITTEXT IDC_CHAT_HINT,198,177,170,14,ES_AUTOHSCROLL | WS_DISABLED +END + +IDD_CHATROOM_CONFIG DIALOGEX 0, 0, 243, 316 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_TOPMOST +CAPTION "Configure conference" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + PUSHBUTTON "&OK",IDOK,141,296,46,14 + PUSHBUTTON "&Cancel",IDCANCEL,191,296,45,14 + LTEXT "Topic:",IDC_STATIC,5,13,74,8 + EDITTEXT IDC_CHAT_TOPIC,5,23,231,14,ES_AUTOHSCROLL + LTEXT "Guideline:",IDC_STATIC,5,44,73,8 + EDITTEXT IDC_CHAT_GUIDLINE,5,54,231,14,ES_AUTOHSCROLL + LTEXT "Password:",IDC_STATIC,16,131,62,8 + EDITTEXT IDC_CHAT_GUIDLINE2,84,128,152,14,ES_AUTOHSCROLL + CONTROL "Enable joining",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,72,231,10 + LTEXT "Join role:",IDC_STATIC,5,88,73,8 + COMBOBOX IDC_COMBO2,5,98,231,30,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP + CONTROL "Set password",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,114,231,10 + LTEXT "Confirmation:",IDC_STATIC,16,149,62,8 + EDITTEXT IDC_CHAT_GUIDLINE3,84,146,152,14,ES_AUTOHSCROLL + LTEXT "Hint:",IDC_STATIC,16,167,62,8 + EDITTEXT IDC_CHAT_GUIDLINE4,84,164,152,14,ES_AUTOHSCROLL +END + +IDD_PASSWORD_REQUEST DIALOGEX 0, 0, 157, 71 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Enter password" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "Enter password",IDC_INSTRUCTION,7,7,142,8 + EDITTEXT IDC_PASSWORD,17,16,122,14,ES_PASSWORD | ES_AUTOHSCROLL + CONTROL "Remember this session password",IDC_SAVEPASSWORD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,32,120,10 + DEFPUSHBUTTON "OK",IDOK,46,50,50,14 + PUSHBUTTON "Cancel",IDCANCEL,99,50,50,14 +END + +IDD_INFO_SKYPE DIALOGEX 0, 0, 222, 132 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "Skype name:",IDC_STATIC,5,5,71,8 + EDITTEXT IDC_SID,74,5,143,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Status text:",IDC_STATIC,5,18,71,8 + EDITTEXT IDC_STATUSTEXT,74,18,74,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Online since:",IDC_STATIC,5,31,71,8 + EDITTEXT IDC_ONLINESINCE,74,31,139,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Last event date:",IDC_STATIC,5,44,71,8 + EDITTEXT IDC_LASTEVENTDATE,74,44,141,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Last profile change:",IDC_STATIC,5,57,71,8 + EDITTEXT IDC_LASTPROFILECHANGE,74,57,142,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER +END + +IDD_OWNINFO_PERSONAL DIALOGEX 0, 0, 222, 132 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "Full name:",IDC_STATIC,6,7,54,8 + EDITTEXT IDC_FULLNAME,60,5,156,12,ES_AUTOHSCROLL + LTEXT "Date of birth:",IDC_STATIC,6,20,54,8 + COMBOBOX IDC_BIRTH_DAY,60,18,25,12,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_BIRTH_MONTH,84,18,25,12,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_BIRTH_YEAR,109,18,35,12,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + LTEXT "Gender:",IDC_STATIC,6,34,54,8 + COMBOBOX IDC_GENDER,60,32,84,52,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + LTEXT "Homepage:",IDC_STATIC,6,119,54,8 + EDITTEXT IDC_HOMEPAGE,60,117,156,12,ES_AUTOHSCROLL + LTEXT "Language:",IDC_STATIC,6,47,54,8 + COMBOBOX IDC_LANGUAGE,60,46,84,52,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + LTEXT "About:",IDC_STATIC,6,90,54,8 + EDITTEXT IDC_ABOUT,60,88,156,24,ES_MULTILINE | WS_VSCROLL + LTEXT "Mood:",IDC_STATIC,6,62,54,8 + EDITTEXT IDC_MOOD,60,61,156,24,ES_MULTILINE | WS_VSCROLL +END + +IDD_OWNINFO_CONTACT DIALOGEX 0, 0, 222, 132 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "E-mail 1:",IDC_STATIC,5,5,46,8 + EDITTEXT IDC_EMAIL1,77,2,126,14,ES_AUTOHSCROLL + LTEXT "E-mail 2:",IDC_STATIC,5,21,46,8 + EDITTEXT IDC_EMAIL2,77,17,126,14,ES_AUTOHSCROLL + LTEXT "E-mail 3:",IDC_STATIC,5,36,46,8 + EDITTEXT IDC_EMAIL3,77,32,126,14,ES_AUTOHSCROLL + LTEXT "Mobile phone:",IDC_STATIC,5,68,67,8 + EDITTEXT IDC_MOBPHONE,77,67,126,14,ES_AUTOHSCROLL + LTEXT "Home phone:",IDC_STATIC,5,83,67,8 + EDITTEXT IDC_HOMEPHONE,77,82,126,14,ES_AUTOHSCROLL + LTEXT "Office phone:",IDC_STATIC,5,99,67,8 + EDITTEXT IDC_OFFICEPHONE,77,97,126,14,ES_AUTOHSCROLL +END + +IDD_OWNINFO_HOME DIALOGEX 0, 0, 222, 132 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "City:",IDC_STATIC,5,6,59,8 + EDITTEXT IDC_CITY,67,4,75,12,ES_AUTOHSCROLL + LTEXT "State:",IDC_STATIC,5,20,59,8 + EDITTEXT IDC_STATE,67,18,75,12,ES_AUTOHSCROLL + LTEXT "Country:",IDC_STATIC,5,33,59,8 + COMBOBOX IDC_COUNTRY,67,31,143,172,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + LTEXT "Timezone:",IDC_STATIC,6,47,59,8 + COMBOBOX IDC_TIMEZONE,68,44,142,172,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP +END + +IDD_OWNINFO_ACCOUNT DIALOGEX 0, 0, 222, 132 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "Skype credit:",IDC_STATIC,5,6,59,8 + EDITTEXT IDC_CREDITVALUE,67,4,10,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_CREDITCURRENCY,78,4,10,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER +END + +IDD_PASSWORD_CHANGE DIALOGEX 0, 0, 201, 90 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Change password" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "Old password:",IDC_INSTRUCTION,7,9,75,8,0,WS_EX_RIGHT + EDITTEXT IDC_PASSWORD,88,7,105,14,ES_PASSWORD | ES_AUTOHSCROLL + LTEXT "New password:",IDC_INSTRUCTION2,7,27,75,8,0,WS_EX_RIGHT + EDITTEXT IDC_PASSWORD2,88,24,105,14,ES_PASSWORD | ES_AUTOHSCROLL + LTEXT "Confirmation:",IDC_INSTRUCTION3,7,44,75,8,0,WS_EX_RIGHT + EDITTEXT IDC_PASSWORD3,88,41,105,14,ES_PASSWORD | ES_AUTOHSCROLL + DEFPUSHBUTTON "OK",IDOK,88,69,50,14 + PUSHBUTTON "Cancel",IDCANCEL,142,69,51,14 +END + +IDD_ACCMGR DIALOGEX 0, 0, 199, 92 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "Skype name:",IDC_STATIC,12,8,54,12 + EDITTEXT IDC_SL,66,7,120,12,ES_AUTOHSCROLL + LTEXT "Password:",IDC_STATIC,12,24,54,12 + EDITTEXT IDC_PW,66,23,120,12,ES_PASSWORD | ES_AUTOHSCROLL + PUSHBUTTON "Register new account",IDC_REGISTER,66,39,120,14,WS_DISABLED +END + +IDD_OPT_MAIN DIALOGEX 0, 0, 305, 230 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + GROUPBOX "Account",IDC_STATIC,7,7,291,60 + LTEXT "Skype name:",IDC_STATIC,15,19,63,8 + EDITTEXT IDC_SL,78,17,121,13,ES_AUTOHSCROLL + LTEXT "Password:",IDC_STATIC,15,35,63,8 + EDITTEXT IDC_PW,78,33,121,13,ES_PASSWORD | ES_AUTOHSCROLL + GROUPBOX "Connection",IDC_STATIC,7,69,291,47 + LTEXT "Use port",IDC_STATIC,15,81,63,8 + EDITTEXT IDC_PORT,78,79,30,14,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "for incoming connections",IDC_STATIC,115,81,176,8 + CONTROL "Use ports 80 and 443 as alternative incoming",IDC_USE_ALT_PORTS, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,97,276,10 + PUSHBUTTON "Register new account",IDC_REGISTER,204,17,87,14,WS_DISABLED + PUSHBUTTON "Change password",IDC_CHANGE_PWD,204,33,87,14,WS_DISABLED + EDITTEXT IDC_GROUP,78,120,121,14,ES_AUTOHSCROLL + LTEXT "Default group:",IDC_STATIC,15,122,61,8 +END + +IDD_OPT_BLOCKED DIALOGEX 0, 0, 305, 230 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "",IDC_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,7,291,194 + COMBOBOX IDC_CONTACTS,7,206,231,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Block",IDC_BLOCK,248,206,50,13,WS_DISABLED +END + +IDD_OPT_PRIVACY DIALOGEX 0, 0, 305, 230 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + GROUPBOX "Allow IMs from...",IDC_STATIC,5,2,294,31 + CONTROL "Anyone",IDC_PRIVACY_IM_ANYONE,"Button",BS_AUTORADIOBUTTON,12,11,250,10 + CONTROL "People in my Contact list only",IDC_PRIVACY_IM_CONTACTLIST, + "Button",BS_AUTORADIOBUTTON,12,21,250,10 + GROUPBOX "Allow calls from...",IDC_STATIC,5,33,294,31 + CONTROL "Anyone",IDC_PRIVACY_CALL_ANYONE,"Button",BS_AUTORADIOBUTTON,12,42,250,10 + CONTROL "People in my Contact list only",IDC_PRIVACY_CALL_CONTACTLIST, + "Button",BS_AUTORADIOBUTTON,12,53,250,10 + GROUPBOX "Automatically receive video and share screens with...",IDC_STATIC,5,64,294,41 + CONTROL "Anyone",IDC_PRIVACY_SHARE_ANYONE,"Button",BS_AUTORADIOBUTTON,12,73,250,10 + CONTROL "People in my Contact list only",IDC_PRIVACY_SHARE_CONTACTLIST, + "Button",BS_AUTORADIOBUTTON,12,83,250,10 + CONTROL "No one",IDC_PRIVACY_SHARE_NOONE,"Button",BS_AUTORADIOBUTTON,12,93,250,10 + GROUPBOX "Show avatars",IDC_STATIC,5,105,294,31 + CONTROL "Anyone",IDC_PRIVACY_AVATAR_ANYONE,"Button",BS_AUTORADIOBUTTON,12,114,250,10 + CONTROL "People in my Contact list only",IDC_PRIVACY_AVATARS_CONTACTLIST, + "Button",BS_AUTORADIOBUTTON,12,124,250,10 + GROUPBOX "Contacts count",IDC_STATIC,5,136,294,31 + CONTROL "Anyone",IDC_PRIVACY_COUNT_ANYONE,"Button",BS_AUTORADIOBUTTON,12,145,250,10 + CONTROL "People in my Contact list only",IDC_PRIVACY_COUNT_CONTACTLIST, + "Button",BS_AUTORADIOBUTTON,12,155,250,10 + GROUPBOX "Local time",IDC_STATIC,5,167,294,31 + CONTROL "Anyone",IDC_PRIVACY_TIME_ANYONE,"Button",BS_AUTORADIOBUTTON,12,176,250,10 + CONTROL "People in my Contact list only",IDC_PRIVACY_TIME_CONTACTLIST, + "Button",BS_AUTORADIOBUTTON,12,186,250,10 + CONTROL "Allow my online status to be shown on the web",IDC_PRIVACY_WEB, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,205,250,10 +END + +IDD_BLOCK DIALOGEX 0, 0, 295, 170 +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "Block this person" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + CONTROL "%s",IDC_HEADERBAR,"MHeaderbarCtrl",0x0,0,0,295,25 + LTEXT "",IDC_MESSAGE,6,32,282,27 + CONTROL "Remove from your Contact List",IDC_REMOVE_FROM_CL, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,67,282,10 + GROUPBOX "Abuse",IDC_STATIC,6,84,282,40 + LTEXT "You can also report abuse from this user.",IDC_STATIC,12,96,270,8 + CONTROL "Report abuse",IDC_REPORT_ABUSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,108,270,10 + DEFPUSHBUTTON "Cancel",IDCANCEL,238,147,50,14 + PUSHBUTTON "Block",IDOK,185,147,50,14 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_CHATROOM_INVITE, DIALOG + BEGIN + RIGHTMARGIN, 188 + TOPMARGIN, 4 + BOTTOMMARGIN, 173 + END + + IDD_CHATROOM_CREATE, DIALOG + BEGIN + RIGHTMARGIN, 375 + VERTGUIDE, 7 + VERTGUIDE, 181 + VERTGUIDE, 188 + VERTGUIDE, 198 + VERTGUIDE, 368 + TOPMARGIN, 4 + BOTTOMMARGIN, 223 + END + + IDD_CHATROOM_CONFIG, DIALOG + BEGIN + RIGHTMARGIN, 241 + VERTGUIDE, 5 + VERTGUIDE, 16 + VERTGUIDE, 78 + VERTGUIDE, 84 + VERTGUIDE, 236 + TOPMARGIN, 4 + BOTTOMMARGIN, 310 + END + + IDD_PASSWORD_REQUEST, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 149 + TOPMARGIN, 7 + BOTTOMMARGIN, 64 + END + + IDD_INFO_SKYPE, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 217 + VERTGUIDE, 61 + TOPMARGIN, 5 + BOTTOMMARGIN, 129 + HORZGUIDE, 22 + HORZGUIDE, 35 + HORZGUIDE, 48 + HORZGUIDE, 61 + HORZGUIDE, 74 + END + + IDD_OWNINFO_PERSONAL, DIALOG + BEGIN + VERTGUIDE, 6 + VERTGUIDE, 60 + VERTGUIDE, 144 + VERTGUIDE, 216 + END + + IDD_PASSWORD_CHANGE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 193 + VERTGUIDE, 82 + VERTGUIDE, 88 + VERTGUIDE, 138 + VERTGUIDE, 142 + TOPMARGIN, 7 + BOTTOMMARGIN, 83 + END + + IDD_ACCMGR, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 192 + VERTGUIDE, 12 + VERTGUIDE, 66 + VERTGUIDE, 186 + TOPMARGIN, 7 + BOTTOMMARGIN, 85 + END + + IDD_OPT_MAIN, DIALOG + BEGIN + LEFTMARGIN, 7 + VERTGUIDE, 15 + VERTGUIDE, 78 + VERTGUIDE, 108 + VERTGUIDE, 115 + VERTGUIDE, 199 + VERTGUIDE, 204 + VERTGUIDE, 291 + VERTGUIDE, 298 + TOPMARGIN, 7 + BOTTOMMARGIN, 223 + END + + IDD_OPT_BLOCKED, DIALOG + BEGIN + LEFTMARGIN, 7 + VERTGUIDE, 298 + TOPMARGIN, 7 + BOTTOMMARGIN, 223 + END + + IDD_BLOCK, DIALOG + BEGIN + RIGHTMARGIN, 293 + VERTGUIDE, 6 + VERTGUIDE, 12 + VERTGUIDE, 282 + VERTGUIDE, 288 + BOTTOMMARGIN, 169 + HORZGUIDE, 161 + END +END +#endif // APSTUDIO_INVOKED + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\\src\\resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // Neutral (Default) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/!Deprecated/Skype/res/Version.rc b/plugins/!Deprecated/Skype/res/Version.rc new file mode 100644 index 0000000000..d741488c4f --- /dev/null +++ b/plugins/!Deprecated/Skype/res/Version.rc @@ -0,0 +1,42 @@ +// 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" + +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#endif //_WIN32 + +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/Skype/res/add_contacts.ico b/plugins/!Deprecated/Skype/res/add_contacts.ico new file mode 100644 index 0000000000..d2b5d6a477 Binary files /dev/null and b/plugins/!Deprecated/Skype/res/add_contacts.ico differ diff --git a/plugins/!Deprecated/Skype/res/block.ico b/plugins/!Deprecated/Skype/res/block.ico new file mode 100644 index 0000000000..e92c4d4bce Binary files /dev/null and b/plugins/!Deprecated/Skype/res/block.ico differ diff --git a/plugins/!Deprecated/Skype/res/call.ico b/plugins/!Deprecated/Skype/res/call.ico new file mode 100644 index 0000000000..41e984fc6b Binary files /dev/null and b/plugins/!Deprecated/Skype/res/call.ico differ diff --git a/plugins/!Deprecated/Skype/res/conference.ico b/plugins/!Deprecated/Skype/res/conference.ico new file mode 100644 index 0000000000..7d535835c0 Binary files /dev/null and b/plugins/!Deprecated/Skype/res/conference.ico differ diff --git a/plugins/!Deprecated/Skype/res/contact.ico b/plugins/!Deprecated/Skype/res/contact.ico new file mode 100644 index 0000000000..241bb8a83b Binary files /dev/null and b/plugins/!Deprecated/Skype/res/contact.ico differ diff --git a/plugins/!Deprecated/Skype/res/delete.ico b/plugins/!Deprecated/Skype/res/delete.ico new file mode 100644 index 0000000000..81a38441b1 Binary files /dev/null and b/plugins/!Deprecated/Skype/res/delete.ico differ diff --git a/plugins/!Deprecated/Skype/res/send_contacts.ico b/plugins/!Deprecated/Skype/res/send_contacts.ico new file mode 100644 index 0000000000..c29ed475e0 Binary files /dev/null and b/plugins/!Deprecated/Skype/res/send_contacts.ico differ diff --git a/plugins/!Deprecated/Skype/res/skype.ico b/plugins/!Deprecated/Skype/res/skype.ico new file mode 100644 index 0000000000..140b9704af Binary files /dev/null and b/plugins/!Deprecated/Skype/res/skype.ico differ diff --git a/plugins/!Deprecated/Skype/src/aes/aes.cpp b/plugins/!Deprecated/Skype/src/aes/aes.cpp new file mode 100644 index 0000000000..e3dfa1261f --- /dev/null +++ b/plugins/!Deprecated/Skype/src/aes/aes.cpp @@ -0,0 +1,493 @@ +/* +* FIPS-197 compliant AES implementation +* +* Copyright (C) 2001-2004 Christophe Devine +* +* 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 "aes.h" + +/* forward S-box & tables */ + +unsigned long int FSb[256]; +unsigned long int FT0[256]; +unsigned long int FT1[256]; +unsigned long int FT2[256]; +unsigned long int FT3[256]; + +/* reverse S-box & tables */ + +unsigned long int RSb[256]; +unsigned long int RT0[256]; +unsigned long int RT1[256]; +unsigned long int RT2[256]; +unsigned long int RT3[256]; + +/* round constants */ + +unsigned long int RCON[10]; + +/* tables generation flag */ + +int do_init = 1; + +/* tables generation routine */ + +#define ROTR8(x) (((x << 24) & 0xFFFFFFFF) | ((x & 0xFFFFFFFF) >> 8)) + +#define XTIME(x) ((x << 1) ^ ((x & 0x80) ? 0x1B : 0x00)) +#define MUL(x, y) ((x && y) ? pow[(log[x] + log[y]) % 255] : 0) + +void aes_gen_tables(void) +{ + int i; + unsigned char x, y; + unsigned char pow[256]; + unsigned char log[256]; + + /* compute pow and log tables over GF(2^8) */ + + for (i = 0, x = 1; i < 256; i++, x ^= XTIME(x)) + { + pow[i] = x; + log[x] = i; + } + + /* calculate the round constants */ + + for (i = 0, x = 1; i < 10; i++, x = XTIME(x)) + { + RCON[i] = (unsigned long int)x << 24; + } + + /* generate the forward and reverse S-boxes */ + + FSb[0x00] = 0x63; + RSb[0x63] = 0x00; + + for (i = 1; i < 256; i++) + { + x = pow[255 - log[i]]; + + y = x; + y = (y << 1) | (y >> 7); + x ^= y; + y = (y << 1) | (y >> 7); + x ^= y; + y = (y << 1) | (y >> 7); + x ^= y; + y = (y << 1) | (y >> 7); + x ^= y ^ 0x63; + + FSb[i] = x; + RSb[x] = i; + } + + /* generate the forward and reverse tables */ + + for (i = 0; i < 256; i++) + { + x = (unsigned char)FSb[i]; + y = XTIME(x); + + FT0[i] = (unsigned long int)(x ^ y) ^ + ((unsigned long int)x << 8) ^ + ((unsigned long int)x << 16) ^ + ((unsigned long int)y << 24); + + FT0[i] &= 0xFFFFFFFF; + + FT1[i] = ROTR8(FT0[i]); + FT2[i] = ROTR8(FT1[i]); + FT3[i] = ROTR8(FT2[i]); + + y = (unsigned char)RSb[i]; + + RT0[i] = ((unsigned long int)MUL(0x0B, y)) ^ + ((unsigned long int)MUL(0x0D, y) << 8) ^ + ((unsigned long int)MUL(0x09, y) << 16) ^ + ((unsigned long int)MUL(0x0E, y) << 24); + + RT0[i] &= 0xFFFFFFFF; + + RT1[i] = ROTR8(RT0[i]); + RT2[i] = ROTR8(RT1[i]); + RT3[i] = ROTR8(RT2[i]); + } +} + +/* platform-independant 32-bit integer manipulation macros */ + +#define GET_UINT32(n, b, i) \ +{ \ + (n) = ((unsigned long int)(b)[(i)] << 24) \ + | ((unsigned long int)(b)[(i) + 1] << 16) \ + | ((unsigned long int)(b)[(i) + 2] << 8) \ + | ((unsigned long int)(b)[(i) + 3]); \ +} + +#define PUT_UINT32(n, b, i) \ +{ \ + (b)[(i)] = (unsigned char)((n) >> 24); \ + (b)[(i) + 1] = (unsigned char)((n) >> 16); \ + (b)[(i) + 2] = (unsigned char)((n) >> 8); \ + (b)[(i) + 3] = (unsigned char)((n)); \ +} + +/* decryption key schedule tables */ + +int KT_init = 1; + +unsigned long int KT0[256]; +unsigned long int KT1[256]; +unsigned long int KT2[256]; +unsigned long int KT3[256]; + +/* AES key scheduling routine */ + +int aes_set_key(aes_context *ctx, unsigned char *key, int nbits) +{ + int i; + unsigned long int *RK, *SK; + + if (do_init) + { + aes_gen_tables(); + + do_init = 0; + } + + switch (nbits) + { + case 128: ctx->nr = 10; break; + case 192: ctx->nr = 12; break; + case 256: ctx->nr = 14; break; + default : return 1; + } + + RK = ctx->erk; + + for (i = 0; i < (nbits >> 5); i++) + { + GET_UINT32(RK[i], key, i * 4); + } + + /* setup encryption round keys */ + + switch (nbits) + { + case 128: + for (i = 0; i < 10; i++, RK += 4) + { + RK[4] = RK[0] ^ RCON[i] ^ + (FSb[(unsigned char)(RK[3] >> 16)] << 24) ^ + (FSb[(unsigned char)(RK[3] >> 8)] << 16) ^ + (FSb[(unsigned char)(RK[3])] << 8) ^ + (FSb[(unsigned char)(RK[3] >> 24)]); + + RK[5] = RK[1] ^ RK[4]; + RK[6] = RK[2] ^ RK[5]; + RK[7] = RK[3] ^ RK[6]; + } + break; + + case 192: + for (i = 0; i < 8; i++, RK += 6) + { + RK[6] = RK[0] ^ RCON[i] ^ + (FSb[(unsigned char)(RK[5] >> 16)] << 24) ^ + (FSb[(unsigned char)(RK[5] >> 8)] << 16) ^ + (FSb[(unsigned char)(RK[5])] << 8) ^ + (FSb[(unsigned char)(RK[5] >> 24)]); + + RK[7] = RK[1] ^ RK[6]; + RK[8] = RK[2] ^ RK[7]; + RK[9] = RK[3] ^ RK[8]; + RK[10] = RK[4] ^ RK[9]; + RK[11] = RK[5] ^ RK[10]; + } + break; + + case 256: + for (i = 0; i < 7; i++, RK += 8) + { + RK[8] = RK[0] ^ RCON[i] ^ + (FSb[(unsigned char)(RK[7] >> 16)] << 24) ^ + (FSb[(unsigned char)(RK[7] >> 8)] << 16) ^ + (FSb[(unsigned char)(RK[7])] << 8) ^ + (FSb[(unsigned char)(RK[7] >> 24)]); + + RK[9] = RK[1] ^ RK[8]; + RK[10] = RK[2] ^ RK[9]; + RK[11] = RK[3] ^ RK[10]; + + RK[12] = RK[4] ^ + (FSb[(unsigned char)(RK[11] >> 24)] << 24) ^ + (FSb[(unsigned char)(RK[11] >> 16)] << 16) ^ + (FSb[(unsigned char)(RK[11] >> 8)] << 8) ^ + (FSb[(unsigned char)(RK[11])]); + + RK[13] = RK[5] ^ RK[12]; + RK[14] = RK[6] ^ RK[13]; + RK[15] = RK[7] ^ RK[14]; + } + break; + } + + /* setup decryption round keys */ + + if (KT_init) + { + for (i = 0; i < 256; i++) + { + KT0[i] = RT0[FSb[i]]; + KT1[i] = RT1[FSb[i]]; + KT2[i] = RT2[FSb[i]]; + KT3[i] = RT3[FSb[i]]; + } + + KT_init = 0; + } + + SK = ctx->drk; + + *SK++ = *RK++; + *SK++ = *RK++; + *SK++ = *RK++; + *SK++ = *RK++; + + for (i = 1; i < ctx->nr; i++) + { + RK -= 8; + + *SK++ = KT0[(unsigned char)(*RK >> 24)] ^ + KT1[(unsigned char)(*RK >> 16)] ^ + KT2[(unsigned char)(*RK >> 8)] ^ + KT3[(unsigned char)(*RK)]; + RK++; + + *SK++ = KT0[(unsigned char)(*RK >> 24)] ^ + KT1[(unsigned char)(*RK >> 16)] ^ + KT2[(unsigned char)(*RK >> 8)] ^ + KT3[(unsigned char)(*RK)]; + RK++; + + *SK++ = KT0[(unsigned char)(*RK >> 24)] ^ + KT1[(unsigned char)(*RK >> 16)] ^ + KT2[(unsigned char)(*RK >> 8)] ^ + KT3[(unsigned char)(*RK)]; + RK++; + + *SK++ = KT0[(unsigned char)(*RK >> 24)] ^ + KT1[(unsigned char)(*RK >> 16)] ^ + KT2[(unsigned char)(*RK >> 8)] ^ + KT3[(unsigned char)(*RK)]; + RK++; + } + + RK -= 8; + + *SK++ = *RK++; + *SK++ = *RK++; + *SK++ = *RK++; + *SK++ = *RK++; + + return 0; +} + +/* AES 128-bit block encryption routine */ + +void aes_encrypt(aes_context *ctx, unsigned char input[16], unsigned char output[16]) +{ + unsigned long int *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3; + + RK = ctx->erk; + + GET_UINT32(X0, input, 0); X0 ^= RK[0]; + GET_UINT32(X1, input, 4); X1 ^= RK[1]; + GET_UINT32(X2, input, 8); X2 ^= RK[2]; + GET_UINT32(X3, input, 12); X3 ^= RK[3]; + +#define AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3) \ +{ \ + RK += 4; \ + \ + X0 = RK[0] ^ FT0[(unsigned char)(Y0 >> 24)] ^ \ + FT1[(unsigned char)(Y1 >> 16)] ^ \ + FT2[(unsigned char)(Y2 >> 8)] ^ \ + FT3[(unsigned char)(Y3)]; \ + \ + X1 = RK[1] ^ FT0[(unsigned char)(Y1 >> 24)] ^ \ + FT1[(unsigned char)(Y2 >> 16)] ^ \ + FT2[(unsigned char)(Y3 >> 8)] ^ \ + FT3[(unsigned char)(Y0)]; \ + \ + X2 = RK[2] ^ FT0[(unsigned char)(Y2 >> 24)] ^ \ + FT1[(unsigned char)(Y3 >> 16)] ^ \ + FT2[(unsigned char)(Y0 >> 8)] ^ \ + FT3[(unsigned char)(Y1)]; \ + \ + X3 = RK[3] ^ FT0[(unsigned char)(Y3 >> 24)] ^ \ + FT1[(unsigned char)(Y0 >> 16)] ^ \ + FT2[(unsigned char)(Y1 >> 8)] ^ \ + FT3[(unsigned char)(Y2)]; \ +} + + AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 1 */ + AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 2 */ + AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 3 */ + AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 4 */ + AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 5 */ + AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 6 */ + AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 7 */ + AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 8 */ + AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 9 */ + + if (ctx->nr > 10) + { + AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 10 */ + AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 11 */ + } + + if (ctx->nr > 12) + { + AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 12 */ + AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 13 */ + } + + /* last round */ + + RK += 4; + + X0 = RK[0] ^ (FSb[(unsigned char)(Y0 >> 24)] << 24) ^ + (FSb[(unsigned char)(Y1 >> 16)] << 16) ^ + (FSb[(unsigned char)(Y2 >> 8)] << 8) ^ + (FSb[(unsigned char)(Y3)]); + + X1 = RK[1] ^ (FSb[(unsigned char)(Y1 >> 24)] << 24) ^ + (FSb[(unsigned char)(Y2 >> 16)] << 16) ^ + (FSb[(unsigned char)(Y3 >> 8)] << 8) ^ + (FSb[(unsigned char)(Y0)]); + + X2 = RK[2] ^ (FSb[(unsigned char)(Y2 >> 24)] << 24) ^ + (FSb[(unsigned char)(Y3 >> 16)] << 16) ^ + (FSb[(unsigned char)(Y0 >> 8)] << 8) ^ + (FSb[(unsigned char)(Y1)]); + + X3 = RK[3] ^ (FSb[(unsigned char)(Y3 >> 24)] << 24) ^ + (FSb[(unsigned char)(Y0 >> 16)] << 16) ^ + (FSb[(unsigned char)(Y1 >> 8)] << 8) ^ + (FSb[(unsigned char)(Y2)]); + + PUT_UINT32(X0, output, 0); + PUT_UINT32(X1, output, 4); + PUT_UINT32(X2, output, 8); + PUT_UINT32(X3, output, 12); +} + +/* AES 128-bit block decryption routine */ + +void aes_decrypt(aes_context *ctx, unsigned char input[16], unsigned char output[16]) +{ + unsigned long int *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3; + + RK = ctx->drk; + + GET_UINT32(X0, input, 0); + X0 ^= RK[0]; + GET_UINT32(X1, input, 4); + X1 ^= RK[1]; + GET_UINT32(X2, input, 8); + X2 ^= RK[2]; + GET_UINT32(X3, input, 12); + X3 ^= RK[3]; + +#define AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3) \ +{ \ + RK += 4; \ + \ + X0 = RK[0] ^ RT0[(unsigned char)(Y0 >> 24)] ^ \ + RT1[(unsigned char)(Y3 >> 16)] ^ \ + RT2[(unsigned char)(Y2 >> 8)] ^ \ + RT3[(unsigned char)(Y1)]; \ + \ + X1 = RK[1] ^ RT0[(unsigned char)(Y1 >> 24)] ^ \ + RT1[(unsigned char)(Y0 >> 16)] ^ \ + RT2[(unsigned char)(Y3 >> 8)] ^ \ + RT3[(unsigned char)(Y2)]; \ + \ + X2 = RK[2] ^ RT0[(unsigned char)(Y2 >> 24)] ^ \ + RT1[(unsigned char)(Y1 >> 16)] ^ \ + RT2[(unsigned char)(Y0 >> 8)] ^ \ + RT3[(unsigned char)(Y3)]; \ + \ + X3 = RK[3] ^ RT0[(unsigned char)(Y3 >> 24)] ^ \ + RT1[(unsigned char)(Y2 >> 16)] ^ \ + RT2[(unsigned char)(Y1 >> 8)] ^ \ + RT3[(unsigned char)(Y0)]; \ +} + + AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 1 */ + AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 2 */ + AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 3 */ + AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 4 */ + AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 5 */ + AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 6 */ + AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 7 */ + AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 8 */ + AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 9 */ + + if (ctx->nr > 10) + { + AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 10 */ + AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 11 */ + } + + if (ctx->nr > 12) + { + AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 12 */ + AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 13 */ + } + + /* last round */ + + RK += 4; + + X0 = RK[0] ^ (RSb[(unsigned char)(Y0 >> 24)] << 24) ^ + (RSb[(unsigned char)(Y3 >> 16)] << 16) ^ + (RSb[(unsigned char)(Y2 >> 8)] << 8) ^ + (RSb[(unsigned char)(Y1)]); + + X1 = RK[1] ^ (RSb[(unsigned char)(Y1 >> 24)] << 24) ^ + (RSb[(unsigned char)(Y0 >> 16)] << 16) ^ + (RSb[(unsigned char)(Y3 >> 8)] << 8) ^ + (RSb[(unsigned char)(Y2)]); + + X2 = RK[2] ^ (RSb[(unsigned char)(Y2 >> 24)] << 24) ^ + (RSb[(unsigned char)(Y1 >> 16)] << 16) ^ + (RSb[(unsigned char)(Y0 >> 8)] << 8) ^ + (RSb[(unsigned char)(Y3)]); + + X3 = RK[3] ^ (RSb[(unsigned char)(Y3 >> 24)] << 24) ^ + (RSb[(unsigned char)(Y2 >> 16)] << 16) ^ + (RSb[(unsigned char)(Y1 >> 8)] << 8) ^ + (RSb[(unsigned char)(Y0)]); + + PUT_UINT32(X0, output, 0); + PUT_UINT32(X1, output, 4); + PUT_UINT32(X2, output, 8); + PUT_UINT32(X3, output, 12); +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/aes/aes.h b/plugins/!Deprecated/Skype/src/aes/aes.h new file mode 100644 index 0000000000..8bc958b410 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/aes/aes.h @@ -0,0 +1,15 @@ +#ifndef _AES_H +#define _AES_H + +typedef struct +{ + unsigned long int erk[64]; /* encryption round keys */ + unsigned long int drk[64]; /* decryption round keys */ + int nr; /* number of rounds */ +} aes_context; + +int aes_set_key(aes_context *ctx, unsigned char *key, int nbits); +void aes_encrypt(aes_context *ctx, unsigned char input[16], unsigned char output[16]); +void aes_decrypt(aes_context *ctx, unsigned char input[16], unsigned char output[16]); + +#endif /* aes.h */ diff --git a/plugins/!Deprecated/Skype/src/resource.h b/plugins/!Deprecated/Skype/src/resource.h new file mode 100644 index 0000000000..e155854f36 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/resource.h @@ -0,0 +1,123 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by E:\Projects\C++\MirandaNG\protocols\Skype\res\Resource.rc +// +#define IDD_ACCMGR 9 +#define IDD_OPT_MAIN 10 +#define IDD_INFO_SKYPE 11 +#define IDD_OWNINFO_PERSONAL 12 +#define IDD_OWNINFO_HOME 13 +#define IDD_OWNINFO_CONTACT 14 +#define IDD_PASSWORD_CHANGE 15 +#define IDD_CHATROOM_INVITE 16 +#define IDD_PASSWORD_REQUEST 17 +#define IDD_CHATROOM_CREATE 18 +#define IDD_CHATROOM_CONFIG 19 +#define IDD_OPT_BLOCKED 20 +#define IDD_IGNORE_LIST 21 +#define IDD_BLOCK 22 +#define IDD_OWNINFO_ACCOUNT 23 +#define IDD_OPT_PRIVACY 24 +#define IDI_SKYPE 101 +#define IDR_RUNTIME 102 +#define IDR_KEY 107 +#define IDI_CALL 108 +#define IDI_ADD_CONTACTS 109 +#define IDI_SEND_CONTACTS 110 +#define IDI_DELETE 112 +#define IDI_BLOCK 115 +#define IDI_CONFERENCE 116 +#define IDI_CONTACT 117 +#define IDC_CCLIST 173 +#define IDC_EDITSCR 174 +#define IDC_ADDSCR 175 +#define IDC_SN 1001 +#define IDC_PW 1002 +#define IDC_SL 1003 +#define IDC_SAVEPASS 1004 +#define IDC_SAVEPASSWORD 1005 +#define IDC_PASSWORD 1006 +#define IDC_INSTRUCTION 1007 +#define IDC_INSTRUCTION2 1008 +#define IDC_INSTRUCTION3 1009 +#define IDC_SID 1010 +#define IDC_STATUSTEXT 1011 +#define IDC_ONLINESINCE 1012 +#define IDC_LASTEVENTDATE 1013 +#define IDC_PASSWORD3 1014 +#define IDC_LASTPROFILECHANGE 1015 +#define IDC_PORT 1016 +#define IDC_USE_ALT_PORTS 1017 +#define IDC_REGISTER 1018 +#define IDC_CHANGE_PWD 1019 +#define IDC_DEFAULT_GROUP 1020 +#define IDC_GROUP 1021 +#define IDC_PASSWORD2 1023 +#define IDC_FULLNAME 1025 +#define IDC_EMAIL1 1026 +#define IDC_EMAIL2 1027 +#define IDC_EMAIL3 1028 +#define IDC_BIRTH_DAY 1029 +#define IDC_BIRTH_MONTH 1030 +#define IDC_BIRTH_YEAR 1031 +#define IDC_MOBPHONE 1032 +#define IDC_GENDER 1033 +#define IDC_HOMEPHONE 1034 +#define IDC_HOMEPAGE 1035 +#define IDC_OFFICEPHONE 1036 +#define IDC_LANGUAGE 1037 +#define IDC_ABOUT 1038 +#define IDC_MOOD 1039 +#define IDC_CITY 1040 +#define IDC_STATE 1041 +#define IDC_COUNTRY 1042 +#define IDC_TIMEZONE 1043 +#define IDC_CHAT_TOPIC 1044 +#define IDC_CHAT_GUIDLINE 1045 +#define IDC_CHAT_JOINING 1046 +#define IDC_CHAT_GUIDLINE2 1047 +#define IDC_CHAT_ROLES 1048 +#define IDC_CHAT_GUIDLINE3 1049 +#define IDC_CONTACTS 1050 +#define IDC_CHAT_SECURED 1051 +#define IDC_CHAT_GUIDLINE4 1052 +#define IDC_CHAT_PASSWORD 1053 +#define IDC_CHAT_CONFIRMATION 1054 +#define IDC_CHAT_HINT 1055 +#define IDC_CHECK1 1056 +#define IDC_COMBO2 1057 +#define IDC_CHECK2 1058 +#define IDC_BLOCK 1059 +#define IDC_REPORT_ABUSE 1060 +#define IDC_REMOVE_FROM_CL 1061 +#define IDC_MESSAGE 1062 +#define IDC_HEADERBAR 1063 +#define IDC_BM_LIST 1064 +#define IDC_LIST 1065 +#define IDC_PRIVACY_IM_ANYONE 1066 +#define IDC_PRIVACY_IM_CONTACTLIST 1067 +#define IDC_PRIVACY_CALL_ANYONE 1068 +#define IDC_PRIVACY_CALL_CONTACTLIST 1069 +#define IDC_PRIVACY_SHARE_ANYONE 1070 +#define IDC_PRIVACY_SHARE_CONTACTLIST 1071 +#define IDC_PRIVACY_SHARE_NOONE 1072 +#define IDC_PRIVACY_WEB 1073 +#define IDC_CREDITVALUE 1074 +#define IDC_CREDITCURRENCY 1075 +#define IDC_PRIVACY_AVATAR_ANYONE 1076 +#define IDC_PRIVACY_AVATARS_CONTACTLIST 1077 +#define IDC_PRIVACY_COUNT_ANYONE 1078 +#define IDC_PRIVACY_COUNT_CONTACTLIST 1079 +#define IDC_PRIVACY_TIME_ANYONE 1080 +#define IDC_PRIVACY_TIME_CONTACTLIST 1081 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 118 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1082 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/!Deprecated/Skype/src/skype.cpp b/plugins/!Deprecated/Skype/src/skype.cpp new file mode 100644 index 0000000000..0416d8f473 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype.cpp @@ -0,0 +1,213 @@ +#include "skype.h" + +int hLangpack; +HINSTANCE g_hInstance; + +TIME_API tmi = {0}; + +int g_cbCountries; +struct CountryListEntry* g_countries; + +PLUGININFOEX pluginInfo = +{ + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // {9C448C61-FC3F-42F9-B9F0-4A30E1CF8671} + {0x9c448c61, 0xfc3f, 0x42f9, {0xb9, 0xf0, 0x4a, 0x30, 0xe1, 0xcf, 0x86, 0x71}} +}; + +DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID) +{ + g_hInstance = hInstance; + + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCOL, MIID_LAST}; + +// --- + +BOOL IsRunAsAdmin() +{ + BOOL fIsRunAsAdmin = FALSE; + DWORD dwError = ERROR_SUCCESS; + PSID pAdministratorsGroup = NULL; + + // Allocate and initialize a SID of the administrators group. + SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; + if ( !AllocateAndInitializeSid( + &NtAuthority, + 2, + SECURITY_BUILTIN_DOMAIN_RID, + DOMAIN_ALIAS_RID_ADMINS, + 0, 0, 0, 0, 0, 0, + &pAdministratorsGroup)) + { + dwError = GetLastError(); + goto Cleanup; + } + + // Determine whether the SID of administrators group is enabled in + // the primary access token of the process. + if ( !CheckTokenMembership(NULL, pAdministratorsGroup, &fIsRunAsAdmin)) + { + dwError = GetLastError(); + goto Cleanup; + } + +Cleanup: + // Centralized cleanup for all allocated resources. + if (pAdministratorsGroup) + { + FreeSid(pAdministratorsGroup); + pAdministratorsGroup = NULL; + } + + // Throw the error if something failed in the function. + if (ERROR_SUCCESS != dwError) + { + throw dwError; + } + + return fIsRunAsAdmin; +} + +int UnpackSkypeRuntime(HINSTANCE hInstance, const wchar_t *profileName) +{ + wchar_t fileName[MAX_PATH]; + ::GetModuleFileName(hInstance, fileName, MAX_PATH); + + wchar_t *skypeKitPath = ::wcsrchr(fileName, '\\'); + if (skypeKitPath != NULL) + *skypeKitPath = 0; + ::mir_snwprintf(fileName, SIZEOF(fileName), L"%s\\%s", fileName, L"SkypeKit.exe"); + if ( ::GetFileAttributes(fileName) == DWORD(-1)) + { + HRSRC hRes = ::FindResource(hInstance, MAKEINTRESOURCE(IDR_RUNTIME), L"BIN"); + if (hRes) + { + HGLOBAL hResource = ::LoadResource(hInstance, hRes); + if (hResource) + { + HANDLE hFile; + char *pData = (char *)LockResource(hResource); + DWORD dwSize = SizeofResource(hInstance, hRes), written = 0; + if ((hFile = ::CreateFile( + fileName, + GENERIC_WRITE, + 0, + NULL, + CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, + 0)) != INVALID_HANDLE_VALUE) + { + ::WriteFile(hFile, (void *)pData, dwSize, &written, NULL); + ::CloseHandle(hFile); + } + else + { + // Check the current process's "run as administrator" status. + // Elevate the process if it is not run as administrator. + if (!IsRunAsAdmin()) + { + wchar_t path[MAX_PATH], cmdLine[100]; + ::GetModuleFileName(NULL, path, ARRAYSIZE(path)); + + if (profileName) + ::mir_snwprintf( + cmdLine, + SIZEOF(cmdLine), + L" /restart:%d /profile=%s", + ::GetCurrentProcessId(), + profileName); + else + ::mir_snwprintf( + cmdLine, + SIZEOF(cmdLine), + L" /restart:%d", + ::GetCurrentProcessId()); + + // Launch itself as administrator. + SHELLEXECUTEINFO sei = { sizeof(sei) }; + sei.lpVerb = L"runas"; + sei.lpFile = path; + sei.lpParameters = cmdLine; + //sei.hwnd = hDlg; + sei.nShow = SW_NORMAL; + + if ( !::ShellExecuteEx(&sei)) + { + DWORD dwError = ::GetLastError(); + if (dwError == ERROR_CANCELLED) + { + // The user refused to allow privileges elevation. + // Do nothing ... + } + } + } + else + return 0; + } + } + else + return 0; + } + else + return 0; + } + + return 1; +} + +// --- + +extern "C" int __declspec(dllexport) Load(void) +{ + VARST profilename( _T("%miranda_profilename%")); + + if ( !UnpackSkypeRuntime(g_hInstance, (TCHAR *)profilename)) + { + ::MessageBox(NULL, TranslateT("Did not unpack SkypeKit.exe."), _T(MODULE), MB_OK | MB_ICONERROR); + return 1; + } + + mir_getTMI(&tmi); + mir_getLP(&pluginInfo); + + PROTOCOLDESCRIPTOR pd = { sizeof(pd) }; + pd.szName = "SKYPE"; + pd.type = PROTOTYPE_PROTOCOL; + pd.fnInit = (pfnInitProto)CSkypeProto::InitSkypeProto; + pd.fnUninit = (pfnUninitProto)CSkypeProto::UninitSkypeProto; + CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd); + + CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&g_cbCountries, (LPARAM)&g_countries); + + CSkypeProto::InitIcons(); + CSkypeProto::InitMenus(); + CSkypeProto::InitHookList(); + CSkypeProto::InitLanguages(); + CSkypeProto::InitServiceList(); + + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + CSkypeProto::UninitIcons(); + CSkypeProto::UninitMenus(); + CSkypeProto::UninitInstances(); + return 0; +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype.h b/plugins/!Deprecated/Skype/src/skype.h new file mode 100644 index 0000000000..d27c7564ab --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype.h @@ -0,0 +1,101 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "resource.h" +#include "version.h" + +#define MODULE "Skype" +#define SKYPE_SID_LIMIT 128 +#define SKYPE_PASSWORD_LIMIT 128 +#define SKYPE_GROUP_NAME_LIMIT 100 + +#define SKYPE_SETTINGS_STATUS "Status" +#define SKYPE_SETTINGS_SID "sid" +#define SKYPE_SETTINGS_PASSWORD "Password" +#define SKYPE_SETTINGS_DEF_GROUP "DefaultGroup" + +#define SKYPE_SEARCH_BYSID 1001 +#define SKYPE_SEARCH_BYEMAIL 1002 +#define SKYPE_SEARCH_BYNAMES 1003 + +#define BBB_ID_CONF_INVITE 2001 +#define BBB_ID_CONF_SPAWN 2002 + +#define SKYPE_DB_EVENT_TYPE_EMOTE 10001 +#define SKYPE_DB_EVENT_TYPE_CONTACTS 10002 +#define SKYPE_DB_EVENT_TYPE_CALL 10010 + +enum +{ + CMI_AUTH_REQUEST, + CMI_AUTH_GRANT, + CMI_AUTH_REVOKE, + CMI_BLOCK, + CMI_HISTORY, + CMI_MAX // this item shall be the last one +}; + +#define SMI_CHAT_CREATE 1 +#define SMI_IGNORE_LIST 2 + +#include "string_list.h" + +#include "skypekit\common.h" +#include "skypekit\group.h" +#include "skypekit\search.h" +#include "skypekit\account.h" +#include "skypekit\contact.h" +#include "skypekit\message.h" +#include "skypekit\transfer.h" +#include "skypekit\participant.h" +#include "skypekit\conversation.h" + +#include "skype_proto.h" + +extern HINSTANCE g_hInstance; + +extern int g_cbCountries; +extern struct CountryListEntry* g_countries; \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype_account.cpp b/plugins/!Deprecated/Skype/src/skype_account.cpp new file mode 100644 index 0000000000..d3729f317a --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_account.cpp @@ -0,0 +1,354 @@ +#include "skype.h" + +wchar_t *CSkypeProto::LogoutReasons[] = +{ + LPGENW("") /* --- */, + LPGENW("LOGOUT_CALLED") /* LOGOUT_CALLED */, + LPGENW("HTTPS proxy authentication failed") /* HTTPS_PROXY_AUTH_FAILED */, + LPGENW("SOCKS proxy authentication failed") /* SOCKS_PROXY_AUTH_FAILED */, + LPGENW("P2P connection failed") /* P2P_CONNECT_FAILED */, + LPGENW("Connection to server failed. SkypeKit has been deprecated by Microsoft.") /* SERVER_CONNECT_FAILED */, + LPGENW("Server is overloaded") /* SERVER_OVERLOADED */, + LPGENW("SkypeKit database already in use") /* DB_IN_USE */, + LPGENW("Invalid Skype name") /* INVALID_SKYPENAME */, + LPGENW("Invalid email") /* INVALID_EMAIL */, + LPGENW("Unacceptable password") /* UNACCEPTABLE_PASSWORD */, + LPGENW("Skype name is taken") /* SKYPENAME_TAKEN */, + LPGENW("REJECTED_AS_UNDERAGE") /* REJECTED_AS_UNDERAGE */, + LPGENW("NO_SUCH_IDENTITY") /* NO_SUCH_IDENTITY */, + LPGENW("Incorrect password") /* INCORRECT_PASSWORD */, + LPGENW("Too many login attempts") /* TOO_MANY_LOGIN_ATTEMPTS */, + LPGENW("Password has changed") /* PASSWORD_HAS_CHANGED */, + LPGENW("PERIODIC_UIC_UPDATE_FAILED") /* PERIODIC_UIC_UPDATE_FAILED */, + LPGENW("DB_DISK_FULL") /* DB_DISK_FULL */, + LPGENW("DB_IO_ERROR") /* DB_IO_ERROR */, + LPGENW("SkypeKit database is corrupt") /* DB_CORRUPT */, + LPGENW("DB_FAILURE") /* DB_FAILURE */, + LPGENW("Invalid application ID") /* INVALID_APP_ID */, + LPGENW("APP_ID_FAILURE") /* APP_ID_FAILURE */, + LPGENW("Version is unsupported") /* UNSUPPORTED_VERSION */, + LPGENW("Account blocked") /* ATO_BLOCKED */, + LPGENW("Logout from another instance") /* REMOTE_LOGOUT */, + LPGENW("ACCESS_TOKEN_RENEWAL_FAILED") /* ACCESS_TOKEN_RENEWAL_FAILED */ +}; + +wchar_t *CSkypeProto::PasswordChangeReasons[] = +{ + LPGENW("Password successfully changed") /* PWD_OK */, + LPGENW("Password changing") /* PWD_CHANGING */, + LPGENW("Old password was incorrect") /* PWD_INVALID_OLD_PASSWORD */, + LPGENW("Failed to verify password. No connection to server") /* PWD_SERVER_CONNECT_FAILED */, + LPGENW("Password was set but server didn't like it much") /* PWD_OK_BUT_CHANGE_SUGGESTED */, + LPGENW("New password was exactly the same as old one") /* PWD_MUST_DIFFER_FROM_OLD */, + LPGENW("The new password was unacceptable") /* PWD_INVALID_NEW_PWD */, + LPGENW("Account was currently not logged in") /* PWD_MUST_LOG_IN_TO_CHANGE */, +}; + +bool CSkypeProto::IsOnline() +{ + return this->m_iStatus > ID_STATUS_OFFLINE; +} + +bool CSkypeProto::PrepareLogin() +{ + this->login = ::db_get_wsa(NULL, this->m_szModuleName, SKYPE_SETTINGS_SID); + if ( !this->login || !::wcslen(this->login)) + { + this->m_iStatus = ID_STATUS_OFFLINE; + this->SendBroadcast(ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID); + + wchar_t message[512]; + ::mir_sntprintf(message, SIZEOF(message), ::TranslateT("You have not entered a Skype name.\nConfigure this in Options->Network->%s and try again."), this->m_tszUserName); + this->ShowNotification(message); + return false; + } + + return true; +} + +bool CSkypeProto::PreparePassword() +{ + if ( !this->rememberPassword) + { + if (this->password) + { + ::mir_free(this->password); + this->password = NULL; + } + this->password = ::db_get_sa(NULL, this->m_szModuleName, SKYPE_SETTINGS_PASSWORD); + if ( !this->password || !::strlen(this->password)) + { + if (this->password) + { + ::mir_free(this->password); + this->password = NULL; + } + PasswordRequestBoxParam param(this->login); + if ( !this->RequestPassword(param)) + { + this->SetStatus(ID_STATUS_OFFLINE); + return false; + } + else + { + this->password = ::mir_strdup(param.password); + this->rememberPassword = param.rememberPassword; + } + } + } + + return true; +} + +bool CSkypeProto::LogIn() +{ + if (this->IsOnline() || !this->PrepareLogin()) + return false; + + if (this->GetAccount((char*)_T2A(this->login), this->account)) + { + if ( !this->PreparePassword()) + return false; + + this->account.fetch(); + + this->InitProxy(); + + this->SetAccountSettings(); + + this->debugLogW(L"Login in an account"); + this->account->LoginWithPassword(this->password, false, false); + } + + return true; +} + +void CSkypeProto::LogOut() +{ + if (this->IsOnline() || this->m_iStatus == ID_STATUS_CONNECTING) + { + this->account->SetAvailability(Contact::OFFLINE); + this->debugLogW(L"Logout from account"); + this->account->Logout(true); + } +} + +void CSkypeProto::SetAccountSettings() +{ + int port = this->getWord("Port", rand() % 10000 + 10000); + this->debugLogW(L"Setting port number to %d", port); + this->SetInt(SETUPKEY_PORT, port); + + bool useAlternativePorts = this->getByte("UseAlternativePorts", 1) > 0; + if (useAlternativePorts) + this->debugLogW(L"Setting listening of alternative ports (80, 443)"); + this->SetInt(SETUPKEY_DISABLE_PORT80, (int)!useAlternativePorts); + + // Create default group for new contacts + DBVARIANT dbv = {0}; + if ( !getTString(SKYPE_SETTINGS_DEF_GROUP, &dbv) && lstrlen(dbv.ptszVal) > 0) + { + this->debugLogW(L"Setting default group for new contacts"); + ::Clist_CreateGroup(0, dbv.ptszVal); + ::db_free(&dbv); + } +} + +void CSkypeProto::InitProxy() +{ + if (this->m_hNetlibUser) + { + NETLIBUSERSETTINGS nlus = { sizeof(NETLIBUSERSETTINGS) }; + ::CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM)this->m_hNetlibUser, (LPARAM)&nlus); + + if (nlus.useProxy) + { + char address[MAX_PATH]; + ::mir_snprintf(address, MAX_PATH, "%s:%d", nlus.szProxyServer, nlus.wProxyPort); + + switch (nlus.proxyType) + { + case PROXYTYPE_HTTP: + case PROXYTYPE_HTTPS: + this->debugLogW(L"Setting https user proxy config"); + this->SetInt(SETUPKEY_HTTPS_PROXY_ENABLE, 1); + this->SetInt(SETUPKEY_SOCKS_PROXY_ENABLE, 0); + this->SetStr(SETUPKEY_HTTPS_PROXY_ADDR, address); + if (nlus.useProxyAuth) + { + this->SetStr(SETUPKEY_HTTPS_PROXY_USER, nlus.szProxyAuthUser); + ptrA encodedPass(::mir_base64_encode((BYTE*)nlus.szProxyAuthPassword, ::lstrlenA(nlus.szProxyAuthPassword))); + this->SetStr(SETUPKEY_HTTPS_PROXY_PWD, (char*)encodedPass); + } + break; + + case PROXYTYPE_SOCKS4: + case PROXYTYPE_SOCKS5: + this->debugLogW(L"Setting socks user proxy config"); + this->SetInt(SETUPKEY_HTTPS_PROXY_ENABLE, 0); + this->SetInt(SETUPKEY_SOCKS_PROXY_ENABLE, 1); + this->SetStr(SETUPKEY_SOCKS_PROXY_ADDR, address); + if (nlus.useProxyAuth) + { + this->SetStr(SETUPKEY_SOCKS_PROXY_USER, nlus.szProxyAuthUser); + ptrA encodedPass(::mir_base64_encode((BYTE*)nlus.szProxyAuthPassword, ::lstrlenA(nlus.szProxyAuthPassword))); + this->SetStr(SETUPKEY_SOCKS_PROXY_PWD, (char*)encodedPass); + } + break; + + default: + this->debugLogW(L"Setting automatic proxy detection"); + this->Delete(SETUPKEY_HTTPS_PROXY_ENABLE); + this->Delete(SETUPKEY_HTTPS_PROXY_ADDR); + this->Delete(SETUPKEY_HTTPS_PROXY_USER); + this->Delete(SETUPKEY_HTTPS_PROXY_PWD); + this->Delete(SETUPKEY_SOCKS_PROXY_ENABLE); + this->Delete(SETUPKEY_SOCKS_PROXY_ADDR); + this->Delete(SETUPKEY_SOCKS_PROXY_USER); + this->Delete(SETUPKEY_SOCKS_PROXY_PWD); + break; + } + } + } +} + +void CSkypeProto::OnLoggedIn() +{ + if ( !this->rememberPassword) + { + ::mir_free(this->password); + this->password = NULL; + } + + this->SetServerStatus(this->m_iDesiredStatus); + + this->LoadOwnInfo(this); + this->LoadChatList(this); + this->LoadContactList(this); + this->LoadAuthWaitList(this); + + fetch(this->transferList); +} + +void CSkypeProto::SetServerStatus(int iNewStatus) +{ + if (!this->account) + return; + + // change status + if (m_iStatus == iNewStatus) + return; + + int oldStatus = m_iStatus; + m_iStatus = iNewStatus; + + CContact::AVAILABILITY availability = CSkypeProto::MirandaToSkypeStatus(iNewStatus); + if (availability != CContact::UNKNOWN) + { + this->debugLogW(L"Setting status to %d", iNewStatus); + this->account->SetAvailability(availability); + } + + this->SendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, this->m_iStatus); +} + +void CSkypeProto::OnCblUpdated() +{ + // reload our CL after skype CL fully synced + this->LoadContactList(NULL); +} + +void CSkypeProto::OnLoggedOut(CAccount::LOGOUTREASON reason) +{ + this->debugLogW(L"Failed to login: %s", CSkypeProto::LogoutReasons[reason]); + + if (this->m_iStatus == ID_STATUS_CONNECTING) + this->SendBroadcast( + ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, + CSkypeProto::SkypeToMirandaLoginError(reason)); + + this->SetStatus(ID_STATUS_OFFLINE); + this->ShowNotification(CSkypeProto::LogoutReasons[reason]); + + if (this->rememberPassword && reason == CAccount::INCORRECT_PASSWORD) + { + this->rememberPassword = false; + if (this->password) + { + ::mir_free(this->password); + this->password = NULL; + } + } +} + +void CSkypeProto::OnAccountChanged(int prop) +{ + switch(prop) + { + case CAccount::P_STATUS: + CAccount::STATUS loginStatus; + this->account->GetPropStatus(loginStatus); + + if (loginStatus == CAccount::LOGGED_IN) + { + //this->ForkThread(&CSkypeProto::SignInAsync, 0); + this->OnLoggedIn(); + } + + if (loginStatus == CAccount::LOGGED_OUT) + { + CAccount::LOGOUTREASON reason; + if (this->account->GetPropLogoutreason(reason)) + if (reason != CAccount::LOGOUT_CALLED) + this->OnLoggedOut(reason); + } + break; + + case CAccount::P_CBLSYNCSTATUS: + { + CAccount::CBLSYNCSTATUS status; + this->account->GetPropCblsyncstatus(status); + if (status == CAccount::CBL_IN_SYNC) + { + this->OnCblUpdated(); + } + } + break; + + case CAccount::P_PWDCHANGESTATUS: + { + CAccount::PWDCHANGESTATUS status; + this->account->GetPropPwdchangestatus(status); + if (status != CAccount::PWD_CHANGING) + { + this->debugLogW(L"Failed to chage password: %s", CSkypeProto::PasswordChangeReasons[status]); + this->ShowNotification(CSkypeProto::PasswordChangeReasons[status]); + } + } + break; + + //case CAccount::P_AVATAR_IMAGE: + case CAccount::P_AVATAR_TIMESTAMP: + this->UpdateProfileAvatar(this->account.fetch()); + break; + + //case CAccount::P_MOOD_TEXT: + case CAccount::P_MOOD_TIMESTAMP: + this->UpdateProfileStatusMessage(this->account.fetch()); + break; + + case CAccount::P_PROFILE_TIMESTAMP: + this->UpdateProfile(this->account.fetch()); + break; + +/* case Account::P_AVAILABILITY: + { + Contact::AVAILABILITY status; + this->account->GetPropAvailability(status); + int mir_status = this->SkypeToMirandaStatus(status); + if (mir_status != this->m_iStatus && mir_status >= ID_STATUS_OFFLINE) + this->SetStatus(mir_status); + } + break;*/ + } +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype_avatars.cpp b/plugins/!Deprecated/Skype/src/skype_avatars.cpp new file mode 100644 index 0000000000..25db2a32df --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_avatars.cpp @@ -0,0 +1,196 @@ +#include "skype.h" + +bool CSkypeProto::IsAvatarChanged(const SEBinary &avatar, MCONTACT hContact) +{ + bool result = false; + + BYTE digest[16]; + ::mir_md5_hash((PBYTE)avatar.data(), (int)avatar.size(), digest); + + DBVARIANT dbv; + ::db_get(hContact, this->m_szModuleName, "AvatarHash", &dbv); + if (dbv.type == DBVT_BLOB && dbv.pbVal && dbv.cpbVal == 16) + { + if (::memcmp(digest, dbv.pbVal, 16) == 0) + { + result = true; + } + } + ::db_free(&dbv); + + return result; +} + +wchar_t * CSkypeProto::GetContactAvatarFilePath(MCONTACT hContact) +{ + TCHAR path[MAX_PATH]; + ::mir_sntprintf(path, SIZEOF(path), _T("%s\\%S"), VARST(_T("%miranda_avatarcache%")), this->m_szModuleName); + + DWORD dwAttributes = GetFileAttributes(path); + if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) + CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)path); + + ptrW sid(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID)); + if (hContact != NULL) + ::mir_sntprintf(path, MAX_PATH, _T("%s\\%s.jpg"), path, sid); + else if (sid != NULL) + ::mir_sntprintf(path, MAX_PATH, _T("%s\\%s avatar.jpg"), path, sid); + else + return NULL; + + return mir_wstrdup(path); +} + +INT_PTR __cdecl CSkypeProto::GetAvatarInfo(WPARAM, LPARAM lParam) +{ + PROTO_AVATAR_INFORMATIONW *pai = (PROTO_AVATAR_INFORMATIONW *)lParam; + + if (this->getDword(pai->hContact, "AvatarTS", 0)) + return GAIR_NOAVATAR; + + ptrW sid( ::db_get_wsa(pai->hContact, this->m_szModuleName, SKYPE_SETTINGS_SID)); + if (sid) + { + ptrW path( this->GetContactAvatarFilePath(pai->hContact)); + if (path && !_waccess(path, 0)) + { + ::wcsncpy(pai->filename, path, SIZEOF(pai->filename)); + pai->format = PA_FORMAT_JPEG; + return GAIR_SUCCESS; + } + } + + return GAIR_NOAVATAR; +} + +INT_PTR __cdecl CSkypeProto::GetAvatarCaps(WPARAM wParam, LPARAM lParam) +{ + switch (wParam) + { + case AF_MAXSIZE: + { + POINT *size = (POINT *)lParam; + if (size) + { + size->x = 96; + size->y = 96; + } + } + break; + + case AF_PROPORTION: + return PIP_NONE; + + case AF_FORMATSUPPORTED: + return lParam == PA_FORMAT_JPEG; + + case AF_ENABLED: + return 1; + + case AF_DONTNEEDDELAYS: + return 1; + + case AF_MAXFILESIZE: + // server accepts images of 32000 bytees, not bigger + return 32000; + + case AF_DELAYAFTERFAIL: + // do not request avatar again if server gave an error + return 1;// * 60 * 60 * 1000; // one hour + + case AF_FETCHIFPROTONOTVISIBLE: + case AF_FETCHIFCONTACTOFFLINE: + // avatars can be fetched all the time (server only operation) + return 1; + } + + return 0; +} + +INT_PTR __cdecl CSkypeProto::GetMyAvatar(WPARAM wParam, LPARAM lParam) +{ + if (!wParam) + return -2; + + mir_ptr path( this->GetContactAvatarFilePath(NULL)); + if (path && CSkypeProto::FileExists(path)) + { + ::wcsncpy((wchar_t *)wParam, path, (int)lParam); + return 0; + } + + return -1; +} + +INT_PTR __cdecl CSkypeProto::SetMyAvatar(WPARAM, LPARAM lParam) +{ + wchar_t *path = (wchar_t *)lParam; + if (path) + { + ptrW avatarPath( this->GetContactAvatarFilePath(NULL)); + if ( !::wcscmp(path, avatarPath)) + { + this->debugLogW(L"New avatar path are same with old."); + return -1; + } + + SEBinary avatar = this->GetAvatarBinary(path); + if (avatar.size() == 0) + { + this->debugLogW(L"Failed to read avatar file."); + return -1; + } + + if (this->IsAvatarChanged(avatar)) + { + this->debugLogW(L"New avatar are same with old."); + return -1; + } + + if ( !::CopyFile(path, avatarPath, FALSE)) + { + this->debugLogW(L"Failed to copy new avatar to local storage."); + return -1; + } + + Skype::VALIDATERESULT result = Skype::NOT_VALIDATED; + if (!this->account->SetAvatar(avatar, result)) + { + this->debugLogW(CSkypeProto::ValidationReasons[result]); + return -1; + } + + uint newTS = this->account->GetUintProp(Account::P_AVATAR_IMAGE); + this->setDword("AvatarTS", newTS); + return 0; + } + + this->account->SetBinProperty(Account::P_AVATAR_IMAGE, SEBinary()); + this->delSetting("AvatarTS"); + return 0; +} + +SEBinary CSkypeProto::GetAvatarBinary(wchar_t *path) +{ + SEBinary avatar; + + if (CSkypeProto::FileExists(path)) + { + int len; + char *buffer; + FILE* fp = ::_wfopen(path, L"rb"); + if (fp) + { + ::fseek(fp, 0, SEEK_END); + len = ::ftell(fp); + ::fseek(fp, 0, SEEK_SET); + buffer = new char[len + 1]; + ::fread(buffer, len, 1, fp); + ::fclose(fp); + + avatar.set(buffer, len); + } + } + + return avatar; +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype_blocked.cpp b/plugins/!Deprecated/Skype/src/skype_blocked.cpp new file mode 100644 index 0000000000..b1a25dc4db --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_blocked.cpp @@ -0,0 +1,369 @@ +#include "skype.h" +#include "skype_chat.h" + +int CSkypeProto::BlockCommand(WPARAM wParam, LPARAM lParam) +{ + MCONTACT hContact = (MCONTACT)wParam; + if (hContact) + { + SEString sid(_T2A(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID))); + + ContactRef contact; + if ( !this->GetContact(sid, contact) || !contact) + return 0; + + bool isBlocked = false; + if (contact->IsMemberOfHardwiredGroup(ContactGroup::CONTACTS_BLOCKED_BY_ME, isBlocked) && !isBlocked) + { + BlockParam param(hContact, this); + if (::DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_BLOCK), NULL, CSkypeProto::SkypeBlockProc, (LPARAM)¶m) == IDOK) + { + if ( !contact->SetBlocked(true, param.abuse)) + return 0; + + if (param.remove) + { + contact->SetBuddyStatus(false); + this->contactList.remove_val(contact); + ::CallService(MS_DB_CONTACT_DELETE, wParam, 0); + } + else if (this->getByte(hContact, "IsSkypeOut", 0) > 0) + this->setWord(hContact, "Status", ID_STATUS_OFFLINE); + } + } + else + { + if (contact->SetBlocked(false)) + if (this->getByte(hContact, "IsSkypeOut", 0) > 0) + this->setWord(hContact, "Status", ID_STATUS_ONTHEPHONE); + } + } + + return 0; +} + +INT_PTR CSkypeProto::OpenBlockedListCommand(WPARAM, LPARAM) +{ + char *title = ::mir_t2a(this->m_tszUserName); + OPENOPTIONSDIALOG ood; + ood.cbSize = sizeof(OPENOPTIONSDIALOG); + ood.pszGroup = "Network"; + ood.pszPage = title; + ood.pszTab = "Blocked contacts"; + return ::Options_Open(&ood); + ::mir_free(title); +} + +INT_PTR CALLBACK CSkypeProto::SkypeBlockProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + BlockParam *param = (BlockParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (msg) + { + case WM_INITDIALOG: + if (lParam) + { + param = (BlockParam *)lParam; + ::SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + ::TranslateDialogDefault(hwndDlg); + + wchar_t *nick = (wchar_t *)::CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)param->hContact, GCDNF_TCHAR); + + TCHAR oldTitle[256], newTitle[256]; + ::GetDlgItemText(hwndDlg, IDC_HEADERBAR, oldTitle, SIZEOF(oldTitle)); + ::mir_sntprintf(newTitle, SIZEOF(newTitle), ::TranslateTS(oldTitle), nick); + ::SetDlgItemText(hwndDlg, IDC_HEADERBAR, newTitle); + + ::SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)::Skin_GetIcon("Skype_block", ICON_BIG)); + ::SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)::Skin_GetIcon("Skype_block")); + + wchar_t text[1024]; + ::mir_sntprintf( + text, + SIZEOF(text), + ::TranslateT("Are you sure you want to block \"%s\" (%s)? They won't be able to contact you and won't appear in your Contact List."), + nick, + ptrW(::db_get_wsa(param->hContact, param->ppro->m_szModuleName, SKYPE_SETTINGS_SID))); + ::SetDlgItemText(hwndDlg, IDC_MESSAGE, text); + + ::Utils_RestoreWindowPosition(hwndDlg, 0, MODULE, "BlockWindow"); + } + break; + + case WM_COMMAND: + if (HIWORD( wParam ) == BN_CLICKED) + { + switch(LOWORD(wParam)) + { + case IDOK: + param->remove = ::IsDlgButtonChecked(hwndDlg, IDC_REMOVE_FROM_CL) > 0; + param->abuse = ::IsDlgButtonChecked(hwndDlg, IDC_REPORT_ABUSE) > 0; + + ::Utils_SaveWindowPosition(hwndDlg, NULL, MODULE, "BlockWindow"); + ::Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0)); + ::Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0)); + ::EndDialog(hwndDlg, IDOK); + break; + + case IDCANCEL: + ::Utils_SaveWindowPosition(hwndDlg, NULL, MODULE, "BlockWindow"); + ::Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0)); + ::Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0)); + ::EndDialog(hwndDlg, IDCANCEL); + break; + } + } + break; + } + return FALSE; +} + +static WNDPROC oldWndProc = NULL; + +LRESULT CALLBACK CSkypeProto::SkypeBlockedOptionsSubProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + if (msg == WM_LBUTTONDOWN) + { + LVHITTESTINFO hi; + hi.pt.x = LOWORD(lParam); hi.pt.y = HIWORD(lParam); + ListView_SubItemHitTest(hwnd, &hi); + if (hi.iSubItem == 1) + { + LVITEM lvi = {0}; + lvi.mask = LVIF_IMAGE | LVIF_PARAM; + lvi.stateMask = -1; + lvi.iItem = hi.iItem; + if (ListView_GetItem(hwnd, &lvi)) + { + ContactParam *param = (ContactParam *)lvi.lParam; + + if (param->contact->SetBlocked(false)) + { + SEString data; + param->contact->GetIdentity(data); + ptrW sid(::mir_utf8decodeW(data)); + + MCONTACT hContact = param->ppro->GetContactBySid(sid); + if (::db_get_b(hContact, param->ppro->m_szModuleName, "IsSkypeOut", 0) > 0) + ::db_set_w(hContact, param->ppro->m_szModuleName, "Status", ID_STATUS_ONTHEPHONE); + + ListView_DeleteItem(hwnd, lvi.iItem); + + int nItem = ::SendMessage(::GetDlgItem(GetParent(hwnd), IDC_CONTACTS), CB_ADDSTRING, 0, (LPARAM)sid); + ::SendMessage(::GetDlgItem(GetParent(hwnd), IDC_CONTACTS), CB_SETITEMDATA, nItem, hContact); + } + } + } + } + + return ::CallWindowProc(oldWndProc, hwnd, msg, wParam, lParam); +} + +int ImageList_AddIconFromIconLib(HIMAGELIST hIml, const char *name) +{ + HICON icon = ::Skin_GetIconByHandle(::Skin_GetIconHandle(name)); + int res = ImageList_AddIcon(hIml, icon); + ::Skin_ReleaseIcon(icon); + return res; +} + +INT_PTR CALLBACK CSkypeProto::SkypeBlockedOptionsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + CSkypeProto *ppro = (CSkypeProto *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (msg) + { + case WM_INITDIALOG: + if (lParam) + { + ppro = (CSkypeProto *)lParam; + ::SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + + ::TranslateDialogDefault(hwndDlg); + + HWND hwndList = ::GetDlgItem(hwndDlg, IDC_LIST); + { // IDC_BM_LIST setup + oldWndProc = (WNDPROC)::SetWindowLongPtr(hwndList, GWLP_WNDPROC, (LONG_PTR)SkypeBlockedOptionsSubProc); + + HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0); + ImageList_AddIconFromIconLib(hIml, "Skype_contact"); + ImageList_AddIconFromIconLib(hIml, "Skype_delete"); + ListView_SetImageList(hwndList, hIml, LVSIL_SMALL); + /// + LVCOLUMN lvc = {0}; + lvc.mask = LVCF_WIDTH | LVCF_TEXT; + //lvc.fmt = LVCFMT_JUSTIFYMASK; + lvc.pszText = TranslateT("Name"); + lvc.cx = 220; // width of column in pixels + ListView_InsertColumn(hwndList, 0, &lvc); + //lvc.fmt = LVCFMT_RIGHT; + lvc.pszText = L""; + lvc.cx = 32 - GetSystemMetrics(SM_CXVSCROLL); // width of column in pixels + ListView_InsertColumn(hwndList, 1, &lvc); + /// + ::SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_SUBITEMIMAGES | LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP); + + if ( !ppro->IsOnline()) + { + ::EnableWindow(hwndList, FALSE); + ::EnableWindow(::GetDlgItem(hwndDlg, IDC_CONTACTS), FALSE); + } + } + + if (ppro->IsOnline()) + { + SEString data; + ContactGroupRef blockedList; + ppro->GetHardwiredContactGroup(ContactGroup::CONTACTS_BLOCKED_BY_ME, blockedList); + + CContact::Refs contacts; + blockedList->GetContacts(contacts); + for (size_t i = 0; i < contacts.size(); i++) + { + auto contact = contacts[i]; + + ptrW sid(::mir_utf8decodeW(contact->GetSid())); + + LVITEM lvi = {0}; + lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; + lvi.iItem = (int)i; + lvi.iImage = 0; + lvi.lParam = (LPARAM)new ContactParam(contact, ppro); + lvi.pszText = sid; + int iRow = ListView_InsertItem(hwndList, &lvi); + + if (iRow != -1) + { + lvi.iItem = iRow; + lvi.mask = LVIF_IMAGE; + lvi.iSubItem = 1; + lvi.iImage = 1; + ListView_SetItem(hwndList, &lvi); + } + } + /// + int nItem = 0; + MCONTACT hContact = NULL; + + ::EnterCriticalSection(&ppro->contact_search_lock); + + for (hContact = ::db_find_first(ppro->m_szModuleName); hContact && !ppro->isChatRoom(hContact); hContact = ::db_find_next(hContact, ppro->m_szModuleName)) + { + ptrW sid(::db_get_wsa(hContact, ppro->m_szModuleName, SKYPE_SETTINGS_SID)); + + ContactRef contact; + ppro->GetContact((char *)_T2A(sid), contact); + if ( !contacts.contains(contact)) + { + nItem = ::SendMessage(::GetDlgItem(hwndDlg, IDC_CONTACTS), CB_ADDSTRING, 0, (LPARAM)sid); + ::SendMessage(::GetDlgItem(hwndDlg, IDC_CONTACTS), CB_SETITEMDATA, nItem, hContact); + } + } + + ::LeaveCriticalSection(&ppro->contact_search_lock); + } + + } + break; + + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case IDC_CONTACTS: + ::EnableWindow(::GetDlgItem(hwndDlg, IDC_BLOCK), TRUE); + break; + + case IDC_BLOCK: + { + int i = ::SendMessage(::GetDlgItem(hwndDlg, IDC_CONTACTS), CB_GETCURSEL, 0, 0); + + MCONTACT hContact = (MCONTACT)::SendMessage(GetDlgItem(hwndDlg, IDC_CONTACTS), CB_GETITEMDATA, i, 0); + if ( !hContact) + break; + + ptrW sid(::db_get_wsa(hContact, ppro->m_szModuleName, SKYPE_SETTINGS_SID)); + + SEString data; + ContactRef contact; + if (!ppro->GetContact((char *)_T2A(sid), contact) || !contact) + break; + + BlockParam param(hContact, ppro); + if (::DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_BLOCK), NULL, CSkypeProto::SkypeBlockProc, (LPARAM)¶m) != IDOK) + break; + + contact->SetBlocked(true, param.abuse); + if (::db_get_b(hContact, ppro->m_szModuleName, "IsSkypeOut", 0) > 0) + ::db_set_w(hContact, ppro->m_szModuleName, "Status", ID_STATUS_OFFLINE); + + if (param.remove) + { + contact->SetBuddyStatus(false); + ppro->contactList.remove_val(contact); + ::CallService(MS_DB_CONTACT_DELETE, wParam, 0); + } + + if (contact->SetBlocked(true)) + { + LVITEM lvi = {0}; + lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; + lvi.iItem = (int)i; + lvi.iImage = 0; + lvi.lParam = (LPARAM)new ContactParam(contact, ppro); + lvi.pszText = sid; + int iRow = ListView_InsertItem(::GetDlgItem(hwndDlg, IDC_LIST), &lvi); + + if (iRow != -1) + { + lvi.iItem = iRow; + lvi.mask = LVIF_IMAGE; + lvi.iSubItem = 1; + lvi.iImage = 1; + ListView_SetItem(::GetDlgItem(hwndDlg, IDC_LIST), &lvi); + } + ::SendMessage(::GetDlgItem(hwndDlg, IDC_CONTACTS), CB_DELETESTRING, i, 0); + } + } + break; + } + } + break; + + case WM_NOTIFY: + if (reinterpret_cast(lParam)->code == PSN_APPLY && !ppro->IsOnline()) + { + return TRUE; + } + break; + + switch(LOWORD(wParam)) + { + case IDC_LIST: + if (((LPNMHDR)lParam)->code == NM_DBLCLK) + { + HWND hwndList = ::GetDlgItem(hwndDlg, IDC_BM_LIST); + int iItem = ListView_GetNextItem(hwndList, -1, LVNI_ALL | LVNI_SELECTED); + if (iItem < 0) break; + LVITEM lvi = {0}; + lvi.mask = LVIF_PARAM | LVIF_GROUPID; + lvi.stateMask = -1; + lvi.iItem = iItem; + if (ListView_GetItem(hwndList, &lvi)) + { + SEString data; + if (lvi.iGroupId == 1) + { + ContactParam *param = (ContactParam *)lvi.lParam; + + param->contact->GetIdentity(data); + ptrW sid(::mir_utf8decodeW(data)); + ::CallService(MS_MSG_SENDMESSAGE, (WPARAM)ppro->GetContactBySid(sid), 0); + } + } + } + } + break; + } + return FALSE; +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype_bookmarks.cpp b/plugins/!Deprecated/Skype/src/skype_bookmarks.cpp new file mode 100644 index 0000000000..29f3cc89d4 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_bookmarks.cpp @@ -0,0 +1,203 @@ +#include "skype.h" +#include "skype_chat.h" + +int CSkypeProto::SetBookmarkCommand(WPARAM wParam, LPARAM) +{ + HANDLE hContact = (HANDLE)wParam; + if (this->IsOnline() && this->IsChatRoom(hContact)) + this->BookmarkChatRoom(hContact); + + return 0; +} + +static WNDPROC oldWndProc = NULL; + +static LRESULT CALLBACK BookmarkListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + if (msg == WM_LBUTTONDOWN) + { + LVHITTESTINFO hi; + hi.pt.x = LOWORD(lParam); hi.pt.y = HIWORD(lParam); + ListView_SubItemHitTest(hwnd, &hi); + if (hi.iSubItem == 1) + { + LVITEM lvi = {0}; + lvi.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_GROUPID; + lvi.stateMask = -1; + lvi.iItem = hi.iItem; + if (ListView_GetItem(hwnd, &lvi) && lvi.iGroupId == 1) + { + CConversation *convo = (CConversation *)lvi.lParam; + + if (convo->SetBookmark(false)) + ListView_DeleteItem(hwnd, lvi.iItem); + } + } + } + + return ::CallWindowProc(oldWndProc, hwnd, msg, wParam, lParam); +} + +int ImageList_AddIconFromIconLib(HIMAGELIST hIml, const char *name) +{ + HICON icon = ::Skin_GetIconByHandle(::Skin_GetIconHandle(name)); + int res = ImageList_AddIcon(hIml, icon); + ::Skin_ReleaseIcon(icon); + return res; +} + +INT_PTR CALLBACK CSkypeProto::SkypeBookmarksProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + CSkypeProto *ppro = (CSkypeProto *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (msg) + { + case WM_INITDIALOG: + if (lParam) + { + ppro = (CSkypeProto *)lParam; + ::TranslateDialogDefault(hwndDlg); + + ::SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + + ::SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)::Skin_GetIcon("Skype_bookmark", ICON_BIG)); + ::SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)::Skin_GetIcon("Skype_bookmark")); + + HWND hwndList = ::GetDlgItem(hwndDlg, IDC_BM_LIST); + { // IDC_BM_LIST setup + oldWndProc = (WNDPROC)::SetWindowLongPtr(hwndList, GWLP_WNDPROC, (LONG_PTR)BookmarkListWndProc); + + HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0); + ImageList_AddIconFromIconLib(hIml, "Skype_bookmark"); + ImageList_AddIconFromIconLib(hIml, "Skype_delete"); + ListView_SetImageList(hwndList, hIml, LVSIL_SMALL); + + /// + LVCOLUMN lvc = {0}; + lvc.mask = LVCF_WIDTH | LVCF_TEXT; + + //lvc.fmt = LVCFMT_JUSTIFYMASK; + lvc.pszText = TranslateT("Name"); + lvc.cx = 220; // width of column in pixels + ListView_InsertColumn(hwndList, 0, &lvc); + + //lvc.fmt = LVCFMT_RIGHT; + lvc.pszText = L""; + lvc.cx = 32 - GetSystemMetrics(SM_CXVSCROLL); // width of column in pixels + ListView_InsertColumn(hwndList, 1, &lvc); + + /// + LVGROUP lvg; + lvg.cbSize = sizeof(LVGROUP); + lvg.mask = LVGF_HEADER | LVGF_GROUPID; + + lvg.pszHeader = ::TranslateT("Conferences"); + lvg.iGroupId = 1; + ListView_InsertGroup(hwndList, 0, &lvg); + + /*lvg.pszHeader = ::TranslateT("Contacts"); + lvg.iGroupId = 2; + ListView_InsertGroup(hwndList, 0, &lvg);*/ + + ListView_EnableGroupView(hwndList, TRUE); + + ::SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_SUBITEMIMAGES | LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP); + + if ( !ppro->IsOnline()) + ::EnableWindow(hwndList, FALSE); + } + + SEString data; + ConversationRefs conversations; + ppro->GetConversationList(conversations, Conversation::BOOKMARKED_CONVERSATIONS); + for (size_t i = 0; i < conversations.size(); i++) + { + auto conversation = conversations[i]; + + uint type = conversation->GetUintProp(Conversation::P_TYPE); + if (type != Conversation::CONFERENCE) + continue; + + conversation->GetPropDisplayname(data); + ptrW name = ::mir_utf8decodeW(data); + + LVITEM lvi = {0}; + lvi.mask = LVIF_GROUPID | LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; + lvi.iItem = (int)i; + lvi.iGroupId = 1; + lvi.iImage = 0; + lvi.lParam = (LPARAM)conversation.fetch(); + lvi.pszText = name; + int iRow = ListView_InsertItem(hwndList, &lvi); + + if (iRow != -1) + { + lvi.iItem = iRow; + lvi.mask = LVIF_IMAGE; + lvi.iSubItem = 1; + lvi.iImage = 1; + ListView_SetItem(hwndList, &lvi); + } + }; + + ::Utils_RestoreWindowPosition(hwndDlg, 0, MODULE, "BookmarksWindow"); + } + break; + + case WM_NOTIFY: + switch(LOWORD(wParam)) + { + case IDC_BM_LIST: + if (((LPNMHDR)lParam)->code == NM_DBLCLK) + { + HWND hwndList = ::GetDlgItem(hwndDlg, IDC_BM_LIST); + int iItem = ListView_GetNextItem(hwndList, -1, LVNI_ALL | LVNI_SELECTED); + if (iItem < 0) break; + LVITEM lvi = {0}; + lvi.mask = LVIF_PARAM; + lvi.stateMask = -1; + lvi.iItem = iItem; + if (ListView_GetItem(hwndList, &lvi)) + { + //ppro->FindChatRoom + + CConversation *conversation = (CConversation *)lvi.lParam; + + SEString data; + conversation->GetPropIdentity(data); + ptrW cid = ::mir_utf8decodeW(data); + CSkypeProto::ReplaceSpecialChars(cid); + + ChatRoom *room = ppro->FindChatRoom(cid); + if (room != NULL) + ::CallProtoService(ppro->m_szModuleName, PS_JOINCHAT, (WPARAM)room->GetContactHandle(), 0); + else + { + conversation->GetPropDisplayname(data); + ptrW name = ::mir_utf8decodeW(data); + + ChatRoom *room = new ChatRoom(cid, name, ppro); + room->Start(conversation->ref(), true); + } + } + } + } + break; + + case WM_COMMAND: + if (HIWORD( wParam ) == BN_CLICKED) + { + switch(LOWORD(wParam)) + { + case IDCANCEL: + ::Utils_SaveWindowPosition(hwndDlg, NULL, MODULE, "BookmarksWindow"); + ::Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0)); + ::Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0)); + ::DestroyWindow(hwndDlg); + return TRUE; + } + } + break; + } + return FALSE; +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype_chat.cpp b/plugins/!Deprecated/Skype/src/skype_chat.cpp new file mode 100644 index 0000000000..2f2f166566 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_chat.cpp @@ -0,0 +1,1735 @@ +#include "skype.h" +#include "skype_chat.h" + +enum CHAT_LIST_MENU +{ + ICM_CANCEL, + + ICM_DETAILS, + ICM_AUTH_REQUEST, + ICM_CONF_INVITE, + ICM_ROLE, ICM_ROLE_ADMIN, ICM_ROLE_SPEAKER, ICM_ROLE_WRITER, ICM_ROLE_SPECTATOR, + ICM_ADD, ICM_KICK, ICM_BAN, + ICM_COPY_SID, ICM_COPY_URI +}; + +static struct gc_item crListItems[] = +{ + { LPGENT("&User details"), ICM_DETAILS, MENU_ITEM }, + { LPGENT("&Request auth"), ICM_AUTH_REQUEST, MENU_ITEM }, + { NULL, 0, MENU_SEPARATOR }, + { LPGENT("Invite to conference"), ICM_CONF_INVITE, MENU_ITEM }, + { NULL, 0, MENU_SEPARATOR }, + { LPGENT("Set &role"), ICM_ROLE, MENU_NEWPOPUP }, + { LPGENT("&Master"), ICM_ROLE_ADMIN, MENU_POPUPITEM }, + { LPGENT("&Helper"), ICM_ROLE_SPEAKER, MENU_POPUPITEM }, + { LPGENT("&User"), ICM_ROLE_WRITER, MENU_POPUPITEM }, + { LPGENT("&Listener"), ICM_ROLE_SPECTATOR, MENU_POPUPITEM }, + { NULL, 0, MENU_SEPARATOR }, + { LPGENT("&Add"), ICM_ADD, MENU_ITEM }, + { LPGENT("&Kick"), ICM_KICK, MENU_ITEM }, + { LPGENT("Outlaw (&ban)"), ICM_BAN, MENU_ITEM }, + { NULL, 0, MENU_SEPARATOR }, + { LPGENT("Copy &Skype name"), ICM_COPY_SID, MENU_ITEM }, + { LPGENT("Copy room &URI"), ICM_COPY_URI, MENU_ITEM } +}; + +static void CheckChatMenuItem(CHAT_LIST_MENU checkedId) +{ + for (int i = 0; i < SIZEOF(crListItems); i++) + { + if (crListItems[i].dwID == checkedId) + { + if (crListItems[i].uType == MENU_ITEM) + crListItems[i].uType = MENU_CHECK; + else if (crListItems[i].uType == MENU_POPUPITEM) + crListItems[i].uType = MENU_POPUPCHECK; + break; + } + } +} + +static void DisableChatMenuItem(CHAT_LIST_MENU disabledId) +{ + for (int i = 0; i < SIZEOF(crListItems); i++) + { + if (crListItems[i].dwID == disabledId) + { + crListItems[i].bDisabled = TRUE; + break; + } + } +} + +static void DisableChatMenuItems(CHAT_LIST_MENU disabledIds[]) +{ + for (int i = 0; i < SIZEOF(disabledIds); i++) + DisableChatMenuItem(disabledIds[i]); +} + +static void ResetChatMenuItem() +{ + for (int i = 0; i < SIZEOF(crListItems); i++) + { + crListItems[i].bDisabled = FALSE; + if (crListItems[i].uType == MENU_CHECK) + crListItems[i].uType = MENU_ITEM; + else if (crListItems[i].uType == MENU_POPUPCHECK) + crListItems[i].uType = MENU_POPUPITEM; + } +} + +void CSkypeProto::InitChatModule() +{ + GCREGISTER gcr = {0}; + gcr.cbSize = sizeof(gcr); + gcr.iMaxText = 0; + gcr.ptszDispName = this->m_tszUserName; + gcr.pszModule = this->m_szModuleName; + ::CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr); + + this->HookProtoEvent(ME_GC_EVENT, &CSkypeProto::OnGCEventHook); + this->HookProtoEvent(ME_GC_BUILDMENU, &CSkypeProto::OnGCMenuHook); +} + +/// + +TCHAR *ChatRoom::Roles[] = +{ + _T(""), // --- + LPGENT("Creator"), // CREATOR = 1 + LPGENT("Master"), // ADMIN = 2 + LPGENT("Helper"), // SPEAKER = 3 + LPGENT("User"), // WRITER = 4 + LPGENT("Listener"), // SPECTATOR= 5 + LPGENT("Applicant"), // APPLICANT= 6 + LPGENT("Retried"), // RETIRED = 7 + LPGENT("Outlaw"), // OUTLAW = 8 +}; + +ChatRoom::ChatRoom(const wchar_t *cid) : members(1, CompareMembers) +{ + this->cid = ::mir_wstrdup(cid); + this->name = NULL; + this->me = NULL; +} + +ChatRoom::ChatRoom(const wchar_t *cid, const wchar_t *name, CSkypeProto *ppro) : members(1, CompareMembers) +{ + this->cid = ::mir_wstrdup(cid); + this->name = ::mir_wstrdup(name); + this->ppro = ppro; + // + this->me = new ChatMember(ppro->login); + this->me->SetNick(::TranslateT("me")); + this->me->SetRank(0); + this->me->SetStatus(ID_STATUS_OFFLINE); + // + this->sys = new ChatMember(L"sys"); + this->sys->SetNick(L"System"); + this->sys->SetRank(0); + this->sys->SetStatus(ID_STATUS_OFFLINE); +} + +ChatRoom::~ChatRoom() +{ + ::mir_free(this->cid); + ::mir_free(this->name); + delete this->me; + delete this->sys; + this->members.destroy(); +} + +MCONTACT ChatRoom::GetContactHandle() const +{ + return this->hContact; +} + +void ChatRoom::CreateChatSession(bool showWindow) +{ + SEString data; + + // start chat session + GCSESSION gcw = {0}; + gcw.cbSize = sizeof(gcw); + gcw.iType = GCW_CHATROOM; + gcw.pszModule = ppro->m_szModuleName; + gcw.ptszName = this->name; + gcw.ptszID = this->cid; + gcw.dwItemData = (DWORD)this; + ::CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw); + + // load chat roles + GCDEST gcd = { ppro->m_szModuleName, this->cid, GC_EVENT_ADDGROUP }; + GCEVENT gce = { sizeof(gce), &gcd }; + for (int i = 1; i < SIZEOF(ChatRoom::Roles) - 2; i++) { + gce.ptszStatus = ::TranslateTS(ChatRoom::Roles[i]); + ::CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); + } + + // init [and show window] + gcd.iType = GC_EVENT_CONTROL; + gce.ptszStatus = NULL; + ::CallServiceSync(MS_GC_EVENT, showWindow ? SESSION_INITDONE : WINDOW_HIDDEN, (LPARAM)&gce); + ::CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce); + + this->ppro->debugLogW(L"Created new chat session %s", this->cid); +} + +void ChatRoom::SetTopic(const wchar_t *topic) +{ + if (this->conversation) + this->conversation->SetTopic((char *)ptrA(::mir_utf8encodeW(topic))); +} + +wchar_t *ChatRoom::GetUri() +{ + SEString data; + this->conversation->GetJoinBlob(data); + ptrW blob( ::mir_utf8decodeW(data)); + + wchar_t *uri = (wchar_t *)::mir_alloc(sizeof(wchar_t) * MAX_PATH); + ::mir_sntprintf(uri, SIZEOF(uri), L"skype:?chat&blob=%s", blob); + + return uri; +} + +void ChatRoom::ShowWindow() +{ + // show window + GCDEST gcd = { this->ppro->m_szModuleName, this->cid, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; + ::CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gce); +} + +void ChatRoom::Invite(const StringList &contacts) +{ + SEStringList needToAdd; + for (size_t i = 0; i < contacts.size(); i++) + { + if ( !contacts.contains(contacts[i])) + needToAdd.append((char *)_T2A(contacts[i])); + } + this->conversation->AddConsumers(needToAdd); +} + +void ChatRoom::Create(const ChatRoomParam *param, CSkypeProto *ppro) +{ + SEString data; + ChatRoom *room = NULL; + + ConversationRef conversation; + if (ppro->CreateConference(conversation)) + { + conversation->SetOption(Conversation::P_OPT_JOINING_ENABLED, param->enableJoining); + conversation->SetOption(Conversation::P_OPT_ENTRY_LEVEL_RANK, (Participant::RANK)param->joinRank); + conversation->SetOption(Conversation::P_OPT_DISCLOSE_HISTORY, true); + if (::wcslen(param->topic) > 0) + conversation->SetTopic((char *)ptrA(::mir_utf8encodeW(param->topic))); + if (::wcslen(param->guidline) > 0) + conversation->SetGuidelines((char *)ptrA(::mir_utf8encodeW(param->guidline))); + if (param->passwordProtection && ::wcslen(param->password) > 0) + { + conversation->SetPassword( + (char *)ptrA(::mir_utf8encodeW(param->password)), + (char *)ptrA(::mir_utf8encodeW(param->hint))); + } + + SEStringList consumers; + for (size_t i = 0; i < param->invitedContacts.size(); i++) + { + data = ::mir_utf8encodeW(param->invitedContacts[i]); + consumers.append(data); + } + conversation->AddConsumers(consumers); + } +} + +void ChatRoom::Start(const ConversationRef &conversation, bool showWindow) +{ + SEString data; + + this->CreateChatSession(showWindow); + + this->conversation = conversation; + this->conversation.fetch(); + this->conversation->SetChatRoom(this); + + GC_INFO gci = { 0 }; + gci.Flags = GCF_BYID | GCF_HCONTACT; + gci.pszModule = ppro->m_szModuleName; + gci.pszID = this->cid; + + if ( !::CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci)) { + this->hContact = gci.hContact; + ptrW cid( ::db_get_wsa(gci.hContact, ppro->m_szModuleName, SKYPE_SETTINGS_SID)); + if (cid == NULL) { + this->conversation->GetPropIdentity(data); + cid = ::mir_utf8decodeW(data); + ::db_set_ws(gci.hContact, ppro->m_szModuleName, SKYPE_SETTINGS_SID, cid); + } + } + + ParticipantRefs participants; + this->conversation->GetParticipants(participants, Conversation::CONSUMERS_AND_APPLICANTS); + for (uint i = 0; i < participants.size(); i++) + { + auto participant = participants[i]; + + participant->GetPropIdentity(data); + ptrW sid( ::mir_utf8decodeW(data)); + + ChatMember member(sid); + member.SetRank(participant->GetUintProp(Participant::P_RANK)); + + Contact::Ref contact; + this->ppro->GetContact(data, contact); + + Contact::AVAILABILITY status; + contact->GetPropAvailability(status); + member.SetStatus(CSkypeProto::SkypeToMirandaStatus(status)); + + contact->GetPropFullname(data); + if (data.length() != 0) + { + ptrW nick( ::mir_utf8decodeW(data)); + member.SetNick(nick); + } + + member.SetPaticipant(participant); + /*member.participant.fetch(); + member.participant->SetOnChangedCallback(&ChatRoom::OnParticipantChanged, this);*/ + + this->AddMember(member, NULL, NULL); + } +} + +void ChatRoom::Join(const wchar_t *joinBlob, CSkypeProto *ppro) +{ + SEString data; + ConversationRef conversation; + if (ppro->GetConversationByBlob(data, conversation)) + { + conversation->GetPropIdentity(data); + ptrW cid(::mir_utf8decodeW(data)); + + conversation->GetPropDisplayname(data); + ptrW name(::mir_utf8decodeW(data)); + + CSkypeProto::ReplaceSpecialChars(cid); + ChatRoom *room = new ChatRoom(cid, name, ppro); + ppro->chatRooms.insert(room); + room->Start(conversation, true); + } +} + +void ChatRoom::SendMessage(const wchar_t *text) +{ + this->ppro->debugLogW(L"Sending chat message %s", this->cid); + + CMessage::Ref message; + if (this->conversation->PostText((char *)ptrA(::mir_utf8encodeW(text)), message)) + this->ppro->debugLogW(L"Chat message sent %s", this->cid); +} + +void ChatRoom::LeaveChat() +{ + this->ppro->debugLogW(L"Leaving chat session %s", this->cid); + + if (this->conversation->RetireFrom()) + this->ppro->debugLogW(L"Retired from conversation %s", this->cid); + + GCDEST gcd = { ppro->m_szModuleName, this->cid, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; + ::CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce); + ::CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce); +} + +void ChatRoom::LeaveChatAndDelete() +{ + this->ppro->debugLogW(L"Leaving chat session %s", this->cid); + + if (this->conversation->RetireFrom()) + this->ppro->debugLogW(L"Retired from conversation %s", this->cid); + + if (this->conversation->Delete()) + this->ppro->debugLogW(L"Delete conversation %s", this->cid); + + GCDEST gcd = { ppro->m_szModuleName, this->cid, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; + ::CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce); + ::CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce); +} + +void ChatRoom::SendEvent(const ChatMember &item, int eventType, DWORD timestamp, DWORD flags, DWORD itemData, const wchar_t *status, const wchar_t *message) +{ + bool isMe = this->IsMe(item); + + GCDEST gcd = { ppro->m_szModuleName, this->cid, eventType }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = flags; + gce.ptszUID = item.GetSid(); + gce.ptszNick = !isMe ? item.GetNick() : ::TranslateT("me"); + gce.bIsMe = isMe; + gce.dwItemData = itemData; + gce.ptszStatus = status; + gce.ptszText = message; + gce.time = timestamp; + + ::CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); +} + +void ChatRoom::SendEvent(const wchar_t *sid, int eventType, DWORD timestamp, DWORD flags, DWORD itemData, const wchar_t *status, const wchar_t *message) +{ + if (this->IsMe(sid)) + this->SendEvent(*this->me, eventType, timestamp, flags, itemData, status, message); + else if (this->IsSys(sid)) + this->SendEvent(*this->sys, eventType, timestamp, flags, itemData, status, message); + else + { + ChatMember search(sid); + ChatMember *member = this->members.find(&search); + if (member != NULL) + this->SendEvent(*member, eventType, timestamp, flags, itemData, status, message); + } +} + +bool ChatRoom::IsMe(const wchar_t *sid) const +{ + return ::lstrcmpi(this->ppro->login, sid) == 0; +} + +bool ChatRoom::IsMe(const ChatMember &item) const +{ + return ::lstrcmpi(this->ppro->login, item.GetSid()) == 0; +} + +bool ChatRoom::IsSys(const wchar_t *sid) const +{ + return ::lstrcmpi(L"sys", sid) == 0; +} + +bool ChatRoom::IsSys(const ChatMember &item) const +{ + return ::lstrcmpi(L"sys", item.GetSid()) == 0; +} + +ChatMember *ChatRoom::FindChatMember(const wchar_t *sid) +{ + if ( !IsMe(sid)) + { + ChatMember search(sid); + return this->members.find(&search); + } + else + return this->me; +} + +void ChatRoom::AddMember(const ChatMember &item, const ChatMember &author, DWORD timestamp) +{ + if ( !this->IsMe(item)) + { + ChatMember *member = this->FindChatMember(item.GetSid()); + if (member != NULL) + { + this->UpdateMember(item, timestamp); + } + else + { + ChatMember *newMember = new ChatMember(item); + newMember->participant.fetch(); + newMember->participant->SetChatRoom(this); + //newMember->participant->SetOnChangedCallback(&ChatRoom::OnParticipantChanged, this); + this->members.insert(newMember); + + if (newMember->GetRank() == CParticipant::APPLICANT) + this->SendEvent( + *this->sys, + GC_EVENT_INFORMATION, + time(NULL), + GCEF_ADDTOLOG, + 0, + NULL, + ::TranslateT("waits to join")); + else + this->SendEvent(item, GC_EVENT_JOIN, timestamp, GCEF_ADDTOLOG, 0, ::TranslateW(ChatRoom::Roles[item.GetRank()])); + + int status = item.GetStatus(); + if (status == ID_STATUS_AWAY || status == ID_STATUS_DND) + this->SendEvent(item, GC_EVENT_SETSTATUSEX, timestamp, 0, GC_SSE_ONLYLISTED | GC_SSE_ONLINE, (const wchar_t*)0, item.GetSid()); + else if (status == ID_STATUS_OFFLINE) + this->SendEvent(item, GC_EVENT_SETSTATUSEX, timestamp, 0, GC_SSE_ONLYLISTED | GC_SSE_OFFLINE, (const wchar_t*)0, item.GetSid()); + else + this->SendEvent(item, GC_EVENT_SETSTATUSEX, timestamp, 0, GC_SSE_ONLYLISTED, (const wchar_t*)0, item.GetSid()); + + this->SendEvent(item, GC_EVENT_SETCONTACTSTATUS, timestamp, 0, status); + } + } + else + { + if (!this->me->participant) + { + this->me->participant = item.participant; + this->me->participant.fetch(); + this->me->participant->SetChatRoom(this); + //this->me->participant->SetOnChangedCallback(&ChatRoom::OnParticipantChanged, this); + } + if (this->me->GetRank() != item.GetRank()) + { + this->SendEvent(*this->me, GC_EVENT_REMOVESTATUS, timestamp, 0, 0, ::TranslateW(ChatRoom::Roles[this->me->GetRank()])); + this->SendEvent(*this->me, GC_EVENT_ADDSTATUS, timestamp, !this->me->GetRank() ? 0 : GCEF_ADDTOLOG, 0, ::TranslateW(ChatRoom::Roles[item.GetRank()]), author == NULL ? this->sys->GetNick() : author.GetNick()); + this->me->SetRank(item.GetRank()); + } + } +} + +void ChatRoom::UpdateMemberNick(ChatMember *member, const wchar_t *nick, DWORD timestamp) +{ + if (::lstrcmp(member->GetNick(), nick) != 0) + { + this->SendEvent(*member, GC_EVENT_NICK, timestamp, GCEF_ADDTOLOG, 0, nick); + member->SetNick(nick); + } +} + +void ChatRoom::UpdateMemberRole(ChatMember *member, int role, const ChatMember &author, DWORD timestamp) +{ + if (member->GetRank() != role) + { + this->SendEvent(*member, GC_EVENT_REMOVESTATUS, timestamp, 0, 0, ::TranslateW(ChatRoom::Roles[member->GetRank()])); + this->SendEvent(*member, GC_EVENT_ADDSTATUS, timestamp, GCEF_ADDTOLOG, 0, ::TranslateW(ChatRoom::Roles[role]), author == NULL ? this->sys->GetNick() : author.GetNick()); + member->SetRank(role); + } +} + +void ChatRoom::UpdateMemberStatus(ChatMember *member, int status, DWORD timestamp) +{ + if (member->GetStatus() != status) + { + if (status == ID_STATUS_AWAY || status == ID_STATUS_DND) + this->SendEvent(*member, GC_EVENT_SETSTATUSEX, timestamp, 0, GC_SSE_ONLYLISTED | GC_SSE_ONLINE, (const wchar_t*)0, member->GetSid()); + else if (status == ID_STATUS_OFFLINE) + this->SendEvent(*member, GC_EVENT_SETSTATUSEX, timestamp, 0, GC_SSE_ONLYLISTED | GC_SSE_OFFLINE, (const wchar_t*)0, member->GetSid()); + else + this->SendEvent(*member, GC_EVENT_SETSTATUSEX, timestamp, 0, GC_SSE_ONLYLISTED, (const wchar_t*)0, member->GetSid()); + + this->SendEvent(*member, GC_EVENT_SETCONTACTSTATUS, timestamp, 0, status); + member->SetStatus(status); + } +} + +void ChatRoom::UpdateMember(const wchar_t *sid, const wchar_t *nick, int role, int status, DWORD timestamp) +{ + ChatMember search(sid); + ChatMember *member = this->members.find(&search); + if (member != NULL) + { + this->UpdateMemberNick(member, nick, timestamp); + this->UpdateMemberRole(member, role, NULL, timestamp); + this->UpdateMemberStatus(member, status, timestamp); + } +} + +void ChatRoom::UpdateMember(const ChatMember &item, DWORD timestamp) +{ + ChatMember *member = this->FindChatMember(item.GetSid()); + if (member != NULL) + { + ptrW nick(item.GetNick()); + if (::lstrcmp(member->GetNick(), nick) != 0) + { + this->SendEvent(*member, GC_EVENT_NICK, timestamp, GCEF_ADDTOLOG, 0, nick); + member->SetNick(nick); + } + if (member->GetRank() != item.GetRank()) + { + this->SendEvent(*member, GC_EVENT_REMOVESTATUS, timestamp, 0, 0, ::TranslateW(ChatRoom::Roles[member->GetRank()])); + this->SendEvent(*member, GC_EVENT_ADDSTATUS, timestamp, GCEF_ADDTOLOG, 0, ::TranslateW(ChatRoom::Roles[item.GetRank()])); + member->SetRank(item.GetRank()); + } + if (member->GetStatus() != item.GetStatus()) + { + this->SendEvent(*member, GC_EVENT_SETCONTACTSTATUS, timestamp, 0, item.GetStatus()); + member->SetStatus(item.GetStatus()); + } + } +} + +void ChatRoom::AddApplicant(const ChatMember *member) +{ + SEStringList consumers; + consumers.append((char *)ptrA(::mir_utf8encodeW(member->GetSid()))); + this->conversation->AddConsumers(consumers); +} + +void ChatRoom::KickMember(const ChatMember &item, const ChatMember *author, DWORD timestamp) +{ + if ( !this->IsMe(item)) + { + ChatMember *member = this->FindChatMember(item.GetSid()); + if (member != NULL) + { + this->SendEvent(*member, GC_EVENT_KICK, timestamp, GCEF_ADDTOLOG, 0, author->GetNick()); + this->members.remove(member); + delete member; + } + } + else + { + this->SendEvent(*this->me, GC_EVENT_KICK, timestamp, GCEF_ADDTOLOG, 0, author->GetNick()); + this->me->SetRank(/*RETIRED= */7); + } +} + +void ChatRoom::KickMember(const wchar_t *sid, const wchar_t *author, DWORD timestamp) +{ + ChatMember member(sid); + this->KickMember(member, this->FindChatMember(author), timestamp); +} + +void ChatRoom::RemoveMember(const ChatMember &item, DWORD timestamp) +{ + if ( !this->IsMe(item)) + { + ChatMember *member = this->FindChatMember(item.GetSid()); + if (member != NULL) + { + this->SendEvent(*member, GC_EVENT_PART, timestamp); + this->members.remove(member); + delete member; + } + } + else + this->LeaveChat(); +} + +void ChatRoom::RemoveMember(const wchar_t *sid, DWORD timestamp) +{ + ChatMember member(sid); + this->RemoveMember(member, timestamp); +} + +void ChatRoom::OnEvent(const ConversationRef &conversation, const MessageRef &message) +{ + if ( !this->conversation) + this->conversation = conversation; + + if ( this->conversation != conversation) + return; + + uint messageType; + messageType = message->GetUintProp(Message::P_TYPE); + + switch (messageType) + { + case CMessage::POSTED_EMOTE: + case CMessage::POSTED_TEXT: + { + SEString data; + + message->GetPropAuthor(data); + ptrW sid( ::mir_utf8decodeW(data)); + + message->GetPropBodyXml(data); + ptrW text( ::mir_utf8decodeW( ptrA(CSkypeProto::RemoveHtml(data)))); + + uint timestamp; + message->GetPropTimestamp(timestamp); + + this->SendEvent( + sid, + messageType == CMessage::POSTED_TEXT ? GC_EVENT_MESSAGE : GC_EVENT_ACTION, + timestamp, + GCEF_ADDTOLOG, + 0, + NULL, + text); + } + break; + + case Message::ADDED_CONSUMERS: + case Message::ADDED_APPLICANTS: + { + SEString data; + + Message::CONSUMPTION_STATUS status; + message->GetPropConsumptionStatus(status); + if (status != Message::CONSUMED) + { + uint timestamp; + message->GetPropTimestamp(timestamp); + + message->GetPropAuthor(data); + ChatMember *author = this->FindChatMember((wchar_t *)ptrW(::mir_utf8decodeW(data))); + + ParticipantRefs participants; + conversation->GetParticipants(participants); + for (size_t i = 0; i < participants.size(); i++) + { + participants[i]->GetPropIdentity(data); + ptrW sid(::mir_utf8decodeW(data)); + if (this->FindChatMember(sid) == NULL) + { + ChatMember member(sid); + member.SetRank(participants[i]->GetUintProp(Participant::P_RANK)); + + Contact::Ref contact; + this->ppro->GetContact(data, contact); + + Contact::AVAILABILITY status; + contact->GetPropAvailability(status); + member.SetStatus(CSkypeProto::SkypeToMirandaStatus(status)); + + contact->GetPropFullname(data); + ptrW nick(::mir_utf8decodeW(data)); + if (data.length() != 0) + { + ptrW nick( ::mir_utf8decodeW(data)); + member.SetNick(nick); + } + + member.participant = participants[i]; + /*member.participant.fetch(); + member.participant->SetOnChangedCallback(&ChatRoom::OnParticipantChanged, this);*/ + + this->AddMember(member, *author, timestamp); + } + } + + // do not remove + //message->GetPropIdentities(data); + //char *identities = ::mir_strdup(data); + //if (identities) + //{ + // char *identity = ::strtok(identities, " "); + // if (identity != NULL) + // { + // do + // { + // Contact::Ref contact; + // this->ppro->GetContact(identity, contact); + + // contact->GetIdentity(data); + // ptrW sid = ::mir_utf8decodeW(data); + + // ChatMember *member = new ChatMember(sid); + // //todo: fix rank + // + // member->rank = + // messageType == Message::ADDED_APPLICANTS ? + // Participant::APPLICANT : + // Participant::SPEAKER; + // //conversation->GetUintProp(Conversation::P_OPT_ENTRY_LEVEL_RANK); + // //participants[i]->GetUintProp(Participant::P_RANK); + + // Contact::AVAILABILITY status; + // contact->GetPropAvailability(status); + // member->status = CSkypeProto::SkypeToMirandaStatus(status); + + // contact->GetPropFullname(data); + // member->nick = ::mir_utf8decodeW(data); + + // this->AddMember(member, timestamp); + + // identity = ::strtok(NULL, " "); + // } + // while (identity != NULL); + // } + // ::mir_free(identities); + //} + } + } + break; + + case Message::RETIRED_OTHERS: + { + SEString data; + + Message::CONSUMPTION_STATUS status; + message->GetPropConsumptionStatus(status); + if (status != Message::CONSUMED) + { + this->ppro->debugLogW(L"Retired other event for conversation %s", this->cid); + + uint timestamp; + message->GetPropTimestamp(timestamp); + + message->GetPropAuthor(data); + ptrW author( ::mir_utf8decodeW(data)); + + message->GetPropIdentities(data); + char *identities = ::mir_strdup(data); + if (identities) + { + char *identity = ::strtok(identities, " "); + if (identity != NULL) + { + do + { + ptrW sid(::mir_utf8decodeW(identity)); + this->KickMember(sid, author, timestamp); + + identity = ::strtok(NULL, " "); + } + while (identity != NULL); + } + ::mir_free(identities); + } + } + } + break; + + case Message::RETIRED: + { + SEString data; + + Message::CONSUMPTION_STATUS status; + message->GetPropConsumptionStatus(status); + if (status != Message::CONSUMED) + { + this->ppro->debugLogW(L"Retired event for conversation %s", this->cid); + + uint timestamp; + message->GetPropTimestamp(timestamp); + + message->GetPropAuthor(data); + ptrW sid( ::mir_utf8decodeW(data)); + + this->RemoveMember(sid, timestamp); + } + } + break; + + case Message::SET_RANK: + { + SEString data; + } + break; + // message->GetPropBodyXml(data); + // ptrA text = ::mir_strdup(data); + // int i = 0; + + // /*Message::CONSUMPTION_STATUS status; + // message->GetPropConsumptionStatus(status); + // if (status == Message::UNCONSUMED_NORMAL)*/ + // { + // message->GetPropAuthor(data); + // ptrW sid = ::mir_utf8decodeW(data); + + // ChatMember search(sid); + // ChatMember *member = this->FindChatMember(sid); + // if (member != NULL) + // { + // uint timestamp; + // message->GetPropTimestamp(timestamp); + + // message->GetPropBodyXml(data); + // ptrW rank = ::mir_utf8decodeW(data); + + // member->SetRank(0); + // } + // } + // } + // break; + + /*case CMessage::STARTED_LIVESESSION: + { + SEString data; + + Message::CONSUMPTION_STATUS status; + message->GetPropConsumptionStatus(status); + if (status != Message::UNCONSUMED_NORMAL) + break; + + message->GetPropAuthor(data); + ptrW sid = ::mir_utf8decodeW(data); + + uint timestamp; + message->GetPropTimestamp(timestamp); + + this->SendEvent( + sid, + GC_EVENT_INFORMATION, + timestamp, + GCEF_ADDTOLOG, + 0, + NULL, + ::TranslateT("Incoming group call received")); + } + break;*/ + + case CMessage::ENDED_LIVESESSION: + { + SEString data; + + //Message::CONSUMPTION_STATUS status; + //message->GetPropConsumptionStatus(status); + //if (status != Message::UNCONSUMED_NORMAL) + // break; + + message->GetPropAuthor(data); + ptrW sid( ::mir_utf8decodeW(data)); + + uint timestamp; + message->GetPropTimestamp(timestamp); + + this->SendEvent( + *this->sys, + GC_EVENT_INFORMATION, + timestamp, + GCEF_ADDTOLOG, + 0, + NULL, + ::TranslateT("Incoming group call finished")); + } + break; + } +} + +void ChatRoom::OnChange(const ConversationRef &conversation, int prop) +{ + if ( !this->conversation) + this->conversation = conversation; + + if ( this->conversation != conversation) + return; + + switch (prop) + { + case Conversation::P_MY_STATUS: + { + Conversation::MY_STATUS status; + conversation->GetPropMyStatus(status); + if (status == Conversation::INVALID_ACCESS_TOKEN) + { + PasswordRequestBoxParam param(this->name, false); + if (this->ppro->RequestPassword(param)) + { + if ( !this->conversation->EnterPassword(param.password)) + this->SendEvent( + *this->sys, + GC_EVENT_INFORMATION, + time(NULL), + GCEF_ADDTOLOG, + 0, + NULL, + ::TranslateT("The password is incorrect")); + } + } + else if (status == Conversation::APPLICATION_DENIED) + { + this->SendEvent( + *this->sys, + GC_EVENT_INFORMATION, + time(NULL), + GCEF_ADDTOLOG, + 0, + NULL, + ::TranslateT("Your application to join the conference was denied")); + } + } + break; + + case Conversation::P_LOCAL_LIVESTATUS: + { + Conversation::LOCAL_LIVESTATUS liveStatus; + conversation->GetPropLocalLivestatus(liveStatus); + if (liveStatus == Conversation::RINGING_FOR_ME) + { + SEString data; + + /*Message::CONSUMPTION_STATUS status; + message->GetPropConsumptionStatus(status); + if (status != Message::UNCONSUMED_NORMAL) + break;*/ + + /*message->GetPropAuthor(data); + ptrW sid = ::mir_utf8decodeW(data);*/ + + /*uint timestamp; + message->GetPropTimestamp(timestamp);*/ + + this->SendEvent( + *this->sys, + GC_EVENT_INFORMATION, + time(NULL), + GCEF_ADDTOLOG, + 0, + NULL, + ::TranslateT("Incoming group call started")); + } + } + break; + } +} + +void ChatRoom::OnParticipantChanged(const ParticipantRef &participant, int prop) +{ + if (prop == Participant::P_RANK) + { + Participant::RANK rank; + participant->GetPropRank(rank); + + SEString identity; + participant->GetPropIdentity(identity); + + ptrW sid(::mir_utf8decodeW(identity)); + ChatMember *member = this->FindChatMember(sid); + if (member != NULL) + this->UpdateMemberRole(member, rank); + } +} + +/// + +void CSkypeProto::ChatValidateContact(MCONTACT hItem, HWND hwndList, const StringList &contacts) +{ + if (this->IsProtoContact(hItem) && !this->isChatRoom(hItem)) + { + ptrW sid( ::db_get_wsa(hItem, this->m_szModuleName, SKYPE_SETTINGS_SID)); + if (sid == NULL || contacts.contains(sid)) + ::SendMessage(hwndList, CLM_DELETEITEM, (WPARAM)hItem, 0); + } + else + ::SendMessage(hwndList, CLM_DELETEITEM, (WPARAM)hItem, 0); +} + +void CSkypeProto::ChatPrepare(MCONTACT hItem, HWND hwndList, const StringList &contacts) +{ + if (hItem == NULL) + hItem = (MCONTACT)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0); + + while (hItem) { + MCONTACT hItemN = (MCONTACT)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem); + + if (IsHContactGroup(hItem)) { + MCONTACT hItemT = (MCONTACT)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); + if (hItemT) + this->ChatPrepare(hItemT, hwndList, contacts); + } + else if (IsHContactContact(hItem)) + this->ChatValidateContact(hItem, hwndList, contacts); + + hItem = hItemN; + } +} + +void CSkypeProto::GetInvitedContacts(MCONTACT hItem, HWND hwndList, StringList &chatTargets) +{ + if (hItem == NULL) + hItem = (MCONTACT)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0); + + while (hItem) { + if (IsHContactGroup(hItem)) { + MCONTACT hItemT = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); + if (hItemT) + this->GetInvitedContacts(hItemT, hwndList, chatTargets); + } + else { + int chk = SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0); + if (chk) { + if (IsHContactInfo(hItem)) { + TCHAR buf[128] = _T(""); + SendMessage(hwndList, CLM_GETITEMTEXT, (WPARAM)hItem, (LPARAM)buf); + if (buf[0]) + chatTargets.insert(buf); + } + else { + ptrW login( ::db_get_wsa(hItem, this->m_szModuleName, SKYPE_SETTINGS_SID)); + chatTargets.insert(login); + } + } + } + hItem = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem); + } +} + +INT_PTR CALLBACK CSkypeProto::ChatRoomProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + ChatRoomParam *param = (ChatRoomParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + param = (ChatRoomParam *)lParam; + { + HWND hwndClist = GetDlgItem(hwndDlg, IDC_CCLIST); + SetWindowLongPtr(hwndClist, GWL_STYLE, GetWindowLongPtr(hwndClist, GWL_STYLE) & ~CLS_HIDEOFFLINE); + + if ( !param->ppro->IsOnline()) + { + ::EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE); + ::EnableWindow(GetDlgItem(hwndDlg, IDC_ADDSCR), FALSE); + ::EnableWindow(GetDlgItem(hwndDlg, IDC_CCLIST), FALSE); + } + + SendDlgItemMessage(hwndDlg, IDC_CHAT_JOINING, BM_SETCHECK, param->enableJoining, 0); + for (int i = 1; i < SIZEOF(ChatRoom::Roles) - 4; i++) { + int nItem = ::SendMessage(::GetDlgItem(hwndDlg, IDC_CHAT_ROLES), CB_ADDSTRING, 0, (LPARAM)::TranslateW(ChatRoom::Roles[i])); + + if (i == Participant::WRITER) + ::SendMessage(::GetDlgItem(hwndDlg, IDC_CHAT_ROLES), CB_SETCURSEL, nItem, 0); + } + + SendDlgItemMessage(hwndDlg, IDC_CHAT_SECURED, BM_SETCHECK, param->passwordProtection, 0); + } + break; + + case WM_CLOSE: + ::EndDialog(hwndDlg, 0); + break; + + case WM_NOTIFY: + { + NMCLISTCONTROL *nmc = (NMCLISTCONTROL *)lParam; + if (nmc->hdr.idFrom == IDC_CCLIST) { + switch (nmc->hdr.code) { + case CLN_NEWCONTACT: + if (param && (nmc->flags & (CLNF_ISGROUP | CLNF_ISINFO)) == 0) + param->ppro->ChatValidateContact((MCONTACT)nmc->hItem, nmc->hdr.hwndFrom, param->invitedContacts); + break; + + case CLN_LISTREBUILT: + if (param) + param->ppro->ChatPrepare(NULL, nmc->hdr.hwndFrom, param->invitedContacts); + break; + } + } + } + break; + + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDC_ADDSCR: + if (param->ppro->IsOnline()) + { + wchar_t sid[SKYPE_SID_LIMIT]; + ::GetDlgItemText(hwndDlg, IDC_EDITSCR, sid, SIZEOF(sid)); + + CLCINFOITEM cii = {0}; + cii.cbSize = sizeof(cii); + cii.flags = CLCIIF_CHECKBOX | CLCIIF_BELOWCONTACTS; + cii.pszText = ::wcslwr(sid); + + HANDLE hItem = (HANDLE)::SendDlgItemMessage(hwndDlg, IDC_CCLIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii); + ::SendDlgItemMessage(hwndDlg, IDC_CCLIST, CLM_SETCHECKMARK, (LPARAM)hItem, 1); + } + break; + + case IDC_CHAT_SECURED: + { + BOOL enable = (BOOL)::IsDlgButtonChecked(hwndDlg, IDC_CHAT_SECURED); + ::EnableWindow(::GetDlgItem(hwndDlg, IDC_CHAT_PASSWORD), enable); + ::EnableWindow(::GetDlgItem(hwndDlg, IDC_CHAT_CONFIRMATION), enable); + ::EnableWindow(::GetDlgItem(hwndDlg, IDC_CHAT_HINT), enable); + } + break; + + case IDC_CHAT_PASSWORD: + case IDC_CHAT_CONFIRMATION: + { + wchar_t pwd[32], cfn[32]; + GetDlgItemText(hwndDlg, IDC_CHAT_PASSWORD, pwd, SIZEOF(pwd)); + GetDlgItemText(hwndDlg, IDC_CHAT_CONFIRMATION, cfn, SIZEOF(cfn)); + + BOOL secured = ::IsDlgButtonChecked(hwndDlg, IDC_CHAT_SECURED); + ::EnableWindow(::GetDlgItem(hwndDlg, IDOK), secured && ::wcscmp(pwd, cfn) == 0); + } + break; + + case IDOK: + { + HWND hwndList = ::GetDlgItem(hwndDlg, IDC_CCLIST); + + param->invitedContacts.clear(); + param->ppro->GetInvitedContacts(NULL, hwndList, param->invitedContacts); + + if ( !param->invitedContacts.empty()) + { + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + ::EndDialog(hwndDlg, IDOK); + } + else + param->ppro->ShowNotification(::TranslateT("You did not select any contact")); + + GetDlgItemText(hwndDlg, IDC_CHAT_TOPIC, param->topic, SIZEOF(param->topic)); + GetDlgItemText(hwndDlg, IDC_CHAT_GUIDLINE, param->guidline, SIZEOF(param->guidline)); + + param->enableJoining = ::IsDlgButtonChecked(hwndDlg, IDC_CHAT_JOINING) != 0; + param->joinRank = ::SendMessage(::GetDlgItem(hwndDlg, IDC_CHAT_ROLES), CB_GETCURSEL, 0, 0) + 1; + + param->passwordProtection = ::IsDlgButtonChecked(hwndDlg, IDC_CHAT_SECURED) != 0; + if (param->passwordProtection) + { + GetDlgItemText(hwndDlg, IDC_CHAT_PASSWORD, param->password, SIZEOF(param->password)); + GetDlgItemText(hwndDlg, IDC_CHAT_CONFIRMATION, param->confirmation, SIZEOF(param->confirmation)); + GetDlgItemText(hwndDlg, IDC_CHAT_HINT, param->hint, SIZEOF(param->hint)); + } + } + break; + + case IDCANCEL: + ::EndDialog(hwndDlg, IDCANCEL); + break; + } + break; + } + return FALSE; +} + +INT_PTR CSkypeProto::CreateChatRoomCommand(WPARAM, LPARAM) +{ + ChatRoomParam *param = new ChatRoomParam(NULL, NULL, this); + + if (::DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CHATROOM_CREATE), NULL, CSkypeProto::ChatRoomProc, (LPARAM)param) == IDOK && param->invitedContacts.size() > 0) + ChatRoom::Create(param, this); + + delete param; + + return 0; +} + +void CSkypeProto::ChatRoomInvite(MCONTACT hContact) +{ + ptrT chat_id(::db_get_tsa(hContact, this->m_szModuleName, "ChatRoomID")); + + GC_INFO gci = { 0 }; + gci.Flags = GCF_BYID | GCF_USERS | GCF_DATA; + gci.pszModule = this->m_szModuleName; + gci.pszID = chat_id; + if ( !::CallService(MS_GC_GETINFO, 0, (LPARAM)&gci)) { + ChatRoom *room = (ChatRoom *)gci.dwItemData; + if (room != NULL && gci.pszUsers != NULL) { + StringList invitedContacts(_A2T(gci.pszUsers)); + ChatRoomParam *param = new ChatRoomParam(NULL, invitedContacts, this); + + if (::DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, CSkypeProto::ChatRoomProc, (LPARAM)param) == IDOK && param->invitedContacts.size() > 0) + room->Invite(param->invitedContacts); + + delete param; + } + } +} + +void CSkypeProto::CloseAllChatSessions() +{ + GC_INFO gci = {0}; + gci.Flags = GCF_BYINDEX | GCF_ID | GCF_DATA; + gci.pszModule = this->m_szModuleName; + + int count = ::CallServiceSync(MS_GC_GETSESSIONCOUNT, 0, (LPARAM)this->m_szModuleName); + for (int i = 0; i < count ; i++) + { + gci.iItem = i; + if ( !::CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci)) + { + GCDEST gcd = { this->m_szModuleName, gci.pszID, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; + ::CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce); + ::CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce); + } + } +} + +ChatRoom *CSkypeProto::FindChatRoom(const wchar_t *cid) +{ + GC_INFO gci = { 0 }; + gci.Flags = GCF_BYID | GCF_DATA; + gci.pszModule = this->m_szModuleName; + gci.pszID = (wchar_t*)cid; + + if ( !::CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci)) + return (ChatRoom *)gci.dwItemData; + + return NULL; +} + +int __cdecl CSkypeProto::OnGCEventHook(WPARAM, LPARAM lParam) +{ + GCHOOK *gch = (GCHOOK *)lParam; + if (!gch) return 1; + + if (::strcmp(gch->pDest->pszModule, this->m_szModuleName) != 0) + return 0; + + ChatRoom *room = this->FindChatRoom(gch->pDest->ptszID); + if (room == NULL) + return 0; + + switch (gch->pDest->iType) + { + case GC_USER_MESSAGE: + if (gch->ptszText && gch->ptszText[0]) + room->SendMessage(gch->ptszText); + break; + + /*case GC_USER_CHANMGR: + if (this->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation, false)) + { + StringList invitedContacts(this->GetChatUsers(cid)); + this->InviteConactsToChat(conversation, invitedContacts); + } + break;*/ + + case GC_USER_PRIVMESS: + ::CallService(MS_MSG_SENDMESSAGE, (WPARAM)this->GetContactBySid(gch->ptszUID), 0); + break; + + case GC_USER_LOGMENU: + case GC_USER_NICKLISTMENU: + switch (gch->dwData) + { + case CHAT_LIST_MENU::ICM_ROLE_ADMIN: + case CHAT_LIST_MENU::ICM_ROLE_SPEAKER: + case CHAT_LIST_MENU::ICM_ROLE_WRITER: + case CHAT_LIST_MENU::ICM_ROLE_SPECTATOR: + { + ChatMember *member = room->FindChatMember(gch->ptszUID); + if (member != NULL) + { + Participant::RANK rank; + switch (gch->dwData) + { + case CHAT_LIST_MENU::ICM_ROLE_ADMIN: + rank = Participant::ADMIN; + break; + + case CHAT_LIST_MENU::ICM_ROLE_SPEAKER: + rank = Participant::SPEAKER; + break; + + case CHAT_LIST_MENU::ICM_ROLE_WRITER: + rank = Participant::WRITER; + break; + + case CHAT_LIST_MENU::ICM_ROLE_SPECTATOR: + rank = Participant::SPECTATOR; + break; + } + if (member->participant && member->participant->SetRankTo(rank)) + room->UpdateMemberRole(member, rank, *room->me); + } + } + break; + + case CHAT_LIST_MENU::ICM_ADD: + { + ChatMember *member = room->FindChatMember(gch->ptszUID); + if (member != NULL) + room->AddApplicant(member); + } + break; + + case CHAT_LIST_MENU::ICM_KICK: + { + ChatMember *member = room->FindChatMember(gch->ptszUID); + if (member != NULL) + { + if (member->participant && member->participant->Retire()) + room->KickMember(gch->ptszUID, room->me->GetSid()); + } + } + break; + + case CHAT_LIST_MENU::ICM_BAN: + { + ChatMember *member = room->FindChatMember(gch->ptszUID); + if (member != NULL && member->participant) + { + member->participant->SetRankTo(Participant::OUTLAW); + if (member->participant->Retire()) + room->KickMember(gch->ptszUID, room->me->GetSid()); + } + } + break; + + case CHAT_LIST_MENU::ICM_CONF_INVITE: + { + GC_INFO gci = { 0 }; + gci.Flags = GCF_BYID | GCF_USERS; + gci.pszModule = this->m_szModuleName; + gci.pszID = gch->pDest->ptszID; + if ( !::CallService(MS_GC_GETINFO, 0, (LPARAM)&gci) && gci.pszUsers != NULL) + { + StringList invitedContacts(_A2T(gci.pszUsers)); + ChatRoomParam *param = new ChatRoomParam(NULL, invitedContacts, this); + + if (::DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, CSkypeProto::ChatRoomProc, (LPARAM)param) == IDOK && param->invitedContacts.size() > 0) + room->Invite(param->invitedContacts); + + delete param; + } + } + break; + + case CHAT_LIST_MENU::ICM_AUTH_REQUEST: + { + CContact::Ref contact; + SEString sid((char *)ptrA(::mir_utf8encodeW(gch->ptszUID))); + if (this->GetContact(sid, contact)) + { + this->AuthRequest( + this->AddContact(contact), + LPGENT("Hi! I'd like to add you to my contact list")); + } + } + break; + + case CHAT_LIST_MENU::ICM_DETAILS: + ::CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)this->GetContactBySid(gch->ptszUID), 0); + break; + + case CHAT_LIST_MENU::ICM_COPY_SID: + { + MCONTACT hContact = this->GetContactBySid(gch->ptszUID); + if (!hContact) + { + ptrW sid( ::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID)); + if (sid != NULL) + CSkypeProto::CopyToClipboard(sid); + } + } + break; + + case CHAT_LIST_MENU::ICM_COPY_URI: + CSkypeProto::CopyToClipboard(ptrW(room->GetUri())); + break; + } + break; + + //case GC_USER_TYPNOTIFY: + //break; + } + return 0; +} + +int __cdecl CSkypeProto::OnGCMenuHook(WPARAM, LPARAM lParam) +{ + GCMENUITEMS *gcmi = (GCMENUITEMS*) lParam; + + if (::stricmp(gcmi->pszModule, this->m_szModuleName) != 0) + return 0; + + ChatRoom *room = this->FindChatRoom(gcmi->pszID); + if (room == NULL) + return 0; + + ResetChatMenuItem(); + + if (room->me->GetRank() > Participant::ADMIN || room->me->GetRank() == 0) + { + DisableChatMenuItem(ICM_ROLE); + DisableChatMenuItem(ICM_ADD); + DisableChatMenuItem(ICM_KICK); + DisableChatMenuItem(ICM_BAN); + } + + //todo: add other case + if (room->me->GetRank() >= Participant::APPLICANT) + { + DisableChatMenuItem(ICM_CONF_INVITE); + } + + ChatMember *member = room->FindChatMember(gcmi->pszUID); + if (member != NULL) + { + if (member->GetRank() == Participant::CREATOR) + { + DisableChatMenuItem(ICM_ROLE); + DisableChatMenuItem(ICM_ADD); + DisableChatMenuItem(ICM_KICK); + DisableChatMenuItem(ICM_BAN); + } + + if (member->GetRank() <= Participant::SPECTATOR) + { + CHAT_LIST_MENU type = (CHAT_LIST_MENU)(ICM_ROLE + member->GetRank() - 1); + CheckChatMenuItem(type); + DisableChatMenuItem(type); + + DisableChatMenuItem(ICM_ADD); + } + + if (member->GetRank() > Participant::SPECTATOR) + DisableChatMenuItem(ICM_ROLE); + + MCONTACT hContact = this->GetContactBySid(gcmi->pszUID); + if (hContact == NULL) + DisableChatMenuItem(ICM_DETAILS); + else if(this->getByte(hContact, "Auth", 0) == 0) + DisableChatMenuItem(ICM_AUTH_REQUEST); + } + else + { + DisableChatMenuItem(ICM_DETAILS); + DisableChatMenuItem(ICM_AUTH_REQUEST); + DisableChatMenuItem(ICM_ROLE); + DisableChatMenuItem(ICM_ADD); + DisableChatMenuItem(ICM_KICK); + DisableChatMenuItem(ICM_BAN); + DisableChatMenuItem(ICM_COPY_SID); + } + + gcmi->nItems = SIZEOF(crListItems); + gcmi->Item = crListItems; + + return 0; +} + +void CSkypeProto::UpdateChatUserStatus(const ContactRef &contact) +{ + CContact::AVAILABILITY availability; + contact->GetPropAvailability(availability); + + SEString identity; + contact->GetIdentity(identity); + ptrW sid(::mir_utf8decodeW(identity)); + + GC_INFO gci = { 0 }; + gci.Flags = GCF_BYINDEX | GCF_DATA; + gci.pszModule = this->m_szModuleName; + + int count = ::CallServiceSync(MS_GC_GETSESSIONCOUNT, 0, (LPARAM)this->m_szModuleName); + for (int i = 0; i < count ; i++) + { + gci.iItem = i; + ::CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci); + + ChatRoom *room = (ChatRoom *)gci.dwItemData; + if (room != NULL) + { + ChatMember *member = room->FindChatMember(sid); + if (member != NULL) + room->UpdateMemberStatus(member, CSkypeProto::SkypeToMirandaStatus(availability)); + } + } +} + +void CSkypeProto::UpdateChatUserNick(const ContactRef &contact) +{ + SEString data; + + contact->GetIdentity(data); + ptrW sid(::mir_utf8decodeW(data)); + + ptrW nick(::mir_utf8decodeW(((CContact::Ref)contact)->GetNick())); + + GC_INFO gci = { 0 }; + gci.Flags = GCF_BYINDEX | GCF_DATA; + gci.pszModule = this->m_szModuleName; + + int count = ::CallServiceSync(MS_GC_GETSESSIONCOUNT, 0, (LPARAM)this->m_szModuleName); + for (int i = 0; i < count ; i++) + { + gci.iItem = i; + ::CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci); + + ChatRoom *room = (ChatRoom *)gci.dwItemData; + if (room != NULL) + { + ChatMember *member = room->FindChatMember(sid); + if (member != NULL) + room->UpdateMemberNick(member, nick); + } + } +} + +INT_PTR __cdecl CSkypeProto::OnJoinChat(WPARAM wParam, LPARAM) +{ + MCONTACT hContact = (MCONTACT)wParam; + if (hContact) + { + ptrW cid(::db_get_wsa(hContact, this->m_szModuleName, "ChatRoomID")); + + ChatRoom *room = this->FindChatRoom(cid); + if ( !room) + { + ConversationRef conversation; + if (this->GetConversationByIdentity( + (char *)_T2A(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID)), + conversation)) + { + SEString data; + conversation->GetJoinBlob(data); + ptrW joinBlob(::mir_utf8decodeW(data)); + ChatRoom::Join(joinBlob, this); + } + } + else + room->ShowWindow(); + } + + return 0; +} + +INT_PTR __cdecl CSkypeProto::OnLeaveChat(WPARAM wParam, LPARAM) +{ + MCONTACT hContact = (MCONTACT)wParam; + if (hContact) { + ptrW cid(::db_get_wsa(hContact, this->m_szModuleName, "ChatRoomID")); + + ChatRoom *room = this->FindChatRoom(cid); + if (room != NULL) + room->LeaveChat(); + } + + return 0; +} + +/// + +void __cdecl CSkypeProto::LoadChatList(void*) +{ + this->debugLogW(L"Updating group chats list"); + CConversation::Refs conversations; + this->GetConversationList(conversations); + + SEString data; + for (uint i = 0; i < conversations.size(); i++) + { + auto conversation = conversations[i]; + + uint convoType = conversation->GetUintProp(Conversation::P_TYPE); + if (convoType == CConversation::CONFERENCE) + { + CConversation::MY_STATUS status; + conversation->GetPropMyStatus(status); + if (status == Conversation::APPLICANT || status == Conversation::CONSUMER ) + { + conversation->GetPropIdentity(data); + ptrW cid( ::mir_utf8decodeW(data)); + CSkypeProto::ReplaceSpecialChars(cid); + + conversation->GetPropDisplayname(data); + ptrW name( ::mir_utf8decodeW(data)); + + ChatRoom *room = new ChatRoom(cid, name, this); + chatRooms.insert(room); + room->Start(conversation); + } + } + } +} + +/// + +void CSkypeProto::OnChatEvent(const ConversationRef &conversation, const MessageRef &message) +{ + uint messageType; + messageType = message->GetUintProp(Message::P_TYPE); + + SEString data; + conversation->GetPropIdentity(data); + ptrW cid( ::mir_utf8decodeW(data)); + CSkypeProto::ReplaceSpecialChars(cid); + + ChatRoom *room = this->FindChatRoom(cid); + if (room != NULL) + { + room->OnEvent(conversation, message); + } + else + { + Conversation::MY_STATUS status; + conversation->GetPropMyStatus(status); + if (status != Conversation::RETIRED_FORCEFULLY || status != Conversation::RETIRED_FORCEFULLY) + { + SEString data; + + conversation->GetPropDisplayname(data); + ptrW name( ::mir_utf8decodeW(data)); + + ChatRoom *room = new ChatRoom(cid, name, this); + chatRooms.insert(room); + room->Start(conversation, true); + } + } +} + +void CSkypeProto::OnConversationListChange( + const ConversationRef& conversation, + const Conversation::LIST_TYPE& type, + const bool& added) +{ + uint convoType = conversation->GetUintProp(Conversation::P_TYPE); + if (convoType == Conversation::CONFERENCE && type == Conversation::INBOX_CONVERSATIONS && added) + { + SEString data; + + conversation->GetPropIdentity(data); + ptrW cid( ::mir_utf8decodeW(data)); + CSkypeProto::ReplaceSpecialChars(cid); + + if ( !this->FindChatRoom(cid)) + { + conversation->GetPropDisplayname(data); + ptrW name( ::mir_utf8decodeW(data)); + + ChatRoom *room = new ChatRoom(cid, name, this); + chatRooms.insert(room); + room->Start(conversation, true); + } + } +} + +void CSkypeProto::ChatRoomParseUriComands(const wchar_t *commands) +{ +} + +static void appendString(bool bIsTipper, const TCHAR *tszTitle, const TCHAR *tszValue, TCHAR* buf, size_t bufSize) +{ + if (*buf) { + const TCHAR *szSeparator = bIsTipper ? _T("\n") : _T("\r\n"); + _tcsncat(buf, szSeparator, bufSize); + } + + size_t len = _tcslen(buf); + buf += len; + bufSize -= len; + + if (bIsTipper) + mir_sntprintf(buf, bufSize, _T("%s%s%s%s"), _T(""), TranslateTS(tszTitle), _T("\t"), tszValue); + else { + TCHAR* p = TranslateTS(tszTitle); + mir_sntprintf(buf, bufSize, _T("%s%s\t%s"), p, _tcslen(p)<=7 ? _T("\t") : _T(""), tszValue); + } +} + +INT_PTR __cdecl CSkypeProto::SkypeGCGetToolTipText(WPARAM wParam, LPARAM lParam) +{ + if ( !wParam || !lParam) + return 0; //room global tooltip not supported yet + + ChatRoom *room = this->FindChatRoom((TCHAR *)wParam); + if (room == NULL) + return 0; //no room found + + ChatMember *member = room->FindChatMember((TCHAR *)lParam); + if (member == NULL) + return 0; //no contact found + + // ok process info output will be: + // Skype name: sid + // Nick: Nickname + // Status: StatusText + // Role: Moderator + + TCHAR outBuf[2048]; + outBuf[0]=_T('\0'); + + bool bIsTipper = db_get_b(NULL, "Tab_SRMsg", "adv_TipperTooltip", 0) && ServiceExists("mToolTip/HideTip"); + + //sid + appendString(bIsTipper, _T("Skype name:"), member->GetSid(), outBuf, SIZEOF(outBuf)); + //nick + appendString(bIsTipper, _T("Nick:"), member->GetNick(), outBuf, SIZEOF(outBuf)); + //status + appendString(bIsTipper, _T("Status:"), (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)member->GetStatus(),GSMDF_TCHAR), outBuf, SIZEOF(outBuf)); + //role + appendString(bIsTipper, _T("Role:"), ::TranslateW(ChatRoom::Roles[member->GetRank()]), outBuf, SIZEOF(outBuf)); + + return (INT_PTR)(outBuf[0] == 0 ? NULL : mir_tstrdup(outBuf)); +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype_chat.h b/plugins/!Deprecated/Skype/src/skype_chat.h new file mode 100644 index 0000000000..d63d7c9da2 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_chat.h @@ -0,0 +1,204 @@ +#pragma once + +#include "skype.h" +#include + +class ChatMember +{ +private: + wchar_t *sid; + wchar_t *nick; + int rank; + WORD status; + +public: + CParticipant::Ref participant; + + ChatMember() + { + this->sid = NULL; + this->nick = NULL; + } + + ChatMember(const wchar_t *sid) + { + this->sid = ::mir_wstrdup(sid); + this->nick = NULL; + } + + ChatMember(const ChatMember &other) + { + this->sid = NULL; + this->nick = NULL; + this->operator=(other); + } + + ~ChatMember() + { + if (this->sid != NULL) + ::mir_free(this->sid); + if (this->nick != NULL) + ::mir_free(this->nick); + } + + void SetNick(const wchar_t *nick) + { + if (this->nick != NULL) + ::mir_free(this->nick); + this->nick = ::mir_wstrdup(nick); + } + + wchar_t *GetSid() const + { + return this->sid; + } + + wchar_t *GetNick() const + { + if (this->nick == NULL) + return this->sid; + + return this->nick; + } + + void SetRank(int rank) + { + this->rank = rank; + } + + int GetRank() const + { + return this->rank; + } + + void SetStatus(int status) + { + this->status = status; + } + + int GetStatus() const + { + return this->status; + } + + void SetPaticipant(const ParticipantRef &participant) + { + this->participant = participant; + } + + static int Compare(const ChatMember *p1, const ChatMember *p2) + { + return ::lstrcmpi(p1->sid, p2->sid); + } + + bool operator==(const ChatMember &other) const + { + return ::lstrcmp(this->sid, other.sid) == 0; + } + + bool operator!=(const ChatMember &other) const + { + return !(*this == other); + } + + ChatMember& operator=(const ChatMember &other) + { + if (this == &other) + return *this; + + if (this->sid != NULL) + ::mir_free(this->sid); + this->sid = ::mir_wstrdup(other.sid); + + if (this->nick != NULL) + ::mir_free(this->nick); + this->nick = ::mir_wstrdup(other.nick); + + this->rank = other.rank; + this->status = other.status; + this->participant = other.participant; + return *this; + } +}; + +class ChatRoom +{ +private: + wchar_t *cid; + wchar_t *name; + + CConversation::Ref conversation; + + MCONTACT hContact; + + OBJLIST members; + + CSkypeProto *ppro; + + ChatRoom(const wchar_t *cid); + + inline static int CompareMembers(const ChatMember *p1, const ChatMember *p2) { return ChatMember::Compare(p1, p2); } + + void CreateChatSession(bool showWindow = false); + + bool IsMe(const ChatMember &item) const; + bool IsSys(const ChatMember &item) const; + void SendEvent(const ChatMember &item, int eventType, DWORD timestamp = time(NULL), DWORD flags = GCEF_ADDTOLOG, DWORD itemData = 0, const wchar_t *status = NULL, const wchar_t *message = NULL); + + void UpdateMember(const ChatMember &item, DWORD timestamp = time(NULL)); + void KickMember(const ChatMember &item, const ChatMember *author, DWORD timestamp = time(NULL)); + void RemoveMember(const ChatMember &item, DWORD timestamp = time(NULL)); + +public: + ChatMember *me; + ChatMember *sys; + + static wchar_t *Roles[]; + + ChatRoom(const wchar_t *cid, const wchar_t *name, CSkypeProto *ppro); + ~ChatRoom(); + + MCONTACT GetContactHandle() const; + + void SetTopic(const wchar_t *topic); + wchar_t *GetUri(); + void ShowWindow(); + + void Invite(const StringList &contacts); + void Start(const ConversationRef &conversation, bool showWindow = false); + //void Join(const wchar_t *joinBlob, bool showWindow = false); + + void SendMessage(const wchar_t *text); + + void LeaveChat(); + void LeaveChatAndDelete(); + + void SendEvent(const wchar_t *sid, int eventType, DWORD timestamp = time(NULL), DWORD flags = GCEF_ADDTOLOG, DWORD itemData = 0, const wchar_t *status = NULL, const wchar_t *message = NULL); + + bool IsMe(const wchar_t *sid) const; + bool IsSys(const wchar_t *sid) const; + + ChatMember *FindChatMember(const wchar_t *sid); + + void AddMember(const ChatMember &item, const ChatMember &author, DWORD timestamp = time(NULL)); + + void UpdateMemberNick(ChatMember *member, const wchar_t *nick, DWORD timestamp = time(NULL)); + void UpdateMemberRole(ChatMember *member, int role, const ChatMember &author = NULL, DWORD timestamp = time(NULL)); + void UpdateMemberStatus(ChatMember *member, int status, DWORD timestamp = time(NULL)); + + void UpdateMember(const wchar_t *sid, const wchar_t *nick, int role, int status, DWORD timestamp = time(NULL)); + + //void GiveMember(const wchar_t *sid); + void AddApplicant(const ChatMember *sid); + + void KickMember(const wchar_t *sid, const wchar_t *author, DWORD timestamp = time(NULL)); + void RemoveMember(const wchar_t *sid, DWORD timestamp = time(NULL)); + + void OnEvent(const ConversationRef &conversation, const MessageRef &message); + void OnChange(const ConversationRef &conversation, int prop); + + void OnParticipantChanged(const ParticipantRef &participant, int prop); + + static void Create(const ChatRoomParam *param, CSkypeProto *ppro); + static void Join(const wchar_t *joinBlob, CSkypeProto *ppro); +}; diff --git a/plugins/!Deprecated/Skype/src/skype_contacts.cpp b/plugins/!Deprecated/Skype/src/skype_contacts.cpp new file mode 100644 index 0000000000..0561db0e04 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_contacts.cpp @@ -0,0 +1,538 @@ +#include "skype.h" + +void CSkypeProto::UpdateContactAuthState(MCONTACT hContact, const ContactRef &contact) +{ + uint newTS = 0; + contact->GetPropAuthreqTimestamp(newTS); + DWORD oldTS = this->getDword("AuthTS", 0); + if (newTS > oldTS) + { + bool result; + if (contact->HasAuthorizedMe(result) && !result) + this->setByte(hContact, "Auth", !result); + else + { + this->delSetting(hContact, "Auth"); + if (contact->IsMemberOfHardwiredGroup(CContactGroup::ALL_BUDDIES, result) && !result) + this->setByte(hContact, "Grant", !result); + else + this->delSetting(hContact, "Grant"); + } + + this->setDword(hContact, "AuthTS", newTS); + } +} + +void CSkypeProto::UpdateContactStatus(MCONTACT hContact, const ContactRef &contact) +{ + Contact::AVAILABILITY availability; + contact->GetPropAvailability(availability); + this->setWord(hContact, SKYPE_SETTINGS_STATUS, CSkypeProto::SkypeToMirandaStatus(availability)); + + if (availability == Contact::SKYPEOUT) + this->setWord(hContact, SKYPE_SETTINGS_STATUS, ID_STATUS_ONTHEPHONE); + else + { + if (availability == Contact::PENDINGAUTH) + this->setByte(hContact, "Auth", 1); + else + this->delSetting(hContact, "Auth"); + } +} + +void CSkypeProto::UpdateContactClient(MCONTACT hContact, const ContactRef &contact) +{ + bool isMobile = false; + contact->HasCapability(Contact::CAPABILITY_MOBILE_DEVICE, isMobile/*, true*/); + + this->setTString(hContact, "MirVer", isMobile ? L"SkypeMobile" : L"Skype"); +} + +void CSkypeProto::UpdateContactOnlineSinceTime(MCONTACT hContact, const ContactRef &contact) +{ + uint newTS = 0; + contact->GetPropLastonlineTimestamp(newTS); + DWORD oldTS = ::db_get_dw(hContact, this->m_szModuleName, "OnlineSinceTS", 0); + if (newTS > oldTS) + this->setDword(hContact, "OnlineSinceTS", newTS); +} + +void CSkypeProto::UpdateContactLastEventDate(MCONTACT hContact, const ContactRef &contact) +{ + uint newTS = 0; + contact->GetPropLastusedTimestamp(newTS); + DWORD oldTS = this->getDword(hContact, "LastEventDateTS", 0); + if (newTS > oldTS) + this->setDword(hContact, "LastEventDateTS", newTS); +} + +void CSkypeProto::OnContactChanged(const ContactRef &contact, int prop) +{ + SEString data; + contact->GetPropSkypename(data); + wchar_t *sid = ::mir_utf8decodeW(data); + MCONTACT hContact = this->GetContactBySid(sid); + ::mir_free(sid); + + SEObject *contactObj = contact.fetch(); + + if (hContact) + { + switch(prop) + { + case Contact::P_AUTHREQ_TIMESTAMP: + { + uint newTS = 0; + contact->GetPropAuthreqTimestamp(newTS); + DWORD oldTS = this->getDword(hContact, "AuthTS", 0); + if (newTS > oldTS) + this->RaiseAuthRequestEvent(newTS, contact); + } + break; + + case Contact::P_AUTHREQUEST_COUNT: + // todo: all authrequests after first should be catch here + this->UpdateContactAuthState(hContact, contact); + break; + + case Contact::P_AVAILABILITY: + this->UpdateContactStatus(hContact, contact); + this->UpdateChatUserStatus(contact); + break; + + //case CContact::P_AVATAR_IMAGE: + case Contact::P_AVATAR_TIMESTAMP: + this->UpdateProfileAvatar(contactObj, hContact); + break; + + //case CContact::P_MOOD_TEXT: + case Contact::P_MOOD_TIMESTAMP: + this->UpdateProfileStatusMessage(contactObj, hContact); + break; + + case Contact::P_FULLNAME: + this->UpdateChatUserNick(contact); + break; + + case Contact::P_PROFILE_TIMESTAMP: + this->UpdateProfile(contactObj, hContact); + break; + } + } +} + +void CSkypeProto::OnContactListChanged(const ContactRef &contact) +{ + bool result; + + contact->IsMemberOfHardwiredGroup(CContactGroup::ALL_BUDDIES, result); + if (result) + { + if ( !this->contactList.contains(contact)) + { + CContact::Ref newContact(contact); + this->contactList.append(newContact); + newContact.fetch(); + } + } + + contact->IsMemberOfHardwiredGroup(CContactGroup::CONTACTS_WAITING_MY_AUTHORIZATION, result); + if (result) + { + SEString data; + + uint newTS = 0; + contact->GetPropAuthreqTimestamp(newTS); + + this->RaiseAuthRequestEvent(newTS, contact); + } +} + +bool CSkypeProto::IsProtoContact(MCONTACT hContact) +{ + return ::lstrcmpiA(::GetContactProto(hContact), this->m_szModuleName) == 0; +} + +MCONTACT CSkypeProto::GetContactBySid(const wchar_t *sid) +{ + MCONTACT hContact = NULL; + + ::EnterCriticalSection(&this->contact_search_lock); + + for (hContact = ::db_find_first(this->m_szModuleName); hContact; hContact = ::db_find_next(hContact, this->m_szModuleName)) + { + ptrW contactSid(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID)); + if (::lstrcmpi(contactSid, sid) == 0) + break; + } + + ::LeaveCriticalSection(&this->contact_search_lock); + + return hContact; +} + +MCONTACT CSkypeProto::GetContactFromAuthEvent(HANDLE hEvent) +{ + // db_event_getContact + DWORD body[3]; + DBEVENTINFO dbei = { sizeof(DBEVENTINFO) }; + dbei.cbBlob = sizeof(DWORD) * 2; + dbei.pBlob = (PBYTE)&body; + + if (::db_event_get(hEvent, &dbei)) + return INVALID_CONTACT_ID; + + if (dbei.eventType != EVENTTYPE_AUTHREQUEST) + return INVALID_CONTACT_ID; + + if (strcmp(dbei.szModule, this->m_szModuleName) != 0) + return INVALID_CONTACT_ID; + + return ::DbGetAuthEventContact(&dbei); +} + +MCONTACT CSkypeProto::AddContact(CContact::Ref contact, bool isTemporary) +{ + ptrW sid(::mir_utf8decodeW(contact->GetSid())); + + CContact::AVAILABILITY availability; + contact->GetPropAvailability(availability); + + MCONTACT hContact = this->GetContactBySid(sid); + if ( !hContact) + { + hContact = (MCONTACT)::CallService(MS_DB_CONTACT_ADD, 0, 0); + ::CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)this->m_szModuleName); + + ptrW nick(::mir_utf8decodeW(contact->GetNick())); + + switch(availability) { + case CContact::SKYPEOUT: + this->setByte(hContact, "IsSkypeOut", 1); + break; + + case CContact::PENDINGAUTH: + ::db_set_b(hContact, "CList", "NotOnList", 1); + break; + + case CContact::BLOCKED: + case CContact::BLOCKED_SKYPEOUT: + ::db_set_b(hContact, "CList", "Hidden", 1); + break; + + default: + this->delSetting(hContact, "IsSkypeOut"); + ::db_unset(hContact, "CList", "Hidden"); + ::db_unset(hContact, "CList", "NotOnList"); + } + + this->setTString(hContact, SKYPE_SETTINGS_SID, sid); + this->setTString(hContact, "Nick", nick); + + DBVARIANT dbv; + if ( !this->getTString(SKYPE_SETTINGS_DEF_GROUP, &dbv)) + { + ::db_set_ts(hContact, "CList", "Group", dbv.ptszVal); + ::db_free(&dbv); + } + } + + return hContact; +} + +void __cdecl CSkypeProto::LoadContactList(void* data) +{ + this->debugLogW(L"Updating contacts list"); + + bool isFirstLoad = data != NULL; + + this->GetHardwiredContactGroup(CContactGroup::ALL_BUDDIES, this->commonList); + this->commonList.fetch(); + + this->commonList->GetContacts(this->contactList); + fetch(this->contactList); + for (uint i = 0; i < this->contactList.size(); i++) + { + CContact::Ref contact = this->contactList[i]; + + MCONTACT hContact = this->AddContact(contact); + + if ( !isFirstLoad) + { + // todo: move to AddContact? + this->UpdateContactAuthState(hContact, contact); + this->UpdateContactStatus(hContact, contact); + + ptrW nick( ::db_get_wsa(hContact, "CList", "MyHandle")); + if ( !nick || !::wcslen(nick)) + { + nick = ::mir_utf8decodeW(contact->GetNick()); + ::db_set_ws(hContact, "CList", "MyHandle", nick); + } + + this->UpdateProfile(contact.fetch(), hContact); + } + } +} + +void __cdecl CSkypeProto::LoadAuthWaitList(void*) +{ + CContact::Refs authContacts; + this->GetHardwiredContactGroup(CContactGroup::CONTACTS_WAITING_MY_AUTHORIZATION, this->authWaitList); + this->authWaitList.fetch(); + + this->authWaitList->GetContacts(authContacts); + for (uint i = 0; i < authContacts.size(); i++) + { + CContact::Ref contact = authContacts[i]; + + uint newTS = 0; + contact->GetPropAuthreqTimestamp(newTS); + + this->RaiseAuthRequestEvent(newTS, contact); + } +} + +bool CSkypeProto::IsContactOnline(MCONTACT hContact) +{ + return this->getWord(hContact, SKYPE_SETTINGS_STATUS, ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE; +} + +void CSkypeProto::SetAllContactStatus(int status) +{ + ::EnterCriticalSection(&this->contact_search_lock); + + for (MCONTACT hContact = ::db_find_first(this->m_szModuleName); hContact; hContact = ::db_find_next(hContact, this->m_szModuleName)) + { + if (this->getByte(hContact, "IsSkypeOut", 0) != 0) + continue; + if (this->isChatRoom(hContact)) + continue; + if (this->IsContactOnline(hContact)) + ::db_set_w(hContact, this->m_szModuleName, SKYPE_SETTINGS_STATUS, status); + } + + ::LeaveCriticalSection(&this->contact_search_lock); +} + +void CSkypeProto::OnSearchCompleted(HANDLE hSearch) +{ + this->SendBroadcast(ACKTYPE_SEARCH, ACKRESULT_SUCCESS, hSearch, 0); +} + +void CSkypeProto::OnContactFinded(CContact::Ref contact, HANDLE hSearch) +{ + PROTOSEARCHRESULT psr = {0}; + psr.cbSize = sizeof(psr); + psr.flags = PSR_TCHAR; + + SEString data; + contact->GetPropSkypename(data); + psr.id = ::mir_utf8decodeW(data); + contact->GetPropDisplayname(data); + psr.nick = ::mir_utf8decodeW(data); + + SEString firstName, lastName; + contact->GetFullname(firstName, lastName); + psr.firstName = ::mir_utf8decodeW(firstName); + psr.lastName = ::mir_utf8decodeW(lastName); + + { + contact->GetPropEmails(data); + mir_ptr emails( ::mir_utf8decodeW(data)); + + wchar_t* main = ::wcstok(emails, L" "); + if (main != NULL) + { + psr.email = main; + } + } + + this->SendBroadcast(ACKTYPE_SEARCH, ACKRESULT_DATA, hSearch, (LPARAM)&psr); +} + +void __cdecl CSkypeProto::SearchBySidAsync(void* arg) +{ + mir_ptr sid((wchar_t*)arg); + + MCONTACT hContact = this->GetContactBySid(sid); + if (hContact) + { + this->ShowNotification(TranslateT("Contact already in your contact list"), 0, hContact); + this->SendBroadcast(ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)SKYPE_SEARCH_BYSID, 0); + return; + } + + CContactSearch::Ref search; + this->CreateIdentitySearch(::mir_u2a(sid), search); + search.fetch(); + search->SetProtoInfo((HANDLE)SKYPE_SEARCH_BYSID); + + bool valid; + if (!search->IsValid(valid) || !valid || !search->Submit()) + return; + + search->BlockWhileSearch(); + search->Release(); +} + +void __cdecl CSkypeProto::SearchByEmailAsync(void* arg) +{ + mir_ptr email((wchar_t *)arg); + + CContactSearch::Ref search; + this->CreateContactSearch(search); + search.fetch(); + search->SetProtoInfo((HANDLE)SKYPE_SEARCH_BYEMAIL); + + bool valid; + if (!search->AddEmailTerm(::mir_u2a(email), valid) || !valid || !search->Submit()) + return; + + search->BlockWhileSearch(); + search->Release(); +} + +void __cdecl CSkypeProto::SearchByNamesAsync(void* arg) +{ + //todo: write me + PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT *)arg; + + std::string nick = ::mir_utf8encodeW(psr->nick); + std::string fName = ::mir_utf8encodeW(psr->firstName); + std::string lName = " "; lName += ::mir_utf8encodeW(psr->lastName); + + CContactSearch::Ref search; + this->CreateContactSearch(search); + search.fetch(); + search->SetProtoInfo((HANDLE)SKYPE_SEARCH_BYNAMES); + + bool valid; + if (nick.length() != 0) + { + search->AddStrTerm( + Contact::P_FULLNAME, + CContactSearch::CONTAINS_WORD_PREFIXES, + nick.c_str(), + valid, + true); + } + if (fName.length() != 0) + { + search->AddOr(); + search->AddStrTerm( + Contact::P_FULLNAME, + CContactSearch::CONTAINS_WORD_PREFIXES, + fName.c_str(), + valid, + true); + } + if (lName.length() != 0) + { + search->AddOr(); + search->AddStrTerm( + Contact::P_FULLNAME, + CContactSearch::CONTAINS_WORD_PREFIXES, + lName.c_str(), + valid, + true); + } + + if (!search->Submit()) + return; + + search->BlockWhileSearch(); + search->Release(); +} + +void CSkypeProto::OnContactsReceived(const ConversationRef &conversation, const MessageRef &message) +{ + CContact::Refs contacts; + message->GetContacts(contacts); + + uint timestamp; + message->GetPropTimestamp(timestamp); + + CMessage::TYPE messageType; + message->GetPropType(messageType); + + SEString data; + message->GetPropAuthor(data); + + CContact::Ref author; + this->GetContact(data, author); + + MCONTACT hContact = this->AddContact(author); + + SEBinary guid; + message->GetPropGuid(guid); + ReadMessageParam param = { guid, messageType }; + + PROTORECVEVENT pre = { 0 }; + pre.flags = PREF_UTF; + pre.lParam = (LPARAM)¶m; + pre.timestamp = timestamp; + + int msgSize = 1; + pre.szMessage = (char *)::mir_alloc(msgSize); + pre.szMessage[0] = 0; + + int len = 0; + char* pCur = &pre.szMessage[0]; + + for (size_t i = 0; i < contacts.size(); i ++) + { + contacts[i]->GetIdentity(data); + if ( ::lstrcmpi(mir_ptr(::mir_utf8decodeW(data)), this->login) != 0) + this->AddContact(contacts[i]); + } + + char *text = ::mir_utf8encode(::Translate("Contacts received")); + + this->AddDBEvent( + hContact, + SKYPE_DB_EVENT_TYPE_CONTACTS, + timestamp, + PREF_UTF, + (DWORD)::strlen(text) + 1, + (PBYTE)text); +} + +void CSkypeProto::OnContactsSent(const ConversationRef &conversation, const MessageRef &message) +{ + SEString data; + + CMessage::TYPE messageType; + message->GetPropType(messageType); + + uint timestamp; + message->GetPropTimestamp(timestamp); + + CMessage::SENDING_STATUS status; + message->GetPropSendingStatus(status); + + CParticipant::Refs participants; + conversation->GetParticipants(participants, CConversation::OTHER_CONSUMERS); + participants[0]->GetPropIdentity(data); + + CContact::Ref receiver; + this->GetContact(data, receiver); + + MCONTACT hContact = this->AddContact(receiver); + this->SendBroadcast( + hContact, + ACKTYPE_CONTACTS, + status == CMessage::FAILED_TO_SEND ? ACKRESULT_FAILED : ACKRESULT_SUCCESS, + (HANDLE)message->getOID(), 0); +} + +void CSkypeProto::OnContactsEvent(const ConversationRef &conversation, const MessageRef &message) +{ + SEString author; + message->GetPropAuthor(author); + + if (::wcsicmp(mir_ptr(::mir_utf8decodeW(author)), this->login) == 0) + this->OnContactsSent(conversation, message); + else + this->OnContactsReceived(conversation, message); +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype_database.cpp b/plugins/!Deprecated/Skype/src/skype_database.cpp new file mode 100644 index 0000000000..6ad9166e11 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_database.cpp @@ -0,0 +1,112 @@ +#include "skype.h" + +bool CSkypeProto::IsMessageInDB(MCONTACT hContact, DWORD timestamp, SEBinary &guid, int flag) +{ + for (HANDLE hDbEvent = ::db_event_last(hContact); hDbEvent; hDbEvent = ::db_event_prev(hContact, hDbEvent)) + { + DBEVENTINFO dbei = { sizeof(dbei) }; + dbei.cbBlob = ::db_event_getBlobSize(hDbEvent); + if (dbei.cbBlob < guid.size()) + continue; + + mir_ptr blob((PBYTE)::mir_alloc(dbei.cbBlob)); + dbei.pBlob = blob; + ::db_event_get(hDbEvent, &dbei); + + if (dbei.timestamp < timestamp) + break; + + int sendFlag = dbei.flags & DBEF_SENT; + if ((dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == SKYPE_DB_EVENT_TYPE_EMOTE) && sendFlag == flag) + if (::memcmp(&dbei.pBlob[dbei.cbBlob - guid.size()], guid.data(), guid.size()) == 0) + return true; + } + + return false; +} + +HANDLE CSkypeProto::AddDBEvent(MCONTACT hContact, WORD type, DWORD timestamp, DWORD flags, DWORD cbBlob, PBYTE pBlob) +{ + DBEVENTINFO dbei = { sizeof(dbei) }; + dbei.szModule = this->m_szModuleName; + dbei.timestamp = timestamp; + dbei.eventType = type; + dbei.cbBlob = cbBlob; + dbei.pBlob = pBlob; + dbei.flags = flags; + return ::db_event_add(hContact, &dbei); +} + +void CSkypeProto::RaiseAuthRequestEvent(DWORD timestamp, CContact::Ref contact) +{ + char *sid = ::mir_strdup(contact->GetSid()); + char *nick = ::mir_strdup(contact->GetNick()); + + SEString data; + + contact->GetPropReceivedAuthrequest(data); + char *reason = ::mir_strdup(data); + + SEString last; + contact->GetFullname(data, last); + char *firstName = ::mir_strdup(data); + char *lastName = ::mir_strdup(last); + + MCONTACT hContact = this->AddContact(contact); + + /*blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), firstName(ASCIIZ), lastName(ASCIIZ), sid(ASCIIZ), reason(ASCIIZ)*/ + DWORD cbBlob = (DWORD) + (sizeof(DWORD) * 2 + + ::strlen(nick) + + ::strlen(firstName) + + ::strlen(lastName) + + ::strlen(sid) + + ::strlen(reason) + + 5); + + PBYTE pBlob, pCurBlob; + pCurBlob = pBlob = (PBYTE)::mir_alloc(cbBlob); + + *((PDWORD)pCurBlob) = 0; + pCurBlob += sizeof(DWORD); + *((PDWORD)pCurBlob) = (DWORD)hContact; + pCurBlob += sizeof(DWORD); + ::strcpy((char *)pCurBlob, nick); + pCurBlob += ::strlen(nick) + 1; + ::strcpy((char *)pCurBlob, firstName); + pCurBlob += ::strlen(firstName) + 1; + ::strcpy((char *)pCurBlob, lastName); + pCurBlob += ::strlen(lastName) + 1; + ::strcpy((char *)pCurBlob, sid); + pCurBlob += ::strlen(sid) + 1; + ::strcpy((char *)pCurBlob, reason); + + this->AddDBEvent(hContact, EVENTTYPE_AUTHREQUEST, time(NULL), DBEF_UTF, cbBlob, pBlob); +} + +void CSkypeProto::RaiseMessageSentEvent(MCONTACT hContact, DWORD timestamp, SEBinary &guid, const char *message, bool isUnread) +{ + if (this->IsMessageInDB(hContact, timestamp, guid, DBEF_SENT)) + return; + + int guidLen = (int)guid.size(); + + int msgLen = (int)::strlen(message) + 1; + ptrA msg((char *)::mir_alloc(msgLen + guidLen)); + + ::strcpy(msg, message); + msg[msgLen - 1] = 0; + ::memcpy((char *)&msg[msgLen], guid.data(), guidLen); + + DWORD flags = DBEF_UTF | DBEF_SENT; + if ( !isUnread) + flags |= DBEF_READ; + + this->AddDBEvent( + hContact, + EVENTTYPE_MESSAGE, + timestamp, + flags, + msgLen + guidLen, + (PBYTE)(char*)msg); +} diff --git a/plugins/!Deprecated/Skype/src/skype_dialogs.cpp b/plugins/!Deprecated/Skype/src/skype_dialogs.cpp new file mode 100644 index 0000000000..a3aa8df4dc --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_dialogs.cpp @@ -0,0 +1,859 @@ +#include "skype.h" + +INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + CSkypeProto *proto = (CSkypeProto *)::GetWindowLongPtr(hwnd, GWLP_USERDATA); + + switch (message) + { + case WM_INITDIALOG: + { + ::TranslateDialogDefault(hwnd); + + proto = (CSkypeProto *)lParam; + ::SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam); + { + ptrW sid( ::db_get_wsa(NULL, proto->m_szModuleName, SKYPE_SETTINGS_SID)); + SetDlgItemText(hwnd, IDC_SL, sid); + } + { + ptrA pwd( ::db_get_sa(NULL, proto->m_szModuleName, SKYPE_SETTINGS_PASSWORD)); + SetDlgItemTextA(hwnd, IDC_PW, pwd); + } + { + int port = rand() % 10000 + 10000; + SetDlgItemInt(hwnd, IDC_PORT, ::db_get_w(NULL, proto->m_szModuleName, "Port", port), FALSE); + SendMessage(GetDlgItem(hwnd, IDC_PORT), EM_SETLIMITTEXT, 5, 0); + } + + CheckDlgButton(hwnd, IDC_USE_ALT_PORTS, ::db_get_b(NULL, proto->m_szModuleName, "UseAlternativePorts", 1)); + + if (proto->IsOnline()) + { + SendMessage(GetDlgItem(hwnd, IDC_SL), EM_SETREADONLY, 1, 0); + SendMessage(GetDlgItem(hwnd, IDC_PW), EM_SETREADONLY, 1, 0); + SendMessage(GetDlgItem(hwnd, IDC_PORT), EM_SETREADONLY, 1, 0); + EnableWindow(GetDlgItem(hwnd, IDC_USE_ALT_PORTS), FALSE); + EnableWindow(GetDlgItem(hwnd, IDC_REGISTER), FALSE); + EnableWindow(GetDlgItem(hwnd, IDC_CHANGE_PWD), TRUE); + EnableWindow(GetDlgItem(hwnd, IDC_GROUP), FALSE); + } + else if (::db_get_w(NULL, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) > ID_STATUS_OFFLINE) + { + EnableWindow(GetDlgItem(hwnd, IDC_REGISTER), FALSE); + } + + SendDlgItemMessage(hwnd, IDC_GROUP, EM_LIMITTEXT, SKYPE_GROUP_NAME_LIMIT, 0); + + ptrW defgroup( db_get_wsa(NULL, proto->m_szModuleName, SKYPE_SETTINGS_DEF_GROUP)); + SetDlgItemText(hwnd, IDC_GROUP, defgroup); + } + return TRUE; + + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case IDC_SL: + { + if ((HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0; + + if (!proto->IsOnline() && ::db_get_w(NULL, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) <= ID_STATUS_OFFLINE) + { + wchar_t sid[128]; + GetDlgItemText(hwnd, IDC_SL, sid, SIZEOF(sid)); + EnableWindow(GetDlgItem(hwnd, IDC_REGISTER), ::wcslen(sid) != 0); + } + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + } + break; + + case IDC_PW: + { + if ((HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0; + if (proto->IsOnline()) + { + char pwd[128]; + GetDlgItemTextA(hwnd, IDC_SL, pwd, SIZEOF(pwd)); + EnableWindow(GetDlgItem(hwnd, IDC_CHANGE_PWD), ::strlen(pwd) != 0); + } + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + } + break; + + case IDC_GROUP: + { + if ((HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) + return 0; + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + } + break; + + case IDC_PORT: + { + if ((HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) + return 0; + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + } + break; + + case IDC_USE_ALT_PORTS: + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + break; + + case IDC_REGISTER: + { + char sid[128], pwd[128]; + GetDlgItemTextA(hwnd, IDC_SL, sid, SIZEOF(sid)); + GetDlgItemTextA(hwnd, IDC_PW, pwd, SIZEOF(pwd)); + + Skype::VALIDATERESULT reason; + proto->ValidatePassword(sid, pwd, reason); + + if (reason == Skype::VALIDATED_OK) + { + CAccount::Ref account; + proto->GetAccount(sid, proto->account); + proto->account->SetStrProperty(CAccount::P_FULLNAME, sid); + proto->account->Register(pwd, false, false); + } + else + { + proto->ShowNotification(CSkypeProto::ValidationReasons[reason]); + } + } + return FALSE; + + case IDC_CHANGE_PWD: + { + char sid[128], pwd[128]; + GetDlgItemTextA(hwnd, IDC_SL, sid, SIZEOF(sid)); + GetDlgItemTextA(hwnd, IDC_PW, pwd, SIZEOF(pwd)); + + PasswordChangeBoxParam param; + param.password = ::mir_strdup(pwd); + + if (proto->ChangePassword(param)) + { + proto->account->ChangePassword(param.password, param.password2); + } + } + break; + } + } + break; + + case WM_NOTIFY: + if (reinterpret_cast(lParam)->code == PSN_APPLY && !proto->IsOnline()) + { + wchar_t sid[128]; + GetDlgItemText(hwnd, IDC_SL, sid, SIZEOF(sid)); + ::db_set_ws(NULL, proto->m_szModuleName, SKYPE_SETTINGS_SID, sid); + ::mir_free(proto->login); + proto->login = ::mir_wstrdup(sid); + + char pwd[128]; + GetDlgItemTextA(hwnd, IDC_PW, pwd, SIZEOF(pwd)); + ::db_set_s(NULL, proto->m_szModuleName, SKYPE_SETTINGS_PASSWORD, pwd); + + HWND item = GetDlgItem(hwnd, IDC_PORT); + if (item) + { + BOOL error; + int port = GetDlgItemInt(hwnd, IDC_PORT, &error, FALSE); + ::db_set_w(NULL, proto->m_szModuleName, "Port", port); + ::db_set_b(NULL, proto->m_szModuleName, "UseAlternativePorts", (BYTE)IsDlgButtonChecked(hwnd, IDC_USE_ALT_PORTS)); + } + + wchar_t tstr[128]; + GetDlgItemText(hwnd, IDC_GROUP, tstr, SIZEOF(tstr)); + if (lstrlen(tstr) > 0) + { + ::db_set_ts(NULL, proto->m_szModuleName, SKYPE_SETTINGS_DEF_GROUP, tstr); + ::Clist_CreateGroup(0, tstr); + } + else + ::db_unset(NULL, proto->m_szModuleName, SKYPE_SETTINGS_DEF_GROUP); + + return TRUE; + } + break; + } + + return FALSE; +} + +INT_PTR CALLBACK CSkypeProto::SkypePrivacyOptionsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + CSkypeProto *ppro = (CSkypeProto *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (msg) + { + case WM_INITDIALOG: + if (lParam) + { + ppro = (CSkypeProto *)lParam; + ::SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + + ::TranslateDialogDefault(hwndDlg); + } + break; + + /*case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + } + } + break;*/ + + case WM_NOTIFY: + if (reinterpret_cast(lParam)->code == PSN_APPLY && !ppro->IsOnline()) + { + return TRUE; + } + break; + + /*switch(LOWORD(wParam)) + { + } + break;*/ + } + return FALSE; +} + +INT_PTR CALLBACK CSkypeProto::SkypePasswordRequestProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + PasswordRequestBoxParam *param = reinterpret_cast(::GetWindowLongPtr(hwndDlg, GWLP_USERDATA)); + + switch (msg) + { + case WM_INITDIALOG: + ::TranslateDialogDefault(hwndDlg); + + param = (PasswordRequestBoxParam *)lParam; + ::SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + { + ::SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)CSkypeProto::IconList[0].Handle); + ::SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)CSkypeProto::IconList[0].Handle); + + wchar_t title[MAX_PATH]; + ::mir_sntprintf( + title, + MAX_PATH, + ::TranslateT("Enter a password for %s:"), + param->login); + ::SetDlgItemText(hwndDlg, IDC_INSTRUCTION, title); + + ::SendDlgItemMessage(hwndDlg, IDC_PASSWORD, EM_LIMITTEXT, 128 - 1, 0); + + ::CheckDlgButton(hwndDlg, IDC_SAVEPASSWORD, param->rememberPassword); + ::ShowWindow(::GetDlgItem(hwndDlg, IDC_SAVEPASSWORD), param->showRememberPasswordBox); + } + break; + + case WM_CLOSE: + EndDialog(hwndDlg, 0); + break; + + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDOK: + { + param->rememberPassword = ::IsDlgButtonChecked(hwndDlg, IDC_SAVEPASSWORD) > 0; + + char password[SKYPE_PASSWORD_LIMIT]; + ::GetDlgItemTextA(hwndDlg, IDC_PASSWORD, password, SIZEOF(password)); + param->password = ::mir_strdup(password); + + ::EndDialog(hwndDlg, IDOK); + } + break; + + case IDCANCEL: + ::EndDialog(hwndDlg, IDCANCEL); + break; + } + } + break; + } + + return FALSE; +} + +bool CSkypeProto::RequestPassword(PasswordRequestBoxParam ¶m) +{ + int value = ::DialogBoxParam( + g_hInstance, + MAKEINTRESOURCE(IDD_PASSWORD_REQUEST), + NULL, + CSkypeProto::SkypePasswordRequestProc, + (LPARAM)¶m); + return value == 1; +} + +INT_PTR CALLBACK CSkypeProto::SkypePasswordChangeProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + PasswordChangeBoxParam *param = reinterpret_cast(::GetWindowLongPtr(hwndDlg, GWLP_USERDATA)); + + switch (msg) + { + case WM_INITDIALOG: + ::TranslateDialogDefault(hwndDlg); + + SendDlgItemMessage(hwndDlg, IDC_PASSWORD, EM_LIMITTEXT, SKYPE_PASSWORD_LIMIT, 0); + SendDlgItemMessage(hwndDlg, IDC_PASSWORD2, EM_LIMITTEXT, SKYPE_PASSWORD_LIMIT, 0); + SendDlgItemMessage(hwndDlg, IDC_PASSWORD3, EM_LIMITTEXT, SKYPE_PASSWORD_LIMIT, 0); + + param = (PasswordChangeBoxParam *)lParam; + ::SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + { + ::SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)CSkypeProto::IconList[0].Handle); + ::SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)CSkypeProto::IconList[0].Handle); + } + break; + + case WM_CLOSE: + ::EndDialog(hwndDlg, 0); + break; + + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDOK: + { + char oldPwd[SKYPE_PASSWORD_LIMIT]; + char pwd1[SKYPE_PASSWORD_LIMIT]; + char pwd2[SKYPE_PASSWORD_LIMIT]; + + ::GetDlgItemTextA(hwndDlg, IDC_PASSWORD, oldPwd, SIZEOF(oldPwd)); + ::GetDlgItemTextA(hwndDlg, IDC_PASSWORD2, pwd1, SIZEOF(pwd1)); + ::GetDlgItemTextA(hwndDlg, IDC_PASSWORD3, pwd2, SIZEOF(pwd2)); + + if (!::strlen(oldPwd) || !::strlen(pwd1)) { + ::MessageBox(NULL, TranslateT("Password can't be empty."), TranslateT("Change password"), MB_OK | MB_ICONERROR); + break; + } + + if (::strcmp(param->password, oldPwd)) { + ::MessageBox(NULL, TranslateT("Old password is not correct."), TranslateT("Change password"), MB_OK | MB_ICONERROR); + break; + } + + if (!::strcmp(oldPwd, pwd1)) { + ::MessageBox(NULL, TranslateT("New password is same as old password."), TranslateT("Change password"), MB_OK | MB_ICONERROR); + break; + } + + if (::strcmp(pwd1, pwd2)) { + ::MessageBox(NULL, TranslateT("New password and confirmation must be same."), TranslateT("Change password"), MB_OK | MB_ICONERROR); + break; + } + + param->password2 = ::mir_strdup(pwd1); + + ::EndDialog(hwndDlg, IDOK); + } + break; + + case IDCANCEL: + ::EndDialog(hwndDlg, IDCANCEL); + break; + } + } + break; + } + + return FALSE; +} + +bool CSkypeProto::ChangePassword(PasswordChangeBoxParam ¶m) +{ + int value = ::DialogBoxParam( + g_hInstance, + MAKEINTRESOURCE(IDD_PASSWORD_CHANGE), + NULL, + CSkypeProto::SkypePasswordChangeProc, + (LPARAM)¶m); + return value == IDOK; +} + +INT_PTR CALLBACK CSkypeProto::SkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + break; + + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_PARAMCHANGED: + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, ((PSHNOTIFY *)lParam )->lParam); + break; + + case PSN_INFOCHANGED: + { + CSkypeProto *ppro = (CSkypeProto *)::GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + if (!ppro) + break; + + char *szProto; + MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; + + if (hContact == NULL) + szProto = ppro->m_szModuleName; + else + szProto = (char *)::CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact, 0); + + if (!szProto) + break; + + ::SetDlgItemText(hwndDlg, IDC_SID, ptrW(::db_get_wsa(hContact, ppro->m_szModuleName, SKYPE_SETTINGS_SID))); + + DBVARIANT dbv; + if ( !::db_get_ts(hContact, ppro->m_szModuleName, "XStatusMsg", &dbv)) { + ::SetDlgItemText(hwndDlg, IDC_STATUSTEXT, dbv.ptszVal); + ::EnableWindow(::GetDlgItem(hwndDlg, IDC_STATUSTEXT), TRUE); + ::db_free(&dbv); + } else { + ::SetDlgItemText(hwndDlg, IDC_STATUSTEXT, TranslateT("")); + ::EnableWindow(::GetDlgItem(hwndDlg, IDC_STATUSTEXT), FALSE); + } + + if (::db_get_dw(hContact, ppro->m_szModuleName, "OnlineSinceTS", 0)) { + TCHAR date[64]; + DBTIMETOSTRINGT tts = {0}; + tts.szFormat = _T("d s"); + tts.szDest = date; + tts.cbDest = sizeof(date); + CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, (WPARAM)::db_get_dw(hContact, ppro->m_szModuleName, "OnlineSinceTS", 0), (LPARAM)&tts); + ::SetDlgItemText(hwndDlg, IDC_ONLINESINCE, date); + ::EnableWindow(::GetDlgItem(hwndDlg, IDC_ONLINESINCE), TRUE); + } else { + ::SetDlgItemText(hwndDlg, IDC_ONLINESINCE, TranslateT("")); + ::EnableWindow(::GetDlgItem(hwndDlg, IDC_ONLINESINCE), FALSE); + } + + if (::db_get_dw(hContact, ppro->m_szModuleName, "LastEventDateTS", 0)) { + TCHAR date[64]; + DBTIMETOSTRINGT tts = {0}; + tts.szFormat = _T("d s"); + tts.szDest = date; + tts.cbDest = sizeof(date); + ::CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, (WPARAM)::db_get_dw(hContact, ppro->m_szModuleName, "LastEventDateTS", 0), (LPARAM)&tts); + ::SetDlgItemText(hwndDlg, IDC_LASTEVENTDATE, date); + ::EnableWindow(::GetDlgItem(hwndDlg, IDC_LASTEVENTDATE), TRUE); + } else { + ::SetDlgItemText(hwndDlg, IDC_LASTEVENTDATE, TranslateT("")); + ::EnableWindow(::GetDlgItem(hwndDlg, IDC_LASTEVENTDATE), FALSE); + } + + if (::db_get_dw(hContact, ppro->m_szModuleName, "ProfileTS", 0)) { + TCHAR date[64]; + DBTIMETOSTRINGT tts = {0}; + tts.szFormat = _T("d s"); + tts.szDest = date; + tts.cbDest = sizeof(date); + ::CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, (WPARAM)::db_get_dw(hContact, ppro->m_szModuleName, "ProfileTS", 0), (LPARAM)&tts); + ::SetDlgItemText(hwndDlg, IDC_LASTPROFILECHANGE, date); + ::EnableWindow(::GetDlgItem(hwndDlg, IDC_LASTPROFILECHANGE), TRUE); + } else { + ::SetDlgItemText(hwndDlg, IDC_LASTPROFILECHANGE, TranslateT("")); + ::EnableWindow(::GetDlgItem(hwndDlg, IDC_LASTPROFILECHANGE), FALSE); + } + } + break; + } + break; + } + break; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDCANCEL: + SendMessage(GetParent(hwndDlg), msg, wParam, lParam); + break; + } + break; + } + + return FALSE; +} + +INT_PTR CALLBACK CSkypeProto::PersonalSkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + const unsigned long iPageId = 0; + CSkypeProto *ppro = (CSkypeProto *)::GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (msg) + { + case WM_INITDIALOG: + if (lParam) + { + ppro = (CSkypeProto *)lParam; + ::TranslateDialogDefault(hwndDlg); + + ::SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + + // gender + ::SendMessage(::GetDlgItem(hwndDlg, IDC_GENDER), CB_ADDSTRING, 0, (LPARAM)L""); + ::SendMessage(::GetDlgItem(hwndDlg, IDC_GENDER), CB_ADDSTRING, 0, (LPARAM)::TranslateT("Male")); + ::SendMessage(::GetDlgItem(hwndDlg, IDC_GENDER), CB_ADDSTRING, 0, (LPARAM)::TranslateT("Female")); + + BYTE b = ::db_get_b(NULL, ppro->m_szModuleName, "Gender", 0); + switch (b) + { + case 0: + ::SetDlgItemText(hwndDlg, IDC_GENDER, _T("")); + break; + case 'M': + ::SetDlgItemText(hwndDlg, IDC_GENDER, TranslateT("Male")); + break; + case 'F': + SetDlgItemText(hwndDlg, IDC_GENDER, TranslateT("Female")); + break; + } + + // birthday + wchar_t date[5]; + + for (int i = 1; i < 32; i++) + { + ::mir_sntprintf(date, 3, L"%02d", i); + ::SendMessage(GetDlgItem(hwndDlg, IDC_BIRTH_DAY), CB_ADDSTRING, 0, (LPARAM)date); + } + BYTE bday = ::db_get_b(NULL, ppro->m_szModuleName, "BirthDay", 0); + if (bday > 0 && bday < 32) + { + ::mir_sntprintf(date, 3, L"%02d", bday); + ::SetDlgItemText(hwndDlg, IDC_BIRTH_DAY, date); + } + + for (int i = 1; i < 13; i++) + { + ::mir_sntprintf(date, 3, L"%02d", i); + ::SendMessage(::GetDlgItem(hwndDlg, IDC_BIRTH_MONTH), CB_ADDSTRING, 0, (LPARAM)date); + } + BYTE bmon = ::db_get_b(NULL, ppro->m_szModuleName, "BirthMonth", 0); + if (bmon > 0 && bmon < 13) + { + ::mir_sntprintf(date, 3, L"%02d", bmon); + ::SetDlgItemText(hwndDlg, IDC_BIRTH_MONTH, date); + } + SYSTEMTIME sToday = {0}; + ::GetLocalTime(&sToday); + // ages from 10 to 50 is need more? + for (WORD i = sToday.wYear - 50; i < sToday.wYear - 10; i++) + { + ::_itow(i, date, 10); + ::SendMessage(::GetDlgItem(hwndDlg, IDC_BIRTH_YEAR), CB_ADDSTRING, 0, (LPARAM)date); + } + WORD byear = ::db_get_w(NULL, ppro->m_szModuleName, "BirthYear", 0); + if (byear > 1900 && bmon < 2214) + ::SetDlgItemInt(hwndDlg, IDC_BIRTH_YEAR, byear, false); + + // language + int i = 0; + ptrW lang( ::db_get_wsa(NULL, ppro->m_szModuleName, "Language1")); + for (auto it = CSkypeProto::languages.begin(); it != CSkypeProto::languages.end(); ++it) + { + ::SendMessage( + ::GetDlgItem(hwndDlg, IDC_LANGUAGE), + CB_ADDSTRING, + 0, + (LPARAM)::TranslateTS(it->second.c_str())); + + ::SendMessage( + ::GetDlgItem(hwndDlg, IDC_LANGUAGE), + CB_SETITEMDATA, + i, + (LPARAM)&it->first); + + if (lang && it->second.compare(lang) == 0) + ::SendMessage(GetDlgItem(hwndDlg, IDC_LANGUAGE), CB_SETCURSEL, i, 0); + i++; + } + + // nick + DBVARIANT dbv; + if ( !ppro->getTString("Nick", &dbv)) + { + ::SetDlgItemText(hwndDlg, IDC_FULLNAME, dbv.ptszVal); + ::db_free(&dbv); + } + else + ::SetDlgItemText(hwndDlg, IDC_FULLNAME, _T("")); + + // homepage + if ( !ppro->getTString("Homepage", &dbv)) + { + ::SetDlgItemText(hwndDlg, IDC_HOMEPAGE, dbv.ptszVal); + ::db_free(&dbv); + } + else + ::SetDlgItemText(hwndDlg, IDC_HOMEPAGE, _T("")); + + // about + if ( !ppro->getTString("About", &dbv)) { + ::SetDlgItemText(hwndDlg, IDC_ABOUT, dbv.ptszVal); + ::db_free(&dbv); + } + else + ::SetDlgItemText(hwndDlg, IDC_ABOUT, _T("")); + + // mood + if ( !ppro->getTString("XStatusMsg", &dbv)) { + ::SetDlgItemText(hwndDlg, IDC_MOOD, dbv.ptszVal); + ::db_free(&dbv); + } + else + ::SetDlgItemText(hwndDlg, IDC_MOOD, _T("")); + } + break; + + case WM_COMMAND: + if (((HWND)lParam == GetFocus() && HIWORD(wParam) == EN_CHANGE) || + (((HWND)lParam == GetDlgItem(hwndDlg, IDC_GENDER) || (HWND)lParam == GetDlgItem(hwndDlg, IDC_BIRTH_DAY) || + (HWND)lParam == GetDlgItem(hwndDlg, IDC_BIRTH_MONTH) || (HWND)lParam == GetDlgItem(hwndDlg, IDC_BIRTH_YEAR) || + (HWND)lParam == GetDlgItem(hwndDlg, IDC_LANGUAGE)) && (HIWORD(wParam) == CBN_EDITCHANGE || HIWORD(wParam) == CBN_SELCHANGE))) + { + ppro->NeedUpdate = 1; + ::SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + + case WM_NOTIFY: + if (((LPNMHDR)lParam)->idFrom == 0) { + switch (((LPNMHDR)lParam)->code) { + case PSN_PARAMCHANGED: + ::SendMessage(hwndDlg, WM_INITDIALOG, 0, ((PSHNOTIFY *)lParam)->lParam); + break; + case PSN_APPLY: + if (ppro->IsOnline() && ppro->NeedUpdate) + ppro->SaveOwnInfoToServer(hwndDlg, iPageId); + else if ( !ppro->IsOnline()) + ppro->ShowNotification(::TranslateT("You are not currently connected to the Skype network. You must be online in order to update your information on the server.")); + break; + } + } + break; + } + return FALSE; +} + +INT_PTR CALLBACK CSkypeProto::ContactSkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + const unsigned long iPageId = 1; + CSkypeProto *ppro = (CSkypeProto *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (msg) { + case WM_INITDIALOG: + if (lParam) { + ppro = (CSkypeProto *)lParam; + ::TranslateDialogDefault(hwndDlg); + + ::SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + + DBVARIANT dbv; + if ( !ppro->getTString("Cellular", &dbv)) { + ::SetDlgItemText(hwndDlg, IDC_MOBPHONE, dbv.ptszVal); + ::db_free(&dbv); + } + else + ::SetDlgItemText(hwndDlg, IDC_MOBPHONE, _T("")); + + if ( !ppro->getTString("Phone", &dbv)) { + ::SetDlgItemText(hwndDlg, IDC_HOMEPHONE, dbv.ptszVal); + ::db_free(&dbv); + } + else + ::SetDlgItemText(hwndDlg, IDC_HOMEPHONE, _T("")); + + if ( !ppro->getTString("CompanyPhone", &dbv)) { + ::SetDlgItemText(hwndDlg, IDC_OFFICEPHONE, dbv.ptszVal); + ::db_free(&dbv); + } + else + ::SetDlgItemText(hwndDlg, IDC_OFFICEPHONE, _T("")); + + if ( !ppro->getTString("e-mail0", &dbv)) { + ::SetDlgItemText(hwndDlg, IDC_EMAIL1, dbv.ptszVal); + ::db_free(&dbv); + } + else + ::SetDlgItemText(hwndDlg, IDC_EMAIL1, _T("")); + + if ( !ppro->getTString("e-mail1", &dbv)) { + ::SetDlgItemText(hwndDlg, IDC_EMAIL2, dbv.ptszVal); + ::db_free(&dbv); + } + else + ::SetDlgItemText(hwndDlg, IDC_EMAIL2, _T("")); + + if ( !ppro->getTString("e-mail2", &dbv)) { + ::SetDlgItemText(hwndDlg, IDC_EMAIL3, dbv.ptszVal); + ::db_free(&dbv); + } + else + ::SetDlgItemText(hwndDlg, IDC_EMAIL3, _T("")); + } + break; + + case WM_COMMAND: + if ((HWND)lParam == GetFocus() && HIWORD(wParam) == EN_CHANGE) + { + ppro->NeedUpdate = 1; + ::SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + + case WM_NOTIFY: + if (((LPNMHDR)lParam)->idFrom == 0) { + switch (((LPNMHDR)lParam)->code) { + case PSN_PARAMCHANGED: + ::SendMessage(hwndDlg, WM_INITDIALOG, 0, ((PSHNOTIFY *)lParam)->lParam); + break; + case PSN_APPLY: + if (ppro->IsOnline() && ppro->NeedUpdate) + ppro->SaveOwnInfoToServer(hwndDlg, iPageId); + else if ( !ppro->IsOnline()) + ppro->ShowNotification(::TranslateT("You are not currently connected to the Skype network. You must be online in order to update your information on the server.")); + break; + } + } + break; + } + return FALSE; +} + +INT_PTR CALLBACK CSkypeProto::HomeSkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + const unsigned long iPageId = 2; + CSkypeProto *ppro = (CSkypeProto *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (msg) { + case WM_INITDIALOG: + if (lParam) { + ppro = (CSkypeProto *)lParam; + ::TranslateDialogDefault(hwndDlg); + + ::SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + + DBVARIANT dbv; + if ( !ppro->getTString("City", &dbv)) { + ::SetDlgItemText(hwndDlg, IDC_CITY, dbv.ptszVal); + ::db_free(&dbv); + } + else ::SetDlgItemText(hwndDlg, IDC_CITY, _T("")); + + if ( !ppro->getTString("State", &dbv)) { + ::SetDlgItemText(hwndDlg, IDC_STATE, dbv.ptszVal); + ::db_free(&dbv); + } + else ::SetDlgItemText(hwndDlg, IDC_STATE, _T("")); + + ptrW countr(::db_get_wsa(NULL, ppro->m_szModuleName, "Country")); + for (int i = 0; i < g_cbCountries; i++) + { + if (g_countries[i].id != 0xFFFF && g_countries[i].id != 0) + { + ptrT country( mir_a2t(g_countries[i].szName)); + int nItem = ::SendMessage( + ::GetDlgItem(hwndDlg, IDC_COUNTRY), + CB_ADDSTRING, + 0, + (LPARAM)::TranslateTS(country)); + + ::SendMessage( + ::GetDlgItem(hwndDlg, IDC_COUNTRY), + CB_SETITEMDATA, + nItem, + (LPARAM)&g_countries[i].ISOcode); + + if (countr && ::wcscmp(country, countr) == 0) + ::SendMessage(GetDlgItem(hwndDlg, IDC_COUNTRY), CB_SETCURSEL, nItem, 0); + } + } + + tmi.prepareList(lParam, NULL, ::GetDlgItem(hwndDlg, IDC_TIMEZONE), TZF_PLF_CB); + HANDLE hTimeZone = tmi.createByContact(NULL, 0, 0); + LPCTSTR TzDescr = tmi.getTzDescription(tmi.getTzName(hTimeZone)); + ::SetDlgItemText(hwndDlg, IDC_TIMEZONE, TzDescr); + } + break; + + case WM_COMMAND: + if (((HWND)lParam == GetFocus() && HIWORD(wParam) == EN_CHANGE) || + (((HWND)lParam == GetDlgItem(hwndDlg, IDC_COUNTRY) || (HWND)lParam == GetDlgItem(hwndDlg, IDC_TIMEZONE)) && + (HIWORD(wParam) == CBN_EDITCHANGE || HIWORD(wParam) == CBN_SELCHANGE))) + { + ppro->NeedUpdate = 1; + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + + case WM_NOTIFY: + if (((LPNMHDR)lParam)->idFrom == 0) { + switch (((LPNMHDR)lParam)->code) { + case PSN_PARAMCHANGED: + SendMessage(hwndDlg, WM_INITDIALOG, 0, ((PSHNOTIFY *)lParam)->lParam); + break; + case PSN_APPLY: + if (ppro->IsOnline() && ppro->NeedUpdate) + ppro->SaveOwnInfoToServer(hwndDlg, iPageId); + else if ( !ppro->IsOnline()) + ppro->ShowNotification(::TranslateT("You are not currently connected to the Skype network. You must be online in order to update your information on the server.")); + break; + } + } + break; + } + return FALSE; +} + +INT_PTR CALLBACK CSkypeProto::AccountSkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + const unsigned long iPageId = 3; + CSkypeProto *ppro = (CSkypeProto *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (msg) { + case WM_INITDIALOG: + if (lParam) { + ppro = (CSkypeProto *)lParam; + ::TranslateDialogDefault(hwndDlg); + + ::SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + } + break; + + case WM_COMMAND: + if (((HWND)lParam == GetFocus() && HIWORD(wParam) == EN_CHANGE)) + { + ppro->NeedUpdate = 1; + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + + case WM_NOTIFY: + if (((LPNMHDR)lParam)->idFrom == 0) { + switch (((LPNMHDR)lParam)->code) { + case PSN_PARAMCHANGED: + SendMessage(hwndDlg, WM_INITDIALOG, 0, ((PSHNOTIFY *)lParam)->lParam); + break; + case PSN_APPLY: + if (ppro->IsOnline() && ppro->NeedUpdate) + ppro->SaveOwnInfoToServer(hwndDlg, iPageId); + else if ( !ppro->IsOnline()) + ppro->ShowNotification(::TranslateT("You are not currently connected to the Skype network. You must be online in order to update your information on the server.")); + break; + } + } + break; + } + return FALSE; +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype_events.cpp b/plugins/!Deprecated/Skype/src/skype_events.cpp new file mode 100644 index 0000000000..ba7ea1d311 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_events.cpp @@ -0,0 +1,284 @@ +#include "skype.h" + +int CSkypeProto::OnModulesLoaded(WPARAM, LPARAM) +{ + /*if (::ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) + { + ::CreateServiceFunction(MODULE"/ParseSkypeURI", &CSkypeProto::ParseSkypeUri); + ::AssocMgr_AddNewUrlTypeT("skype:", TranslateT("Skype URI API"), g_hInstance, IDI_SKYPE, MODULE"/ParseSkypeURI", 0); + }*/ + + return 0; +} + +int CSkypeProto::OnProtoModulesLoaded(WPARAM, LPARAM) +{ + this->InitNetLib(); + this->InitChatModule(); + this->InitInstanceHookList(); + + if (::ServiceExists(MS_BB_ADDBUTTON)) + { + BBButton bbd = { sizeof(bbd) }; + bbd.pszModuleName = MODULE; + + bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON; + bbd.ptszTooltip = ::TranslateT("Invite contacts to conference"); + bbd.hIcon = CSkypeProto::GetSkinIconHandle("addContacts"); + bbd.dwButtonID = BBB_ID_CONF_INVITE; + bbd.dwDefPos = 100 + bbd.dwButtonID; + ::CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); + + bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISRSIDEBUTTON; + bbd.ptszTooltip = ::TranslateT("Spawn conference"); + bbd.hIcon = CSkypeProto::GetSkinIconHandle("conference"); + bbd.dwButtonID = BBB_ID_CONF_SPAWN; + bbd.dwDefPos = 100 + bbd.dwButtonID; + ::CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); + + this->HookProtoEvent(ME_MSG_WINDOWEVENT, &CSkypeProto::OnSrmmWindowOpen); + } + + return 0; +} + +int CSkypeProto::OnPreShutdown(WPARAM, LPARAM) +{ + if (::ServiceExists(MS_BB_REMOVEBUTTON)) + { + BBButton bbd = { sizeof(bbd) }; + bbd.pszModuleName = MODULE; + + bbd.dwButtonID = BBB_ID_CONF_INVITE; + ::CallService(MS_BB_REMOVEBUTTON, 0, (LPARAM)&bbd); + + bbd.dwButtonID = BBB_ID_CONF_SPAWN; + ::CallService(MS_BB_REMOVEBUTTON, 0, (LPARAM)&bbd); + } + + this->SetStatus(ID_STATUS_OFFLINE); + + this->UninitNetLib(); + + return 0; +} + +int CSkypeProto::OnContactDeleted(WPARAM wParam, LPARAM lParam) +{ + MCONTACT hContact = (MCONTACT)wParam; + if (hContact) + { + if (this->isChatRoom(hContact)) + { + this->OnLeaveChat(wParam, 0); + ptrW cid(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID)); + if (cid != NULL) + { + ConversationRef conversation; + if (this->GetConversationByIdentity((char *)_T2A(cid), conversation)) + conversation->Delete(); + } + } + else + this->RevokeAuth(wParam, lParam); + } + + return 0; +} + +INT_PTR __cdecl CSkypeProto::OnAccountManagerInit(WPARAM wParam, LPARAM lParam) +{ + return (int)::CreateDialogParam( + g_hInstance, + MAKEINTRESOURCE(IDD_ACCMGR), + (HWND)lParam, + &CSkypeProto::SkypeMainOptionsProc, + (LPARAM)this); +} + +int __cdecl CSkypeProto::OnOptionsInit(WPARAM wParam, LPARAM lParam) +{ + char *title = ::mir_t2a(this->m_tszUserName); + + OPTIONSDIALOGPAGE odp = { sizeof(odp) }; + odp.hInstance = g_hInstance; + odp.pszTitle = title; + odp.dwInitParam = LPARAM(this); + odp.flags = ODPF_BOLDGROUPS; + odp.pszGroup = LPGEN("Network"); + + odp.pszTab = LPGEN("Account"); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_MAIN); + odp.pfnDlgProc = CSkypeProto::SkypeMainOptionsProc; + ::Options_AddPage(wParam, &odp); + + odp.pszTab = LPGEN("Blocked contacts"); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_BLOCKED); + odp.pfnDlgProc = CSkypeProto::SkypeBlockedOptionsProc; + ::Options_AddPage(wParam, &odp); + + odp.pszTab = LPGEN("Privacy"); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_PRIVACY); + odp.pfnDlgProc = CSkypeProto::SkypePrivacyOptionsProc; + ::Options_AddPage(wParam, &odp); + + ::mir_free(title); + return 0; +} + +int __cdecl CSkypeProto::OnUserInfoInit(WPARAM wParam, LPARAM lParam) +{ + if ((!this->IsProtoContact((MCONTACT)lParam)) && lParam) + return 0; + + OPTIONSDIALOGPAGE odp = { sizeof(odp) }; + odp.flags = ODPF_TCHAR | ODPF_USERINFOTAB | ODPF_DONTTRANSLATE; + odp.hInstance = g_hInstance; + odp.dwInitParam = LPARAM(this); + odp.position = -1900000000; + odp.ptszTitle = this->m_tszUserName; + + MCONTACT hContact = (MCONTACT)lParam; + if (hContact) { + char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact, 0); + if (szProto != NULL && !strcmp(szProto, m_szModuleName)) { + odp.pfnDlgProc = SkypeDlgProc; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_SKYPE); + UserInfo_AddPage(wParam, &odp); + } + } + else { + NeedUpdate = 0; + odp.pfnDlgProc = ContactSkypeDlgProc; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OWNINFO_CONTACT); + odp.ptszTab = LPGENT("Contacts"); + UserInfo_AddPage(wParam, &odp); + + odp.pfnDlgProc = HomeSkypeDlgProc; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OWNINFO_HOME); + odp.ptszTab = LPGENT("Home"); + UserInfo_AddPage(wParam, &odp); + + odp.pfnDlgProc = PersonalSkypeDlgProc; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OWNINFO_PERSONAL); + odp.ptszTab = LPGENT("General"); + UserInfo_AddPage(wParam, &odp); + + odp.pfnDlgProc = AccountSkypeDlgProc; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OWNINFO_ACCOUNT); + odp.ptszTab = LPGENT("Skype account"); + UserInfo_AddPage(wParam, &odp); + } + return 0; +} + +int __cdecl CSkypeProto::OnSrmmWindowOpen(WPARAM, LPARAM lParam) +{ + MessageWindowEventData *ev = (MessageWindowEventData*)lParam; + if (ev->uType == MSG_WINDOW_EVT_OPENING && ev->hContact) + { + BBButton bbd = { sizeof(bbd) }; + bbd.pszModuleName = MODULE; + bbd.bbbFlags = (!::strcmp(::GetContactProto(ev->hContact), this->m_szModuleName)) ? 0 : BBSF_HIDDEN | BBSF_DISABLED; + + bbd.dwButtonID = BBB_ID_CONF_INVITE; + ::CallService(MS_BB_SETBUTTONSTATE, (WPARAM)ev->hContact, (LPARAM)&bbd); + + bbd.dwButtonID = BBB_ID_CONF_SPAWN; + ::CallService(MS_BB_SETBUTTONSTATE, (WPARAM)ev->hContact, (LPARAM)&bbd); + } + return 0; +} + +int __cdecl CSkypeProto::OnTabSRMMButtonPressed(WPARAM wParam, LPARAM lParam) +{ + MCONTACT hContact = (MCONTACT)wParam; + CustomButtonClickData *cbcd = (CustomButtonClickData *)lParam; + + switch (cbcd->dwButtonId) + { + case BBB_ID_CONF_INVITE: + if (this->IsOnline() && this->isChatRoom(hContact)) + this->ChatRoomInvite(hContact); + break; + + case BBB_ID_CONF_SPAWN: + if (this->IsOnline() && !this->isChatRoom(hContact)) + { + SEStringList targets; + ptrW sid(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID)); + targets.append((char *)_T2A(sid)); + + ConversationRef conversation, conference; + this->GetConversationByParticipants(targets, conversation); + + StringList invitedContacts(sid); + ChatRoomParam *param = new ChatRoomParam(NULL, invitedContacts, this); + + if (::DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CHATROOM_CREATE), NULL, CSkypeProto::ChatRoomProc, (LPARAM)param) == IDOK && param->invitedContacts.size() > 0) + { + for (size_t i = 0; i < param->invitedContacts.size(); i++) + { + SEString contact(_T2A(param->invitedContacts[i])); + if ( !targets.contains(contact)) + targets.append(contact); + } + conversation->SpawnConference(targets, conference); + } + } + break; + } + + return 1; +} + +void CSkypeProto::OnMessage( + const MessageRef & message, + const bool & changesInboxTimestamp, + const MessageRef & supersedesHistoryMessage, + const ConversationRef & conversation) +{ + CMessage::TYPE messageType; + message->GetPropType(messageType); + + switch (messageType) + { + case CMessage::POSTED_EMOTE: + case CMessage::POSTED_TEXT: + case CMessage::STARTED_LIVESESSION: + case CMessage::ENDED_LIVESESSION: + { + CConversation::TYPE type; + conversation->GetPropType(type); + if (type == 0 || type == CConversation::DIALOG) + this->OnMessageEvent(conversation, message); + else + this->OnChatEvent(conversation, message); + } + break; + + case CMessage::ADDED_CONSUMERS: + case CMessage::RETIRED: + case CMessage::RETIRED_OTHERS: + case CMessage::SPAWNED_CONFERENCE: + this->OnChatEvent(conversation, message); + break; + + case CMessage::POSTED_FILES: + this->OnFileEvent(conversation, message); + break; + + case CMessage::POSTED_CONTACTS: + this->OnContactsEvent(conversation, message); + break; + + //case CMessage::REQUESTED_AUTH: + // break; + + //case CMessage::GRANTED_AUTH: + // break; + + //case CMessage::BLOCKED: + // break; + } +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype_hooks.cpp b/plugins/!Deprecated/Skype/src/skype_hooks.cpp new file mode 100644 index 0000000000..13dc08c95b --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_hooks.cpp @@ -0,0 +1,17 @@ +#include "skype.h" + +void CSkypeProto::InitHookList() +{ + ::HookEvent(ME_SYSTEM_MODULESLOADED, &CSkypeProto::OnModulesLoaded); + ::HookEvent(ME_CLIST_PREBUILDCONTACTMENU, &CSkypeProto::PrebuildContactMenu); +} + +void CSkypeProto::InitInstanceHookList() +{ + this->HookProtoEvent(ME_OPT_INITIALISE, &CSkypeProto::OnOptionsInit); + this->HookProtoEvent(ME_USERINFO_INITIALISE, &CSkypeProto::OnUserInfoInit); + + this->HookProtoEvent(ME_MSG_PRECREATEEVENT, &CSkypeProto::OnMessagePreCreate); + + this->HookProtoEvent(ME_MSG_BUTTONPRESSED, &CSkypeProto::OnTabSRMMButtonPressed); +} diff --git a/plugins/!Deprecated/Skype/src/skype_icons.cpp b/plugins/!Deprecated/Skype/src/skype_icons.cpp new file mode 100644 index 0000000000..5822cf2b37 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_icons.cpp @@ -0,0 +1,66 @@ +#include "skype.h" + +_tag_iconList CSkypeProto::IconList[] = +{ + { LPGENT("Protocol icon"), "main", IDI_SKYPE }, + + { LPGENT("Call"), "call", IDI_CALL }, + { LPGENT("Invite to conference"), "addContacts", IDI_ADD_CONTACTS }, + { LPGENT("Conference"), "conference", IDI_CONFERENCE }, + { LPGENT("Send contact"), "sendContacts", IDI_SEND_CONTACTS }, + { LPGENT("Contact"), "contact", IDI_CONTACT }, + { LPGENT("Delete"), "delete", IDI_DELETE }, + { LPGENT("Block"), "block", IDI_BLOCK }, +}; + +void CSkypeProto::InitIcons() +{ + wchar_t szFile[MAX_PATH]; + ::GetModuleFileName(g_hInstance, szFile, MAX_PATH); + + char szSettingName[100]; + wchar_t szSectionName[100]; + + SKINICONDESC sid = {0}; + sid.cbSize = sizeof(SKINICONDESC); + sid.flags = SIDF_ALL_TCHAR; + sid.ptszDefaultFile = szFile; + sid.pszName = szSettingName; + sid.ptszSection = szSectionName; + + ::mir_sntprintf(szSectionName, SIZEOF(szSectionName), _T("%s/%s"), LPGENT("Protocols"), LPGENT(MODULE)); + for (int i = 0; i < SIZEOF(CSkypeProto::IconList); i++) + { + ::mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", MODULE, CSkypeProto::IconList[i].Name); + + sid.ptszDescription = CSkypeProto::IconList[i].Description; + sid.iDefaultIndex = -CSkypeProto::IconList[i].IconId; + CSkypeProto::IconList[i].Handle = ::Skin_AddIcon(&sid); + } +} + +HANDLE CSkypeProto::GetIconHandle(const char* name) +{ + for (size_t i = 0; i < SIZEOF(CSkypeProto::IconList); i++) + { + if (::stricmp(CSkypeProto::IconList[i].Name, name) == 0) + return CSkypeProto::IconList[i].Handle; + } + return 0; +} + +HANDLE CSkypeProto::GetSkinIconHandle(const char* name) +{ + char iconName[100]; + ::mir_snprintf(iconName, SIZEOF(iconName), "%s_%s", MODULE, name); + HANDLE hIcon = ::Skin_GetIconHandle(iconName); + if ( !hIcon) + hIcon = CSkypeProto::GetIconHandle(name); + return hIcon; +} + +void CSkypeProto::UninitIcons() +{ + for (size_t i = 0; i < SIZEOF(CSkypeProto::IconList); i++) + ::Skin_RemoveIcon(CSkypeProto::IconList[i].Name); +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype_ignore_list.cpp b/plugins/!Deprecated/Skype/src/skype_ignore_list.cpp new file mode 100644 index 0000000000..b37f6787e0 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_ignore_list.cpp @@ -0,0 +1,271 @@ +#include "skype.h" +#include "skype_chat.h" + +int CSkypeProto::IgnoreCommand(WPARAM wParam, LPARAM) +{ + CContact::Ref contact; + HANDLE hContact = (HANDLE)wParam; + SEString sid(_T2A(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID))); + if (this->GetContact(sid, contact)) + { + //bool state = ::CallService(MS_IGNORE_ISIGNORED, wParam, IGNOREEVENT_ALL); + bool state = ::db_get_b(hContact, this->m_szModuleName, "Ignore", 0) > 0; + if (contact->SetBlocked(!state)) + { + //::CallService(!state ? MS_IGNORE_IGNORE : MS_IGNORE_UNIGNORE, wParam, IGNOREEVENT_ALL); + ::db_set_b(hContact, this->m_szModuleName, "Ignore", (int)!state); + } + } + + return 0; +} + +int CSkypeProto::BlockCommand(WPARAM wParam, LPARAM lParam) +{ + HANDLE hContact = (HANDLE)wParam; + if (hContact) + { + this->IgnoreCommand(wParam, lParam); + + ::db_set_b(hContact, "CList", "Hidden", 1); + } + + return 0; +} + +INT_PTR CSkypeProto::OpenIgnoreListCommand(WPARAM, LPARAM) +{ + ::DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_IGNORE_LIST), NULL, CSkypeProto::IgnoreListWndProc, (LPARAM)this); + + return 0; +} + +static WNDPROC oldWndProc = NULL; + +static LRESULT CALLBACK IgnoreListSubProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + if (msg == WM_LBUTTONDOWN) + { + LVHITTESTINFO hi; + hi.pt.x = LOWORD(lParam); hi.pt.y = HIWORD(lParam); + ListView_SubItemHitTest(hwnd, &hi); + if (hi.iSubItem == 1) + { + LVITEM lvi = {0}; + lvi.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_GROUPID; + lvi.stateMask = -1; + lvi.iItem = hi.iItem; + if (ListView_GetItem(hwnd, &lvi)) + { + if (lvi.iGroupId == 1) + { + CContact *contact = (CContact *)lvi.lParam; + + if (contact->SetBlocked(false)) + ListView_DeleteItem(hwnd, lvi.iItem); + } + /*else if (lvi.iGroupId == 2) + { + CConversation *convo = (CConversation *)lvi.lParam; + + if (convo->SetBlocked(false)) + ListView_DeleteItem(hwnd, lvi.iItem); + }*/ + } + } + } + + return ::CallWindowProc(oldWndProc, hwnd, msg, wParam, lParam); +} + +int ImageList_AddIconFromIconLib(HIMAGELIST hIml, const char *name) +{ + HICON icon = ::Skin_GetIconByHandle(::Skin_GetIconHandle(name)); + int res = ImageList_AddIcon(hIml, icon); + ::Skin_ReleaseIcon(icon); + return res; +} + +INT_PTR CALLBACK CSkypeProto::IgnoreListWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + CSkypeProto *ppro = (CSkypeProto *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (msg) + { + case WM_INITDIALOG: + if (lParam) + { + ppro = (CSkypeProto *)lParam; + ::TranslateDialogDefault(hwndDlg); + + ::SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + + ::SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)::Skin_GetIcon("Skype_block", ICON_BIG)); + ::SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)::Skin_GetIcon("Skype_block")); + + HWND hwndList = ::GetDlgItem(hwndDlg, IDC_BM_LIST); + { // IDC_BM_LIST setup + oldWndProc = (WNDPROC)::SetWindowLongPtr(hwndList, GWLP_WNDPROC, (LONG_PTR)IgnoreListSubProc); + + HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0); + ImageList_AddIconFromIconLib(hIml, "Skype_contact"); + ImageList_AddIconFromIconLib(hIml, "Skype_delete"); + ListView_SetImageList(hwndList, hIml, LVSIL_SMALL); + + /// + LVCOLUMN lvc = {0}; + lvc.mask = LVCF_WIDTH | LVCF_TEXT; + + //lvc.fmt = LVCFMT_JUSTIFYMASK; + lvc.pszText = TranslateT("Name"); + lvc.cx = 220; // width of column in pixels + ListView_InsertColumn(hwndList, 0, &lvc); + + //lvc.fmt = LVCFMT_RIGHT; + lvc.pszText = L""; + lvc.cx = 32 - GetSystemMetrics(SM_CXVSCROLL); // width of column in pixels + ListView_InsertColumn(hwndList, 1, &lvc); + + /// + LVGROUP lvg; + lvg.cbSize = sizeof(LVGROUP); + lvg.mask = LVGF_HEADER | LVGF_GROUPID; + + lvg.pszHeader = ::TranslateT("Contacts"); + lvg.iGroupId = 1; + ListView_InsertGroup(hwndList, 0, &lvg); + + lvg.pszHeader = ::TranslateT("Conferences"); + lvg.iGroupId = 2; + ListView_InsertGroup(hwndList, 0, &lvg); + + ListView_EnableGroupView(hwndList, TRUE); + + ::SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_SUBITEMIMAGES | LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP); + + if ( !ppro->IsOnline()) + ::EnableWindow(hwndList, FALSE); + } + + SEString data; + ContactGroupRef blockedList; + ppro->GetHardwiredContactGroup(ContactGroup::CONTACTS_BLOCKED_BY_ME, blockedList); + + ContactRefs contacts; + blockedList->GetContacts(contacts); + for (size_t i = 0; i < contacts.size(); i++) + { + auto contact = contacts[i]; + + contact->GetPropDisplayname(data); + ptrW name = ::mir_utf8decodeW(data); + + LVITEM lvi = {0}; + lvi.mask = LVIF_GROUPID | LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; + lvi.iItem = (int)i; + lvi.iGroupId = 1; + lvi.iImage = 0; + lvi.lParam = (LPARAM)contact.fetch(); + lvi.pszText = name; + int iRow = ListView_InsertItem(hwndList, &lvi); + + if (iRow != -1) + { + lvi.iItem = iRow; + lvi.mask = LVIF_IMAGE; + lvi.iSubItem = 1; + lvi.iImage = 1; + ListView_SetItem(hwndList, &lvi); + } + } + + ConversationRefs conversations; + blockedList->GetConversations(conversations); + for (size_t i = 0; i < conversations.size(); i++) + { + auto conversation = conversations[i]; + + uint type = conversation->GetUintProp(Conversation::P_TYPE); + if (type != Conversation::CONFERENCE) + continue; + + conversation->GetPropDisplayname(data); + ptrW name = ::mir_utf8decodeW(data); + + LVITEM lvi = {0}; + lvi.mask = LVIF_GROUPID | LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; + lvi.iItem = (int)i; + lvi.iGroupId = 2; + lvi.iImage = 0; + lvi.lParam = (LPARAM)conversation.fetch(); + lvi.pszText = name; + int iRow = ListView_InsertItem(hwndList, &lvi); + + if (iRow != -1) + { + lvi.iItem = iRow; + lvi.mask = LVIF_IMAGE; + lvi.iSubItem = 1; + lvi.iImage = 1; + ListView_SetItem(hwndList, &lvi); + } + } + + ::Utils_RestoreWindowPosition(hwndDlg, 0, MODULE, "IgnoreListWindow"); + } + break; + + case WM_NOTIFY: + switch(LOWORD(wParam)) + { + case IDC_BM_LIST: + if (((LPNMHDR)lParam)->code == NM_DBLCLK) + { + HWND hwndList = ::GetDlgItem(hwndDlg, IDC_BM_LIST); + int iItem = ListView_GetNextItem(hwndList, -1, LVNI_ALL | LVNI_SELECTED); + if (iItem < 0) break; + LVITEM lvi = {0}; + lvi.mask = LVIF_PARAM | LVIF_GROUPID; + lvi.stateMask = -1; + lvi.iItem = iItem; + if (ListView_GetItem(hwndList, &lvi)) + { + SEString data; + if (lvi.iGroupId == 1) + { + CContact *contact = (CContact *)lvi.lParam; + + contact->GetIdentity(data); + ptrW sid(::mir_utf8decodeW(data)); + ::CallService(MS_MSG_SENDMESSAGE, (WPARAM)ppro->GetContactBySid(sid), 0); + } + /*else if (lvi.iGroupId == 2) + { + CConversation *conversation = (CConversation *)lvi.lParam; + + conversation->GetPropIdentity(data); + ptrW cid(::mir_utf8decodeW(data)); + CSkypeProto::ReplaceSpecialChars(cid); + }*/ + } + } + } + break; + + case WM_COMMAND: + if (HIWORD( wParam ) == BN_CLICKED) + { + switch(LOWORD(wParam)) + { + case IDCANCEL: + ::Utils_SaveWindowPosition(hwndDlg, NULL, MODULE, "IgnoreListWindow"); + ::Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0)); + ::Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0)); + ::DestroyWindow(hwndDlg); + return TRUE; + } + } + break; + } + return FALSE; +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype_instances.cpp b/plugins/!Deprecated/Skype/src/skype_instances.cpp new file mode 100644 index 0000000000..66b8447fbc --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_instances.cpp @@ -0,0 +1,88 @@ +#include "skype.h" + +LIST CSkypeProto::instanceList(1, CSkypeProto::CompareProtos); + +int CSkypeProto::CompareProtos(const CSkypeProto *p1, const CSkypeProto *p2) +{ + return wcscmp(p1->m_tszUserName, p2->m_tszUserName); +} + +CSkypeProto* CSkypeProto::InitSkypeProto(const char* protoName, const wchar_t* userName) +{ + if (CSkypeProto::instanceList.getCount() > 0) + { + CSkypeProto::ShowNotification( + ::TranslateT("Skype protocol plugin only permits you to login to one account at a time. Adding multiple accounts is prohibited in the license agreement and standard distribution terms of SkypeKit."), + MB_ICONERROR); + return NULL; + } + + CSkypeProto *ppro = new CSkypeProto(protoName, userName); + + VARST profilename( _T("%miranda_profilename%")); + + if ( !ppro->StartSkypeRuntime((TCHAR *)profilename)) + { + CSkypeProto::ShowNotification(::TranslateT("Did not unpack SkypeKit.exe."), MB_ICONERROR); + return NULL; + } + + char *keyPair = ppro->LoadKeyPair(); + if (keyPair == NULL) + { + CSkypeProto::ShowNotification(::TranslateT("Initialization key corrupted or not valid."), MB_ICONERROR); + return NULL; + } + + TransportInterface::Status status = ppro->init(keyPair, "127.0.0.1", ppro->skypeKitPort, 0, 1); + if (status != TransportInterface::OK) + { + wchar_t message[256]; + ::mir_sntprintf(message, SIZEOF(message), ::TranslateT("SkypeKit did not initialize (%d)."), status); + CSkypeProto::ShowNotification(message, MB_ICONERROR); + return NULL; + } + + if ( !ppro->start()) + { + CSkypeProto::ShowNotification(TranslateT("SkypeKit did not start."), MB_ICONERROR); + return NULL; + } + + ::mir_free(keyPair); + + CSkypeProto::instanceList.insert(ppro); + + return ppro; +} + +int CSkypeProto::UninitSkypeProto(CSkypeProto* ppro) +{ + ppro->stop(); + + ppro->StopSkypeRuntime(); + + CSkypeProto::instanceList.remove(ppro); + delete ppro; + + return 0; +} + +void CSkypeProto::UninitInstances() +{ + instanceList.destroy(); +} + +CSkypeProto* CSkypeProto::GetContactInstance(MCONTACT hContact) +{ + char *proto = (char *)::CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact, 0); + + if (proto == NULL) + return NULL; + + for (int i = 0; i < CSkypeProto::instanceList.getCount(); i++) + if ( !::strcmp(proto, CSkypeProto::instanceList[i]->m_szModuleName)) + return CSkypeProto::instanceList[i]; + + return NULL; +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype_menus.cpp b/plugins/!Deprecated/Skype/src/skype_menus.cpp new file mode 100644 index 0000000000..a051d24911 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_menus.cpp @@ -0,0 +1,268 @@ +#include "skype.h" + +HANDLE CSkypeProto::hChooserMenu; +HGENMENU CSkypeProto::contactMenuItems[CMI_MAX]; + +INT_PTR CSkypeProto::MenuChooseService(WPARAM wParam, LPARAM lParam) +{ + if (lParam) + *(void**)lParam = (void*)wParam; + + return 0; +} + +int CSkypeProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) +{ + MCONTACT hContact = (MCONTACT)wParam; + if ( !hContact) + return 0; + + if ( !this->IsOnline() || ::lstrcmpA(::GetContactProto(hContact), m_szModuleName)) + return 0; + + if ( !this->isChatRoom(hContact)) + { + bool ctrlPressed = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; + + bool authNeed = this->getByte(hContact, "Auth", 0) > 0; + bool grantNeed = this->getByte(hContact, "Grant", 0) > 0; + + ::Menu_ShowItem(CSkypeProto::contactMenuItems[CMI_AUTH_REQUEST], ctrlPressed || authNeed); + ::Menu_ShowItem(CSkypeProto::contactMenuItems[CMI_AUTH_GRANT], ctrlPressed || grantNeed); + ::Menu_ShowItem(CSkypeProto::contactMenuItems[CMI_AUTH_REVOKE], ctrlPressed || (!grantNeed && !authNeed)); + ::Menu_ShowItem(CSkypeProto::contactMenuItems[CMI_HISTORY], TRUE); + + { + SEString sid(_T2A(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID))); + + ContactRef contact; + this->GetContact(sid, contact); + + bool isBlocked = false; + contact->IsMemberOfHardwiredGroup(ContactGroup::CONTACTS_BLOCKED_BY_ME, isBlocked); + + CLISTMENUITEM clmi = { sizeof(clmi) }; + clmi.cbSize = sizeof(CLISTMENUITEM); + clmi.flags = CMIM_FLAGS; + if (isBlocked) + { + clmi.flags |= CMIM_NAME | CMIM_ICON | CMIF_TCHAR; + clmi.icolibItem = CSkypeProto::GetSkinIconHandle("contact"); + clmi.ptszName = LPGENT("Unblock this person..."); + } + else + { + clmi.flags |= CMIM_NAME | CMIM_ICON | CMIF_TCHAR; + clmi.icolibItem = CSkypeProto::GetSkinIconHandle("block"); + clmi.ptszName = LPGENT("Block this person..."); + } + ::CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)CSkypeProto::contactMenuItems[CMI_BLOCK], (LPARAM)&clmi); + } + } + + return 0; +} + +template +INT_PTR GlobalService(WPARAM wParam, LPARAM lParam) +{ + CSkypeProto *ppro = CSkypeProto::GetContactInstance((MCONTACT)wParam); + return ppro ? (ppro->*Service)(wParam, lParam) : 0; +} + +int CSkypeProto::RequestAuth(WPARAM wParam, LPARAM lParam) +{ + return this->AuthRequest((MCONTACT)wParam, LPGENT("Hi! I'd like to add you to my contact list")); +} + +int CSkypeProto::GrantAuth(WPARAM wParam, LPARAM lParam) +{ + CContact::Ref contact; + MCONTACT hContact = (MCONTACT)wParam; + SEString sid(_T2A(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID))); + if (this->GetContact(sid, contact)) + { + if (contact->SetBuddyStatus(true)) + { + this->delSetting(hContact, "Auth"); + this->delSetting(hContact, "Grant"); + } + } + + return 0; +} + +int CSkypeProto::RevokeAuth(WPARAM wParam, LPARAM lParam) +{ + CContact::Ref contact; + MCONTACT hContact = (MCONTACT)wParam; + SEString sid(_T2A(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID))); + if (this->GetContact(sid, contact)) + { + if (contact->SetBuddyStatus(false)) + this->setByte(hContact, "Grant", 1); + this->contactList.remove_val(contact); + } + + return 0; +} + +int CSkypeProto::PrebuildContactMenu(WPARAM wParam, LPARAM lParam) +{ + for (int i = 0; i < SIZEOF(CSkypeProto::contactMenuItems); i++) + ::Menu_ShowItem(CSkypeProto::contactMenuItems[i], false); + + CSkypeProto* ppro = CSkypeProto::GetContactInstance((MCONTACT)wParam); + return (ppro) ? ppro->OnPrebuildContactMenu(wParam, lParam) : 0; +} + +void CSkypeProto::InitMenus() +{ + hChooserMenu = MO_CreateMenuObject("SkypeAccountChooser", LPGEN("Skype menu chooser"), 0, "Skype/MenuChoose"); + + ////////////////////////////////////////////////////////////////////////////////////// + // Contact menu initialization + + CLISTMENUITEM mi = { 0 }; + mi.cbSize = sizeof(CLISTMENUITEM); + mi.flags = CMIF_TCHAR | CMIF_NOTOFFLINE; + + // "Request authorization" + mi.pszService = MODULE"/RequestAuth"; + mi.ptszName = LPGENT("Request authorization"); + mi.position = -201001000 + CMI_AUTH_REQUEST; + mi.icolibItem = ::LoadSkinnedIconHandle(SKINICON_AUTH_REQUEST); + CSkypeProto::contactMenuItems[CMI_AUTH_REQUEST] = ::Menu_AddContactMenuItem(&mi); + ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::RequestAuth>); + + // "Grant authorization" + mi.pszService = MODULE"/GrantAuth"; + mi.ptszName = LPGENT("Grant authorization"); + mi.position = -201001000 + CMI_AUTH_GRANT; + mi.icolibItem = ::LoadSkinnedIconHandle(SKINICON_AUTH_GRANT); + CSkypeProto::contactMenuItems[CMI_AUTH_GRANT] = ::Menu_AddContactMenuItem(&mi); + ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::GrantAuth>); + + // "Revoke authorization" + mi.pszService = MODULE"/RevokeAuth"; + mi.ptszName = LPGENT("Revoke authorization"); + mi.position = -201001000 + CMI_AUTH_REVOKE; + mi.icolibItem = ::LoadSkinnedIconHandle(SKINICON_AUTH_REVOKE); + CSkypeProto::contactMenuItems[CMI_AUTH_REVOKE] = ::Menu_AddContactMenuItem(&mi); + ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::RevokeAuth>); + + // "Block" + mi.pszService = MODULE"/Block"; + mi.ptszName = LPGENT("Block this person..."); + mi.position = -200001000 + CMI_BLOCK; + mi.icolibItem = CSkypeProto::GetSkinIconHandle("block"); + CSkypeProto::contactMenuItems[CMI_BLOCK] = ::Menu_AddContactMenuItem(&mi); + ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::BlockCommand>); + + mi.pszService = MODULE"/SyncHistory"; + mi.ptszName = LPGENT("View old messages..."); + mi.flags = CMIF_TCHAR | CMIF_ROOTPOPUP; + mi.position = -200001000 + CMI_HISTORY; + mi.icolibItem = ::LoadSkinnedIconHandle(SKINICON_OTHER_HISTORY); + CSkypeProto::contactMenuItems[CMI_HISTORY] = ::Menu_AddContactMenuItem(&mi); + + mi.flags &= ~CMIF_ROOTPOPUP; + + mi.pszService = MODULE"/SyncHistoryDay"; + mi.ptszName = LPGENT("for last day"); + mi.flags |= CMIF_CHILDPOPUP; + mi.position = -200001000 + CMI_HISTORY + 100; + mi.hParentMenu = CSkypeProto::contactMenuItems[CMI_HISTORY]; + ::Menu_AddContactMenuItem(&mi); + ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::SyncLastDayHistoryCommand>); + + mi.pszService = MODULE"/SyncHistoryWeek"; + mi.ptszName = LPGENT("for last week"); + mi.flags |= CMIF_CHILDPOPUP; + mi.position = -200001000 + CMI_HISTORY + 1001; + mi.hParentMenu = CSkypeProto::contactMenuItems[CMI_HISTORY]; + ::Menu_AddContactMenuItem(&mi); + ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::SyncLastWeekHistoryCommand>); + + mi.pszService = MODULE"/SyncHistoryMonth"; + mi.ptszName = LPGENT("for last month"); + mi.flags |= CMIF_CHILDPOPUP; + mi.position = -200001000 + CMI_HISTORY + 102; + mi.hParentMenu = CSkypeProto::contactMenuItems[CMI_HISTORY]; + ::Menu_AddContactMenuItem(&mi); + ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::SyncLastMonthHistoryCommand>); + + mi.pszService = MODULE"/SyncHistory3Month"; + mi.ptszName = LPGENT("for last 3 month"); + mi.flags |= CMIF_CHILDPOPUP; + mi.position = -200001000 + CMI_HISTORY + 103; + mi.hParentMenu = CSkypeProto::contactMenuItems[CMI_HISTORY]; + ::Menu_AddContactMenuItem(&mi); + ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::SyncLast3MonthHistoryCommand>); + + mi.pszService = MODULE"/SyncHistoryYear"; + mi.ptszName = LPGENT("for last year"); + mi.flags |= CMIF_CHILDPOPUP; + mi.position = -200001000 + CMI_HISTORY + 104; + mi.hParentMenu = CSkypeProto::contactMenuItems[CMI_HISTORY]; + ::Menu_AddContactMenuItem(&mi); + ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::SyncLastYearHistoryCommand>); + + mi.pszService = MODULE"/SyncHistoryAllTime"; + mi.ptszName = LPGENT("for all time"); + mi.flags |= CMIF_CHILDPOPUP; + mi.position = -200001000 + CMI_HISTORY + 105; + mi.hParentMenu = CSkypeProto::contactMenuItems[CMI_HISTORY]; + ::Menu_AddContactMenuItem(&mi); + ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::SyncAllTimeHistoryCommand>); +} + +void CSkypeProto::UninitMenus() +{ +} + +void CSkypeProto::OnInitStatusMenu() +{ + char text[ 200 ]; + strcpy(text, m_szModuleName); + char* tDest = text + strlen(text); + + CLISTMENUITEM mi = { sizeof(mi) }; + mi.pszService = text; + + HGENMENU hSkypeRoot = ::MO_GetProtoRootMenu(m_szModuleName); + if (!hSkypeRoot) + { + mi.ptszName = m_tszUserName; + mi.position = -1999901006; + mi.hParentMenu = HGENMENU_ROOT; + mi.flags = CMIF_ROOTPOPUP | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED; + mi.icolibItem = CSkypeProto::GetSkinIconHandle("main"); + hSkypeRoot = m_hMenuRoot = ::Menu_AddProtoMenuItem(&mi); + } + else + { + if (m_hMenuRoot) + ::CallService(MS_CLIST_REMOVEMAINMENUITEM, (WPARAM)m_hMenuRoot, 0); + m_hMenuRoot = NULL; + } + + mi.hParentMenu = hSkypeRoot; + mi.flags = CMIF_CHILDPOPUP | CMIF_TCHAR; + + // Invite Command + ::strcpy(tDest, "/CreateChatRoom"); + this->CreateProtoService(tDest, &CSkypeProto::CreateChatRoomCommand); + mi.ptszName = LPGENT("Create conference"); + mi.position = 200000 + SMI_CHAT_CREATE; + mi.icolibItem = CSkypeProto::GetSkinIconHandle("conference"); + ::Menu_AddProtoMenuItem(&mi); + + // Invite Command + ::strcpy(tDest, "/BlockedeList"); + this->CreateProtoService(tDest, &CSkypeProto::OpenBlockedListCommand); + mi.ptszName = LPGENT("Blocked contacts"); + mi.position = 200000 + SMI_IGNORE_LIST; + mi.icolibItem = CSkypeProto::GetSkinIconHandle("block"); + ::Menu_AddProtoMenuItem(&mi); +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype_messages.cpp b/plugins/!Deprecated/Skype/src/skype_messages.cpp new file mode 100644 index 0000000000..b212959f98 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_messages.cpp @@ -0,0 +1,315 @@ +#include "skype.h" + +int CSkypeProto::OnMessagePreCreate(WPARAM, LPARAM lParam) +{ + MessageWindowEvent *evt = (MessageWindowEvent *)lParam; + if ( strcmp(GetContactProto(evt->hContact), this->m_szModuleName)) + return 0; + + MessageRef message(evt->seq); + SEBinary guid; + if (message->GetPropGuid(guid)) + { + CMessage::TYPE messageType; + message->GetPropType(messageType); + + if (messageType == CMessage::POSTED_TEXT) + { + evt->dbei->pBlob = (PBYTE)::mir_realloc(evt->dbei->pBlob, evt->dbei->cbBlob + guid.size()); + ::memcpy((char *)&evt->dbei->pBlob[evt->dbei->cbBlob], guid.data(), guid.size()); + evt->dbei->cbBlob += (DWORD)guid.size(); + } + else if (messageType == CMessage::POSTED_EMOTE) + { + evt->dbei->pBlob = (PBYTE)::mir_realloc(evt->dbei->pBlob, evt->dbei->cbBlob + guid.size() - 4); + ::memcpy((char *)&evt->dbei->pBlob[0], (char *)&evt->dbei->pBlob[4], evt->dbei->cbBlob - 4); + ::memcpy((char *)&evt->dbei->pBlob[evt->dbei->cbBlob - 4], guid.data(), guid.size()); + evt->dbei->cbBlob += (DWORD)guid.size() - 4; + + evt->dbei->eventType = SKYPE_DB_EVENT_TYPE_EMOTE; + } + } + + return 1; +} + +void CSkypeProto::OnMessageReceived(const ConversationRef &conversation, const MessageRef &message) +{ + SEString data; + + Message::TYPE messageType; + message->GetPropType(messageType); + + uint timestamp; + message->GetPropTimestamp(timestamp); + + Message::CONSUMPTION_STATUS status; + message->GetPropConsumptionStatus(status); + + message->GetPropBodyXml(data); + ptrA text( CSkypeProto::RemoveHtml(data)); + + ContactRef author; + message->GetPropAuthor(data); + this->GetContact(data, author); + + MCONTACT hContact = this->AddContact(author, true); + this->UserIsTyping(hContact, PROTOTYPE_SELFTYPING_OFF); + + SEBinary guid; + message->GetPropGuid(guid); + ReadMessageParam param = { guid, messageType }; + + //if (status != CMessage::UNCONSUMED_NORMAL) + if (this->IsMessageInDB(hContact, timestamp, guid)) + return; + + DWORD flags = PREF_UTF; + if (status != CMessage::UNCONSUMED_NORMAL) + flags |= PREF_CREATEREAD; + + PROTORECVEVENT recv = { 0 }; + recv.flags = flags; + recv.lParam = (LPARAM)¶m; + recv.timestamp = timestamp; + recv.szMessage = ::mir_strdup(text); + ::ProtoChainRecvMsg(hContact, &recv); +} + +///////////////////////////////////////////////////////////////////////////////////////// + +void CSkypeProto::OnMessageSent(const ConversationRef &conversation, const MessageRef &message) +{ + SEString data; + + CMessage::TYPE messageType; + message->GetPropType(messageType); + + uint timestamp; + message->GetPropTimestamp(timestamp); + + CMessage::SENDING_STATUS sstatus; + message->GetPropSendingStatus(sstatus); + + CMessage::CONSUMPTION_STATUS status; + message->GetPropConsumptionStatus(status); + + message->GetPropBodyXml(data); + ptrA text( CSkypeProto::RemoveHtml(data)); + + CParticipant::Refs participants; + conversation->GetParticipants(participants, CConversation::OTHER_CONSUMERS); + participants[0]->GetPropIdentity(data); + + ptrW sid(::mir_utf8decodeW(data)); + + MCONTACT hContact = this->GetContactBySid(sid); + this->SendBroadcast( + hContact, + ACKTYPE_MESSAGE, + sstatus == CMessage::FAILED_TO_SEND ? ACKRESULT_FAILED : ACKRESULT_SUCCESS, + (HANDLE)message->getOID(), 0); + + SEBinary guid; + message->GetPropGuid(guid); + + this->RaiseMessageSentEvent( + hContact, + timestamp, + guid, + text, + status == CMessage::UNCONSUMED_NORMAL); +} + +void CSkypeProto::OnMessageEvent(const ConversationRef &conversation, const MessageRef &message) +{ + CMessage::TYPE messageType; + message->GetPropType(messageType); + + switch (messageType) + { + case CMessage::POSTED_EMOTE: + case CMessage::POSTED_TEXT: + { + SEString author; + message->GetPropAuthor(author); + + if (::wcsicmp(ptrW(::mir_utf8decodeW(author)), this->login) == 0) + this->OnMessageSent(conversation, message); + else + this->OnMessageReceived(conversation, message); + } + break; + + case CMessage::STARTED_LIVESESSION: + { + Message::CONSUMPTION_STATUS status; + message->GetPropConsumptionStatus(status); + if (status != Message::UNCONSUMED_NORMAL) + break; + + uint timestamp; + message->GetPropTimestamp(timestamp); + + SEString identity; + message->GetPropAuthor(identity); + + CContact::Ref author; + this->GetContact(identity, author); + + MCONTACT hContact = this->AddContact(author); + + char *message = ::mir_utf8encode(::Translate("Incoming call started")); + + this->AddDBEvent( + hContact, + SKYPE_DB_EVENT_TYPE_CALL, + timestamp, + DBEF_UTF, + (DWORD)::strlen(message) + 1, + (PBYTE)message); + //temp popup + /*TCHAR popuptext[MAX_PATH]; + mir_sntprintf(popuptext, SIZEOF(popuptext), TranslateT("Incoming call from %s. Use offical skype for calling."), ptrW(::mir_utf8decodeW(identity))); + this->ShowNotification(popuptext);*/ + } + break; + + case CMessage::ENDED_LIVESESSION: + { + Message::CONSUMPTION_STATUS status; + message->GetPropConsumptionStatus(status); + if (status != Message::UNCONSUMED_NORMAL) + break; + + uint timestamp; + message->GetPropTimestamp(timestamp); + + SEString identity; + message->GetPropAuthor(identity); + + CContact::Ref author; + this->GetContact(identity, author); + + MCONTACT hContact = this->AddContact(author); + + char *message = ::mir_utf8encode(::Translate("Incoming call finished")); + + this->AddDBEvent( + hContact, + SKYPE_DB_EVENT_TYPE_CALL, + timestamp, + DBEF_UTF, + (DWORD)::strlen(message) + 1, + (PBYTE)message); + } + break; + } +} + +void CSkypeProto::SyncMessageHystory(const ConversationRef &conversation, const time_t timestamp) +{ + if (conversation) + { + conversation->SetConsumedHorizon(timestamp); + MessageRefs oldMessages, newMessages; + conversation->GetLastMessages(oldMessages, newMessages, timestamp); + for (size_t i = 0; i < oldMessages.size(); i++) + this->OnMessageEvent(conversation, oldMessages[i]); + for (size_t i = 0; i < newMessages.size(); i++) + this->OnMessageEvent(conversation, newMessages[i]); + conversation->SetConsumedHorizon(time(NULL)); + } +} + +void CSkypeProto::SyncHistoryCommand(MCONTACT hContact, time_t timestamp) +{ + if (hContact) + { + ptrW sid( ::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID)); + + ConversationRef conversation; + if ( !this->isChatRoom(hContact)) + { + SEStringList target; + target.append((char *)ptrA(::mir_utf8encodeW(sid))); + this->GetConversationByParticipants(target, conversation); + } + else + this->GetConversationByIdentity((char *)ptrA(::mir_utf8encodeW(sid)), conversation); + + if (conversation) + { + this->SyncMessageHystory(conversation, timestamp); + CSkypeProto::ShowNotification(TranslateT("history synchronization"), TranslateT("Done!"), MB_ICONINFORMATION, hContact); + } + } +} + +int CSkypeProto::SyncLastDayHistoryCommand(WPARAM wParam, LPARAM lParam) +{ + time_t timestamp = time(NULL); + timestamp -= 60*60*24; + this->SyncHistoryCommand((MCONTACT)wParam, timestamp); + return 0; +} + +int CSkypeProto::SyncLastWeekHistoryCommand(WPARAM wParam, LPARAM lParam) +{ + time_t timestamp = time(NULL); + timestamp -= 60*60*24*7; + this->SyncHistoryCommand((MCONTACT)wParam, timestamp); + return 0; +} + +int CSkypeProto::SyncLastMonthHistoryCommand(WPARAM wParam, LPARAM lParam) +{ + time_t timestamp = time(NULL); + timestamp -= 60*60*24*30; + this->SyncHistoryCommand((MCONTACT)wParam, timestamp); + return 0; +} + +int CSkypeProto::SyncLast3MonthHistoryCommand(WPARAM wParam, LPARAM lParam) +{ + time_t timestamp = time(NULL); + timestamp -= 60*60*24*90; + this->SyncHistoryCommand((MCONTACT)wParam, timestamp); + return 0; +} + +int CSkypeProto::SyncLastYearHistoryCommand(WPARAM wParam, LPARAM lParam) +{ + time_t timestamp = time(NULL); + timestamp -= 60*60*24*365; + this->SyncHistoryCommand((MCONTACT)wParam, timestamp); + return 0; +} + +int CSkypeProto::SyncAllTimeHistoryCommand(WPARAM wParam, LPARAM lParam) +{ + MCONTACT hContact = (MCONTACT)wParam; + if (hContact) + { + ptrW sid( ::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID)); + + ConversationRef conversation; + if ( !this->isChatRoom(hContact)) + { + SEStringList target; + target.append((char *)ptrA(::mir_utf8encodeW(sid))); + this->GetConversationByParticipants(target, conversation); + } + else + this->GetConversationByIdentity((char *)ptrA(::mir_utf8encodeW(sid)), conversation); + + if (conversation) + { + uint timestamp; + conversation->GetPropCreationTimestamp(timestamp); + this->SyncMessageHystory(conversation, timestamp); + CSkypeProto::ShowNotification(TranslateT("history synchronization"), TranslateT("Done!"), MB_ICONINFORMATION, hContact); + } + } + return 0; +} diff --git a/plugins/!Deprecated/Skype/src/skype_netlib.cpp b/plugins/!Deprecated/Skype/src/skype_netlib.cpp new file mode 100644 index 0000000000..6a958d0217 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_netlib.cpp @@ -0,0 +1,22 @@ +#include "skype.h" + +void CSkypeProto::InitNetLib() +{ + wchar_t name[128]; + ::mir_sntprintf(name, SIZEOF(name), ::TranslateT("%s connection"), this->m_tszUserName); + + NETLIBUSER nlu = {0}; + nlu.cbSize = sizeof(nlu); + nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_UNICODE; + nlu.ptszDescriptiveName = name; + nlu.szSettingsModule = this->m_szModuleName; + this->m_hNetlibUser = (HANDLE)::CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); + + this->debugLogW(L"Setting protocol/module name to '%s'", (TCHAR*)_A2T(m_szModuleName)); +} + +void CSkypeProto::UninitNetLib() +{ + ::Netlib_CloseHandle(this->m_hNetlibUser); + this->m_hNetlibUser = NULL; +} diff --git a/plugins/!Deprecated/Skype/src/skype_own_info.cpp b/plugins/!Deprecated/Skype/src/skype_own_info.cpp new file mode 100644 index 0000000000..f56178229a --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_own_info.cpp @@ -0,0 +1,136 @@ +#include "skype.h" + +void __cdecl CSkypeProto::LoadOwnInfo(void *) +{ + /*ptrW nick( ::db_get_wsa(NULL, this->m_szModuleName, "Nick")); + if ( !nick) + { + SEString data; + this->account->GetPropFullname(data); + + if (data.length() == 0) + { + this->account->GetPropSkypename(data); + } + + nick = ::mir_utf8decodeW(data); + ::db_set_ws(NULL, this->m_szModuleName, "Nick", nick); + }*/ + + this->UpdateProfile(this->account.fetch()); +} + +INT_PTR __cdecl CSkypeProto::SetMyNickName(WPARAM wParam, LPARAM lParam) +{ + wchar_t *nick = (wParam & SMNN_UNICODE) ? ::mir_wstrdup((wchar_t *)lParam) : ::mir_a2t((char*) lParam); + + //::db_set_ws(NULL, this->m_szModuleName, "Nick", nick); + + if ( !this->IsOnline()) + return 0; + + this->account->SetStrProperty(Account::P_FULLNAME, (char *)ptrA(::mir_utf8encodeW(nick))); + + return 0; +} + +void CSkypeProto::SaveOwnInfoToServer(HWND hwndPage, int iPage) +{ + wchar_t text[2048]; + + switch (iPage) + { + // Page 0: Personal + case 0: + { + ::GetDlgItemText(hwndPage, IDC_FULLNAME, text, SIZEOF(text)); + if (this->account->SetStrProperty(Account::P_FULLNAME, (char *)ptrA(::mir_utf8encodeW(text)))) + this->setTString("Nick", text); + + ::GetDlgItemText(hwndPage, IDC_MOOD, text, SIZEOF(text)); + this->account->SetStrProperty(Account::P_MOOD_TEXT, (char *)ptrA(::mir_utf8encodeW(text))); + + ::GetDlgItemText(hwndPage, IDC_ABOUT, text, SIZEOF(text)); + this->account->SetStrProperty(Account::P_ABOUT, (char *)ptrA(::mir_utf8encodeW(text))); + + ::GetDlgItemText(hwndPage, IDC_HOMEPAGE, text, SIZEOF(text)); + this->account->SetStrProperty(Account::P_HOMEPAGE, (char *)ptrA(::mir_utf8encodeW(text))); + + this->account->SetIntProperty( + Account::P_GENDER, + ::SendMessage(::GetDlgItem(hwndPage, IDC_GENDER), CB_GETCURSEL, 0, 0)); + + char day[3], month[3], year[5], date[9]; + ::GetDlgItemTextA(hwndPage, IDC_BIRTH_DAY, day, 3); + ::GetDlgItemTextA(hwndPage, IDC_BIRTH_MONTH, month, 3); + ::GetDlgItemTextA(hwndPage, IDC_BIRTH_YEAR, year, 5); + ::mir_snprintf(date, 9, "%s%s%s", year, month, day); + int value = atoi(date); + this->account->SetIntProperty(Account::P_BIRTHDAY, value); + + int lang = ::SendMessage(GetDlgItem(hwndPage, IDC_LANGUAGE), CB_GETCURSEL, 0, 0); + if (lang != -1) { + std::wstring key = *(std::wstring *)SendMessage(GetDlgItem(hwndPage, IDC_LANGUAGE), CB_GETITEMDATA, lang, 0); + this->account->SetStrProperty( + Account::P_LANGUAGES, + (char *)ptrA(::mir_utf8encodeW(key.c_str()))); + } + } + break; + + // Page 1: Contacts + case 1: + wchar_t emails[2048]; + ::GetDlgItemText(hwndPage, IDC_EMAIL1, emails, SIZEOF(emails)); + ::GetDlgItemText(hwndPage, IDC_EMAIL2, text, SIZEOF(text)); + if (::wcslen(text) > 0) + { + ::wcscat(emails, L" "); + ::wcscat(emails, text); + } + ::GetDlgItemText(hwndPage, IDC_EMAIL3, text, SIZEOF(text)); + if (::wcslen(text) > 0) + { + ::wcscat(emails, L" "); + ::wcscat(emails, text); + } + this->account->SetStrProperty(Account::P_EMAILS, (char *)ptrA(::mir_utf8encodeW(emails))); + + ::GetDlgItemText(hwndPage, IDC_MOBPHONE, text, SIZEOF(text)); + this->account->SetStrProperty(Account::P_PHONE_MOBILE, (char *)ptrA(::mir_utf8encodeW(text))); + + ::GetDlgItemText(hwndPage, IDC_HOMEPHONE, text, SIZEOF(text)); + this->account->SetStrProperty(Account::P_PHONE_HOME, (char *)ptrA(::mir_utf8encodeW(text))); + + ::GetDlgItemText(hwndPage, IDC_OFFICEPHONE, text, SIZEOF(text)); + this->account->SetStrProperty(Account::P_PHONE_OFFICE, (char *)ptrA(::mir_utf8encodeW(text))); + + break; + + // Page 2: Home + case 2: + ::GetDlgItemText(hwndPage, IDC_CITY, text, SIZEOF(text)); + this->account->SetStrProperty(Account::P_CITY, (char *)ptrA(::mir_utf8encodeW(text))); + + ::GetDlgItemText(hwndPage, IDC_STATE, text, SIZEOF(text)); + this->account->SetStrProperty(Account::P_PROVINCE, (char *)ptrA(::mir_utf8encodeW(text))); + + int i = ::SendMessage(::GetDlgItem(hwndPage, IDC_COUNTRY), CB_GETCURSEL, 0, 0); + char *iso = (char *)::SendMessage(::GetDlgItem(hwndPage, IDC_COUNTRY), CB_GETITEMDATA, i, 0); + this->account->SetStrProperty(Account::P_COUNTRY, iso); + + HWND ctrl = ::GetDlgItem(hwndPage, IDC_TIMEZONE); + i = ::SendMessage(ctrl, CB_GETCURSEL, 0, 0); + HANDLE hTimeZone = (HANDLE)::SendMessage(ctrl, CB_GETITEMDATA, i, 0); + + SYSTEMTIME my_st, utc_ts; + tmi.getTimeZoneTime(hTimeZone, &my_st); + tmi.getTimeZoneTime(UTC_TIME_HANDLE, &utc_ts); + + uint diff_to_UTC_in_seconds = (my_st.wHour - utc_ts.wHour) * 3600 + (my_st.wMinute - utc_ts.wMinute) * 60; + uint timezone = 24*3600 + diff_to_UTC_in_seconds; + this->account->SetIntProperty(Account::P_TIMEZONE, timezone); + + break; + } +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype_profile.cpp b/plugins/!Deprecated/Skype/src/skype_profile.cpp new file mode 100644 index 0000000000..0a6686303d --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_profile.cpp @@ -0,0 +1,321 @@ +#include "skype.h" +#include + +void CSkypeProto::UpdateProfileAvatar(SEObject *obj, MCONTACT hContact) +{ + uint newTS = obj->GetUintProp(/* *::P_AVATAR_TIMESTAMP */ 182); + //if (!newTS) return; //uncomment when skypekit will be work correctly + + DWORD oldTS = this->getDword(hContact, "AvatarTS", 0); + + ptrW path( this->GetContactAvatarFilePath(hContact)); + bool isAvatarFileExists = CSkypeProto::FileExists(path); + if (newTS > oldTS || !isAvatarFileExists) + { + SEBinary data = obj->GetBinProp(/* *::P_AVATAR_IMAGE */ 37); + if (data.size() > 0) + { + FILE *fp = ::_wfopen(path, L"wb"); + if (fp) + { + ::fwrite(data.data(), sizeof(char), data.size(), fp); + ::fclose(fp); + + this->setDword(hContact, "AvatarTS", newTS); + + if (hContact) + { + PROTO_AVATAR_INFORMATIONW pai = { sizeof(pai) }; + pai.format = PA_FORMAT_JPEG; + pai.hContact = hContact; + ::wcscpy(pai.filename, path); + + this->SendBroadcast(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&pai, 0); + } + else + { + BYTE digest[16]; + ::mir_md5_hash((BYTE*)data.data(), (int)data.size(), digest); + ::db_set_blob(hContact, this->m_szModuleName, "AvatarHash", digest, 16); + + ::CallService(MS_AV_SETMYAVATART, (WPARAM)m_szModuleName, (LPARAM)path); + } + } + } + else if (isAvatarFileExists) + { + ::_wremove(path); + this->SendBroadcast(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, NULL, 0); + } + } +} + +void CSkypeProto::UpdateProfileAboutText(SEObject *obj, MCONTACT hContact) +{ + ptrW aboutText(::mir_utf8decodeW(obj->GetStrProp(/* *::P_ABOUT */ 18))); + if ( !::wcslen(aboutText)) + this->delSetting(hContact, "About"); + else + this->setTString(hContact, "About", aboutText); +} + +void CSkypeProto::UpdateProfileBirthday(SEObject *obj, MCONTACT hContact) +{ + uint data = obj->GetUintProp(/* *::P_BIRTHDAY */ 7); + if (data > 0) + { + TCHAR date[20]; + _itot_s(data, date, 10); + + INT day, month, year; + _stscanf(date, _T("%04d%02d%02d"), &year, &month, &day); + + SYSTEMTIME sToday = {0}; + GetLocalTime(&sToday); + + if (sToday.wYear > year) return; + else if(sToday.wYear == year && sToday.wMonth > month) return; + else if(sToday.wYear == year && sToday.wMonth == month && sToday.wDay >= day) return; + + this->setByte(hContact, "BirthDay", day); + this->setByte(hContact, "BirthMonth", month); + this->setWord(hContact, "BirthYear", year); + + int nAge = sToday.wYear - year; + if (sToday.wMonth < month || (sToday.wMonth == month && sToday.wDay < day)) + nAge--; + if (nAge) + this->setWord(hContact, "Age", (WORD)nAge ); + } + else + { + this->delSetting(hContact, "BirthDay"); + this->delSetting(hContact, "BirthMonth"); + this->delSetting(hContact, "BirthYear"); + this->delSetting(hContact, "Age"); + } +} + +void CSkypeProto::UpdateProfileCity(SEObject *obj, MCONTACT hContact) +{ + ptrW city(::mir_utf8decodeW(obj->GetStrProp(/* *::P_CITY */ 12))); + if ( !::wcslen(city)) + this->delSetting(hContact, "City"); + else + this->setTString(hContact, "City", city); +} + +void CSkypeProto::UpdateProfileCountry(SEObject *obj, MCONTACT hContact) +{ + char *country; + ptrA isocode(::mir_strdup(obj->GetStrProp(/* *::P_COUNTRY */ 10))); + if ( !::strlen(isocode)) + this->delSetting(hContact, "Country"); + else + { + country = (char *)CallService(MS_UTILS_GETCOUNTRYBYISOCODE, (WPARAM)isocode, 0); + this->setTString(hContact, "Country", _A2T(country)); + } +} + +void CSkypeProto::UpdateProfileEmails(SEObject *obj, MCONTACT hContact) +{ + ptrW emails(::mir_utf8decodeW(obj->GetStrProp(/* *::P_EMAILS */ 16))); + if (::wcscmp(emails, L"") == 0) + { + this->delSetting(hContact, "e-mail0"); + this->delSetting(hContact, "e-mail1"); + this->delSetting(hContact, "e-mail2"); + } + else + { + StringList emls = emails; + for (size_t i = 0; i < emls.size(); i++) + { + std::stringstream ss; + ss << "e-mail" << i; + std::string key = ss.str(); + + this->setTString(hContact, key.c_str(), emls[i]); + } + } +} + +void CSkypeProto::UpdateProfileFullName(SEObject *obj, MCONTACT hContact) +{ + ptrW fullname(::mir_utf8decodeW(obj->GetStrProp(/* *::P_FULLNAME */ 5))); + if ( !::wcslen(fullname)) + { + this->delSetting(hContact, "FirstName"); + this->delSetting(hContact, "LastName"); + } + else + { + StringList names = fullname; + + this->setTString(hContact, "FirstName", names[0]); + if (names.size() > 1) + this->setTString(hContact, "LastName", names[1]); + } +} + +void CSkypeProto::UpdateProfileGender(SEObject *obj, MCONTACT hContact) +{ + uint data = obj->GetUintProp(/* *::P_GENDER */ 8); + if (data) + this->setByte(hContact, "Gender", (BYTE)(data == 1 ? 'M' : 'F')); + else + this->delSetting(hContact, "Gender"); +} + +void CSkypeProto::UpdateProfileHomepage(SEObject *obj, MCONTACT hContact) +{ + ptrW homepage(::mir_utf8decodeW(obj->GetStrProp(/* *::P_HOMEPAGE */ 17))); + if (::wcscmp(homepage, L"") == 0) + this->delSetting(hContact, "Homepage"); + else + this->setTString(hContact, "Homepage", homepage); +} + +void CSkypeProto::UpdateProfileLanguages(SEObject *obj, MCONTACT hContact) +{ + ptrW isocodes(::mir_utf8decodeW(obj->GetStrProp(/* *::P_LANGUAGES */ 9))); + + this->delSetting(hContact, "Language1"); + this->delSetting(hContact, "Language2"); + this->delSetting(hContact, "Language3"); + + StringList langs = isocodes; + for (size_t i = 0; i < langs.size(); i++) + { + if (CSkypeProto::languages.count(langs[i])) + { + std::stringstream ss; + ss << "Language" << i + 1; + std::string key = ss.str(); + std::wstring val = CSkypeProto::languages[langs[i]]; + this->setTString(hContact, key.c_str(), val.c_str()); + } + } +} + +void CSkypeProto::UpdateProfileMobilePhone(SEObject *obj, MCONTACT hContact) +{ + ptrW phone(::mir_utf8decodeW(obj->GetStrProp(/* *::P_PHONE_MOBILE */ 15))); + if ( !::wcslen(phone)) + this->delSetting(hContact, "Cellular"); + else + this->setTString(hContact, "Cellular", phone); +} + +void CSkypeProto::UpdateProfileNick(SEObject *obj, MCONTACT hContact) +{ + ptrW nick; + if (hContact) + { + CContact *contact = (CContact *)obj; + nick = ::mir_utf8decodeW(contact->GetNick()); + } + else + nick = ::mir_utf8decodeW(obj->GetStrProp(Account::P_FULLNAME)); + + if ( !::wcslen(nick)) + this->delSetting(hContact, "Nick"); + else + this->setTString(hContact, "Nick", nick); +} + +void CSkypeProto::UpdateProfilePhone(SEObject *obj, MCONTACT hContact) +{ + ptrW phone(::mir_utf8decodeW(obj->GetStrProp(/* *::P_PHONE_MOBILE */ 13))); + if ( !::wcslen(phone)) + this->delSetting(hContact, "Phone"); + else + this->setTString(hContact, "Phone", phone); +} + +void CSkypeProto::UpdateProfileOfficePhone(SEObject *obj, MCONTACT hContact) +{ + ptrW phone(::mir_utf8decodeW(obj->GetStrProp(/* *::P_PHONE_OFFICE */ 14))); + if ( !::wcslen(phone)) + this->delSetting(hContact, "CompanyPhone"); + else + this->setTString(hContact, "CompanyPhone", phone); +} + +void CSkypeProto::UpdateProfileState(SEObject *obj, MCONTACT hContact) +{ + ptrW state(::mir_utf8decodeW(obj->GetStrProp(/* *::P_PROVINCE */ 11))); + if ( !::wcslen(state)) + this->delSetting(hContact, "State"); + else + this->setTString(hContact, "State", state); +} + +void CSkypeProto::UpdateProfileStatusMessage(SEObject *obj, MCONTACT hContact) +{ + ptrW statusMessage(::mir_utf8decodeW(obj->GetStrProp(/* *::P_MOOD_TEXT */ 26))); + if ( !::wcslen(statusMessage)) + this->delSetting(hContact, "XStatusMsg"); + else + this->setTString(hContact, "XStatusMsg", statusMessage); +} + +void CSkypeProto::UpdateProfileTimezone(SEObject *obj, MCONTACT hContact) +{ + LONG data = obj->GetUintProp(/* *::P_TIMEZONE */ 27); + if (data > 0) + { + LONG diffmin = (data - 24*3600) / 60; + wchar_t sign[2]; + if (diffmin < 0) + ::wcscpy(sign, L"-"); + else + ::wcscpy(sign, L"+"); + uint hours = ::abs((int)(diffmin / 60)); + uint mins = ::abs((int)(diffmin % 60)); + wchar_t timeshift[7]; + ::mir_sntprintf(timeshift, SIZEOF(timeshift), _T("%s%d:%02d"), sign, hours, mins); + + wchar_t *szMin = wcschr(timeshift, ':'); + int nTz = ::_wtoi(timeshift) * -2; + nTz += (nTz < 0 ? -1 : 1) * (szMin ? _ttoi( szMin + 1 ) / 30 : 0); + + this->setByte(hContact, "Timezone", (signed char)nTz); + } + else this->delSetting(hContact, "Timezone"); +} + +void CSkypeProto::UpdateProfile(SEObject *obj, MCONTACT hContact) +{ + this->debugLogW(L"Updating profile for %p", hContact); + this->UpdateProfileAvatar(obj, hContact); + + uint newTS = hContact ? obj->GetUintProp(Contact::P_PROFILE_TIMESTAMP) : obj->GetUintProp(Account::P_PROFILE_TIMESTAMP); + this->UpdateProfileAboutText(obj, hContact); + this->UpdateProfileBirthday(obj, hContact); + this->UpdateProfileCity(obj, hContact); + this->UpdateProfileCountry(obj, hContact); + this->UpdateProfileEmails(obj, hContact); + this->UpdateProfileFullName(obj, hContact); + this->UpdateProfileGender(obj, hContact); + this->UpdateProfileHomepage(obj, hContact); + this->UpdateProfileLanguages(obj, hContact); + this->UpdateProfileMobilePhone(obj, hContact); + this->UpdateProfileNick(obj, hContact); + this->UpdateProfilePhone(obj, hContact); + this->UpdateProfileOfficePhone(obj, hContact); + this->UpdateProfileState(obj, hContact); + this->UpdateProfileStatusMessage(obj, hContact); + this->UpdateProfileTimezone(obj, hContact); + + if (hContact) + { + ContactRef ref(obj->getOID()); + this->UpdateContactClient(hContact, ref); + this->UpdateContactLastEventDate(hContact, ref); + this->UpdateContactOnlineSinceTime(hContact, ref); + } + + this->setDword(hContact, "ProfileTS", newTS); +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype_proto.cpp b/plugins/!Deprecated/Skype/src/skype_proto.cpp new file mode 100644 index 0000000000..8931a48498 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_proto.cpp @@ -0,0 +1,672 @@ +#include "skype.h" +#include "skype_chat.h" + +CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName) : + PROTO(protoName, userName), + Skype(1), + skypeKitPort(8963), + chatRooms(5) +{ + this->rememberPassword = false; + + ::InitializeCriticalSection(&this->contact_search_lock); + + this->SetAllContactStatus(ID_STATUS_OFFLINE); + + DBEVENTTYPEDESCR dbEventType = { sizeof(dbEventType) }; + dbEventType.module = this->m_szModuleName; + dbEventType.flags = DETF_HISTORY | DETF_MSGWINDOW; + + dbEventType.eventType = SKYPE_DB_EVENT_TYPE_EMOTE; + dbEventType.descr = "Skype emote"; + ::CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType); + + dbEventType.eventType = SKYPE_DB_EVENT_TYPE_CONTACTS; + dbEventType.descr = "Skype contacts"; + dbEventType.eventIcon = CSkypeProto::GetSkinIconHandle("sendContacts"); + ::CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType); + + dbEventType.eventType = SKYPE_DB_EVENT_TYPE_CALL; + dbEventType.descr = "Skype call"; + dbEventType.eventIcon = CSkypeProto::GetSkinIconHandle("call"); + ::CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType); + + this->InitInstanceServiceList(); +} + +CSkypeProto::~CSkypeProto() +{ + ::DeleteCriticalSection(&this->contact_search_lock); + + ::mir_free(this->login); + if (this->password) + { + ::mir_free(this->password); + this->password = NULL; + } +} + +MCONTACT __cdecl CSkypeProto::AddToList(int flags, PROTOSEARCHRESULT* psr) +{ + CContact::Ref contact; + this->GetContact((char *)mir_ptr(::mir_utf8encodeW(psr->id)), contact); + return this->AddContact(contact); +} + +MCONTACT __cdecl CSkypeProto::AddToListByEvent(int flags, int iContact, HANDLE hDbEvent) +{ + DBEVENTINFO dbei = {0}; + dbei.cbSize = sizeof(dbei); + + /*if ((dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) != -1) + { + dbei.pBlob = (PBYTE)alloca(dbei.cbBlob); + if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei) == 0 && + !strcmp(dbei.szModule, m_szModuleName) && + (dbei.eventType == EVENTTYPE_AUTHREQUEST || dbei.eventType == EVENTTYPE_CONTACTS)) + { + char *nick = (char*)(dbei.pBlob + sizeof(DWORD) * 2); + char *firstName = nick + strlen(nick) + 1; + char *lastName = firstName + strlen(firstName) + 1; + char *skypeName = lastName + strlen(lastName) + 1; + return AddContactBySkypeName(::mir_a2u(skypeName), ::mir_a2u(nick), 0); + } + }*/ + return 0; +} + +int __cdecl CSkypeProto::Authorize(HANDLE hDbEvent) +{ + if (this->IsOnline() && hDbEvent) + { + MCONTACT hContact = this->GetContactFromAuthEvent(hDbEvent); + if (hContact == INVALID_CONTACT_ID) + return 1; + + return CSkypeProto::GrantAuth(hContact, NULL); + } + + return 1; +} + +int __cdecl CSkypeProto::AuthDeny(HANDLE hDbEvent, const TCHAR* szReason) +{ + if (this->IsOnline()) + { + MCONTACT hContact = this->GetContactFromAuthEvent(hDbEvent); + if (hContact == INVALID_CONTACT_ID) + return 1; + + return CSkypeProto::RevokeAuth(hContact, NULL); + } + + return 1; +} + +int __cdecl CSkypeProto::AuthRecv(MCONTACT hContact, PROTORECVEVENT* pre) +{ + DWORD flags = 0; + + if (pre->flags & PREF_CREATEREAD) + flags |= DBEF_READ; + + if (pre->flags & PREF_UTF) + flags |= DBEF_UTF; + + this->AddDBEvent( + hContact, + EVENTTYPE_AUTHREQUEST, + pre->timestamp, + flags, + pre->lParam, + (PBYTE)pre->szMessage); + + return 0; +} + +int __cdecl CSkypeProto::AuthRequest(MCONTACT hContact, const TCHAR* szMessage) +{ + if (this->IsOnline() && hContact) + { + CContact::Ref contact; + SEString sid(_T2A(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID))); + if (this->GetContact(sid, contact)) + { + contact->SetBuddyStatus(Contact::AUTHORIZED_BY_ME); + contact->SendAuthRequest(::mir_utf8encodeW(szMessage)); + } + + return 0; + } + + return 1; +} + +HANDLE __cdecl CSkypeProto::FileAllow(MCONTACT hContact, HANDLE hTransfer, const TCHAR* szPath ) +{ + uint oid = (uint)hTransfer; + + this->debugLogW(L"Incoming file transfer is accepted"); + + bool success; + wchar_t fullPath[MAX_PATH] = {0}; + + SEString data; + MessageRef msgRef(oid); + TransferRefs transfers; + msgRef->GetTransfers(transfers); + for (uint i = 0; i < transfers.size(); i++) + { + auto transfer = transfers[i]; + transfer->GetPropFilename(data); + ptrW name(::mir_utf8decodeW(data)); + ::mir_sntprintf(fullPath, MAX_PATH, L"%s%s", szPath, name); + + auto fOid = transfer->getOID(); + FileTransferParam ftp = this->transferts[oid]; + + //PROTOFILETRANSFERSTATUS pfts = { sizeof(pfts) }; + //pfts.hContact = hContact; + //pfts.flags = PFTS_UNICODE | PFTS_RECEIVING; + //pfts.ptszFiles = ftp.pfts.ptszFiles; + //pfts.totalFiles = ftp.pfts.totalFiles; + //pfts.currentFileNumber = i; + //pfts.totalBytes = ftp.files[fOid].size; + //pfts.totalProgress = ftp.files[fOid].transfered; + //pfts.tszWorkingDir = mir_wstrdup(szPath); + //pfts.currentFileNumber = 0; + //pfts.tszCurrentFile = mir_wstrdup(fullPath); + ////pfts.tszCurrentFile = ::mir_utf8decodeW(data); + //pfts.currentFileSize = ftp.files[fOid].size; + //pfts.currentFileProgress = ftp.files[fOid].transfered; + + //if ( !ProtoBroadcastAck(hContact, ACKTYPE_FILE, ACKRESULT_FILERESUME, (HANDLE)oid, (LPARAM)&pfts)) + if ( !transfer->Accept((char *)ptrA(::mir_utf8encodeW(fullPath)), success) || !success) + { + this->debugLogW(L"Cannot accept file transfer"); + this->transferList.remove_val(transfer); + } + } + + return hTransfer; +} + +int __cdecl CSkypeProto::FileCancel(MCONTACT hContact, HANDLE hTransfer ) +{ + uint oid = (uint)hTransfer; + + MessageRef msgRef(oid); + TransferRefs transfers; + Transfer::STATUS transferStatus; + msgRef->GetTransfers(transfers); + for (uint i = 0; i < transfers.size(); i++) + { + auto transfer = transfers[i]; + transfer->GetPropStatus(transferStatus); + if (transferStatus <= Transfer::CANCELLED && this->transferList.contains(transfer)) + { + if ( !transfer->Cancel()) + this->debugLogW(L"Incoming file transfer is cancelled"); + this->transferList.remove_val(transfer); + } + } + this->transferts.erase(this->transferts.find(oid)); + + return 1; +} + +int __cdecl CSkypeProto::FileDeny(MCONTACT hContact, HANDLE hTransfer, const TCHAR* szReason ) +{ + uint oid = (uint)hTransfer; + + MessageRef msgRef(oid); + TransferRefs transfers; + Transfer::STATUS transferStatus; + msgRef->GetTransfers(transfers); + for (uint i = 0; i < transfers.size(); i++) + { + auto transfer = transfers[i]; + transfer->GetPropStatus(transferStatus); + if (transferStatus <= Transfer::CANCELLED && this->transferList.contains(transfer)) + { + if ( !transfer->Cancel()) + this->debugLogW(L"Incoming file transfer is denied"); + this->transferList.remove_val(transfer); + } + } + this->transferts.erase(this->transferts.find(oid)); + + return 1; +} + +int __cdecl CSkypeProto::FileResume( HANDLE hTransfer, int* action, const TCHAR** szFilename ) +{ + if ( !this->IsOnline()) + return 1; + + uint oid = (uint)hTransfer; + + //auto fOid = transfers[i]->getOID(); + FileTransferParam ftp = this->transferts[oid]; + + MessageRef msgRef(oid); + TransferRefs transfers; + msgRef->GetTransfers(transfers); + for (uint i = 0; i < transfers.size(); i++){} + + switch (*action) + { + case FILERESUME_SKIP: + /*if (ft->p2p_appID != 0) + p2p_sendStatus(ft, 603); + else + msnftp_sendAcceptReject (ft, false);*/ + break; + + case FILERESUME_RESUME: + //replaceStrT(ft->std.tszCurrentFile, *szFilename); + break; + + case FILERESUME_RENAME: + //replaceStrT(ft->std.tszCurrentFile, *szFilename); + break; + + default: + /*bool fcrt = ft->create() != -1; + if (ft->p2p_appID != 0) + { + if (fcrt) + p2p_sendFeedStart(ft); + + p2p_sendStatus(ft, fcrt ? 200 : 603); + } + else + msnftp_sendAcceptReject (ft, fcrt);*/ + + //ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, ft, 0); + break; + } + + return 0; +} + +DWORD_PTR __cdecl CSkypeProto:: GetCaps(int type, MCONTACT hContact) +{ + switch(type) + { + case PFLAGNUM_1: + return PF1_IM | PF1_FILE | PF1_BASICSEARCH | PF1_ADDSEARCHRES | PF1_SEARCHBYEMAIL | PF1_SEARCHBYNAME | + PF1_AUTHREQ | PF1_CHAT | PF1_SERVERCLIST | PF1_CONTACT/* | PF1_ADDSEARCHRES*/; + case PFLAGNUM_2: + case PFLAGNUM_3: + return PF2_ONLINE | PF2_SHORTAWAY | PF2_HEAVYDND | PF2_INVISIBLE | PF2_ONTHEPHONE; + case PFLAGNUM_4: + return PF4_FORCEAUTH | PF4_FORCEADDED | PF4_SUPPORTTYPING | PF4_AVATARS | + /*PF4_OFFLINEFILES | */PF4_IMSENDUTF | PF4_IMSENDOFFLINE | PF4_NOAUTHDENYREASON; + case PFLAGNUM_5: + return PF2_ONTHEPHONE; + case PFLAG_UNIQUEIDTEXT: + return (DWORD_PTR)::Translate("Skype name"); + case PFLAG_MAXCONTACTSPERPACKET: + return 1024; + case PFLAG_UNIQUEIDSETTING: + return (DWORD_PTR)SKYPE_SETTINGS_SID; + default: + return 0; + } +} + +int __cdecl CSkypeProto::GetInfo(MCONTACT hContact, int infoType ) { return 0; } + +HANDLE __cdecl CSkypeProto::SearchBasic(const TCHAR* id) +{ + if ( !this->IsOnline()) + return 0; + + this->ForkThread(&CSkypeProto::SearchBySidAsync, ::mir_tstrdup(id)); + + return (HANDLE)SKYPE_SEARCH_BYSID; +} + +HANDLE __cdecl CSkypeProto::SearchByEmail(const TCHAR* email) +{ + if ( !this->IsOnline()) + return 0; + + this->ForkThread(&CSkypeProto::SearchByEmailAsync, ::mir_tstrdup(email)); + + return (HANDLE)SKYPE_SEARCH_BYEMAIL; +} + +HANDLE __cdecl CSkypeProto::SearchByName(const TCHAR* nick, const TCHAR* firstName, const TCHAR* lastName) +{ + PROTOSEARCHRESULT *psr = new PROTOSEARCHRESULT(); + psr->cbSize = sizeof(psr); + psr->flags = PSR_TCHAR; + psr->nick = ::mir_wstrdup(nick); + psr->firstName = ::mir_wstrdup(firstName); + psr->lastName = ::mir_wstrdup(lastName); + + this->ForkThread(&CSkypeProto::SearchByNamesAsync, psr); + + return (HANDLE)SKYPE_SEARCH_BYNAMES; +} + +HWND __cdecl CSkypeProto::SearchAdvanced( HWND owner ) { return 0; } + +HWND __cdecl CSkypeProto::CreateExtendedSearchUI( HWND owner ){ return 0; } + +int __cdecl CSkypeProto::RecvContacts(MCONTACT hContact, PROTORECVEVENT* pre) +{ + this->debugLogW(L"Incoming contacts"); + ::db_unset(hContact, "CList", "Hidden"); + + return (INT_PTR)this->AddDBEvent( + hContact, + EVENTTYPE_CONTACTS, + pre->timestamp, + DBEF_UTF | ((pre->flags & PREF_CREATEREAD) ? DBEF_READ : 0), + pre->lParam, + (PBYTE)pre->szMessage); +} + +int __cdecl CSkypeProto::RecvFile(MCONTACT hContact, PROTORECVFILET* pre) +{ + this->debugLogW(L"Incoming file transfer"); + ::db_unset(hContact, "CList", "Hidden"); + return ::Proto_RecvFile(hContact, pre); +} + +int __cdecl CSkypeProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT* pre) +{ + this->debugLogW(L"Incoming message"); + ::db_unset(hContact, "CList", "Hidden"); + + ReadMessageParam *param = (ReadMessageParam*)pre->lParam; + + char *message = (char *)pre->szMessage; + size_t msgLen = ::strlen(message) + 1; + + message = (char *)::mir_realloc(message, msgLen + param->guid.size()); + ::memcpy((char *)&message[msgLen], param->guid.data(), param->guid.size()); + + return (INT_PTR)this->AddDBEvent( + hContact, + param->msgType == CMessage::POSTED_TEXT ? EVENTTYPE_MESSAGE : SKYPE_DB_EVENT_TYPE_EMOTE, + pre->timestamp, + DBEF_UTF | ((pre->flags & PREF_CREATEREAD) ? DBEF_READ : 0), + DWORD(msgLen + param->guid.size()), + (PBYTE)message); +} + +int __cdecl CSkypeProto::RecvUrl(MCONTACT hContact, PROTORECVEVENT *) { return 0; } + +int __cdecl CSkypeProto::SendContacts(MCONTACT hContact, int flags, int nContacts, MCONTACT *hContactsList) +{ + if (this->IsOnline() && hContact && hContactsList) + { + this->debugLogW(L"Outcoming contacts"); + + ConversationRef conversation; + if ( !this->isChatRoom(hContact)) + { + SEStringList targets; + targets.append((char *)_T2A(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID))); + + this->GetConversationByParticipants(targets, conversation); + } + else + { + this->GetConversationByIdentity((char *)_T2A(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID)), conversation); + } + if ( !conversation) + return 0; + + ContactRefs contacts; + for (int i = 0; i < nContacts; i++) + { + CContact::Ref contact; + + ptrW csid(::db_get_wsa(hContactsList[i], this->m_szModuleName, SKYPE_SETTINGS_SID)); + this->GetContact((char *)ptrA(::mir_utf8encodeW(csid)), contact); + contacts.append(contact); + } + + time_t timestamp = time(NULL); + + if ( !conversation->PostContacts(contacts)) + return 0; + + // todo: bad hack + CMessage::Refs msgs; + this->GetMessageListByType(Message::POSTED_CONTACTS, true, msgs, timestamp); + + if (msgs.size() == 0) + return 0; + + CMessage::Ref lastMsg = msgs[msgs.size() - 1]; + + return lastMsg->getOID(); + } + + return 0; +} + +HANDLE __cdecl CSkypeProto::SendFile(MCONTACT hContact, const TCHAR *szDescription, TCHAR **ppszFiles) +{ + if (this->IsOnline() && hContact && ppszFiles) + { + this->debugLogW(L"Outcoming file transfer"); + + ConversationRef conversation; + if ( !this->isChatRoom(hContact)) + { + SEStringList targets; + targets.append((char *)_T2A(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID))); + + this->GetConversationByParticipants(targets, conversation); + } + else + { + this->GetConversationByIdentity((char *)_T2A(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID)), conversation); + } + if ( !conversation) + return 0; + + FileTransferParam ftp; + ftp.pfts.flags = PFTS_SENDING | PFTS_UNICODE; + ftp.pfts.hContact = hContact; + for (ftp.pfts.totalFiles = 0; ppszFiles[ftp.pfts.totalFiles]; ftp.pfts.totalFiles++); + ftp.pfts.ptszFiles = new wchar_t*[ftp.pfts.totalFiles + 1]; + + wchar_t *wd = new wchar_t[wcslen(ppszFiles[0]) + 1]; + wcscpy(wd, ppszFiles[0]); + PathRemoveFileSpec(wd); + ftp.pfts.tszWorkingDir = wd; + + SEFilenameList fileList; + for (int i = 0; ppszFiles[i]; i++) + { + ftp.pfts.ptszFiles[i] = ::mir_wstrdup(ppszFiles[i]); + fileList.append((char *)ptrA(::mir_utf8encodeW(ppszFiles[i]))); + } + + auto error = TRANSFER_OPEN_SUCCESS; + SEFilename errFile; + MessageRef msgRef; + if ( !conversation->PostFiles(fileList, " ", error, errFile, msgRef) || error) + return 0; + + SEString data; + TransferRefs transfers; + if (msgRef->GetTransfers(transfers)) + { + for (uint i = 0; i < transfers.size(); i++) + { + transfers[i].fetch(); + this->transferList.append(transfers[i]); + + transfers[i]->GetPropFilesize(data); + Sid::uint64 size = data.toUInt64(); + + ftp.files.insert(std::make_pair(transfers[i]->getOID(), FileParam(size))); + ftp.pfts.totalBytes += size; + } + } + + auto oid = msgRef->getOID(); + this->transferts.insert(std::make_pair(oid, ftp)); + + return (HANDLE)oid; + } + + return 0; +} + +int __cdecl CSkypeProto::SendMsg(MCONTACT hContact, int flags, const char *msg) +{ + this->debugLogW(L"Outcoming message"); + SEStringList targets; + targets.append((char *)_T2A(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID))); + + CConversation::Ref conversation; + this->GetConversationByParticipants(targets, conversation); + + if (conversation) + { + CMessage::Ref message; + if (!conversation->PostText(msg, message)) + return 0; + + return message->getOID(); + } + + return 0; +} + +int __cdecl CSkypeProto::SendUrl(MCONTACT hContact, int flags, const char *url) { return 0; } + +int __cdecl CSkypeProto::SetApparentMode(MCONTACT hContact, int mode) { return 0; } + +int CSkypeProto::SetStatus(int new_status) +{ + switch (new_status) + { + case ID_STATUS_OCCUPIED: + new_status = ID_STATUS_DND; + break; + case ID_STATUS_FREECHAT: + new_status = ID_STATUS_ONLINE; + break; + case ID_STATUS_ONTHEPHONE: + case ID_STATUS_OUTTOLUNCH: + case ID_STATUS_NA: + new_status = ID_STATUS_AWAY; + break; + } + + if (new_status == this->m_iDesiredStatus) + return 0; + + int old_status = this->m_iStatus; + this->m_iDesiredStatus = new_status; + + if (new_status == ID_STATUS_OFFLINE) + { + this->LogOut(); + this->m_iStatus = this->m_iDesiredStatus = ID_STATUS_OFFLINE; + + this->SendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus); + + if ( !::Miranda_Terminated()) + { + this->SetAllContactStatus(ID_STATUS_OFFLINE); + this->CloseAllChatSessions(); + } + + return 0; + } + else + { + if (old_status == ID_STATUS_OFFLINE && !this->IsOnline()) + { + this->m_iStatus = ID_STATUS_CONNECTING; + if ( !this->LogIn()) + return 0; + } + else + { + if ( this->account->IsOnline()) + { + SetServerStatus(new_status); + return 0; + } + + this->SendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus); + return 0; + } + } + + this->SendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus); + return 0; +} + +HANDLE __cdecl CSkypeProto::GetAwayMsg(MCONTACT hContact) { return 0; } +int __cdecl CSkypeProto::RecvAwayMsg(MCONTACT hContact, int mode, PROTORECVEVENT *evt) { return 0; } +int __cdecl CSkypeProto::SetAwayMsg(int m_iStatus, const TCHAR *msg) { return 0; } + +int __cdecl CSkypeProto::UserIsTyping(MCONTACT hContact, int type) +{ + if (hContact && this->IsOnline() && this->m_iStatus != ID_STATUS_INVISIBLE) + { + ptrW sid(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID)); + if (sid != NULL && ::wcsicmp(sid, this->login) != 0) + { + SEStringList targets; + targets.append((char *)ptrA(::mir_utf8encodeW(sid))); + + CConversation::Ref conversation; + this->GetConversationByParticipants(targets, conversation); + + if (conversation) + { + switch (type) + { + case PROTOTYPE_SELFTYPING_ON: + conversation->SetMyTextStatusTo(Participant::WRITING); + return 0; + + case PROTOTYPE_SELFTYPING_OFF: + conversation->SetMyTextStatusTo(Participant::READING); //todo: mb TEXT_UNKNOWN? + return 0; + } + } + } + } + + return 1; +} + +int __cdecl CSkypeProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam) +{ + switch (eventType) + { + case EV_PROTO_ONLOAD: + return this->OnProtoModulesLoaded(wParam, lParam); + + case EV_PROTO_ONEXIT: + return this->OnPreShutdown(wParam, lParam); + + case EV_PROTO_ONOPTIONS: + return this->OnOptionsInit(wParam,lParam); + + case EV_PROTO_ONCONTACTDELETED: + return this->OnContactDeleted(wParam, lParam); + + case EV_PROTO_ONMENU: + this->OnInitStatusMenu(); + break; + } + + return 1; +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype_proto.h b/plugins/!Deprecated/Skype/src/skype_proto.h new file mode 100644 index 0000000000..5f6bb13e2d --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_proto.h @@ -0,0 +1,560 @@ +#pragma once + +struct _tag_iconList +{ + wchar_t* Description; + char* Name; + int IconId; + HANDLE Handle; +}; + +struct ReadMessageParam +{ + SEBinary& guid; + CMessage::TYPE msgType; +}; + +struct ContactParam +{ + ContactRef contact; + CSkypeProto *ppro; + + ContactParam(const ContactRef &contact, CSkypeProto *ppro) : contact(contact), ppro(ppro) + { + } +}; + +struct BlockParam +{ + MCONTACT hContact; + CSkypeProto *ppro; + bool remove; + bool abuse; + + BlockParam(MCONTACT hContact, CSkypeProto *ppro) : ppro(ppro) + { + this->hContact = hContact; + } +}; + +struct ChatRoomParam +{ + wchar_t *id; + StringList invitedContacts; + CSkypeProto *ppro; + + wchar_t topic[256]; + wchar_t guidline[256]; + + bool enableJoining; + int joinRank; + + bool passwordProtection; + wchar_t password[32]; + wchar_t confirmation[32]; + wchar_t hint[32]; + + ChatRoomParam(CSkypeProto *ppro) + : ppro(ppro) + { + this->id = NULL; + this->topic[0] = 0; + this->guidline[0] = 0; + this->password[0] = 0; + this->confirmation[0] = 0; + this->hint[0] = 0; + this->enableJoining = true; + this->joinRank = Participant::WRITER; + this->passwordProtection = false; + } + + ChatRoomParam(const wchar_t *id, const StringList &contacts, CSkypeProto *ppro) + : id(::mir_wstrdup(id)), invitedContacts(contacts), ppro(ppro) + { + this->topic[0] = 0; + this->guidline[0] = 0; + this->password[0] = 0; + this->confirmation[0] = 0; + this->hint[0] = 0; + this->enableJoining = true; + this->joinRank = Participant::WRITER; + this->passwordProtection = false; + } + + ~ChatRoomParam() + { ::mir_free(id); } +}; + +struct PasswordRequestBoxParam +{ + wchar_t *login; + char *password; + bool rememberPassword; + bool showRememberPasswordBox; + + PasswordRequestBoxParam(const wchar_t *login, bool showRememberPasswordBox = true, bool rememberPassword = false) : + login(::mir_wstrdup(login)), + password(NULL), + rememberPassword(rememberPassword), + showRememberPasswordBox(showRememberPasswordBox) { } + + ~PasswordRequestBoxParam() + { + ::mir_free(login); + ::mir_free(password); + } +}; + +struct PasswordChangeBoxParam +{ + char *password; + char *password2; + + PasswordChangeBoxParam() { } + + ~PasswordChangeBoxParam() + { + ::mir_free(password); + ::mir_free(password2); + } +}; + +struct FileParam +{ + bool isCanceled; + bool isCompleted; + + unsigned __int64 size; + unsigned __int64 transfered; + + FileParam() { } + FileParam(unsigned __int64 size) + { + this->size = size; + this->transfered = 0; + this->isCanceled = this->isCompleted = false; + } +}; + +struct FileTransferParam +{ + //CTransfer::Refs transfers; + PROTOFILETRANSFERSTATUS pfts; + std::map files; + + FileTransferParam() + { + this->pfts.cbSize = sizeof(this->pfts); + this->pfts.flags = 0; + this->pfts.currentFileNumber = 0; + this->pfts.currentFileProgress = 0; + this->pfts.currentFileSize = 0; + this->pfts.currentFileTime = 0; + this->pfts.totalBytes = 0; + this->pfts.totalFiles = 0; + this->pfts.totalProgress = 0; + this->pfts.tszWorkingDir = NULL; + this->pfts.wszCurrentFile = NULL; + + //Sid::fetch(this->transfers); + } +}; + +class ChatMember; +class ChatRoom; + +struct CSkypeProto : public PROTO, private Skype +{ + friend class ChatRoom; + friend class CAccount; + friend class CContact; + friend class CConversation; + friend class CContactGroup; + friend class CContactSearch; + friend class CTransfer; + +public: + // PROTO_INTERFACE + CSkypeProto(const char *protoName, const wchar_t *userName); + ~CSkypeProto(); + + // PROTO_INTERFACE + virtual MCONTACT __cdecl AddToList( int flags, PROTOSEARCHRESULT* psr ); + virtual MCONTACT __cdecl AddToListByEvent( int flags, int iContact, HANDLE hDbEvent ); + + virtual int __cdecl Authorize( HANDLE hDbEvent ); + virtual int __cdecl AuthDeny( HANDLE hDbEvent, const TCHAR* szReason ); + virtual int __cdecl AuthRecv(MCONTACT hContact, PROTORECVEVENT* ); + virtual int __cdecl AuthRequest(MCONTACT hContact, const TCHAR* szMessage ); + + virtual HANDLE __cdecl FileAllow(MCONTACT hContact, HANDLE hTransfer, const TCHAR* szPath ); + virtual int __cdecl FileCancel(MCONTACT hContact, HANDLE hTransfer ); + virtual int __cdecl FileDeny(MCONTACT hContact, HANDLE hTransfer, const TCHAR* szReason ); + virtual int __cdecl FileResume( HANDLE hTransfer, int* action, const TCHAR** szFilename ); + + virtual DWORD_PTR __cdecl GetCaps( int type, MCONTACT hContact = NULL ); + virtual int __cdecl GetInfo(MCONTACT hContact, int infoType ); + + virtual HANDLE __cdecl SearchBasic( const TCHAR* id ); + virtual HANDLE __cdecl SearchByEmail( const TCHAR* email ); + virtual HANDLE __cdecl SearchByName( const TCHAR* nick, const TCHAR* firstName, const TCHAR* lastName ); + virtual HWND __cdecl SearchAdvanced( HWND owner ); + virtual HWND __cdecl CreateExtendedSearchUI( HWND owner ); + + virtual int __cdecl RecvContacts(MCONTACT hContact, PROTORECVEVENT* ); + virtual int __cdecl RecvFile(MCONTACT hContact, PROTORECVFILET* ); + virtual int __cdecl RecvMsg(MCONTACT hContact, PROTORECVEVENT* ); + virtual int __cdecl RecvUrl(MCONTACT hContact, PROTORECVEVENT* ); + + virtual int __cdecl SendContacts(MCONTACT hContact, int flags, int nContacts, MCONTACT *hContactsList); + virtual HANDLE __cdecl SendFile(MCONTACT hContact, const TCHAR* szDescription, TCHAR** ppszFiles ); + virtual int __cdecl SendMsg(MCONTACT hContact, int flags, const char* msg ); + virtual int __cdecl SendUrl(MCONTACT hContact, int flags, const char* url ); + + virtual int __cdecl SetApparentMode(MCONTACT hContact, int mode ); + virtual int __cdecl SetStatus( int iNewStatus ); + + virtual HANDLE __cdecl GetAwayMsg(MCONTACT hContact ); + virtual int __cdecl RecvAwayMsg(MCONTACT hContact, int mode, PROTORECVEVENT* evt ); + virtual int __cdecl SetAwayMsg( int m_iStatus, const TCHAR* msg ); + + virtual int __cdecl UserIsTyping(MCONTACT hContact, int type ); + + virtual int __cdecl OnEvent( PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam ); + + // instances + static CSkypeProto* InitSkypeProto(const char* protoName, const wchar_t* userName); + static int UninitSkypeProto(CSkypeProto* ppro); + + static CSkypeProto* GetContactInstance(MCONTACT hContact); + static void UninitInstances(); + + // icons + static void InitIcons(); + static void UninitIcons(); + + // menus + void OnInitStatusMenu(); + static void InitMenus(); + static void UninitMenus(); + + // services + static void InitServiceList(); + + // hooks + static void InitHookList(); + + // languages + static void InitLanguages(); + + static INT_PTR __cdecl ParseSkypeUri(WPARAM wParam, LPARAM lParam); + +private: + // Skype + CAccount *newAccount(int oid); + CContactGroup *newContactGroup(int oid); + CConversation *newConversation(int oid); + CContactSearch *newContactSearch(int oid); + CParticipant *newParticipant(int oid); + CContact *newContact(int oid); + CMessage *newMessage(int oid); + CTransfer *newTransfer(int oid); + + void OnMessage( + const MessageRef & message, + const bool & changesInboxTimestamp, + const MessageRef & supersedesHistoryMessage, + const ConversationRef & conversation); + + void OnConversationListChange( + const ConversationRef& conversation, + const Conversation::LIST_TYPE& type, + const bool& added); + + int skypeKitPort; + PROCESS_INFORMATION skypeKitProcessInfo; + +protected: + CAccount::Ref account; + CContact::Refs contactList; + CTransfer::Refs transferList; + + CContactGroup::Ref commonList; + CContactGroup::Ref authWaitList; + + CRITICAL_SECTION contact_search_lock; + + bool IsOnline(); + + BYTE NeedUpdate; + + // account + static wchar_t *LogoutReasons[]; + static wchar_t *PasswordChangeReasons[]; + + wchar_t *login; + char *password; + bool rememberPassword; + + bool RequestPassword(PasswordRequestBoxParam ¶m); + bool ChangePassword(PasswordChangeBoxParam ¶m); + + bool PrepareLogin(); + bool PreparePassword(); + + void InitProxy(); + void SetAccountSettings(); + + void SetServerStatus(int iStatus); + + bool LogIn(); + void LogOut(); + + void OnLoggedIn(); + void OnCblUpdated(); + void OnLoggedOut(CAccount::LOGOUTREASON reason); + + void OnAccountChanged(int prop); + + INT_PTR __cdecl SetMyNickName(WPARAM, LPARAM); + + // avatars + bool IsAvatarChanged(const SEBinary &avatar, MCONTACT hContact = NULL); + + wchar_t* GetContactAvatarFilePath(MCONTACT hContact); + + INT_PTR __cdecl GetAvatarInfo(WPARAM, LPARAM); + INT_PTR __cdecl GetAvatarCaps(WPARAM, LPARAM); + INT_PTR __cdecl GetMyAvatar(WPARAM, LPARAM); + INT_PTR __cdecl SetMyAvatar(WPARAM, LPARAM); + + SEBinary GetAvatarBinary(wchar_t *path); + + // messages + void OnMessageEvent(const ConversationRef &conversation, const MessageRef &message); + void OnMessageSent(const ConversationRef &conversation, const MessageRef &message); + void OnMessageReceived(const ConversationRef &conversation, const MessageRef &message); + + void SyncMessageHystory(const ConversationRef &conversation, const time_t timestamp); + void SyncHistoryCommand(MCONTACT hContact, time_t timestamp); + int __cdecl SyncLastDayHistoryCommand(WPARAM wParam, LPARAM lParam); + int __cdecl SyncLastWeekHistoryCommand(WPARAM wParam, LPARAM lParam); + int __cdecl SyncLastMonthHistoryCommand(WPARAM wParam, LPARAM lParam); + int __cdecl SyncLast3MonthHistoryCommand(WPARAM wParam, LPARAM lParam); + int __cdecl SyncLastYearHistoryCommand(WPARAM wParam, LPARAM lParam); + int __cdecl SyncAllTimeHistoryCommand(WPARAM wParam, LPARAM lParam); + + // contacts + void OnContactsEvent(const ConversationRef &conversation, const MessageRef &message); + void OnContactsSent(const ConversationRef &conversation, const MessageRef &message); + void OnContactsReceived(const ConversationRef &conversation, const MessageRef &message); + + // transfer + static wchar_t *TransferFailureReasons[]; + + std::map transferts; + + void OnFileEvent(const ConversationRef &conversation, const MessageRef &message); + void OnTransferChanged(const TransferRef &transfer, int prop); + + // chat + void InitChatModule(); + INT_PTR __cdecl SkypeGCGetToolTipText(WPARAM wParam, LPARAM lParam); + + void UpdateChatUserStatus(const ContactRef &contact); + void UpdateChatUserNick(const ContactRef &contact); + + void ChatValidateContact(MCONTACT hItem, HWND hwndList, const StringList &contacts); + void ChatPrepare(MCONTACT hItem, HWND hwndList, const StringList &contacts); + + void GetInvitedContacts(MCONTACT hItem, HWND hwndList, StringList &invitedContacts); + + void ChatRoomParseUriComands(const wchar_t *commands); + + void ChatRoomInvite(MCONTACT hContact); + + void CloseAllChatSessions(); + + ChatRoom *FindChatRoom(const wchar_t *cid); + + INT_PTR __cdecl CreateChatRoomCommand(WPARAM, LPARAM); + INT_PTR __cdecl OnJoinChat(WPARAM wParam, LPARAM); + INT_PTR __cdecl OnLeaveChat(WPARAM wParam, LPARAM); + + int __cdecl OnGCEventHook(WPARAM, LPARAM lParam); + int __cdecl OnGCMenuHook(WPARAM, LPARAM lParam); + + void OnChatEvent(const ConversationRef &conversation, const MessageRef &message); + + OBJLIST chatRooms; + + // contacts + void UpdateContactAuthState(MCONTACT hContact, const ContactRef &contact); + void UpdateContactStatus(MCONTACT hContact, const ContactRef &contact); + void UpdateContactClient(MCONTACT hContact, const ContactRef &contact); + void UpdateContactOnlineSinceTime(MCONTACT hContact, const ContactRef &contact); + void UpdateContactLastEventDate(MCONTACT hContact, const ContactRef &contact); + + void OnSearchCompleted(HANDLE hSearch); + void OnContactFinded(CContact::Ref contact, HANDLE hSearch); + + void OnContactChanged(const ContactRef &contact, int prop); + void OnContactListChanged(const ContactRef &contact); + + bool IsProtoContact(MCONTACT hContact); + MCONTACT GetContactBySid(const wchar_t* sid); + MCONTACT GetContactFromAuthEvent(HANDLE hEvent); + MCONTACT AddContact(CContact::Ref contact, bool isTemporary = false); + + bool IsContactOnline(MCONTACT hContact); + void SetAllContactStatus(int status); + + void __cdecl LoadContactList(void*); + void __cdecl LoadChatList(void*); + void __cdecl LoadAuthWaitList(void*); + + void __cdecl SearchBySidAsync(void*); + void __cdecl SearchByNamesAsync(void*); + void __cdecl SearchByEmailAsync(void*); + + // profile + void UpdateProfileAvatar(SEObject *obj, MCONTACT hContact = NULL); + void UpdateProfileAboutText(SEObject *obj, MCONTACT hContact = NULL); + void UpdateProfileBirthday(SEObject *obj, MCONTACT hContact = NULL); + void UpdateProfileCity(SEObject *obj, MCONTACT hContact = NULL); + void UpdateProfileCountry(SEObject *obj, MCONTACT hContact = NULL); + void UpdateProfileEmails(SEObject *obj, MCONTACT hContact = NULL); + void UpdateProfileFullName(SEObject *obj, MCONTACT hContact = NULL); + void UpdateProfileGender(SEObject *obj, MCONTACT hContact = NULL); + void UpdateProfileHomepage(SEObject *obj, MCONTACT hContact = NULL); + void UpdateProfileLanguages(SEObject *obj, MCONTACT hContact = NULL); + void UpdateProfileMobilePhone(SEObject *obj, MCONTACT hContact = NULL); + void UpdateProfileNick(SEObject *obj, MCONTACT hContact = NULL); + void UpdateProfilePhone(SEObject *obj, MCONTACT hContact = NULL); + void UpdateProfileOfficePhone(SEObject *obj, MCONTACT hContact = NULL); + void UpdateProfileState(SEObject *obj, MCONTACT hContact = NULL); + void UpdateProfileStatusMessage(SEObject *obj, MCONTACT hContact = NULL); + void UpdateProfileTimezone(SEObject *obj, MCONTACT hContact = NULL); + + void UpdateProfile(SEObject *obj, MCONTACT hContact = NULL); + + void __cdecl LoadOwnInfo(void*); + + void SaveOwnInfoToServer(HWND hwndPage, int iPage); + + // utils + static wchar_t* ValidationReasons[]; + + static int SkypeToMirandaLoginError(CAccount::LOGOUTREASON logoutReason); + + static char *RemoveHtml(const char *data); + + static int SkypeToMirandaStatus(CContact::AVAILABILITY availability); + static CContact::AVAILABILITY MirandaToSkypeStatus(int status); + + static bool FileExists(wchar_t *path); + + static void ShowNotification(const wchar_t *message, int flags = 0, MCONTACT hContact = NULL); + static void ShowNotification(const wchar_t *caption, const wchar_t *message, int flags = 0, MCONTACT hContact = NULL); + + static void CopyToClipboard(const wchar_t *text); + + static void ReplaceSpecialChars(wchar_t *text, wchar_t replaceWith = L'_'); + + // languages + static std::map languages; + + // instances + static LIST instanceList; + static int CompareProtos(const CSkypeProto *p1, const CSkypeProto *p2); + + // + int SendBroadcast(int type, int result, HANDLE hProcess, LPARAM lParam); + int SendBroadcast(MCONTACT hContact, int type, int result, HANDLE hProcess, LPARAM lParam); + + HANDLE CreateEvent(const char* szService); + + // netlib + void InitNetLib(); + void UninitNetLib(); + + // services + void InitInstanceServiceList(); + + // hooks + void InitInstanceHookList(); + + // icons + static _tag_iconList IconList[]; + static HANDLE GetIconHandle(const char *name); + static HANDLE GetSkinIconHandle(const char *name); + + // menus + HGENMENU m_hMenuRoot; + static HANDLE hChooserMenu; + static HGENMENU contactMenuItems[CMI_MAX]; + + virtual int __cdecl RequestAuth(WPARAM, LPARAM); + virtual int __cdecl GrantAuth(WPARAM, LPARAM); + virtual int __cdecl RevokeAuth(WPARAM, LPARAM); + + static INT_PTR MenuChooseService(WPARAM wParam, LPARAM lParam); + + static int PrebuildContactMenu(WPARAM wParam, LPARAM lParam); + int OnPrebuildContactMenu(WPARAM wParam, LPARAM); + + // blocked list + int __cdecl BlockCommand(WPARAM, LPARAM); + INT_PTR __cdecl OpenBlockedListCommand(WPARAM, LPARAM); + + static INT_PTR CALLBACK SkypeBlockProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); + static INT_PTR CALLBACK SkypeBlockedOptionsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); + static LRESULT CALLBACK SkypeBlockedOptionsSubProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + + // database + bool IsMessageInDB(MCONTACT hContact, DWORD timestamp, SEBinary &guid, int flag = 0); + + HANDLE AddDBEvent(MCONTACT hContact, WORD type, DWORD time, DWORD flags = 0, DWORD cbBlob = 0, PBYTE pBlob = 0); + void RaiseMessageSentEvent( + MCONTACT hContact, + DWORD timestamp, + SEBinary &guid, + const char *message, + bool isUnread = true); + void RaiseAuthRequestEvent( + DWORD timestamp, + CContact::Ref contact); + + // dialog procs + static INT_PTR CALLBACK SkypeMainOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); + static INT_PTR CALLBACK SkypePasswordRequestProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); + static INT_PTR CALLBACK SkypePasswordChangeProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); + static INT_PTR CALLBACK ChatRoomProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); + static INT_PTR CALLBACK SkypePrivacyOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); + + static INT_PTR CALLBACK SkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); + static INT_PTR CALLBACK PersonalSkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); + static INT_PTR CALLBACK ContactSkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); + static INT_PTR CALLBACK HomeSkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); + static INT_PTR CALLBACK AccountSkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); + + // skype runtime + char *LoadKeyPair(); + int StartSkypeRuntime(const wchar_t *profileName); + BOOL SafeTerminateProcess(HANDLE hProcess, UINT uExitCode); + void StopSkypeRuntime(); + + // events + static int OnModulesLoaded(WPARAM wParam, LPARAM lParam); + + int __cdecl OnProtoModulesLoaded(WPARAM, LPARAM); + int __cdecl OnPreShutdown(WPARAM, LPARAM); + int __cdecl OnContactDeleted(WPARAM, LPARAM); + int __cdecl OnOptionsInit(WPARAM, LPARAM); + int __cdecl OnSrmmWindowOpen(WPARAM, LPARAM); + int __cdecl OnUserInfoInit(WPARAM, LPARAM); + INT_PTR __cdecl OnAccountManagerInit(WPARAM wParam, LPARAM lParam); + + int __cdecl OnMessagePreCreate(WPARAM, LPARAM); + int __cdecl OnTabSRMMButtonPressed(WPARAM, LPARAM); +}; diff --git a/plugins/!Deprecated/Skype/src/skype_runtime.cpp b/plugins/!Deprecated/Skype/src/skype_runtime.cpp new file mode 100644 index 0000000000..ed966b1f34 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_runtime.cpp @@ -0,0 +1,162 @@ +#include "skype.h" + +#include "aes\aes.h" + +#include "..\..\..\..\skypekit\key.h" + +char *CSkypeProto::LoadKeyPair() +{ + HRSRC hResource = FindResource(g_hInstance, MAKEINTRESOURCE(IDR_KEY), L"BIN"); + if (hResource == NULL) + return NULL; + + HGLOBAL hLoadedResource = LoadResource(g_hInstance, hResource); + if (hLoadedResource == NULL) + return NULL; + + LPVOID pLockedResource = LockResource(hLoadedResource); + if (pLockedResource == NULL) + return NULL; + + int length = ::SizeofResource(g_hInstance, hResource); + if (length == 0) + return NULL; + + char* pData = (char*)_alloca(length + 1); + ::memcpy(pData, pLockedResource, length); + pData[length] = 0; + + unsigned decodedLen; + mir_ptr tmpD((BYTE*)::mir_base64_decode(pData, &decodedLen)); + BYTE *result = (BYTE*)::mir_alloc(decodedLen+17); + + aes_context ctx; + char *key = (char*)::mir_base64_decode(MY_KEY, NULL); + ::aes_set_key(&ctx, (BYTE*)key, 128); + ::mir_free(key); + + for (unsigned i = 0; i < decodedLen; i += 16) + aes_decrypt(&ctx, &tmpD[i], &result[i]); + + result[decodedLen] = 0; + return (char *)result; +} + +int CSkypeProto::StartSkypeRuntime(const wchar_t *profileName) +{ + STARTUPINFO cif = {0}; + cif.cb = sizeof(STARTUPINFO); + cif.dwFlags = STARTF_USESHOWWINDOW; + cif.wShowWindow = SW_HIDE; + + wchar_t fileName[MAX_PATH]; + ::GetModuleFileName(g_hInstance, fileName, MAX_PATH); + + wchar_t *skypeKitPath = ::wcsrchr(fileName, '\\'); + if (skypeKitPath != NULL) + *skypeKitPath = 0; + ::mir_snwprintf(fileName, SIZEOF(fileName), L"%s\\%s", fileName, L"SkypeKit.exe"); + + PROCESSENTRY32 entry; + entry.dwSize = sizeof(PROCESSENTRY32); + + // todo: rework + HANDLE snapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL); + if (::Process32First(snapshot, &entry) == TRUE) + { + while (::Process32Next(snapshot, &entry) == TRUE) + { + if (::wcsicmp(entry.szExeFile, L"SkypeKit.exe") == 0 || ::wcsicmp(entry.szExeFile, L"Skype.exe") == 0) + { + this->skypeKitPort += rand() % 1000 + 8963; + break; + } + } + } + ::CloseHandle(snapshot); + + wchar_t param[128]; + VARST dbPath( _T("%miranda_userdata%\\SkypeKit")); + ::mir_snwprintf(param, SIZEOF(param), L"-p -P %d -f \"%s\"", this->skypeKitPort, dbPath); + int startingrt = ::CreateProcess( + fileName, param, + NULL, NULL, FALSE, + CREATE_NEW_CONSOLE, + NULL, NULL, &cif, &this->skypeKitProcessInfo); + + return startingrt; +} + +BOOL CSkypeProto::SafeTerminateProcess(HANDLE hProcess, UINT uExitCode) +{ + DWORD dwTID, dwCode, dwErr = 0; + HANDLE hProcessDup = INVALID_HANDLE_VALUE; + HANDLE hRT = NULL; + HINSTANCE hKernel = ::GetModuleHandle(L"Kernel32"); + BOOL bSuccess = FALSE; + + BOOL bDup = ::DuplicateHandle( + ::GetCurrentProcess(), + hProcess, + GetCurrentProcess(), + &hProcessDup, + PROCESS_ALL_ACCESS, + FALSE, + 0); + + // Detect the special case where the process is + // already dead... + if (::GetExitCodeProcess((bDup) ? hProcessDup : hProcess, &dwCode) && (dwCode == STILL_ACTIVE)) + { + FARPROC pfnExitProc; + + pfnExitProc = GetProcAddress(hKernel, "ExitProcess"); + + hRT = ::CreateRemoteThread( + (bDup) ? hProcessDup : hProcess, + NULL, + 0, + (LPTHREAD_START_ROUTINE)pfnExitProc, + (PVOID)uExitCode, 0, &dwTID); + + if ( hRT == NULL ) + dwErr = GetLastError(); + } + else + dwErr = ERROR_PROCESS_ABORTED; + + if (hRT) + { + // Must wait process to terminate to + // guarantee that it has exited... + ::WaitForSingleObject((bDup) ? hProcessDup : hProcess, INFINITE); + + ::CloseHandle(hRT); + bSuccess = TRUE; + } + + if ( bDup ) + ::CloseHandle(hProcessDup); + + if ( !bSuccess ) + ::SetLastError(dwErr); + + return bSuccess; +} + +void CSkypeProto::StopSkypeRuntime() +{ + //DWORD dwExitCode = 0; + //this->SafeTerminateProcess(this->skypeKitProcessInfo.hProcess, 0); + //::PostThreadMessage(this->skypeKitProcessInfo.dwThreadId, WM_CLOSE, 0, 0); + //::WaitForSingleObject(this->skypeKitProcessInfo.hProcess, 1500); + + DWORD dwExitCode = 0; + ::GetExitCodeProcess(this->skypeKitProcessInfo.hProcess, &dwExitCode); + if (dwExitCode == STILL_ACTIVE) + //::TerminateProcess(this->skypeKitProcessInfo.hProcess, 0); // Zero is the exit code + this->SafeTerminateProcess(this->skypeKitProcessInfo.hProcess, 0); + + ::CloseHandle(this->skypeKitProcessInfo.hThread); + ::CloseHandle(this->skypeKitProcessInfo.hProcess); +} diff --git a/plugins/!Deprecated/Skype/src/skype_services.cpp b/plugins/!Deprecated/Skype/src/skype_services.cpp new file mode 100644 index 0000000000..9f2ac62434 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_services.cpp @@ -0,0 +1,25 @@ +#include "skype.h" +#include + +void CSkypeProto::InitServiceList() +{ + ::CreateServiceFunction("Skype/MenuChoose", CSkypeProto::MenuChooseService); +} + +void CSkypeProto::InitInstanceServiceList() +{ + // Message API + this->CreateProtoService(PS_CREATEACCMGRUI, &CSkypeProto::OnAccountManagerInit); + // Chat API + this->CreateProtoService(PS_JOINCHAT, &CSkypeProto::OnJoinChat); + this->CreateProtoService(PS_LEAVECHAT, &CSkypeProto::OnLeaveChat); + // Own info + this->CreateProtoService(PS_SETMYNICKNAME, &CSkypeProto::SetMyNickName); + // Avatar API + this->CreateProtoService(PS_GETAVATARINFOT, &CSkypeProto::GetAvatarInfo); + this->CreateProtoService(PS_GETAVATARCAPS, &CSkypeProto::GetAvatarCaps); + this->CreateProtoService(PS_GETMYAVATART, &CSkypeProto::GetMyAvatar); + this->CreateProtoService(PS_SETMYAVATART, &CSkypeProto::SetMyAvatar); + // service to get from protocol chat buddy info + this->CreateProtoService(MS_GC_PROTO_GETTOOLTIPTEXT, &CSkypeProto::SkypeGCGetToolTipText); +} diff --git a/plugins/!Deprecated/Skype/src/skype_settings.cpp b/plugins/!Deprecated/Skype/src/skype_settings.cpp new file mode 100644 index 0000000000..4b4c7482c9 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_settings.cpp @@ -0,0 +1,141 @@ +#include "skype_proto.h" + +BYTE CSkypeProto::GetSettingByte(HANDLE hContact, const char *setting, BYTE errorValue) +{ + return ::db_get_b(hContact, this->m_szModuleName, setting, errorValue); +} + +BYTE CSkypeProto::GetSettingByte(const char *setting, BYTE errorValue) +{ + return this->GetSettingByte(NULL, setting, errorValue); +} + +WORD CSkypeProto::GetSettingWord(HANDLE hContact, const char *setting, WORD errorValue) +{ + return ::db_get_w(hContact, this->m_szModuleName, setting, errorValue); +} + +WORD CSkypeProto::GetSettingWord(const char *setting, WORD errorValue) +{ + return this->GetSettingWord(NULL, setting, errorValue); +} + +DWORD CSkypeProto::GetSettingDword(HANDLE hContact, const char *setting, DWORD errorValue) +{ + return ::db_get_dw(hContact, this->m_szModuleName, setting, errorValue); +} + +DWORD CSkypeProto::GetSettingDword(const char *setting, DWORD errorValue) +{ + return this->GetSettingDword(NULL, setting, errorValue); +} + +wchar_t* CSkypeProto::GetSettingString(HANDLE hContact, const char *setting, wchar_t* errorValue) +{ + DBVARIANT dbv = {0}; + wchar_t* result = NULL; + + if ( !::db_get_ws(hContact, this->m_szModuleName, setting, &dbv)) + { + result = ::mir_wstrdup(dbv.pwszVal); + ::db_free(&dbv); + } + else + { + result = ::mir_wstrdup(errorValue); + } + + return result; +} + +wchar_t* CSkypeProto::GetSettingString(const char *setting, wchar_t* errorValue) +{ + return this->GetSettingString(NULL, setting, errorValue); +} + +char* CSkypeProto::GetDecodeSettingString(HANDLE hContact, const char *setting, char* errorValue) +{ + DBVARIANT dbv = {0}; + char* result = NULL; + + if ( !::db_get_s(hContact, this->m_szModuleName, setting, &dbv)) + { + result = ::mir_strdup(dbv.pszVal); + ::db_free(&dbv); + + ::CallService( + MS_DB_CRYPT_DECODESTRING, + ::strlen(result), + reinterpret_cast(result)); + } + else result = ::mir_strdup(errorValue); + + return result; +} + +// + +bool CSkypeProto::SetSettingByte(HANDLE hContact, const char *setting, BYTE value) +{ + return !::db_set_b(hContact, this->m_szModuleName, setting, value); +} + +bool CSkypeProto::SetSettingByte(const char *setting, BYTE errorValue) +{ + return this->SetSettingByte(NULL, setting, errorValue); +} + +bool CSkypeProto::SetSettingWord(HANDLE hContact, const char *setting, WORD value) +{ + return !::db_set_w(hContact, this->m_szModuleName, setting, value); +} + +bool CSkypeProto::SetSettingWord(const char *setting, WORD value) +{ + return this->SetSettingWord(NULL, setting, value); +} + +bool CSkypeProto::SetSettingDword(HANDLE hContact, const char *setting, DWORD value) +{ + return !::db_set_dw(hContact, this->m_szModuleName, setting, value); +} + +bool CSkypeProto::SetSettingDword(const char *setting, DWORD value) +{ + return this->SetSettingDword(NULL, setting, value); +} + +bool CSkypeProto::SetSettingString(HANDLE hContact, const char *szSetting, const wchar_t* value) +{ + return !::db_set_ws(hContact, this->m_szModuleName, szSetting, value); +} + +bool CSkypeProto::SetSettingString(const char *szSetting, const wchar_t* value) +{ + return this->SetSettingString(NULL, szSetting, value); +} + +bool CSkypeProto::SetDecodeSettingString(HANDLE hContact, const char *setting, const char* value) +{ + if( ::strcmp(value, "")) + { + mir_ptr result (::mir_strdup(value)); + ::CallService(MS_DB_CRYPT_ENCODESTRING, strlen(result), LPARAM((char*)result)); + + return !db_set_s(hContact, m_szModuleName, setting, result); + } + + return !this->SetSettingString(hContact, setting, L""); +} + +// + +void CSkypeProto::DeleteSetting(const char *setting) +{ + this->DeleteSetting(NULL, setting); +} + +void CSkypeProto::DeleteSetting(HANDLE hContact, const char *setting) +{ + ::db_unset(hContact, this->m_szModuleName, setting); +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype_skype.cpp b/plugins/!Deprecated/Skype/src/skype_skype.cpp new file mode 100644 index 0000000000..65df7f98f7 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_skype.cpp @@ -0,0 +1,41 @@ +#include "skype.h" + +CAccount* CSkypeProto::newAccount(int oid) +{ + return new CAccount(oid, this); +} + +CContactGroup* CSkypeProto::newContactGroup(int oid) +{ + return new CContactGroup(oid, this); +} + +CContact* CSkypeProto::newContact(int oid) +{ + return new CContact(oid, this); +} + +CConversation* CSkypeProto::newConversation(int oid) +{ + return new CConversation(oid, this); +} + +CParticipant* CSkypeProto::newParticipant(int oid) +{ + return new CParticipant(oid, this); +} + +CMessage* CSkypeProto::newMessage(int oid) +{ + return new CMessage(oid, this); +} + +CTransfer* CSkypeProto::newTransfer(int oid) +{ + return new CTransfer(oid, this); +} + +CContactSearch* CSkypeProto::newContactSearch(int oid) +{ + return new CContactSearch(oid, this); +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype_transfers.cpp b/plugins/!Deprecated/Skype/src/skype_transfers.cpp new file mode 100644 index 0000000000..a6f5fc5cab --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_transfers.cpp @@ -0,0 +1,191 @@ +#include "skype.h" + +wchar_t *CSkypeProto::TransferFailureReasons[] = +{ + LPGENW("") /* --- */, + LPGENW("SENDER_NOT_AUTHORIZED") /* SENDER_NOT_AUTHORISED */, + LPGENW("REMOTELY_CANCELED") /* REMOTELY_CANCELLED */, + LPGENW("FAILED_READ") /* FAILED_READ */, + LPGENW("FAILED_REMOTE_READ") /* FAILED_REMOTE_READ */, + LPGENW("FAILED_WRITE") /* FAILED_WRITE */, + LPGENW("FAILED_REMOTE_WRITE") /* FAILED_REMOTE_WRITE */, + LPGENW("REMOTE_DOES_NOT_SUPPORT_FT") /* REMOTE_DOES_NOT_SUPPORT_FT */, + LPGENW("REMOTE_OFFLINE_FOR_TOO_LONG") /* REMOTE_OFFLINE_FOR_TOO_LONG */, + LPGENW("TOO_MANY_PARALLEL") /* TOO_MANY_PARALLEL */, + LPGENW("PLACEHOLDER_TIMEOUT") /* PLACEHOLDER_TIMEOUT */ +}; + +void CSkypeProto::OnTransferChanged(const TransferRef &transfer, int prop) +{ + switch (prop) + { + case Transfer::P_STATUS: + { + Transfer::FAILUREREASON reason; + + SEBinary guid; + transfer->GetPropChatmsgGuid(guid); + + MessageRef msgRef; + this->GetMessageByGuid(guid, msgRef); + + uint oid = msgRef->getOID(); + + uint fOid = transfer->getOID(); + + Transfer::STATUS status; + transfer->GetPropStatus(status); + switch(status) + { + case Transfer::CONNECTING: + this->SendBroadcast(this->transferts[oid].pfts.hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, (HANDLE)oid, 0); + break; + case Transfer::TRANSFERRING: + case Transfer::TRANSFERRING_OVER_RELAY: + this->SendBroadcast(this->transferts[oid].pfts.hContact, ACKTYPE_FILE, ACKRESULT_CONNECTED, (HANDLE)oid, 0); + break; + case Transfer::FAILED: + transfer->GetPropFailurereason(reason); + this->debugLogW(L"File transfer failed: %s", CSkypeProto::TransferFailureReasons[reason]); + this->transferList.remove_val(transfer); + this->transferts[oid].files[fOid].isCanceled = true; + break; + case Transfer::COMPLETED: + this->transferList.remove_val(transfer); + this->transferts[oid].files[fOid].isCompleted = true; + this->transferts[oid].pfts.totalProgress += this->transferts[oid].files[fOid].size - this->transferts[oid].files[fOid].transfered; + break; + case Transfer::CANCELLED: + case Transfer::CANCELLED_BY_REMOTE: + transfer->GetPropFailurereason(reason); + this->debugLogW(L"File transfer cancelled: %s", CSkypeProto::TransferFailureReasons[reason]); + this->transferList.remove_val(transfer); + this->transferts[oid].files[fOid].isCanceled = true; + break; + } + + int isNotAll = false; + for (auto i = this->transferts[oid].files.begin(); i != this->transferts[oid].files.end(); i++) + if ( !(i->second.isCanceled || i->second.isCompleted)) + { + isNotAll = true; + break; + } + if (isNotAll) + { + SEString data; + uint fOid = transfer->getOID(); + transfer->GetPropBytestransferred(data); + Sid::uint64 tb = data.toUInt64(); + this->transferts[oid].pfts.totalProgress += tb; + this->transferts[oid].files[fOid].transfered = tb; + + this->SendBroadcast(this->transferts[oid].pfts.hContact, ACKTYPE_FILE, ACKRESULT_DATA, (HANDLE)oid, (LPARAM)&this->transferts[oid].pfts); + } + else + { + this->SendBroadcast(this->transferts[oid].pfts.hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, (HANDLE)oid, 0); + delete [] this->transferts[oid].pfts.ptszFiles; + this->transferts.erase(this->transferts.find(oid)); + } + } + break; + + case Transfer::P_BYTESTRANSFERRED: + { + SEString data; + + SEBinary guid; + transfer->GetPropChatmsgGuid(guid); + + MessageRef msgRef; + this->GetMessageByGuid(guid, msgRef); + + uint oid = msgRef->getOID(); + + uint fOid = transfer->getOID(); + transfer->GetPropBytestransferred(data); + Sid::uint64 tb = data.toUInt64(); + this->transferts[oid].pfts.totalProgress += tb; + this->transferts[oid].files[fOid].transfered = tb; + + this->SendBroadcast(this->transferts[oid].pfts.hContact, ACKTYPE_FILE, ACKRESULT_DATA, (HANDLE)oid, (LPARAM)&this->transferts[oid].pfts); + } + break; + } +} + +void CSkypeProto::OnFileEvent(const ConversationRef &conversation, const MessageRef &message) +{ + SEString data; + Transfer::TYPE transferType; + Transfer::STATUS transferStatus; + + ContactRef author; + message->GetPropAuthor(data); + this->GetContact(data, author); + + TransferRefs transfers; + message->GetTransfers(transfers); + + FileTransferParam ftp; + ftp.pfts.flags = PFTS_RECEIVING | PFTS_UNICODE; + ftp.pfts.hContact = this->AddContact(author, true); + ftp.pfts.totalFiles = (int)transfers.size(); + ftp.pfts.ptszFiles = new wchar_t*[transfers.size() + 1]; + + int nifc = 0; + for (size_t i = 0; i < transfers.size(); i++) + { + auto transfer = transfers[i]; + + // For incomings, we need to check for transfer status, just to be sure. + // In some cases, a transfer can appear with STATUS == PLACEHOLDER + // As such transfers cannot be accepted, we will need to just store + // the reference to Transfer Object and then check for further + // status changes in Transfer::OnChange + transfer->GetPropStatus(transferStatus); + if (transferStatus == Transfer::NEW || transferStatus == Transfer::PLACEHOLDER) + { + transfer->GetPropType(transferType); + if (transferType == Transfer::INCOMING) + { + transfer->GetPropFilename(data); + ftp.pfts.ptszFiles[nifc++] = ::mir_utf8decodeW(data); + + transfer.fetch(); + this->transferList.append(transfer); + //transfer.fetch(); + + transfer->GetPropFilesize(data); + Sid::uint64 size = data.toUInt64(); + + ftp.files.insert(std::make_pair(transfer->getOID(), FileParam(size))); + ftp.pfts.totalBytes += size; + } + } + } + + if (nifc > 0) + { + uint timestamp; + message->GetPropTimestamp(timestamp); + + auto oid = message->getOID(); + + this->transferts.insert(std::make_pair(oid, ftp)); + + PROTORECVFILET pre = {0}; + pre.flags = PREF_TCHAR; + pre.fileCount = ftp.pfts.totalFiles; + pre.timestamp = timestamp; + pre.tszDescription = L""; + pre.ptszFiles = ftp.pfts.ptszFiles; + pre.lParam = (LPARAM)oid; + ::ProtoChainRecvFile(ftp.pfts.hContact, &pre); + } + else + { + delete [] ftp.pfts.ptszFiles; + } +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skype_utils.cpp b/plugins/!Deprecated/Skype/src/skype_utils.cpp new file mode 100644 index 0000000000..f8c410513d --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skype_utils.cpp @@ -0,0 +1,542 @@ +#include "skype.h" + +wchar_t *CSkypeProto::ValidationReasons[] = +{ + LPGENW("NOT_VALIDATED") /* NOT_VALIDATED */, + LPGENW("Validation succeeded") /* VALIDATED_OK */, + LPGENW("Password is too short") /* TOO_SHORT */, + LPGENW("The value exceeds max size limit for the given property") /* TOO_LONG */, + LPGENW("Value contains illegal characters") /* CONTAINS_INVALID_CHAR */, + LPGENW("Value contains whitespace") /* CONTAINS_SPACE */, + LPGENW("Password cannot be the same as Skype name") /* SAME_AS_USERNAME */, + LPGENW("Value has invalid format") /* INVALID_FORMAT */, + LPGENW("Value contains invalid word") /* CONTAINS_INVALID_WORD */, + LPGENW("Password is too simple") /* TOO_SIMPLE */, + LPGENW("Value starts with an invalid character") /* STARTS_WITH_INVALID_CHAR */, +}; + +std::map CSkypeProto::languages; + +void CSkypeProto::InitLanguages() +{ + std::map result; + result[L"ab"] = L"Abkhazian"; + result[L"aa"] = L"Afar"; + result[L"af"] = L"Afrikaans"; + result[L"ak"] = L"Akan"; + result[L"sq"] = L"Albanian"; + result[L"am"] = L"Amharic"; + result[L"ar"] = L"Arabic"; + result[L"an"] = L"Aragonese"; + result[L"hy"] = L"Armenian"; + result[L"as"] = L"Assamese"; + result[L"av"] = L"Avaric"; + result[L"ae"] = L"Avestan"; + result[L"ay"] = L"Aymara"; + result[L"az"] = L"Azerbaijani"; + result[L"bm"] = L"Bambara"; + result[L"ba"] = L"Bashkir"; + result[L"eu"] = L"Basque"; + result[L"be"] = L"Belarusian"; + result[L"bn"] = L"Bengali"; + result[L"bh"] = L"Bihari languages"; + result[L"bi"] = L"Bislama"; + result[L"nb"] = L"Bokmal, Norwegian"; + result[L"bs"] = L"Bosnian"; + result[L"br"] = L"Breton"; + result[L"bg"] = L"Bulgarian"; + result[L"my"] = L"Burmese"; + result[L"es"] = L"Castilian"; + result[L"ca"] = L"Catalan"; + result[L"km"] = L"Central Khmer"; + result[L"ch"] = L"Chamorro"; + result[L"ce"] = L"Chechen"; + result[L"ny"] = L"Chewa"; + result[L"ny"] = L"Chichewa"; + result[L"zh"] = L"Chinese"; + result[L"za"] = L"Chuang"; + result[L"cu"] = L"Church Slavic"; + result[L"cu"] = L"Church Slavonic"; + result[L"cv"] = L"Chuvash"; + result[L"kw"] = L"Cornish"; + result[L"co"] = L"Corsican"; + result[L"cr"] = L"Cree"; + result[L"hr"] = L"Croatian"; + result[L"cs"] = L"Czech"; + result[L"da"] = L"Danish"; + result[L"dv"] = L"Dhivehi"; + result[L"dv"] = L"Divehi"; + result[L"nl"] = L"Dutch"; + result[L"dz"] = L"Dzongkha"; + result[L"en"] = L"English"; + result[L"eo"] = L"Esperanto"; + result[L"et"] = L"Estonian"; + result[L"ee"] = L"Ewe"; + result[L"fo"] = L"Faroese"; + result[L"fj"] = L"Fijian"; + result[L"fi"] = L"Finnish"; + result[L"nl"] = L"Flemish"; + result[L"fr"] = L"French"; + result[L"ff"] = L"Fulah"; + result[L"gd"] = L"Gaelic"; + result[L"gl"] = L"Galician"; + result[L"lg"] = L"Ganda"; + result[L"ka"] = L"Georgian"; + result[L"de"] = L"German"; + result[L"ki"] = L"Gikuyu"; + result[L"el"] = L"Greek, Modern (1453-)"; + result[L"kl"] = L"Greenlandic"; + result[L"gn"] = L"Guarani"; + result[L"gu"] = L"Gujarati"; + result[L"ht"] = L"Haitian"; + result[L"ht"] = L"Haitian Creole"; + result[L"ha"] = L"Hausa"; + result[L"he"] = L"Hebrew"; + result[L"hz"] = L"Herero"; + result[L"hi"] = L"Hindi"; + result[L"ho"] = L"Hiri Motu"; + result[L"hu"] = L"Hungarian"; + result[L"is"] = L"Icelandic"; + result[L"io"] = L"Ido"; + result[L"ig"] = L"Igbo"; + result[L"id"] = L"Indonesian"; + result[L"ia"] = L"Interlingua (International Auxiliary Language Association)"; + result[L"ie"] = L"Interlingue"; + result[L"iu"] = L"Inuktitut"; + result[L"ik"] = L"Inupiaq"; + result[L"ga"] = L"Irish"; + result[L"it"] = L"Italian"; + result[L"ja"] = L"Japanese"; + result[L"jv"] = L"Javanese"; + result[L"kl"] = L"Kalaallisut"; + result[L"kn"] = L"Kannada"; + result[L"kr"] = L"Kanuri"; + result[L"ks"] = L"Kashmiri"; + result[L"kk"] = L"Kazakh"; + result[L"ki"] = L"Kikuyu"; + result[L"rw"] = L"Kinyarwanda"; + result[L"ky"] = L"Kirghiz"; + result[L"kv"] = L"Komi"; + result[L"kg"] = L"Kongo"; + result[L"ko"] = L"Korean"; + result[L"kj"] = L"Kuanyama"; + result[L"ku"] = L"Kurdish"; + result[L"kj"] = L"Kwanyama"; + result[L"ky"] = L"Kyrgyz"; + result[L"lo"] = L"Lao"; + result[L"la"] = L"Latin"; + result[L"lv"] = L"Latvian"; + result[L"lb"] = L"Letzeburgesch"; + result[L"li"] = L"Limburgan"; + result[L"li"] = L"Limburger"; + result[L"li"] = L"Limburgish"; + result[L"ln"] = L"Lingala"; + result[L"lt"] = L"Lithuanian"; + result[L"lu"] = L"Luba-Katanga"; + result[L"lb"] = L"Luxembourgish"; + result[L"mk"] = L"Macedonian"; + result[L"mg"] = L"Malagasy"; + result[L"ms"] = L"Malay"; + result[L"ml"] = L"Malayalam"; + result[L"dv"] = L"Maldivian"; + result[L"mt"] = L"Maltese"; + result[L"gv"] = L"Manx"; + result[L"mi"] = L"Maori"; + result[L"mr"] = L"Marathi"; + result[L"mh"] = L"Marshallese"; + result[L"ro"] = L"Moldavian"; + result[L"ro"] = L"Moldovan"; + result[L"mn"] = L"Mongolian"; + result[L"na"] = L"Nauru"; + result[L"nv"] = L"Navaho"; + result[L"nv"] = L"Navajo"; + result[L"nd"] = L"Ndebele, North"; + result[L"nr"] = L"Ndebele, South"; + result[L"ng"] = L"Ndonga"; + result[L"ne"] = L"Nepali"; + result[L"nd"] = L"North Ndebele"; + result[L"se"] = L"Northern Sami"; + result[L"no"] = L"Norwegian"; + result[L"nb"] = L"Norwegian Bokmal"; + result[L"nn"] = L"Norwegian Nynorsk"; + result[L"ii"] = L"Nuosu"; + result[L"ny"] = L"Nyanja"; + result[L"nn"] = L"Nynorsk, Norwegian"; + result[L"ie"] = L"Occidental"; + result[L"oc"] = L"Occitan (post 1500)"; + result[L"oj"] = L"Ojibwa"; + result[L"cu"] = L"Old Bulgarian"; + result[L"cu"] = L"Old Church Slavonic"; + result[L"cu"] = L"Old Slavonic"; + result[L"or"] = L"Oriya"; + result[L"om"] = L"Oromo"; + result[L"os"] = L"Ossetian"; + result[L"os"] = L"Ossetic"; + result[L"pi"] = L"Pali"; + result[L"pa"] = L"Panjabi"; + result[L"ps"] = L"Pashto"; + result[L"fa"] = L"Persian"; + result[L"pl"] = L"Polish"; + result[L"pt"] = L"Portuguese"; + result[L"pa"] = L"Punjabi"; + result[L"ps"] = L"Pushto"; + result[L"qu"] = L"Quechua"; + result[L"ro"] = L"Romanian"; + result[L"rm"] = L"Romansh"; + result[L"rn"] = L"Rundi"; + result[L"ru"] = L"Russian"; + result[L"sm"] = L"Samoan"; + result[L"sg"] = L"Sango"; + result[L"sa"] = L"Sanskrit"; + result[L"sc"] = L"Sardinian"; + result[L"gd"] = L"Scottish Gaelic"; + result[L"sr"] = L"Serbian"; + result[L"sn"] = L"Shona"; + result[L"ii"] = L"Sichuan Yi"; + result[L"sd"] = L"Sindhi"; + result[L"si"] = L"Sinhala"; + result[L"si"] = L"Sinhalese"; + result[L"sk"] = L"Slovak"; + result[L"sl"] = L"Slovenian"; + result[L"so"] = L"Somali"; + result[L"st"] = L"Sotho, Southern"; + result[L"nr"] = L"South Ndebele"; + result[L"es"] = L"Spanish"; + result[L"su"] = L"Sundanese"; + result[L"sw"] = L"Swahili"; + result[L"ss"] = L"Swati"; + result[L"sv"] = L"Swedish"; + result[L"tl"] = L"Tagalog"; + result[L"ty"] = L"Tahitian"; + result[L"tg"] = L"Tajik"; + result[L"ta"] = L"Tamil"; + result[L"tt"] = L"Tatar"; + result[L"te"] = L"Telugu"; + result[L"th"] = L"Thai"; + result[L"bo"] = L"Tibetan"; + result[L"ti"] = L"Tigrinya"; + result[L"to"] = L"Tonga (Tonga Islands)"; + result[L"ts"] = L"Tsonga"; + result[L"tn"] = L"Tswana"; + result[L"tr"] = L"Turkish"; + result[L"tk"] = L"Turkmen"; + result[L"tw"] = L"Twi"; + result[L"ug"] = L"Uighur"; + result[L"uk"] = L"Ukrainian"; + result[L"ur"] = L"Urdu"; + result[L"ug"] = L"Uyghur"; + result[L"uz"] = L"Uzbek"; + result[L"ca"] = L"Valencian"; + result[L"ve"] = L"Venda"; + result[L"vi"] = L"Vietnamese"; + result[L"vo"] = L"Volapuk"; + result[L"wa"] = L"Walloon"; + result[L"cy"] = L"Welsh"; + result[L"fy"] = L"Western Frisian"; + result[L"wo"] = L"Wolof"; + result[L"xh"] = L"Xhosa"; + result[L"yi"] = L"Yiddish"; + result[L"yo"] = L"Yoruba"; + result[L"za"] = L"Zhuang"; + result[L"zu"] = L"Zulu"; +} + +// --- + +int CSkypeProto::SendBroadcast(MCONTACT hContact, int type, int result, HANDLE hProcess, LPARAM lParam) +{ + return ::ProtoBroadcastAck(this->m_szModuleName, hContact, type, result, hProcess, lParam); +} + +int CSkypeProto::SendBroadcast(int type, int result, HANDLE hProcess, LPARAM lParam) +{ + return this->SendBroadcast(NULL, type, result, hProcess, lParam); +} + +// + +int CSkypeProto::SkypeToMirandaLoginError(CAccount::LOGOUTREASON logoutReason) +{ + int loginError = 0; + + // todo: rewrite!! + + switch (logoutReason) + { + case CAccount::SERVER_OVERLOADED: + case CAccount::P2P_CONNECT_FAILED: + case CAccount::SERVER_CONNECT_FAILED: + loginError = LOGINERR_NOSERVER; + break; + case CAccount::HTTPS_PROXY_AUTH_FAILED: + case CAccount::SOCKS_PROXY_AUTH_FAILED: + loginError = LOGINERR_PROXYFAILURE; + break; + case CAccount::INCORRECT_PASSWORD: + case CAccount::UNACCEPTABLE_PASSWORD: + loginError = LOGINERR_WRONGPASSWORD; + break; + + case CAccount::INVALID_APP_ID: + loginError = 1001; + break; + } + + return loginError; +} + +void CSkypeProto::ShowNotification(const wchar_t *caption, const wchar_t *message, int flags, MCONTACT hContact) +{ + if (::Miranda_Terminated()) return; + + if ( ::ServiceExists(MS_POPUP_ADDPOPUPT) && ::db_get_b(NULL, "Popup", "ModuleIsEnabled", 1)) + { + POPUPDATAW ppd = {0}; + ppd.lchContact = hContact; + ::wcsncpy(ppd.lpwzContactName, caption, MAX_CONTACTNAME); + ::wcsncpy(ppd.lpwzText, message, MAX_SECONDLINE); + ppd.lchIcon = ::Skin_GetIcon("Skype_main"); + + if ( !::PUAddPopupW(&ppd)) + return; + + } + + ::MessageBoxW(NULL, message, caption, MB_OK | flags); +} + +void CSkypeProto::ShowNotification(const wchar_t *message, int flags, MCONTACT hContact) +{ + CSkypeProto::ShowNotification(::TranslateT(MODULE), message, flags, hContact); +} + +struct HtmlEntity +{ + const char *entity; + char symbol; +}; + +const HtmlEntity htmlEntities[]={ + {"nbsp", ' '}, + {"amp", '&'}, + {"quot", '"'}, + {"lt", '<'}, + {"gt", '>'}, + {"apos", '\''}, + {"copy", '©'}, + // TODO: add more +}; + +char *CSkypeProto::RemoveHtml(const char *text) +{ + std::string new_string = ""; + std::string data = text; + + if (data.find("\x1b\xe3\xac\x8d\x1d") != -1) + data = "CONVERSATION MEMBERS:" + data.substr(5, data.length() - 5); + + for (std::string::size_type i = 0; i < data.length(); i++) + { + if (data.at(i) == '<' && data.at(i+1) != ' ') + { + i = data.find(">", i); + if (i == std::string::npos) + break; + + continue; + } + + if (data.at(i) == '&') { + std::string::size_type begin = i; + i = data.find(";", i); + if (i == std::string::npos) { + i = begin; + } else { + std::string entity = data.substr(begin+1, i-begin-1); + + bool found = false; + for (int j=0; j|"; + for (size_t i = 0; i < ::wcslen(text); i++) + if (::wcschr(special, text[i]) != NULL) + text[i] = replaceWith; +} + +INT_PTR CSkypeProto::ParseSkypeUri(WPARAM wParam, LPARAM lParam) +{ + if (CSkypeProto::instanceList.getCount() == 0 || !CSkypeProto::instanceList[0]->IsOnline()) + return 1; + + CSkypeProto *ppro = CSkypeProto::instanceList[0]; + + wchar_t *args = ::mir_wstrdup((wchar_t *)lParam); + if (args == NULL) + return 1; + // set focus on clist + + wchar_t * q = ::wcschr(args, L'?'); + if (q == NULL) + return 1; + + wchar_t *c = q + 1; *q = 0; + StringList commands = StringList(c, L"&"); + StringList participants = StringList(args, L";"); + ptrW command, arg, commandAndParam; + + if ( !::lstrcmpiW(commands[0], L"chat")) + ppro->ChatRoomParseUriComands(c); + else + { + wchar_t message[1024]; + ::mir_sntprintf(message, SIZEOF(message), ::TranslateT("Command \"%s\" is unsupported"), args); + CSkypeProto::ShowNotification(message); + return 1; + } + + //for (size_t i = 1; i < commands.size(); i++) + //{ + // command = ::mir_wstrdup(commands[i]); + // wchar_t * p = ::wcschr(command, L'='); + // if (p != NULL) + // { + // arg = p + 1; + // *p = 0; + // } + + // if ( !::lstrcmpiW(command, L"blob")) + // { + // ppro->JoinToChat(arg); + // break; + // } + // else if ( !::lstrcmpiW(command, L"topic") && !participants.empty()) + // { + // ChatRoomParam param(NULL, participants, ppro); + // ::wcscpy(param.topic, arg); + // ppro->CreateChatRoom(¶m); + // break; + // + // } + //} + + return 0; +} diff --git a/plugins/!Deprecated/Skype/src/skypekit/account.cpp b/plugins/!Deprecated/Skype/src/skypekit/account.cpp new file mode 100644 index 0000000000..8ec02e08e8 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skypekit/account.cpp @@ -0,0 +1,32 @@ +#include "..\skype.h" +#include "account.h" + +CAccount::CAccount(unsigned int oid, CSkypeProto* _ppro) : + Account(oid, _ppro), + ppro(_ppro) +{ +} + +bool CAccount::IsOnline() +{ + CAccount::STATUS status; + this->GetPropStatus(status); + return status == CAccount::LOGGED_IN; +} + +bool CAccount::SetAvatar(SEBinary avatar, Skype::VALIDATERESULT &result) +{ + int fbl; + if (!((Skype*)this->root)->ValidateAvatar(avatar, result, fbl) || result != Skype::VALIDATED_OK) + return false; + + if (!this->SetBinProperty(Account::P_AVATAR_IMAGE, avatar)) + return false; + + return true; +} + +void CAccount::OnChange(int prop) +{ + ppro->OnAccountChanged(prop); +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skypekit/account.h b/plugins/!Deprecated/Skype/src/skypekit/account.h new file mode 100644 index 0000000000..a7128598ee --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skypekit/account.h @@ -0,0 +1,20 @@ +#pragma once + +#include "common.h" + +class CAccount : public Account +{ +public: + typedef DRef Ref; + typedef DRefs Refs; + + CAccount(unsigned int oid, CSkypeProto*); + + bool IsOnline(); + bool SetAvatar(SEBinary avatar, Skype::VALIDATERESULT &result); + +private: + CSkypeProto* ppro; + + void OnChange(int prop); +}; \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skypekit/common.h b/plugins/!Deprecated/Skype/src/skypekit/common.h new file mode 100644 index 0000000000..de00501ba3 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skypekit/common.h @@ -0,0 +1,8 @@ +#pragma once + +#undef OCSP_REQUEST +#undef OCSP_RESPONSE + +#include + +struct CSkypeProto; \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skypekit/contact.cpp b/plugins/!Deprecated/Skype/src/skypekit/contact.cpp new file mode 100644 index 0000000000..c7a1a3247d --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skypekit/contact.cpp @@ -0,0 +1,65 @@ +#include "..\skype.h" +#include "contact.h" + +CContact::CContact(unsigned int oid, CSkypeProto* _ppro) : + Contact(oid, _ppro), + proto(_ppro) +{ +} + +SEString CContact::GetSid() +{ + SEString result; + CContact::AVAILABILITY availability; + this->GetPropAvailability(availability); + if (availability == Contact::SKYPEOUT || availability == Contact::BLOCKED_SKYPEOUT) + this->GetPropPstnnumber(result); + else + this->GetPropSkypename(result); + return result; +} + +SEString CContact::GetNick() +{ + SEString result; + CContact::AVAILABILITY availability; + this->GetPropAvailability(availability); + if (availability == CContact::SKYPEOUT) + this->GetPropPstnnumber(result); + else + { + SEString sid; + this->GetIdentity(sid); + + this->GetPropDisplayname(result); + if (this->proto && this->proto->login) + { + if (sid.equals(result)) + this->GetPropFullname(result); + } + + if (result.size() == 0) + result = sid; + } + return result; +} + +bool CContact::GetFullname(SEString &firstName, SEString &lastName) +{ + SEString fullname; + this->GetPropFullname(fullname); + int pos = fullname.find(" "); + if (pos != -1) + { + firstName = fullname.substr(0, pos - 1); + lastName = fullname.right((int)fullname.size() - pos - 1); + } else + firstName = fullname; + + return true; +} + +void CContact::OnChange(int prop) +{ + proto->OnContactChanged(this->ref(), prop); +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skypekit/contact.h b/plugins/!Deprecated/Skype/src/skypekit/contact.h new file mode 100644 index 0000000000..4a79ba723d --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skypekit/contact.h @@ -0,0 +1,21 @@ +#pragma once + +#include "common.h" + +class CContact : public Contact +{ +public: + typedef DRef Ref; + typedef DRefs Refs; + + CContact(unsigned int oid, CSkypeProto*); + + SEString GetSid(); + SEString GetNick(); + bool GetFullname(SEString &firstName, SEString &lastName); + +private: + CSkypeProto* proto; + + void OnChange(int prop); +}; \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skypekit/conversation.cpp b/plugins/!Deprecated/Skype/src/skypekit/conversation.cpp new file mode 100644 index 0000000000..ff393c8efb --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skypekit/conversation.cpp @@ -0,0 +1,20 @@ +#include "..\skype.h" +#include "conversation.h" +#include "..\skype_chat.h" + +CConversation::CConversation(unsigned int oid, SERootObject* root) : + Conversation(oid, root) +{ + this->room = NULL; +} + +void CConversation::SetChatRoom(ChatRoom *room) +{ + this->room = room; +} + +void CConversation::OnChange(int prop) +{ + if (this->room != NULL) + this->room->OnChange(this->ref(), prop); +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skypekit/conversation.h b/plugins/!Deprecated/Skype/src/skypekit/conversation.h new file mode 100644 index 0000000000..3441743328 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skypekit/conversation.h @@ -0,0 +1,23 @@ +#pragma once + +#include "common.h" + +class ChatRoom; + +class CConversation : public Conversation +{ +public: + //typedef void (CSkypeProto::* OnConvoChanged)(const ConversationRef &conversation, int); + + typedef DRef Ref; + typedef DRefs Refs; + + CConversation(unsigned int oid, SERootObject* root); + + void SetChatRoom(ChatRoom *room); + +private: + ChatRoom *room; + + void OnChange(int prop); +}; \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skypekit/group.cpp b/plugins/!Deprecated/Skype/src/skypekit/group.cpp new file mode 100644 index 0000000000..a75c43d371 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skypekit/group.cpp @@ -0,0 +1,13 @@ +#include "..\skype.h" +#include "group.h" + +CContactGroup::CContactGroup(unsigned int oid, CSkypeProto* _ppro) : + ContactGroup(oid, _ppro), + proto(_ppro) +{ +} + +void CContactGroup::OnChange(const ContactRef &contact) +{ + proto->OnContactListChanged(contact); +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skypekit/group.h b/plugins/!Deprecated/Skype/src/skypekit/group.h new file mode 100644 index 0000000000..0443d203ea --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skypekit/group.h @@ -0,0 +1,19 @@ +#pragma once + +#include "common.h" +#include "contact.h" + +class CContactGroup : public ContactGroup +{ +public: + typedef void (CSkypeProto::* OnContactListChanged)(CContact::Ref contact); + + typedef DRef Ref; + typedef DRefs Refs; + CContactGroup(unsigned int oid, CSkypeProto*); + +private: + CSkypeProto* proto; + + void OnChange(const ContactRef &contact); +}; \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skypekit/message.cpp b/plugins/!Deprecated/Skype/src/skypekit/message.cpp new file mode 100644 index 0000000000..48afa08662 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skypekit/message.cpp @@ -0,0 +1,7 @@ +#include "..\skype.h" +#include "message.h" + +CMessage::CMessage(unsigned int oid, SERootObject* root) : + Message(oid, root) +{ +} diff --git a/plugins/!Deprecated/Skype/src/skypekit/message.h b/plugins/!Deprecated/Skype/src/skypekit/message.h new file mode 100644 index 0000000000..6bf1eda497 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skypekit/message.h @@ -0,0 +1,12 @@ +#pragma once + +#include "common.h" + +class CMessage : public Message +{ +public: + typedef DRef Ref; + typedef DRefs Refs; + + CMessage(unsigned int oid, SERootObject* root); +}; \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skypekit/participant.cpp b/plugins/!Deprecated/Skype/src/skypekit/participant.cpp new file mode 100644 index 0000000000..41e183821b --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skypekit/participant.cpp @@ -0,0 +1,27 @@ +#include "..\skype.h" +#include "participant.h" +#include "..\skype_chat.h" + +CParticipant::CParticipant(unsigned int oid, SERootObject* root) : + Participant(oid, root) +{ + this->room = NULL; +} + +//void CParticipant::SetOnChangedCallback(OnChanged callback, ChatRoom *room) +//{ +// this->room = room; +// this->callback = callback; +//} + +void CParticipant::SetChatRoom(ChatRoom *room) +{ + this->room = room; +} + +void CParticipant::OnChange(int prop) +{ + if (this->room != NULL) + this->room->OnParticipantChanged(this->ref(), prop); + //(room->*callback)(this->ref(), prop); +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skypekit/participant.h b/plugins/!Deprecated/Skype/src/skypekit/participant.h new file mode 100644 index 0000000000..170c14f1b7 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skypekit/participant.h @@ -0,0 +1,25 @@ +#pragma once + +#include "common.h" + +class ChatRoom; + +class CParticipant : public Participant +{ +public: + //typedef void (ChatRoom::* OnChanged)(const ParticipantRef &participant, int); + + typedef DRef Ref; + typedef DRefs Refs; + + CParticipant(unsigned int oid, SERootObject* root); + + //void SetOnChangedCallback(OnChanged callback, ChatRoom *room); + void SetChatRoom(ChatRoom *room); + +private: + ChatRoom *room; + //OnChanged callback; + + void OnChange(int prop); +}; \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skypekit/search.cpp b/plugins/!Deprecated/Skype/src/skypekit/search.cpp new file mode 100644 index 0000000000..f1b20563aa --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skypekit/search.cpp @@ -0,0 +1,36 @@ +#include "..\skype.h" +#include "search.h" + +CContactSearch::CContactSearch(unsigned int oid, CSkypeProto* _ppro) : + ContactSearch(oid, _ppro), + proto(_ppro) +{ +} + +void CContactSearch::OnChange(int prop) +{ + if (prop == P_CONTACT_SEARCH_STATUS) + { + CContactSearch::STATUS status; + this->GetPropContactSearchStatus(status); + if (status == FINISHED || status == FAILED) + { + this->isSeachFinished = true; + if (this->proto) + proto->OnSearchCompleted(this->hSearch); + } + } +} + +void CContactSearch::OnNewResult(const ContactRef &contact, const uint &rankValue) +{ + proto->OnContactFinded(contact, this->hSearch); +} + +void CContactSearch::BlockWhileSearch() +{ + this->isSeachFinished = false; + this->isSeachFailed = false; + while (!this->isSeachFinished && !this->isSeachFailed) + Sleep(1); +} diff --git a/plugins/!Deprecated/Skype/src/skypekit/search.h b/plugins/!Deprecated/Skype/src/skypekit/search.h new file mode 100644 index 0000000000..dde9a043e3 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skypekit/search.h @@ -0,0 +1,29 @@ +#pragma once + +#include "common.h" +#include "contact.h" + +class CContactSearch : public ContactSearch +{ +public: + typedef DRef Ref; + typedef DRefs Refs; + + bool isSeachFinished; + bool isSeachFailed; + + CContactSearch(unsigned int oid, CSkypeProto* _ppro); + + void OnChange(int prop); + void OnNewResult(const ContactRef &contact, const uint &rankValue); + + __forceinline void SetProtoInfo(HANDLE _hSearch) { + hSearch = _hSearch; + } + + void BlockWhileSearch(); + +private: + HANDLE hSearch; + CSkypeProto* proto; +}; \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skypekit/transfer.cpp b/plugins/!Deprecated/Skype/src/skypekit/transfer.cpp new file mode 100644 index 0000000000..60a41bdcfe --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skypekit/transfer.cpp @@ -0,0 +1,13 @@ +#include "..\skype.h" +#include "transfer.h" + +CTransfer::CTransfer(unsigned int oid, CSkypeProto* _ppro) : + Transfer(oid, _ppro), + proto(_ppro) +{ +} + +void CTransfer::OnChange(int prop) +{ + proto->OnTransferChanged(this->ref(), prop); +} \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/skypekit/transfer.h b/plugins/!Deprecated/Skype/src/skypekit/transfer.h new file mode 100644 index 0000000000..f01d48d328 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/skypekit/transfer.h @@ -0,0 +1,17 @@ +#pragma once + +#include "common.h" + +class CTransfer : public Transfer +{ +public: + typedef DRef Ref; + typedef DRefs Refs; + + CTransfer(unsigned int oid, CSkypeProto*); + +private: + CSkypeProto* proto; + + void OnChange(int prop); +}; \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/stdafx.cpp b/plugins/!Deprecated/Skype/src/stdafx.cpp new file mode 100644 index 0000000000..102b3be23c --- /dev/null +++ b/plugins/!Deprecated/Skype/src/stdafx.cpp @@ -0,0 +1 @@ +#include "skype.h" diff --git a/plugins/!Deprecated/Skype/src/string_list.h b/plugins/!Deprecated/Skype/src/string_list.h new file mode 100644 index 0000000000..7cf3b0aee7 --- /dev/null +++ b/plugins/!Deprecated/Skype/src/string_list.h @@ -0,0 +1,61 @@ +#pragma once + +#include +#include + +class StringList +{ +private: + std::vector strings; + +public: + StringList() {} + StringList(const wchar_t* string, const wchar_t *delimeters = L" ") + { + wchar_t *data = ::mir_wstrdup(string); + if (data) + { + wchar_t *p = ::wcstok(data, delimeters); + if (p) + { + this->strings.push_back(p); + while (p = wcstok(NULL, delimeters)) + { + this->strings.push_back(p); + } + } + ::mir_free(data); + } + } + virtual ~StringList() { } + + __inline const wchar_t *operator[](size_t idx) const + { + return (idx >= 0 && idx < this->size()) ? this->strings[idx].c_str() : NULL; + } + + __inline void insert(const wchar_t* p) + { + this->strings.push_back(::mir_wstrdup(p)); + } + + __inline bool contains(const wchar_t* p) const + { + return std::find(this->strings.begin(), this->strings.end(), p) != this->strings.end(); + } + + __inline size_t size() const + { + return this->strings.size(); + } + + __inline bool empty() const + { + return this->strings.empty(); + } + + __inline void clear() + { + this->strings.clear(); + } +}; \ No newline at end of file diff --git a/plugins/!Deprecated/Skype/src/version.h b/plugins/!Deprecated/Skype/src/version.h new file mode 100644 index 0000000000..11d4ede64f --- /dev/null +++ b/plugins/!Deprecated/Skype/src/version.h @@ -0,0 +1,15 @@ +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 11 +#define __RELEASE_NUM 0 +#define __BUILD_NUM 2 + +#include + +#define __PLUGIN_NAME "Skype protocol" +#define __INTERNAL_NAME "Skype" +#define __FILENAME "Skype.dll" +#define __DESCRIPTION "Skype protocol support for Miranda NG." +#define __AUTHOR "unsane, mataes, ghazan" +#define __AUTHOREMAIL "mataes2007@gmail.com" +#define __AUTHORWEB "http://miranda-ng.org/p/Skype/" +#define __COPYRIGHT "© 2012-14 Miranda NG team" diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp index d93331eb5d..8edb1431e8 100644 --- a/plugins/PluginUpdater/src/DlgUpdate.cpp +++ b/plugins/PluginUpdater/src/DlgUpdate.cpp @@ -521,6 +521,8 @@ static renameTable[] = { _T("dbx_tree.dll"), _T("Plugins\\dbx_mmap.dll") }, { _T("rc4.dll"), NULL }, { _T("athena.dll"), NULL }, + { _T("skype.dll"), NULL }, + { _T("skypekit.exe"), NULL }, #else { _T("skype.dll"), _T("Plugins\\skypeclassic.dll") }, #endif -- cgit v1.2.3