Commit 196936ea authored by atraczyk's avatar atraczyk Committed by Andreas Traczyk

account: add RING/SIP accounts

- adds the ability to add accounts from within the accounts menu

Change-Id: Ic2bd21f8c08e0e159c1006409eaaf815b7748bc8
Tuleap: #996
parent aef65721
......@@ -37,6 +37,7 @@ AccountsViewModel::add(std::string& name, std::string& ringID, std::string& acco
Utils::toPlatformString(accountType),
Utils::toPlatformString(accountID)
));
updateScrollView();
}
void
......
......@@ -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
......
......@@ -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,
......
......@@ -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;
......
......@@ -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="&#xE081;"
Click="_createAccountYes__Click"
Style="{StaticResource ButtonStyle2}"/>
Style="{StaticResource ButtonStyle5}"/>
<Button x:Name="_createAccountNo_"
Grid.Row="1"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Content="&#xE106;"
Click="_createAccountNo__Click"
Style="{StaticResource ButtonStyle2}"/>
Style="{StaticResource ButtonStyle5}"/>
</StackPanel>
</Grid>
</Grid>
......
......@@ -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
......
......@@ -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"
......
Markdown is supported
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