capi-sensor: recorder: add code skeleton of sensor_recorder APIs
[platform/core/api/sensor.git] / src / sensor_recorder.cpp
1 /*
2  * Copyright (c) 2016 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 #include <stdlib.h>
18 #include <sensor.h>
19 #include <sensor_log.h>
20
21 int sensor_recorder_is_supported(sensor_type_e type, bool *supported)
22 {
23         _D("Called : sensor[%#x]", type);
24
25         if (type <= SENSOR_ALL)
26                 return SENSOR_ERROR_INVALID_PARAMETER;
27         if (!supported)
28                 return SENSOR_ERROR_INVALID_PARAMETER;
29
30         *supported = false;
31
32         return SENSOR_ERROR_NONE;
33 }
34
35 int sensor_recorder_start(sensor_type_e type, sensor_recorder_option_h option)
36 {
37         _D("Called : sensor[%#x] with option[%d]", type, option);
38
39         if (type <= SENSOR_ALL)
40                 return SENSOR_ERROR_INVALID_PARAMETER;
41
42         return SENSOR_ERROR_NOT_SUPPORTED;
43 }
44
45 int sensor_recorder_stop(sensor_type_e type)
46 {
47         _D("Called : sensor[%#x]", type);
48
49         if (type <= SENSOR_ALL)
50                 return SENSOR_ERROR_INVALID_PARAMETER;
51
52         return SENSOR_ERROR_NOT_SUPPORTED;
53 }
54
55 int sensor_recorder_create_option(sensor_recorder_option_h *option)
56 {
57         _D("Called : option[%#x]", *option);
58
59         if (!option)
60                 return SENSOR_ERROR_INVALID_PARAMETER;
61
62         *option = (sensor_recorder_option_h)malloc(sizeof(sensor_recorder_option_h));
63
64         return SENSOR_ERROR_NONE;
65 }
66
67 int sensor_recorder_destroy_option(sensor_recorder_option_h option)
68 {
69         _D("Called : option[%#x]", option);
70
71         if (!option)
72                 return SENSOR_ERROR_INVALID_PARAMETER;
73
74         return SENSOR_ERROR_NONE;
75 }
76
77 int sensor_recorder_option_set_int(sensor_recorder_option_h option, sensor_recorder_option_e attribute, int value)
78 {
79         _D("Called : attribute[%d] with value[%d] to option[%#x]", attribute, value, option);
80
81         if (!option)
82                 return SENSOR_ERROR_INVALID_PARAMETER;
83         if (attribute < 0)
84                 return SENSOR_ERROR_INVALID_PARAMETER;
85
86         return SENSOR_ERROR_NONE;
87 }
88
89 int sensor_recorder_create_query(sensor_recorder_query_h *query)
90 {
91         _D("Called : query[%#x]", *query);
92
93         if (!query)
94                 return SENSOR_ERROR_INVALID_PARAMETER;
95
96         *query = (sensor_recorder_query_h)malloc(sizeof(sensor_recorder_query_h));
97
98         return SENSOR_ERROR_NONE;
99 }
100
101 int sensor_recorder_destroy_query(sensor_recorder_query_h query)
102 {
103         _D("Called : query[%#x]", query);
104
105         if (!query)
106                 return SENSOR_ERROR_INVALID_PARAMETER;
107
108         return SENSOR_ERROR_NONE;
109 }
110
111 int sensor_recorder_query_set_int(sensor_recorder_query_h query, sensor_recorder_query_e attribute, int value)
112 {
113         _D("Called : attribute[%d] with value[%d] to query[%#x]", attribute, value, query);
114
115         if (!query)
116                 return SENSOR_ERROR_INVALID_PARAMETER;
117         if (attribute < 0)
118                 return SENSOR_ERROR_INVALID_PARAMETER;
119
120         return SENSOR_ERROR_NONE;
121 }
122
123 int sensor_recorder_query_set_time(sensor_recorder_query_h query, sensor_recorder_query_e attribute, time_t t)
124 {
125         _D("Called : attribute[%d] with time[%d] to query[%#x]", attribute, time(&t), query);
126
127         if (!query)
128                 return SENSOR_ERROR_INVALID_PARAMETER;
129         if (attribute < 0)
130                 return SENSOR_ERROR_INVALID_PARAMETER;
131
132         return SENSOR_ERROR_NONE;
133 }
134
135 int sensor_recorder_read(sensor_type_e type, sensor_recorder_query_h query, sensor_recorder_data_cb cb, void *user_data)
136 {
137         _D("Called : query[%#x]", query);
138
139         if (type <= SENSOR_ALL)
140                 return SENSOR_ERROR_INVALID_PARAMETER;
141         if (!query || !cb)
142                 return SENSOR_ERROR_INVALID_PARAMETER;
143
144         return SENSOR_ERROR_NONE;
145 }
146
147 int sensor_recorder_read_sync(sensor_type_e type, sensor_recorder_query_h query, sensor_recorder_data_cb cb, void *user_data)
148 {
149         _D("Called : query[%#x]", query);
150
151         if (type <= SENSOR_ALL)
152                 return SENSOR_ERROR_INVALID_PARAMETER;
153         if (!query || !cb)
154                 return SENSOR_ERROR_INVALID_PARAMETER;
155
156         return SENSOR_ERROR_NONE;
157 }
158
159 int sensor_recorder_data_get_time(sensor_recorder_data_h data, time_t *start_time, time_t *end_time)
160 {
161         _D("Called : data[%#x]", data);
162
163         if (!data || !start_time || !end_time)
164                 return SENSOR_ERROR_INVALID_PARAMETER;
165
166         return SENSOR_ERROR_NONE;
167 }
168
169 int sensor_recorder_data_get_int(sensor_recorder_data_h data, sensor_recorder_data_e key, int *value)
170 {
171         _D("Called : key[%d], data[%#x]", key, data);
172
173         if (!data || !value)
174                 return SENSOR_ERROR_INVALID_PARAMETER;
175         if (key < 0)
176                 return SENSOR_ERROR_INVALID_PARAMETER;
177
178         return SENSOR_ERROR_NONE;
179 }
180
181 int sensor_recorder_data_get_double(sensor_recorder_data_h data, sensor_recorder_data_e key, double *value)
182 {
183         _D("Called : key[%d], data[%#x]", key, data);
184
185         if (!data || !value)
186                 return SENSOR_ERROR_INVALID_PARAMETER;
187         if (key < 0)
188                 return SENSOR_ERROR_INVALID_PARAMETER;
189
190         return SENSOR_ERROR_NONE;
191 }