4 * Copyright (c) 2016 - 2017 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.
23 #include <sys/reboot.h>
25 #include <system_info.h>
26 #include <systemd/sd-daemon.h>
27 #include <libsyscommon/libgdbus.h>
29 #include "shared/log.h"
30 #include "shared/common.h"
33 #define VIBRATION_FEATURE "http://tizen.org/feature/feedback.vibration"
35 static GMainLoop *mainloop = NULL;
37 static void sig_quit(int signo)
39 _D("Received SIGTERM signal(%d)", signo);
42 static void sig_usr1(int signo)
44 _D("Received SIGUSR1 signal(%d), feedbackd'll be finished.", signo);
47 if (g_main_loop_is_running(mainloop))
48 g_main_loop_quit(mainloop);
52 static void dbus_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
54 _I("sd_notify(READY=1)");
55 sd_notify(0, "READY=1");
58 int main(int argc, char **argv)
61 dbus_handle_h handle = NULL;
62 bool haptic_avail = false;
64 ret = system_info_get_platform_bool(VIBRATION_FEATURE, &haptic_avail);
65 if ((ret < 0) || !haptic_avail) {
66 _I("Vibration feature is not supported.");
67 sd_notify(0, "READY=1");
71 mainloop = g_main_loop_new(NULL, FALSE);
73 handle = gdbus_get_connection(G_BUS_TYPE_SYSTEM, FALSE);
75 _E("Failed to get dbus connection.");;
79 _E("'Haptic' probe fail.");
80 g_main_loop_unref(mainloop);
85 ret = gdbus_request_name(handle, VIBRATOR_BUS_NAME, dbus_name_acquired, NULL);
87 _E("Failed to request bus name.");
88 gdbus_check_name_owner(NULL, VIBRATOR_BUS_NAME);
91 signal(SIGTERM, sig_quit);
92 signal(SIGUSR1, sig_usr1);
95 g_main_loop_run(mainloop);
97 _D("'Haptic' deinitialize.");
101 g_main_loop_unref(mainloop);