From 4db6c5178cbd85e29e714a63ee5b1e8fc9881bae Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Thu, 27 Sep 2012 05:44:38 +0000 Subject: - added skype sublassing - CSkupeProto funcs moved to spec files - some minor changes git-svn-id: http://svn.miranda-ng.org/main/trunk@1675 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/Skype.vcxproj | 22 ++++++++++----- protocols/Skype/Skype.vcxproj.filters | 15 +++++++++++ protocols/Skype/src/skype.cpp | 6 ++--- protocols/Skype/src/skype.h | 4 +-- protocols/Skype/src/skype_dialogs.cpp | 9 +++++++ protocols/Skype/src/skype_events.cpp | 1 + protocols/Skype/src/skype_proto.cpp | 43 ++++++----------------------- protocols/Skype/src/skype_proto.h | 9 ++++++- protocols/Skype/src/skype_settings.cpp | 33 +++++++++++++++++++++++ protocols/Skype/src/skype_subclassing.cpp | 45 +++++++++++++++++++++++++++++++ protocols/Skype/src/skype_subclassing.h | 27 +++++++++++++++++++ protocols/Skype/src/skype_utils.cpp | 21 +++++++++++++++ protocols/Skype/src/version.h | 1 + 13 files changed, 188 insertions(+), 48 deletions(-) create mode 100644 protocols/Skype/src/skype_events.cpp create mode 100644 protocols/Skype/src/skype_settings.cpp create mode 100644 protocols/Skype/src/skype_subclassing.cpp create mode 100644 protocols/Skype/src/skype_subclassing.h create mode 100644 protocols/Skype/src/skype_utils.cpp (limited to 'protocols/Skype') diff --git a/protocols/Skype/Skype.vcxproj b/protocols/Skype/Skype.vcxproj index 5fd7ff3d49..4c852865c9 100644 --- a/protocols/Skype/Skype.vcxproj +++ b/protocols/Skype/Skype.vcxproj @@ -45,12 +45,14 @@ + NotUsing Level3 Disabled WIN32;_DEBUG;_WINDOWS;_USRDLL;SKYPE_EXPORTS;%(PreprocessorDefinitions) ..\..\include;..\..\plugins\ExternalAPI;..\..\..\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\api;..\..\..\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\ipc;..\..\..\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\types;..\..\..\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading;..\..\..\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading\win;..\..\..\SkypeKit\SDK\ipc\cpp;..\..\..\SkypeKit\SDK\ipc\cpp\VideoBuffers;..\..\..\SkypeKit\SDK\ipc\cpp\platform\se;..\..\..\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include;..\..\..\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include\openssl;..\..\..\SkypeKit\SDK\ipc\cpp\ssl\cyassl\ctaocrypt\include;%(AdditionalIncludeDirectories) false true + skype.h 4996;%(DisableSpecificWarnings) MultiThreadedDebugDLL @@ -62,8 +64,6 @@ Ws2_32.lib;Advapi32.lib;skypekit-cyassl_lib.lib;skypekit-cppwrapper_2_lib.lib;%(AdditionalDependencies) - false - /PDBALTPATH:%_PDB% %(AdditionalOptions) _DEBUG;%(PreprocessorDefinitions) @@ -73,11 +73,13 @@ Level3 + Use Full true true WIN32;NDEBUG;_WINDOWS;_USRDLL;SKYPE_EXPORTS;%(PreprocessorDefinitions) - ..\..\include;..\..\plugins\ExternalAPI;..\..\..\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\api;..\..\..\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\ipc;..\..\..\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\types;..\..\..\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading;..\..\..\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading\win;..\..\..\SkypeKit\SDK\ipc\cpp;..\..\..\SkypeKit\SDK\ipc\cpp\VideoBuffers;..\..\..\SkypeKit\SDK\ipc\cpp\platform\se;..\..\..\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include;..\..\..\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include\openssl;..\..\..\SkypeKit\SDK\ipc\cpp\ssl\cyassl\ctaocrypt\include;%(AdditionalIncludeDirectories) + ..\..\include;..\..\plugins\ExternalAPI;..\..\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\api;..\..\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\ipc;..\..\..\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\types;..\..\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading;..\..\SkypeKit\SDK\interfaces\skype\cpp_embedded\src\platform\threading\win;..\..\SkypeKit\SDK\ipc\cpp;..\..\SkypeKit\SDK\ipc\cpp\VideoBuffers;..\..\SkypeKit\SDK\ipc\cpp\platform\se;..\..\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include;..\..\SkypeKit\SDK\ipc\cpp\ssl\cyassl\include\openssl;..\..\SkypeKit\SDK\ipc\cpp\ssl\cyassl\ctaocrypt\include;%(AdditionalIncludeDirectories) + skype.h 4996;%(DisableSpecificWarnings) @@ -87,9 +89,7 @@ true false /PDBALTPATH:%_PDB% - Ws2_32.lib;Advapi32.lib;skypekit-cyassl_lib.lib;skypekit-cppwrapper_2_lib.lib;%(AdditionalDependencies) - $(SolutionDir)\lib;$(SolutionDir)..\..\SkypeKit\SDK\interfaces\skype\cpp_embedded\build - $(IntDir)$(TargetName).lib + $(SolutionDir)..\..\SkypeKit\SDK\interfaces\skype\cpp_embedded\build\skypekit-cyassl_lib.lib;$(SolutionDir)..\..\SkypeKit\SDK\interfaces\skype\cpp_embedded\build\skypekit-cppwrapper_2_lib.lib;%(AdditionalDependencies) NDEBUG;%(PreprocessorDefinitions) @@ -97,15 +97,23 @@ + - + + Create + Create + + + + + diff --git a/protocols/Skype/Skype.vcxproj.filters b/protocols/Skype/Skype.vcxproj.filters index c23255e856..e38dad19a3 100644 --- a/protocols/Skype/Skype.vcxproj.filters +++ b/protocols/Skype/Skype.vcxproj.filters @@ -10,6 +10,18 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + @@ -24,6 +36,9 @@ Header Files + + Header Files + diff --git a/protocols/Skype/src/skype.cpp b/protocols/Skype/src/skype.cpp index 01df986a0e..b45462ede8 100644 --- a/protocols/Skype/src/skype.cpp +++ b/protocols/Skype/src/skype.cpp @@ -4,13 +4,13 @@ int hLangpack; HINSTANCE g_hInstance; -Skype* g_skype; +CSkype* g_skype; PLUGININFOEX pluginInfo = { sizeof(PLUGININFOEX), __PLUGIN_NAME, - PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __VERSION_DWORD, __DESCRIPTION, __AUTHOR, __AUTHOREMAIL, @@ -91,7 +91,7 @@ int LoadKeyPair() extern "C" int __declspec(dllexport) Load(void) { - g_skype = new Skype(); + g_skype = new CSkype(); LoadKeyPair(); g_skype->init(keyBuf, "127.0.0.1", 8963, "streamlog.txt"); g_skype->start(); diff --git a/protocols/Skype/src/skype.h b/protocols/Skype/src/skype.h index 076c26da80..8fd0390354 100644 --- a/protocols/Skype/src/skype.h +++ b/protocols/Skype/src/skype.h @@ -59,8 +59,8 @@ extern HINSTANCE g_hInstance; #undef OCSP_REQUEST #undef OCSP_RESPONSE -#include +#include "skype_subclassing.h" static const char* g_keyFileName = "..\\..\\..\\SkypeKit\\keypair.crt"; -extern Skype* g_skype; \ No newline at end of file +extern CSkype* g_skype; \ No newline at end of file diff --git a/protocols/Skype/src/skype_dialogs.cpp b/protocols/Skype/src/skype_dialogs.cpp index 806843cd86..fea322746c 100644 --- a/protocols/Skype/src/skype_dialogs.cpp +++ b/protocols/Skype/src/skype_dialogs.cpp @@ -69,4 +69,13 @@ INT_PTR CALLBACK CSkypeProto::SkypeAccountProc(HWND hwnd, UINT message, WPARAM w } return FALSE; +} + +INT_PTR __cdecl CSkypeProto::SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam) +{ + return (int)CreateDialogParam( + g_hInstance, + MAKEINTRESOURCE(IDD_SKYPEACCOUNT), + (HWND)lParam, + &CSkypeProto::SkypeAccountProc, (LPARAM)this); } \ No newline at end of file diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp new file mode 100644 index 0000000000..159b64a666 --- /dev/null +++ b/protocols/Skype/src/skype_events.cpp @@ -0,0 +1 @@ +#include "skype_proto.h" diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index d4f19e4aa8..d9986db95c 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -36,15 +36,6 @@ CSkypeProto::~CSkypeProto() mir_free(this->m_tszUserName); } -INT_PTR __cdecl CSkypeProto::SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam) -{ - return (int)CreateDialogParam( - g_hInstance, - MAKEINTRESOURCE(IDD_SKYPEACCOUNT), - (HWND)lParam, - &CSkypeProto::SkypeAccountProc, (LPARAM)this); -} - HANDLE __cdecl CSkypeProto::AddToList( int flags, PROTOSEARCHRESULT* psr ) { return 0; } HANDLE __cdecl CSkypeProto::AddToListByEvent( int flags, int iContact, HANDLE hDbEvent ) { return 0; } int __cdecl CSkypeProto::Authorize( HANDLE hDbEvent ) { return 0; } @@ -88,18 +79,19 @@ int CSkypeProto::SetStatus(int new_status) if ( !this->isOffline) { this->isOffline = true; - account->Logout(false); + this->account->Logout(false); }; break; case ID_STATUS_ONLINE: - if (g_skype->GetAccount("", this->account)) + + char* sn = mir_t2a(this->GetSettingString(NULL, "SkypeName")); + if (g_skype->GetAccount(sn, this->account)) { this->isOffline = false; - account->LoginWithPassword("", false, false); - - // Loop until LoggedIn or login failure - //while ( (!account->loggedIn) && (!account->loggedOut) ) { Delay(1); }; + char* pw = mir_t2a(this->GetDecodeSettingString(NULL, "Password")); + this->account->LoginWithPassword(pw, false, false); + this->account->BlockWhileLoggingIn(); } break; } @@ -116,29 +108,10 @@ int __cdecl CSkypeProto::UserIsTyping( HANDLE hContact, int type ) { return 0 int __cdecl CSkypeProto::OnEvent( PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam ) { return 0; } -void CSkypeProto::Log(const char* fmt, ...) -{ - va_list va; - char msg[1024]; - - va_start(va, fmt); - mir_vsnprintf(msg, sizeof(msg), fmt, va); - va_end(va); - - CallService(MS_NETLIB_LOG, ( WPARAM )this->hNetlibUser, (LPARAM)msg); -} - -void CSkypeProto::CreateProtoService(const char* szService, SkypeServiceFunc serviceProc) -{ - char temp[MAX_PATH*2]; - - mir_snprintf(temp, sizeof(temp), "%s%s", this->m_szModuleName, szService); - CreateServiceFunctionObj(temp, (MIRANDASERVICEOBJ)*(void**)&serviceProc, this); -} char* CSkypeProto::ModuleName() { - return this->m_szProtoName; + return this->m_szModuleName; } bool CSkypeProto::IsOffline() diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index 414f104d3c..c31b1f1afd 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -1,6 +1,7 @@ #pragma once #include "skype.h" +#include "skype_subclassing.h" struct CSkypeProto; @@ -65,7 +66,7 @@ public: protected: bool isOffline; - Account::Ref account; + CAccount::Ref account; HANDLE hNetlibUser; void Log( const char* fmt, ... ); @@ -73,5 +74,11 @@ protected: INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam); void CreateProtoService(const char* szService, SkypeServiceFunc serviceProc); + TCHAR* GetSettingString(const char *szSetting, TCHAR* defVal = NULL); + TCHAR* GetSettingString(HANDLE hContact, const char *szSetting, TCHAR* defVal = NULL); + + TCHAR* GetDecodeSettingString(const char *szSetting, TCHAR* defVal = NULL); + TCHAR* GetDecodeSettingString(HANDLE hContact, const char *szSetting, TCHAR* defVal = NULL); + static INT_PTR CALLBACK SkypeAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); }; \ No newline at end of file diff --git a/protocols/Skype/src/skype_settings.cpp b/protocols/Skype/src/skype_settings.cpp new file mode 100644 index 0000000000..8a2d0c0bfa --- /dev/null +++ b/protocols/Skype/src/skype_settings.cpp @@ -0,0 +1,33 @@ +#include "skype_proto.h" + +TCHAR* CSkypeProto::GetSettingString(const char *szSetting, TCHAR* defVal) +{ + return this->GetSettingString(NULL, szSetting, defVal); +} + +TCHAR* CSkypeProto::GetSettingString(HANDLE hContact, const char *szSetting, TCHAR* defVal) +{ + TCHAR* result = DBGetStringW(hContact, this->m_szModuleName, szSetting); + return result != NULL ? result : defVal; +} + +TCHAR* CSkypeProto::GetDecodeSettingString(const char *szSetting, TCHAR* defVal) +{ + return this->GetSettingString(NULL, szSetting, defVal); +} + +TCHAR* CSkypeProto::GetDecodeSettingString(HANDLE hContact, const char *szSetting, TCHAR* defVal) +{ + DBVARIANT dbv; + TCHAR* result = NULL; + if ( !DBGetContactSettingString(0, this->m_szModuleName, szSetting, &dbv)) + { + CallService( + MS_DB_CRYPT_DECODESTRING, + wcslen(dbv.ptszVal) + 1, + reinterpret_cast(dbv.ptszVal)); + result = mir_wstrdup(dbv.pwszVal); + DBFreeVariant(&dbv); + } + return result; +} \ No newline at end of file diff --git a/protocols/Skype/src/skype_subclassing.cpp b/protocols/Skype/src/skype_subclassing.cpp new file mode 100644 index 0000000000..04b4a82b74 --- /dev/null +++ b/protocols/Skype/src/skype_subclassing.cpp @@ -0,0 +1,45 @@ +#include "skype_subclassing.h" + +Account* CSkype::newAccount(int oid) +{ + return new CAccount(oid, this); +} + +CAccount::CAccount(unsigned int oid, SERootObject* root) : Account(oid, root) +{ + this->isLoggedOut = true; +} + +void CAccount::OnChange(int prop) +{ + if (prop == Account::P_STATUS) + { + Account::STATUS loginStatus; + this->GetPropStatus(loginStatus); + if (loginStatus == Account::LOGGED_IN) + this->isLoggedOut = false; + + if (loginStatus == Account::LOGGED_OUT) + { + this->isLoggedOut = true; + Account::LOGOUTREASON whyLogout; + this->GetPropLogoutreason(whyLogout); + /*if (whyLogout != Account::LOGOUT_CALLED) + { + printf("%s\n", (const char*)tostring(whyLogout)); + }*/ + } + } +}; + +void CAccount::BlockWhileLoggingIn() +{ + while (this->isLoggedOut) + Sleep(1); +} + +void CAccount::BlockWhileLoggingOut() +{ + while ( !this->isLoggedOut) + Sleep(1); +}; \ No newline at end of file diff --git a/protocols/Skype/src/skype_subclassing.h b/protocols/Skype/src/skype_subclassing.h new file mode 100644 index 0000000000..466b84809e --- /dev/null +++ b/protocols/Skype/src/skype_subclassing.h @@ -0,0 +1,27 @@ +#pragma once + +#include + +class CAccount; + +class CSkype : public Skype +{ +public: + Account* newAccount(int oid); +}; + +class CAccount : public Account +{ +public: + typedef DRef Ref; + typedef DRefs Refs; + + bool isLoggedOut; + + CAccount(unsigned int oid, SERootObject* root); + void OnChange(int prop); + + void BlockWhileLoggingIn(); + void BlockWhileLoggingOut(); +}; + diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp new file mode 100644 index 0000000000..be141b3e75 --- /dev/null +++ b/protocols/Skype/src/skype_utils.cpp @@ -0,0 +1,21 @@ +#include "skype_proto.h" + +void CSkypeProto::Log(const char* fmt, ...) +{ + va_list va; + char msg[1024]; + + va_start(va, fmt); + mir_vsnprintf(msg, sizeof(msg), fmt, va); + va_end(va); + + CallService(MS_NETLIB_LOG, ( WPARAM )this->hNetlibUser, (LPARAM)msg); +} + +void CSkypeProto::CreateProtoService(const char* szService, SkypeServiceFunc serviceProc) +{ + char temp[MAX_PATH*2]; + + mir_snprintf(temp, sizeof(temp), "%s%s", this->m_szModuleName, szService); + CreateServiceFunctionObj(temp, (MIRANDASERVICEOBJ)*(void**)&serviceProc, this); +} \ No newline at end of file diff --git a/protocols/Skype/src/version.h b/protocols/Skype/src/version.h index 281233e9ec..9acc0b7ca3 100644 --- a/protocols/Skype/src/version.h +++ b/protocols/Skype/src/version.h @@ -2,6 +2,7 @@ #define __MINOR_VERSION 0 #define __RELEASE_NUM 0 #define __BUILD_NUM 1 +#define __VERSION_DWORD PLUGIN_MAKE_VERSION(0, 1, 0, 0) #define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM #define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM -- cgit v1.2.3