From c680e4f025f254a3df4154b4f588601ed31119d9 Mon Sep 17 00:00:00 2001 From: Nicolas Jager <nicolas.jager@savoirfairelinux.com> Date: Tue, 6 Dec 2016 16:02:23 -0500 Subject: [PATCH] fix : various fixes - fix : upon creation of 2+ accounts, the blockchain name appears as registerable regardless of check. - fix : after having already created account without registering a blockchain name, editing the account to add a blockchain name succeeds but does not return to user to the UI from the loading page. - fix : editing account details more than once, does not return the user to the UI. - fix : click to accept modification for an account without any data changed result to wrong behaviour. Change-Id: I08f19e6c902070b6260c466670badf3eab606934 Tuleap: #790 --- MainPage.xaml.cpp | 17 +++++++++++++++++ MainPage.xaml.h | 3 +++ RingD.cpp | 43 ++++++++++++++++++++++++++++++++++--------- RingD.h | 4 ++++ SmartPanel.xaml | 2 +- SmartPanel.xaml.cpp | 21 +++++++++++++++++++-- 6 files changed, 78 insertions(+), 12 deletions(-) diff --git a/MainPage.xaml.cpp b/MainPage.xaml.cpp index 52e093f..61d5109 100644 --- a/MainPage.xaml.cpp +++ b/MainPage.xaml.cpp @@ -358,6 +358,11 @@ void RingClientUWP::MainPage::OnregistrationStateErrorGeneric(const std::string& void RingClientUWP::MainPage::OnregistrationStateRegistered() { showLoadingOverlay(false, false); + + /* do not connect those delegates before initial registration on dht is fine. + Otherwise your going to mess with the wizard */ + RingD::instance->nameRegistred += ref new RingClientUWP::NameRegistred(this, &RingClientUWP::MainPage::OnnameRegistred); + RingD::instance->volatileDetailsChanged += ref new RingClientUWP::VolatileDetailsChanged(this, &RingClientUWP::MainPage::OnvolatileDetailsChanged); } @@ -365,3 +370,15 @@ void RingClientUWP::MainPage::OncallPlaced(Platform::String ^callId) { showFrame(_welcomeFrame_); } + + +void RingClientUWP::MainPage::OnnameRegistred(bool status) +{ + showLoadingOverlay(false, false); +} + + +void RingClientUWP::MainPage::OnvolatileDetailsChanged(const std::string &accountId, const std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<const std::string, std::string>>> &details) +{ + showLoadingOverlay(false, false); +} diff --git a/MainPage.xaml.h b/MainPage.xaml.h index f04bc26..efa59b6 100644 --- a/MainPage.xaml.h +++ b/MainPage.xaml.h @@ -59,6 +59,7 @@ private: void DisplayProperties_DpiChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args); EventRegistrationToken dpiChangedtoken; Rect bounds; + bool editionMode = false; void _toggleSmartBoxButton__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void showFrame(Windows::UI::Xaml::Controls::Frame^ frame); @@ -73,5 +74,7 @@ private: void OnregistrationStateErrorGeneric(const std::string& accountId); void OnregistrationStateRegistered(); void OncallPlaced(Platform::String ^callId); + void OnnameRegistred(bool status); + void OnvolatileDetailsChanged(const std::string &accountId, const std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<const std::string, std::string>>> &details); }; } diff --git a/RingD.cpp b/RingD.cpp index 0f9563f..9f6c6ac 100644 --- a/RingD.cpp +++ b/RingD.cpp @@ -544,7 +544,7 @@ RingD::registerCallbacks() } else if (state == DRing::Account::States::TRYING) { CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High, - ref new DispatchedHandler([=]() { + ref new DispatchedHandler([=]() { setLoadingStatusText("Attempting to register account...", "#ff00f0f0"); })); } @@ -584,7 +584,7 @@ RingD::registerCallbacks() { if (debugModeOn_) { dispatcher->RunAsync(CoreDispatcherPriority::High, - ref new DispatchedHandler([=]() { + ref new DispatchedHandler([=]() { std::string displayMsg = msg.substr(56); setLoadingStatusText(Utils::toPlatformString(displayMsg.substr(0,40) + "..."), "#ff000000"); DMSG_(msg); @@ -744,6 +744,12 @@ RingD::registerCallbacks() break; } })); + }), + DRing::exportable_callback<DRing::ConfigurationSignal::VolatileDetailsChanged>( + [this](const std::string& accountId, const std::map<std::string, std::string>& details) { + ref new DispatchedHandler([=]() { + volatileDetailsChanged(accountId, details); + }); }) }; registerConfHandlers(nameRegistrationHandlers); @@ -1007,16 +1013,28 @@ RingD::dequeueTasks() { auto account = AccountListItemsViewModel::instance->findItem(Utils::toPlatformString(task->_accountId_new))->_account; std::map<std::string, std::string> accountDetails = DRing::getAccountDetails(task->_accountId_new); - accountDetails[DRing::Account::ConfProperties::UPNP_ENABLED] = (account->_upnpState) ? ring::TRUE_STR : ring::FALSE_STR; + std::map<std::string, std::string> accountDetailsOld(accountDetails); + + + accountDetails[DRing::Account::ConfProperties::ALIAS] = Utils::toString(account->name_); - if (accountDetails[DRing::Account::ConfProperties::TYPE] == "RING") + if (accountDetails[DRing::Account::ConfProperties::TYPE] == "RING") { + if (accountDetails == accountDetailsOld) + break; + + accountDetails[DRing::Account::ConfProperties::UPNP_ENABLED] = (account->_upnpState) ? ring::TRUE_STR : ring::FALSE_STR; CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High, ref new DispatchedHandler([=]() { - auto frame = dynamic_cast<Frame^>(Window::Current->Content); - dynamic_cast<RingClientUWP::MainPage^>(frame->Content)->showLoadingOverlay(true, true); - })); - + auto frame = dynamic_cast<Frame^>(Window::Current->Content); + dynamic_cast<RingClientUWP::MainPage^>(frame->Content)->showLoadingOverlay(true, true); + })); + } + else { + accountDetails[DRing::Account::ConfProperties::HOSTNAME] = Utils::toString(account->_sipHostname); + accountDetails[DRing::Account::ConfProperties::PASSWORD] = Utils::toString(account->_sipPassword); + accountDetails[DRing::Account::ConfProperties::USERNAME] = Utils::toString(account->_sipUsername); + } DRing::setAccountDetails(Utils::toString(account->accountID_), accountDetails); break; @@ -1091,11 +1109,18 @@ RingD::dequeueTasks() case Request::RegisterName: { auto accountDetails = DRing::getAccountDetails(task->_accountId_new); + bool result; if (accountDetails[DRing::Account::ConfProperties::USERNAME].empty()) registerName_new(task->_accountId_new, task->_password_new, task->_publicUsername_new); else - DRing::registerName(task->_accountId_new, task->_password_new, task->_publicUsername_new); + result = DRing::registerName(task->_accountId_new, task->_password_new, task->_publicUsername_new); + + CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High, + ref new DispatchedHandler([=]() { + nameRegistred(result); + })); + //const wchar_t* toto = task->_accountId->Data(); //auto accountId = ref new String(toto);// Utils::toString(task->_accountId); diff --git a/RingD.h b/RingD.h index e47ce0a..05f8935 100644 --- a/RingD.h +++ b/RingD.h @@ -45,6 +45,8 @@ delegate void RegistrationStateRegistered(); delegate void SetLoadingStatusText(String^ statusText, String^ color); delegate void CallsListRecieved(const std::vector<std::string>& callsList); delegate void AudioMuted(const std::string& callId, bool state); +delegate void NameRegistred(bool status); +delegate void VolatileDetailsChanged(const std::string& accountId, const std::map<std::string, std::string>& details); using SharedCallback = std::shared_ptr<DRing::CallbackWrapperBase>; using namespace std::placeholders; @@ -160,6 +162,8 @@ internal: event SetLoadingStatusText^ setLoadingStatusText; event CallsListRecieved^ callsListRecieved; // est implemente a la base pour regler le probleme du boutton d'appel qui est present lorsqu'un appel est en cours, mais il n'est pas utilise. Voir si ca peut servir a autre chose event AudioMuted^ audioMuted; + event NameRegistred^ nameRegistred; + event VolatileDetailsChanged^ volatileDetailsChanged; private: /* sub classes */ diff --git a/SmartPanel.xaml b/SmartPanel.xaml index 622829e..89ecb16 100644 --- a/SmartPanel.xaml +++ b/SmartPanel.xaml @@ -532,7 +532,7 @@ <TextBlock Style="{StaticResource TextSegoeStyle-20pt-black}" Margin="0,0,10,0" Text=""/> - <TextBlock Text="Archive password"/> + <TextBlock Text="Password"/> </StackPanel> <Grid Margin="10"> <Grid.ColumnDefinitions> diff --git a/SmartPanel.xaml.cpp b/SmartPanel.xaml.cpp index 87f5486..c13c4ba 100644 --- a/SmartPanel.xaml.cpp +++ b/SmartPanel.xaml.cpp @@ -365,6 +365,8 @@ void RingClientUWP::Views::SmartPanel::_addAccountBtn__Click(Platform::Object^ s _RegisterStateEdition_->IsOn = true; _accountAliasTextBox_->Text = ""; _usernameTextBox_->Text = ""; + + checkStateAddAccountMenu(); } void RingClientUWP::Views::SmartPanel::_createAccountYes__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) @@ -696,7 +698,8 @@ void RingClientUWP::Views::SmartPanel::checkStateAddAccountMenu() if (isRingAccountType) { bool isPublic = _RegisterState_->IsOn; - bool isUsernameValid = (_usernameValid_->Visibility == Windows::UI::Xaml::Visibility::Visible) ? true : false; + bool isUsernameValid = (_usernameValid_->Visibility == Windows::UI::Xaml::Visibility::Visible + && !_usernameTextBox_->Text->IsEmpty()) ? true : false; bool isPasswordValid = (_ringPasswordBoxAccountCreation_->Password->IsEmpty()) ? false : true; @@ -723,6 +726,13 @@ void RingClientUWP::Views::SmartPanel::checkStateAddAccountMenu() _passwordCheckInvalid_->Visibility = Windows::UI::Xaml::Visibility::Visible; } + if (isUsernameValid) { + _usernameValid_->Visibility = Windows::UI::Xaml::Visibility::Visible; + _usernameInvalid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; + } else { + _usernameValid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; + _usernameInvalid_->Visibility = Windows::UI::Xaml::Visibility::Visible; + } if (isPublic) if (isUsernameValid && isAccountAlias && isRingPasswordCheck && isPasswordValid) @@ -1119,7 +1129,14 @@ void RingClientUWP::Views::SmartPanel::_acceptAccountModification__Click(Platfor account->name_ = _accountAliasTextBoxEdition_->Text; - account->_upnpState = _upnpState_->IsOn; + if (account->accountType_ == "RING") { + account->_upnpState = _upnpState_->IsOn; + } + else { + account->_sipHostname = _sipHostnameEdition_->Text; + account->_sipUsername = _sipUsernameEditionTextBox_->Text; + account->_sipPassword = _sipPasswordEdition_->Password; + } RingD::instance->updateAccount(accountId); } -- GitLab