Commit 0a7b77df authored by Nicolas Jager's avatar Nicolas Jager

smartpanel : creation and edition of sip account.

Change-Id: I2cc7ea4778a303c5b16b15ce5dbe6b0735fbddc7
Tuleap: #1249
parent 7168df93
...@@ -32,7 +32,10 @@ Account::Account(String^ name, ...@@ -32,7 +32,10 @@ Account::Account(String^ name,
String^ accountType, String^ accountType,
String^ accountID, String^ accountID,
String^ deviceId, String^ deviceId,
bool upnpState) bool upnpState,
String^ sipHostname,
String^ sipUsername,
String^ sipPassword)
{ {
name_ = name; name_ = name;
ringID_ = ringID; ringID_ = ringID;
...@@ -40,6 +43,10 @@ Account::Account(String^ name, ...@@ -40,6 +43,10 @@ Account::Account(String^ name,
accountID_ = accountID; accountID_ = accountID;
_deviceId = deviceId; _deviceId = deviceId;
_upnpState = _upnpState; _upnpState = _upnpState;
_sipHostname = sipHostname;
_sipUsername = sipUsername;
_sipPassword = sipPassword;
} }
void void
......
...@@ -28,17 +28,18 @@ namespace RingClientUWP ...@@ -28,17 +28,18 @@ namespace RingClientUWP
public ref class Account sealed : public INotifyPropertyChanged public ref class Account sealed : public INotifyPropertyChanged
{ {
public: public:
Account(String^ name, String^ ringID, String^ accountType, String^ accountID, String^ deviceId, bool upnpState); Account(String^ name, String^ ringID, String^ accountType, String^ accountID, String^ deviceId, bool upnpState
, String^ sipHostname, String^ sipUsername, String^ sipPassword);
virtual event PropertyChangedEventHandler^ PropertyChanged; virtual event PropertyChangedEventHandler^ PropertyChanged;
property String^ name_ property String^ name_
{ {
String^ get() { String^ get() {
return name__; return alias_;
} }
void set(String^ value) { void set(String^ value) {
name__ = value; alias_ = value;
NotifyPropertyChanged("name_"); NotifyPropertyChanged("name_");
} }
} }
...@@ -63,14 +64,27 @@ public: ...@@ -63,14 +64,27 @@ public:
} }
}; };
property bool _upnpState; property bool _upnpState;
property String^ _sipHostname;
property String^ _sipUsername
{
String^ get() {
return sipUsername_;
}
void set(String^ value) {
sipUsername_ = value;
NotifyPropertyChanged("_sipUsername");
}
}
property String^ _sipPassword; // refacto : think to encrypt password in memory
protected: protected:
void NotifyPropertyChanged(String^ propertyName); void NotifyPropertyChanged(String^ propertyName);
private: private:
Windows::Foundation::Collections::IVector<String^>^ devicesIdList_; Windows::Foundation::Collections::IVector<String^>^ devicesIdList_;
String^ name__; String^ alias_;
String^ ringID__; String^ ringID__;
String^ sipUsername_;
}; };
} }
......
...@@ -29,15 +29,38 @@ AccountsViewModel::AccountsViewModel() ...@@ -29,15 +29,38 @@ AccountsViewModel::AccountsViewModel()
} }
void void
AccountsViewModel::add(std::string& name, std::string& ringID, std::string& accountType, std::string& accountID, std::string& deviceId, bool upnpState) AccountsViewModel::addRingAccount(std::string& alias, std::string& ringID, std::string& accountID, std::string& deviceId, bool upnpState)
{ {
auto account = ref new Account( auto account = ref new Account(
Utils::toPlatformString(name), Utils::toPlatformString(alias),
Utils::toPlatformString(ringID), Utils::toPlatformString(ringID),
Utils::toPlatformString(accountType), "RING",
Utils::toPlatformString(accountID), Utils::toPlatformString(accountID),
Utils::toPlatformString(deviceId), Utils::toPlatformString(deviceId),
upnpState); upnpState,
"" /* sip hostame not used woth ring account */,
"" /* sip username not used with ring account */,
"" /* sip password not used with ring */ );
accountsList_->Append(account);
updateScrollView();
accountAdded(account);
}
void
AccountsViewModel::addSipAccount(std::string& alias, std::string& accountID, std::string& sipHostname, std::string& sipUsername, std::string& sipPassword)
{
auto account = ref new Account(
Utils::toPlatformString(alias),
"" /* ring Id not used with sip */ ,
"SIP",
Utils::toPlatformString(accountID),
"" /* device id not used with sip */,
false /* upnpn not used with sip */,
Utils::toPlatformString(sipHostname),
Utils::toPlatformString(sipUsername),
Utils::toPlatformString(sipPassword)
);
accountsList_->Append(account); accountsList_->Append(account);
updateScrollView(); updateScrollView();
......
...@@ -46,7 +46,8 @@ internal: ...@@ -46,7 +46,8 @@ internal:
} }
/* functions */ /* functions */
void add(std::string& name, std::string& ringID, std::string& accountType, std::string& accountID, std::string& deviceId, bool upnpState); void addRingAccount(std::string& alias, std::string& ringID, std::string& accountID, std::string& deviceId, bool upnpState);
void addSipAccount(std::string& alias, std::string& accountID, std::string& sipHostname, std::string& sipUsername, std::string& sipPassword);
void clearAccountList(); void clearAccountList();
Account^ findItem(String^ accountId); Account^ findItem(String^ accountId);
......
...@@ -59,38 +59,58 @@ RingClientUWP::RingD::reloadAccountList() ...@@ -59,38 +59,58 @@ RingClientUWP::RingD::reloadAccountList()
std::vector<std::string>::reverse_iterator rit = accountList.rbegin(); std::vector<std::string>::reverse_iterator rit = accountList.rbegin();
for (; rit != accountList.rend(); ++rit) { for (; rit != accountList.rend(); ++rit) {
std::map<std::string,std::string> accountDetails = DRing::getAccountDetails(*rit); std::map<std::string,std::string> accountDetails = DRing::getAccountDetails(*rit);
std::string ringID(accountDetails.find(DRing::Account::ConfProperties::USERNAME)->second);
bool upnpState = (accountDetails.find(DRing::Account::ConfProperties::UPNP_ENABLED)->second == ring::TRUE_STR)
? true
: false;
MSG_("upnp state : " + accountDetails.find(DRing::Account::ConfProperties::UPNP_ENABLED)->second);
if(!ringID.empty())
ringID = ringID.substr(5);
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; if (type == "RING") {
auto ringId = accountDetails.find(DRing::Account::ConfProperties::USERNAME)->second; auto ringID = accountDetails.find(DRing::Account::ConfProperties::USERNAME)->second;
if (!ringID.empty())
auto accountId = Utils::toPlatformString(*rit); ringID = ringID.substr(5);
auto account = AccountsViewModel::instance->findItem(accountId);
bool upnpState = (accountDetails.find(DRing::Account::ConfProperties::UPNP_ENABLED)->second == ring::TRUE_STR)
if (account) { ? true
account->name_ = Utils::toPlatformString(alias); : false;
account->_upnpState = upnpState; auto alias = accountDetails.find(DRing::Account::ConfProperties::ALIAS)->second;
account->accountType_ = Utils::toPlatformString(type); auto deviceId = accountDetails.find(DRing::Account::ConfProperties::RING_DEVICE_ID)->second;
account->ringID_ = Utils::toPlatformString(ringId); auto accountId = *rit;
accountUpdated(account);
} auto account = AccountsViewModel::instance->findItem(Utils::toPlatformString(accountId));
else {
RingClientUWP::ViewModel::AccountsViewModel::instance->add(alias, ringID, type, *rit /*account id*/, deviceId, upnpState); if (account) {
account->name_ = Utils::toPlatformString(alias);
account->_upnpState = upnpState;
account->accountType_ = Utils::toPlatformString(type);
account->ringID_ = Utils::toPlatformString(ringID);
accountUpdated(account);
}
else {
RingClientUWP::ViewModel::AccountsViewModel::instance->addRingAccount(alias, ringID, accountId, deviceId, upnpState);
}
} }
else { /* SIP */
auto alias = accountDetails.find(DRing::Account::ConfProperties::ALIAS)->second;
auto accountId = *rit;
auto sipHostname = accountDetails.find(DRing::Account::ConfProperties::HOSTNAME)->second;
auto sipUsername = accountDetails.find(DRing::Account::ConfProperties::USERNAME)->second;
auto sipPassword = accountDetails.find(DRing::Account::ConfProperties::PASSWORD)->second;
auto account = AccountsViewModel::instance->findItem(Utils::toPlatformString(accountId));
if (account) {
account->name_ = Utils::toPlatformString(alias);
account->accountType_ = Utils::toPlatformString(type);
account->_sipHostname = Utils::toPlatformString(sipHostname);
account->_sipUsername = Utils::toPlatformString(sipUsername);
account->_sipPassword = Utils::toPlatformString(sipPassword);
accountUpdated(account);
}
else {
RingClientUWP::ViewModel::AccountsViewModel::instance->addSipAccount(alias, accountId, sipHostname, sipUsername, sipPassword);
}
sipPassword = ""; // avoid to keep password in memory
}
} }
// load user preferences // load user preferences
...@@ -163,30 +183,38 @@ void RingClientUWP::RingD::sendSIPTextMessage(String^ message) ...@@ -163,30 +183,38 @@ void RingClientUWP::RingD::sendSIPTextMessage(String^ message)
} }
void void
RingD::createRINGAccount(String^ alias) RingD::createRINGAccount(String^ alias, String^ archivePassword, bool upnp)
{ {
editModeOn_ = true; editModeOn_ = true;
auto frame = dynamic_cast<Frame^>(Window::Current->Content); auto frame = dynamic_cast<Frame^>(Window::Current->Content);
dynamic_cast<RingClientUWP::MainPage^>(frame->Content)->showLoadingOverlay(true, true); dynamic_cast<RingClientUWP::MainPage^>(frame->Content)->showLoadingOverlay(true, true);
// refactoring : create a dedicated class constructor task and removes accountName from RingD auto task = ref new RingD::Task(Request::AddRingAccount);
accountName = Utils::toString(alias);
tasksList_.push(ref new RingD::Task(Request::AddRingAccount)); task->_alias = alias;
task->_password = archivePassword;
task->_upnp = upnp;
tasksList_.push(task);
} }
void void
RingD::createSIPAccount(String^ alias) RingD::createSIPAccount(String^ alias, String^ sipPassword, String^ sipHostname, String^ sipusername)
{ {
editModeOn_ = true; editModeOn_ = true;
auto frame = dynamic_cast<Frame^>(Window::Current->Content); auto frame = dynamic_cast<Frame^>(Window::Current->Content);
dynamic_cast<RingClientUWP::MainPage^>(frame->Content)->showLoadingOverlay(true, true); dynamic_cast<RingClientUWP::MainPage^>(frame->Content)->showLoadingOverlay(true, true);
// refactoring : create a dedicated class constructor task and removes accountName from RingD auto task = ref new RingD::Task(Request::AddSIPAccount);
accountName = Utils::toString(alias);
tasksList_.push(ref new RingD::Task(Request::AddSIPAccount)); task->_alias = alias;
task->_sipPassword = sipPassword;
task->_sipHostname = sipHostname;
task->_sipUsername = sipusername;
tasksList_.push(task);
} }
void RingClientUWP::RingD::refuseIncommingCall(String^ callId) void RingClientUWP::RingD::refuseIncommingCall(String^ callId)
...@@ -600,7 +628,6 @@ RingClientUWP::RingD::startDaemon() ...@@ -600,7 +628,6 @@ RingClientUWP::RingD::startDaemon()
case StartingStatus::REGISTERING_ON_THIS_PC: case StartingStatus::REGISTERING_ON_THIS_PC:
{ {
tasksList_.push(ref new RingD::Task(Request::AddRingAccount)); tasksList_.push(ref new RingD::Task(Request::AddRingAccount));
tasksList_.push(ref new RingD::Task(Request::AddSIPAccount));
break; break;
} }
case StartingStatus::REGISTERING_THIS_DEVICE: case StartingStatus::REGISTERING_THIS_DEVICE:
...@@ -663,17 +690,28 @@ RingD::dequeueTasks() ...@@ -663,17 +690,28 @@ RingD::dequeueTasks()
case Request::AddRingAccount: case Request::AddRingAccount:
{ {
std::map<std::string, std::string> ringAccountDetails; std::map<std::string, std::string> ringAccountDetails;
ringAccountDetails.insert(std::make_pair(DRing::Account::ConfProperties::ALIAS, accountName)); ringAccountDetails.insert(std::make_pair(DRing::Account::ConfProperties::ALIAS
ringAccountDetails.insert(std::make_pair(DRing::Account::ConfProperties::ARCHIVE_PASSWORD, accountName)); , Utils::toString(task->_alias)));
ringAccountDetails.insert(std::make_pair(DRing::Account::ConfProperties::ARCHIVE_PASSWORD,
Utils::toString(task->_password)));
ringAccountDetails.insert(std::make_pair(DRing::Account::ConfProperties::TYPE,"RING")); ringAccountDetails.insert(std::make_pair(DRing::Account::ConfProperties::TYPE,"RING"));
ringAccountDetails.insert(std::make_pair(DRing::Account::ConfProperties::UPNP_ENABLED
, (task->_upnp)? ring::TRUE_STR : ring::FALSE_STR));
DRing::addAccount(ringAccountDetails); DRing::addAccount(ringAccountDetails);
} }
break; break;
case Request::AddSIPAccount: case Request::AddSIPAccount:
{ {
std::map<std::string, std::string> sipAccountDetails; std::map<std::string, std::string> sipAccountDetails;
sipAccountDetails.insert(std::make_pair(DRing::Account::ConfProperties::ALIAS, accountName + " (SIP)")); sipAccountDetails.insert(std::make_pair(DRing::Account::ConfProperties::ALIAS
, Utils::toString(task->_alias)));
sipAccountDetails.insert(std::make_pair(DRing::Account::ConfProperties::TYPE,"SIP")); sipAccountDetails.insert(std::make_pair(DRing::Account::ConfProperties::TYPE,"SIP"));
sipAccountDetails.insert(std::make_pair(DRing::Account::ConfProperties::PASSWORD
, Utils::toString(task->_sipPassword)));
sipAccountDetails.insert(std::make_pair(DRing::Account::ConfProperties::HOSTNAME
, Utils::toString(task->_sipHostname)));
sipAccountDetails.insert(std::make_pair(DRing::Account::ConfProperties::USERNAME
, Utils::toString(task->_sipUsername)));
DRing::addAccount(sipAccountDetails); DRing::addAccount(sipAccountDetails);
} }
break; break;
......
...@@ -61,8 +61,8 @@ public: ...@@ -61,8 +61,8 @@ public:
} }
} }
property StartingStatus _startingStatus; property StartingStatus _startingStatus;
property String^ _pin; property String^ _pin; // you should RM ME
property String^ _password; property String^ _password; // refatco : think a little... RM ME
void cancelOutGoingCall2(String^ callId); // marche void cancelOutGoingCall2(String^ callId); // marche
...@@ -82,8 +82,8 @@ internal: ...@@ -82,8 +82,8 @@ internal:
void reloadAccountList(); void reloadAccountList();
void sendAccountTextMessage(String^ message); void sendAccountTextMessage(String^ message);
void sendSIPTextMessage(String^ message); void sendSIPTextMessage(String^ message);
void createRINGAccount(String^ alias); void createRINGAccount(String^ alias, String^ archivePassword, bool upnp);
void createSIPAccount(String^ alias); void createSIPAccount(String^ alias, String^ sipPassword, String^ sipHostname, String^ sipusername);
void refuseIncommingCall(String^ call); void refuseIncommingCall(String^ call);
void acceptIncommingCall(String^ call); void acceptIncommingCall(String^ call);
void placeCall(Contact^ contact); void placeCall(Contact^ contact);
...@@ -102,7 +102,7 @@ internal: ...@@ -102,7 +102,7 @@ internal:
/* TODO : move members */ /* TODO : move members */
///bool hasConfig; // replaced by startingStatus ///bool hasConfig; // replaced by startingStatus
std::string accountName; std::string accountName; // YOU SHOULD RM ME
String ^ currentCallId; // to save ongoing call id during visibility change String ^ currentCallId; // to save ongoing call id during visibility change
/* events */ /* events */
...@@ -155,10 +155,15 @@ private: ...@@ -155,10 +155,15 @@ private:
} }
public: public:
property Request request; property Request request;
property String^ _alias;
property String^ _callId; property String^ _callId;
property String^ _pin; property String^ _pin;
property String^ _password; property String^ _password; // refacto : is it safe ? are tasks destroy quickly after been used ?
property String^ _accountId; property String^ _accountId;
property bool _upnp;
property String^ _sipPassword;
property String^ _sipHostname;
property String^ _sipUsername;
}; };
/* functions */ /* functions */
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
<views:HasAnActiveCall x:Key="_HasAnActiveCall_" /> <views:HasAnActiveCall x:Key="_HasAnActiveCall_" />
<views:AccountTypeToSourceImage x:Key="_AccountTypeToSourceImage_" /> <views:AccountTypeToSourceImage x:Key="_AccountTypeToSourceImage_" />
<views:AccountSelectedToVisibility x:Key="_AccountSelectedToVisibility_" /> <views:AccountSelectedToVisibility x:Key="_AccountSelectedToVisibility_" />
<views:CollapseEmptyString x:Key="_CollapseEmptyString_" />
<Style x:Key="addContactTextBoxStyle" <Style x:Key="addContactTextBoxStyle"
TargetType="TextBox"> TargetType="TextBox">
...@@ -207,9 +208,15 @@ ...@@ -207,9 +208,15 @@
Style="{StaticResource TextStyle5}" Style="{StaticResource TextStyle5}"
Text="{x:Bind _account.name_, Mode=OneWay}"/> Text="{x:Bind _account.name_, Mode=OneWay}"/>
<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_, Mode=OneWay}"/> Visibility="{x:Bind _account.ringID_, Converter={StaticResource _CollapseEmptyString_}, Mode=OneWay}"
Text="{x:Bind _account.ringID_, Mode=OneWay}"/>
<TextBlock x:Name="_sipUsername_"
Grid.ColumnSpan="2"
Visibility="{x:Bind _account._sipUsername, Converter={StaticResource _CollapseEmptyString_}, Mode=OneWay}"
Style="{StaticResource TextStyle6}"
Text="{x:Bind _account._sipUsername, Mode=OneWay}"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</DataTemplate> </DataTemplate>
...@@ -464,33 +471,77 @@ ...@@ -464,33 +471,77 @@
<StackPanel Orientation="Vertical" <StackPanel Orientation="Vertical"
Grid.Row="0" Grid.Row="0"
Background="#FFE4F1F9"> Background="#FFE4F1F9">
<StackPanel Orientation="Horizontal"> <!-- alias sub menu. -->
<TextBlock VerticalAlignment="Center" <StackPanel Orientation="Horizontal" Margin="10">
Text="Account type : " <TextBlock Style="{StaticResource TextSegoeStyle-20pt-black}"
Margin="10,10,0,10"/> Text="&#xE8EC;"/>
<ComboBox x:Name="_accountTypeComboBox_" <TextBlock Text="Alias" Margin="10"/>
</StackPanel>
<TextBox x:Name="_ringAliasTextBox_"
TextChanged="_ringAliasTextBox__TextChanged"
Margin="10"
PlaceholderText="Enter alias"/>
<!-- account type chooser -->
<StackPanel Orientation="Horizontal" Margin="10">
<TextBlock Style="{StaticResource TextSegoeStyle-20pt-black}"
Text="&#xE168;"/>
<TextBlock Text="Account type" Margin="10"/>
</StackPanel>
<ComboBox x:Name="_accountTypeComboBox_"
SelectedIndex="0" SelectedIndex="0"
Margin="10" Margin="10"
SelectionChanged="_accountTypeComboBox__SelectionChanged"
VerticalAlignment="Center" VerticalAlignment="Center"
Width="195"> Width="195">
<ComboBoxItem Content="Ring"/> <ComboBoxItem Content="Ring"/>
<ComboBoxItem Content="Sip"/> <ComboBoxItem Content="Sip"/>
</ComboBox> </ComboBox>
</StackPanel>
<!-- RING account. --> <!-- RING account. -->
<StackPanel x:Name="_ringAccountCreationStack_" <StackPanel x:Name="_ringAccountCreationStack_"
Visibility="Visible"> Visibility="Visible">
<TextBox x:Name="_aliasTextBox_" <!-- password sub menu. -->
Margin="10" <StackPanel Orientation="Horizontal" Margin="10">
PlaceholderText="Enter your username"/> <TextBlock Style="{StaticResource TextSegoeStyle-20pt-black}"
<PasswordBox x:Name="_passwordBoxAccountCreation_" Text="&#xE8D7;"/>
<TextBlock Text="Archive password" Margin="10"/>
</StackPanel>
<PasswordBox x:Name="_ringPasswordBoxAccountCreation_"
Margin="10" Margin="10"
PasswordChanged="_passwordBoxAccountCreationCheck__PasswordChanged" PasswordChanged="_passwordBoxAccountCreationCheck__PasswordChanged"
PlaceholderText="Enter your password"/> PlaceholderText="Enter archive password"/>
<PasswordBox x:Name="_passwordBoxAccountCreationCheck_" <PasswordBox x:Name="_ringPasswordBoxAccountCreationCheck_"
Margin="10" Margin="10"
PasswordChanged="_passwordBoxAccountCreationCheck__PasswordChanged" PasswordChanged="_passwordBoxAccountCreationCheck__PasswordChanged"
PlaceholderText="Repeat your Password"/> PlaceholderText="Repeat archive Password"/>
<!-- upnp sub menu. -->
<StackPanel Orientation="Horizontal" Margin="10">
<TextBlock Style="{StaticResource TextSegoeStyle-20pt-black}"
Text="&#xE15E;"/>
<TextBlock Text="UPnP" Margin="10"/>
</StackPanel>
<ToggleSwitch x:Name="_upnpStateAccountCreation_"
IsOn="True"
Margin="20,10"/>
</StackPanel>
<!-- SIP account. -->
<StackPanel x:Name="_sipAccountCreationStack_"
Visibility="Collapsed">
<StackPanel Orientation="Horizontal"
Margin="10">
<TextBlock Style="{StaticResource TextSegoeStyle-20pt-black}"
Text="&#xE717;"/>
<TextBlock Text="SIP account parameters"
Margin="10"/>
</StackPanel>
<TextBox x:Name="_sipHostnameTextBox_"
Margin="10"
PlaceholderText="Enter hostname"/>
<TextBox x:Name="_sipUsernameTextBox_"
Margin="10"
PlaceholderText="Enter username"/>
<PasswordBox x:Name="_sipPasswordBoxAccountCreation_"
Margin="10"
PlaceholderText="Enter password"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<!-- buttons yes/no to create the new account. --> <!-- buttons yes/no to create the new account. -->
...@@ -535,15 +586,37 @@ ...@@ -535,15 +586,37 @@
<TextBox x:Name="_aliasTextBoxEditionMenu_" <TextBox x:Name="_aliasTextBoxEditionMenu_"
FontSize="20" FontSize="20"
Margin="20,10" Margin="20,10"
PlaceholderText="Enter your username"/> PlaceholderText="Enter alias"/>
<!-- upnp sub menu. --> <!-- upnp sub menu. -->
<StackPanel Orientation="Horizontal" Margin="10"> <StackPanel x:Name="_upnpStackEditionMenu_">
<TextBlock Style="{StaticResource TextSegoeStyle-20pt-black}" <StackPanel Orientation="Horizontal" Margin="10">
Text="&#xE15E;"/> <TextBlock Style="{StaticResource TextSegoeStyle-20pt-black}"
<TextBlock Text="UPnP" Margin="10"/> Text="&#xE15E;"/>
<TextBlock Text="UPnP" Margin="10"/>
</StackPanel>
<ToggleSwitch x:Name="_upnpState_"
Margin="20,10"/>
</StackPanel>
<!-- SIP parameters. -->
<StackPanel x:Name="_sipAccountStackEditionMenu_"
Visibility="Collapsed">
<StackPanel Orientation="Horizontal"
Margin="10">
<TextBlock Style="{StaticResource TextSegoeStyle-20pt-black}"
Text="&#xE717;"/>
<TextBlock Text="SIP account parameters"
Margin="10"/>
</StackPanel>
<TextBox x:Name="_sipHostnameEditionMenu_"
Margin="10"
PlaceholderText="Enter hostname"/>
<TextBox x:Name="_sipUsernameEditionTextBox_"
Margin="10"
PlaceholderText="Enter username"/>
<PasswordBox x:Name="_sipPasswordEditionMenu_"
Margin="10"
PlaceholderText="Enter password"/>
</StackPanel> </StackPanel>
<ToggleSwitch x:Name="_upnpState_"
Margin="20,10"/>
<!-- delete account sub menu. --> <!-- delete account sub menu. -->
<StackPanel Orientation="Horizontal" Margin="10"> <StackPanel Orientation="Horizontal" Margin="10">
<TextBlock Style="{StaticResource TextSegoeStyle-20pt-black}" <TextBlock Style="{StaticResource TextSegoeStyle-20pt-black}"
......
...@@ -248,34 +248,42 @@ void RingClientUWP::Views::SmartPanel::_addAccountBtn__Click(Platform::Object^ s ...@@ -248,34 +248,42 @@ 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; _createAccountYes_->IsEnabled = false;
_accountTypeComboBox_->SelectedIndex = 0;
_upnpStateAccountCreation_->IsOn = true;
_ringAliasTextBox_->Text = "";
} }
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)
{ {
switch (_accountTypeComboBox_->SelectedIndex) switch (_accountTypeComboBox_->SelectedIndex) {
{ case 0: /* RING account */
case 0:
{ {
RingD::instance->createRINGAccount(_aliasTextBox_->Text); RingD::instance->createRINGAccount(_ringAliasTextBox_->Text, _ringPasswordBoxAccountCreation_->Password, _upnpStateAccountCreation_->IsOn);
_accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; _ringPasswordBoxAccountCreation_->Password = "";
_accountsMenuButton__Checked(nullptr, nullptr); _ringPasswordBoxAccountCreationCheck_->Password = "";
break; break;
} }
break; break;
case 1: case 1: /* SIP account */
{ {
RingD::instance->createSIPAccount(_aliasTextBox_->Text); RingD::instance->createSIPAccount(_ringAliasTextBox_->Text, _sipPasswordBoxAccountCreation_->Password, _sipHostnameTextBox_->Text, _sipUsernameTextBox_->Text);
_accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; _sipPasswordBoxAccountCreation_->Password = "";
_accountsMenuButton__Checked(nullptr, nullptr); _sipUsernameTextBox_->Text = "";
_sipHostnameTextBox_->Text = "";
break; break;
} }
default: default:
break; break;
} }
_aliasTextBox_->Text = "";
_passwordBoxAccountCreation_->Password = ""; _accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_passwordBoxAccountCreationCheck_->Password = ""; _accountsMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_accountsMenuButton__Checked(nullptr, nullptr);
} }
...@@ -728,6 +736,16 @@ void RingClientUWP::Views::SmartPanel::_editAccountMenuButton__Click(Platform::O ...@@ -728,6 +736,16 @@ void RingClientUWP::Views::SmartPanel::_editAccountMenuButton__Click(Platform::O
_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; _createAccountYes_->IsEnabled = false;
_sipAccountStackEditionMenu_->Visibility = (account->accountType_ == "SIP")
? Windows::UI::Xaml::Visibility::Visible
:Windows::UI::Xaml::Visibility::Collapsed;
_upnpStackEditionMenu_->Visibility = (account->accountType_ == "RING")
? Windows::UI::Xaml::Visibility::Visible
: Windows::UI::Xaml::Visibility::Collapsed;
_sipHostnameEditionMenu_->Text = account->_sipHostname;
_sipUsernameEditionTextBox_->Text = account->_sipUsername;
_sipPasswordEditionMenu_->Password = account->_sipPassword;
} }
...@@ -779,8 +797,64 @@ void RingClientUWP::Views::SmartPanel::OnaccountUpdated(RingClientUWP::Account ^ ...@@ -779,8 +797,64 @@ void RingClientUWP::Views::SmartPanel::OnaccountUpdated(RingClientUWP::Account ^
void RingClientUWP::Views::SmartPanel::_passwordBoxAccountCreationCheck__PasswordChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) void RingClientUWP::Views::SmartPanel::_passwordBoxAccountCreationCheck__PasswordChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{ {
_createAccountYes_->IsEnabled = (_passwordBoxAccountCreation_->Password _createAccountYes_->IsEnabled = (_ringPasswordBoxAccountCreation_->Password
== _passwordBoxAccountCreationCheck_->Password == _ringPasswordBoxAccountCreationCheck_->Password
&& _passwordBoxAccountCreation_->Password->Length() > 0) && _