aboutsummaryrefslogtreecommitdiffstats
path: root/src/activity_manager.hpp
diff options
context:
space:
mode:
authorTadao Tanikawa <tanikawa.tadao@jp.panasonic.com>2018-12-04 01:13:04 +0000
committerTadao Tanikawa <tanikawa.tadao@jp.panasonic.com>2018-12-10 01:17:50 +0000
commite35c4bf9b16927829e1741b9d9c08294f0cbed29 (patch)
tree97e0b4a71a445e34a02d5aab6913530713386880 /src/activity_manager.hpp
parent2b1bf85afe0a8b24f75386f7c24df85f9b785bd3 (diff)
POI: AGL LifeCycle Management
Limited function are supported for CES2019 demo. API: registerActivityObserver { "target": $appid } unregisterActivityObserver { "target": $appid } getActivityStatus { "target" : $appid } reply { "response": { "api": "getActivityStatus", "target": $appid, "state": $activity_status } Event: statusChanged { "jtype": "afb-event", "event": "windowmanager/statusChanged", "data": { "state": "CREATED|DESTROYED|STARTED|STOPPED|FOREGROUND|BACKGROUND", "target": $appid } } Change-Id: Ie54c7f379df58667bd5878b4115a3c763c761a83 Signed-off-by: Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com>
Diffstat (limited to 'src/activity_manager.hpp')
-rw-r--r--src/activity_manager.hpp85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/activity_manager.hpp b/src/activity_manager.hpp
new file mode 100644
index 0000000..0663003
--- /dev/null
+++ b/src/activity_manager.hpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2018 Panasonic Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef ACTIVITY_MANAGER_HPP
+#define ACTIVITY_MANAGER_HPP
+
+#include <bitset>
+
+extern "C"
+{
+#include <afb/afb-binding.h>
+}
+
+namespace lcm
+{
+
+#define LCM_EVENT_STATUS_CHANGED "statusChanged"
+#define LCM_API_GET_ACTIVITY_STATUS "getActivityStatus"
+#define LCM_API "api"
+#define LCM_TARGET "target"
+#define LCM_STATE "state"
+
+enum activity_status
+{
+ NOTEXISTS,
+
+ CREATED, // after ON_CREATE
+ DESTROYED,// after ON_DESTROY
+
+ STARTED, // after ON_START, ON_RESTART
+ STOPPED, // after ON_STOP
+
+ FOREGROUND, // after ON_FOREGROUND
+ BACKGROUND, // after ON_BACKGROUND
+
+ NUM_STATUS,
+};
+
+#define ACTIVITY_FILTER_ALL_SET "111111" // For demo, always notify all states
+
+struct _observer_context {
+ afb_event_t event; // onStatusChanged
+ std::bitset<NUM_STATUS> filter; // not supported yet
+};
+
+using observer = struct _observer_context;
+
+// map of <"id:appid", "context of observer">
+using observers = std::map<std::string, observer>;
+
+class ActivityManager
+{
+ public:
+ explicit ActivityManager();
+ ~ActivityManager() = default;
+
+ void api_register_activity_observer (afb_req_t req);
+ void api_unregister_activity_observer (afb_req_t req);
+ wm::result<json_object *> api_get_activity_status(const char *appid);
+
+ public:
+ void emit_activity_status_changed(const char* appid, const char* state);
+
+ // map of <"id:target", "registered observers">
+ std::map<std::string, observers> map_observers;
+ // map of <"id:target", "current_state">
+ std::map<std::string, int> states;
+
+ const char *states_s[NUM_STATUS];
+};
+
+} // namespace lcm
+#endif /* ACTIVITY_MANAGER_HPP */