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.
28 #include "dbus_util.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 class injector_wristup_algo : public injector {
39 injector_wristup_algo(sensor_type_t sensor_type, const char *event_name);
40 virtual ~injector_wristup_algo() {}
43 bool inject(int argc, char *argv[]);
46 injector_wristup_algo::injector_wristup_algo(sensor_type_t sensor_type, const char *event_name)
47 : injector(sensor_type, event_name)
51 bool injector_wristup_algo::setup(void)
53 option_map.insert(option_map_t::value_type("auto", 0));
54 option_map.insert(option_map_t::value_type("green", 1));
55 option_map.insert(option_map_t::value_type("purple", 2));
56 option_map.insert(option_map_t::value_type("red", 3));
61 bool injector_wristup_algo::inject(int argc, char *argv[])
65 RETVM_IF(argc == 0, false, "Invalid argument\n");
67 option_map_t::iterator it;
68 it = option_map.find(argv[INJECTOR_ARGC]);
69 RETVM_IF(it == option_map.end(), false, "No matched option: %s\n", argv[INJECTOR_ARGC]);
73 dbus_emit_signal(NULL,
74 (gchar *)SENSORD_OBJ_PATH,
75 (gchar *)SENSORD_INTERFACE_NAME,
76 (gchar *)WRISTUP_ALGO_SIGNAL,
77 g_variant_new("(i)", option),
80 _I("Set up [%s] mode to wristup (%d)\n", argv[INJECTOR_ARGC], option);
84 REGISTER_INJECTOR(GESTURE_WRIST_UP_SENSOR, WRISTUP_ALGO_SIGNAL, injector_wristup_algo)