Skip to content
Snippets Groups Projects
Commit 6290cc3b authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Andreas Traczyk
Browse files

internal: add application ExtendedExecution state

- adds exetended execution after quitting
- hangs up calls upon quitting
- cleans camera objects on termination
- only fades loading screen when last account is registered

Change-Id: I50336c43690c0d7dc38377ea846cedddfc3f0f44
Tuleap: #1208
parent d57809fd
Branches
Tags
No related merge requests found
...@@ -172,7 +172,7 @@ ContactsViewModel::Destringify(String^ data) ...@@ -172,7 +172,7 @@ ContactsViewModel::Destringify(String^ data)
void RingClientUWP::ViewModel::ContactsViewModel::OnincomingMessage(Platform::String ^callId, Platform::String ^payload) void RingClientUWP::ViewModel::ContactsViewModel::OnincomingMessage(Platform::String ^callId, Platform::String ^payload)
{ {
auto itemlist = SmartPanelItemsViewModel::instance->itemsList;
auto item = SmartPanelItemsViewModel::instance->findItem(callId); auto item = SmartPanelItemsViewModel::instance->findItem(callId);
auto contact = item->_contact; auto contact = item->_contact;
......
...@@ -71,6 +71,13 @@ MainPage::MainPage() ...@@ -71,6 +71,13 @@ MainPage::MainPage()
DisplayInformation^ displayInformation = DisplayInformation::GetForCurrentView(); DisplayInformation^ displayInformation = DisplayInformation::GetForCurrentView();
dpiChangedtoken = (displayInformation->DpiChanged += ref new TypedEventHandler<DisplayInformation^, dpiChangedtoken = (displayInformation->DpiChanged += ref new TypedEventHandler<DisplayInformation^,
Platform::Object^>(this, &MainPage::DisplayProperties_DpiChanged)); Platform::Object^>(this, &MainPage::DisplayProperties_DpiChanged));
visibilityChangedEventToken = Window::Current->VisibilityChanged +=
ref new WindowVisibilityChangedEventHandler(this, &MainPage::Application_VisibilityChanged);
applicationSuspendingEventToken = Application::Current->Suspending +=
ref new SuspendingEventHandler(this, &MainPage::Application_Suspending);
applicationResumingEventToken = Application::Current->Resuming +=
ref new EventHandler<Object^>(this, &MainPage::Application_Resuming);
} }
void void
...@@ -251,21 +258,34 @@ void RingClientUWP::MainPage::OnstateChange(Platform::String ^callId, RingClient ...@@ -251,21 +258,34 @@ void RingClientUWP::MainPage::OnstateChange(Platform::String ^callId, RingClient
} }
} }
#include <dring.h>
#include "callmanager_interface.h"
void void
MainPage::Application_Suspending(Object^, Windows::ApplicationModel::SuspendingEventArgs^ e) MainPage::Application_Suspending(Object^, Windows::ApplicationModel::SuspendingEventArgs^ e)
{ {
WriteLine("Application_Suspending"); WriteLine("Application_Suspending");
if (Frame->CurrentSourcePageType.Name == if (Frame->CurrentSourcePageType.Name ==
Interop::TypeName(MainPage::typeid).Name) Interop::TypeName(MainPage::typeid).Name) {
{
if (Video::VideoManager::instance->captureManager()->captureTaskTokenSource)
Video::VideoManager::instance->captureManager()->captureTaskTokenSource->cancel();
//displayInformation->OrientationChanged -= displayInformationEventToken;
auto deferral = e->SuspendingOperation->GetDeferral(); auto deferral = e->SuspendingOperation->GetDeferral();
Video::VideoManager::instance->captureManager()->CleanupCameraAsync() BeginExtendedExecution()
.then([this, deferral]() { .then([=](task<void> previousTask) {
try {
previousTask.get();
}
catch (Exception^ e) {
WriteLine("Exception: Extended Execution Begin");
}
})
.then([this, deferral](task<void> previousTask) {
try {
previousTask.get();
WriteLine("deferral->Complete()");
deferral->Complete();
}
catch (Exception^ e) {
WriteLine("Exception: Extended Execution");
deferral->Complete(); deferral->Complete();
}
}); });
} }
} }
...@@ -273,16 +293,76 @@ MainPage::Application_Suspending(Object^, Windows::ApplicationModel::SuspendingE ...@@ -273,16 +293,76 @@ MainPage::Application_Suspending(Object^, Windows::ApplicationModel::SuspendingE
void void
MainPage::Application_VisibilityChanged(Object^ sender, VisibilityChangedEventArgs^ e) MainPage::Application_VisibilityChanged(Object^ sender, VisibilityChangedEventArgs^ e)
{ {
if (e->Visible) if (e->Visible) {
{
WriteLine("->Visible"); WriteLine("->Visible");
if (Video::VideoManager::instance->captureManager()->isInitialized) { //Video::VideoManager::instance->
Video::VideoManager::instance->captureManager()->InitializeCameraAsync();
} }
else {
WriteLine("->Invisible");
//Video::VideoManager::instance->captureManager()->CleanupCameraAsync();
} }
else }
void MainPage::Application_Resuming(Object^, Object^)
{ {
WriteLine("->Invisible"); WriteLine("Application_Resuming");
} }
void
MainPage::SessionRevoked(Object^ sender, ExtendedExecutionRevokedEventArgs^ args)
{
Dispatcher->RunAsync(CoreDispatcherPriority::High, ref new DispatchedHandler([=]() {
ClearExtendedExecution();
}));
} }
void
MainPage::ClearExtendedExecution()
{
if (session != nullptr) {
WriteLine("End Extended Execution");
session->Revoked -= sessionRevokedToken;
}
}
task<void>
MainPage::BeginExtendedExecution()
{
ClearExtendedExecution();
auto newSession = ref new ExtendedExecutionSession();
newSession->Reason = ExtendedExecutionReason::SavingData;
newSession->Description = "Extended Execution";
sessionRevokedToken = (newSession->Revoked += ref new TypedEventHandler<Object^,
ExtendedExecutionRevokedEventArgs^>(this, &MainPage::SessionRevoked));
return create_task(newSession->RequestExtensionAsync())
.then([=](ExtendedExecutionResult result){
try {
switch (result)
{
case ExtendedExecutionResult::Allowed:
session = newSession;
WriteLine("Request Extended Execution Allowed");
WriteLine("Clean up camera...");
Video::VideoManager::instance->captureManager()->CleanupCameraAsync()
.then([](){
WriteLine("Hang up calls...");
for (auto item : SmartPanelItemsViewModel::instance->itemsList) {
if (item->_callId && item->_callStatus != CallStatus::NONE) {
DRing::hangUp(Utils::toString(item->_callId));
}
}
});
break;
default:
case ExtendedExecutionResult::Denied:
WriteLine("Request Extended Execution Denied");
break;
}
}
catch (Exception^ e) {
WriteLine("Exception: Extended Execution Request");
}
});
}
\ No newline at end of file
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
using namespace Windows::UI::Xaml::Controls; using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Input; using namespace Windows::UI::Xaml::Input;
using namespace Windows::Foundation; using namespace Windows::Foundation;
using namespace Windows::ApplicationModel::ExtendedExecution;
namespace RingClientUWP namespace RingClientUWP
{ {
...@@ -45,13 +46,25 @@ protected: ...@@ -45,13 +46,25 @@ protected:
void OnResize(Platform::Object^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ e); void OnResize(Platform::Object^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ e);
private: private:
// event handlers // Visibility and suspension
void Application_Suspending(Object^, Windows::ApplicationModel::SuspendingEventArgs^ e); void Application_Suspending(Object^, Windows::ApplicationModel::SuspendingEventArgs^ e);
EventRegistrationToken applicationSuspendingEventToken;
void Application_VisibilityChanged(Object^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ e); void Application_VisibilityChanged(Object^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ e);
EventRegistrationToken visibilityChangedEventToken;
void Application_Resuming(Object^ sender, Object^ args);
EventRegistrationToken applicationResumingEventToken;
//void Application_Closing(Object^ sender, Windows::UI::Core::^ e);
//EventRegistrationToken applicationClosingEventToken;
ExtendedExecutionSession^ session;
void SessionRevoked(Object^ sender, ExtendedExecutionRevokedEventArgs^ args);
EventRegistrationToken sessionRevokedToken;
task<void> BeginExtendedExecution();
void ClearExtendedExecution();
// Multi-monitor, DPI, scale factor change, and window resize detection // Multi-monitor, DPI, scale factor change, and window resize detection
void DisplayProperties_DpiChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args); void DisplayProperties_DpiChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args);
Windows::Foundation::EventRegistrationToken dpiChangedtoken; EventRegistrationToken dpiChangedtoken;
Rect bounds; Rect bounds;
void _toggleSmartBoxButton__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void _toggleSmartBoxButton__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
......
...@@ -296,9 +296,6 @@ RingClientUWP::RingD::startDaemon() ...@@ -296,9 +296,6 @@ RingClientUWP::RingD::startDaemon()
auto callId2 = toPlatformString(callId); auto callId2 = toPlatformString(callId);
auto from2 = toPlatformString(from); auto from2 = toPlatformString(from);
///from2 = Utils::TrimFrom(from2);
const std::string PROFILE_VCF = "x-ring/ring.profile.vcard"; const std::string PROFILE_VCF = "x-ring/ring.profile.vcard";
static const unsigned int profileSize = PROFILE_VCF.size(); static const unsigned int profileSize = PROFILE_VCF.size();
...@@ -328,8 +325,12 @@ RingClientUWP::RingD::startDaemon() ...@@ -328,8 +325,12 @@ RingClientUWP::RingD::startDaemon()
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High, CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() { ref new DispatchedHandler([=]() {
reloadAccountList(); reloadAccountList();
std::vector<std::string> accountList = DRing::getAccountList();
auto last_id = accountList.back();
if (!account_id.compare(last_id)) {
auto frame = dynamic_cast<Frame^>(Window::Current->Content); auto frame = dynamic_cast<Frame^>(Window::Current->Content);
dynamic_cast<RingClientUWP::MainPage^>(frame->Content)->showLoadingOverlay(false, false); dynamic_cast<RingClientUWP::MainPage^>(frame->Content)->showLoadingOverlay(false, false);
}
})); }));
} }
}), }),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment