[HAM] Added privilege checks in C++.
[platform/core/api/webapi-plugins.git] / src / humanactivitymonitor / humanactivitymonitor_manager.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef HUMANACTIVITYMONITOR_HUMANACTIVITYMONITOR_MANAGER_H
18 #define HUMANACTIVITYMONITOR_HUMANACTIVITYMONITOR_MANAGER_H
19
20 #include <functional>
21 #include <sensor.h>
22 #include <gesture_recognition.h>
23 #include <location_batch.h>
24 #include <string>
25
26 #include "common/picojson.h"
27 #include "common/platform_result.h"
28
29 namespace extension {
30 namespace humanactivitymonitor {
31
32 namespace {
33 const std::string kActivityTypePedometer = "PEDOMETER";
34 const std::string kActivityTypeWristUp = "WRIST_UP";
35 const std::string kActivityTypeHrm = "HRM";
36 const std::string kActivityTypeGps = "GPS";
37 }
38
39 typedef std::function<void(picojson::value*)> JsonCallback;
40
41 class HumanActivityMonitorManager {
42  public:
43   HumanActivityMonitorManager();
44   virtual ~HumanActivityMonitorManager();
45
46   common::PlatformResult Init();
47
48   common::PlatformResult SetListener(const std::string& type,
49                                      JsonCallback callback);
50   common::PlatformResult UnsetListener(const std::string& type);
51
52   common::PlatformResult GetHumanActivityData(const std::string& type,
53                                               picojson::value* data);
54
55  private:
56   // common
57   common::PlatformResult IsSupported(const std::string& type);
58   // WRIST_UP
59   common::PlatformResult SetWristUpListener(JsonCallback callback);
60   common::PlatformResult UnsetWristUpListener();
61   static void OnWristUpEvent(gesture_type_e gesture,
62                              const gesture_data_h data,
63                              double timestamp,
64                              gesture_error_e error,
65                              void* user_data);
66   // HRM
67   common::PlatformResult SetHrmListener(JsonCallback callback);
68   common::PlatformResult UnsetHrmListener();
69   static void OnHrmSensorEvent(sensor_h sensor,
70                                sensor_event_s *event,
71                                void *user_data);
72   common::PlatformResult GetHrmData(picojson::value* data);
73   // GPS
74   common::PlatformResult SetGpsListener(JsonCallback callback);
75   common::PlatformResult UnsetGpsListener();
76   static void OnGpsEvent(int num_of_location, void *user_data);
77   common::PlatformResult GetGpsData(picojson::value* data);
78
79   // common
80   std::map<std::string, bool> supported_;
81   // WRIST_UP
82   gesture_h gesture_handle_;
83   JsonCallback wrist_up_event_callback_;
84   // HRM
85   sensor_listener_h hrm_sensor_listener_;
86   JsonCallback hrm_event_callback_;
87   // GPS
88   location_manager_h location_handle_;
89   JsonCallback gps_event_callback_;
90 };
91
92 } // namespace humanactivitymonitor
93 } // namespace extension
94
95 #endif  // HUMANACTIVITYMONITOR_HUMANACTIVITYMONITOR_MANAGER_H