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.
22 #include <sys/reboot.h>
24 #include <libsyscommon/dbus-system.h>
25 #include <systemd/sd-daemon.h>
28 #include "core/common.h"
29 #include "haptic/haptic.h"
31 static GMainLoop *mainloop = NULL;
33 static void sig_quit(int signo)
35 _D("Received SIGTERM signal(%d)", signo);
38 static void sig_usr1(int signo)
40 _D("Received SIGUSR1 signal(%d), feedbackd'll be finished.", signo);
43 if (g_main_loop_is_running(mainloop))
44 g_main_loop_quit(mainloop);
49 static void dbus_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
51 _I("sd_notify(READY=1)");
52 sd_notify(0, "READY=1");
55 int main(int argc, char **argv)
58 dbus_handle_h handle = NULL;
60 mainloop = g_main_loop_new(NULL, FALSE);
62 handle = dbus_handle_get_connection(G_BUS_TYPE_SYSTEM, FALSE);
64 _E("Failed to get dbus connection.");;
68 _E("'Haptic' probe fail.");
73 ret = dbus_handle_request_bus_name(handle, VIBRATOR_BUS_NAME, dbus_name_acquired, NULL);
75 _E("Failed to request bus name.");
76 dbus_handle_check_owner_name(NULL, VIBRATOR_BUS_NAME);
79 signal(SIGTERM, sig_quit);
80 signal(SIGUSR1, sig_usr1);
83 g_main_loop_run(mainloop);
85 _D("'Haptic' deinitialize.");
87 g_main_loop_unref(mainloop);