Commit 7168df93 authored by Nicolas Jager's avatar Nicolas Jager
Browse files

smartpanel : hardening ring account creation

Change-Id: I48e064e891118427d83c3fb3e44846dbf39d64ab
Tuleap: #1247
parent 5a197d5c
...@@ -42,7 +42,15 @@ public: ...@@ -42,7 +42,15 @@ public:
NotifyPropertyChanged("name_"); NotifyPropertyChanged("name_");
} }
} }
property String^ ringID_; property String^ ringID_ {
String^ get() {
return ringID__;
}
void set(String^ value) {
ringID__ = value;
NotifyPropertyChanged("ringID_");
}
}
property String^ accountType_; // refacto : create a enum accountType property String^ accountType_; // refacto : create a enum accountType
property String^ accountID_; property String^ accountID_;
property String^ _deviceId; property String^ _deviceId;
...@@ -62,6 +70,7 @@ protected: ...@@ -62,6 +70,7 @@ protected:
private: private:
Windows::Foundation::Collections::IVector<String^>^ devicesIdList_; Windows::Foundation::Collections::IVector<String^>^ devicesIdList_;
String^ name__; String^ name__;
String^ ringID__;
}; };
} }
......
...@@ -75,6 +75,7 @@ RingClientUWP::RingD::reloadAccountList() ...@@ -75,6 +75,7 @@ RingClientUWP::RingD::reloadAccountList()
auto alias = accountDetails.find(DRing::Account::ConfProperties::ALIAS)->second; auto alias = accountDetails.find(DRing::Account::ConfProperties::ALIAS)->second;
auto type = accountDetails.find(DRing::Account::ConfProperties::TYPE)->second; auto type = accountDetails.find(DRing::Account::ConfProperties::TYPE)->second;
auto deviceId = (type == "SIP")? std::string() : accountDetails.find(DRing::Account::ConfProperties::RING_DEVICE_ID)->second; auto deviceId = (type == "SIP")? std::string() : accountDetails.find(DRing::Account::ConfProperties::RING_DEVICE_ID)->second;
auto ringId = accountDetails.find(DRing::Account::ConfProperties::USERNAME)->second;
auto accountId = Utils::toPlatformString(*rit); auto accountId = Utils::toPlatformString(*rit);
auto account = AccountsViewModel::instance->findItem(accountId); auto account = AccountsViewModel::instance->findItem(accountId);
...@@ -82,17 +83,14 @@ RingClientUWP::RingD::reloadAccountList() ...@@ -82,17 +83,14 @@ RingClientUWP::RingD::reloadAccountList()
if (account) { if (account) {
account->name_ = Utils::toPlatformString(alias); account->name_ = Utils::toPlatformString(alias);
account->_upnpState = upnpState; account->_upnpState = upnpState;
account->accountType_ = Utils::toPlatformString(type);
account->ringID_ = Utils::toPlatformString(ringId);
accountUpdated(account); accountUpdated(account);
} }
else { else {
RingClientUWP::ViewModel::AccountsViewModel::instance->add(alias, ringID, type, *rit /*account id*/, deviceId, upnpState); RingClientUWP::ViewModel::AccountsViewModel::instance->add(alias, ringID, type, *rit /*account id*/, deviceId, upnpState);
} }
if (editModeOn_) {
auto frame = dynamic_cast<Frame^>(Window::Current->Content);
dynamic_cast<RingClientUWP::MainPage^>(frame->Content)->showLoadingOverlay(false, false);
}
} }
// load user preferences // load user preferences
...@@ -167,6 +165,12 @@ void RingClientUWP::RingD::sendSIPTextMessage(String^ message) ...@@ -167,6 +165,12 @@ void RingClientUWP::RingD::sendSIPTextMessage(String^ message)
void void
RingD::createRINGAccount(String^ alias) RingD::createRINGAccount(String^ alias)
{ {
editModeOn_ = true;
auto frame = dynamic_cast<Frame^>(Window::Current->Content);
dynamic_cast<RingClientUWP::MainPage^>(frame->Content)->showLoadingOverlay(true, true);
// refactoring : create a dedicated class constructor task and removes accountName from RingD // refactoring : create a dedicated class constructor task and removes accountName from RingD
accountName = Utils::toString(alias); accountName = Utils::toString(alias);
tasksList_.push(ref new RingD::Task(Request::AddRingAccount)); tasksList_.push(ref new RingD::Task(Request::AddRingAccount));
...@@ -175,6 +179,11 @@ RingD::createRINGAccount(String^ alias) ...@@ -175,6 +179,11 @@ RingD::createRINGAccount(String^ alias)
void void
RingD::createSIPAccount(String^ alias) RingD::createSIPAccount(String^ alias)
{ {
editModeOn_ = true;
auto frame = dynamic_cast<Frame^>(Window::Current->Content);
dynamic_cast<RingClientUWP::MainPage^>(frame->Content)->showLoadingOverlay(true, true);
// refactoring : create a dedicated class constructor task and removes accountName from RingD // refactoring : create a dedicated class constructor task and removes accountName from RingD
accountName = Utils::toString(alias); accountName = Utils::toString(alias);
tasksList_.push(ref new RingD::Task(Request::AddSIPAccount)); tasksList_.push(ref new RingD::Task(Request::AddSIPAccount));
...@@ -310,6 +319,8 @@ void ...@@ -310,6 +319,8 @@ void
RingClientUWP::RingD::startDaemon() RingClientUWP::RingD::startDaemon()
{ {
eraseCacheFolder(); eraseCacheFolder();
editModeOn_ = true;
create_task([&]() create_task([&]()
{ {
...@@ -431,16 +442,15 @@ RingClientUWP::RingD::startDaemon() ...@@ -431,16 +442,15 @@ RingClientUWP::RingD::startDaemon()
const std::string& account_id, const std::string& state, const std::string& account_id, const std::string& state,
int detailsCode, const std::string& detailsStr) int detailsCode, const std::string& detailsStr)
{ {
MSG_("<RegistrationStateChanged>: ID = " + account_id + "state = " + state); MSG_("<RegistrationStateChanged>: ID = " + account_id + " state = " + state);
if (state == DRing::Account::States::REGISTERED) { if (state == DRing::Account::States::REGISTERED) {
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High, CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() { ref new DispatchedHandler([=]() {
reloadAccountList(); reloadAccountList();
std::vector<std::string> accountList = DRing::getAccountList(); // refacto : there is already a callo to getAccountList in reloadAccountList if (editModeOn_) {
auto last_id = accountList.back();
if (!account_id.compare(last_id)) {
auto frame = dynamic_cast<Frame^>(Window::Current->Content); auto frame = dynamic_cast<Frame^>(Window::Current->Content);
dynamic_cast<RingClientUWP::MainPage^>(frame->Content)->showLoadingOverlay(false, false); dynamic_cast<RingClientUWP::MainPage^>(frame->Content)->showLoadingOverlay(false, false);
editModeOn_ = false;
} }
})); }));
} }
...@@ -451,6 +461,11 @@ RingClientUWP::RingD::startDaemon() ...@@ -451,6 +461,11 @@ RingClientUWP::RingD::startDaemon()
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High, CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() { ref new DispatchedHandler([=]() {
reloadAccountList(); reloadAccountList();
if (editModeOn_) {
auto frame = dynamic_cast<Frame^>(Window::Current->Content);
dynamic_cast<RingClientUWP::MainPage^>(frame->Content)->showLoadingOverlay(false, false);
editModeOn_ = false;
}
})); }));
}), }),
DRing::exportable_callback<DRing::Debug::MessageSend>([&](const std::string& toto) DRing::exportable_callback<DRing::Debug::MessageSend>([&](const std::string& toto)
......
...@@ -209,7 +209,7 @@ ...@@ -209,7 +209,7 @@
<TextBlock x:Name="_ringID_" <TextBlock x:Name="_ringID_"
Grid.ColumnSpan="2" Grid.ColumnSpan="2"
Style="{StaticResource TextStyle6}" Style="{StaticResource TextStyle6}"
Text="{x:Bind _account.ringID_}"/> Text="{x:Bind _account.ringID_, Mode=OneWay}"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</DataTemplate> </DataTemplate>
...@@ -483,9 +483,13 @@ ...@@ -483,9 +483,13 @@
<TextBox x:Name="_aliasTextBox_" <TextBox x:Name="_aliasTextBox_"
Margin="10" Margin="10"
PlaceholderText="Enter your username"/> PlaceholderText="Enter your username"/>
<PasswordBox Margin="10" <PasswordBox x:Name="_passwordBoxAccountCreation_"
Margin="10"
PasswordChanged="_passwordBoxAccountCreationCheck__PasswordChanged"
PlaceholderText="Enter your password"/> PlaceholderText="Enter your password"/>
<PasswordBox Margin="10" <PasswordBox x:Name="_passwordBoxAccountCreationCheck_"
Margin="10"
PasswordChanged="_passwordBoxAccountCreationCheck__PasswordChanged"
PlaceholderText="Repeat your Password"/> PlaceholderText="Repeat your Password"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
......
...@@ -248,6 +248,7 @@ void RingClientUWP::Views::SmartPanel::_addAccountBtn__Click(Platform::Object^ s ...@@ -248,6 +248,7 @@ void RingClientUWP::Views::SmartPanel::_addAccountBtn__Click(Platform::Object^ s
{ {
_accountsMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; _accountsMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Visible; _accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_createAccountYes_->IsEnabled = false;
} }
void RingClientUWP::Views::SmartPanel::_createAccountYes__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) void RingClientUWP::Views::SmartPanel::_createAccountYes__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
...@@ -256,11 +257,6 @@ void RingClientUWP::Views::SmartPanel::_createAccountYes__Click(Platform::Object ...@@ -256,11 +257,6 @@ void RingClientUWP::Views::SmartPanel::_createAccountYes__Click(Platform::Object
{ {
case 0: case 0:
{ {
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
auto frame = dynamic_cast<Windows::UI::Xaml::Controls::Frame^>(Window::Current->Content);
dynamic_cast<RingClientUWP::MainPage^>(frame->Content)->showLoadingOverlay(true, true);
}));
RingD::instance->createRINGAccount(_aliasTextBox_->Text); RingD::instance->createRINGAccount(_aliasTextBox_->Text);
_accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; _accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_accountsMenuButton__Checked(nullptr, nullptr); _accountsMenuButton__Checked(nullptr, nullptr);
...@@ -278,6 +274,8 @@ void RingClientUWP::Views::SmartPanel::_createAccountYes__Click(Platform::Object ...@@ -278,6 +274,8 @@ void RingClientUWP::Views::SmartPanel::_createAccountYes__Click(Platform::Object
break; break;
} }
_aliasTextBox_->Text = ""; _aliasTextBox_->Text = "";
_passwordBoxAccountCreation_->Password = "";
_passwordBoxAccountCreationCheck_->Password = "";
} }
...@@ -729,6 +727,7 @@ void RingClientUWP::Views::SmartPanel::_editAccountMenuButton__Click(Platform::O ...@@ -729,6 +727,7 @@ void RingClientUWP::Views::SmartPanel::_editAccountMenuButton__Click(Platform::O
_accountEditionMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Visible; _accountEditionMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_deleteAccountBtnEditionMenu_->IsChecked = false; _deleteAccountBtnEditionMenu_->IsChecked = false;
_deleteAccountBtnEditionMenu_->IsEnabled = (AccountListItemsViewModel::instance->itemsList->Size > 1)? true : false; _deleteAccountBtnEditionMenu_->IsEnabled = (AccountListItemsViewModel::instance->itemsList->Size > 1)? true : false;
_createAccountYes_->IsEnabled = false;
} }
...@@ -776,4 +775,12 @@ void RingClientUWP::Views::SmartPanel::_cancelAccountModification__Click(Platfor ...@@ -776,4 +775,12 @@ void RingClientUWP::Views::SmartPanel::_cancelAccountModification__Click(Platfor
void RingClientUWP::Views::SmartPanel::OnaccountUpdated(RingClientUWP::Account ^account) void RingClientUWP::Views::SmartPanel::OnaccountUpdated(RingClientUWP::Account ^account)
{ {
updatePageContent(); updatePageContent();
} }
\ No newline at end of file
void RingClientUWP::Views::SmartPanel::_passwordBoxAccountCreationCheck__PasswordChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
_createAccountYes_->IsEnabled = (_passwordBoxAccountCreation_->Password
== _passwordBoxAccountCreationCheck_->Password
&& _passwordBoxAccountCreation_->Password->Length() > 0)
? true : false;
}
...@@ -123,6 +123,7 @@ private: ...@@ -123,6 +123,7 @@ private:
void _acceptAccountModification__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void _acceptAccountModification__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _cancelAccountModification__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void _cancelAccountModification__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void OnaccountUpdated(RingClientUWP::Account ^account); void OnaccountUpdated(RingClientUWP::Account ^account);
void _passwordBoxAccountCreationCheck__PasswordChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
}; };
} }
} }
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment