sensor-rec: Add Internal CAPIs for client 51/121551/2
authorkibak.yoon <kibak.yoon@samsung.com>
Tue, 28 Mar 2017 07:54:43 +0000 (16:54 +0900)
committerkibak.yoon <kibak.yoon@samsung.com>
Tue, 28 Mar 2017 12:08:51 +0000 (21:08 +0900)
Change-Id: Ia0cc80b08d371fcd0ccaf857640aefcfd7075049
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
include/SensorRecorder.h [deleted file]
include/SensorRecorderService.h
include/SensorRecorderTypes.h [deleted file]
include/sensor_recorder_internal.h [new file with mode: 0644]
src/client-dummy/SensorRecorder.cpp [deleted file]
src/client-dummy/sensor_recorder.cpp [new file with mode: 0644]
src/client/SensorRecorder.cpp [deleted file]
src/client/sensor_recorder.cpp [new file with mode: 0644]
src/shared/SensorRecorderTypesPrivate.h

diff --git a/include/SensorRecorder.h b/include/SensorRecorder.h
deleted file mode 100644 (file)
index 94964ac..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * 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 __SENSOR_RECORDER_H__
-#define __SENSOR_RECORDER_H__
-
-#include <SensorRecorderTypes.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-int sensor_recorder_test();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
index 79ebf2a..50f9a8b 100644 (file)
@@ -20,7 +20,6 @@
 /* This header SHOULD NOT be included by other headers in this directory. */
 
 #include <ServiceBase.h>
-#include <SensorRecorderTypes.h>
 
 namespace ctx {
 
diff --git a/include/SensorRecorderTypes.h b/include/SensorRecorderTypes.h
deleted file mode 100644 (file)
index 00fbaed..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * 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 __SENSOR_RECORDER_TYPES_H__
-#define __SENSOR_RECORDER_TYPES_H__
-
-#include <tizen.h>
-
-
-#endif
diff --git a/include/sensor_recorder_internal.h b/include/sensor_recorder_internal.h
new file mode 100644 (file)
index 0000000..7ba49aa
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * 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 __CAPI_SENSOR_RECORDER_INTERNAL_H__
+#define __CAPI_SENSOR_RECORDER_INTERNAL_H__
+
+#include <tizen.h>
+#include <time.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* Error */
+#define CTX_SENSOR_RECORDER_ERROR_STARTED                (TIZEN_ERROR_CONTEXT | 0x01)
+
+/* Subject name */
+#define CTX_SENSOR_RECORDER_BASE "sensor/"
+#define CTX_SENSOR_RECORDER_PEDOMETER             CTX_SENSOR_RECORDER_BASE "pedometer"
+#define CTX_SENSOR_RECORDER_PRESSURE              CTX_SENSOR_RECORDER_BASE "pressure"
+#define CTX_SENSOR_RECORDER_HEART_RATE            CTX_SENSOR_RECORDER_BASE "heart_rate"
+#define CTX_SENSOR_RECORDER_SLEEP_MONITOR         CTX_SENSOR_RECORDER_BASE "sleep"
+
+/* Key */
+#define CTX_SENSOR_RECORDER_KEY_RETENTION   "Retention"
+#define CTX_SENSOR_RECORDER_KEY_INTERVAL    "Interval"
+#define CTX_SENSOR_RECORDER_KEY_START_TIME  "StartTime"
+#define CTX_SENSOR_RECORDER_KEY_END_TIME    "EndTime"
+#define CTX_SENSOR_RECORDER_KEY_ANCHOR      "Anchor"
+
+#define CTX_SENSOR_RECORDER_KEY_STEPS         "Steps"
+#define CTX_SENSOR_RECORDER_KEY_WALK_STEPS    "WalkSteps"
+#define CTX_SENSOR_RECORDER_KEY_RUN_STEPS     "RunSteps"
+#define CTX_SENSOR_RECORDER_KEY_DISTANCE      "Dist"
+#define CTX_SENSOR_RECORDER_KEY_CALORIES      "Cal"
+#define CTX_SENSOR_RECORDER_KEY_PRESSURE      "Pressure"
+#define CTX_SENSOR_RECORDER_KEY_AVG_PRESSURE  "AvgPressure"
+#define CTX_SENSOR_RECORDER_KEY_MIN_PRESSURE  "MinPressure"
+#define CTX_SENSOR_RECORDER_KEY_MAX_PRESSURE  "MaxPressure"
+#define CTX_SENSOR_RECORDER_KEY_SLEEP_STATE   "SleepState"
+#define CTX_SENSOR_RECORDER_KEY_HEART_RATE    "HeartRate"
+
+typedef void* ctx_sensor_rec_option_h;
+
+typedef void* ctx_sensor_rec_query_h;
+
+typedef void* ctx_sensor_rec_data_h;
+
+typedef int ctx_sensor_rec_error_e;
+
+int ctx_sensor_rec_is_supported(const char* subject, bool *supported);
+
+int ctx_sensor_rec_start(const char* subject, ctx_sensor_rec_option_h option);
+
+int ctx_sensor_rec_stop(const char* subject);
+
+
+int ctx_sensor_rec_create_option(ctx_sensor_rec_option_h *option);
+
+int ctx_sensor_rec_destroy_option(ctx_sensor_rec_option_h option);
+
+int ctx_sensor_rec_option_set_int(ctx_sensor_rec_option_h option, const char* param, int value);
+
+
+int ctx_sensor_rec_create_query(ctx_sensor_rec_query_h *query);
+
+int ctx_sensor_rec_destroy_query(ctx_sensor_rec_query_h query);
+
+int ctx_sensor_rec_query_set_int(ctx_sensor_rec_query_h query, const char* param, int value);
+
+int ctx_sensor_rec_query_set_time(ctx_sensor_rec_query_h query, const char* param, time_t t);
+
+
+typedef bool (*ctx_sensor_rec_data_cb)(const char* subject, ctx_sensor_rec_data_h data, int remains, ctx_sensor_rec_error_e error, void *user_data);
+
+int ctx_sensor_rec_read(const char* subject, ctx_sensor_rec_query_h query, ctx_sensor_rec_data_cb cb, void *user_data);
+
+int ctx_sensor_rec_read_sync(const char* subject, ctx_sensor_rec_query_h query, ctx_sensor_rec_data_cb cb, void *user_data);
+
+
+int ctx_sensor_rec_data_get_time(ctx_sensor_rec_data_h data, time_t *start_time, time_t *end_time);
+
+int ctx_sensor_rec_data_get_int(ctx_sensor_rec_data_h data, const char* key, int *value);
+
+int ctx_sensor_rec_data_get_double(ctx_sensor_rec_data_h data, const char* key, double *value);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/client-dummy/SensorRecorder.cpp b/src/client-dummy/SensorRecorder.cpp
deleted file mode 100644 (file)
index 66d0bae..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-#include <SensorRecorderTypesPrivate.h>
-#include <SensorRecorder.h>
-
-using namespace ctx;
-
-/* TODO: Remove this test code */
-EXPORT_API int sensor_recorder_test()
-{
-       return E_SUPPORT;
-}
diff --git a/src/client-dummy/sensor_recorder.cpp b/src/client-dummy/sensor_recorder.cpp
new file mode 100644 (file)
index 0000000..413ee26
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <sensor_recorder_internal.h>
+#include <SensorRecorderTypesPrivate.h>
+
+EXPORT_API int ctx_sensor_rec_is_supported(const char* subject, bool *supported)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_start(const char* subject, ctx_sensor_rec_option_h option)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_stop(const char* subject)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_create_option(ctx_sensor_rec_option_h *option)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_destroy_option(ctx_sensor_rec_option_h option)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_option_set_int(ctx_sensor_rec_option_h option, const char* param, int value)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_create_query(ctx_sensor_rec_query_h *query)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_destroy_query(ctx_sensor_rec_query_h query)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_query_set_int(ctx_sensor_rec_query_h query, const char* param, int value)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_query_set_time(ctx_sensor_rec_query_h query, const char* param, time_t t)
+{
+       return E_SUPPORT;
+}
+
+static int __getQuery(ctx_sensor_rec_query_h query, int& startTime, int& endTime, int& anchor, int& interval)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_read(const char* subject, ctx_sensor_rec_query_h query, ctx_sensor_rec_data_cb cb, void *user_data)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_read_sync(const char* subject, ctx_sensor_rec_query_h query, ctx_sensor_rec_data_cb cb, void *user_data)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_data_get_time(ctx_sensor_rec_data_h data, time_t *start_time, time_t *end_time)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_data_get_int(ctx_sensor_rec_data_h data, const char* key, int *value)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_data_get_double(ctx_sensor_rec_data_h data, const char* key, double *value)
+{
+       return E_SUPPORT;
+}
diff --git a/src/client/SensorRecorder.cpp b/src/client/SensorRecorder.cpp
deleted file mode 100644 (file)
index ec9ff43..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-#include <SensorRecorderTypesPrivate.h>
-#include <ServiceProxy.h>
-#include <SensorRecorder.h>
-
-using namespace ctx;
-
-/* TODO: Remove this test code */
-EXPORT_API int sensor_recorder_test()
-{
-       // ServiceProxy object can be maintained as a static object.
-       ServiceProxy proxy(CTX_SENSOR_RECORDER);
-
-       GVariant* output = NULL;
-
-       int err = proxy.call("test", g_variant_new("(i)", 100), &output);
-
-       _I(YELLOW("Return: %d (%s)"), err, CTX_ERROR_STR(err));
-
-       return err;
-}
diff --git a/src/client/sensor_recorder.cpp b/src/client/sensor_recorder.cpp
new file mode 100644 (file)
index 0000000..1c22e17
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <sensor_recorder_internal.h>
+#include <SensorRecorderTypesPrivate.h>
+#include <ServiceProxy.h>
+#include <map>
+#include <cmath>
+
+typedef std::map<std::string, int> ctx_sensor_rec_option_t;
+typedef std::map<std::string, int> ctx_sensor_rec_query_t;
+
+using namespace ctx;
+
+EXPORT_API int ctx_sensor_rec_is_supported(const char* subject, bool *supported)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_start(const char* subject, ctx_sensor_rec_option_h option)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_stop(const char* subject)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_create_option(ctx_sensor_rec_option_h *option)
+{
+       IF_FAIL_RETURN(option, E_PARAM);
+
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_destroy_option(ctx_sensor_rec_option_h option)
+{
+       IF_FAIL_RETURN(option, E_PARAM);
+
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_option_set_int(ctx_sensor_rec_option_h option, const char* param, int value)
+{
+       IF_FAIL_RETURN(option, E_PARAM);
+       IF_FAIL_RETURN(STR_EQ(param, CTX_SENSOR_RECORDER_KEY_INTERVAL) ||
+                                  STR_EQ(param, CTX_SENSOR_RECORDER_KEY_RETENTION), E_PARAM);
+
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_create_query(ctx_sensor_rec_query_h *query)
+{
+       IF_FAIL_RETURN(query, E_PARAM);
+
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_destroy_query(ctx_sensor_rec_query_h query)
+{
+       IF_FAIL_RETURN(query, E_PARAM);
+
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_query_set_int(ctx_sensor_rec_query_h query, const char* param, int value)
+{
+       IF_FAIL_RETURN(query, E_PARAM);
+       IF_FAIL_RETURN(STR_EQ(param, CTX_SENSOR_RECORDER_KEY_ANCHOR) ||
+                                  STR_EQ(param, CTX_SENSOR_RECORDER_KEY_INTERVAL), E_PARAM);
+
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_query_set_time(ctx_sensor_rec_query_h query, const char* param, time_t t)
+{
+       IF_FAIL_RETURN(query, E_PARAM);
+       IF_FAIL_RETURN(STR_EQ(param, CTX_SENSOR_RECORDER_KEY_START_TIME) ||
+                                  STR_EQ(param, CTX_SENSOR_RECORDER_KEY_END_TIME), E_PARAM);
+
+       return E_SUPPORT;
+}
+
+static int __getQuery(ctx_sensor_rec_query_h query, int& startTime, int& endTime, int& anchor, int& interval)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_read(const char* subject, ctx_sensor_rec_query_h query, ctx_sensor_rec_data_cb cb, void *user_data)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_read_sync(const char* subject, ctx_sensor_rec_query_h query, ctx_sensor_rec_data_cb cb, void *user_data)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_data_get_time(ctx_sensor_rec_data_h data, time_t *start_time, time_t *end_time)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_data_get_int(ctx_sensor_rec_data_h data, const char* key, int *value)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sensor_rec_data_get_double(ctx_sensor_rec_data_h data, const char* key, double *value)
+{
+       return E_SUPPORT;
+}
index ddcd1d5..1d34346 100644 (file)
@@ -27,4 +27,8 @@
        "       <arg type='i' name='return' direction='out'/>" \
        "</method>"
 
+#ifndef STR_EQ
+#define STR_EQ(X, Y) (g_strcmp0((X), (Y)) == 0)
+#endif
+
 #endif