input: Replace input plugin-backend by using plugin-api-deviced API 41/297441/5
authorChanwoo Choi <cw00.choi@samsung.com>
Fri, 18 Aug 2023 04:27:49 +0000 (13:27 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Tue, 22 Aug 2023 08:08:46 +0000 (08:08 +0000)
Until now, deviced contains the all plugin backend package for each profile like
headless, headed and so on. In order to move the plugin to the seprate
git repository, handle the input plugin-backend by using
plugin-api-deviced API (input plugin-api).

[Sequence flow between packages]
- deviced (input core)
-> plugin-api-deviced(input plugin-api)
-> plugin-backend-deviced-* (input plugin-backend, e.g., plugin-backend-deviced-headless)

Change-Id: Ic01198cc2b3e512ce059c96894ac0b94039e286a
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
CMakeLists.txt
src/input/input-plugin-interface.h [deleted file]
src/input/input-plugin.c [deleted file]
src/input/input-plugin.h [deleted file]
src/input/input.c

index ee7bca9e79d0ecc2b5014539ff6658bbfc877b72..31e2f684d4d179b7e54308651f05b4e5403e40e6 100644 (file)
@@ -188,6 +188,7 @@ SET(PKG_MODULES
        capi-system-device
        libsystemd
        libsyscommon
+       libsyscommon-plugin-api-deviced
        wayland-client
        tizen-extension-client
        tizen-dpms-client
diff --git a/src/input/input-plugin-interface.h b/src/input/input-plugin-interface.h
deleted file mode 100644 (file)
index 26736a4..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2023 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.
- */
-
-#ifndef __INPUT_PLUGIN_INTERFACE_H__
-#define __INPUT_PLUGIN_INTERFACE_H__
-
-struct input_plugin_interface {
-       int (*init) (void *);
-       void (*exit) (void *);
-};
-
-#define INPUT_PLUGIN_INTERFACE_SYMBOL   input_plugin_interface_sym
-
-#endif// __INPUT_PLUGIN_INTERFACE_H__
diff --git a/src/input/input-plugin.c b/src/input/input-plugin.c
deleted file mode 100644 (file)
index 03b30b7..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#include <unistd.h>
-#include <dlfcn.h>
-#include <shared/log.h>
-
-#include "input-plugin-interface.h"
-
-#define INPUT_PLUGIN_PATH      LIBPATH"/deviced/input-handler.so"
-
-#define __stringify(s)  #s
-#define stringify(s)   __stringify(s)
-
-static void *g_input_plugin_handle;
-static struct input_plugin_interface *g_input_plugin;
-
-int input_plugin_init(void *data)
-{
-       if (access(INPUT_PLUGIN_PATH, F_OK) != 0) {
-               _D("There is no input plugin, %s", INPUT_PLUGIN_PATH);
-               return -ENOENT;
-       }
-
-       if (!g_input_plugin_handle) {
-               g_input_plugin_handle = dlopen(INPUT_PLUGIN_PATH, RTLD_NOW | RTLD_GLOBAL);
-               if (!g_input_plugin_handle) {
-                       _E("Failed to load input plugin shared object, %s", dlerror());
-                       return -ENOTSUP;
-               }
-       }
-
-       if (!g_input_plugin) {
-               g_input_plugin = dlsym(g_input_plugin_handle, stringify(INPUT_PLUGIN_INTERFACE_SYMBOL));
-               if (!g_input_plugin) {
-                       _E("Failed to load input plugin symbol, %s", dlerror());
-                       return -ENOTSUP;
-               }
-       }
-
-       if (!g_input_plugin->init)
-               return -EOPNOTSUPP;
-
-       return g_input_plugin->init(data);
-}
-
-void input_plugin_exit(void *data)
-{
-       if (g_input_plugin && g_input_plugin->exit)
-               g_input_plugin->exit(data);
-
-       g_input_plugin = NULL;
-
-       if (g_input_plugin_handle)
-               dlclose(g_input_plugin_handle);
-
-       g_input_plugin_handle = NULL;
-}
diff --git a/src/input/input-plugin.h b/src/input/input-plugin.h
deleted file mode 100644 (file)
index cb17a3d..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2023 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.
- */
-
-#ifndef __INPUT_PLUGIN_H__
-#define __INPUT_PLUGIN_H__
-
-int input_plugin_init(void *data);
-void input_plugin_exit(void *data);
-
-#endif //__INPUT_PLUGIN_H__
index 2af25627df5585e1a87aa09a583b25dd3ed4dd4e..6e302e97a41fa09d2d875d165074b57089c49e7f 100644 (file)
 #include <libinput.h>
 #include <dlfcn.h>
 
+#include <system/syscommon-plugin-deviced-input.h>
+
 #include "shared/devices.h"
 #include "shared/log.h"
 #include "input.h"
 #include "input-dbus.h"
-#include "input-plugin.h"
 #include "input-parser.h"
 #include "input-device-manager.h"
 
@@ -53,6 +54,7 @@ struct input_event_handler {
 };
 
 static GList *input_event_handler_list;
+static int g_input_plugin_event_handler_id;
 
 static void invoke_input_event_callback(gpointer data, gpointer udata)
 {
@@ -244,6 +246,37 @@ void input_unregister_event_callback(int cb_id)
        g_list_free(l);
 }
 
+static int input_plugin_init(void *data)
+{
+       int ret = 0;
+
+       ret = syscommon_plugin_deviced_input_get_backend();
+       if (ret < 0) {
+               _E("failed to get input plugin-backend\n");
+               return ret;
+       }
+
+       input_register_event_callback(syscommon_plugin_deviced_input_event_cb,
+                                       NULL, NULL, &g_input_plugin_event_handler_id);
+
+       return 0;
+}
+
+static void input_plugin_exit(void *data)
+{
+       int ret = 0;
+
+       input_unregister_event_callback(g_input_plugin_event_handler_id);
+
+       ret = syscommon_plugin_deviced_input_put_backend();
+       if (ret < 0) {
+               _E("failed to put input plugin-backend\n");
+               return;
+       }
+
+       return;
+}
+
 static void input_init(void *data)
 {
        int ret;