Skip to content
Snippets Groups Projects
Commit e4eb5134 authored by Nicolas Jager's avatar Nicolas Jager
Browse files

Wizard : add multi device support

Change-Id: I501120b7a5e1a2b8e90d7a5c8dd8a18a0fb3ed7c
Tuleap: #1207
parent 299aeb9a
No related branches found
No related tags found
No related merge requests found
...@@ -52,14 +52,12 @@ LoadingPage::LoadingPage() ...@@ -52,14 +52,12 @@ LoadingPage::LoadingPage()
.then([this](bool config_exists) .then([this](bool config_exists)
{ {
if (config_exists) { if (config_exists) {
RingD::instance->hasConfig = true; this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this] () {
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([this] () {
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(MainPage::typeid)); this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(MainPage::typeid));
})); }));
} }
else { else {
RingD::instance->hasConfig = false; this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this] () {
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([this] () {
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(Wizard::typeid)); this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(Wizard::typeid));
})); }));
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</Resources> </Resources>
<Applications> <Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="RingClientUWP.App"> <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="RingClientUWP.App">
<uap:VisualElements DisplayName="ring-client-uwp" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="ring-client-uwp" BackgroundColor="transparent"> <uap:VisualElements DisplayName="ring-client-uwp-md" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="ring-client-uwp" BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"> <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
</uap:DefaultTile> </uap:DefaultTile>
<uap:SplashScreen Image="Assets\SplashScreen.png" /> <uap:SplashScreen Image="Assets\SplashScreen.png" />
......
...@@ -425,16 +425,29 @@ RingClientUWP::RingD::startDaemon() ...@@ -425,16 +425,29 @@ RingClientUWP::RingD::startDaemon()
return; return;
} }
else { else {
if (!hasConfig) { switch (_startingStatus) {
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)); tasksList_.push(ref new RingD::Task(Request::AddSIPAccount));
break;
} }
else { case StartingStatus::REGISTERING_THIS_DEVICE:
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High, {
tasksList_.push(ref new RingD::Task(Request::RegisterDevice, _pin, _password));
break;
}
case StartingStatus::NORMAL:
default:
{
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal,
ref new DispatchedHandler([=]() { ref new DispatchedHandler([=]() {
reloadAccountList(); reloadAccountList();
})); }));
break;
} }
}
while (true) { while (true) {
DRing::pollEvents(); DRing::pollEvents();
dequeueTasks(); dequeueTasks();
...@@ -498,6 +511,19 @@ RingD::dequeueTasks() ...@@ -498,6 +511,19 @@ RingD::dequeueTasks()
DRing::hangUp(Utils::toString(callId)); DRing::hangUp(Utils::toString(callId));
} }
break; break;
case Request::RegisterDevice:
{
auto pin = Utils::toString(_pin);
auto password = Utils::toString(_password);
std::map<std::string, std::string> deviceDetails;
deviceDetails.insert(std::make_pair(DRing::Account::ConfProperties::TYPE, "RING"));
//deviceDetails.insert(std::make_pair(DRing::Account::ConfProperties::UPNP_ENABLED, "true"));
//deviceDetails.insert(std::make_pair(DRing::Account::ConfProperties::ALIAS, "MonSuperUsername"));
deviceDetails.insert(std::make_pair(DRing::Account::ConfProperties::ARCHIVE_PIN, pin));
deviceDetails.insert(std::make_pair(DRing::Account::ConfProperties::ARCHIVE_PASSWORD, password));
DRing::addAccount(deviceDetails);
}
default: default:
break; break;
} }
......
...@@ -21,6 +21,10 @@ using namespace concurrency; ...@@ -21,6 +21,10 @@ using namespace concurrency;
namespace RingClientUWP namespace RingClientUWP
{ {
// its ok to keep this enum here and to use it with the wizard, because in pch.h headers are a-z sorted,
// but it would be much more consistent to move this enum in globals.h when merged
public enum class StartingStatus { NORMAL, REGISTERING_ON_THIS_PC, REGISTERING_THIS_DEVICE };
/* delegate */ /* delegate */
delegate void IncomingCall(String^ accountId, String^ callId, String^ from); delegate void IncomingCall(String^ accountId, String^ callId, String^ from);
...@@ -63,6 +67,9 @@ internal: // why this property has to be internal and not public ? ...@@ -63,6 +67,9 @@ internal: // why this property has to be internal and not public ?
} }
} }
property StartingStatus _startingStatus;
property String^ _pin;
property String^ _password;
internal: internal:
/* functions */ /* functions */
...@@ -80,7 +87,7 @@ internal: ...@@ -80,7 +87,7 @@ internal:
void hangUpCall2(String^ callId); void hangUpCall2(String^ callId);
/* TODO : move members */ /* TODO : move members */
bool hasConfig; ///bool hasConfig; // replaced by startingStatus
std::string accountName; std::string accountName;
/* events */ /* events */
...@@ -98,7 +105,8 @@ private: ...@@ -98,7 +105,8 @@ private:
RefuseIncommingCall, RefuseIncommingCall,
AcceptIncommingCall, AcceptIncommingCall,
CancelOutGoingCall, CancelOutGoingCall,
HangUpCall HangUpCall,
RegisterDevice
}; };
...@@ -114,9 +122,16 @@ private: ...@@ -114,9 +122,16 @@ private:
request = r; request = r;
_callId = c; _callId = c;
} }
Task(Request r, String^ p, String^ P) {
request = r;
_pin = p;
_password = P;
}
public: public:
property Request request; property Request request;
property String^ _callId; property String^ _callId;
property String^ _pin;
property String^ _password;
}; };
/* functions */ /* functions */
...@@ -128,5 +143,6 @@ private: ...@@ -128,5 +143,6 @@ private:
std::string localFolder_; std::string localFolder_;
bool daemonRunning_ = false; bool daemonRunning_ = false;
std::queue<Task^> tasksList_; std::queue<Task^> tasksList_;
StartingStatus startingStatus_ = StartingStatus::NORMAL;
}; };
} }
\ No newline at end of file
...@@ -389,6 +389,11 @@ ...@@ -389,6 +389,11 @@
Checked="_shareMenuButton__Checked" Checked="_shareMenuButton__Checked"
Unchecked="_shareMenuButton__Unchecked" Unchecked="_shareMenuButton__Unchecked"
Style="{StaticResource ToggleButtonStyle1}"/> Style="{StaticResource ToggleButtonStyle1}"/>
<ToggleButton x:Name="_devicesMenuButton_"
VerticalAlignment="Bottom"
Content="devices;"
Checked="_devicesMenuButton__Checked"
Unchecked="_devicesMenuButton__Unchecked"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<ToggleButton x:Name="_settingsTBtn_" <ToggleButton x:Name="_settingsTBtn_"
...@@ -520,6 +525,34 @@ ...@@ -520,6 +525,34 @@
Grid.Row="2"/> Grid.Row="2"/>
</Grid> </Grid>
</Grid> </Grid>
<!-- devices menu. -->
<Grid x:Name="_devicesMenuGrid_"
Grid.Row="2"
Visibility="Collapsed"
Background="LightBlue">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid Background="#FFE4F1F9">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<TextBlock Text="devices:"
Grid.Row="0"
HorizontalAlignment="Center"/>
</Grid>
<Button x:Name="_addDevice_"
Grid.Row="1"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Content="&#xE948;"
Click="_addDevice__Click"
Style="{StaticResource ButtonStyle6}"/>
</Grid>
</Grid> </Grid>
<!-- smartList and settings. --> <!-- smartList and settings. -->
<Grid Grid.Row="1"> <Grid Grid.Row="1">
......
...@@ -463,3 +463,20 @@ Object ^ RingClientUWP::Views::NewMessageBubleNotification::ConvertBack(Object ^ ...@@ -463,3 +463,20 @@ Object ^ RingClientUWP::Views::NewMessageBubleNotification::ConvertBack(Object ^
RingClientUWP::Views::NewMessageBubleNotification::NewMessageBubleNotification() RingClientUWP::Views::NewMessageBubleNotification::NewMessageBubleNotification()
{} {}
void RingClientUWP::Views::SmartPanel::_devicesMenuButton__Unchecked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
_devicesMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
}
void RingClientUWP::Views::SmartPanel::_devicesMenuButton__Checked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
_devicesMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
}
void RingClientUWP::Views::SmartPanel::_addDevice__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
}
...@@ -95,6 +95,9 @@ private: ...@@ -95,6 +95,9 @@ private:
void _contactItem__PointerReleased(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e); void _contactItem__PointerReleased(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
/* members */ /* members */
void _devicesMenuButton__Unchecked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _devicesMenuButton__Checked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _addDevice__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
}; };
} }
} }
\ No newline at end of file
...@@ -115,7 +115,8 @@ ...@@ -115,7 +115,8 @@
<TextBox x:Name="_PINTextBox_" <TextBox x:Name="_PINTextBox_"
Margin="10" Margin="10"
PlaceholderText="Enter PIN"/> PlaceholderText="Enter PIN"/>
<PasswordBox Margin="10" <PasswordBox x:Name="_ArchivePassword_"
Margin="10"
PlaceholderText="Enter your password"/> PlaceholderText="Enter your password"/>
</StackPanel> </StackPanel>
<!-- buttons yes/no to add the account. --> <!-- buttons yes/no to add the account. -->
...@@ -127,6 +128,7 @@ ...@@ -127,6 +128,7 @@
VerticalAlignment="Center" VerticalAlignment="Center"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Content="&#xE081;" Content="&#xE081;"
Click="_addAccountYes__Click"
Style="{StaticResource ButtonStyle2}"/> Style="{StaticResource ButtonStyle2}"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
......
...@@ -36,7 +36,7 @@ Wizard::_createAccountYes__Click(Object^ sender, RoutedEventArgs^ e) ...@@ -36,7 +36,7 @@ Wizard::_createAccountYes__Click(Object^ sender, RoutedEventArgs^ e)
alias = "windows user"; alias = "windows user";
std::wstring wstr(alias->Begin()); std::wstring wstr(alias->Begin());
std::string str(wstr.begin(), wstr.end()); std::string str(wstr.begin(), wstr.end());
RingD::instance->hasConfig = false; RingD::instance->_startingStatus = StartingStatus::REGISTERING_ON_THIS_PC;
RingD::instance->accountName = std::string(wstr.begin(), wstr.end()); RingD::instance->accountName = std::string(wstr.begin(), wstr.end());
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([this] () { this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([this] () {
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(RingClientUWP::MainPage::typeid)); this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(RingClientUWP::MainPage::typeid));
...@@ -115,3 +115,14 @@ Wizard::_avatarWebcamCaptureBtn__Click(Platform::Object^ sender, Windows::UI::Xa ...@@ -115,3 +115,14 @@ Wizard::_avatarWebcamCaptureBtn__Click(Platform::Object^ sender, Windows::UI::Xa
}); });
} }
void RingClientUWP::Views::Wizard::_addAccountYes__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
RingD::instance->_pin = _PINTextBox_->Text;
RingD::instance->_password = _ArchivePassword_->Password;
RingD::instance->_startingStatus = StartingStatus::REGISTERING_THIS_DEVICE;
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this]() {
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(RingClientUWP::MainPage::typeid));
}));
}
...@@ -16,6 +16,7 @@ private: ...@@ -16,6 +16,7 @@ private:
void _showCreateAccountMenuBtn__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); void _showAddAccountMenuBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _avatarWebcamCaptureBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void _avatarWebcamCaptureBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _addAccountYes__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
}; };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment