#include <app_event.h>
#include <app_manager.h>
#include <bundle.h>
-#include <functional>
-#include <memory>
#include <package-manager.h>
-#include <string>
#include <pkgmgr-info.h>
#include <functional>
-#ifdef TIZEN_MOBILE
+#include <memory>
+#include <mutex>
+#include <set>
+#include <string>
+#if defined(TIZEN_MOBILE) || defined(TIZEN_COMMON)
#include <context-service/context_history.h>
+#elif defined(TIZEN_WEARABLE)
+#include <context-service/wearable/context_history.h>
#endif
#include "common/picojson.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:
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,
JsonCallback event_callback_;
JsonCallback status_callback_;
std::map<std::string, event_handler_h> event_handler_map_;
- static void OnEvent(const char* event_name,
- bundle* event_data,
- void* user_data);
- static void OnStatusEvent(const char *type, const char *app_id,
+ 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);
-
-#ifdef TIZEN_MOBILE
- static common::PlatformResult GetContextHistory(const picojson::value& args, picojson::object* out,
- common::PlatformResult (*)(const picojson::value&, const context_history_filter_h, context_history_data_e* data_type),
- common::PlatformResult (*)(const context_history_record_h, picojson::object*));
-
- static common::PlatformResult BatteryUsageFilter(const picojson::value&, const context_history_filter_h, context_history_data_e* data_type);
- static common::PlatformResult BatteryUsageAttributes(const context_history_record_h, picojson::object*);
-
- static common::PlatformResult AppsUsageFilter(const picojson::value&, const context_history_filter_h, context_history_data_e* data_type);
- static common::PlatformResult AppsUsageAttributes(const context_history_record_h, picojson::object*);
+ app_manager_event_state_e event_state, app_manager_event_h handle,
+ void* user_data);
+
+#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,
+ context_history_data_e* data_type),
+ common::PlatformResult (*)(const context_history_record_h, picojson::object*));
+
+ static common::PlatformResult BatteryUsageFilter(const picojson::value&,
+ const context_history_filter_h,
+ context_history_data_e* data_type);
+ static common::PlatformResult BatteryUsageAttributes(const context_history_record_h,
+ picojson::object*);
+
+ static common::PlatformResult AppsUsageFilter(const picojson::value&,
+ const context_history_filter_h,
+ context_history_data_e* data_type);
+ static common::PlatformResult AppsUsageAttributes(const context_history_record_h,
+ picojson::object*);
#endif
};
-} // namespace application
-} // namespace extension
+} // namespace application
+} // namespace extension
-#endif // SRC_APPLICATION_APPLICATION_MANAGER_H__
+#endif // SRC_APPLICATION_APPLICATION_MANAGER_H__