├── .gitignore ├── .gitlab-ci.yml ├── .mailmap ├── CMakeLists.txt ├── CONTRIBUTORS ├── COPYING ├── QtSystemd.pc.cmake ├── QtSystemdConfig.cmake.in ├── QtSystemdConfigVersion.cmake.in ├── README.md ├── src ├── CMakeLists.txt ├── QtSystemd-export.h ├── dbus │ ├── org.freedesktop.DBus.Properties.xml │ ├── org.freedesktop.login1.LDManager.xml │ ├── org.freedesktop.login1.Seat.xml │ ├── org.freedesktop.login1.Session.xml │ ├── org.freedesktop.login1.User.xml │ ├── org.freedesktop.systemd1.Automount.xml │ ├── org.freedesktop.systemd1.Device.xml │ ├── org.freedesktop.systemd1.Job.xml │ ├── org.freedesktop.systemd1.Manager.xml │ ├── org.freedesktop.systemd1.Mount.xml │ ├── org.freedesktop.systemd1.Path.xml │ ├── org.freedesktop.systemd1.Scope.xml │ ├── org.freedesktop.systemd1.Service.xml │ ├── org.freedesktop.systemd1.Slice.xml │ ├── org.freedesktop.systemd1.Socket.xml │ ├── org.freedesktop.systemd1.Swap.xml │ ├── org.freedesktop.systemd1.Target.xml │ ├── org.freedesktop.systemd1.Timer.xml │ └── org.freedesktop.systemd1.Unit.xml ├── generic-types.cpp ├── generic-types.h ├── job.cpp ├── job.h ├── job_p.h ├── ldmanager.cpp ├── ldmanager.h ├── ldmanager_p.h ├── sdmanager.cpp ├── sdmanager.h ├── sdmanager_p.h ├── seat.cpp ├── seat.h ├── seat_p.h ├── session.cpp ├── session.h ├── session_p.h ├── unit.cpp ├── unit.h ├── unit_p.h ├── user.cpp ├── user.h └── user_p.h └── tests ├── CMakeLists.txt ├── ldmanager-test.cpp └── sdmanager-test.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | *.dylib 9 | 10 | # Compiled Static libraries 11 | *.lai 12 | *.la 13 | *.a 14 | 15 | build 16 | *~ 17 | *.kdev4 18 | *.user 19 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | image: centos/systemd 2 | 3 | build: 4 | script: 5 | - yum install -y make gcc-c++ cmake systemd-devel qt5-qtbase-devel 6 | - mkdir build && cd build && cmake .. 7 | - make 8 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Andrea Scarpino 2 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(libsystemd-qt) 2 | 3 | cmake_minimum_required(VERSION 2.8.8) 4 | 5 | set(QTSYSTEMD_MAJOR_VERSION 0) 6 | set(QTSYSTEMD_MINOR_VERSION 1) 7 | set(QTSYSTEMD_PATCH_VERSION 0) 8 | set(QTSYSTEMD_VERSION 9 | ${QTSYSTEMD_MAJOR_VERSION}.${QTSYSTEMD_MINOR_VERSION}.${QTSYSTEMD_PATCH_VERSION}) 10 | 11 | set(CMAKE_AUTOMOC ON) 12 | 13 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 14 | 15 | include(CMakeDependentOption) 16 | 17 | option(BUILD_WITH_QT4 "Build with Qt4 no matter if Qt5 is found" OFF) 18 | 19 | if( NOT BUILD_WITH_QT4 ) 20 | find_package(Qt5Core QUIET) 21 | if( Qt5Core_DIR ) 22 | message(STATUS "Found Qt5!") 23 | 24 | macro(qt_wrap_cpp) 25 | qt5_wrap_cpp(${ARGN}) 26 | endmacro() 27 | 28 | find_package(Qt5DBus REQUIRED) 29 | macro(qt_add_dbus_interfaces) 30 | qt5_add_dbus_interfaces(${ARGN}) 31 | endmacro() 32 | endif() 33 | endif() 34 | 35 | if( NOT Qt5Core_DIR ) 36 | message(STATUS "Could not find Qt5, searching for Qt4 instead...") 37 | message(STATUS "Be aware that Qt4 support is not officially supported!") 38 | find_package( Qt4 COMPONENTS QtCore QtDBus REQUIRED ) 39 | include( ${QT_USE_FILE} ) 40 | 41 | macro(qt5_use_modules) 42 | endmacro() 43 | 44 | macro(qt_wrap_cpp) 45 | qt4_wrap_cpp(${ARGN}) 46 | endmacro() 47 | 48 | macro(qt_add_dbus_interfaces) 49 | qt4_add_dbus_interfaces(${ARGN}) 50 | endmacro() 51 | endif() 52 | 53 | find_package(PkgConfig) 54 | 55 | pkg_check_modules(SYSTEMD "libsystemd" REQUIRED) 56 | IF(NOT SYSTEMD_FOUND) 57 | message(FATAL_ERROR "ERROR: Systemd not found") 58 | ENDIF(NOT SYSTEMD_FOUND) 59 | 60 | set(LIB_SUFFIX "" CACHE STRING 61 | "Define suffix of library directory name (32/64)") 62 | 63 | # Offer the user the choice of overriding the installation directories 64 | set(INSTALL_LIB_DIR lib${LIB_SUFFIX} CACHE PATH 65 | "Installation directory for libraries") 66 | set(INSTALL_INCLUDE_DIR include/QtSystemd CACHE PATH 67 | "Installation directory for header files") 68 | if(WIN32 AND NOT CYGWIN) 69 | set(DEF_INSTALL_CMAKE_DIR CMake) 70 | else() 71 | set(DEF_INSTALL_CMAKE_DIR lib/cmake/QtSystemd) 72 | endif() 73 | set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH 74 | "Installation directory for CMake files") 75 | 76 | # Make relative paths absolute (needed later on) 77 | foreach(p LIB INCLUDE CMAKE) 78 | set(var INSTALL_${p}_DIR) 79 | if(NOT IS_ABSOLUTE "${${var}}") 80 | set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") 81 | endif() 82 | endforeach() 83 | 84 | add_subdirectory(src) 85 | 86 | cmake_dependent_option(BUILD_QTSYSTEMD_TESTS "Build Tests" ON "Qt5Core_DIR" OFF) 87 | if (BUILD_QTSYSTEMD_TESTS) 88 | add_subdirectory(tests) 89 | endif (BUILD_QTSYSTEMD_TESTS) 90 | 91 | # Add all targets to the build-tree export set 92 | export(TARGETS QtSystemd FILE "${PROJECT_BINARY_DIR}/QtSystemdTargets.cmake") 93 | 94 | # Export the package for use from the build-tree 95 | # (this registers the build-tree with a global CMake-registry) 96 | export(PACKAGE QtSystemd) 97 | 98 | # Create the QtSystemdConfig.cmake and QtSystemdConfigVersion files 99 | file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}" 100 | "${INSTALL_INCLUDE_DIR}") 101 | # ... for the build tree 102 | set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}") 103 | configure_file(QtSystemdConfig.cmake.in 104 | "${PROJECT_BINARY_DIR}/QtSystemdConfig.cmake" @ONLY) 105 | # ... for the install tree 106 | set(CONF_INCLUDE_DIRS "\${QTSYSTEMD_CMAKE_DIR}/${REL_INCLUDE_DIR}") 107 | configure_file(QtSystemdConfig.cmake.in 108 | "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/QtSystemdConfig.cmake" @ONLY) 109 | # ... for both 110 | configure_file(QtSystemdConfigVersion.cmake.in 111 | "${PROJECT_BINARY_DIR}/QtSystemdConfigVersion.cmake" @ONLY) 112 | 113 | # Install the QtSystemdConfig.cmake and QtSystemdConfigVersion.cmake 114 | install(FILES 115 | "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/QtSystemdConfig.cmake" 116 | "${PROJECT_BINARY_DIR}/QtSystemdConfigVersion.cmake" 117 | DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev) 118 | 119 | # Install the export set for use with the install-tree 120 | install(EXPORT QtSystemdTargets DESTINATION 121 | "${INSTALL_CMAKE_DIR}" COMPONENT dev) 122 | 123 | message(STATUS "Writing pkg-config file...") 124 | configure_file(${CMAKE_SOURCE_DIR}/QtSystemd.pc.cmake ${CMAKE_BINARY_DIR}/QtSystemd.pc @ONLY) 125 | install(FILES ${CMAKE_BINARY_DIR}/QtSystemd.pc DESTINATION "${INSTALL_LIB_DIR}/pkgconfig/") 126 | -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | This list contains list of contributors to the sddm. Names are sorted by number 2 | of commits at time of this writing. Commit data has been generated using: 3 | 4 | git shortlog -s -e -n 5 | 6 | Commit counts have ben removed, since they change pretty frequently. 7 | 8 | Andrea Scarpino 9 | Dario Freddi 10 | Tom Gundersen 11 | Uwe L. Korn 12 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /QtSystemd.pc.cmake: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=@CMAKE_INSTALL_PREFIX@/lib@LIB_SUFFIX@ 4 | includedir=${prefix}/include/QtSystemd 5 | 6 | Name: QtSystemd 7 | Description: Convenience Qt library for Systemd 8 | Version: @VERSION@ 9 | 10 | Requires: systemd 11 | Cflags: -I${includedir} @CMAKE_INCLUDE_PATH@ 12 | Libs: -L${libdir} -lQtSystemd @CMAKE_LIBRARY_PATH@ 13 | -------------------------------------------------------------------------------- /QtSystemdConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # - Config file for the QtSystemd package 2 | # It defines the following variables 3 | # QTSYSTEMD_INCLUDE_DIRS - include directories for QtSystemd 4 | # QTSYSTEMD_LIBRARIES - libraries to link against 5 | 6 | # Compute paths 7 | get_filename_component(QTSYSTEMD_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 8 | set(QtSystemd_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@") 9 | set(QtSystemd_INCLUDE_DIR "@INSTALL_INCLUDE_DIR@") 10 | 11 | # Our library dependencies (contains definitions for IMPORTED targets) 12 | if(NOT TARGET QtSystemd) 13 | include("${QTSYSTEMD_CMAKE_DIR}/QtSystemdTargets.cmake") 14 | endif() 15 | 16 | # These are IMPORTED targets created by QtSystemdTargets.cmake 17 | set(QtSystemd_LIBRARIES QtSystemd) 18 | set(QtSystemd_INCLUDE_DIRS ${QtSystemd_INCLUDE_DIR}) -------------------------------------------------------------------------------- /QtSystemdConfigVersion.cmake.in: -------------------------------------------------------------------------------- 1 | set(PACKAGE_VERSION "@QTSYSTEMD_VERSION@") 2 | 3 | # Check whether the requested PACKAGE_FIND_VERSION is compatible 4 | if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") 5 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 6 | else() 7 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 8 | if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") 9 | set(PACKAGE_VERSION_EXACT TRUE) 10 | endif() 11 | endif() -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | libsystemd-qt 2 | ============= 3 | 4 | Qt-only wrapper for [Systemd D-Bus API](https://www.freedesktop.org/wiki/Software/systemd/dbus/). 5 | 6 | Also supports [logind D-Bus interface](https://www.freedesktop.org/wiki/Software/systemd/logind/). 7 | 8 | ## Build and Installation## 9 | 10 | It requires cmake >= 2.8.8 and Qt 5.x 11 | 12 | $ mkdir build 13 | $ cd build 14 | $ cmake ../ -DCMAKE_INSTALL_PREFIX=/usr 15 | $ make 16 | # make install 17 | 18 | ## Packages 19 | 20 | * [PKGBUILD](https://aur.archlinux.org/packages/libsystemd-qt-git/) for Arch Linux 21 | * [EBUILD](https://github.com/gentoo/qt/tree/master/dev-libs/libsystemd-qt) for Gentoo Linux in the Qt Overlay 22 | 23 | ## Donate 24 | 25 | Donations via [Liberapay](https://liberapay.com/ilpianista) or Bitcoin (1Ph3hFEoQaD4PK6MhL3kBNNh9FZFBfisEH) are always welcomed, _thank you_! 26 | 27 | ## License 28 | 29 | LGPL 30 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(QtSystemd_HEADERS 2 | generic-types.h 3 | job.h 4 | ldmanager.h 5 | sdmanager.h 6 | seat.h 7 | session.h 8 | unit.h 9 | user.h 10 | QtSystemd-export.h 11 | ) 12 | 13 | set(QtSystemd_PART_SRCS 14 | generic-types.cpp 15 | job.cpp 16 | ldmanager.cpp 17 | sdmanager.cpp 18 | seat.cpp 19 | session.cpp 20 | unit.cpp 21 | user.cpp 22 | ) 23 | 24 | set(INTERFACE_INTROSPECTION_XML_FILES 25 | dbus/org.freedesktop.login1.LDManager.xml 26 | dbus/org.freedesktop.login1.Seat.xml 27 | dbus/org.freedesktop.login1.Session.xml 28 | dbus/org.freedesktop.login1.User.xml 29 | dbus/org.freedesktop.systemd1.Automount.xml 30 | dbus/org.freedesktop.systemd1.Device.xml 31 | dbus/org.freedesktop.systemd1.Job.xml 32 | dbus/org.freedesktop.systemd1.Manager.xml 33 | dbus/org.freedesktop.systemd1.Mount.xml 34 | dbus/org.freedesktop.systemd1.Path.xml 35 | dbus/org.freedesktop.systemd1.Scope.xml 36 | dbus/org.freedesktop.systemd1.Service.xml 37 | dbus/org.freedesktop.systemd1.Slice.xml 38 | dbus/org.freedesktop.systemd1.Socket.xml 39 | dbus/org.freedesktop.systemd1.Swap.xml 40 | dbus/org.freedesktop.systemd1.Target.xml 41 | dbus/org.freedesktop.systemd1.Timer.xml 42 | dbus/org.freedesktop.systemd1.Unit.xml 43 | dbus/org.freedesktop.DBus.Properties.xml 44 | ) 45 | 46 | set_property(SOURCE ${INTERFACE_INTROSPECTION_XML_FILES} 47 | PROPERTY INCLUDE generic-types.h) 48 | 49 | set_source_files_properties(${INTERFACE_INTROSPECTION_XML_FILES} 50 | PROPERTIES NO_NAMESPACE TRUE) 51 | 52 | qt_add_dbus_interfaces(QtSystemd_PART_SRCS ${INTERFACE_INTROSPECTION_XML_FILES}) 53 | 54 | add_library(QtSystemd SHARED ${QtSystemd_PART_SRCS}) 55 | 56 | qt5_use_modules(QtSystemd Core DBus) 57 | 58 | set_property(TARGET QtSystemd PROPERTY COMPILE_DEFINITIONS MAKE_SDQT_LIB) 59 | set_property(TARGET QtSystemd PROPERTY VERSION ${VERSION}) 60 | set_property(TARGET QtSystemd PROPERTY SOVERSION 0) 61 | 62 | set_target_properties(QtSystemd PROPERTIES 63 | PUBLIC_HEADER "${QtSystemd_HEADERS}") 64 | 65 | install(TARGETS QtSystemd 66 | # IMPORTANT: Add the QtSystemd library to the "export-set" 67 | EXPORT QtSystemdTargets 68 | RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin 69 | LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT shlib 70 | PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}" 71 | COMPONENT dev) 72 | -------------------------------------------------------------------------------- /src/QtSystemd-export.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #ifndef SDQT_EXPORT_H 21 | #define SDQT_EXPORT_H 22 | 23 | /** \file QtSystemd-export.h 24 | \ brief Contains Macr*os for exporting symbols 25 | 26 | This file contains macros needed for exporting/importing symbols 27 | */ 28 | 29 | #include 30 | 31 | #ifndef SDQT_EXPORT 32 | # if defined(MAKE_SDQT_LIB) 33 | /* We are building this library */ 34 | # define SDQT_EXPORT Q_DECL_EXPORT 35 | # else 36 | /* We are using this library */ 37 | # define SDQT_EXPORT Q_DECL_IMPORT 38 | # endif 39 | #endif 40 | 41 | #endif /*SDQT_EXPORT_H*/ -------------------------------------------------------------------------------- /src/dbus/org.freedesktop.DBus.Properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/dbus/org.freedesktop.login1.LDManager.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | -------------------------------------------------------------------------------- /src/dbus/org.freedesktop.login1.Seat.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/dbus/org.freedesktop.login1.Session.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /src/dbus/org.freedesktop.login1.User.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/dbus/org.freedesktop.systemd1.Automount.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/dbus/org.freedesktop.systemd1.Device.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/dbus/org.freedesktop.systemd1.Job.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/dbus/org.freedesktop.systemd1.Path.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/dbus/org.freedesktop.systemd1.Scope.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /src/dbus/org.freedesktop.systemd1.Slice.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/dbus/org.freedesktop.systemd1.Target.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/dbus/org.freedesktop.systemd1.Timer.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/dbus/org.freedesktop.systemd1.Unit.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | -------------------------------------------------------------------------------- /src/generic-types.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #include "generic-types.h" 21 | 22 | 23 | QDBusArgument& operator<<(QDBusArgument &argument, const DBusJob &job) 24 | { 25 | argument.beginStructure(); 26 | argument << job.id << job.path; 27 | argument.endStructure(); 28 | return argument; 29 | } 30 | 31 | const QDBusArgument& operator>>(const QDBusArgument &argument, DBusJob &job) 32 | { 33 | argument.beginStructure(); 34 | argument >> job.id >> job.path; 35 | argument.endStructure(); 36 | return argument; 37 | } 38 | 39 | QDBusArgument& operator<<(QDBusArgument &argument, const DBusSeat &seat) 40 | { 41 | argument.beginStructure(); 42 | argument << seat.id << seat.path; 43 | argument.endStructure(); 44 | return argument; 45 | } 46 | 47 | const QDBusArgument& operator>>(const QDBusArgument &argument, DBusSeat &seat) 48 | { 49 | argument.beginStructure(); 50 | argument >> seat.id >> seat.path; 51 | argument.endStructure(); 52 | return argument; 53 | } 54 | 55 | QDBusArgument& operator<<(QDBusArgument &argument, const DBusSession &session) 56 | { 57 | argument.beginStructure(); 58 | argument << session.id << session.path; 59 | argument.endStructure(); 60 | return argument; 61 | } 62 | 63 | const QDBusArgument& operator>>(const QDBusArgument &argument, DBusSession &session) 64 | { 65 | argument.beginStructure(); 66 | argument >> session.id >> session.path; 67 | argument.endStructure(); 68 | return argument; 69 | } 70 | 71 | QDBusArgument& operator<<(QDBusArgument &argument, const DBusUnit &unit) 72 | { 73 | argument.beginStructure(); 74 | argument << unit.name << unit.path; 75 | argument.endStructure(); 76 | return argument; 77 | } 78 | 79 | const QDBusArgument& operator>>(const QDBusArgument &argument, DBusUnit &unit) 80 | { 81 | argument.beginStructure(); 82 | argument >> unit.name >> unit.path; 83 | argument.endStructure(); 84 | return argument; 85 | } 86 | 87 | QDBusArgument& operator<<(QDBusArgument &argument, const DBusUser &user) 88 | { 89 | argument.beginStructure(); 90 | argument << user.id << user.path; 91 | argument.endStructure(); 92 | return argument; 93 | } 94 | 95 | const QDBusArgument& operator>>(const QDBusArgument &argument, DBusUser &user) 96 | { 97 | argument.beginStructure(); 98 | argument >> user.id >> user.path; 99 | argument.endStructure(); 100 | return argument; 101 | } 102 | 103 | QDBusArgument& operator<<(QDBusArgument &argument, const CGroupDBusBlockIODeviceWeight &cGroupBlockIODeviceWeight) 104 | { 105 | argument.beginStructure(); 106 | argument << cGroupBlockIODeviceWeight.path << cGroupBlockIODeviceWeight.weight; 107 | argument.endStructure(); 108 | return argument; 109 | } 110 | 111 | const QDBusArgument& operator>>(const QDBusArgument &argument, CGroupDBusBlockIODeviceWeight &cGroupBlockIODeviceWeight) 112 | { 113 | argument.beginStructure(); 114 | argument >> cGroupBlockIODeviceWeight.path >> cGroupBlockIODeviceWeight.weight; 115 | argument.endStructure(); 116 | return argument; 117 | } 118 | 119 | QDBusArgument& operator<<(QDBusArgument &argument, const CGroupDBusDeviceAllow &cGroupDeviceAllow) 120 | { 121 | argument.beginStructure(); 122 | argument << cGroupDeviceAllow.path << cGroupDeviceAllow.rwm; 123 | argument.endStructure(); 124 | return argument; 125 | } 126 | 127 | const QDBusArgument& operator>>(const QDBusArgument &argument, CGroupDBusDeviceAllow &cGroupDeviceAllow) 128 | { 129 | argument.beginStructure(); 130 | argument >> cGroupDeviceAllow.path >> cGroupDeviceAllow.rwm; 131 | argument.endStructure(); 132 | return argument; 133 | } 134 | 135 | QDBusArgument& operator<<(QDBusArgument &argument, const ExecuteDBusAddressFamilies &addressFamilies) 136 | { 137 | argument.beginStructure(); 138 | argument << addressFamilies.whitelist << addressFamilies.names; 139 | argument.endStructure(); 140 | return argument; 141 | } 142 | 143 | const QDBusArgument& operator>>(const QDBusArgument &argument, ExecuteDBusAddressFamilies &addressFamilies) 144 | { 145 | argument.beginStructure(); 146 | argument >> addressFamilies.whitelist >> addressFamilies.names; 147 | argument.endStructure(); 148 | return argument; 149 | } 150 | 151 | QDBusArgument& operator<<(QDBusArgument &argument, const ExecuteDBusAppArmorProfile &appArmorProfile) 152 | { 153 | argument.beginStructure(); 154 | argument << appArmorProfile.ignore << appArmorProfile.profile; 155 | argument.endStructure(); 156 | return argument; 157 | } 158 | 159 | const QDBusArgument& operator>>(const QDBusArgument &argument, ExecuteDBusAppArmorProfile &appArmorProfile) 160 | { 161 | argument.beginStructure(); 162 | argument >> appArmorProfile.ignore >> appArmorProfile.profile; 163 | argument.endStructure(); 164 | return argument; 165 | } 166 | 167 | QDBusArgument& operator<<(QDBusArgument &argument, const ExecuteDBusSmackProcessLabel &smackProcessLabel) 168 | { 169 | argument.beginStructure(); 170 | argument << smackProcessLabel.ignore << smackProcessLabel.profile; 171 | argument.endStructure(); 172 | return argument; 173 | } 174 | 175 | const QDBusArgument& operator>>(const QDBusArgument &argument, ExecuteDBusSmackProcessLabel &smackProcessLabel) 176 | { 177 | argument.beginStructure(); 178 | argument >> smackProcessLabel.ignore >> smackProcessLabel.profile; 179 | argument.endStructure(); 180 | return argument; 181 | } 182 | 183 | QDBusArgument& operator<<(QDBusArgument &argument, const ExecuteDBusEnvironmentFile &environmentFile) 184 | { 185 | argument.beginStructure(); 186 | argument << environmentFile.fileName << environmentFile.dash; 187 | argument.endStructure(); 188 | return argument; 189 | } 190 | 191 | const QDBusArgument& operator>>(const QDBusArgument &argument, ExecuteDBusEnvironmentFile &environmentFile) 192 | { 193 | argument.beginStructure(); 194 | argument >> environmentFile.fileName >> environmentFile.dash; 195 | argument.endStructure(); 196 | return argument; 197 | } 198 | 199 | QDBusArgument& operator<<(QDBusArgument &argument, const ExecuteDBusExecCommand &execCommand) 200 | { 201 | argument.beginStructure(); 202 | argument << execCommand.path << execCommand.argv << execCommand.ignore; 203 | argument << execCommand.startTimestamp << execCommand.exitTimestamp << execCommand.pid; 204 | argument << execCommand.exitCode << execCommand.exitStatus; 205 | argument.endStructure(); 206 | return argument; 207 | } 208 | 209 | const QDBusArgument& operator>>(const QDBusArgument &argument, ExecuteDBusExecCommand &execCommand) 210 | { 211 | argument.beginStructure(); 212 | argument >> execCommand.path >> execCommand.argv >> execCommand.ignore; 213 | argument >> execCommand.startTimestamp >> execCommand.exitTimestamp >> execCommand.pid; 214 | argument >> execCommand.exitCode >> execCommand.exitStatus; 215 | argument.endStructure(); 216 | return argument; 217 | } 218 | 219 | QDBusArgument& operator<<(QDBusArgument &argument, const ExecuteDBusSELinuxContext &seLinuxContext) 220 | { 221 | argument.beginStructure(); 222 | argument << seLinuxContext.ignore << seLinuxContext.context; 223 | argument.endStructure(); 224 | return argument; 225 | } 226 | 227 | const QDBusArgument& operator>>(const QDBusArgument &argument, ExecuteDBusSELinuxContext &seLinuxContext) 228 | { 229 | argument.beginStructure(); 230 | argument >> seLinuxContext.ignore >> seLinuxContext.context; 231 | argument.endStructure(); 232 | return argument; 233 | } 234 | 235 | QDBusArgument& operator<<(QDBusArgument &argument, const ExecuteDBusSystemCall &systemCall) 236 | { 237 | argument.beginStructure(); 238 | argument << systemCall.whitelist << systemCall.names; 239 | argument.endStructure(); 240 | return argument; 241 | } 242 | 243 | const QDBusArgument& operator>>(const QDBusArgument &argument, ExecuteDBusSystemCall &systemCall) 244 | { 245 | argument.beginStructure(); 246 | argument >> systemCall.whitelist >> systemCall.names; 247 | argument.endStructure(); 248 | return argument; 249 | } 250 | 251 | QDBusArgument& operator<<(QDBusArgument &argument, const LoginInhibitor &inhibitor) 252 | { 253 | argument.beginStructure(); 254 | argument << inhibitor.what << inhibitor.who << inhibitor.why << inhibitor.mode; 255 | argument << inhibitor.uid << inhibitor.pid; 256 | argument.endStructure(); 257 | return argument; 258 | } 259 | 260 | const QDBusArgument& operator>>(const QDBusArgument &argument, LoginInhibitor &inhibitor) 261 | { 262 | argument.beginStructure(); 263 | argument >> inhibitor.what >> inhibitor.who >> inhibitor.why >> inhibitor.mode; 264 | argument >> inhibitor.uid >> inhibitor.pid; 265 | argument.endStructure(); 266 | return argument; 267 | } 268 | 269 | QDBusArgument& operator<<(QDBusArgument &argument, const LoginDBusScheduledShutdown &scheduledShutdown) 270 | { 271 | argument.beginStructure(); 272 | argument << scheduledShutdown.type << scheduledShutdown.timeout; 273 | argument.endStructure(); 274 | return argument; 275 | } 276 | 277 | const QDBusArgument& operator>>(const QDBusArgument &argument, LoginDBusScheduledShutdown &scheduledShutdown) 278 | { 279 | argument.beginStructure(); 280 | argument >> scheduledShutdown.type >> scheduledShutdown.timeout; 281 | argument.endStructure(); 282 | return argument; 283 | } 284 | 285 | QDBusArgument& operator<<(QDBusArgument &argument, const LoginDBusSession &session) 286 | { 287 | argument.beginStructure(); 288 | argument << session.id << session.uid << session.name << session.seatId; 289 | argument << session.path; 290 | argument.endStructure(); 291 | return argument; 292 | } 293 | 294 | const QDBusArgument& operator>>(const QDBusArgument &argument, LoginDBusSession &session) 295 | { 296 | argument.beginStructure(); 297 | argument >> session.id >> session.uid >> session.name >> session.seatId; 298 | argument >> session.path; 299 | argument.endStructure(); 300 | return argument; 301 | } 302 | 303 | QDBusArgument& operator<<(QDBusArgument &argument, const LoginDBusUser &user) 304 | { 305 | argument.beginStructure(); 306 | argument << user.uid << user.name << user.path; 307 | argument.endStructure(); 308 | return argument; 309 | } 310 | 311 | const QDBusArgument& operator>>(const QDBusArgument &argument, LoginDBusUser &user) 312 | { 313 | argument.beginStructure(); 314 | argument >> user.uid >> user.name >> user.path; 315 | argument.endStructure(); 316 | return argument; 317 | } 318 | 319 | QDBusArgument& operator<<(QDBusArgument &argument, const ManagerDBusJob &job) 320 | { 321 | argument.beginStructure(); 322 | argument << job.id << job.unitId << job.type << job.state << job.path; 323 | argument << job.unitPath; 324 | argument.endStructure(); 325 | return argument; 326 | } 327 | 328 | const QDBusArgument& operator>>(const QDBusArgument &argument, ManagerDBusJob &job) 329 | { 330 | argument.beginStructure(); 331 | argument >> job.id >> job.unitId >> job.type >> job.state >> job.path; 332 | argument >> job.unitPath; 333 | argument.endStructure(); 334 | return argument; 335 | } 336 | 337 | QDBusArgument& operator<<(QDBusArgument &argument, const ManagerDBusUnit &unit) 338 | { 339 | argument.beginStructure(); 340 | argument << unit.id << unit.description << unit.loadState << unit.activeState; 341 | argument << unit.subState << unit.following << unit.path << unit.jobId; 342 | argument << unit.jobType << unit.jobPath; 343 | argument.endStructure(); 344 | return argument; 345 | } 346 | 347 | const QDBusArgument& operator>>(const QDBusArgument &argument, ManagerDBusUnit &unit) 348 | { 349 | argument.beginStructure(); 350 | argument >> unit.id >> unit.description >> unit.loadState >> unit.activeState; 351 | argument >> unit.subState >> unit.following >> unit.path >> unit.jobId; 352 | argument >> unit.jobType >> unit.jobPath; 353 | argument.endStructure(); 354 | return argument; 355 | } 356 | 357 | QDBusArgument& operator<<(QDBusArgument &argument, const ManagerDBusUnitFile &unitFile) 358 | { 359 | argument.beginStructure(); 360 | argument << unitFile.path << unitFile.state; 361 | argument.endStructure(); 362 | return argument; 363 | } 364 | 365 | const QDBusArgument& operator>>(const QDBusArgument &argument, ManagerDBusUnitFile &unitFile) 366 | { 367 | argument.beginStructure(); 368 | argument >> unitFile.path >> unitFile.state; 369 | argument.endStructure(); 370 | return argument; 371 | } 372 | 373 | QDBusArgument& operator<<(QDBusArgument &argument, const ManagerDBusUnitFileChange &unitFileChange) 374 | { 375 | argument.beginStructure(); 376 | argument << unitFileChange.type << unitFileChange.path << unitFileChange.source; 377 | argument.endStructure(); 378 | return argument; 379 | } 380 | 381 | const QDBusArgument& operator>>(const QDBusArgument &argument, ManagerDBusUnitFileChange &unitFileChange) 382 | { 383 | argument.beginStructure(); 384 | argument >> unitFileChange.type >> unitFileChange.path >> unitFileChange.source; 385 | argument.endStructure(); 386 | return argument; 387 | } 388 | 389 | QDBusArgument& operator<<(QDBusArgument &argument, const PathDBusPath &path) 390 | { 391 | argument.beginStructure(); 392 | argument << path.type << path.path; 393 | argument.endStructure(); 394 | return argument; 395 | } 396 | 397 | const QDBusArgument& operator>>(const QDBusArgument &argument, PathDBusPath &path) 398 | { 399 | argument.beginStructure(); 400 | argument >> path.type >> path.path; 401 | argument.endStructure(); 402 | return argument; 403 | } 404 | 405 | QDBusArgument& operator<<(QDBusArgument &argument, const SocketDBusSocket &socket) 406 | { 407 | argument.beginStructure(); 408 | argument << socket.type << socket.address; 409 | argument.endStructure(); 410 | return argument; 411 | } 412 | 413 | const QDBusArgument& operator>>(const QDBusArgument &argument, SocketDBusSocket &socket) 414 | { 415 | argument.beginStructure(); 416 | argument >> socket.type >> socket.address; 417 | argument.endStructure(); 418 | return argument; 419 | } 420 | 421 | QDBusArgument& operator<<(QDBusArgument &argument, const TimerDBusCalendarTimer &calendarTimer) 422 | { 423 | argument.beginStructure(); 424 | argument << calendarTimer.timerBase << calendarTimer.calendarSpec << calendarTimer.nextElapse; 425 | argument.endStructure(); 426 | return argument; 427 | } 428 | 429 | const QDBusArgument& operator>>(const QDBusArgument &argument, TimerDBusCalendarTimer &calendarTimer) 430 | { 431 | argument.beginStructure(); 432 | argument >> calendarTimer.timerBase >> calendarTimer.calendarSpec >> calendarTimer.nextElapse; 433 | argument.endStructure(); 434 | return argument; 435 | } 436 | 437 | QDBusArgument& operator<<(QDBusArgument &argument, const TimerDBusMonotonicTimer &monotonicTimer) 438 | { 439 | argument.beginStructure(); 440 | argument << monotonicTimer.timerBase << monotonicTimer.value << monotonicTimer.nextElapse; 441 | argument.endStructure(); 442 | return argument; 443 | } 444 | 445 | const QDBusArgument& operator>>(const QDBusArgument &argument, TimerDBusMonotonicTimer &monotonicTimer) 446 | { 447 | argument.beginStructure(); 448 | argument >> monotonicTimer.timerBase >> monotonicTimer.value >> monotonicTimer.nextElapse; 449 | argument.endStructure(); 450 | return argument; 451 | } 452 | 453 | QDBusArgument& operator<<(QDBusArgument &argument, const UnitCondition &condition) 454 | { 455 | argument.beginStructure(); 456 | argument << condition.name << condition.trigger << condition.negate << condition.param; 457 | argument << condition.state; 458 | argument.endStructure(); 459 | return argument; 460 | } 461 | 462 | const QDBusArgument& operator>>(const QDBusArgument &argument, UnitCondition &condition) 463 | { 464 | argument.beginStructure(); 465 | argument >> condition.name >> condition.trigger >> condition.negate >> condition.param; 466 | argument >> condition.state; 467 | argument.endStructure(); 468 | return argument; 469 | } 470 | 471 | QDBusArgument& operator<<(QDBusArgument &argument, const UnitLoadError &loadError) 472 | { 473 | argument.beginStructure(); 474 | argument << loadError.name << loadError.message; 475 | argument.endStructure(); 476 | return argument; 477 | } 478 | 479 | const QDBusArgument& operator>>(const QDBusArgument &argument, UnitLoadError &loadError) 480 | { 481 | argument.beginStructure(); 482 | argument >> loadError.name >> loadError.message; 483 | argument.endStructure(); 484 | return argument; 485 | } 486 | 487 | QDBusArgument& operator<<(QDBusArgument &argument, const ManagerDBusAux&aux) 488 | { 489 | argument.beginStructure(); 490 | argument << aux.name << aux.properties; 491 | argument.endStructure(); 492 | return argument; 493 | } 494 | 495 | const QDBusArgument& operator>>(const QDBusArgument &argument, ManagerDBusAux &aux) 496 | { 497 | argument.beginStructure(); 498 | argument >> aux.name >> aux.properties; 499 | argument.endStructure(); 500 | return argument; 501 | } 502 | -------------------------------------------------------------------------------- /src/generic-types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #ifndef GENERIC_TYPES_H 21 | #define GENERIC_TYPES_H 22 | 23 | #include 24 | 25 | typedef struct { 26 | uint id; 27 | QDBusObjectPath path; 28 | } DBusJob; 29 | Q_DECLARE_METATYPE(DBusJob) 30 | 31 | QDBusArgument &operator<<(QDBusArgument &argument, const DBusJob &job); 32 | const QDBusArgument &operator>>(const QDBusArgument &argument, DBusJob &job); 33 | 34 | typedef struct { 35 | QString id; 36 | QDBusObjectPath path; 37 | } DBusSeat; 38 | Q_DECLARE_METATYPE(DBusSeat) 39 | typedef QList DBusSeatList; 40 | Q_DECLARE_METATYPE(DBusSeatList) 41 | 42 | QDBusArgument &operator<<(QDBusArgument &argument, const DBusSeat &seat); 43 | const QDBusArgument &operator>>(const QDBusArgument &argument, DBusSeat &seat); 44 | 45 | typedef struct { 46 | QString id; 47 | QDBusObjectPath path; 48 | } DBusSession; 49 | Q_DECLARE_METATYPE(DBusSession) 50 | typedef QList DBusSessionList; 51 | Q_DECLARE_METATYPE(DBusSessionList) 52 | 53 | QDBusArgument &operator<<(QDBusArgument &argument, const DBusSession &session); 54 | const QDBusArgument &operator>>(const QDBusArgument &argument, DBusSession &session); 55 | 56 | typedef struct { 57 | QString name; 58 | QDBusObjectPath path; 59 | } DBusUnit; 60 | Q_DECLARE_METATYPE(DBusUnit) 61 | 62 | QDBusArgument &operator<<(QDBusArgument &argument, const DBusUnit &unit); 63 | const QDBusArgument &operator>>(const QDBusArgument &argument, DBusUnit &unit); 64 | 65 | typedef struct { 66 | uint id; 67 | QDBusObjectPath path; 68 | } DBusUser; 69 | Q_DECLARE_METATYPE(DBusUser) 70 | 71 | QDBusArgument &operator<<(QDBusArgument &argument, const DBusUser &user); 72 | const QDBusArgument &operator>>(const QDBusArgument &argument, DBusUser &user); 73 | 74 | typedef struct { 75 | QString path; 76 | qulonglong weight; 77 | } CGroupDBusBlockIODeviceWeight; 78 | Q_DECLARE_METATYPE(CGroupDBusBlockIODeviceWeight) 79 | typedef QList CGroupDBusBlockIODeviceWeightList; 80 | Q_DECLARE_METATYPE(CGroupDBusBlockIODeviceWeightList) 81 | 82 | QDBusArgument &operator<<(QDBusArgument &argument, const CGroupDBusBlockIODeviceWeight &cGroupBlockIODeviceWeight); 83 | const QDBusArgument &operator>>(const QDBusArgument &argument, CGroupDBusBlockIODeviceWeight &cGroupBlockIODeviceWeight); 84 | 85 | typedef struct { 86 | QString path; 87 | QString rwm; 88 | } CGroupDBusDeviceAllow; 89 | Q_DECLARE_METATYPE(CGroupDBusDeviceAllow) 90 | typedef QList CGroupDBusDeviceAllowList; 91 | Q_DECLARE_METATYPE(CGroupDBusDeviceAllowList) 92 | 93 | QDBusArgument &operator<<(QDBusArgument &argument, const CGroupDBusDeviceAllow &cGroupDeviceAllow); 94 | const QDBusArgument &operator>>(const QDBusArgument &argument, CGroupDBusDeviceAllow &cGroupDeviceAllow); 95 | 96 | typedef struct { 97 | bool whitelist; 98 | QStringList names; 99 | } ExecuteDBusAddressFamilies; 100 | Q_DECLARE_METATYPE(ExecuteDBusAddressFamilies) 101 | 102 | QDBusArgument &operator<<(QDBusArgument &argument, const ExecuteDBusAddressFamilies &addressFamilies); 103 | const QDBusArgument &operator>>(const QDBusArgument &argument, ExecuteDBusAddressFamilies &addressFamilies); 104 | 105 | typedef struct { 106 | bool ignore; 107 | QString profile; 108 | } ExecuteDBusAppArmorProfile; 109 | Q_DECLARE_METATYPE(ExecuteDBusAppArmorProfile) 110 | 111 | QDBusArgument &operator<<(QDBusArgument &argument, const ExecuteDBusAppArmorProfile &appArmorProfile); 112 | const QDBusArgument &operator>>(const QDBusArgument &argument, ExecuteDBusAppArmorProfile &appArmorProfile); 113 | 114 | typedef struct { 115 | bool ignore; 116 | QString profile; 117 | } ExecuteDBusSmackProcessLabel; 118 | Q_DECLARE_METATYPE(ExecuteDBusSmackProcessLabel) 119 | 120 | QDBusArgument &operator<<(QDBusArgument &argument, const ExecuteDBusSmackProcessLabel &smackProcessLabel); 121 | const QDBusArgument &operator>>(const QDBusArgument &argument, ExecuteDBusSmackProcessLabel &smackProcessLabel); 122 | 123 | typedef struct { 124 | QString fileName; 125 | bool dash; 126 | } ExecuteDBusEnvironmentFile; 127 | Q_DECLARE_METATYPE(ExecuteDBusEnvironmentFile) 128 | typedef QList ExecuteDBusEnvironmentFileList; 129 | Q_DECLARE_METATYPE(ExecuteDBusEnvironmentFileList) 130 | 131 | QDBusArgument &operator<<(QDBusArgument &argument, const ExecuteDBusEnvironmentFile &environmentFile); 132 | const QDBusArgument &operator>>(const QDBusArgument &argument, ExecuteDBusEnvironmentFile &environmentFile); 133 | 134 | typedef struct { 135 | QString path; 136 | QStringList argv; 137 | bool ignore; 138 | qlonglong startTimestamp; 139 | qlonglong exitTimestamp; 140 | quint32 pid; 141 | qint32 exitCode; 142 | qint32 exitStatus; 143 | } ExecuteDBusExecCommand; 144 | Q_DECLARE_METATYPE(ExecuteDBusExecCommand) 145 | typedef QList ExecuteDBusExecCommandList; 146 | Q_DECLARE_METATYPE(ExecuteDBusExecCommandList) 147 | 148 | QDBusArgument &operator<<(QDBusArgument &argument, const ExecuteDBusExecCommand &execCommand); 149 | const QDBusArgument &operator>>(const QDBusArgument &argument, ExecuteDBusExecCommand &execCommand); 150 | 151 | typedef struct { 152 | bool ignore; 153 | QString context; 154 | } ExecuteDBusSELinuxContext; 155 | Q_DECLARE_METATYPE(ExecuteDBusSELinuxContext) 156 | 157 | QDBusArgument &operator<<(QDBusArgument &argument, const ExecuteDBusSELinuxContext &seLinuxContext); 158 | const QDBusArgument &operator>>(const QDBusArgument &argument, ExecuteDBusSELinuxContext &seLinuxContext); 159 | 160 | typedef struct { 161 | bool whitelist; 162 | QStringList names; 163 | } ExecuteDBusSystemCall; 164 | Q_DECLARE_METATYPE(ExecuteDBusSystemCall) 165 | 166 | QDBusArgument &operator<<(QDBusArgument &argument, const ExecuteDBusSystemCall &systemCall); 167 | const QDBusArgument &operator>>(const QDBusArgument &argument, ExecuteDBusSystemCall &systemCall); 168 | 169 | typedef struct { 170 | QString what; 171 | QString who; 172 | QString why; 173 | QString mode; 174 | quint32 uid; 175 | quint32 pid; 176 | } LoginInhibitor; 177 | Q_DECLARE_METATYPE(LoginInhibitor) 178 | typedef QList LoginInhibitorList; 179 | Q_DECLARE_METATYPE(LoginInhibitorList) 180 | 181 | QDBusArgument &operator<<(QDBusArgument &argument, const LoginInhibitor &inhibitor); 182 | const QDBusArgument &operator>>(const QDBusArgument &argument, LoginInhibitor &inhibitor); 183 | 184 | typedef struct { 185 | QString type; 186 | qulonglong timeout; 187 | } LoginDBusScheduledShutdown; 188 | Q_DECLARE_METATYPE(LoginDBusScheduledShutdown) 189 | 190 | QDBusArgument &operator<<(QDBusArgument &argument, const LoginDBusScheduledShutdown &scheduledShutdown); 191 | const QDBusArgument &operator>>(const QDBusArgument &argument, LoginDBusScheduledShutdown &scheduledShutdown); 192 | 193 | typedef struct { 194 | QString id; 195 | quint32 uid; 196 | QString name; 197 | QString seatId; 198 | QDBusObjectPath path; 199 | } LoginDBusSession; 200 | Q_DECLARE_METATYPE(LoginDBusSession) 201 | typedef QList LoginDBusSessionList; 202 | Q_DECLARE_METATYPE(LoginDBusSessionList) 203 | 204 | QDBusArgument &operator<<(QDBusArgument &argument, const LoginDBusSession &session); 205 | const QDBusArgument &operator>>(const QDBusArgument &argument, LoginDBusSession &session); 206 | 207 | typedef struct { 208 | quint32 uid; 209 | QString name; 210 | QDBusObjectPath path; 211 | } LoginDBusUser; 212 | Q_DECLARE_METATYPE(LoginDBusUser) 213 | typedef QList LoginDBusUserList; 214 | Q_DECLARE_METATYPE(LoginDBusUserList) 215 | 216 | QDBusArgument &operator<<(QDBusArgument &argument, const LoginDBusUser &user); 217 | const QDBusArgument &operator>>(const QDBusArgument &argument, LoginDBusUser &user); 218 | 219 | typedef struct { 220 | quint32 id; 221 | QString unitId; 222 | QString type; 223 | QString state; 224 | QDBusObjectPath path; 225 | QDBusObjectPath unitPath; 226 | } ManagerDBusJob; 227 | Q_DECLARE_METATYPE(ManagerDBusJob) 228 | typedef QList ManagerDBusJobList; 229 | Q_DECLARE_METATYPE(ManagerDBusJobList) 230 | 231 | QDBusArgument &operator<<(QDBusArgument &argument, const ManagerDBusJob &job); 232 | const QDBusArgument &operator>>(const QDBusArgument &argument, ManagerDBusJob &job); 233 | 234 | typedef struct { 235 | QString id; 236 | QString description; 237 | QString loadState; 238 | QString activeState; 239 | QString subState; 240 | QString following; 241 | QDBusObjectPath path; 242 | quint32 jobId; 243 | QString jobType; 244 | QDBusObjectPath jobPath; 245 | } ManagerDBusUnit; 246 | Q_DECLARE_METATYPE(ManagerDBusUnit) 247 | typedef QList ManagerDBusUnitList; 248 | Q_DECLARE_METATYPE(ManagerDBusUnitList) 249 | 250 | QDBusArgument &operator<<(QDBusArgument &argument, const ManagerDBusUnit &unit); 251 | const QDBusArgument &operator>>(const QDBusArgument &argument, ManagerDBusUnit &unit); 252 | 253 | typedef struct { 254 | QString path; 255 | QString state; 256 | } ManagerDBusUnitFile; 257 | Q_DECLARE_METATYPE(ManagerDBusUnitFile) 258 | typedef QList ManagerDBusUnitFileList; 259 | Q_DECLARE_METATYPE(ManagerDBusUnitFileList) 260 | 261 | QDBusArgument &operator<<(QDBusArgument &argument, const ManagerDBusUnitFile &unitFile); 262 | const QDBusArgument &operator>>(const QDBusArgument &argument, ManagerDBusUnitFile &unitFile); 263 | 264 | typedef struct { 265 | QString type; 266 | QString path; 267 | QString source; 268 | } ManagerDBusUnitFileChange; 269 | Q_DECLARE_METATYPE(ManagerDBusUnitFileChange) 270 | typedef QList ManagerDBusUnitFileChangeList; 271 | Q_DECLARE_METATYPE(ManagerDBusUnitFileChangeList) 272 | 273 | QDBusArgument &operator<<(QDBusArgument &argument, const ManagerDBusUnitFileChange &unitFileChange); 274 | const QDBusArgument &operator>>(const QDBusArgument &argument, ManagerDBusUnitFileChange &unitFileChange); 275 | 276 | typedef struct { 277 | QString type; 278 | QString path; 279 | } PathDBusPath; 280 | Q_DECLARE_METATYPE(PathDBusPath) 281 | typedef QList PathDBusPathList; 282 | Q_DECLARE_METATYPE(PathDBusPathList) 283 | 284 | QDBusArgument &operator<<(QDBusArgument &argument, const PathDBusPath &path); 285 | const QDBusArgument &operator>>(const QDBusArgument &argument, PathDBusPath &path); 286 | 287 | typedef struct { 288 | QString type; 289 | QString address; 290 | } SocketDBusSocket; 291 | Q_DECLARE_METATYPE(SocketDBusSocket) 292 | typedef QList SocketDBusSocketList; 293 | Q_DECLARE_METATYPE(SocketDBusSocketList) 294 | 295 | QDBusArgument &operator<<(QDBusArgument &argument, const SocketDBusSocket &socket); 296 | const QDBusArgument &operator>>(const QDBusArgument &argument, SocketDBusSocket &socket); 297 | 298 | typedef struct { 299 | QString timerBase; 300 | QString calendarSpec; 301 | qlonglong nextElapse; 302 | } TimerDBusCalendarTimer; 303 | Q_DECLARE_METATYPE(TimerDBusCalendarTimer) 304 | typedef QList TimerDBusCalendarTimerList; 305 | Q_DECLARE_METATYPE(TimerDBusCalendarTimerList) 306 | 307 | QDBusArgument &operator<<(QDBusArgument &argument, const TimerDBusCalendarTimer &calendarTimer); 308 | const QDBusArgument &operator>>(const QDBusArgument &argument, TimerDBusCalendarTimer &calendarTimer); 309 | 310 | typedef struct { 311 | QString timerBase; 312 | qlonglong value; 313 | qlonglong nextElapse; 314 | } TimerDBusMonotonicTimer; 315 | Q_DECLARE_METATYPE(TimerDBusMonotonicTimer) 316 | typedef QList TimerDBusMonotonicTimerList; 317 | Q_DECLARE_METATYPE(TimerDBusMonotonicTimerList) 318 | 319 | QDBusArgument &operator<<(QDBusArgument &argument, const TimerDBusMonotonicTimer &monotonicTimer); 320 | const QDBusArgument &operator>>(const QDBusArgument &argument, TimerDBusMonotonicTimer &monotonicTimer); 321 | 322 | typedef struct { 323 | QString name; 324 | bool trigger; 325 | bool negate; 326 | QString param; 327 | qint32 state; 328 | } UnitCondition; 329 | Q_DECLARE_METATYPE(UnitCondition) 330 | typedef QList UnitConditionList; 331 | Q_DECLARE_METATYPE(UnitConditionList) 332 | 333 | QDBusArgument &operator<<(QDBusArgument &argument, const UnitCondition &condition); 334 | const QDBusArgument &operator>>(const QDBusArgument &argument, UnitCondition &condition); 335 | 336 | typedef struct { 337 | QString name; 338 | QString message; 339 | } UnitLoadError; 340 | Q_DECLARE_METATYPE(UnitLoadError) 341 | 342 | QDBusArgument &operator<<(QDBusArgument &argument, const UnitLoadError &loadError); 343 | const QDBusArgument &operator>>(const QDBusArgument &argument, UnitLoadError &loadError); 344 | 345 | typedef struct { 346 | QString name; 347 | QVariantMap properties; 348 | } ManagerDBusAux; 349 | Q_DECLARE_METATYPE(ManagerDBusAux) 350 | typedef QList ManagerDBusAuxList; 351 | Q_DECLARE_METATYPE(ManagerDBusAuxList) 352 | 353 | QDBusArgument &operator<<(QDBusArgument &argument, const ManagerDBusAux &aux); 354 | const QDBusArgument &operator>>(const QDBusArgument &argument, ManagerDBusAux &aux); 355 | 356 | #endif // GENERIC_TYPES_H 357 | -------------------------------------------------------------------------------- /src/job.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #include "job_p.h" 21 | #include "sdmanager_p.h" 22 | 23 | Systemd::JobPrivate::JobPrivate(const QString &path, const QDBusConnection &connection) : 24 | jobIface(Systemd::SystemdPrivate::SD_DBUS_SERVICE, path, connection) 25 | { 26 | id = jobIface.id(); 27 | jobType = jobIface.jobType(); 28 | state = jobIface.state(); 29 | unit = jobIface.unit().name; 30 | } 31 | 32 | Systemd::JobPrivate::~JobPrivate() 33 | { 34 | } 35 | 36 | Systemd::Job::Job(const QString &path, const QDBusConnection &connection, QObject *parent) : 37 | QObject(parent), d_ptr(new JobPrivate(path, connection)) 38 | { 39 | } 40 | 41 | Systemd::Job::Job(JobPrivate &job, QObject *parent) : 42 | QObject(parent), d_ptr(&job) 43 | { 44 | } 45 | 46 | Systemd::Job::~Job() 47 | { 48 | delete d_ptr; 49 | } 50 | 51 | uint Systemd::Job::id() const 52 | { 53 | Q_D(const Job); 54 | return d->id; 55 | } 56 | 57 | QString Systemd::Job::jobType() const 58 | { 59 | Q_D(const Job); 60 | return d->jobType; 61 | } 62 | 63 | QString Systemd::Job::state() const 64 | { 65 | Q_D(const Job); 66 | return d->state; 67 | } 68 | 69 | QString Systemd::Job::unit() const 70 | { 71 | Q_D(const Job); 72 | return d->unit; 73 | } 74 | -------------------------------------------------------------------------------- /src/job.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #ifndef SD_JOB_H 21 | #define SD_JOB_H 22 | 23 | #include 24 | 25 | #include "QtSystemd-export.h" 26 | 27 | class QDBusConnection; 28 | 29 | namespace Systemd 30 | { 31 | 32 | class JobPrivate; 33 | 34 | class SDQT_EXPORT Job : public QObject 35 | { 36 | Q_OBJECT 37 | Q_DECLARE_PRIVATE(Job) 38 | 39 | public: 40 | typedef QSharedPointer Ptr; 41 | 42 | explicit Job(const QString &path, const QDBusConnection &connection, QObject *parent = 0); 43 | explicit Job(JobPrivate &job, QObject *parent = 0); 44 | virtual ~Job(); 45 | 46 | uint id() const; 47 | QString jobType() const; 48 | QString state() const; 49 | QString unit() const; 50 | 51 | protected: 52 | JobPrivate *d_ptr; 53 | 54 | }; 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/job_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #ifndef SD_JOB_P_H 21 | #define SD_JOB_P_H 22 | 23 | #include "jobinterface.h" 24 | 25 | #include "job.h" 26 | 27 | namespace Systemd 28 | { 29 | 30 | class JobPrivate 31 | { 32 | 33 | public: 34 | explicit JobPrivate(const QString &path, const QDBusConnection &connection); 35 | virtual ~JobPrivate(); 36 | 37 | OrgFreedesktopSystemd1JobInterface jobIface; 38 | 39 | uint id; 40 | QString jobType; 41 | QString state; 42 | QString unit; 43 | }; 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/ldmanager.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #include "ldmanager.h" 21 | #include "ldmanager_p.h" 22 | 23 | const QString Systemd::Logind::LogindPrivate::LD_DBUS_SERVICE(QLatin1Literal("org.freedesktop.login1")); 24 | const QString Systemd::Logind::LogindPrivate::LD_DBUS_DAEMON_PATH(QLatin1Literal("/org/freedesktop/login1")); 25 | 26 | Q_GLOBAL_STATIC(Systemd::Logind::LogindPrivate, globalLogind) 27 | 28 | Systemd::Logind::LogindPrivate::LogindPrivate() : 29 | ildface(Systemd::Logind::LogindPrivate::LD_DBUS_SERVICE, 30 | Systemd::Logind::LogindPrivate::LD_DBUS_DAEMON_PATH, QDBusConnection::systemBus()) 31 | { 32 | connect(&ildface, SIGNAL(PrepareForShutdown(bool)), 33 | this, SLOT(onPrepareForShutdown(bool))); 34 | connect(&ildface, SIGNAL(PrepareForSleep(bool)), 35 | this, SLOT(onPrepareForSleep(bool))); 36 | 37 | connect(&ildface, SIGNAL(SeatNew(QString, QDBusObjectPath)), this, 38 | SLOT(onSeatNew(QString, QDBusObjectPath))); 39 | connect(&ildface, SIGNAL(SeatRemoved(QString, QDBusObjectPath)), this, 40 | SLOT(onSeatRemoved(QString, QDBusObjectPath))); 41 | 42 | connect(&ildface, SIGNAL(SessionNew(QString, QDBusObjectPath)), this, 43 | SLOT(onSessionNew(QString, QDBusObjectPath))); 44 | connect(&ildface, SIGNAL(SessionRemoved(QString, QDBusObjectPath)), this, 45 | SLOT(onSessionRemoved(QString, QDBusObjectPath))); 46 | 47 | connect(&ildface, SIGNAL(UserNew(uint, QDBusObjectPath)), this, 48 | SLOT(onUserNew(uint, QDBusObjectPath))); 49 | connect(&ildface, SIGNAL(UserRemoved(uint, QDBusObjectPath)), this, 50 | SLOT(onUserRemoved(uint, QDBusObjectPath))); 51 | 52 | init(); 53 | } 54 | 55 | Systemd::Logind::LogindPrivate::~LogindPrivate() 56 | { 57 | } 58 | 59 | void Systemd::Logind::LogindPrivate::init() 60 | { 61 | qDBusRegisterMetaType(); 62 | } 63 | 64 | Systemd::Logind::Seat::Ptr Systemd::Logind::LogindPrivate::getSeat(const QString &id) 65 | { 66 | Seat::Ptr seat; 67 | 68 | QDBusPendingReply reply = ildface.GetSeat(id); 69 | reply.waitForFinished(); 70 | 71 | if (reply.isError()) { 72 | qDebug() << reply.error().message(); 73 | } else if (! reply.reply().arguments().isEmpty()) { 74 | QString seatPath = qdbus_cast(reply.reply().arguments().first()).path(); 75 | seat = Seat::Ptr(new Seat(seatPath), &QObject::deleteLater); 76 | } 77 | 78 | return seat; 79 | } 80 | 81 | Systemd::Logind::Session::Ptr Systemd::Logind::LogindPrivate::getSession(const QString &id) 82 | { 83 | Session::Ptr session; 84 | 85 | QDBusPendingReply reply = ildface.GetSession(id); 86 | reply.waitForFinished(); 87 | 88 | if (reply.isError()) { 89 | qDebug() << reply.error().message(); 90 | } else if (! reply.reply().arguments().isEmpty()) { 91 | QString sessionPath = qdbus_cast(reply.reply().arguments().first()).path(); 92 | session = Session::Ptr(new Session(sessionPath), &QObject::deleteLater); 93 | } 94 | 95 | return session; 96 | } 97 | 98 | Systemd::Logind::Session::Ptr Systemd::Logind::LogindPrivate::getSessionByPID(const uint &pid) 99 | { 100 | Session::Ptr session; 101 | 102 | QDBusPendingReply reply = ildface.GetSessionByPID(pid); 103 | reply.waitForFinished(); 104 | 105 | if (reply.isError()) { 106 | qDebug() << reply.error().message(); 107 | } else if (! reply.reply().arguments().isEmpty()) { 108 | QString sessionPath = qdbus_cast(reply.reply().arguments().first()).path(); 109 | session = Session::Ptr(new Session(sessionPath), &QObject::deleteLater); 110 | } 111 | 112 | return session; 113 | } 114 | 115 | Systemd::Logind::User::Ptr Systemd::Logind::LogindPrivate::getUser(const uint &uid) 116 | { 117 | User::Ptr user; 118 | 119 | QDBusPendingReply reply = ildface.GetUser(uid); 120 | reply.waitForFinished(); 121 | 122 | if (reply.isError()) { 123 | qDebug() << reply.error().message(); 124 | } else if (! reply.reply().arguments().isEmpty()) { 125 | QString userPath = qdbus_cast(reply.reply().arguments().first()).path(); 126 | user = User::Ptr(new User(userPath), &QObject::deleteLater); 127 | } 128 | 129 | return user; 130 | } 131 | 132 | Systemd::Logind::User::Ptr Systemd::Logind::LogindPrivate::getUserByPID(const uint &pid) 133 | { 134 | User::Ptr user; 135 | 136 | QDBusPendingReply reply = ildface.GetUserByPID(pid); 137 | reply.waitForFinished(); 138 | 139 | if (reply.isError()) { 140 | qDebug() << reply.error().message(); 141 | } else if (! reply.reply().arguments().isEmpty()) { 142 | QString userPath = qdbus_cast(reply.reply().arguments().first()).path(); 143 | user = User::Ptr(new User(userPath), &QObject::deleteLater); 144 | } 145 | 146 | return user; 147 | } 148 | 149 | QList Systemd::Logind::LogindPrivate::listInhibitors() 150 | { 151 | qDBusRegisterMetaType(); 152 | qDBusRegisterMetaType(); 153 | QDBusPendingReply reply = ildface.ListInhibitors(); 154 | reply.waitForFinished(); 155 | 156 | if (reply.isError()) { 157 | qDebug() << reply.error().message(); 158 | return QList(); 159 | } 160 | 161 | QList inhibitors; 162 | const QDBusMessage message = reply.reply(); 163 | if (message.type() == QDBusMessage::ReplyMessage) { 164 | inhibitors = qdbus_cast(message.arguments().first()); 165 | } 166 | 167 | return inhibitors; 168 | } 169 | 170 | QList Systemd::Logind::LogindPrivate::listSeats() 171 | { 172 | qDBusRegisterMetaType(); 173 | qDBusRegisterMetaType(); 174 | QDBusPendingReply reply = ildface.ListSeats(); 175 | reply.waitForFinished(); 176 | 177 | if (reply.isError()) { 178 | qDebug() << reply.error().message(); 179 | return QList(); 180 | } 181 | 182 | QList seatsList; 183 | const QDBusMessage message = reply.reply(); 184 | if (message.type() == QDBusMessage::ReplyMessage) { 185 | const DBusSeatList seats = qdbus_cast(message.arguments().first()); 186 | Q_FOREACH (const DBusSeat seat, seats) { 187 | Seat::Ptr s = Seat::Ptr(new Seat(seat.path.path())); 188 | seatsList.append(s); 189 | } 190 | } 191 | 192 | return seatsList; 193 | } 194 | 195 | QList Systemd::Logind::LogindPrivate::listSessions() 196 | { 197 | qDBusRegisterMetaType(); 198 | qDBusRegisterMetaType(); 199 | qDBusRegisterMetaType(); 200 | QDBusPendingReply reply = ildface.ListSessions(); 201 | reply.waitForFinished(); 202 | 203 | if (reply.isError()) { 204 | qDebug() << reply.error().message(); 205 | return QList(); 206 | } 207 | 208 | QList sessionsList; 209 | const QDBusMessage message = reply.reply(); 210 | if (message.type() == QDBusMessage::ReplyMessage) { 211 | const LoginDBusSessionList sessions = qdbus_cast(message.arguments().first()); 212 | Q_FOREACH (const LoginDBusSession session, sessions) { 213 | Session::Ptr s = Session::Ptr(new Session(session.path.path())); 214 | sessionsList.append(s); 215 | } 216 | } 217 | 218 | return sessionsList; 219 | } 220 | 221 | QList Systemd::Logind::LogindPrivate::listUsers() 222 | { 223 | qDBusRegisterMetaType(); 224 | qDBusRegisterMetaType(); 225 | QDBusPendingReply reply = ildface.ListUsers(); 226 | reply.waitForFinished(); 227 | 228 | if (reply.isError()) { 229 | qDebug() << reply.error().message(); 230 | return QList(); 231 | } 232 | 233 | QList usersList; 234 | const QDBusMessage message = reply.reply(); 235 | if (message.type() == QDBusMessage::ReplyMessage) { 236 | const LoginDBusUserList users = qdbus_cast(message.arguments().first()); 237 | Q_FOREACH (const LoginDBusUser user, users) { 238 | User::Ptr s = User::Ptr(new User(user.path.path())); 239 | usersList.append(s); 240 | } 241 | } 242 | 243 | return usersList; 244 | } 245 | 246 | Systemd::Logind::Permission Systemd::Logind::LogindPrivate::canHibernate() 247 | { 248 | QDBusPendingReply reply = ildface.CanHibernate(); 249 | reply.waitForFinished(); 250 | 251 | if (reply.isError()) { 252 | qDebug() << reply.error().message(); 253 | return Systemd::Logind::No; 254 | } 255 | 256 | const QString permission = qdbus_cast(reply.reply().arguments().first()); 257 | 258 | return stringToPermission(permission); 259 | } 260 | 261 | Systemd::Logind::Permission Systemd::Logind::LogindPrivate::canHybridSleep() 262 | { 263 | QDBusPendingReply reply = ildface.CanHybridSleep(); 264 | reply.waitForFinished(); 265 | 266 | if (reply.isError()) { 267 | qDebug() << reply.error().message(); 268 | return Systemd::Logind::No; 269 | } 270 | 271 | const QString permission = qdbus_cast(reply.reply().arguments().first()); 272 | 273 | return stringToPermission(permission); 274 | } 275 | 276 | Systemd::Logind::Permission Systemd::Logind::LogindPrivate::canPowerOff() 277 | { 278 | QDBusPendingReply reply = ildface.CanPowerOff(); 279 | reply.waitForFinished(); 280 | 281 | if (reply.isError()) { 282 | qDebug() << reply.error().message(); 283 | return Systemd::Logind::No; 284 | } 285 | 286 | const QString permission = qdbus_cast(reply.reply().arguments().first()); 287 | 288 | return stringToPermission(permission); 289 | } 290 | 291 | Systemd::Logind::Permission Systemd::Logind::LogindPrivate::canReboot() 292 | { 293 | QDBusPendingReply reply = ildface.CanReboot(); 294 | reply.waitForFinished(); 295 | 296 | if (reply.isError()) { 297 | qDebug() << reply.error().message(); 298 | return Systemd::Logind::No; 299 | } 300 | 301 | const QString permission = qdbus_cast(reply.reply().arguments().first()); 302 | 303 | return stringToPermission(permission); 304 | } 305 | 306 | Systemd::Logind::Permission Systemd::Logind::LogindPrivate::canSuspend() 307 | { 308 | QDBusPendingReply reply = ildface.CanSuspend(); 309 | reply.waitForFinished(); 310 | 311 | if (reply.isError()) { 312 | qDebug() << reply.error().message(); 313 | return Systemd::Logind::No; 314 | } 315 | 316 | const QString permission = qdbus_cast(reply.reply().arguments().first()); 317 | 318 | return stringToPermission(permission); 319 | } 320 | 321 | void Systemd::Logind::LogindPrivate::hibernate(const bool interactive) 322 | { 323 | QDBusPendingReply reply = ildface.Hibernate(interactive); 324 | reply.waitForFinished(); 325 | 326 | if (reply.isError()) { 327 | qDebug() << reply.error().message(); 328 | } 329 | } 330 | 331 | void Systemd::Logind::LogindPrivate::hybridSleep(const bool interactive) 332 | { 333 | QDBusPendingReply reply = ildface.HybridSleep(interactive); 334 | reply.waitForFinished(); 335 | 336 | if (reply.isError()) { 337 | qDebug() << reply.error().message(); 338 | } 339 | } 340 | 341 | void Systemd::Logind::LogindPrivate::onSeatNew(const QString &id, const QDBusObjectPath &seat) 342 | { 343 | Q_UNUSED(id) 344 | emit Logind::Notifier::seatNew(Seat::Ptr(new Seat(seat.path()))); 345 | } 346 | 347 | void Systemd::Logind::LogindPrivate::onSeatRemoved(const QString &id, const QDBusObjectPath &seat) 348 | { 349 | Q_UNUSED(id) 350 | emit Logind::Notifier::seatRemoved(Seat::Ptr(new Seat(seat.path()))); 351 | } 352 | 353 | void Systemd::Logind::LogindPrivate::onSessionNew(const QString &id, const QDBusObjectPath &session) 354 | { 355 | Q_UNUSED(id) 356 | emit Logind::Notifier::sessionNew(Session::Ptr(new Session(session.path()))); 357 | } 358 | 359 | void Systemd::Logind::LogindPrivate::onSessionRemoved(const QString &id, const QDBusObjectPath &session) 360 | { 361 | Q_UNUSED(id) 362 | emit Logind::Notifier::sessionRemoved(Session::Ptr(new Session(session.path()))); 363 | } 364 | 365 | void Systemd::Logind::LogindPrivate::onUserNew(const uint &id, const QDBusObjectPath &user) 366 | { 367 | Q_UNUSED(id) 368 | emit Logind::Notifier::userNew(User::Ptr(new User(user.path()))); 369 | } 370 | 371 | void Systemd::Logind::LogindPrivate::onUserRemoved(const uint &id, const QDBusObjectPath &user) 372 | { 373 | Q_UNUSED(id) 374 | emit Logind::Notifier::userRemoved(User::Ptr(new User(user.path()))); 375 | } 376 | 377 | void Systemd::Logind::LogindPrivate::powerOff(const bool interactive) 378 | { 379 | QDBusPendingReply reply = ildface.PowerOff(interactive); 380 | reply.waitForFinished(); 381 | 382 | if (reply.isError()) { 383 | qDebug() << reply.error().message(); 384 | } 385 | } 386 | 387 | void Systemd::Logind::LogindPrivate::reboot(const bool interactive) 388 | { 389 | QDBusPendingReply reply = ildface.Reboot(interactive); 390 | reply.waitForFinished(); 391 | 392 | if (reply.isError()) { 393 | qDebug() << reply.error().message(); 394 | } 395 | } 396 | 397 | void Systemd::Logind::LogindPrivate::suspend(const bool interactive) 398 | { 399 | QDBusPendingReply reply = ildface.Suspend(interactive); 400 | reply.waitForFinished(); 401 | 402 | if (reply.isError()) { 403 | qDebug() << reply.error().message(); 404 | } 405 | } 406 | 407 | void Systemd::Logind::LogindPrivate::onPrepareForShutdown(const bool active) 408 | { 409 | emit Logind::Notifier::prepareForShutdown(active); 410 | } 411 | 412 | void Systemd::Logind::LogindPrivate::onPrepareForSleep(const bool active) 413 | { 414 | emit Logind::Notifier::prepareForSleep(active); 415 | } 416 | 417 | Systemd::Logind::Permission Systemd::Logind::LogindPrivate::stringToPermission(const QString &permission) const 418 | { 419 | if (QString::compare(permission, QLatin1String("na")) == 0) { 420 | return Systemd::Logind::Na; 421 | } else if (QString::compare(permission, QLatin1String("yes")) == 0) { 422 | return Systemd::Logind::Yes; 423 | } else if (QString::compare(permission, QLatin1String("challenge")) == 0) { 424 | return Systemd::Logind::Challenge; 425 | } else { 426 | return Systemd::Logind::No; 427 | } 428 | } 429 | 430 | Systemd::Logind::Permission Systemd::Logind::canHibernate() 431 | { 432 | return globalLogind()->canHibernate(); 433 | } 434 | 435 | Systemd::Logind::Permission Systemd::Logind::canHybridSleep() 436 | { 437 | return globalLogind()->canHybridSleep(); 438 | } 439 | 440 | Systemd::Logind::Permission Systemd::Logind::canPowerOff() 441 | { 442 | return globalLogind()->canPowerOff(); 443 | } 444 | 445 | Systemd::Logind::Permission Systemd::Logind::canReboot() 446 | { 447 | return globalLogind()->canReboot(); 448 | } 449 | 450 | Systemd::Logind::Permission Systemd::Logind::canSuspend() 451 | { 452 | return globalLogind()->canSuspend(); 453 | } 454 | 455 | Systemd::Logind::Seat::Ptr Systemd::Logind::getSeat(const QString &id) 456 | { 457 | return globalLogind()->getSeat(id); 458 | } 459 | 460 | Systemd::Logind::Session::Ptr Systemd::Logind::getSession(const QString &id) 461 | { 462 | return globalLogind()->getSession(id); 463 | } 464 | 465 | Systemd::Logind::Session::Ptr Systemd::Logind::getSessionByPID(const uint &pid) 466 | { 467 | return globalLogind()->getSessionByPID(pid); 468 | } 469 | 470 | Systemd::Logind::User::Ptr Systemd::Logind::getUser(const uint &uid) 471 | { 472 | return globalLogind()->getUser(uid); 473 | } 474 | 475 | Systemd::Logind::User::Ptr Systemd::Logind::getUserByPID(const uint &pid) 476 | { 477 | return globalLogind()->getUserByPID(pid); 478 | } 479 | 480 | void Systemd::Logind::hibernate(const bool interactive) 481 | { 482 | globalLogind()->hibernate(interactive); 483 | } 484 | 485 | void Systemd::Logind::hybridSleep(const bool interactive) 486 | { 487 | globalLogind()->hybridSleep(interactive); 488 | } 489 | 490 | QList Systemd::Logind::listInhibitors() 491 | { 492 | return globalLogind()->listInhibitors(); 493 | } 494 | 495 | 496 | QList Systemd::Logind::listSeats() 497 | { 498 | return globalLogind()->listSeats(); 499 | } 500 | 501 | QList Systemd::Logind::listSessions() 502 | { 503 | return globalLogind()->listSessions(); 504 | } 505 | 506 | QList Systemd::Logind::listUsers() 507 | { 508 | return globalLogind()->listUsers(); 509 | } 510 | 511 | void Systemd::Logind::powerOff(const bool interactive) 512 | { 513 | globalLogind()->powerOff(interactive); 514 | } 515 | 516 | void Systemd::Logind::reboot(const bool interactive) 517 | { 518 | globalLogind()->reboot(interactive); 519 | } 520 | 521 | void Systemd::Logind::suspend(const bool interactive) 522 | { 523 | globalLogind()->suspend(interactive); 524 | } 525 | 526 | Systemd::Logind::Notifier* Systemd::Logind::notifier() 527 | { 528 | return globalLogind(); 529 | } 530 | -------------------------------------------------------------------------------- /src/ldmanager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #ifndef LD_MANAGER_H 21 | #define LD_MANAGER_H 22 | 23 | #include 24 | 25 | #include "QtSystemd-export.h" 26 | #include "generic-types.h" 27 | #include "seat.h" 28 | #include "session.h" 29 | #include "user.h" 30 | 31 | /** 32 | * This class allows querying the underlying system. 33 | * 34 | * It is the unique entry point for logind. 35 | * 36 | * Note that it is implemented as a singleton 37 | */ 38 | namespace Systemd 39 | { 40 | namespace Logind 41 | { 42 | enum Permission { 43 | Challenge, 44 | Na, 45 | No, 46 | Yes 47 | }; 48 | 49 | class SDQT_EXPORT Notifier : public QObject 50 | { 51 | Q_OBJECT 52 | 53 | Q_SIGNALS: 54 | void prepareForSleep(const bool active); 55 | void prepareForShutdown(const bool active); 56 | void seatNew(const Seat::Ptr &seat); 57 | void seatRemoved(const Seat::Ptr &seat); 58 | void sessionNew(const Session::Ptr &session); 59 | void sessionRemoved(const Session::Ptr &session); 60 | void userNew(const User::Ptr &user); 61 | void userRemoved(const User::Ptr &user); 62 | }; 63 | 64 | /* 65 | * Tests whether the system supports hibernation. 66 | */ 67 | SDQT_EXPORT Permission canHibernate(); 68 | 69 | /* 70 | * Tests whether the system supports hibernation + suspension. 71 | */ 72 | SDQT_EXPORT Permission canHybridSleep(); 73 | 74 | /* 75 | * Tests whether the system can be powered off. 76 | */ 77 | SDQT_EXPORT Permission canPowerOff(); 78 | 79 | /* 80 | * Tests whether the system supports reboot. 81 | */ 82 | SDQT_EXPORT Permission canReboot(); 83 | 84 | /* 85 | * Tests whether the system supports suspension. 86 | */ 87 | SDQT_EXPORT Permission canSuspend(); 88 | 89 | /** 90 | * May be used to get a Seat for the given id. 91 | */ 92 | SDQT_EXPORT Seat::Ptr getSeat(const QString &id); 93 | 94 | /** 95 | * May be used to get a Session for the given id. 96 | */ 97 | SDQT_EXPORT Session::Ptr getSession(const QString &id); 98 | 99 | /** 100 | * May be used to get a Session for the given process id. 101 | */ 102 | SDQT_EXPORT Session::Ptr getSessionByPID(const uint &pid); 103 | 104 | /** 105 | * May be used to get a User for the given user id. 106 | */ 107 | SDQT_EXPORT User::Ptr getUser(const uint &uid); 108 | 109 | /** 110 | * May be used to get a User for the given process id. 111 | */ 112 | SDQT_EXPORT User::Ptr getUserByPID(const uint &pid); 113 | 114 | /** 115 | * Results in the system being hibernated. 116 | */ 117 | SDQT_EXPORT void hibernate(const bool interactive); 118 | 119 | /** 120 | * Results in the system being hibernated + suspended. 121 | */ 122 | SDQT_EXPORT void hybridSleep(const bool interactive); 123 | 124 | /** 125 | * Returns an array with all currently available inhibitors. 126 | */ 127 | SDQT_EXPORT QList listInhibitors(); 128 | 129 | /** 130 | * Returns an array with all currently available seats. 131 | */ 132 | SDQT_EXPORT QList listSeats(); 133 | 134 | /** 135 | * Returns an array with all currently available sessions. 136 | */ 137 | SDQT_EXPORT QList listSessions(); 138 | 139 | /** 140 | * Returns an array with all currently available users. 141 | */ 142 | SDQT_EXPORT QList listUsers(); 143 | 144 | /** 145 | * Results in the system being powered off. 146 | */ 147 | SDQT_EXPORT void powerOff(const bool interactive); 148 | 149 | /** 150 | * Results in the system being rebooted. 151 | */ 152 | SDQT_EXPORT void reboot(const bool interactive); 153 | 154 | /** 155 | * Results in the system being suspended. 156 | */ 157 | SDQT_EXPORT void suspend(const bool interactive); 158 | 159 | SDQT_EXPORT Notifier* notifier(); 160 | } 161 | } 162 | 163 | #endif 164 | -------------------------------------------------------------------------------- /src/ldmanager_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #ifndef LD_MANAGER_P_H 21 | #define LD_MANAGER_P_H 22 | 23 | #include "ldmanagerinterface.h" 24 | 25 | #include "ldmanager.h" 26 | 27 | namespace Systemd 28 | { 29 | namespace Logind 30 | { 31 | class LogindPrivate : public Notifier 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | static const QString LD_DBUS_SERVICE; 37 | static const QString LD_DBUS_DAEMON_PATH; 38 | 39 | LogindPrivate(); 40 | ~LogindPrivate(); 41 | OrgFreedesktopLogin1ManagerInterface ildface; 42 | 43 | Seat::Ptr getSeat(const QString &id); 44 | Session::Ptr getSession(const QString &id); 45 | Session::Ptr getSessionByPID(const uint &pid); 46 | User::Ptr getUser(const uint &id); 47 | User::Ptr getUserByPID(const uint &pid); 48 | Permission canHibernate(); 49 | Permission canHybridSleep(); 50 | Permission canPowerOff(); 51 | Permission canReboot(); 52 | Permission canSuspend(); 53 | void hibernate(const bool interactive); 54 | void hybridSleep(const bool interactive); 55 | QList listInhibitors(); 56 | QList listSeats(); 57 | QList listSessions(); 58 | QList listUsers(); 59 | void powerOff(const bool interactive); 60 | void reboot(const bool interactive); 61 | void suspend(const bool interactive); 62 | 63 | protected Q_SLOTS: 64 | void onPrepareForShutdown(const bool active); 65 | void onPrepareForSleep(const bool active); 66 | void onSeatNew(const QString &id, const QDBusObjectPath &seat); 67 | void onSeatRemoved(const QString &id, const QDBusObjectPath &seat); 68 | void onSessionNew(const QString &id, const QDBusObjectPath &session); 69 | void onSessionRemoved(const QString &id, const QDBusObjectPath &session); 70 | void onUserNew(const uint &id, const QDBusObjectPath &user); 71 | void onUserRemoved(const uint &id, const QDBusObjectPath &user); 72 | 73 | private: 74 | Permission stringToPermission(const QString &permission) const; 75 | void init(); 76 | }; 77 | } 78 | } 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /src/sdmanager.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #include "sdmanager.h" 21 | #include "sdmanager_p.h" 22 | 23 | using namespace Systemd; 24 | 25 | const QString SystemdPrivate::SD_DBUS_SERVICE(QLatin1String("org.freedesktop.systemd1")); 26 | const QString SystemdPrivate::SD_DBUS_DAEMON_PATH(QLatin1String("/org/freedesktop/systemd1")); 27 | 28 | Q_GLOBAL_STATIC_WITH_ARGS(Systemd::SystemdPrivate, globalSystemdSystemBus, (QDBusConnection::systemBus())) 29 | Q_GLOBAL_STATIC_WITH_ARGS(Systemd::SystemdPrivate, globalSystemdSessionBus, (QDBusConnection::sessionBus())) 30 | 31 | static SystemdPrivate *globalSystemd(const SessionType &sessionType) 32 | { 33 | switch (sessionType) { 34 | case User: 35 | return globalSystemdSessionBus(); 36 | case System: 37 | default: 38 | return globalSystemdSystemBus(); 39 | } 40 | } 41 | 42 | SystemdPrivate::SystemdPrivate(const QDBusConnection &connection) : 43 | isdface(SystemdPrivate::SD_DBUS_SERVICE, SystemdPrivate::SD_DBUS_DAEMON_PATH, 44 | connection) 45 | { 46 | connect(&isdface, SIGNAL(JobNew(uint, QDBusObjectPath, QString)), this, 47 | SLOT(onJobNew(uint, QDBusObjectPath, QString))); 48 | connect(&isdface, SIGNAL(JobRemoved(uint, QDBusObjectPath, QString, QString)), this, 49 | SLOT(onJobRemoved(uint, QDBusObjectPath, QString, QString))); 50 | connect(&isdface, SIGNAL(Reloading(bool)), this, 51 | SLOT(onReloading(bool))); 52 | connect(&isdface, SIGNAL(UnitNew(QString, QDBusObjectPath)), this, 53 | SLOT(onUnitNew(QString, QDBusObjectPath))); 54 | connect(&isdface, SIGNAL(UnitRemoved(QString, QDBusObjectPath)), this, 55 | SLOT(onUnitRemoved(QString, QDBusObjectPath))); 56 | connect(&isdface, SIGNAL(UnitFilesChanged()), this, 57 | SLOT(onUnitFilesChanged())); 58 | 59 | init(); 60 | } 61 | 62 | SystemdPrivate::~SystemdPrivate() 63 | { 64 | } 65 | 66 | void SystemdPrivate::init() 67 | { 68 | qDBusRegisterMetaType(); 69 | qDBusRegisterMetaType(); 70 | } 71 | 72 | void SystemdPrivate::cancelJob(const uint id) 73 | { 74 | QDBusPendingReply reply = isdface.CancelJob(id); 75 | reply.waitForFinished(); 76 | 77 | if (reply.isError()) { 78 | qDebug() << reply.error().message(); 79 | } 80 | } 81 | 82 | void SystemdPrivate::clearJobs() 83 | { 84 | QDBusPendingReply reply = isdface.ClearJobs(); 85 | reply.waitForFinished(); 86 | 87 | if (reply.isError()) { 88 | qDebug() << reply.error().message(); 89 | } 90 | } 91 | 92 | void SystemdPrivate::disableUnitFiles(const QStringList &files, const bool runtime) 93 | { 94 | qDBusRegisterMetaType(); 95 | qDBusRegisterMetaType(); 96 | QDBusPendingReply reply = isdface.DisableUnitFiles(files, runtime); 97 | reply.waitForFinished(); 98 | 99 | if (reply.isError()) { 100 | qDebug() << reply.error().message(); 101 | } 102 | } 103 | 104 | void SystemdPrivate::enableUnitFiles(const QStringList &files, const bool runtime, const bool force) 105 | { 106 | qDBusRegisterMetaType(); 107 | qDBusRegisterMetaType(); 108 | QDBusPendingReply reply = isdface.EnableUnitFiles(files, runtime, force); 109 | reply.waitForFinished(); 110 | 111 | if (reply.isError()) { 112 | qDebug() << reply.error().message(); 113 | } 114 | } 115 | 116 | Job::Ptr SystemdPrivate::getJob(const uint id) 117 | { 118 | Job::Ptr job; 119 | 120 | QDBusPendingReply reply = isdface.GetJob(id); 121 | reply.waitForFinished(); 122 | 123 | if (reply.isError()) { 124 | qDebug() << reply.error().message(); 125 | } else if (! reply.reply().arguments().isEmpty()) { 126 | QString jobPath = qdbus_cast(reply.reply().arguments().first()).path(); 127 | job = Job::Ptr(new Job(jobPath, isdface.connection()), &QObject::deleteLater); 128 | } 129 | 130 | return job; 131 | } 132 | 133 | Unit::Ptr SystemdPrivate::getUnit(const QString &name) 134 | { 135 | Unit::Ptr unit; 136 | 137 | qDBusRegisterMetaType(); 138 | qDBusRegisterMetaType(); 139 | qDBusRegisterMetaType(); 140 | QDBusPendingReply reply = isdface.GetUnit(name); 141 | reply.waitForFinished(); 142 | 143 | if (reply.isError()) { 144 | qDebug() << reply.error().message(); 145 | } else if (! reply.reply().arguments().isEmpty()) { 146 | QString unitPath = qdbus_cast(reply.reply().arguments().first()).path(); 147 | unit = Unit::Ptr(new Unit(unitPath, isdface.connection()), &QObject::deleteLater); 148 | } 149 | 150 | return unit; 151 | } 152 | 153 | Unit::Ptr SystemdPrivate::getUnitByPID(const uint pid) 154 | { 155 | Unit::Ptr unit; 156 | 157 | QDBusPendingReply reply = isdface.GetUnitByPID(pid); 158 | reply.waitForFinished(); 159 | 160 | if (reply.isError()) { 161 | qDebug() << reply.error().message(); 162 | } else if (! reply.reply().arguments().isEmpty()) { 163 | QString unitPath = qdbus_cast(reply.reply().arguments().first()).path(); 164 | unit = Unit::Ptr(new Unit(unitPath, isdface.connection()), &QObject::deleteLater); 165 | } 166 | 167 | return unit; 168 | } 169 | 170 | QString SystemdPrivate::getUnitFileState(const QString &file) 171 | { 172 | QDBusPendingReply reply = isdface.GetUnitFileState(file); 173 | reply.waitForFinished(); 174 | 175 | if (reply.isError()) { 176 | qDebug() << reply.error().message(); 177 | } 178 | 179 | return qdbus_cast(reply.reply().arguments().first()); 180 | } 181 | 182 | void SystemdPrivate::killUnit(const QString& name, const Unit::Who &who, const int signal) 183 | { 184 | QDBusPendingReply reply = isdface.KillUnit(name, whoToString(who), signal); 185 | reply.waitForFinished(); 186 | 187 | if (reply.isError()) { 188 | qDebug() << reply.error().message(); 189 | } 190 | } 191 | 192 | QList SystemdPrivate::listJobs() 193 | { 194 | QList jobs; 195 | 196 | qDBusRegisterMetaType(); 197 | qDBusRegisterMetaType(); 198 | QDBusPendingReply reply = isdface.ListJobs(); 199 | reply.waitForFinished(); 200 | 201 | if (reply.isError()) { 202 | qDebug() << reply.error().message(); 203 | } else { 204 | const QDBusMessage message = reply.reply(); 205 | if (message.type() == QDBusMessage::ReplyMessage) { 206 | const ManagerDBusJobList queued = qdbus_cast(message.arguments().first()); 207 | Q_FOREACH (const ManagerDBusJob job, queued) { 208 | jobs.append(Job::Ptr(new Job(job.path.path(), isdface.connection()), &QObject::deleteLater)); 209 | } 210 | } 211 | } 212 | 213 | return jobs; 214 | } 215 | 216 | QList SystemdPrivate::listUnits() 217 | { 218 | QList units; 219 | 220 | qDBusRegisterMetaType(); 221 | qDBusRegisterMetaType(); 222 | QDBusPendingReply reply = isdface.ListUnits(); 223 | reply.waitForFinished(); 224 | 225 | if (reply.isError()) { 226 | qDebug() << reply.error().message(); 227 | } else { 228 | const QDBusMessage message = reply.reply(); 229 | if (message.type() == QDBusMessage::ReplyMessage) { 230 | const ManagerDBusUnitList loaded = qdbus_cast(message.arguments().first()); 231 | Q_FOREACH (const ManagerDBusUnit unit, loaded) { 232 | units.append(Unit::Ptr(new Unit(unit.path.path(), isdface.connection()), &QObject::deleteLater)); 233 | } 234 | } 235 | } 236 | 237 | return units; 238 | } 239 | 240 | QStringList SystemdPrivate::listUnitFiles() 241 | { 242 | QStringList unitFiles; 243 | 244 | qDBusRegisterMetaType(); 245 | qDBusRegisterMetaType(); 246 | QDBusPendingReply reply = isdface.ListUnitFiles(); 247 | reply.waitForFinished(); 248 | 249 | if (reply.isError()) { 250 | qDebug() << reply.error().message(); 251 | } else { 252 | const QDBusMessage message = reply.reply(); 253 | if (message.type() == QDBusMessage::ReplyMessage) { 254 | const ManagerDBusUnitFileList files = qdbus_cast(message.arguments().first()); 255 | Q_FOREACH (const ManagerDBusUnitFile file, files) { 256 | unitFiles.append(file.path); 257 | } 258 | } 259 | } 260 | 261 | return unitFiles; 262 | } 263 | 264 | Unit::Ptr SystemdPrivate::loadUnit(const QString &name) 265 | { 266 | Unit::Ptr unit; 267 | 268 | QDBusPendingReply reply = isdface.LoadUnit(name); 269 | reply.waitForFinished(); 270 | 271 | if (reply.isError()) { 272 | qDebug() << reply.error().message(); 273 | } else if (! reply.reply().arguments().isEmpty()) { 274 | QString unitPath = qdbus_cast(reply.reply().arguments().first()).path(); 275 | unit = Unit::Ptr(new Unit(unitPath, isdface.connection()), &QObject::deleteLater); 276 | } 277 | 278 | return unit; 279 | } 280 | 281 | void SystemdPrivate::onJobNew(const uint id, const QDBusObjectPath &job, const QString &unit) 282 | { 283 | emit Notifier::jobNew(job.path(), unit); 284 | } 285 | 286 | void SystemdPrivate::onJobRemoved(const uint id, const QDBusObjectPath &job, const QString &unit, const QString &result) 287 | { 288 | emit Notifier::jobRemoved(job.path(), unit, stringToResult(result)); 289 | } 290 | 291 | void SystemdPrivate::onReloading(const bool active) 292 | { 293 | emit Notifier::reloading(active); 294 | } 295 | 296 | void SystemdPrivate::onUnitNew(const QString &id, const QDBusObjectPath &unit) 297 | { 298 | emit Notifier::unitNew(unit.path()); 299 | } 300 | 301 | void SystemdPrivate::onUnitRemoved(const QString &id, const QDBusObjectPath &unit) 302 | { 303 | emit Notifier::unitRemoved(unit.path()); 304 | } 305 | 306 | void SystemdPrivate::onUnitFilesChanged() 307 | { 308 | emit Notifier::unitFilesChanged(); 309 | } 310 | 311 | void SystemdPrivate::reexecute() 312 | { 313 | QDBusPendingReply reply = isdface.Reexecute(); 314 | reply.waitForFinished(); 315 | 316 | if (reply.isError()) { 317 | qDebug() << reply.error().message(); 318 | } 319 | } 320 | 321 | void SystemdPrivate::reload() 322 | { 323 | QDBusPendingReply reply = isdface.Reload(); 324 | reply.waitForFinished(); 325 | 326 | if (reply.isError()) { 327 | qDebug() << reply.error().message(); 328 | } 329 | } 330 | 331 | Job::Ptr SystemdPrivate::reloadUnit(const QString &name, const Unit::Mode &mode) 332 | { 333 | Job::Ptr job; 334 | 335 | QDBusPendingReply reply = isdface.ReloadUnit(name, modeToString(mode)); 336 | reply.waitForFinished(); 337 | 338 | if (reply.isError()) { 339 | qDebug() << reply.error().message(); 340 | } else if (! reply.reply().arguments().isEmpty()) { 341 | QString jobPath = qdbus_cast(reply.reply().arguments().first()).path(); 342 | job = Job::Ptr(new Job(jobPath, isdface.connection()), &QObject::deleteLater); 343 | } 344 | 345 | return job; 346 | } 347 | 348 | Job::Ptr SystemdPrivate::restartUnit(const QString &name, const Unit::Mode &mode) 349 | { 350 | Job::Ptr job; 351 | 352 | QDBusPendingReply reply = isdface.RestartUnit(name, modeToString(mode)); 353 | reply.waitForFinished(); 354 | 355 | if (reply.isError()) { 356 | qDebug() << reply.error().message(); 357 | } else if (! reply.reply().arguments().isEmpty()) { 358 | QString jobPath = qdbus_cast(reply.reply().arguments().first()).path(); 359 | job = Job::Ptr(new Job(jobPath, isdface.connection()), &QObject::deleteLater); 360 | } 361 | 362 | return job; 363 | } 364 | 365 | void SystemdPrivate::setUnitProperties(const QString &name, const bool runtime, const QVariantMap &properties) 366 | { 367 | QDBusPendingReply reply = isdface.SetUnitProperties(name, runtime, properties); 368 | reply.waitForFinished(); 369 | 370 | if (reply.isError()) { 371 | qDebug() << reply.error().message(); 372 | } 373 | } 374 | 375 | Job::Ptr SystemdPrivate::startTransientUnit(const QString &name, const Unit::Mode &mode, const QVariantMap &properties) 376 | { 377 | Job::Ptr job; 378 | 379 | QDBusPendingReply reply = isdface.StartTransientUnit(name, modeToString(mode), properties, ManagerDBusAuxList()); 380 | reply.waitForFinished(); 381 | 382 | if (reply.isError()) { 383 | qDebug() << reply.error().message(); 384 | } else if (! reply.reply().arguments().isEmpty()) { 385 | QString jobPath = qdbus_cast(reply.reply().arguments().first()).path(); 386 | job = Job::Ptr(new Job(jobPath, isdface.connection()), &QObject::deleteLater); 387 | } 388 | 389 | return job; 390 | } 391 | 392 | Job::Ptr SystemdPrivate::startUnit(const QString &name, const Unit::Mode &mode) 393 | { 394 | Job::Ptr job; 395 | 396 | QDBusPendingReply reply = isdface.StartUnit(name, modeToString(mode)); 397 | reply.waitForFinished(); 398 | 399 | if (reply.isError()) { 400 | qDebug() << reply.error().message(); 401 | } else if (! reply.reply().arguments().isEmpty()) { 402 | QString jobPath = qdbus_cast(reply.reply().arguments().first()).path(); 403 | job = Job::Ptr(new Job(jobPath, isdface.connection()), &QObject::deleteLater); 404 | } 405 | 406 | return job; 407 | } 408 | 409 | Job::Ptr SystemdPrivate::stopUnit(const QString &name, const Unit::Mode &mode) 410 | { 411 | Job::Ptr job; 412 | 413 | QDBusPendingReply reply = isdface.StopUnit(name, modeToString(mode)); 414 | reply.waitForFinished(); 415 | 416 | if (reply.isError()) { 417 | qDebug() << reply.error().message(); 418 | } else if (! reply.reply().arguments().isEmpty()) { 419 | QString jobPath = qdbus_cast(reply.reply().arguments().first()).path(); 420 | job = Job::Ptr(new Job(jobPath, isdface.connection()), &QObject::deleteLater); 421 | } 422 | 423 | return job; 424 | } 425 | 426 | void SystemdPrivate::resetFailed() 427 | { 428 | QDBusPendingReply reply = isdface.ResetFailed(); 429 | reply.waitForFinished(); 430 | 431 | if (reply.isError()) { 432 | qDebug() << reply.error().message(); 433 | } 434 | } 435 | 436 | void SystemdPrivate::resetFailedUnit(const QString& name) 437 | { 438 | QDBusPendingReply reply = isdface.ResetFailedUnit(name); 439 | reply.waitForFinished(); 440 | 441 | if (reply.isError()) { 442 | qDebug() << reply.error().message(); 443 | } 444 | } 445 | 446 | QString SystemdPrivate::modeToString(const Unit::Mode &mode) const 447 | { 448 | switch (mode) { 449 | case Unit::Fail: return QLatin1Literal("fail"); 450 | case Unit::IgnoreDependencies: return QLatin1Literal("ignore-dependencies"); 451 | case Unit::IgnoreRequirements: return QLatin1Literal("ignore-requirements"); 452 | case Unit::Isolate: return QLatin1Literal("isolate"); 453 | case Unit::Replace: return QLatin1Literal("replace"); 454 | default: return QString(); 455 | } 456 | } 457 | 458 | QString SystemdPrivate::whoToString(const Unit::Who &who) const 459 | { 460 | switch (who) { 461 | case Unit::All: return QLatin1Literal("all"); 462 | case Unit::Control: return QLatin1Literal("control"); 463 | case Unit::Main: return QLatin1Literal("main"); 464 | default: return QString(); 465 | } 466 | } 467 | 468 | Unit::Result SystemdPrivate::stringToResult(const QString &result) const 469 | { 470 | if (QString::compare(result, QLatin1Literal("canceled")) == 0) { 471 | return Unit::Canceled; 472 | } else if (QString::compare(result, QLatin1Literal("dependency")) == 0) { 473 | return Unit::Dependency; 474 | } else if (QString::compare(result, QLatin1Literal("failed")) == 0) { 475 | return Unit::Failed; 476 | } else if (QString::compare(result, QLatin1Literal("skipped")) == 0) { 477 | return Unit::Skipped; 478 | } else if (QString::compare(result, QLatin1Literal("timeout")) == 0) { 479 | return Unit::Timeout; 480 | } else { // "done" 481 | return Unit::Done; 482 | } 483 | } 484 | 485 | void Systemd::cancelJob(const SessionType &session, const uint id) 486 | { 487 | globalSystemd(session)->cancelJob(id); 488 | } 489 | 490 | void Systemd::clearJobs(const SessionType &session) 491 | { 492 | globalSystemd(session)->clearJobs(); 493 | } 494 | 495 | void Systemd::disableUnitFiles(const SessionType &session, const QStringList &files, const bool runtime) 496 | { 497 | globalSystemd(session)->disableUnitFiles(files, runtime); 498 | } 499 | 500 | void Systemd::enableUnitFiles(const SessionType &session, const QStringList &files, const bool runtime, const bool force) 501 | { 502 | globalSystemd(session)->enableUnitFiles(files, runtime, force); 503 | } 504 | 505 | Job::Ptr Systemd::getJob(const SessionType &session, const uint id) 506 | { 507 | return globalSystemd(session)->getJob(id); 508 | } 509 | 510 | Unit::Ptr Systemd::getUnit(const SessionType &session, const QString &name) 511 | { 512 | return globalSystemd(session)->getUnit(name); 513 | } 514 | 515 | Unit::Ptr Systemd::getUnitByPID(const SessionType &session, const uint pid) 516 | { 517 | return globalSystemd(session)->getUnitByPID(pid); 518 | } 519 | 520 | QString Systemd::getUnitFileState(const SessionType &session, const QString &file) 521 | { 522 | return globalSystemd(session)->getUnitFileState(file); 523 | } 524 | 525 | void Systemd::killUnit(const SessionType &session, const QString &name, const Unit::Who &who, const int signal) 526 | { 527 | return globalSystemd(session)->killUnit(name, who, signal); 528 | } 529 | 530 | QList Systemd::listJobs(const SessionType &session) 531 | { 532 | return globalSystemd(session)->listJobs(); 533 | } 534 | 535 | QList Systemd::listUnits(const SessionType &session) 536 | { 537 | return globalSystemd(session)->listUnits(); 538 | } 539 | 540 | QStringList Systemd::listUnitFiles(const SessionType &session) 541 | { 542 | return globalSystemd(session)->listUnitFiles(); 543 | } 544 | 545 | Unit::Ptr Systemd::loadUnit(const SessionType &session, const QString &name) 546 | { 547 | return globalSystemd(session)->loadUnit(name); 548 | } 549 | 550 | void Systemd::reexecute(const SessionType &session) 551 | { 552 | return globalSystemd(session)->reexecute(); 553 | } 554 | 555 | void Systemd::reload(const SessionType &session) 556 | { 557 | return globalSystemd(session)->reload(); 558 | } 559 | 560 | Job::Ptr Systemd::reloadUnit(const SessionType &session, const QString &name, const Unit::Mode &mode) 561 | { 562 | return globalSystemd(session)->reloadUnit(name, mode); 563 | } 564 | 565 | Job::Ptr Systemd::restartUnit(const SessionType &session, const QString &name, const Unit::Mode &mode) 566 | { 567 | return globalSystemd(session)->restartUnit(name, mode); 568 | } 569 | 570 | void Systemd::setUnitProperties(const SessionType &session, const QString &name, const bool runtime, const QVariantMap &properties) 571 | { 572 | globalSystemd(session)->setUnitProperties(name, runtime, properties); 573 | } 574 | 575 | Job::Ptr Systemd::startTransientUnit(const SessionType &session, const QString &name, const Unit::Mode &mode, const QVariantMap &properties) 576 | { 577 | return globalSystemd(session)->startTransientUnit(name, mode, properties); 578 | } 579 | 580 | Job::Ptr Systemd::startUnit(const SessionType &session, const QString &name, const Unit::Mode &mode) 581 | { 582 | return globalSystemd(session)->startUnit(name, mode); 583 | } 584 | 585 | Job::Ptr Systemd::stopUnit(const SessionType &session, const QString &name, const Unit::Mode &mode) 586 | { 587 | return globalSystemd(session)->stopUnit(name, mode); 588 | } 589 | 590 | void Systemd::resetFailed(const SessionType &session) 591 | { 592 | return globalSystemd(session)->resetFailed(); 593 | } 594 | 595 | void Systemd::resetFailedUnit(const SessionType &session, const QString &name) 596 | { 597 | return globalSystemd(session)->resetFailedUnit(name); 598 | } 599 | 600 | Notifier* Systemd::notifier(const SessionType &session) 601 | { 602 | return globalSystemd(session); 603 | } 604 | -------------------------------------------------------------------------------- /src/sdmanager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #ifndef SD_MANAGER_H 21 | #define SD_MANAGER_H 22 | 23 | #include 24 | 25 | #include "QtSystemd-export.h" 26 | 27 | #include "job.h" 28 | #include "unit.h" 29 | 30 | /** 31 | * This class allows querying the underlying system. 32 | * 33 | * It is the unique entry point for systemd. 34 | * 35 | * Note that it is implemented as a singleton. 36 | */ 37 | namespace Systemd 38 | { 39 | enum SessionType { 40 | System, 41 | User 42 | }; 43 | 44 | class SDQT_EXPORT Notifier : public QObject 45 | { 46 | Q_OBJECT 47 | 48 | Q_SIGNALS: 49 | /* 50 | * Sent out each time a new job is queued. 51 | */ 52 | void jobNew(const QString &jobPath, const QString &unit); 53 | 54 | /* 55 | * Sent out each time a new job is dequeued. 56 | */ 57 | void jobRemoved(const QString &jobPath, const QString &unit, const Unit::Result result); 58 | 59 | /* 60 | * Is sent out immediately before a daemon reload is done (with the 61 | * boolean parameter set to True) and after a daemon reload is completed 62 | * (with the boolean parameter set to False). 63 | */ 64 | void reloading(const bool active); 65 | 66 | /* 67 | * Sent out each time a new unit is loaded. 68 | */ 69 | void unitNew(const QString &unitPath); 70 | 71 | /* 72 | * Sent out each time a new unit is unloaded. 73 | */ 74 | void unitRemoved(const QString &unitPath); 75 | 76 | /* 77 | * Sent out each time the list of enabled or masked unit files on disk 78 | * have changed. 79 | */ 80 | void unitFilesChanged(); 81 | }; 82 | 83 | // See http://www.freedesktop.org/wiki/Software/systemd/dbus for more info. 84 | 85 | /* 86 | * Cancels a specific job identified by its numer ID. This operation is also 87 | * available in the Cancel() method of Job objects (see below), and exists 88 | * primarily to reduce the necessary round trips to execute this operation. 89 | * Note that this will not have any effect on jobs whose execution has 90 | * already begun. 91 | */ 92 | SDQT_EXPORT void cancelJob(const SessionType &session, const uint id); 93 | 94 | /* 95 | * Flushes the job queue, removing all jobs that are still queued. Note that 96 | * this does not have any effect on jobs whose execution has already begun, 97 | * it only flushes jobs that are queued and have not yet begun execution. 98 | */ 99 | SDQT_EXPORT void clearJobs(const SessionType &session); 100 | 101 | /* 102 | * Disables one or more units in the system, i.e. removes all symlinks to 103 | * them in /etc and /run. 104 | */ 105 | SDQT_EXPORT void disableUnitFiles(const SessionType &session, const QStringList &files, const bool runtime); 106 | 107 | /* 108 | * May be used to enable one or more units in the system (by creating 109 | * symlinks to them in /etc or /run). 110 | */ 111 | SDQT_EXPORT void enableUnitFiles(const SessionType &session, const QStringList &files, const bool runtime, const bool force); 112 | 113 | /* 114 | * Returns the job object path for a specific job, identified by its id. 115 | */ 116 | SDQT_EXPORT Job::Ptr getJob(const SessionType &session, const uint id); 117 | 118 | /* 119 | * May be used to get the unit object path for a unit name. It takes the 120 | * unit name and returns the object path. If a unit has not been loaded 121 | * yet by this name this call will fail. 122 | */ 123 | SDQT_EXPORT Unit::Ptr getUnit(const SessionType &session, const QString &name); 124 | 125 | /* 126 | * May be used to get the unit object path of the unit a process ID 127 | * belongs to. Takes a Unix PID and returns the object path. The PID must 128 | * refer to an existing process of the system. 129 | */ 130 | SDQT_EXPORT Unit::Ptr getUnitByPID(const SessionType &session, const uint pid); 131 | 132 | /* 133 | * Returns the current enablement status of specific unit file. 134 | */ 135 | SDQT_EXPORT QString getUnitFileState(const SessionType &session, const QString &file); 136 | 137 | /* 138 | * May be used to kill (i.e. send a signal to) all processes of a unit. 139 | */ 140 | SDQT_EXPORT void killUnit(const SessionType &session, const QString &name, const Unit::Who &who, const int signal); 141 | 142 | /* 143 | * Returns an array with all currently queued jobs. 144 | */ 145 | SDQT_EXPORT QList listJobs(const SessionType &session); 146 | 147 | /* 148 | * Returns an array with all currently loaded units. Note that units may 149 | * be known by multiple names at the same name, and hence there might be 150 | * more unit names loaded than actual units behind them. 151 | */ 152 | SDQT_EXPORT QList listUnits(const SessionType &session); 153 | 154 | /* 155 | * Returns an array of unit names. Note that listUnit() returns a list of 156 | * units currently loaded into memory, while listUnitFiles() returns a 157 | * list of unit files that could be found on disk. 158 | */ 159 | SDQT_EXPORT QStringList listUnitFiles(const SessionType &session); 160 | 161 | /* 162 | * Is similar to getUnit() but will load the unit from disk if possible. 163 | */ 164 | SDQT_EXPORT Unit::Ptr loadUnit(const SessionType &session, const QString &name); 165 | 166 | /* 167 | * May be invoked to reexecute the main manager process. It will serialize 168 | * its state, reexecute, and deserizalize the state again. This is useful 169 | * for upgrades and is a more comprehensive version of Reload(). 170 | */ 171 | SDQT_EXPORT void reexecute(const SessionType &session); 172 | 173 | /* 174 | * May be invoked to reload all unit files. 175 | */ 176 | SDQT_EXPORT void reload(const SessionType &session); 177 | 178 | /* 179 | * May be used to reload a unit, and takes similar arguments as 180 | * startUnit(). Reloading is done only if the unit is already running and 181 | * fails otherwise. 182 | */ 183 | SDQT_EXPORT Job::Ptr reloadUnit(const SessionType &session, const QString &name, const Unit::Mode &mode); 184 | 185 | /* 186 | * Resets the "failed" state of all units. 187 | */ 188 | SDQT_EXPORT void resetFailed(const SessionType &session); 189 | 190 | /* 191 | * Resets the "failed" state of a specific unit. 192 | */ 193 | SDQT_EXPORT void resetFailedUnit(const SessionType &session, const QString &name); 194 | 195 | /* 196 | * Is similar to reloadUnit() but will restart the unit. If a service is 197 | * restarted that isn't running it will be started, unless the "Try" 198 | * flavor is used in which case a service that isn't running is not 199 | * affected by the restart. 200 | */ 201 | SDQT_EXPORT Job::Ptr restartUnit(const SessionType &session, const QString &name, const Unit::Mode &mode); 202 | 203 | /* 204 | * May be used to modify certain unit properties at runtime. Not all 205 | * properties may be changed at runtime, but many resource management 206 | * settings may. 207 | */ 208 | SDQT_EXPORT void setUnitProperties(const SessionType &session, const QString &name, const bool runtime, const QVariantMap &properties); 209 | 210 | /* 211 | * May be used to create and start a transient unit, which will be released 212 | * as soon as it is not running or referenced anymore or the system is 213 | * rebooted. 214 | */ 215 | SDQT_EXPORT Job::Ptr startTransientUnit(const SessionType &session, const QString &name, const Unit::Mode &mode, const QVariantMap &properties); 216 | 217 | /* 218 | * Enqeues a start job, and possibly depending jobs. Takes the unit to 219 | * activate, plus a mode string. 220 | */ 221 | SDQT_EXPORT Job::Ptr startUnit(const SessionType &session, const QString &name, const Unit::Mode &mode); 222 | 223 | /* 224 | * Is similar to startUnit() but stops the specified unit rather than 225 | * starting it. Note that "isolate" mode is invalid for this call. 226 | */ 227 | SDQT_EXPORT Job::Ptr stopUnit(const SessionType &session, const QString &name, const Unit::Mode &mode); 228 | 229 | SDQT_EXPORT Notifier* notifier(const SessionType &session); 230 | } 231 | 232 | #endif 233 | -------------------------------------------------------------------------------- /src/sdmanager_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #ifndef SD_MANAGER_P_H 21 | #define SD_MANAGER_P_H 22 | 23 | #include "managerinterface.h" 24 | 25 | #include "sdmanager.h" 26 | 27 | namespace Systemd 28 | { 29 | 30 | class SystemdPrivate : public Notifier 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | static const QString SD_DBUS_SERVICE; 36 | static const QString SD_DBUS_DAEMON_PATH; 37 | 38 | SystemdPrivate(const QDBusConnection &connection); 39 | ~SystemdPrivate(); 40 | OrgFreedesktopSystemd1ManagerInterface isdface; 41 | 42 | void cancelJob(const uint id); 43 | void clearJobs(); 44 | void disableUnitFiles(const QStringList &files, const bool runtime); 45 | void enableUnitFiles(const QStringList &files, const bool runtime, const bool force); 46 | Job::Ptr getJob(const uint id); 47 | Unit::Ptr getUnit(const QString &name); 48 | Unit::Ptr getUnitByPID(const uint pid); 49 | QString getUnitFileState(const QString &file); 50 | void killUnit(const QString &name, const Unit::Who &who, const int signal); 51 | QList listJobs(); 52 | QList listUnits(); 53 | QStringList listUnitFiles(); 54 | Unit::Ptr loadUnit(const QString &name); 55 | void reexecute(); 56 | void reload(); 57 | Job::Ptr reloadUnit(const QString &name, const Unit::Mode &mode); 58 | void resetFailed(); 59 | void resetFailedUnit(const QString &name); 60 | Job::Ptr restartUnit(const QString &name, const Unit::Mode &mode); 61 | void setUnitProperties(const QString &name, const bool runtime, const QVariantMap &properties); 62 | Job::Ptr startTransientUnit(const QString &name, const Unit::Mode &mode, const QVariantMap &properties); 63 | Job::Ptr startUnit(const QString &name, const Unit::Mode &mode); 64 | Job::Ptr stopUnit(const QString &name, const Unit::Mode &mode); 65 | 66 | protected Q_SLOTS: 67 | void onJobNew(const uint id, const QDBusObjectPath &job, const QString &unit); 68 | void onJobRemoved(const uint id, const QDBusObjectPath &job, const QString &unit, const QString &result); 69 | void onReloading(const bool active); 70 | void onUnitNew(const QString &id, const QDBusObjectPath &unit); 71 | void onUnitRemoved(const QString &id, const QDBusObjectPath &unit); 72 | void onUnitFilesChanged(); 73 | 74 | private: 75 | QString modeToString(const Unit::Mode &mode) const; 76 | QString whoToString(const Unit::Who &mode) const; 77 | Unit::Result stringToResult(const QString &result) const; 78 | void init(); 79 | }; 80 | } 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /src/seat.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #include "seat_p.h" 21 | #include "ldmanager_p.h" 22 | 23 | Systemd::Logind::SeatPrivate::SeatPrivate(const QString &path) : 24 | seatIface(Systemd::Logind::LogindPrivate::LD_DBUS_SERVICE, path, QDBusConnection::systemBus()) 25 | { 26 | qDBusRegisterMetaType(); 27 | qDBusRegisterMetaType(); 28 | 29 | activeSession = seatIface.activeSession(); 30 | canGraphical = seatIface.canGraphical(); 31 | canMultiSession = seatIface.canMultiSession(); 32 | canTTY = seatIface.canTTY(); 33 | id = seatIface.id(); 34 | Q_FOREACH (const DBusSession &session, seatIface.sessions()) { 35 | sessions << session.id; 36 | } 37 | } 38 | 39 | Systemd::Logind::SeatPrivate::~SeatPrivate() 40 | { 41 | } 42 | 43 | Systemd::Logind::Seat::Seat(const QString &path, QObject *parent) : 44 | QObject(parent), d_ptr(new SeatPrivate(path)) 45 | { 46 | } 47 | 48 | Systemd::Logind::Seat::Seat(SeatPrivate &seat, QObject *parent) : 49 | QObject(parent), d_ptr(&seat) 50 | { 51 | } 52 | 53 | Systemd::Logind::Seat::~Seat() 54 | { 55 | delete d_ptr; 56 | } 57 | 58 | QString Systemd::Logind::Seat::activeSession() const 59 | { 60 | Q_D(const Seat); 61 | return d->activeSession.id; 62 | } 63 | 64 | bool Systemd::Logind::Seat::canGraphical() const 65 | { 66 | Q_D(const Seat); 67 | return d->canGraphical; 68 | } 69 | 70 | bool Systemd::Logind::Seat::canMultiSession() const 71 | { 72 | Q_D(const Seat); 73 | return d->canMultiSession; 74 | } 75 | 76 | bool Systemd::Logind::Seat::canTTY() const 77 | { 78 | Q_D(const Seat); 79 | return d->canTTY; 80 | } 81 | 82 | QString Systemd::Logind::Seat::id() const 83 | { 84 | Q_D(const Seat); 85 | return d->id; 86 | } 87 | 88 | QStringList Systemd::Logind::Seat::sessions() const 89 | { 90 | Q_D(const Seat); 91 | return d->sessions; 92 | } 93 | -------------------------------------------------------------------------------- /src/seat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #ifndef SD_SEAT_H 21 | #define SD_SEAT_H 22 | 23 | #include 24 | #include 25 | 26 | #include "QtSystemd-export.h" 27 | 28 | namespace Systemd 29 | { 30 | namespace Logind 31 | { 32 | class SeatPrivate; 33 | 34 | class SDQT_EXPORT Seat : public QObject 35 | { 36 | Q_OBJECT 37 | Q_DECLARE_PRIVATE(Seat) 38 | 39 | public: 40 | typedef QSharedPointer Ptr; 41 | 42 | explicit Seat(const QString &path, QObject *parent = 0); 43 | explicit Seat(SeatPrivate &seat, QObject *parent = 0); 44 | virtual ~Seat(); 45 | 46 | QString activeSession() const; 47 | bool canGraphical() const; 48 | bool canMultiSession() const; 49 | bool canTTY() const; 50 | QString id() const; 51 | QStringList sessions() const; 52 | 53 | protected: 54 | SeatPrivate *d_ptr; 55 | }; 56 | } 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/seat_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #ifndef SD_SEAT_P_H 21 | #define SD_SEAT_P_H 22 | 23 | #include "seatinterface.h" 24 | 25 | #include "seat.h" 26 | 27 | namespace Systemd 28 | { 29 | namespace Logind 30 | { 31 | class SeatPrivate 32 | { 33 | 34 | public: 35 | explicit SeatPrivate(const QString &path); 36 | virtual ~SeatPrivate(); 37 | 38 | OrgFreedesktopLogin1SeatInterface seatIface; 39 | 40 | DBusSession activeSession; 41 | bool canGraphical; 42 | bool canMultiSession; 43 | bool canTTY; 44 | QString id; 45 | QStringList sessions; 46 | }; 47 | } 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/session.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #include "session_p.h" 21 | #include "ldmanager_p.h" 22 | 23 | Systemd::Logind::SessionPrivate::SessionPrivate(const QString &path) : 24 | sessionIface(Systemd::Logind::LogindPrivate::LD_DBUS_SERVICE, path, QDBusConnection::systemBus()) 25 | { 26 | active = sessionIface.active(); 27 | audit = sessionIface.audit(); 28 | desktop = sessionIface.desktop(); 29 | display = sessionIface.display(); 30 | id = sessionIface.id(); 31 | idleHint = sessionIface.idleHint(); 32 | idleSinceHint = sessionIface.idleSinceHint(); 33 | idleSinceHintMonotonic = sessionIface.idleSinceHintMonotonic(); 34 | leader = sessionIface.leader(); 35 | name = sessionIface.name(); 36 | remote = sessionIface.remote(); 37 | remoteHost = sessionIface.remoteHost(); 38 | remoteUser = sessionIface.remoteUser(); 39 | scope = sessionIface.scope(); 40 | seat = sessionIface.seat().id; 41 | service = sessionIface.service(); 42 | state = sessionIface.state(); 43 | tty = sessionIface.tTY(); 44 | timestamp = sessionIface.timestamp(); 45 | timestampMonotonic = sessionIface.timestampMonotonic(); 46 | type = sessionIface.type(); 47 | user = sessionIface.user().id; 48 | vtNr = sessionIface.vTNr(); 49 | _class = sessionIface._Class(); 50 | } 51 | 52 | Systemd::Logind::SessionPrivate::~SessionPrivate() 53 | { 54 | } 55 | 56 | Systemd::Logind::Session::Session(const QString &path, QObject *parent) : 57 | QObject(parent), d_ptr(new SessionPrivate(path)) 58 | { 59 | } 60 | 61 | Systemd::Logind::Session::Session(SessionPrivate &session, QObject *parent) : 62 | QObject(parent), d_ptr(&session) 63 | { 64 | } 65 | 66 | Systemd::Logind::Session::~Session() 67 | { 68 | delete d_ptr; 69 | } 70 | 71 | bool Systemd::Logind::Session::active() const 72 | { 73 | Q_D(const Session); 74 | return d->active; 75 | } 76 | 77 | uint Systemd::Logind::Session::audit() const 78 | { 79 | Q_D(const Session); 80 | return d->audit; 81 | } 82 | 83 | QString Systemd::Logind::Session::desktop() const 84 | { 85 | Q_D(const Session); 86 | return d->desktop; 87 | } 88 | 89 | QString Systemd::Logind::Session::display() const 90 | { 91 | Q_D(const Session); 92 | return d->display; 93 | } 94 | 95 | QString Systemd::Logind::Session::id() const 96 | { 97 | Q_D(const Session); 98 | return d->id; 99 | } 100 | 101 | bool Systemd::Logind::Session::idleHint() const 102 | { 103 | Q_D(const Session); 104 | return d->idleHint; 105 | } 106 | 107 | qulonglong Systemd::Logind::Session::idleSinceHint() const 108 | { 109 | Q_D(const Session); 110 | return d->idleSinceHint; 111 | } 112 | 113 | qulonglong Systemd::Logind::Session::idleSinceHintMonotonic() const 114 | { 115 | Q_D(const Session); 116 | return d->idleSinceHintMonotonic; 117 | } 118 | 119 | uint Systemd::Logind::Session::leader() const 120 | { 121 | Q_D(const Session); 122 | return d->leader; 123 | } 124 | 125 | QString Systemd::Logind::Session::name() const 126 | { 127 | Q_D(const Session); 128 | return d->name; 129 | } 130 | 131 | bool Systemd::Logind::Session::remote() const 132 | { 133 | Q_D(const Session); 134 | return d->remote; 135 | } 136 | 137 | QString Systemd::Logind::Session::remoteHost() const 138 | { 139 | Q_D(const Session); 140 | return d->remoteHost; 141 | } 142 | 143 | QString Systemd::Logind::Session::remoteUser() const 144 | { 145 | Q_D(const Session); 146 | return d->remoteUser; 147 | } 148 | 149 | QString Systemd::Logind::Session::seat() const 150 | { 151 | Q_D(const Session); 152 | return d->seat; 153 | } 154 | 155 | QString Systemd::Logind::Session::scope() const 156 | { 157 | Q_D(const Session); 158 | return d->scope; 159 | } 160 | 161 | QString Systemd::Logind::Session::service() const 162 | { 163 | Q_D(const Session); 164 | return d->service; 165 | } 166 | 167 | QString Systemd::Logind::Session::state() const 168 | { 169 | Q_D(const Session); 170 | return d->state; 171 | } 172 | 173 | QString Systemd::Logind::Session::tty() const 174 | { 175 | Q_D(const Session); 176 | return d->tty; 177 | } 178 | 179 | qulonglong Systemd::Logind::Session::timestamp() const 180 | { 181 | Q_D(const Session); 182 | return d->timestamp; 183 | } 184 | 185 | qulonglong Systemd::Logind::Session::timestampMonotonic() const 186 | { 187 | Q_D(const Session); 188 | return d->timestampMonotonic; 189 | } 190 | 191 | QString Systemd::Logind::Session::type() const 192 | { 193 | Q_D(const Session); 194 | return d->type; 195 | } 196 | 197 | uint Systemd::Logind::Session::user() const 198 | { 199 | Q_D(const Session); 200 | return d->user; 201 | } 202 | 203 | uint Systemd::Logind::Session::vtNr() const 204 | { 205 | Q_D(const Session); 206 | return d->vtNr; 207 | } 208 | 209 | QString Systemd::Logind::Session::_class() const 210 | { 211 | Q_D(const Session); 212 | return d->_class; 213 | } 214 | -------------------------------------------------------------------------------- /src/session.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #ifndef SD_SESSION_H 21 | #define SD_SESSION_H 22 | 23 | #include 24 | #include 25 | 26 | #include "QtSystemd-export.h" 27 | 28 | namespace Systemd 29 | { 30 | namespace Logind 31 | { 32 | class SessionPrivate; 33 | 34 | class SDQT_EXPORT Session : public QObject 35 | { 36 | Q_OBJECT 37 | Q_DECLARE_PRIVATE(Session) 38 | 39 | public: 40 | typedef QSharedPointer Ptr; 41 | 42 | explicit Session(const QString &path, QObject *parent = 0); 43 | explicit Session(SessionPrivate &session, QObject *parent = 0); 44 | virtual ~Session(); 45 | 46 | bool active() const; 47 | uint audit() const; 48 | QString desktop() const; 49 | QString display() const; 50 | QString id() const; 51 | bool idleHint() const; 52 | qulonglong idleSinceHint() const; 53 | qulonglong idleSinceHintMonotonic() const; 54 | uint leader() const; 55 | QString name() const; 56 | bool remote() const; 57 | QString remoteHost() const; 58 | QString remoteUser() const; 59 | QString seat() const; 60 | QString scope() const; 61 | QString service() const; 62 | QString state() const; 63 | QString tty() const; 64 | qulonglong timestamp() const; 65 | qulonglong timestampMonotonic() const; 66 | QString type() const; 67 | uint user() const; 68 | uint vtNr() const; 69 | QString _class() const; 70 | 71 | protected: 72 | SessionPrivate *d_ptr; 73 | }; 74 | } 75 | } 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /src/session_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #ifndef SD_SESSION_P_H 21 | #define SD_SESSION_P_H 22 | 23 | #include "sessioninterface.h" 24 | 25 | #include "session.h" 26 | 27 | namespace Systemd 28 | { 29 | namespace Logind 30 | { 31 | class SessionPrivate 32 | { 33 | 34 | public: 35 | explicit SessionPrivate(const QString &path); 36 | virtual ~SessionPrivate(); 37 | 38 | OrgFreedesktopLogin1SessionInterface sessionIface; 39 | 40 | bool active; 41 | uint audit; 42 | QString desktop; 43 | QString display; 44 | QString id; 45 | bool idleHint; 46 | qulonglong idleSinceHint; 47 | qulonglong idleSinceHintMonotonic; 48 | uint leader; 49 | QString name; 50 | bool remote; 51 | QString remoteHost; 52 | QString remoteUser; 53 | QString seat; 54 | QString scope; 55 | QString service; 56 | QString state; 57 | QString tty; 58 | qulonglong timestamp; 59 | qulonglong timestampMonotonic; 60 | QString type; 61 | uint user; 62 | uint vtNr; 63 | QString _class; 64 | }; 65 | } 66 | } 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/unit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #include "unit_p.h" 21 | #include "sdmanager_p.h" 22 | 23 | Systemd::UnitPrivate::UnitPrivate(const QString &path, const QDBusConnection &connection) : 24 | unitIface(Systemd::SystemdPrivate::SD_DBUS_SERVICE, path, connection) 25 | { 26 | activeEnterTimestamp = unitIface.activeEnterTimestamp(); 27 | activeEnterTimestampMonotonic = unitIface.activeEnterTimestampMonotonic(); 28 | activeExitTimestamp = unitIface.activeExitTimestamp(); 29 | activeExitTimestampMonotonic = unitIface.activeExitTimestampMonotonic(); 30 | activeState = unitIface.activeState(); 31 | after = unitIface.after(); 32 | allowIsolate = unitIface.allowIsolate(); 33 | assertResult = unitIface.assertResult(); 34 | assertTimestamp = unitIface.assertTimestamp(); 35 | assertTimestampMonotonic = unitIface.assertTimestampMonotonic(); 36 | asserts = unitIface.asserts(); 37 | before = unitIface.before(); 38 | bindsTo = unitIface.bindsTo(); 39 | boundBy = unitIface.boundBy(); 40 | canIsolate = unitIface.canIsolate(); 41 | canReload = unitIface.canReload(); 42 | canStart = unitIface.canStart(); 43 | canStop = unitIface.canStop(); 44 | conditionResult = unitIface.conditionResult(); 45 | conditionTimestamp = unitIface.conditionTimestamp(); 46 | conditionTimestampMonotonic = unitIface.conditionTimestampMonotonic(); 47 | conditions = unitIface.conditions(); 48 | conflictedBy = unitIface.conflictedBy(); 49 | conflicts = unitIface.conflicts(); 50 | consistsOf = unitIface.consistsOf(); 51 | defaultDependencies = unitIface.defaultDependencies(); 52 | description = unitIface.description(); 53 | documentation = unitIface.documentation(); 54 | dropInPaths = unitIface.dropInPaths(); 55 | following = unitIface.following(); 56 | fragmentPath = unitIface.fragmentPath(); 57 | id = unitIface.id(); 58 | ignoreOnIsolate = unitIface.ignoreOnIsolate(); 59 | inactiveEnterTimestamp = unitIface.inactiveEnterTimestamp(); 60 | inactiveEnterTimestampMonotonic = unitIface.inactiveEnterTimestampMonotonic(); 61 | inactiveExitTimestamp = unitIface.inactiveExitTimestamp(); 62 | inactiveExitTimestampMonotonic = unitIface.inactiveExitTimestampMonotonic(); 63 | job = unitIface.job().id; 64 | jobTimeoutAction = unitIface.jobTimeoutAction(); 65 | jobTimeoutRebootArgument = unitIface.jobTimeoutRebootArgument(); 66 | jobTimeoutUSec = unitIface.jobTimeoutUSec(); 67 | joinsNamespaceOf = unitIface.joinsNamespaceOf(); 68 | loadError = unitIface.loadError(); 69 | loadState = unitIface.loadState(); 70 | names = unitIface.names(); 71 | needDaemonReload = unitIface.needDaemonReload(); 72 | onFailure = unitIface.onFailure(); 73 | onFailureJobMode = unitIface.onFailureJobMode(); 74 | partOf = unitIface.partOf(); 75 | propagatesReloadTo = unitIface.propagatesReloadTo(); 76 | rebootArgument = unitIface.rebootArgument(); 77 | refuseManualStart = unitIface.refuseManualStart(); 78 | refuseManualStop = unitIface.refuseManualStop(); 79 | reloadPropagatedFrom = unitIface.reloadPropagatedFrom(); 80 | requiredBy = unitIface.requiredBy(); 81 | requires = unitIface.requires(); 82 | requiresMountsFor = unitIface.requiresMountsFor(); 83 | requisite = unitIface.requisite(); 84 | requisiteOf = unitIface.requisiteOf(); 85 | sourcePath = unitIface.sourcePath(); 86 | stateChangeTimestamp = unitIface.stateChangeTimestamp(); 87 | stateChangeTimestampMonotonic = unitIface.stateChangeTimestampMonotonic(); 88 | startLimitAction = unitIface.startLimitAction(); 89 | startLimitBurst = unitIface.startLimitBurst(); 90 | startLimitInterval = unitIface.startLimitInterval(); 91 | stopWhenUnneeded = unitIface.stopWhenUnneeded(); 92 | subState = unitIface.subState(); 93 | transient = unitIface.transient(); 94 | triggeredBy = unitIface.triggeredBy(); 95 | triggers = unitIface.triggers(); 96 | unitFileState = unitIface.unitFileState(); 97 | wantedBy = unitIface.wantedBy(); 98 | wants = unitIface.wants(); 99 | } 100 | 101 | Systemd::UnitPrivate::~UnitPrivate() 102 | { 103 | } 104 | 105 | Systemd::Unit::Unit(const QString &path, const QDBusConnection &connection, QObject *parent) : 106 | QObject(parent), d_ptr(new UnitPrivate(path, connection)) 107 | { 108 | } 109 | 110 | Systemd::Unit::Unit(UnitPrivate &unit, QObject *parent) : 111 | QObject(parent), d_ptr(&unit) 112 | { 113 | } 114 | 115 | Systemd::Unit::~Unit() 116 | { 117 | delete d_ptr; 118 | } 119 | 120 | qulonglong Systemd::Unit::activeEnterTimestamp() const 121 | { 122 | Q_D(const Unit); 123 | return d->activeEnterTimestamp; 124 | } 125 | 126 | qulonglong Systemd::Unit::activeEnterTimestampMonotonic() const 127 | { 128 | Q_D(const Unit); 129 | return d->activeEnterTimestampMonotonic; 130 | } 131 | 132 | qulonglong Systemd::Unit::activeExitTimestamp() const 133 | { 134 | Q_D(const Unit); 135 | return d->activeExitTimestamp; 136 | } 137 | 138 | qulonglong Systemd::Unit::activeExitTimestampMonotonic() const 139 | { 140 | Q_D(const Unit); 141 | return d->activeExitTimestampMonotonic; 142 | } 143 | 144 | QString Systemd::Unit::activeState() const 145 | { 146 | Q_D(const Unit); 147 | return d->activeState; 148 | } 149 | 150 | QStringList Systemd::Unit::after() const 151 | { 152 | Q_D(const Unit); 153 | return d->after; 154 | } 155 | 156 | bool Systemd::Unit::allowIsolate() const 157 | { 158 | Q_D(const Unit); 159 | return d->allowIsolate; 160 | } 161 | 162 | bool Systemd::Unit::assertResult() const 163 | { 164 | Q_D(const Unit); 165 | return d->assertResult; 166 | } 167 | 168 | qulonglong Systemd::Unit::assertTimestamp() const 169 | { 170 | Q_D(const Unit); 171 | return d->assertTimestamp; 172 | } 173 | 174 | qulonglong Systemd::Unit::assertTimestampMonotonic() const 175 | { 176 | Q_D(const Unit); 177 | return d->assertTimestampMonotonic; 178 | } 179 | 180 | QList Systemd::Unit::asserts() const 181 | { 182 | Q_D(const Unit); 183 | return d->asserts; 184 | } 185 | 186 | QStringList Systemd::Unit::before() const 187 | { 188 | Q_D(const Unit); 189 | return d->before; 190 | } 191 | 192 | QStringList Systemd::Unit::bindsTo() const 193 | { 194 | Q_D(const Unit); 195 | return d->bindsTo; 196 | } 197 | 198 | QStringList Systemd::Unit::boundBy() const 199 | { 200 | Q_D(const Unit); 201 | return d->boundBy; 202 | } 203 | 204 | bool Systemd::Unit::canIsolate() const 205 | { 206 | Q_D(const Unit); 207 | return d->canIsolate; 208 | } 209 | 210 | bool Systemd::Unit::canReload() const 211 | { 212 | Q_D(const Unit); 213 | return d->canReload; 214 | } 215 | 216 | bool Systemd::Unit::canStart() const 217 | { 218 | Q_D(const Unit); 219 | return d->canStart; 220 | } 221 | 222 | bool Systemd::Unit::canStop() const 223 | { 224 | Q_D(const Unit); 225 | return d->canStop; 226 | } 227 | 228 | bool Systemd::Unit::conditionResult() const 229 | { 230 | Q_D(const Unit); 231 | return d->conditionResult; 232 | } 233 | 234 | qulonglong Systemd::Unit::conditionTimestamp() const 235 | { 236 | Q_D(const Unit); 237 | return d->conditionTimestamp; 238 | } 239 | 240 | qulonglong Systemd::Unit::conditionTimestampMonotonic() const 241 | { 242 | Q_D(const Unit); 243 | return d->conditionTimestampMonotonic; 244 | } 245 | 246 | QList Systemd::Unit::conditions() const 247 | { 248 | Q_D(const Unit); 249 | return d->conditions; 250 | } 251 | 252 | QStringList Systemd::Unit::conflictedBy() const 253 | { 254 | Q_D(const Unit); 255 | return d->conflictedBy; 256 | } 257 | 258 | QStringList Systemd::Unit::conflicts() const 259 | { 260 | Q_D(const Unit); 261 | return d->conflicts; 262 | } 263 | 264 | QStringList Systemd::Unit::consistsOf() const 265 | { 266 | Q_D(const Unit); 267 | return d->consistsOf; 268 | } 269 | 270 | bool Systemd::Unit::defaultDependencies() const 271 | { 272 | Q_D(const Unit); 273 | return d->defaultDependencies; 274 | } 275 | 276 | QString Systemd::Unit::description() const 277 | { 278 | Q_D(const Unit); 279 | return d->description; 280 | } 281 | 282 | QStringList Systemd::Unit::documentation() const 283 | { 284 | Q_D(const Unit); 285 | return d->documentation; 286 | } 287 | 288 | QStringList Systemd::Unit::dropInPaths() const 289 | { 290 | Q_D(const Unit); 291 | return d->dropInPaths; 292 | } 293 | 294 | QString Systemd::Unit::following() const 295 | { 296 | Q_D(const Unit); 297 | return d->following; 298 | } 299 | 300 | QString Systemd::Unit::fragmentPath() const 301 | { 302 | Q_D(const Unit); 303 | return d->fragmentPath; 304 | } 305 | 306 | QString Systemd::Unit::id() const 307 | { 308 | Q_D(const Unit); 309 | return d->id; 310 | } 311 | 312 | bool Systemd::Unit::ignoreOnIsolate() const 313 | { 314 | Q_D(const Unit); 315 | return d->ignoreOnIsolate; 316 | } 317 | 318 | qulonglong Systemd::Unit::inactiveEnterTimestamp() const 319 | { 320 | Q_D(const Unit); 321 | return d->inactiveEnterTimestamp; 322 | } 323 | 324 | qulonglong Systemd::Unit::inactiveEnterTimestampMonotonic() const 325 | { 326 | Q_D(const Unit); 327 | return d->inactiveEnterTimestampMonotonic; 328 | } 329 | 330 | qulonglong Systemd::Unit::inactiveExitTimestamp() const 331 | { 332 | Q_D(const Unit); 333 | return d->inactiveExitTimestamp; 334 | } 335 | 336 | qulonglong Systemd::Unit::inactiveExitTimestampMonotonic() const 337 | { 338 | Q_D(const Unit); 339 | return d->inactiveExitTimestampMonotonic; 340 | } 341 | 342 | uint Systemd::Unit::job() const 343 | { 344 | Q_D(const Unit); 345 | return d->job; 346 | } 347 | 348 | QString Systemd::Unit::jobTimeoutAction() const 349 | { 350 | Q_D(const Unit); 351 | return d->jobTimeoutAction; 352 | } 353 | 354 | QString Systemd::Unit::jobTimeoutRebootArgument() const 355 | { 356 | Q_D(const Unit); 357 | return d->jobTimeoutRebootArgument; 358 | } 359 | 360 | qulonglong Systemd::Unit::jobTimeoutUSec() const 361 | { 362 | Q_D(const Unit); 363 | return d->jobTimeoutUSec; 364 | } 365 | 366 | QStringList Systemd::Unit::joinsNamespaceOf() const 367 | { 368 | Q_D(const Unit); 369 | return d->joinsNamespaceOf; 370 | } 371 | 372 | UnitLoadError Systemd::Unit::loadError() const 373 | { 374 | Q_D(const Unit); 375 | return d->loadError; 376 | } 377 | 378 | QString Systemd::Unit::loadState() const 379 | { 380 | Q_D(const Unit); 381 | return d->loadState; 382 | } 383 | 384 | QStringList Systemd::Unit::names() const 385 | { 386 | Q_D(const Unit); 387 | return d->names; 388 | } 389 | 390 | bool Systemd::Unit::needDaemonReload() const 391 | { 392 | Q_D(const Unit); 393 | return d->needDaemonReload; 394 | } 395 | 396 | QStringList Systemd::Unit::onFailure() const 397 | { 398 | Q_D(const Unit); 399 | return d->onFailure; 400 | } 401 | 402 | QString Systemd::Unit::onFailureJobMode() const 403 | { 404 | Q_D(const Unit); 405 | return d->onFailureJobMode; 406 | } 407 | 408 | QStringList Systemd::Unit::partOf() const 409 | { 410 | Q_D(const Unit); 411 | return d->partOf; 412 | } 413 | 414 | QStringList Systemd::Unit::propagatesReloadTo() const 415 | { 416 | Q_D(const Unit); 417 | return d->propagatesReloadTo; 418 | } 419 | 420 | QString Systemd::Unit::rebootArgument() const 421 | { 422 | Q_D(const Unit); 423 | return d->rebootArgument; 424 | } 425 | 426 | bool Systemd::Unit::refuseManualStart() const 427 | { 428 | Q_D(const Unit); 429 | return d->refuseManualStart; 430 | } 431 | 432 | bool Systemd::Unit::refuseManualStop() const 433 | { 434 | Q_D(const Unit); 435 | return d->refuseManualStop; 436 | } 437 | 438 | QStringList Systemd::Unit::reloadPropagatedFrom() const 439 | { 440 | Q_D(const Unit); 441 | return d->reloadPropagatedFrom; 442 | } 443 | 444 | QStringList Systemd::Unit::requiredBy() const 445 | { 446 | Q_D(const Unit); 447 | return d->requiredBy; 448 | } 449 | 450 | QStringList Systemd::Unit::requires() const 451 | { 452 | Q_D(const Unit); 453 | return d->requires; 454 | } 455 | 456 | QStringList Systemd::Unit::requiresMountsFor() const 457 | { 458 | Q_D(const Unit); 459 | return d->requiresMountsFor; 460 | } 461 | 462 | QStringList Systemd::Unit::requisite() const 463 | { 464 | Q_D(const Unit); 465 | return d->requisite; 466 | } 467 | 468 | QStringList Systemd::Unit::requisiteOf() const 469 | { 470 | Q_D(const Unit); 471 | return d->requisiteOf; 472 | } 473 | 474 | QString Systemd::Unit::sourcePath() const 475 | { 476 | Q_D(const Unit); 477 | return d->sourcePath; 478 | } 479 | 480 | qulonglong Systemd::Unit::stateChangeTimestamp() const 481 | { 482 | Q_D(const Unit); 483 | return d->stateChangeTimestamp; 484 | } 485 | 486 | qulonglong Systemd::Unit::stateChangeTimestampMonotonic() const 487 | { 488 | Q_D(const Unit); 489 | return d->stateChangeTimestampMonotonic; 490 | } 491 | 492 | QString Systemd::Unit::startLimitAction() const 493 | { 494 | Q_D(const Unit); 495 | return d->startLimitAction; 496 | } 497 | 498 | uint Systemd::Unit::startLimitBurst() const 499 | { 500 | Q_D(const Unit); 501 | return d->startLimitBurst; 502 | } 503 | 504 | qulonglong Systemd::Unit::startLimitInterval() const 505 | { 506 | Q_D(const Unit); 507 | return d->startLimitInterval; 508 | } 509 | 510 | bool Systemd::Unit::stopWhenUnneeded() const 511 | { 512 | Q_D(const Unit); 513 | return d->stopWhenUnneeded; 514 | } 515 | 516 | QString Systemd::Unit::subState() const 517 | { 518 | Q_D(const Unit); 519 | return d->subState; 520 | } 521 | 522 | bool Systemd::Unit::transient() const 523 | { 524 | Q_D(const Unit); 525 | return d->transient; 526 | } 527 | 528 | QStringList Systemd::Unit::triggeredBy() const 529 | { 530 | Q_D(const Unit); 531 | return d->triggeredBy; 532 | } 533 | 534 | QStringList Systemd::Unit::triggers() const 535 | { 536 | Q_D(const Unit); 537 | return d->triggers; 538 | } 539 | 540 | QString Systemd::Unit::unitFileState() const 541 | { 542 | Q_D(const Unit); 543 | return d->unitFileState; 544 | } 545 | 546 | QStringList Systemd::Unit::wantedBy() const 547 | { 548 | Q_D(const Unit); 549 | return d->wantedBy; 550 | } 551 | 552 | QStringList Systemd::Unit::wants() const 553 | { 554 | Q_D(const Unit); 555 | return d->wants; 556 | } 557 | -------------------------------------------------------------------------------- /src/unit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #ifndef SD_UNIT_H 21 | #define SD_UNIT_H 22 | 23 | #include 24 | #include 25 | 26 | #include "QtSystemd-export.h" 27 | #include "generic-types.h" 28 | 29 | class QDBusConnection; 30 | 31 | namespace Systemd 32 | { 33 | 34 | class UnitPrivate; 35 | 36 | class SDQT_EXPORT Unit : public QObject 37 | { 38 | Q_OBJECT 39 | Q_DECLARE_PRIVATE(Unit) 40 | 41 | public: 42 | 43 | enum Mode { 44 | Replace, 45 | Fail, 46 | Isolate, 47 | IgnoreDependencies, 48 | IgnoreRequirements 49 | }; 50 | 51 | enum Result { 52 | Done, 53 | Canceled, 54 | Timeout, 55 | Failed, 56 | Dependency, 57 | Skipped 58 | }; 59 | 60 | enum Who { 61 | Main, 62 | Control, 63 | All 64 | }; 65 | 66 | typedef QSharedPointer Ptr; 67 | 68 | explicit Unit(const QString &path, const QDBusConnection &connection, QObject *parent = 0); 69 | explicit Unit(UnitPrivate &unit, QObject *parent = 0); 70 | virtual ~Unit(); 71 | 72 | qulonglong activeEnterTimestamp() const; 73 | qulonglong activeEnterTimestampMonotonic() const; 74 | qulonglong activeExitTimestamp() const; 75 | qulonglong activeExitTimestampMonotonic() const; 76 | QString activeState() const; 77 | QStringList after() const; 78 | bool allowIsolate() const; 79 | bool assertResult() const; 80 | qulonglong assertTimestamp() const; 81 | qulonglong assertTimestampMonotonic() const; 82 | QList asserts() const; 83 | QStringList before() const; 84 | QStringList bindsTo() const; 85 | QStringList boundBy() const; 86 | bool canIsolate() const; 87 | bool canReload() const; 88 | bool canStart() const; 89 | bool canStop() const; 90 | bool conditionResult() const; 91 | qulonglong conditionTimestamp() const; 92 | qulonglong conditionTimestampMonotonic() const; 93 | QList conditions() const; 94 | QStringList conflictedBy() const; 95 | QStringList conflicts() const; 96 | QStringList consistsOf() const; 97 | bool defaultDependencies() const; 98 | QString description() const; 99 | QStringList documentation() const; 100 | QStringList dropInPaths() const; 101 | QString following() const; 102 | QString fragmentPath() const; 103 | QString id() const; 104 | bool ignoreOnIsolate() const; 105 | qulonglong inactiveEnterTimestamp() const; 106 | qulonglong inactiveEnterTimestampMonotonic() const; 107 | qulonglong inactiveExitTimestamp() const; 108 | qulonglong inactiveExitTimestampMonotonic() const; 109 | uint job() const; 110 | QString jobTimeoutAction() const; 111 | QString jobTimeoutRebootArgument() const; 112 | qulonglong jobTimeoutUSec() const; 113 | QStringList joinsNamespaceOf() const; 114 | UnitLoadError loadError() const; 115 | QString loadState() const; 116 | QStringList names() const; 117 | bool needDaemonReload() const; 118 | QStringList onFailure() const; 119 | QString onFailureJobMode() const; 120 | QStringList partOf() const; 121 | QStringList propagatesReloadTo() const; 122 | QString rebootArgument() const; 123 | bool refuseManualStart() const; 124 | bool refuseManualStop() const; 125 | QStringList reloadPropagatedFrom() const; 126 | QStringList requiredBy() const; 127 | QStringList requires() const; 128 | QStringList requiresMountsFor() const; 129 | QStringList requisite() const; 130 | QStringList requisiteOf() const; 131 | QString sourcePath() const; 132 | qulonglong stateChangeTimestamp() const; 133 | qulonglong stateChangeTimestampMonotonic() const; 134 | QString startLimitAction() const; 135 | uint startLimitBurst() const; 136 | qulonglong startLimitInterval() const; 137 | bool stopWhenUnneeded() const; 138 | QString subState() const; 139 | bool transient() const; 140 | QStringList triggeredBy() const; 141 | QStringList triggers() const; 142 | QString unitFileState() const; 143 | QStringList wantedBy() const; 144 | QStringList wants() const; 145 | 146 | protected: 147 | UnitPrivate *d_ptr; 148 | 149 | }; 150 | } 151 | 152 | #endif 153 | -------------------------------------------------------------------------------- /src/unit_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #ifndef SD_UNIT_P_H 21 | #define SD_UNIT_P_H 22 | 23 | #include "unitinterface.h" 24 | 25 | #include "unit.h" 26 | 27 | namespace Systemd 28 | { 29 | 30 | class UnitPrivate 31 | { 32 | 33 | public: 34 | explicit UnitPrivate(const QString &path, const QDBusConnection &connection); 35 | virtual ~UnitPrivate(); 36 | 37 | OrgFreedesktopSystemd1UnitInterface unitIface; 38 | 39 | qulonglong activeEnterTimestamp; 40 | qulonglong activeEnterTimestampMonotonic; 41 | qulonglong activeExitTimestamp; 42 | qulonglong activeExitTimestampMonotonic; 43 | QString activeState; 44 | QStringList after; 45 | bool allowIsolate; 46 | bool assertResult; 47 | qulonglong assertTimestamp; 48 | qulonglong assertTimestampMonotonic; 49 | QList asserts; 50 | QStringList before; 51 | QStringList bindsTo; 52 | QStringList boundBy; 53 | bool canIsolate; 54 | bool canReload; 55 | bool canStart; 56 | bool canStop; 57 | bool conditionResult; 58 | qulonglong conditionTimestamp; 59 | qulonglong conditionTimestampMonotonic; 60 | QList conditions; 61 | QStringList conflictedBy; 62 | QStringList conflicts; 63 | QStringList consistsOf; 64 | bool defaultDependencies; 65 | QString description; 66 | QStringList documentation; 67 | QStringList dropInPaths; 68 | QString following; 69 | QString fragmentPath; 70 | QString id; 71 | bool ignoreOnIsolate; 72 | qulonglong inactiveEnterTimestamp; 73 | qulonglong inactiveEnterTimestampMonotonic; 74 | qulonglong inactiveExitTimestamp; 75 | qulonglong inactiveExitTimestampMonotonic; 76 | uint job; 77 | QString jobTimeoutAction; 78 | QString jobTimeoutRebootArgument; 79 | qulonglong jobTimeoutUSec; 80 | QStringList joinsNamespaceOf; 81 | UnitLoadError loadError; 82 | QString loadState; 83 | QStringList names; 84 | bool needDaemonReload; 85 | QStringList onFailure; 86 | QString onFailureJobMode; 87 | QStringList partOf; 88 | QStringList propagatesReloadTo; 89 | QString rebootArgument; 90 | bool refuseManualStart; 91 | bool refuseManualStop; 92 | QStringList reloadPropagatedFrom; 93 | QStringList requiredBy; 94 | QStringList requires; 95 | QStringList requiresMountsFor; 96 | QStringList requisite; 97 | QStringList requisiteOf; 98 | QString sourcePath; 99 | qulonglong stateChangeTimestamp; 100 | qulonglong stateChangeTimestampMonotonic; 101 | QString startLimitAction; 102 | uint startLimitBurst; 103 | qulonglong startLimitInterval; 104 | bool stopWhenUnneeded; 105 | QString subState; 106 | bool transient; 107 | QStringList triggeredBy; 108 | QStringList triggers; 109 | QString unitFileState; 110 | QStringList wantedBy; 111 | QStringList wants; 112 | }; 113 | } 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /src/user.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #include "user_p.h" 21 | #include "ldmanager_p.h" 22 | 23 | Systemd::Logind::UserPrivate::UserPrivate(const QString &path) : 24 | userIface(Systemd::Logind::LogindPrivate::LD_DBUS_SERVICE, path, QDBusConnection::systemBus()) 25 | { 26 | display = userIface.display().id; 27 | gid = userIface.uID(); 28 | idleHint = userIface.idleHint(); 29 | idleSinceHint = userIface.idleSinceHint(); 30 | idleSinceHintMonotonic = userIface.idleSinceHintMonotonic(); 31 | linger = userIface.linger(); 32 | name = userIface.name(); 33 | runtimePath = userIface.runtimePath(); 34 | service = userIface.service(); 35 | Q_FOREACH (const DBusSession &session, userIface.sessions()) { 36 | sessions << session.id; 37 | } 38 | slice = userIface.slice(); 39 | state = userIface.state(); 40 | timestamp = userIface.timestamp(); 41 | timestampMonotonic = userIface.timestampMonotonic(); 42 | uid = userIface.uID(); 43 | } 44 | 45 | Systemd::Logind::UserPrivate::~UserPrivate() 46 | { 47 | } 48 | 49 | Systemd::Logind::User::User(const QString &path, QObject *parent) : 50 | QObject(parent), d_ptr(new UserPrivate(path)) 51 | { 52 | } 53 | 54 | Systemd::Logind::User::User(UserPrivate &user, QObject *parent) : 55 | QObject(parent), d_ptr(&user) 56 | { 57 | } 58 | 59 | Systemd::Logind::User::~User() 60 | { 61 | delete d_ptr; 62 | } 63 | 64 | QString Systemd::Logind::User::display() const 65 | { 66 | Q_D(const User); 67 | return d->display; 68 | } 69 | 70 | uint Systemd::Logind::User::gid() const 71 | { 72 | Q_D(const User); 73 | return d->gid; 74 | } 75 | 76 | bool Systemd::Logind::User::idleHint() const 77 | { 78 | Q_D(const User); 79 | return d->idleHint; 80 | } 81 | 82 | qulonglong Systemd::Logind::User::idleSinceHint() const 83 | { 84 | Q_D(const User); 85 | return d->idleSinceHint; 86 | } 87 | 88 | qulonglong Systemd::Logind::User::idleSinceHintMonotonic() const 89 | { 90 | Q_D(const User); 91 | return d->idleSinceHintMonotonic; 92 | } 93 | 94 | bool Systemd::Logind::User::linger() const 95 | { 96 | Q_D(const User); 97 | return d->linger; 98 | } 99 | 100 | QString Systemd::Logind::User::name() const 101 | { 102 | Q_D(const User); 103 | return d->name; 104 | } 105 | 106 | QString Systemd::Logind::User::runtimePath() const 107 | { 108 | Q_D(const User); 109 | return d->runtimePath; 110 | } 111 | 112 | QString Systemd::Logind::User::service() const 113 | { 114 | Q_D(const User); 115 | return d->service; 116 | } 117 | 118 | QStringList Systemd::Logind::User::sessions() const 119 | { 120 | Q_D(const User); 121 | return d->sessions; 122 | } 123 | 124 | QString Systemd::Logind::User::slice() const 125 | { 126 | Q_D(const User); 127 | return d->slice; 128 | } 129 | 130 | QString Systemd::Logind::User::state() const 131 | { 132 | Q_D(const User); 133 | return d->state; 134 | } 135 | 136 | qulonglong Systemd::Logind::User::timestamp() const 137 | { 138 | Q_D(const User); 139 | return d->timestamp; 140 | } 141 | 142 | qulonglong Systemd::Logind::User::timestampMonotonic() const 143 | { 144 | Q_D(const User); 145 | return d->timestampMonotonic; 146 | } 147 | 148 | uint Systemd::Logind::User::uid() const 149 | { 150 | Q_D(const User); 151 | return d->uid; 152 | } 153 | 154 | -------------------------------------------------------------------------------- /src/user.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #ifndef SD_USER_H 21 | #define SD_USER_H 22 | 23 | #include 24 | #include 25 | 26 | #include "QtSystemd-export.h" 27 | 28 | namespace Systemd 29 | { 30 | namespace Logind 31 | { 32 | class UserPrivate; 33 | 34 | class SDQT_EXPORT User : public QObject 35 | { 36 | Q_OBJECT 37 | Q_DECLARE_PRIVATE(User) 38 | 39 | public: 40 | typedef QSharedPointer Ptr; 41 | 42 | explicit User(const QString &path, QObject *parent = 0); 43 | explicit User(UserPrivate &user, QObject *parent = 0); 44 | virtual ~User(); 45 | 46 | QString display() const; 47 | uint gid() const; 48 | bool idleHint() const; 49 | qulonglong idleSinceHint() const; 50 | qulonglong idleSinceHintMonotonic() const; 51 | bool linger() const; 52 | QString name() const; 53 | QString runtimePath() const; 54 | QString service() const; 55 | QStringList sessions() const; 56 | QString slice() const; 57 | QString state() const; 58 | qulonglong timestamp() const; 59 | qulonglong timestampMonotonic() const; 60 | uint uid() const; 61 | 62 | protected: 63 | UserPrivate *d_ptr; 64 | }; 65 | } 66 | } 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/user_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #ifndef SD_USER_P_H 21 | #define SD_USER_P_H 22 | 23 | #include "userinterface.h" 24 | 25 | #include "user.h" 26 | 27 | namespace Systemd 28 | { 29 | namespace Logind 30 | { 31 | class UserPrivate 32 | { 33 | 34 | public: 35 | explicit UserPrivate(const QString &path); 36 | virtual ~UserPrivate(); 37 | 38 | OrgFreedesktopLogin1UserInterface userIface; 39 | 40 | QString display; 41 | uint gid; 42 | bool idleHint; 43 | qulonglong idleSinceHint; 44 | qulonglong idleSinceHintMonotonic; 45 | bool linger; 46 | QString name; 47 | QString runtimePath; 48 | QString service; 49 | QStringList sessions; 50 | QString slice; 51 | QString state; 52 | qulonglong timestamp; 53 | qulonglong timestampMonotonic; 54 | uint uid; 55 | }; 56 | } 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(QtSDManager_SRCS 2 | sdmanager-test.cpp 3 | ) 4 | 5 | add_executable(sdmanager-test ${QtSDManager_SRCS}) 6 | 7 | qt5_use_modules(sdmanager-test Core) 8 | 9 | target_link_libraries(sdmanager-test QtSystemd) 10 | 11 | set(QtLDManager_SRCS 12 | ldmanager-test.cpp 13 | ) 14 | 15 | add_executable(ldmanager-test ${QtLDManager_SRCS}) 16 | 17 | qt5_use_modules(ldmanager-test Core) 18 | 19 | target_link_libraries(ldmanager-test QtSystemd) 20 | -------------------------------------------------------------------------------- /tests/ldmanager-test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #include "../src/ldmanager.h" 24 | 25 | class LDManagerTest 26 | { 27 | public: 28 | LDManagerTest() 29 | { 30 | } 31 | 32 | static void canHibernate() 33 | { 34 | qDebug() << "Can hibernate?"; 35 | Systemd::Logind::Permission perm = Systemd::Logind::canHibernate(); 36 | switch (perm) { 37 | case Systemd::Logind::Challenge: 38 | qDebug() << "Challenge"; 39 | break; 40 | case Systemd::Logind::Na: 41 | qDebug() << "Na"; 42 | break; 43 | case Systemd::Logind::No: 44 | qDebug() << "No"; 45 | break; 46 | case Systemd::Logind::Yes: 47 | qDebug() << "Yes"; 48 | break; 49 | } 50 | } 51 | 52 | static void canHybridSleep() 53 | { 54 | qDebug() << "Can hybrid sleep?"; 55 | Systemd::Logind::Permission perm = Systemd::Logind::canHybridSleep(); 56 | switch (perm) { 57 | case Systemd::Logind::Challenge: 58 | qDebug() << "Challenge"; 59 | break; 60 | case Systemd::Logind::Na: 61 | qDebug() << "Na"; 62 | break; 63 | case Systemd::Logind::No: 64 | qDebug() << "No"; 65 | break; 66 | case Systemd::Logind::Yes: 67 | qDebug() << "Yes"; 68 | break; 69 | } 70 | } 71 | 72 | static void canPowerOff() 73 | { 74 | qDebug() << "Can power off?"; 75 | Systemd::Logind::Permission perm = Systemd::Logind::canPowerOff(); 76 | switch (perm) { 77 | case Systemd::Logind::Challenge: 78 | qDebug() << "Challenge"; 79 | break; 80 | case Systemd::Logind::Na: 81 | qDebug() << "Na"; 82 | break; 83 | case Systemd::Logind::No: 84 | qDebug() << "No"; 85 | break; 86 | case Systemd::Logind::Yes: 87 | qDebug() << "Yes"; 88 | break; 89 | } 90 | } 91 | 92 | static void canReboot() 93 | { 94 | qDebug() << "Can reboot?"; 95 | Systemd::Logind::Permission perm = Systemd::Logind::canReboot(); 96 | switch (perm) { 97 | case Systemd::Logind::Challenge: 98 | qDebug() << "Challenge"; 99 | break; 100 | case Systemd::Logind::Na: 101 | qDebug() << "Na"; 102 | break; 103 | case Systemd::Logind::No: 104 | qDebug() << "No"; 105 | break; 106 | case Systemd::Logind::Yes: 107 | qDebug() << "Yes"; 108 | break; 109 | } 110 | } 111 | 112 | static void canSuspend() 113 | { 114 | qDebug() << "Can suspend?"; 115 | Systemd::Logind::Permission perm = Systemd::Logind::canSuspend(); 116 | switch (perm) { 117 | case Systemd::Logind::Challenge: 118 | qDebug() << "Challenge"; 119 | break; 120 | case Systemd::Logind::Na: 121 | qDebug() << "Na"; 122 | break; 123 | case Systemd::Logind::No: 124 | qDebug() << "No"; 125 | break; 126 | case Systemd::Logind::Yes: 127 | qDebug() << "Yes"; 128 | break; 129 | } 130 | } 131 | 132 | static void listInhibitors() 133 | { 134 | qDebug() << "Listing inhibitors:"; 135 | Q_FOREACH (const LoginInhibitor &inhibitor, Systemd::Logind::listInhibitors()) { 136 | qDebug() << "\t" << inhibitor.who << "(" << inhibitor.what << ")"; 137 | } 138 | } 139 | 140 | static void listSeats() 141 | { 142 | qDebug() << "Listing seats:"; 143 | Q_FOREACH (const Systemd::Logind::Seat::Ptr &seat, Systemd::Logind::listSeats()) { 144 | qDebug() << "\t" << seat->id(); 145 | } 146 | } 147 | 148 | static void listSessions() 149 | { 150 | qDebug() << "Listing sessions:"; 151 | Q_FOREACH (const Systemd::Logind::Session::Ptr &session, Systemd::Logind::listSessions()) { 152 | qDebug() << "\t" << session->id(); 153 | } 154 | } 155 | 156 | static void listUsers() 157 | { 158 | qDebug() << "Listing users:"; 159 | Q_FOREACH (const Systemd::Logind::User::Ptr &user, Systemd::Logind::listUsers()) { 160 | qDebug() << "\t" << user->name(); 161 | } 162 | } 163 | }; 164 | 165 | int main(int argc, char* argv[]) 166 | { 167 | QCoreApplication app(argc, argv); 168 | 169 | LDManagerTest::canHibernate(); 170 | 171 | LDManagerTest::canHybridSleep(); 172 | 173 | LDManagerTest::canPowerOff(); 174 | 175 | LDManagerTest::canReboot(); 176 | 177 | LDManagerTest::canSuspend(); 178 | 179 | LDManagerTest::listInhibitors(); 180 | 181 | LDManagerTest::listSeats(); 182 | 183 | LDManagerTest::listSessions(); 184 | 185 | LDManagerTest::listUsers(); 186 | } 187 | -------------------------------------------------------------------------------- /tests/sdmanager-test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Andrea Scarpino 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | * 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #include "../src/sdmanager.h" 24 | 25 | using namespace Systemd; 26 | 27 | class SDManagerTest 28 | { 29 | public: 30 | static void disableUnitFiles() 31 | { 32 | const QString unitName("lm_sensors.service"); 33 | 34 | QStringList f; 35 | f << unitName; 36 | 37 | qDebug() << "Disabling units:" << f; 38 | Systemd::disableUnitFiles(Systemd::System, f, false); 39 | 40 | qDebug() << "State:" << Systemd::getUnit(Systemd::System, unitName).data()->activeState(); 41 | } 42 | 43 | static void enableUnitFiles() 44 | { 45 | const QString unitName("lm_sensors.service"); 46 | 47 | QStringList f; 48 | f << unitName; 49 | 50 | qDebug() << "Enabling units:" << f; 51 | Systemd::enableUnitFiles(Systemd::System, f, false, false); 52 | 53 | qDebug() << "State:" << Systemd::getUnit(Systemd::System, unitName).data()->activeState(); 54 | } 55 | 56 | static void getUnit() 57 | { 58 | const QString unitName("lm_sensors.service"); 59 | 60 | qDebug() << "Got unit, id:" << Systemd::getUnit(Systemd::System, unitName)->id(); 61 | } 62 | 63 | static void getUnitFileState() 64 | { 65 | const QString unitName("lm_sensors.service"); 66 | 67 | qDebug() << "lm_sesnsors unit file state:" << Systemd::getUnitFileState(Systemd::System, unitName); 68 | } 69 | 70 | static void getUnitByPID() 71 | { 72 | qDebug() << Systemd::getUnitByPID(Systemd::System, 1)->id(); 73 | } 74 | 75 | static void listJobs() 76 | { 77 | qDebug() << "Listing jobs:"; 78 | Q_FOREACH (const Job::Ptr &job, Systemd::listJobs(Systemd::System)) { 79 | qDebug() << "\t" << job->id(); 80 | } 81 | } 82 | 83 | static void listUnits() 84 | { 85 | qDebug() << "Listing units:"; 86 | Q_FOREACH (const Unit::Ptr &unit, Systemd::listUnits(Systemd::System)) { 87 | qDebug() << "\t" << unit->id(); 88 | } 89 | } 90 | 91 | static void listUnitFiles() 92 | { 93 | qDebug() << "Listing unit files:"; 94 | 95 | Q_FOREACH (const QString &unitFile, Systemd::listUnitFiles(Systemd::System)) { 96 | qDebug() << "\t" << unitFile; 97 | } 98 | } 99 | 100 | static void loadUnit() 101 | { 102 | const QString unitName("lm_sensors.service"); 103 | 104 | qDebug() << "Loading unit:" << unitName; 105 | qDebug() << "State:" << Systemd::loadUnit(Systemd::System, unitName)->loadState(); 106 | } 107 | 108 | static void reloadUnit() 109 | { 110 | const QString unitName("lm_sensors.service"); 111 | 112 | qDebug() << "Reloading unit:" << unitName; 113 | qDebug() << Systemd::reloadUnit(Systemd::System, unitName, Unit::Replace); 114 | } 115 | 116 | static void restartUnit() 117 | { 118 | const QString unitName("lm_sensors.service"); 119 | 120 | qDebug() << "Restaring unit:" << unitName; 121 | qDebug() << Systemd::restartUnit(Systemd::System, unitName, Unit::Replace); 122 | } 123 | 124 | static void startUnit() 125 | { 126 | const QString unitName("lm_sensors.service"); 127 | 128 | qDebug() << "Starting unit:" << unitName; 129 | qDebug() << Systemd::startUnit(Systemd::System, unitName, Unit::Replace); 130 | } 131 | 132 | static void stopUnit() 133 | { 134 | const QString unitName("lm_sensors.service"); 135 | 136 | qDebug() << "Stopping unit:" << unitName; 137 | qDebug() << Systemd::stopUnit(Systemd::System, unitName, Unit::Replace); 138 | } 139 | }; 140 | 141 | int main(int argc, char* argv[]) 142 | { 143 | QCoreApplication app(argc, argv); 144 | 145 | // SDManagerTest::disableUnitFiles(); 146 | 147 | // SDManagerTest::enableUnitFiles(); 148 | 149 | SDManagerTest::getUnit(); 150 | 151 | SDManagerTest::getUnitFileState(); 152 | 153 | // SDManagerTest::getUnitByPID(); 154 | 155 | SDManagerTest::listJobs(); 156 | 157 | SDManagerTest::listUnits(); 158 | 159 | SDManagerTest::listUnitFiles(); 160 | 161 | // SDManagerTest::loadUnit(); 162 | 163 | // SDManagerTest::reloadUnit(); 164 | 165 | // SDManagerTest::restartUnit(); 166 | 167 | // SDManagerTest::startUnit(); 168 | 169 | // SDManagerTest::stopUnit(); 170 | } 171 | --------------------------------------------------------------------------------