From 085877491630a1e60d7f14d6b743e0ba6ea13894 Mon Sep 17 00:00:00 2001 From: deepti Date: Wed, 28 Mar 2018 11:46:09 +0530 Subject: [PATCH] Handling app Control Data 1)Take decision whether to launch or send app control data. 2)Parsing of config file to check whether to reload or not. Change-Id: I51f0d48aba58ca62d185b994beca12abb9344578 Signed-off-by: deepti --- atom/app/ui_runtime.cc | 7 +++++++ atom/browser/browser.cc | 31 +++++++++++++++++++++++++++++-- atom/browser/browser.h | 14 ++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/atom/app/ui_runtime.cc b/atom/app/ui_runtime.cc index 2593e32..c773aca 100644 --- a/atom/app/ui_runtime.cc +++ b/atom/app/ui_runtime.cc @@ -66,6 +66,13 @@ void UiRuntime::OnAppControl(app_control_h app_control) { common::AppDB* appdb = common::AppDB::GetInstance(); appdb->Set(kAppDBRuntimeSection, kAppDBRuntimeBundle, appcontrol->encoded_bundle()); + atom::Browser *browser_model = atom::Browser::Get(); + if (browser_model->launched()) { + browser_model->AppControl(std::move(appcontrol)); + } else { + browser_model->Initialize(); + browser_model->Launch(std::move(appcontrol)); + } } void UiRuntime::OnLanguageChanged(const std::string& language) { diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index 2678b1c..2a36143 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -16,14 +16,16 @@ #include "base/run_loop.h" #include "base/threading/thread_task_runner_handle.h" #include "brightray/browser/brightray_paths.h" - +#include "tizen/common/command_line.h" namespace atom { Browser::Browser() : is_quiting_(false), is_exiting_(false), is_ready_(false), - is_shutdown_(false) { + is_shutdown_(false), + launched_(false), + locale_manager_(new common::LocaleManager()) { WindowList::AddObserver(this); } @@ -225,4 +227,29 @@ void Browser::Show() { observer.OnResume(); } +void Browser::Initialize() { + common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); + std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron"); + //TODO: update the appid from binary name to electron + if (appid != "electron") { + auto appdata_manager = common::ApplicationDataManager::GetInstance(); + common::ApplicationData* appdata = appdata_manager->GetApplicationData(appid); + + resource_manager_.reset( + new common::ResourceManager(appdata, locale_manager_.get())); + } +} + +void Browser::AppControl(std::unique_ptr appcontrol) { + std::unique_ptr res = + resource_manager_->GetStartResource(appcontrol.get()); + bool do_reset = res->should_reset(); +//To do: Implementation of reset case according to parsed config file parameter. +} + +void Browser::Launch(std::unique_ptr appcontrol) { + launched_ = true; +//To do:Implementation of relaunching of app +} + } // namespace atom diff --git a/atom/browser/browser.h b/atom/browser/browser.h index fc674dd..286ba29 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -16,6 +16,10 @@ #include "base/strings/string16.h" #include "base/values.h" #include "native_mate/arguments.h" +#include "tizen/common/app_control.h" +#include "tizen/common/application_data.h" +#include "tizen/common/resource_manager.h" +#include "tizen/common/locale_manager.h" #if defined(OS_WIN) #include "base/files/file_path.h" @@ -42,6 +46,10 @@ class Browser : public WindowListObserver { static Browser* Get(); + std::unique_ptr resource_manager_; + std::unique_ptr locale_manager_; + + void Initialize(); // Try to close all windows and quit the application. void Quit(); @@ -89,6 +97,7 @@ class Browser : public WindowListObserver { // Set/Get the badge count. bool SetBadgeCount(int count); + bool launched() const { return launched_; } int GetBadgeCount(); // Set/Get the login item settings of the app @@ -106,6 +115,9 @@ class Browser : public WindowListObserver { void Hide(); void Show(); + void AppControl(std::unique_ptr appcontrol); + void Launch(std::unique_ptr appcontrol); + #if defined(OS_MACOSX) // Hide the application. void Hide(); @@ -226,6 +238,8 @@ class Browser : public WindowListObserver { bool is_quiting_; + bool launched_; + private: // WindowListObserver implementations: void OnWindowCloseCancelled(NativeWindow* window) override; -- 2.7.4