Move main.c file to haptic folder 86/237986/1 submit/tizen/20200707.064531
authorYunmi Ha <yunmi.ha@samsung.com>
Tue, 7 Jul 2020 06:29:13 +0000 (15:29 +0900)
committerYunmi Ha <yunmi.ha@samsung.com>
Tue, 7 Jul 2020 06:29:13 +0000 (15:29 +0900)
- 'core' and 'haptic' sub-modules has cycle dependecies
cause main function.
- For remove this, move main function to haptic sub-module.

Change-Id: Ie9e967d2b74694e020a5fccb5881e25248e7897c
Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
CMakeLists.txt
src/core/main.c [deleted file]
src/haptic/main.c [new file with mode: 0644]

index c4ffa35ef67a1db10599bf9c528f115b8ca7d3ce..621d2bf6c1854525632ebc864ae559ede427aca6 100644 (file)
@@ -8,7 +8,7 @@ PROJECT(feedbackd C)
 SET(VERSION 0.1.0)
 
 SET(SRCS
-       src/core/main.c
+       src/haptic/main.c
        src/core/common.c
        src/core/config-parser.c
        src/core/device-idler.c
diff --git a/src/core/main.c b/src/core/main.c
deleted file mode 100644 (file)
index ff068c8..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * feedbackd
- *
- * Copyright (c) 2016 - 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 <stdio.h>
-#include <fcntl.h>
-#include <glib.h>
-#include <sys/reboot.h>
-
-#include <system_info.h>
-#include <systemd/sd-daemon.h>
-#include <libsyscommon/dbus-system.h>
-
-#include "core/log.h"
-#include "core/common.h"
-#include "haptic/haptic.h"
-
-#define VIBRATION_FEATURE              "http://tizen.org/feature/feedback.vibration"
-
-static GMainLoop *mainloop = NULL;
-
-static void sig_quit(int signo)
-{
-       _D("Received SIGTERM signal(%d)", signo);
-}
-
-static void sig_usr1(int signo)
-{
-       _D("Received SIGUSR1 signal(%d), feedbackd'll be finished.", signo);
-
-       if (mainloop) {
-               if (g_main_loop_is_running(mainloop))
-                       g_main_loop_quit(mainloop);
-       }
-}
-
-static void dbus_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
-{
-       _I("sd_notify(READY=1)");
-       sd_notify(0, "READY=1");
-}
-
-int main(int argc, char **argv)
-{
-       int ret;
-       dbus_handle_h handle = NULL;
-       bool haptic_avail = false;
-
-       ret = system_info_get_platform_bool(VIBRATION_FEATURE, &haptic_avail);
-       if ((ret < 0) || !haptic_avail) {
-               _I("Vibration feature is not supported.");
-               sd_notify(0, "READY=1");
-               return 0;
-       }
-
-       mainloop = g_main_loop_new(NULL, FALSE);
-
-       handle = dbus_handle_get_connection(G_BUS_TYPE_SYSTEM, FALSE);
-       if (!handle)
-               _E("Failed to get dbus connection.");;
-
-       ret = haptic_probe();
-       if (ret != 0) {
-               _E("'Haptic' probe fail.");
-               g_main_loop_unref(mainloop);
-               return ret;
-       }
-       haptic_init();
-
-       ret = dbus_handle_request_bus_name(handle, VIBRATOR_BUS_NAME, dbus_name_acquired, NULL);
-       if (ret <= 0) {
-               _E("Failed to request bus name.");
-               dbus_handle_check_owner_name(NULL, VIBRATOR_BUS_NAME);
-       }
-
-       signal(SIGTERM, sig_quit);
-       signal(SIGUSR1, sig_usr1);
-
-       /* g_main_loop */
-       g_main_loop_run(mainloop);
-
-       _D("'Haptic' deinitialize.");
-       haptic_exit();
-
-       if (mainloop) {
-               g_main_loop_unref(mainloop);
-               mainloop = NULL;
-       }
-
-       return 0;
-}
diff --git a/src/haptic/main.c b/src/haptic/main.c
new file mode 100644 (file)
index 0000000..ff068c8
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * feedbackd
+ *
+ * Copyright (c) 2016 - 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 <stdio.h>
+#include <fcntl.h>
+#include <glib.h>
+#include <sys/reboot.h>
+
+#include <system_info.h>
+#include <systemd/sd-daemon.h>
+#include <libsyscommon/dbus-system.h>
+
+#include "core/log.h"
+#include "core/common.h"
+#include "haptic/haptic.h"
+
+#define VIBRATION_FEATURE              "http://tizen.org/feature/feedback.vibration"
+
+static GMainLoop *mainloop = NULL;
+
+static void sig_quit(int signo)
+{
+       _D("Received SIGTERM signal(%d)", signo);
+}
+
+static void sig_usr1(int signo)
+{
+       _D("Received SIGUSR1 signal(%d), feedbackd'll be finished.", signo);
+
+       if (mainloop) {
+               if (g_main_loop_is_running(mainloop))
+                       g_main_loop_quit(mainloop);
+       }
+}
+
+static void dbus_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
+{
+       _I("sd_notify(READY=1)");
+       sd_notify(0, "READY=1");
+}
+
+int main(int argc, char **argv)
+{
+       int ret;
+       dbus_handle_h handle = NULL;
+       bool haptic_avail = false;
+
+       ret = system_info_get_platform_bool(VIBRATION_FEATURE, &haptic_avail);
+       if ((ret < 0) || !haptic_avail) {
+               _I("Vibration feature is not supported.");
+               sd_notify(0, "READY=1");
+               return 0;
+       }
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       handle = dbus_handle_get_connection(G_BUS_TYPE_SYSTEM, FALSE);
+       if (!handle)
+               _E("Failed to get dbus connection.");;
+
+       ret = haptic_probe();
+       if (ret != 0) {
+               _E("'Haptic' probe fail.");
+               g_main_loop_unref(mainloop);
+               return ret;
+       }
+       haptic_init();
+
+       ret = dbus_handle_request_bus_name(handle, VIBRATOR_BUS_NAME, dbus_name_acquired, NULL);
+       if (ret <= 0) {
+               _E("Failed to request bus name.");
+               dbus_handle_check_owner_name(NULL, VIBRATOR_BUS_NAME);
+       }
+
+       signal(SIGTERM, sig_quit);
+       signal(SIGUSR1, sig_usr1);
+
+       /* g_main_loop */
+       g_main_loop_run(mainloop);
+
+       _D("'Haptic' deinitialize.");
+       haptic_exit();
+
+       if (mainloop) {
+               g_main_loop_unref(mainloop);
+               mainloop = NULL;
+       }
+
+       return 0;
+}