From 578c3d4a75046cc06dfa247b437f04fc542c36a9 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Fri, 28 Dec 2012 20:34:31 +0000 Subject: - added password changing git-svn-id: http://svn.miranda-ng.org/main/trunk@2875 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/src/skype_account.cpp | 104 ++++++++++++++++++++++++++++++++-- 1 file changed, 98 insertions(+), 6 deletions(-) (limited to 'protocols/Skype/src/skype_account.cpp') diff --git a/protocols/Skype/src/skype_account.cpp b/protocols/Skype/src/skype_account.cpp index 34cac051a5..6002061a6f 100644 --- a/protocols/Skype/src/skype_account.cpp +++ b/protocols/Skype/src/skype_account.cpp @@ -12,11 +12,6 @@ void CSkypeProto::OnAccountChanged(int prop) { this->ForkThread(&CSkypeProto::SignInAsync, 0); //this->SignInAsync(this); - - CContact::AVAILABILITY status; - this->account->GetPropAvailability(status); - if (status != CContact::CONNECTING && status >= CContact::ONLINE) - this->SetStatus(this->SkypeToMirandaStatus(status)); } if (loginStatus == CAccount::LOGGED_OUT) @@ -31,12 +26,28 @@ void CSkypeProto::OnAccountChanged(int prop) ACKRESULT_FAILED, NULL, this->SkypeToMirandaLoginError(whyLogout)); - + this->ShowNotification(CSkypeProto::LogoutReasons[whyLogout - 1]); + + if (this->rememberPassword && whyLogout == CAccount::INCORRECT_PASSWORD) + { + this->rememberPassword = false; + if (this->password) + ::mir_free(this->password); + } } } break; + case CAccount::P_PWDCHANGESTATUS: + { + CAccount::PWDCHANGESTATUS status; + this->account->GetPropPwdchangestatus(status); + if (status != CAccount::PWD_CHANGING) + this->ShowNotification(CSkypeProto::PasswordChangeReasons[status]); + } + break; + //case CAccount::P_AVATAR_IMAGE: case CAccount::P_AVATAR_TIMESTAMP: this->UpdateProfileAvatar(this->account.fetch()); @@ -49,10 +60,91 @@ void CSkypeProto::OnAccountChanged(int prop) case CAccount::P_PROFILE_TIMESTAMP: this->UpdateProfile(this->account.fetch()); + break; + + /*case CAccount::P_AVAILABILITY: + { + CContact::AVAILABILITY status; + this->account->GetPropAvailability(status); + if (status != CContact::CONNECTING && status >= CContact::ONLINE) + this->SetStatus(this->SkypeToMirandaStatus(status)); + } + break;*/ } } bool CSkypeProto::IsOnline() { return this->m_iStatus > ID_STATUS_OFFLINE; +} + +void __cdecl CSkypeProto::SignInAsync(void*) +{ + if ( !this->rememberPassword) + ::mir_free(this->password); + else + { + ::CallService(MS_DB_CRYPT_ENCODESTRING, ::strlen(this->password), LPARAM(this->password)); + } + + this->LoadOwnInfo(this); + this->LoadContactList(this); + + this->SetStatus(this->m_iDesiredStatus); +} + +bool CSkypeProto::SignIn(int status) +{ + this->login = ::DBGetString(NULL, this->m_szModuleName, SKYPE_SETTINGS_LOGIN); + if ( !this->login || !::strlen(this->login)) + { + this->m_iStatus = ID_STATUS_OFFLINE; + this->SendBroadcast(ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID); + this->ShowNotification( + TranslateT("You have not entered a Skype name.\n\ + Configure this in Options->Network->Skype and try again.")); + } + else if (this->skype->GetAccount(this->login, this->account)) + { + if ( !this->rememberPassword) + { + if (this->password) + ::mir_free(this->password); + this->password = ::DBGetString(NULL, this->m_szModuleName, SKYPE_SETTINGS_PASSWORD); + if ( !this->password || !::strlen(this->password)) + { + if (this->password) + ::mir_free(this->password); + 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; + } + } + else ::CallService(MS_DB_CRYPT_DECODESTRING, ::strlen(this->password), LPARAM(this->password)); + } + + this->account.fetch(); + this->account->SetOnAccountChangedCallback( + (CAccount::OnAccountChanged)&CSkypeProto::OnAccountChanged, + this); + + int port = this->GetSettingWord("Port", rand() % 10000 + 10000); + this->skype->SetInt(SETUPKEY_PORT, port); + this->skype->SetInt(SETUPKEY_DISABLE_PORT80, (int)!this->GetSettingByte("UseAlternativePorts", 1)); + + this->InitProxy(); + + this->account->LoginWithPassword(this->password, false, false); + + return true; + } + + return false; } \ No newline at end of file -- cgit v1.2.3