PROJECT(libsyscommon C)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
-ADD_SUBDIRECTORY(src/libgdbus)
\ No newline at end of file
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/shared)
+# ADD_SUBDIRECTORY(src/libgdbus)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "${PREFIX}/bin")
+SET(LIBDIR ${LIB_INSTALL_DIR})
+SET(INCLUDEDIR "${PREFIX}/include")
+SET(VERSION 4.1)
+
+SET(libsyscommon_SRCS
+ src/libgdbus/dbus-system.c
+ src/libgdbus/dbus-systemd.c
+ src/libsystemd/systemd-state.c
+)
+SET(HEADERS
+ src/libgdbus/dbus-system.h
+ src/libgdbus/dbus-systemd.h
+ src/libsystemd/systemd-state.h
+)
+
+# CHECK PKG
+INCLUDE(FindPkgConfig)
+pkg_check_modules(syscommon REQUIRED
+ glib-2.0
+ gio-2.0
+ dlog
+ gio-unix-2.0)
+
+FOREACH(flag ${syscommon_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+# LIBRARY
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${libsyscommon_SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${syscommon_LDFLAGS} "-ldl" pthread)
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-fPIC")
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME syscommon)
+
+# INSTALL
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+
+# CONGIFURE FILE
+FOREACH(flag ${syscommon_INCLUDE_DIRS})
+ SET(SYSCOMMON_INCLUDEDIR "${SYSCOMMON_INCLUDEDIR} -I${flag}")
+ENDFOREACH(flag)
+
+FOREACH(flag ${syscommon_LIBRARIES})
+ SET(SYSCOMMON_LIBS "${SYSCOMMON_LIBS} -l${flag}")
+ENDFOREACH(flag)
+
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+
+# HEADER
+FOREACH(hfile ${HEADERS})
+ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/${PROJECT_NAME})
+ENDFOREACH(hfile)
libdir=@LIBDIR@
includedir=@INCLUDEDIR@
-Name: libgdbus
-Description: Dbus library
+Name: libsyscommon
+Description: system common library
Version: @VERSION@
-Requires.private: libgdbus
-Cflags: -I${includedir} @GDBUS_INCLUDEDIR@
-Libs: -L${libdir} -lgdbus @GDBUS_LIBS@
+Requires.private: libsyscommon
+Cflags: -I${includedir} @SYSCOMMON_INCLUDEDIR@
+Libs: -L${libdir} -lsyscommon @SYSCOMMON_LIBS@
Requires(postun): /sbin/ldconfig
%description
-System utility libraries.
+System common utility libraries.
-%package -n libgdbus
-Summary: Dbus library
+%package -n libsyscommon-devel
+Summary: Header files for system common library
License: Apache-2.0
-
-%description -n libgdbus
-Internal dbus library
-
-%package -n libgdbus-devel
-Summary: Header files for dbus library
-License: Apache-2.0
-Requires: libgdbus = %{version}
+Requires: libsyscommon = %{version}
Requires: pkgconfig(gio-2.0)
Requires: pkgconfig(gio-unix-2.0)
-%description -n libgdbus-devel
-Development header files for dbus library.
+%description -n libsyscommon-devel
+Development header files for system common library.
%prep
%setup -q
%postun -p /sbin/ldconfig
-%files -n libgdbus
+%files
%defattr(-,root,root,-)
%if 0%{?_with_tizen}
%manifest %{name}.manifest
%endif
%license LICENSE.Apache-2.0
-%{_libdir}/libgdbus.so.*
+%{_libdir}/libsyscommon.so.*
-%files -n libgdbus-devel
+%files -n libsyscommon-devel
%defattr(-,root,root,-)
%if 0%{?_with_tizen}
%manifest %{name}.manifest
%endif
%license LICENSE.Apache-2.0
-%{_libdir}/libgdbus.so
-%{_includedir}/libgdbus/dbus-system.h
-%{_includedir}/libgdbus/dbus-systemd.h
-%{_libdir}/pkgconfig/libgdbus.pc
+%{_libdir}/libsyscommon.so
+%{_includedir}/libsyscommon/dbus-system.h
+%{_includedir}/libsyscommon/dbus-systemd.h
+%{_includedir}/libsyscommon/systemd-state.h
+%{_libdir}/pkgconfig/libsyscommon.pc
+++ /dev/null
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(libgdbus C)
-
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(EXEC_PREFIX "${PREFIX}/bin")
-SET(LIBDIR ${LIB_INSTALL_DIR})
-SET(INCLUDEDIR "${PREFIX}/include")
-SET(VERSION 4.1)
-
-SET(libgdbus_SRCS
- dbus-system.c
- dbus-systemd.c
-)
-SET(HEADERS
- dbus-system.h
- dbus-systemd.h
-)
-
-# CHECK PKG
-INCLUDE(FindPkgConfig)
-pkg_check_modules(gdbus REQUIRED
- glib-2.0
- gio-2.0
- dlog
- gio-unix-2.0)
-
-FOREACH(flag ${gdbus_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-
-# LIBRARY
-ADD_LIBRARY(${PROJECT_NAME} SHARED ${libgdbus_SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${gdbus_LDFLAGS} "-ldl" pthread)
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-fPIC")
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION})
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME gdbus)
-
-# INSTALL
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
-
-# CONGIFURE FILE
-FOREACH(flag ${gdbus_INCLUDE_DIRS})
- SET(GDBUS_INCLUDEDIR "${GDBUS_INCLUDEDIR} -I${flag}")
-ENDFOREACH(flag)
-
-FOREACH(flag ${gdbus_LIBRARIES})
- SET(GDBUS_LIBS "${GDBUS_LIBS} -l${flag}")
-ENDFOREACH(flag)
-
-CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-
-# HEADER
-FOREACH(hfile ${HEADERS})
- INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/${PROJECT_NAME})
-ENDFOREACH(hfile)
--- /dev/null
+/*
+ * libsyscommon
+ *
+ * Copyright (c) 2019 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 <libgdbus/dbus-systemd.h>
+
+#include "shared/log.h"
+
+#define SYSTEMD_DBUS_METHOD_SYSTEM_STATE "SystemState"
+#define SYSTEMD_STATE_RUNNING "running"
+#define SYSTEMD_STATE_DEGRADED "degraded"
+
+int check_system_boot_finished(void)
+{
+ char *state = NULL;
+ int ret = 0;
+ size_t len;
+ GVariant *reply = NULL;
+
+ reply = systemd_get_manager_property(SYSTEMD_DBUS_METHOD_SYSTEM_STATE);
+ if (!reply) {
+ _E("Failed to get system state: No reply");
+ goto err;
+ }
+ if (!dh_get_param_from_var(reply, "s", &state)) {
+ _E("Failed to get system state(%s)", g_variant_get_type_string(reply));
+ goto err;
+ }
+
+ _I("System state=%s", state);
+
+ len = strlen(state) + 1;
+ if (!strncmp(state, SYSTEMD_STATE_RUNNING, len) ||
+ !strncmp(state, SYSTEMD_STATE_DEGRADED, len))
+ ret = 1;
+ else
+ ret = 0;
+
+err:
+ if (reply)
+ g_variant_unref(reply);
+ free(state);
+
+ return ret;
+}
--- /dev/null
+/*
+ * libsyscommon
+ *
+ * Copyright (c) 2019 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 __SYSTEMD_STATE_H__
+#define __SYSTEMD_STATE_H__
+
+#include "dbus-systemd.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int check_system_boot_finished(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif __SYSTEMD_STATE_H__