diff --git a/AccountListItem.h b/AccountListItem.h index 7f4e920eea377f0441dbea827ef07149fc12a1f9..5ab41ad3f6997d1689e5aad439520e12a735aa8d 100644 --- a/AccountListItem.h +++ b/AccountListItem.h @@ -41,6 +41,7 @@ public: property Account^ _account; + property bool _hasArchivePassword; property bool _editionMode; property bool _disconnected; diff --git a/RingD.cpp b/RingD.cpp index 6e5b8283abddcad94fbfac2c56739e1a87a95bec..77f84c92a2dfd40e8c43e70237db2a6d19c9fbe5 100644 --- a/RingD.cpp +++ b/RingD.cpp @@ -115,6 +115,10 @@ RingD::parseAccountDetails(const AccountDetailsBlob& allAccountDetails) auto deviceId = accountDetails.find(DRing::Account::ConfProperties::RING_DEVICE_ID)->second; auto deviceName = accountDetails.find(DRing::Account::ConfProperties::RING_DEVICE_NAME)->second; + auto hasArchivePassword = (accountDetails.find(DRing::Account::ConfProperties::ARCHIVE_HAS_PASSWORD)->second == ring::TRUE_STR) + ? true + : false; + auto account = AccountsViewModel::instance->findItem(Utils::toPlatformString(accountId)); if (account) { @@ -192,6 +196,7 @@ RingD::parseAccountDetails(const AccountDetailsBlob& allAccountDetails) dhtPublicInCalls, turnEnabled, turnAddress); + archive_has_password->Insert(Utils::toPlatformString(accountId), hasArchivePassword); } } } @@ -1567,6 +1572,8 @@ RingD::startDaemon() RingD::RingD() { + archive_has_password = ref new Map<String^, bool>(); + toaster = ToastNotificationManager::CreateToastNotifier(); NetworkInformation::NetworkStatusChanged += ref new NetworkStatusChangedEventHandler(this, &RingD::InternetConnectionChanged); diff --git a/RingD.h b/RingD.h index b44b8196c537dad119879600752b0f249c084a44..5a31dbd58fbb72d37657d579abed3e91919e100c 100644 --- a/RingD.h +++ b/RingD.h @@ -269,6 +269,8 @@ internal: // why this property has to be internal and not public ? event ShareRequested^ shareRequested; event NameRegistered^ nameRegistered; + Map<String^, bool>^ archive_has_password; + private: Vector<String^>^ callIdsList_; diff --git a/SmartPanel.xaml b/SmartPanel.xaml index 4b6e86d3a839b291ba25f211fbf6246fd6f39f0a..94ff1f40d0e2bdc03dd7671b8cd143771395103a 100644 --- a/SmartPanel.xaml +++ b/SmartPanel.xaml @@ -1355,6 +1355,10 @@ Text="" /> <TextBlock Text="Password" /> </StackPanel> + <ToggleSwitch x:Name="_usePasswordState_" + Margin="10,0,0,10" + IsOn="True" + Toggled="_usePasswordState__Toggled" /> <Grid Margin="10"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> diff --git a/SmartPanel.xaml.cpp b/SmartPanel.xaml.cpp index d333449249493b9cf26c69910d6b68cf0854eb91..b6ce51d6f45862912144c145543646fa4758cf59 100644 --- a/SmartPanel.xaml.cpp +++ b/SmartPanel.xaml.cpp @@ -334,7 +334,7 @@ void RingClientUWP::Views::SmartPanel::_addAccountBtn__Click(Platform::Object^ s _accountCreationMenuScrollViewer_->ScrollToVerticalOffset(0); _createAccountYes_->IsEnabled = false; - + _usePasswordState_->IsOn = true; _accountTypeComboBox_->SelectedIndex = 0; _RegisterStateEdition_->IsOn = true; _accountAliasTextBox_->Text = ""; @@ -349,7 +349,7 @@ void RingClientUWP::Views::SmartPanel::_createAccountYes__Click(Platform::Object case 0: /* RING account */ { RingD::instance->createRINGAccount(_accountAliasTextBox_->Text - , _ringPasswordBoxAccountCreation_->Password + , _usePasswordState_->IsOn ? _ringPasswordBoxAccountCreation_->Password : "" , true , (_RegisterState_->IsOn) ? _usernameTextBox_->Text : ""); @@ -605,6 +605,8 @@ SmartPanel::SmartPanelItem_Grid_PointerMoved(Platform::Object^ sender, Windows:: void RingClientUWP::Views::SmartPanel::checkStateAddAccountMenu() { + bool usePassword = _usePasswordState_->IsOn; + bool isRingAccountType = (_accountTypeComboBox_->SelectedIndex == 0) ? true : false; bool isAccountAlias = (_accountAliasTextBox_->Text->IsEmpty()) ? false : true; @@ -617,7 +619,7 @@ void RingClientUWP::Views::SmartPanel::checkStateAddAccountMenu() _accountAliasInvalid_->Visibility = Windows::UI::Xaml::Visibility::Visible; } - if (isRingAccountType) { + if (isRingAccountType && _ringPasswordBoxAccountCreation_) { bool isPublic = _RegisterState_->IsOn; bool isUsernameValid = (_usernameValid_->Visibility == Windows::UI::Xaml::Visibility::Visible @@ -630,22 +632,37 @@ void RingClientUWP::Views::SmartPanel::checkStateAddAccountMenu() && isPasswordValid) ? true : false; - if (isPasswordValid) { - _passwordValid_->Visibility = Windows::UI::Xaml::Visibility::Visible; - _passwordInvalid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; - } - else { - _passwordValid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; - _passwordInvalid_->Visibility = Windows::UI::Xaml::Visibility::Visible; - } + auto passwordValidation = ((isRingPasswordCheck && isPasswordValid) || !usePassword); - if (isRingPasswordCheck) { - _passwordCheckValid_->Visibility = Windows::UI::Xaml::Visibility::Visible; + if (!usePassword) { + _ringPasswordBoxAccountCreation_->IsEnabled = false; + _ringPasswordBoxAccountCreationCheck_->IsEnabled = false; + _passwordValid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; + _passwordInvalid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; + _passwordCheckValid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; _passwordCheckInvalid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; } else { - _passwordCheckValid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; - _passwordCheckInvalid_->Visibility = Windows::UI::Xaml::Visibility::Visible; + _ringPasswordBoxAccountCreation_->IsEnabled = true; + _ringPasswordBoxAccountCreationCheck_->IsEnabled = true; + + if (isPasswordValid) { + _passwordValid_->Visibility = Windows::UI::Xaml::Visibility::Visible; + _passwordInvalid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; + } + else { + _passwordValid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; + _passwordInvalid_->Visibility = Windows::UI::Xaml::Visibility::Visible; + } + + if (isRingPasswordCheck) { + _passwordCheckValid_->Visibility = Windows::UI::Xaml::Visibility::Visible; + _passwordCheckInvalid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; + } + else { + _passwordCheckValid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; + _passwordCheckInvalid_->Visibility = Windows::UI::Xaml::Visibility::Visible; + } } if (isUsernameValid) { @@ -657,16 +674,17 @@ void RingClientUWP::Views::SmartPanel::checkStateAddAccountMenu() } if (isPublic) - if (isUsernameValid && isAccountAlias && isRingPasswordCheck && isPasswordValid) + if (isUsernameValid && isAccountAlias && passwordValidation) _createAccountYes_->IsEnabled = true; else _createAccountYes_->IsEnabled = false; - else if (isAccountAlias && isRingPasswordCheck && isPasswordValid) + else if (isAccountAlias && passwordValidation) _createAccountYes_->IsEnabled = true; else _createAccountYes_->IsEnabled = false; - } else { + } + else if (_createAccountYes_) { if (isAccountAlias) _createAccountYes_->IsEnabled = true; else @@ -1269,6 +1287,12 @@ void RingClientUWP::Views::SmartPanel::_RegisterState__Toggled(Platform::Object^ checkStateAddAccountMenu(); } +void +SmartPanel::_usePasswordState__Toggled(Object^ sender, RoutedEventArgs^ e) +{ + checkStateAddAccountMenu(); +} + void RingClientUWP::Views::SmartPanel::_RegisterStateEdition__Toggled(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { auto toggleSwitch = dynamic_cast<ToggleSwitch^>(sender); @@ -1802,7 +1826,14 @@ void RingClientUWP::Views::SmartPanel::_devicesMenuButton__Click(Platform::Objec { selectMenu(MenuOpen::DEVICE); - _pinGeneratorYes_->IsEnabled = false; + auto account = AccountListItemsViewModel::instance->_selectedItem->_account; + + bool enablePasswordForPinGen = true; + if (RingD::instance->archive_has_password->HasKey(account->accountID_)) + enablePasswordForPinGen = RingD::instance->archive_has_password->Lookup(account->accountID_); + + _pinGeneratorYes_->IsEnabled = !enablePasswordForPinGen; + _passwordForPinGenerator_->IsEnabled = enablePasswordForPinGen; _passwordForPinGenerator_->Password = ""; // refacto : do something better... auto loader = ref new Windows::ApplicationModel::Resources::ResourceLoader(); @@ -1811,7 +1842,6 @@ void RingClientUWP::Views::SmartPanel::_devicesMenuButton__Click(Platform::Objec _waitingDevicesList_->Visibility = Windows::UI::Xaml::Visibility::Visible; _devicesIdList_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; - auto account = AccountListItemsViewModel::instance->_selectedItem->_account; _deviceId_->Text = account->_deviceId; _deviceName_->Text = account->_deviceName; diff --git a/SmartPanel.xaml.h b/SmartPanel.xaml.h index 5e107e7991247d2fc529bfa85f355f27e9a48bc1..4c93416fecec6cefce677c0b3a4555aae387cc03 100644 --- a/SmartPanel.xaml.h +++ b/SmartPanel.xaml.h @@ -170,6 +170,7 @@ private: void _turnEnabledToggle__Toggled(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void _deleteAccountButton__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void _removeContact_MenuFlyoutItem__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e); + void _usePasswordState__Toggled(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); }; } } diff --git a/Styles.xaml b/Styles.xaml index 7a848d6077656c3adaa36d5a2a7662f9ede5ada4..9977e298c5f9bb46bb078fc169dbae1513c46560 100644 --- a/Styles.xaml +++ b/Styles.xaml @@ -167,7 +167,6 @@ <Setter Property="Background" Value="Transparent" /> <Setter Property="FontFamily" Value="Segoe MDL2 Assets" /> <Setter Property="Width" Value="80" /> - <Setter Property="Width" Value="120" /> <Setter Property="FontSize" Value="70" /> <Setter Property="BorderThickness" Value="0" /> </Style> diff --git a/Wizard.xaml b/Wizard.xaml index 8176bcb1917bc191fcb1a3307a92cd20c844ef2b..d6dae94b9a7b67103f385e18c447bfc6320aa2b9 100644 --- a/Wizard.xaml +++ b/Wizard.xaml @@ -31,12 +31,12 @@ <Rectangle Height="50" /> <TextBlock x:Uid="_welcome_" HorizontalAlignment="Center" - Style="{StaticResource HeaderTextBlockStyle}" - FontWeight="Normal" FontSize="60" - Foreground="#FF535E5E"> + FontWeight="Normal" + Foreground="#FF535E5E" + Style="{StaticResource HeaderTextBlockStyle}"> <TextBlock.RenderTransform> - <TranslateTransform X="0" Y="10"/> + <TranslateTransform X="0" Y="10" /> </TextBlock.RenderTransform> </TextBlock> <Image x:Name="_welcomeImage_" @@ -52,10 +52,10 @@ Visibility="Visible"> <TextBlock x:Name="_showCreateAccountMenuTitle_" x:Uid="_wizardCreateAccountTitle_" + Padding="4" HorizontalAlignment="Center" FontSize="30" Foreground="White" - Padding="4" Style="{StaticResource SubheaderTextBlockStyle}" Visibility="Collapsed" /> <Button x:Name="_showCreateAccountMenuBtn_" @@ -82,8 +82,8 @@ Padding="10,0" Visibility="Visible"> <Button x:Name="_avatarWebcamCaptureBtn_" - Width="90" - Height="90" + Width="100" + Height="100" Margin="0,10,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" @@ -168,6 +168,10 @@ FontWeight="SemiLight" Style="{StaticResource TitleTextBlockStyle}" /> </StackPanel> + <ToggleSwitch x:Name="_usePasswordState_" + Margin="10,0,0,10" + IsOn="True" + Toggled="_usePasswordState__Toggled" /> <Grid Margin="0,10"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> @@ -256,10 +260,10 @@ <StackPanel x:Name="addExistingAccountStep2"> <TextBlock x:Name="_showAddAccountMenuTitle_" x:Uid="_wizardAddExistingAccountTitle_" + Padding="4" HorizontalAlignment="Center" FontSize="30" Foreground="White" - Padding="4" Style="{StaticResource SubheaderTextBlockStyle}" Visibility="Collapsed" /> <Button x:Name="_showAddAccountMenuBtn_" diff --git a/Wizard.xaml.cpp b/Wizard.xaml.cpp index 7d94bd84fb184c6f8a7fb12ea9b621a2a9a692ea..1791cd83a3a25bee3a9aedb0562134341bfc7220 100644 --- a/Wizard.xaml.cpp +++ b/Wizard.xaml.cpp @@ -75,6 +75,7 @@ Wizard::_createAccountYes__Click(Object^ sender, RoutedEventArgs^ e) this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([this] () { RingD::instance->isInWizard = false; this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(RingClientUWP::MainPage::typeid)); + _password_->Password = usePassword ? _password_->Password : ""; RingD::instance->createRINGAccount(_fullnameTextBox_->Text , _password_->Password , true // upnp by default set to true @@ -120,8 +121,8 @@ Wizard::_avatarWebcamCaptureBtn__Click(Platform::Object^ sender, Windows::UI::Xa if (auto bitmapImage = image.get()) { auto brush = ref new ImageBrush(); auto circle = ref new Ellipse(); - circle->Height = 100; - circle->Width = 100; + circle->Height = 80; + circle->Width = 80; brush->ImageSource = bitmapImage; circle->Fill = brush; _avatarWebcamCaptureBtn_->Content = circle; @@ -182,7 +183,8 @@ void RingClientUWP::Views::Wizard::_password__PasswordChanged(Platform::Object^ checkState(); } -void RingClientUWP::Views::Wizard::_passwordCheck__PasswordChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) +void +Wizard::_passwordCheck__PasswordChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { isPasswordsMatching = (_password_->Password == _passwordCheck_->Password @@ -203,8 +205,13 @@ void RingClientUWP::Views::Wizard::_passwordCheck__PasswordChanged(Platform::Obj void RingClientUWP::Views::Wizard::checkState() { - if ((isPublic && isPasswordValid && isPasswordsMatching && isUsernameValid && isFullNameValid) - ||(!isPublic && isPasswordValid && isPasswordsMatching && isFullNameValid)) + if (!_password_) + return; + + auto passwordValidation = ((isPasswordsMatching && isPasswordValid) || !usePassword); + + if ((isPublic && passwordValidation && isUsernameValid && isFullNameValid) + || (!isPublic && passwordValidation && isFullNameValid)) _createAccountYes_->IsEnabled = true; else _createAccountYes_->IsEnabled = false; @@ -333,3 +340,29 @@ Wizard::_createAccountNo__Click(Platform::Object^ sender, Windows::UI::Xaml::Rou { } + +void +Wizard::_usePasswordState__Toggled(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) +{ + if (!_password_) + return; + + usePassword = _usePasswordState_->IsOn; + + if (!usePassword) { + _password_->IsEnabled = false; + _passwordCheck_->IsEnabled = false; + _passwordValid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; + _passwordInvalid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; + _passwordCheckValid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; + _passwordCheckInvalid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; + } + else { + _password_->IsEnabled = true; + _passwordCheck_->IsEnabled = true; + _password__PasswordChanged(nullptr, nullptr); + _passwordCheck__PasswordChanged(nullptr, nullptr); + } + + checkState(); +} diff --git a/Wizard.xaml.h b/Wizard.xaml.h index 71c4761f7671146577639c5ad628375e08a8dfe7..2e84c7c367d5616545202c7be052e4117c29ef52 100644 --- a/Wizard.xaml.h +++ b/Wizard.xaml.h @@ -35,6 +35,13 @@ protected: virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override; private: + bool usePassword; + bool isPasswordValid; + bool isPasswordsMatching; + bool isPublic = true; + bool isUsernameValid; // available + bool isFullNameValid; + void _createAccountYes__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void _showCreateAccountMenuBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void _showAddAccountMenuBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); @@ -48,18 +55,12 @@ private: void _password__PasswordChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void _passwordCheck__PasswordChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void checkState(); - - /*members*/ - bool isPasswordValid; - bool isPasswordsMatching; - bool isPublic = true; - bool isUsernameValid; // available - bool isFullNameValid; void OnregistrationStateErrorGeneric(const std::string &accountId); void _PINTextBox__GotFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void _ArchivePassword__KeyUp(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e); void _PINTextBox__KeyUp(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e); void _createAccountNo__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + void _usePasswordState__Toggled(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); }; }