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>
24 #include <package-manager.h>
27 #include "common/picojson.h"
28 #include "common/platform_result.h"
30 typedef std::function<void(picojson::value*)> JsonCallback;
33 namespace application {
35 class ApplicationInstance;
37 class ApplicationManager {
39 explicit ApplicationManager(ApplicationInstance& instance);
40 ~ApplicationManager();
42 void GetCurrentApplication(const std::string& app_id, picojson::object* out);
43 void Kill(const picojson::value& args);
44 void Launch(const picojson::value& args);
45 void LaunchAppControl(const picojson::value& args);
46 void FindAppControl(const picojson::value& args);
47 void GetAppsContext(const picojson::value& args);
48 void GetAppContext(const picojson::value& args, picojson::object* out);
49 void GetAppsInfo(const picojson::value& args);
50 void GetAppInfo(const std::string& app_id, picojson::object* out);
51 void GetAppCerts(const std::string& app_id, picojson::object* out);
52 void GetAppSharedUri(const std::string& app_id, picojson::object* out);
53 void GetAppMetaData(const std::string& app_id, picojson::object* out);
54 void StartAppInfoEventListener(picojson::object* out);
55 void StopAppInfoEventListener();
56 void GetApplicationInformationSize(const picojson::value& args, picojson::object* out);
57 void AsyncResponse(common::PlatformResult& result, std::shared_ptr<picojson::value>* response);
59 void BroadcastEventHelper(const picojson::value& args, picojson::object& out, bool trusted);
60 common::PlatformResult StartEventListener(const std::string& event_name,
61 const JsonCallback& callback);
62 void StopEventListener(const std::string& event_name);
65 char* GetPackageId(const std::string& app_id);
67 pkgmgr_client* pkgmgr_client_handle_;
68 ApplicationInstance& instance_;
70 JsonCallback event_callback_;
71 std::map<std::string, event_handler_h> event_handler_map_;
72 static void OnEvent(const char* event_name,
77 } // namespace application
78 } // namespace extension
80 #endif // SRC_APPLICATION_APPLICATION_MANAGER_H__