[Common] Changed configuration for common profile build
[platform/core/api/webapi-plugins.git] / src / application / application_manager.h
index c1fa8ad..a7485ce 100644 (file)
 #include <package-manager.h>
 #include <pkgmgr-info.h>
 #include <functional>
-#include <functional>
 #include <memory>
+#include <mutex>
+#include <set>
 #include <string>
-#if defined(TIZEN_MOBILE)
+#if defined(TIZEN_MOBILE) || defined(TIZEN_COMMON)
 #include <context-service/context_history.h>
 #elif defined(TIZEN_WEARABLE)
 #include <context-service/wearable/context_history.h>
 #include "common/platform_result.h"
 
 typedef std::function<void(picojson::value*)> JsonCallback;
-
 namespace extension {
 namespace application {
 
 class ApplicationInstance;
+typedef struct LaunchAppControlCallbackDataStruct {
+  ApplicationInstance* instance;
+  std::shared_ptr<picojson::value> response;
+  std::string reply_callback_id;
+} LaunchAppControlCallbackData;
 
 class ApplicationManager {
  public:
@@ -64,7 +69,8 @@ class ApplicationManager {
   void StartAppInfoEventListener(picojson::object* out);
   void StopAppInfoEventListener();
   void GetApplicationInformationSize(const picojson::value& args, picojson::object* out);
-  void AsyncResponse(common::PlatformResult& result, std::shared_ptr<picojson::value>* response);
+  void AsyncResponse(const common::PlatformResult& result,
+                     std::shared_ptr<picojson::value>* response);
 
   void BroadcastEventHelper(const picojson::value& args, picojson::object& out, bool trusted);
   common::PlatformResult StartEventListener(const std::string& event_name,
@@ -84,13 +90,18 @@ class ApplicationManager {
   JsonCallback event_callback_;
   JsonCallback status_callback_;
   std::map<std::string, event_handler_h> event_handler_map_;
+  std::set<LaunchAppControlCallbackData*> launch_app_control_set_;
+  // We use static set of callback_data's pointers to be able to check whether
+  // callback is fired after ApplicationInstance destruction
+  static std::set<LaunchAppControlCallbackData*> launch_app_control_set_global_;
+  static std::mutex launch_app_control_set_mutex_;
   static void OnEvent(const char* event_name, bundle* event_data, void* user_data);
   static void OnStatusEvent(const char* type, const char* app_id,
                             app_manager_event_type_e event_type,
                             app_manager_event_state_e event_state, app_manager_event_h handle,
                             void* user_data);
 
-#if defined(TIZEN_MOBILE) || defined(TIZEN_WEARABLE)
+#if defined(TIZEN_MOBILE) || defined(TIZEN_WEARABLE) || defined(TIZEN_COMMON)
   static common::PlatformResult GetContextHistory(
       const picojson::value& args, picojson::object* out,
       common::PlatformResult (*)(const picojson::value&, const context_history_filter_h,