4 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
26 #include <sensorctl_log.h>
27 #include "dbus_util.h"
28 #include "injector_manager.h"
29 #include "injector_wristup_algo.h"
31 #define WRISTUP_ALGO_SIGNAL "algo"
32 #define OPTION_INDEX 0
34 typedef std::map<std::string, int> option_map_t;
35 static option_map_t option_map;
37 bool injector_wristup_algo::init(void)
39 option_map.insert(option_map_t::value_type("auto", 0));
40 option_map.insert(option_map_t::value_type("green", 1));
41 option_map.insert(option_map_t::value_type("purple", 2));
42 option_map.insert(option_map_t::value_type("red", 3));
47 bool injector_wristup_algo::inject(int option_count, char *options[])
51 if (option_count == 0) {
52 _E("ERROR: invalid argument\n");
56 option_map_t::iterator it;
57 it = option_map.find(options[OPTION_INDEX]);
59 if (it == option_map.end()) {
60 _E("ERROR: no matched-option: %s\n", options[OPTION_INDEX]);
66 dbus_emit_signal(NULL,
67 (gchar *)SENSORD_OBJ_PATH,
68 (gchar *)SENSORD_INTERFACE_NAME,
69 (gchar *)WRISTUP_ALGO_SIGNAL,
70 g_variant_new("(i)", option),
73 _I("set [%s] mode to wristup (%d)", options[OPTION_INDEX], option);
77 REGISTER_INJECTOR(MOTION_SENSOR, "algo", injector_wristup_algo)