From 1a0b04b27c21311555f39d6a9cebd3b43d5615b8 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Thu, 27 Sep 2012 19:03:00 +0000 Subject: - full worked skype login - some minor fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@1689 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/Skype.vcxproj | 2 +- protocols/Skype/Skype.vcxproj.filters | 65 ---------------------------- protocols/Skype/src/skype_proto.cpp | 71 ++++++++++++++++++++----------- protocols/Skype/src/skype_proto.h | 24 +++++++---- protocols/Skype/src/skype_settings.cpp | 2 +- protocols/Skype/src/skype_subclassing.cpp | 14 +++--- protocols/Skype/src/skype_utils.cpp | 7 ++- 7 files changed, 78 insertions(+), 107 deletions(-) delete mode 100644 protocols/Skype/Skype.vcxproj.filters (limited to 'protocols') diff --git a/protocols/Skype/Skype.vcxproj b/protocols/Skype/Skype.vcxproj index cc64210e5d..9adcad1ae5 100644 --- a/protocols/Skype/Skype.vcxproj +++ b/protocols/Skype/Skype.vcxproj @@ -97,7 +97,7 @@ - + diff --git a/protocols/Skype/Skype.vcxproj.filters b/protocols/Skype/Skype.vcxproj.filters deleted file mode 100644 index ef8f0e7bab..0000000000 --- a/protocols/Skype/Skype.vcxproj.filters +++ /dev/null @@ -1,65 +0,0 @@ - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Resource Filess - - - Resource Filess - - - - - {13e9b105-554f-4080-b7de-8adf0f43b9f6} - - - {901463af-0f59-4125-b874-1662b095d403} - - - {b14a0070-da9c-49e8-8a47-d93df5eed672} - - - - - - \ No newline at end of file diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index 18cc3a9e52..4c21d1ae95 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -2,14 +2,15 @@ CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName) { - this->isOffline = true; this->m_iVersion = 2; this->m_iStatus = ID_STATUS_OFFLINE; this->m_tszUserName = mir_tstrdup(userName); this->m_szModuleName = mir_strdup(protoName); this->m_szProtoName = mir_strdup(protoName); - _strlwr(m_szProtoName); - this->m_szProtoName[0] = toupper(m_szProtoName[0]); + //_strlwr(m_szProtoName); + //this->m_szProtoName[0] = toupper(m_szProtoName[0]); + + this->signin_lock = CreateMutex(0, false, 0); TCHAR name[128]; mir_sntprintf(name, SIZEOF(name), TranslateT("%s connection"), this->m_tszUserName); @@ -31,6 +32,8 @@ CSkypeProto::~CSkypeProto() Netlib_CloseHandle(this->hNetlibUser); this->hNetlibUser = NULL; + CloseHandle(this->signin_lock); + mir_free(this->m_szProtoName); mir_free(this->m_szModuleName); mir_free(this->m_tszUserName); @@ -94,34 +97,43 @@ int __cdecl CSkypeProto::SetApparentMode( HANDLE hContact, int mode ) { retur int CSkypeProto::SetStatus(int new_status) { - switch(new_status) + if (new_status == this->m_iStatus) + return 0; + + int old_status = this->m_iStatus; + this->m_iDesiredStatus = new_status; + + if (new_status == ID_STATUS_OFFLINE && old_status != ID_STATUS_OFFLINE) { - case ID_STATUS_OFFLINE: - if ( !this->isOffline) - { - this->isOffline = true; - this->account->Logout(false); - this->account->BlockWhileLoggingOut(); - }; - break; - - case ID_STATUS_ONLINE: - - char* sn = mir_t2a(this->GetSettingString(NULL, "SkypeName")); - if (g_skype->GetAccount(sn, this->account)) + this->m_iStatus = new_status; + //todo: set all status to offline + this->account->Logout(true); + this->account->BlockWhileLoggingOut(); + } + else + { + this->m_iStatus = new_status; + if (old_status == ID_STATUS_OFFLINE) { - this->isOffline = false; - char* pw = mir_t2a(this->GetDecodeSettingString(NULL, "Password")); - this->account->LoginWithPassword(pw, false, false); - this->account->BlockWhileLoggingIn(); + this->login = this->GetSettingString(SKYPE_SETTINGS_LOGIN); + if (g_skype->GetAccount(mir_u2a(login), this->account)) + { + this->m_iStatus = ID_STATUS_CONNECTING; + this->password = this->GetDecodeSettingString(SKYPE_SETTINGS_PASSWORD); + + this->ForkThread(&CSkypeProto::SignIn, this); + } } - break; + + //todo: change skype status } + this->SendBroadcast(ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, this->m_iStatus); + return 0; } -HANDLE __cdecl CSkypeProto::GetAwayMsg( HANDLE hContact ) { return 0; } +HANDLE __cdecl CSkypeProto::GetAwayMsg(HANDLE hContact) { return 0; } int __cdecl CSkypeProto::RecvAwayMsg( HANDLE hContact, int mode, PROTORECVEVENT* evt ) { return 0; } int __cdecl CSkypeProto::SendAwayMsg( HANDLE hContact, HANDLE hProcess, const char* msg ) { return 0; } int __cdecl CSkypeProto::SetAwayMsg( int m_iStatus, const TCHAR* msg ) { return 0; } @@ -150,5 +162,16 @@ char* CSkypeProto::ModuleName() bool CSkypeProto::IsOffline() { - return this->isOffline; + return this->m_iStatus == ID_STATUS_OFFLINE; +} + +void __cdecl CSkypeProto::SignIn(void*) +{ + WaitForSingleObject(&this->signin_lock, INFINITE); + + this->account->LoginWithPassword(mir_u2a(this->password), false, false); + this->account->BlockWhileLoggingIn(); + this->SetStatus(this->m_iDesiredStatus); + + ReleaseMutex(this->signin_lock); } \ No newline at end of file diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index bbd6a37926..5f41c3dc01 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -74,29 +74,37 @@ public: bool IsOffline(); protected: - bool isOffline; CAccount::Ref account; - TCHAR* password; - HANDLE hNetlibUser; - void Log(const char* fmt, ...); + + TCHAR* login; + TCHAR* password; + + HANDLE hNetlibUser; + void Log(const char* fmt, ...); + + HANDLE signin_lock; + void __cdecl SignIn(void*); + void CreateService(const char* szService, SkypeServiceFunc serviceProc); void CreateServiceParam(const char* szService, SkypeServiceFunc serviceProc, LPARAM lParam); HANDLE CreateHookableEvent(const char* szService); void HookEvent(const char*, SkypeEventFunc); + + int SendBroadcast(int type, int result, HANDLE hProcess, LPARAM lParam); int SendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam); void ForkThread(SkypeThreadFunc, void*); HANDLE ForkThreadEx(SkypeThreadFunc, void*, UINT* threadID = NULL); - TCHAR* GetSettingString(const char *szSetting, TCHAR* defVal = NULL); - TCHAR* GetSettingString(HANDLE hContact, const char *szSetting, TCHAR* defVal = NULL); + 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); + 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); diff --git a/protocols/Skype/src/skype_settings.cpp b/protocols/Skype/src/skype_settings.cpp index 3222605577..59ea576d93 100644 --- a/protocols/Skype/src/skype_settings.cpp +++ b/protocols/Skype/src/skype_settings.cpp @@ -13,7 +13,7 @@ TCHAR* CSkypeProto::GetSettingString(HANDLE hContact, const char *szSetting, TCH TCHAR* CSkypeProto::GetDecodeSettingString(const char *szSetting, TCHAR* defVal) { - return this->GetSettingString(NULL, szSetting, defVal); + return this->GetDecodeSettingString(NULL, szSetting, defVal); } TCHAR* CSkypeProto::GetDecodeSettingString(HANDLE hContact, const char *szSetting, TCHAR* defVal) diff --git a/protocols/Skype/src/skype_subclassing.cpp b/protocols/Skype/src/skype_subclassing.cpp index 04b4a82b74..115d6e044b 100644 --- a/protocols/Skype/src/skype_subclassing.cpp +++ b/protocols/Skype/src/skype_subclassing.cpp @@ -12,22 +12,22 @@ CAccount::CAccount(unsigned int oid, SERootObject* root) : Account(oid, root) void CAccount::OnChange(int prop) { - if (prop == Account::P_STATUS) + if (prop == CAccount::P_STATUS) { - Account::STATUS loginStatus; + CAccount::STATUS loginStatus; this->GetPropStatus(loginStatus); - if (loginStatus == Account::LOGGED_IN) + if (loginStatus == CAccount::STATUS::LOGGED_IN) this->isLoggedOut = false; - if (loginStatus == Account::LOGGED_OUT) + if (loginStatus == CAccount::STATUS::LOGGED_OUT) { this->isLoggedOut = true; - Account::LOGOUTREASON whyLogout; + CAccount::LOGOUTREASON whyLogout; this->GetPropLogoutreason(whyLogout); - /*if (whyLogout != Account::LOGOUT_CALLED) + if (whyLogout != Account::LOGOUT_CALLED) { printf("%s\n", (const char*)tostring(whyLogout)); - }*/ + } } } }; diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp index 66529fb097..34471d14be 100644 --- a/protocols/Skype/src/skype_utils.cpp +++ b/protocols/Skype/src/skype_utils.cpp @@ -41,11 +41,16 @@ void CSkypeProto::HookEvent(const char* szEvent, SkypeEventFunc handler) HookEventObj(szEvent, (MIRANDAHOOKOBJ)*( void**)&handler, this); } +int CSkypeProto::SendBroadcast(int type, int result, HANDLE hProcess, LPARAM lParam) +{ + return this->SendBroadcast(NULL, type, result, hProcess, lParam); +} + int CSkypeProto::SendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam) { ACKDATA ack = {0}; ack.cbSize = sizeof(ACKDATA); - ack.szModule = m_szModuleName; + ack.szModule = this->m_szModuleName; ack.hContact = hContact; ack.type = type; ack.result = result; -- cgit v1.2.3