Merge branch 'tizen_3.0' into tizen_4.0
[platform/core/api/webapi-plugins.git] / src / application / application_manager.h
old mode 100755 (executable)
new mode 100644 (file)
index 6229c73..6bb4ecc
 #ifndef SRC_APPLICATION_APPLICATION_MANAGER_H__
 #define SRC_APPLICATION_APPLICATION_MANAGER_H__
 
-#include <string>
-#include <memory>
-
+#include <app_event.h>
+#include <app_manager.h>
+#include <bundle.h>
 #include <package-manager.h>
-#include <string>
 #include <pkgmgr-info.h>
+#include <functional>
+#include <functional>
+#include <memory>
+#include <string>
+#ifdef TIZEN_MOBILE
+#include <context-service/context_history.h>
+#endif
 
 #include "common/picojson.h"
 #include "common/platform_result.h"
 
+typedef std::function<void(picojson::value*)> JsonCallback;
+
 namespace extension {
 namespace application {
 
@@ -49,20 +57,59 @@ class ApplicationManager {
   void GetAppCerts(const std::string& app_id, picojson::object* out);
   void GetAppSharedUri(const std::string& app_id, picojson::object* out);
   void GetAppMetaData(const std::string& app_id, picojson::object* out);
+  void GetBatteryUsageInfo(const picojson::value& args, picojson::object* out);
+  void GetAppsUsageInfo(const picojson::value& args, picojson::object* out);
   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 BroadcastEventHelper(const picojson::value& args, picojson::object& out, bool trusted);
+  common::PlatformResult StartEventListener(const std::string& event_name,
+                                            const JsonCallback& callback);
+  void StopEventListener(const std::string& event_name);
+  common::PlatformResult StartStatusListener(const JsonCallback& callback);
+  common::PlatformResult StopStatusChangeListener();
+
  private:
   char* GetPackageId(const std::string& app_id);
 
   pkgmgr_client* pkgmgr_client_handle_;
-  pkgmgrinfo_client* pkgmgrinfo_client_handle_;
+  pkgmgr_client* pkgmgr_client_uninstall_handle_;
   ApplicationInstance& instance_;
+  app_manager_event_h app_status_handle_;
+
+  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,
+                            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*);
+#endif
 };
 
-} // namespace application
-} // namespace extension
+}  // namespace application
+}  // namespace extension
 
-#endif // SRC_APPLICATION_APPLICATION_MANAGER_H__
+#endif  // SRC_APPLICATION_APPLICATION_MANAGER_H__