diff --git a/LoadingPage.xaml.cpp b/LoadingPage.xaml.cpp index ac0b6cf69882edbb54934d3c77dc77b1f9d50264..df8bf3d23a29c00eb29767035d39831cd7e3b9b4 100644 --- a/LoadingPage.xaml.cpp +++ b/LoadingPage.xaml.cpp @@ -52,14 +52,12 @@ LoadingPage::LoadingPage() .then([this](bool config_exists) { if (config_exists) { - RingD::instance->hasConfig = true; - this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([this] () { + this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this] () { this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(MainPage::typeid)); })); } else { - RingD::instance->hasConfig = false; - this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([this] () { + this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this] () { this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(Wizard::typeid)); })); } diff --git a/Package.appxmanifest b/Package.appxmanifest index e096e06996ef829b0bf381711874d1649a891468..9cece412bf6a63e24d6ccd6c52c060deda5b13ec 100644 --- a/Package.appxmanifest +++ b/Package.appxmanifest @@ -15,7 +15,7 @@ </Resources> <Applications> <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> <uap:SplashScreen Image="Assets\SplashScreen.png" /> diff --git a/RingD.cpp b/RingD.cpp index 58ccfbec2e1e20608e50bfc51ba4211b21bb6d46..0e6249f8ca6f8464a31bfc8ecedc9b1d6ef18fea 100644 --- a/RingD.cpp +++ b/RingD.cpp @@ -425,16 +425,29 @@ RingClientUWP::RingD::startDaemon() return; } 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::AddSIPAccount)); + break; } - else { - CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High, + case StartingStatus::REGISTERING_THIS_DEVICE: + { + 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([=]() { reloadAccountList(); })); + break; } + } + while (true) { DRing::pollEvents(); dequeueTasks(); @@ -498,6 +511,19 @@ RingD::dequeueTasks() DRing::hangUp(Utils::toString(callId)); } 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: break; } diff --git a/RingD.h b/RingD.h index c1eed29a5ad55630a22160afe0812a8ce7312f72..b8177bc49f14c1bad3a4d787424da9d10138d7a8 100644 --- a/RingD.h +++ b/RingD.h @@ -21,6 +21,10 @@ using namespace concurrency; 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 void IncomingCall(String^ accountId, String^ callId, String^ from); @@ -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: /* functions */ @@ -80,7 +87,7 @@ internal: void hangUpCall2(String^ callId); /* TODO : move members */ - bool hasConfig; + ///bool hasConfig; // replaced by startingStatus std::string accountName; /* events */ @@ -98,7 +105,8 @@ private: RefuseIncommingCall, AcceptIncommingCall, CancelOutGoingCall, - HangUpCall + HangUpCall, + RegisterDevice }; @@ -114,9 +122,16 @@ private: request = r; _callId = c; } + Task(Request r, String^ p, String^ P) { + request = r; + _pin = p; + _password = P; + } public: property Request request; property String^ _callId; + property String^ _pin; + property String^ _password; }; /* functions */ @@ -128,5 +143,6 @@ private: std::string localFolder_; bool daemonRunning_ = false; std::queue<Task^> tasksList_; + StartingStatus startingStatus_ = StartingStatus::NORMAL; }; } \ No newline at end of file diff --git a/SmartPanel.xaml b/SmartPanel.xaml index 4bda00e31b094bcb8f6f9cea8d16585171e3290d..f62e36d2ce65331c3d8b5b7486f1ec93362a01fb 100644 --- a/SmartPanel.xaml +++ b/SmartPanel.xaml @@ -389,6 +389,11 @@ Checked="_shareMenuButton__Checked" Unchecked="_shareMenuButton__Unchecked" Style="{StaticResource ToggleButtonStyle1}"/> + <ToggleButton x:Name="_devicesMenuButton_" + VerticalAlignment="Bottom" + Content="devices;" + Checked="_devicesMenuButton__Checked" + Unchecked="_devicesMenuButton__Unchecked"/> </StackPanel> </StackPanel> <ToggleButton x:Name="_settingsTBtn_" @@ -520,6 +525,34 @@ Grid.Row="2"/> </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="" + Click="_addDevice__Click" + Style="{StaticResource ButtonStyle6}"/> + </Grid> </Grid> <!-- smartList and settings. --> <Grid Grid.Row="1"> diff --git a/SmartPanel.xaml.cpp b/SmartPanel.xaml.cpp index b91a2ac73de208a6d616a2f08806baac7123ac0f..f596aa25c1d40ac14c0470deaab12122d13d15d8 100644 --- a/SmartPanel.xaml.cpp +++ b/SmartPanel.xaml.cpp @@ -463,3 +463,20 @@ Object ^ RingClientUWP::Views::NewMessageBubleNotification::ConvertBack(Object ^ 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) +{ + +} diff --git a/SmartPanel.xaml.h b/SmartPanel.xaml.h index c0176175cda7e782b42994ec40279ff80f1dbd69..64567ad5acb21c6612b966767724a82115401e7e 100644 --- a/SmartPanel.xaml.h +++ b/SmartPanel.xaml.h @@ -95,6 +95,9 @@ private: void _contactItem__PointerReleased(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e); /* 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 diff --git a/Wizard.xaml b/Wizard.xaml index 599ae1c64b35c2b29de3029246c20d3d03ad513c..0b11d97fe9138e698496e75c065559d8d8364835 100644 --- a/Wizard.xaml +++ b/Wizard.xaml @@ -115,7 +115,8 @@ <TextBox x:Name="_PINTextBox_" Margin="10" PlaceholderText="Enter PIN"/> - <PasswordBox Margin="10" + <PasswordBox x:Name="_ArchivePassword_" + Margin="10" PlaceholderText="Enter your password"/> </StackPanel> <!-- buttons yes/no to add the account. --> @@ -127,6 +128,7 @@ VerticalAlignment="Center" HorizontalAlignment="Center" Content="" + Click="_addAccountYes__Click" Style="{StaticResource ButtonStyle2}"/> </StackPanel> </Grid> diff --git a/Wizard.xaml.cpp b/Wizard.xaml.cpp index 13c95565b0225e0ce5a447076210767f3c0f08b8..a643a783965372c6d5030cc90e5d9c84e0a8b27c 100644 --- a/Wizard.xaml.cpp +++ b/Wizard.xaml.cpp @@ -36,7 +36,7 @@ Wizard::_createAccountYes__Click(Object^ sender, RoutedEventArgs^ e) alias = "windows user"; std::wstring wstr(alias->Begin()); 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()); 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)); @@ -75,7 +75,7 @@ Wizard::_avatarWebcamCaptureBtn__Click(Platform::Object^ sender, Windows::UI::Xa cameraCaptureUI->PhotoSettings->CroppedSizeInPixels = Size(100, 100); create_task(cameraCaptureUI->CaptureFileAsync(CameraCaptureUIMode::Photo)) - .then([this](StorageFile^ photoFile) + .then([this](StorageFile^ photoFile) { if (photoFile != nullptr) { // maybe it would be possible to move some logics to the style sheet @@ -92,13 +92,13 @@ Wizard::_avatarWebcamCaptureBtn__Click(Platform::Object^ sender, Windows::UI::Xa StorageFolder^ localfolder = ApplicationData::Current->LocalFolder; String^ profilefolder = ".profile"; create_task(localfolder->CreateFolderAsync(profilefolder, - Windows::Storage::CreationCollisionOption::OpenIfExists)) - .then([=](StorageFolder^ copytofolder){ + Windows::Storage::CreationCollisionOption::OpenIfExists)) + .then([=](StorageFolder^ copytofolder) { try { create_task(photoFile->CopyAsync(copytofolder)) - .then([=](StorageFile^ copiedfile){ + .then([=](StorageFile^ copiedfile) { copiedfile->RenameAsync("profile_image.png", - Windows::Storage::NameCollisionOption::ReplaceExisting); + Windows::Storage::NameCollisionOption::ReplaceExisting); }); } catch (Exception^ e) { @@ -114,4 +114,15 @@ Wizard::_avatarWebcamCaptureBtn__Click(Platform::Object^ sender, Windows::UI::Xa } }); -} \ No newline at end of file +} + +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)); + })); +} diff --git a/Wizard.xaml.h b/Wizard.xaml.h index 7c146a0cddff7afd89f86502f9c740377b563ef8..28cbcd67ece4db184feef3d0d1d3cd997ed72105 100644 --- a/Wizard.xaml.h +++ b/Wizard.xaml.h @@ -16,6 +16,7 @@ private: void _showCreateAccountMenuBtn__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 _addAccountYes__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); }; }