From 2d4a68a9141e796841aff92cae1016a366ae1e4d Mon Sep 17 00:00:00 2001 From: Nicolas Jager <nicolas.jager@savoirfairelinux.com> Date: Fri, 21 Oct 2016 12:29:53 -0400 Subject: [PATCH] fix : client crashes in case of empty account list. - summons the wizard. - nb : this patch doesn't solve the problem in the daemon Change-Id: Ice12e43c04a299affa093031e772ee013b801178 Tuleap: #1240 --- App.xaml.cpp | 11 ++++++++++- App.xaml.h | 1 + RingD.cpp | 9 ++++++++- RingD.h | 2 ++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/App.xaml.cpp b/App.xaml.cpp index 7239a55..bd5300b 100644 --- a/App.xaml.cpp +++ b/App.xaml.cpp @@ -19,6 +19,7 @@ #include "LoadingPage.xaml.h" #include "MainPage.xaml.h" +#include "Wizard.xaml.h" using namespace Windows::ApplicationModel::Core; using namespace Windows::Foundation; @@ -35,6 +36,9 @@ using namespace RingClientUWP; App::App() { InitializeComponent(); // summon partial class, form generated files trough App.xaml + + /* connect to delegate */ + RingD::instance->summonWizard += ref new RingClientUWP::SummonWizard(this, &RingClientUWP::App::OnsummonWizard); } void @@ -59,4 +63,9 @@ App::OnLaunched(LaunchActivatedEventArgs^ e) ApplicationView::GetForCurrentView()->TitleBar->BackgroundColor = Colors::LightBlue; ApplicationView::GetForCurrentView()->TitleBar->ForegroundColor = Colors::White; ApplicationView::GetForCurrentView()->TitleBar->ButtonForegroundColor = Colors::White; -} \ No newline at end of file +} + +void RingClientUWP::App::OnsummonWizard() +{ + rootFrame->Navigate(Windows::UI::Xaml::Interop::TypeName(Views::Wizard::typeid)); +} diff --git a/App.xaml.h b/App.xaml.h index cdc1f26..a638f50 100644 --- a/App.xaml.h +++ b/App.xaml.h @@ -33,5 +33,6 @@ internal: private: Frame^ rootFrame; + void OnsummonWizard(); }; } \ No newline at end of file diff --git a/RingD.cpp b/RingD.cpp index 814d080..a6d001f 100644 --- a/RingD.cpp +++ b/RingD.cpp @@ -47,6 +47,13 @@ RingClientUWP::RingD::reloadAccountList() RingClientUWP::ViewModel::AccountsViewModel::instance->clearAccountList(); std::vector<std::string> accountList = DRing::getAccountList(); + + /* if for any reason there is no account at all, screen the wizard */ + if (accountList.size() == 0) { + summonWizard(); + return; + } + std::vector<std::string>::reverse_iterator rit = accountList.rbegin(); for (; rit != accountList.rend(); ++rit) { @@ -380,7 +387,7 @@ RingClientUWP::RingD::startDaemon() CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High, ref new DispatchedHandler([=]() { reloadAccountList(); - std::vector<std::string> accountList = DRing::getAccountList(); + std::vector<std::string> accountList = DRing::getAccountList(); // refacto : there is already a callo to getAccountList in reloadAccountList auto last_id = accountList.back(); if (!account_id.compare(last_id)) { auto frame = dynamic_cast<Frame^>(Window::Current->Content); diff --git a/RingD.h b/RingD.h index b776f07..7c29da7 100644 --- a/RingD.h +++ b/RingD.h @@ -34,6 +34,7 @@ delegate void CallPlaced(String^ callId); delegate void IncomingMessage(String^ callId, String^ payload); delegate void DevicesListRefreshed(Vector<String^>^ devicesList); delegate void ExportOnRingEnded(String^ accountId, String^ pin); +delegate void SummonWizard(); public ref class RingD sealed @@ -109,6 +110,7 @@ internal: event CallPlaced^ callPlaced; event DevicesListRefreshed^ devicesListRefreshed; event ExportOnRingEnded^ exportOnRingEnded; + event SummonWizard^ summonWizard; private: /* sub classes */ -- GitLab