2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef SRC_APPLICATION_APPLICATION_MANAGER_H__
18 #define SRC_APPLICATION_APPLICATION_MANAGER_H__
20 #include <app_event.h>
21 #include <app_manager.h>
25 #include <package-manager.h>
27 #include <pkgmgr-info.h>
30 #include <context-service/context_history.h>
33 #include "common/picojson.h"
34 #include "common/platform_result.h"
36 typedef std::function<void(picojson::value*)> JsonCallback;
39 namespace application {
41 class ApplicationInstance;
43 class ApplicationManager {
45 explicit ApplicationManager(ApplicationInstance& instance);
46 ~ApplicationManager();
48 void GetCurrentApplication(const std::string& app_id, picojson::object* out);
49 void Kill(const picojson::value& args);
50 void Launch(const picojson::value& args);
51 void LaunchAppControl(const picojson::value& args);
52 void FindAppControl(const picojson::value& args);
53 void GetAppsContext(const picojson::value& args);
54 void GetAppContext(const picojson::value& args, picojson::object* out);
55 void GetAppsInfo(const picojson::value& args);
56 void GetAppInfo(const std::string& app_id, picojson::object* out);
57 void GetAppCerts(const std::string& app_id, picojson::object* out);
58 void GetAppSharedUri(const std::string& app_id, picojson::object* out);
59 void GetAppMetaData(const std::string& app_id, picojson::object* out);
60 void GetBatteryUsageInfo(const picojson::value& args, picojson::object* out);
61 void GetAppsUsageInfo(const picojson::value& args, picojson::object* out);
62 void StartAppInfoEventListener(picojson::object* out);
63 void StopAppInfoEventListener();
64 void GetApplicationInformationSize(const picojson::value& args, picojson::object* out);
65 void AsyncResponse(common::PlatformResult& result, std::shared_ptr<picojson::value>* response);
67 void BroadcastEventHelper(const picojson::value& args, picojson::object& out, bool trusted);
68 common::PlatformResult StartEventListener(const std::string& event_name,
69 const JsonCallback& callback);
70 void StopEventListener(const std::string& event_name);
71 common::PlatformResult StartStatusListener(const JsonCallback& callback);
72 common::PlatformResult StopStatusChangeListener();
75 char* GetPackageId(const std::string& app_id);
77 pkgmgr_client* pkgmgr_client_handle_;
78 pkgmgr_client* pkgmgr_client_uninstall_handle_;
79 ApplicationInstance& instance_;
80 app_manager_event_h app_status_handle_;
82 JsonCallback event_callback_;
83 JsonCallback status_callback_;
84 std::map<std::string, event_handler_h> event_handler_map_;
85 static void OnEvent(const char* event_name,
88 static void OnStatusEvent(const char *type, const char *app_id,
89 app_manager_event_type_e event_type,
90 app_manager_event_state_e event_state,
91 app_manager_event_h handle,
95 static common::PlatformResult GetContextHistory(const picojson::value& args, picojson::object* out,
96 common::PlatformResult (*)(const picojson::value&, const context_history_filter_h, context_history_data_e* data_type),
97 common::PlatformResult (*)(const context_history_record_h, picojson::object*));
99 static common::PlatformResult BatteryUsageFilter(const picojson::value&, const context_history_filter_h, context_history_data_e* data_type);
100 static common::PlatformResult BatteryUsageAttributes(const context_history_record_h, picojson::object*);
102 static common::PlatformResult AppsUsageFilter(const picojson::value&, const context_history_filter_h, context_history_data_e* data_type);
103 static common::PlatformResult AppsUsageAttributes(const context_history_record_h, picojson::object*);
107 } // namespace application
108 } // namespace extension
110 #endif // SRC_APPLICATION_APPLICATION_MANAGER_H__