diff --git a/AccountsViewModel.cpp b/AccountsViewModel.cpp index 36e891ff6628361c16e39813490ecb2f2392928f..57f890578dc4b9a7afa75297c243196fc98d8f02 100644 --- a/AccountsViewModel.cpp +++ b/AccountsViewModel.cpp @@ -37,6 +37,7 @@ AccountsViewModel::add(std::string& name, std::string& ringID, std::string& acco Utils::toPlatformString(accountType), Utils::toPlatformString(accountID) )); + updateScrollView(); } void diff --git a/AccountsViewModel.h b/AccountsViewModel.h index fcbd4b72872b6287d44debe5b7813b0f1979ab16..9f766c0ade2e810b0ffed5dbe9840e13ac7296b7 100644 --- a/AccountsViewModel.h +++ b/AccountsViewModel.h @@ -26,6 +26,7 @@ namespace RingClientUWP delegate void NewAccountSelected(); delegate void NoAccountSelected(); +delegate void UpdateScrollView(); namespace ViewModel { public ref class AccountsViewModel sealed @@ -74,6 +75,7 @@ internal: /* events */ event NewAccountSelected^ newAccountSelected; event NoAccountSelected^ noAccountSelected; + event UpdateScrollView^ updateScrollView; private: AccountsViewModel(); // singleton diff --git a/RingD.cpp b/RingD.cpp index 365274be9670c52ac7763d093b7f8cced7c1e311..ea6db1413f0fd89816416c63720e9ebbaafd02c3 100644 --- a/RingD.cpp +++ b/RingD.cpp @@ -24,8 +24,8 @@ #include "configurationmanager_interface.h" #include "presencemanager_interface.h" #include "fileutils.h" - #include "account_schema.h" +#include "account_const.h" #include "SmartPanel.xaml.h" @@ -99,6 +99,20 @@ void RingClientUWP::RingD::sendAccountTextMessage(String^ message) } } +void +RingD::createRINGAccount(String^ alias) +{ + accountName = Utils::toString(alias); + tasksList_.push(ref new RingD::Task(Request::AddRingAccount)); +} + +void +RingD::createSIPAccount(String^ alias) +{ + accountName = Utils::toString(alias); + tasksList_.push(ref new RingD::Task(Request::AddSIPAccount)); +} + void RingClientUWP::RingD::startDaemon() { @@ -176,6 +190,18 @@ RingClientUWP::RingD::startDaemon() })); } }), + DRing::exportable_callback<DRing::ConfigurationSignal::RegistrationStateChanged>([this]( + const std::string& account_id, const std::string& state, + int detailsCode, const std::string& detailsStr) + { + MSG_("<RegistrationStateChanged>: ID = " + account_id + "state = " + state); + if (state == DRing::Account::States::UNREGISTERED) { + CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, + ref new DispatchedHandler([=]() { + reloadAccountList(); + })); + } + }), DRing::exportable_callback<DRing::ConfigurationSignal::AccountsChanged>([this]() { CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, diff --git a/RingD.h b/RingD.h index 5aaaa30a8d8880bc11633ee9b8b44460f8c9610b..4026c546afd2d139908e4012284951cf19fba3cf 100644 --- a/RingD.h +++ b/RingD.h @@ -56,6 +56,8 @@ internal: void startDaemon(); void reloadAccountList(); void sendAccountTextMessage(String^ message); + void createRINGAccount(String^ alias); + void createSIPAccount(String^ alias); /* TODO : move members */ bool hasConfig; diff --git a/SmartPanel.xaml b/SmartPanel.xaml index 9736001f673a6a010aab5aa2ae8f5cf67bd4ca5b..d113973208322a9bc7c64804643c04b4a6e42fd7 100644 --- a/SmartPanel.xaml +++ b/SmartPanel.xaml @@ -132,7 +132,7 @@ Grid.Column="1" Grid.Row="0" TextAlignment="Right" - Margin="0,5,10,0" + Margin="0,5,18,0" Foreground="ForestGreen" Text="{x:Bind accountType_}"/> <TextBlock x:Name="_ringID_" @@ -228,15 +228,17 @@ <RowDefinition Height="*"/> <RowDefinition Height="30"/> </Grid.RowDefinitions> - <ListBox x:Name="_accountsList_" + <ScrollViewer x:Name="_accountsListScrollView_" + ScrollViewer.VerticalScrollBarVisibility="Auto" + ScrollViewer.VerticalScrollMode="Enabled"> + <ListBox x:Name="_accountsList_" Grid.Row="0" SelectionChanged="_accountList__SelectionChanged" - ScrollViewer.HorizontalScrollBarVisibility="Auto" - ScrollViewer.HorizontalScrollMode="Enabled" Width="320" ItemContainerStyle="{StaticResource contactsListBoxStyle}" Background="#FFE4F1F9" ItemTemplate="{StaticResource AccountTemplate}"/> + </ScrollViewer> <Button x:Name="_addAccountBtn_" Grid.Row="1" VerticalAlignment="Center" @@ -261,7 +263,8 @@ <TextBlock VerticalAlignment="Center" Text="Account type : " Margin="10,10,0,10"/> - <ComboBox SelectedIndex="0" + <ComboBox x:Name="_accountTypeComboBox_" + SelectedIndex="0" Margin="10" VerticalAlignment="Center" Width="195"> @@ -272,25 +275,14 @@ <!-- RING account. --> <StackPanel x:Name="_ringAccountCreationStack_" Visibility="Visible"> - <TextBox Margin="10" + <TextBox x:Name="_aliasTextBox_" + Margin="10" PlaceholderText="Enter your username"/> <PasswordBox Margin="10" PlaceholderText="Enter your password"/> <PasswordBox Margin="10" PlaceholderText="Repeat your Password"/> </StackPanel> - <!-- SIP account. --> - <StackPanel x:Name="_sipAccountCreationStack_" - Visibility="Collapsed"> - <TextBox Margin="10" - PlaceholderText="Enter hostname"/> - <TextBox Margin="10" - PlaceholderText="Enter your username"/> - <PasswordBox Margin="10" - PlaceholderText="Enter your password"/> - <PasswordBox Margin="10" - PlaceholderText="Repeat your Password"/> - </StackPanel> </StackPanel> <!-- buttons yes/no to create the new account. --> <Grid Grid.Row="1"> @@ -302,14 +294,14 @@ HorizontalAlignment="Center" Content="" Click="_createAccountYes__Click" - Style="{StaticResource ButtonStyle2}"/> + Style="{StaticResource ButtonStyle5}"/> <Button x:Name="_createAccountNo_" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" Content="" Click="_createAccountNo__Click" - Style="{StaticResource ButtonStyle2}"/> + Style="{StaticResource ButtonStyle5}"/> </StackPanel> </Grid> </Grid> diff --git a/SmartPanel.xaml.cpp b/SmartPanel.xaml.cpp index 85238c09b42cee3d5bd86b37213133466122d1b1..2742708a12e64eb6aa2cb56ec94c5906e0ba990e 100644 --- a/SmartPanel.xaml.cpp +++ b/SmartPanel.xaml.cpp @@ -48,6 +48,10 @@ SmartPanel::SmartPanel() auto uri = ref new Windows::Foundation::Uri(image_path); _selectedAccountAvatar_->ImageSource = ref new BitmapImage(uri); }); + AccountsViewModel::instance->updateScrollView += ref new UpdateScrollView([this]() { + _accountsListScrollView_->UpdateLayout(); + _accountsListScrollView_->ScrollToVerticalOffset(_accountsListScrollView_->ScrollableHeight); + }); _accountsList_->ItemsSource = AccountsViewModel::instance->accountsList; _smartList_->ItemsSource = ContactsViewModel::instance->contactsList; @@ -129,16 +133,35 @@ void RingClientUWP::Views::SmartPanel::_addAccountBtn__Click(Platform::Object^ s _accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Visible; } - void RingClientUWP::Views::SmartPanel::_createAccountYes__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { - + switch (_accountTypeComboBox_->SelectedIndex) + { + case 0: + { + RingD::instance->createRINGAccount(_aliasTextBox_->Text); + _accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; + _accountsMenuButton__Checked(nullptr, nullptr); + break; + } + break; + case 1: + { + RingD::instance->createSIPAccount(_aliasTextBox_->Text); + _accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; + _accountsMenuButton__Checked(nullptr, nullptr); + break; + } + default: + break; + } } void RingClientUWP::Views::SmartPanel::_createAccountNo__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { - + _accountsMenuButton_->IsChecked = false; + _accountsMenuButton__Unchecked(nullptr,nullptr); } void diff --git a/Styles.xaml b/Styles.xaml index 9afeebe28532161fd4ffaea61524158ac650348b..3a87cd946fa901c78aa3f79117f622a2796c2f94 100644 --- a/Styles.xaml +++ b/Styles.xaml @@ -115,6 +115,19 @@ <Setter Property="Background" Value="LightBlue"/> </Style> + <Style x:Key="ButtonStyle5" + TargetType="Button"> + <Setter Property="Width" + Value="160"/> + <Setter Property="Height" + Value="30"/> + <Setter Property="FontFamily" + Value="Segoe MDL2 Assets"/> + <Setter Property="Foreground" + Value="White"/> + <Setter Property="Background" + Value="Transparent"/> + </Style> <Style x:Key="ToggleButtonStyle1" TargetType="ToggleButton"> <Setter Property="Width"