Handling app Control Data 04/174104/8
authordeepti <d.saraswat@samsung.com>
Wed, 28 Mar 2018 06:16:09 +0000 (11:46 +0530)
committerjaekuk lee <juku1999@samsung.com>
Wed, 4 Apr 2018 10:11:04 +0000 (10:11 +0000)
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 <d.saraswat@samsung.com>
atom/app/ui_runtime.cc
atom/browser/browser.cc
atom/browser/browser.h

index 2593e32..c773aca 100644 (file)
@@ -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) {
index 2678b1c..2a36143 100644 (file)
 #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<common::AppControl> appcontrol) {
+  std::unique_ptr<common::ResourceManager::Resource> 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<common::AppControl> appcontrol) {
+  launched_ = true;
+//To do:Implementation of relaunching of app
+}
+
 }  // namespace atom
index fc674dd..286ba29 100644 (file)
 #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<common::ResourceManager> resource_manager_;
+  std::unique_ptr<common::LocaleManager> 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<common::AppControl> appcontrol);
+  void Launch(std::unique_ptr<common::AppControl> 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;