plugin-api: common: Add new SYSCOMMON_PLUGIN_MODULE_SESSIOND plugin 76/321076/9 accepted/tizen/unified/20250403.081017 accepted/tizen/unified/x/20250403.110105
authorChanwoo Choi <cw00.choi@samsung.com>
Wed, 5 Mar 2025 12:08:23 +0000 (21:08 +0900)
committerMichal Bloch <m.bloch@samsung.com>
Thu, 27 Mar 2025 17:36:47 +0000 (18:36 +0100)
Add new SYSCOMMON_PLUGIN_MODULE_SESSIOND for sessiond.service
plugin to support the specific multi-user feature of
GBM/profile/product.

Change-Id: I25499ecc449b7a99b2805ee4f76a13b1c7f7da12
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
CMakeLists.txt
packaging/libsyscommon.spec
src/plugin-api/common/include/system/syscommon-plugin-common.h
src/plugin-api/common/src/common.h
src/plugin-api/common/src/syscommon-plugin-api-list.h
src/plugin-api/sessiond/CMakeLists.txt [new file with mode: 0644]
src/plugin-api/sessiond/include/system/syscommon-internal-sessiond.h [new file with mode: 0644]
src/plugin-api/sessiond/include/system/syscommon-plugin-sessiond-interface.h [new file with mode: 0644]
src/plugin-api/sessiond/include/system/syscommon-plugin-sessiond.h [new file with mode: 0644]
src/plugin-api/sessiond/libsyscommon-plugin-api-sessiond.pc.in [new file with mode: 0644]
src/plugin-api/sessiond/src/syscommon-plugin-sessiond.c [new file with mode: 0644]

index 5412f1cce5ed49dcde3a718c1766353a43cc2e1e..51f115ba79b2264d4bdad1b7c5c0ed78823e4870 100644 (file)
@@ -8,6 +8,7 @@ ADD_SUBDIRECTORY(src/plugin-api/common)
 ADD_SUBDIRECTORY(src/plugin-api/resourced)
 ADD_SUBDIRECTORY(src/plugin-api/deviced)
 ADD_SUBDIRECTORY(src/plugin-api/update-control)
+ADD_SUBDIRECTORY(src/plugin-api/sessiond)
 # ADD_SUBDIRECTORY(src/libgdbus)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
index 561bf64163a1db802d7a05bbd81b40259ff79670..8f812290af4998a6c50d6376c5ceeccc3e1edcaf 100644 (file)
@@ -3,6 +3,7 @@
 %define libsyscommon_plugin_api_resourced_version 0.1.0
 %define libsyscommon_plugin_api_deviced_version 0.1.0
 %define libsyscommon_plugin_api_update_control_version 0.1.0
+%define libsyscommon_plugin_api_sessiond_version 0.1.0
 
 Name:           libsyscommon
 Summary:        System Libraries
@@ -101,6 +102,23 @@ License:   MIT
 Development header files for system plugin API for update-control.
 
 
+%package -n libsyscommon-plugin-api-sessiond
+Summary:       System plugin API for the sessiond
+Version:       %{libsyscommon_plugin_api_sessiond_version}
+License:       MIT
+
+%description -n libsyscommon-plugin-api-sessiond
+System plugin API for sessiond.
+
+%package -n libsyscommon-plugin-api-sessiond-devel
+Summary:       Header files for system plugin API for sessiond
+Version:       %{libsyscommon_plugin_api_sessiond_version}
+License:       MIT
+
+%description -n libsyscommon-plugin-api-sessiond-devel
+Development header files for system plugin API for sessiond.
+
+
 ######
 
 
@@ -113,6 +131,7 @@ PLUGIN_API_COMMON_MAJORVER=$(echo %{libsyscommon_plugin_api_common_version} | cu
 PLUGIN_API_RESOURCED_MAJORVER=$(echo %{libsyscommon_plugin_api_resourced_version} | cut -d'.' -f1)
 PLUGIN_API_DEVICED_MAJORVER=$(echo %{libsyscommon_plugin_api_deviced_version} | cut -d'.' -f1)
 PLUGIN_API_UPDATE_CONTROL_MAJORVER=$(echo %{libsyscommon_plugin_api_update_control_version} | cut -d'.' -f1)
+PLUGIN_API_SESSIOND_MAJORVER=$(echo %{libsyscommon_plugin_api_sessiond_version} | cut -d'.' -f1)
 %cmake . -DFULLVER=%{libsyscommon_version} \
        -DPLUGIN_API_COMMON_VERSION=%{libsyscommon_plugin_api_common_version} \
        -DPLUGIN_API_COMMON_MAJORVER=${PLUGIN_API_COMMON_MAJORVER} \
@@ -122,10 +141,13 @@ PLUGIN_API_UPDATE_CONTROL_MAJORVER=$(echo %{libsyscommon_plugin_api_update_contr
        -DPLUGIN_API_DEVICED_MAJORVER=${PLUGIN_API_DEVICED_MAJORVER} \
        -DPLUGIN_API_UPDATE_CONTROL_VERSION=%{libsyscommon_plugin_api_update_control_version} \
        -DPLUGIN_API_UPDATE_CONTROL_MAJORVER=${PLUGIN_API_UPDATE_CONTROL_MAJORVER} \
+       -DPLUGIN_API_SESSIOND_VERSION=%{libsyscommon_plugin_api_sessiond_version} \
+       -DPLUGIN_API_SESSIOND_MAJORVER=${PLUGIN_API_SESSIOND_MAJORVER} \
        -DPLUGIN_API_COMMON_ENABLE_DLOG=1 \
        -DPLUGIN_API_RESOURCED_ENABLE_DLOG=1 \
        -DPLUGIN_API_DEVICED_ENABLE_DLOG=1 \
-       -DPLUGIN_API_UPDATE_CONTROL_ENABLE_DLOG=1
+       -DPLUGIN_API_UPDATE_CONTROL_ENABLE_DLOG=1 \
+       -DPLUGIN_API_SESSIOND_ENABLE_DLOG=1
 make %{?_smp_mflags}
 
 %install
@@ -218,3 +240,18 @@ Common system plugin APIs to load another APIs from backend.
 %{_includedir}/system/syscommon-plugin-update-control*.h
 %{_libdir}/pkgconfig/libsyscommon-plugin-api-update-control.pc
 %{_libdir}/libsyscommon-plugin-api-update-control.so
+
+%files -n libsyscommon-plugin-api-sessiond
+%defattr(-,root,root,-)
+%manifest %{name}.manifest
+%license LICENSE.MIT
+%{_libdir}/libsyscommon-plugin-api-sessiond.so.*
+
+%files -n libsyscommon-plugin-api-sessiond-devel
+%defattr(-,root,root,-)
+%manifest %{name}.manifest
+%license LICENSE.MIT
+%{_includedir}/system/syscommon-plugin-sessiond*.h
+%{_includedir}/system/syscommon-internal-sessiond.h
+%{_libdir}/pkgconfig/libsyscommon-plugin-api-sessiond.pc
+%{_libdir}/libsyscommon-plugin-api-sessiond.so
index 7993c080a1c517f022f9836698f0b76b2f9677d4..4cdd6b9f9b2ebb021f2a8c83283e62e42f33cdac 100644 (file)
@@ -39,6 +39,7 @@ enum syscommon_plugin_module {
        SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY,
        SYSCOMMON_PLUGIN_MODULE_RESOURCED_CPU_BOOSTING,
        SYSCOMMON_PLUGIN_MODULE_UPDATE_CONTROL,
+       SYSCOMMON_PLUGIN_MODULE_SESSIOND,
        SYSCOMMON_PLUGIN_MODULE_END,
 };
 
index d6a370d8caf36982726bb1771f1dd2037d639cd8..49605859f9ab0343db320b72246d05a257e53690 100644 (file)
@@ -48,6 +48,7 @@ enum plugin_group {
        PLUGIN_GROUP_RESOURCED,
        PLUGIN_GROUP_DEVICED,
        PLUGIN_GROUP_UPDATE_CONTROL,
+       PLUGIN_GROUP_SESSIOND,
        PLUGIN_GROUP_END,
 };
 
index 8161a3118ab9ed4dcc758b6ec7a7ac7f4a099eda..41d8474c30b04ff3c4869b1740d4649961ceaf39 100644 (file)
@@ -90,6 +90,16 @@ static struct __plugin_module_info g_plugin_module_info[] = {
                .library_name_64bit     = "/usr/lib64/system/plugin/libplugin-backend-update-control.so",
                .symbol_name            = "system_plugin_backend_update_control_data",
        },
+       [SYSCOMMON_PLUGIN_MODULE_SESSIOND] = {
+               .group                  = PLUGIN_GROUP_SESSIOND,
+               .module                 = SYSCOMMON_PLUGIN_MODULE_SESSIOND,
+               .license                = PLUGIN_LICENSE_APACHE_2_0,
+               .module_name            = "SYSCOMMON_PLUGIN_MODULE_SESSIOND",
+               .backend_module_name    = "sessiond",
+               .library_name           = "/usr/lib/system/plugin/libplugin-backend-sessiond.so",
+               .library_name_64bit     = "/usr/lib64/system/plugin/libplugin-backend-sessiond.so",
+               .symbol_name            = "system_plugin_backend_sessiond_data",
+       },
 };
 
 #endif /* __PLUGIN_API_LIST_H__ */
diff --git a/src/plugin-api/sessiond/CMakeLists.txt b/src/plugin-api/sessiond/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a6f6886
--- /dev/null
@@ -0,0 +1,68 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(syscommon-plugin-api-sessiond)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "${PREFIX}/bin")
+SET(LIBDIR ${LIB_INSTALL_DIR})
+SET(INCLUDEDIR "${PREFIX}/include/system")
+SET(VERSION ${PLUGIN_API_SESSIOND_VERSION})
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+# Including below should be removed if the repository of
+# syscommon-plugin-api-common is separated.
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../common/include)
+
+if (${PLUGIN_API_DEVICED_ENABLE_DLOG})
+       SET(PKG_MODULES
+               glib-2.0
+               dlog)
+       ADD_DEFINITIONS("-DENABLE_DLOG")
+       ADD_DEFINITIONS("-DLOG_TAG=\"SYSTEM_PLUGIN_API_SESSIOND\"")
+else()
+       SET(PKG_MODULES
+               glib-2.0)
+endif()
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED ${PKG_MODULES})
+FOREACH(flag ${pkgs_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -fPIC")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -lrt")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+# syscommon-plugin-api-common.c and syscommon-plugin-api-conf.c are unnecessary
+# if the repository of syscommon-plugin-api-common is separated.
+# Please remove them from SRCS and add 'syscommon-plugin-api-common'
+# to PKG_MODULES.
+SET(SRCS src/syscommon-plugin-sessiond.c
+       ../common/src/syscommon-plugin-api-common.c
+       ../common/src/syscommon-plugin-api-conf.c)
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS}
+       -ldl -Wl,-z,nodelete,--no-undefined)
+
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${PLUGIN_API_SESSIOND_VERSION})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${PLUGIN_API_SESSIOND_MAJORVER})
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR})
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/system/
+       DESTINATION ${INCLUDEDIR}
+       FILES_MATCHING PATTERN "*.h"
+)
+
+# CONFIGURE .pc FILE
+FOREACH(include_dirs ${pkgs_INCLUDE_DIRS})
+       SET(PLUGIN_SESSIOND_INCLUDEDIR "${PLUGIN_SESSIOND_INCLUDEDIR} -I${include_dirs}")
+ENDFOREACH(include_dirs)
+FOREACH(libraries ${pkgs_LIBRARIES})
+       SET(PLUGIN_SESSIOND_LIBS "${PLUGIN_SESSIOND_LIBS} -l${libraries}")
+ENDFOREACH(libraries)
+SET(PACKAGE_CONFIG_FILE "lib${PROJECT_NAME}.pc")
+CONFIGURE_FILE(${PACKAGE_CONFIG_FILE}.in ${PACKAGE_CONFIG_FILE} @ONLY)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_CONFIG_FILE} DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
diff --git a/src/plugin-api/sessiond/include/system/syscommon-internal-sessiond.h b/src/plugin-api/sessiond/include/system/syscommon-internal-sessiond.h
new file mode 100644 (file)
index 0000000..3e8c3dd
--- /dev/null
@@ -0,0 +1,74 @@
+/**
+ * MIT License
+ *
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef __SYSCOMMON_INTERNAL_SESSIOND_H__
+#define __SYSCOMMON_INTERNAL_SESSIOND_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* These functions are to be called by the plugin, and let it access sessiond
+ * directly. There is no routing via libsyscommon, the header is here mostly
+ * because otherwise there would be a cyclical sessiond/plugin dependency. */
+
+/**
+ * @brief Add a subsession (called from plugin)
+ * @param uid user ID to add the subsession to
+ * @param subsession Subsession name to add
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int sessiond_internal_add_subsession(int uid, const char *subsession);
+
+/**
+ * @brief Add a subsession (called from plugin)
+ * @param uid user ID to add the subsession to
+ * @param subsession Subsession name to add
+ * @param size_kB Size limit of the subsession in kilobytes
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int sessiond_internal_add_subsession_fixed_size(int uid, const char *subsession, unsigned size_kB);
+
+/**
+ * @brief Remove a subsession (called from plugin)
+ * @param uid user ID to remove the subsession from
+ * @param subsession Subsession name to remove
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int sessiond_internal_remove_subsession(int uid, const char *subsession);
+
+/**
+ * @brief Switch subsession (called from plugin)
+ * @param uid user ID whose subsession to switch
+ * @param subsession Subsession name to switch to
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int sessiond_internal_switch_subsession(int uid, const char *subsession);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __SYSCOMMON_INTERNAL_SESSIOND_H__
diff --git a/src/plugin-api/sessiond/include/system/syscommon-plugin-sessiond-interface.h b/src/plugin-api/sessiond/include/system/syscommon-plugin-sessiond-interface.h
new file mode 100644 (file)
index 0000000..40bee76
--- /dev/null
@@ -0,0 +1,53 @@
+/**
+ * MIT License
+ *
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef __SYSCOMMON_PLUGIN_SESSIOND_INTERFACE_H__
+#define __SYSCOMMON_PLUGIN_SESSIOND_INTERFACE_H__
+
+#include <tizen.h>
+#include <time.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _syscommon_plugin_backend_sessiond_funcs {
+       int (*sessiond_initialize) (void);
+
+       /* The functions below return an `int` mostly for consistency with
+        * other libcommon interfaces, but sessiond ignores it. Only initialize's
+        * return value is actually used. */
+
+       int (*sessiond_deinitialize) (void);
+       int (*sessiond_subsession_changed)(int uid, const char *subsession_from, const char *subsession_to);
+       int (*sessiond_subsession_added)(int uid, const char *subsession);
+       int (*sessiond_subsession_removed)(int uid, const char *subsession);
+} syscommon_plugin_backend_sessiond_funcs;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__SYSCOMMON_PLUGIN_SESSIOND_INTERFACE_H__
diff --git a/src/plugin-api/sessiond/include/system/syscommon-plugin-sessiond.h b/src/plugin-api/sessiond/include/system/syscommon-plugin-sessiond.h
new file mode 100644 (file)
index 0000000..d31de23
--- /dev/null
@@ -0,0 +1,93 @@
+/**
+ * MIT License
+ *
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef __SYSCOMMON_PLUGIN_SESSIOND_H__
+#define __SYSCOMMON_PLUGIN_SESSIOND_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <system/syscommon-plugin-sessiond-interface.h>
+
+
+/* These functions are called by sessiond, and let it access plugin functions
+ * by routing via usual libsyscommon patterns. */
+
+
+/**
+ * @brief Get the backend data of sessiond-plugin module
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int syscommon_plugin_sessiond_get_backend(int *backend_exists);
+
+/**
+ * @brief Put the backend data of sessiond-plugin module
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int syscommon_plugin_sessiond_put_backend(void);
+
+/**
+ * @brief Call the sessiond_initialize function of sessiond-plugin module
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int syscommon_plugin_sessiond_initialize();
+
+/**
+ * @brief Call the sessiond_deinitialize function of sessiond-plugin module
+ * Call this before calling syscommon_plugin_SESSIOND_put_backend()
+ */
+int syscommon_plugin_sessiond_deinitialize(void);
+
+/**
+ * @brief Call the sessiond_subsession_changed function of sessiond-plugin module
+ * @param uid user ID whose subsession changed
+ * @param from Subsession name that is being switched away from
+ * @param to Subsession name that is being switched into
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int syscommon_plugin_sessiond_subsession_changed(int uid, const char *from, const char *to);
+
+/**
+ * @brief Call the sessiond_subsession_added function of sessiond-plugin module
+ * @param uid user ID to whom a subsession is being added
+ * @param subsession Subsession name that is being added
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int syscommon_plugin_sessiond_subsession_added(int uid, const char *subsession);
+
+/**
+ * @brief Call the sessiond_subsession_removed function of sessiond-plugin module
+ * @param uid user ID whose subsession is being removed
+ * @param subsession Subsession name that is being removed
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int syscommon_plugin_sessiond_subsession_removed(int uid, const char *subsession);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__SYSCOMMON_PLUGIN_SESSIOND_H__
diff --git a/src/plugin-api/sessiond/libsyscommon-plugin-api-sessiond.pc.in b/src/plugin-api/sessiond/libsyscommon-plugin-api-sessiond.pc.in
new file mode 100644 (file)
index 0000000..6590c27
--- /dev/null
@@ -0,0 +1,17 @@
+# Package Information for pkg-config
+#
+# Copyright (c) 2025 Samsung Electronics Co., Ltd.
+# All rights reserved.
+#
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: libsyscommon-plugin-api-sessiond
+Description: System plugin API for sessiond
+Version: @VERSION@
+Requires.private: libsyscommon-plugin-api-common
+Cflags: -I${includedir} @PLUGIN_SESSIOND_INCLUDEDIR@
+Libs: -L${libdir} -lsyscommon-plugin-api-sessiond @PLUGIN_SESSIOND_LIBS@
diff --git a/src/plugin-api/sessiond/src/syscommon-plugin-sessiond.c b/src/plugin-api/sessiond/src/syscommon-plugin-sessiond.c
new file mode 100644 (file)
index 0000000..04f2c19
--- /dev/null
@@ -0,0 +1,131 @@
+/**
+ * MIT License
+ *
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include <libsyscommon/log.h>
+
+#include <system/syscommon-plugin-common.h>
+#include <system/syscommon-plugin-sessiond.h>
+#include <system/syscommon-plugin-sessiond-interface.h>
+
+#ifndef EXPORT
+#define EXPORT __attribute__((visibility("default")))
+#endif
+
+static syscommon_plugin_backend_sessiond_funcs *funcs = NULL;
+
+EXPORT
+int syscommon_plugin_sessiond_get_backend(int *backend_exists)
+{
+       if (funcs)
+               goto get_backend_success;
+
+       int ret = syscommon_plugin_common_get_backend(
+                               SYSCOMMON_PLUGIN_MODULE_SESSIOND,
+                               (void **)&funcs);
+
+       if (ret < 0) {
+               if (ret == -ENOENT) {
+                       _I("sessiond backend was not found");
+                       if (backend_exists)
+                               *backend_exists = 0;
+                       return 0;
+               }
+
+               _E("Failed to get sessiond backend: %d", ret);
+               return ret;
+       }
+
+       _I("Success to get sessiond backend: %d", ret);
+
+get_backend_success:
+       if (backend_exists)
+               *backend_exists = 1;
+
+       return 0;
+}
+
+EXPORT
+int syscommon_plugin_sessiond_put_backend(void)
+{
+       if (!funcs)
+               return 0;
+
+       int ret = syscommon_plugin_common_put_backend(
+                               SYSCOMMON_PLUGIN_MODULE_SESSIOND,
+                               (void *)funcs);
+       if (ret < 0) {
+               _E("Failed to put sessiond backend: %d", ret);
+               return ret;
+       }
+       funcs = NULL;
+
+       _I("Success to put sessiond backend: %d", ret);
+
+       return 0;
+}
+
+#define RUN_CHECKED_FUNCTION(name, ...) \
+       if (!funcs) { \
+               _E("No backend"); \
+               return -EINVAL; \
+       } \
+       if (!funcs->name) { \
+               static bool message_sent = false; \
+               if (!message_sent) { \
+                       _I("No " #name " function"); \
+                       message_sent = true; \
+               } \
+               return -ENOTSUP; \
+       } \
+       return funcs->name(__VA_ARGS__);
+
+
+EXPORT
+int syscommon_plugin_sessiond_initialize()
+{
+       RUN_CHECKED_FUNCTION(sessiond_initialize);
+}
+
+EXPORT
+int syscommon_plugin_sessiond_deinitialize(void)
+{
+       RUN_CHECKED_FUNCTION(sessiond_deinitialize);
+}
+
+EXPORT
+int syscommon_plugin_sessiond_subsession_changed(int uid, const char *from, const char *to)
+{
+       RUN_CHECKED_FUNCTION(sessiond_subsession_changed, uid, from, to);
+}
+
+EXPORT
+int syscommon_plugin_sessiond_subsession_added(int uid, const char *subsession)
+{
+       RUN_CHECKED_FUNCTION(sessiond_subsession_added, uid, subsession);
+}
+
+EXPORT
+int syscommon_plugin_sessiond_subsession_removed(int uid, const char *subsession)
+{
+       RUN_CHECKED_FUNCTION(sessiond_subsession_removed, uid, subsession);
+}