From e8933e99b4600d91e9eab7d1ad3a2d35813028a9 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 31 Oct 2021 00:13:21 +0900 Subject: More Qt->TQt conversion and some clean up. Signed-off-by: Michele Calgaro --- AUTHORS | 5 +- CMakeLists.txt | 104 +-- INSTALL | 6 +- Mainpage.dox | 52 +- PolkitQt-1Config.cmake.in | 41 -- Polkittqt-1Config.cmake.in | 41 ++ README | 12 +- README.porting | 25 - TODO | 11 - agent/CMakeLists.txt | 24 +- agent/listeneradapter.cpp | 14 +- agent/listeneradapter_p.h | 12 +- agent/polkitqt1-agent-listener.cpp | 28 +- agent/polkitqt1-agent-listener.h | 16 +- agent/polkitqt1-agent-session.cpp | 16 +- agent/polkitqt1-agent-session.h | 16 +- agent/polkitqtlistener.cpp | 48 +- agent/polkitqtlistener_p.h | 26 +- cmake/modules/CMakeLists.txt | 2 +- cmake/modules/FindPolkitQt-1.cmake | 32 +- cmake/modules/PolkitQt-1Dist.cmake | 12 +- core/CMakeLists.txt | 32 +- core/polkitqt1-actiondescription.cpp | 148 ----- core/polkitqt1-actiondescription.h | 149 ----- core/polkitqt1-authority.cpp | 855 ------------------------- core/polkitqt1-authority.h | 539 ---------------- core/polkitqt1-details.cpp | 99 --- core/polkitqt1-details.h | 97 --- core/polkitqt1-identity.cpp | 227 ------- core/polkitqt1-identity.h | 211 ------ core/polkitqt1-subject.cpp | 205 ------ core/polkitqt1-subject.h | 262 -------- core/polkitqt1-temporaryauthorization.cpp | 117 ---- core/polkitqt1-temporaryauthorization.h | 124 ---- core/polkittqt1-actiondescription.cpp | 148 +++++ core/polkittqt1-actiondescription.h | 149 +++++ core/polkittqt1-authority.cpp | 855 +++++++++++++++++++++++++ core/polkittqt1-authority.h | 539 ++++++++++++++++ core/polkittqt1-details.cpp | 99 +++ core/polkittqt1-details.h | 97 +++ core/polkittqt1-identity.cpp | 227 +++++++ core/polkittqt1-identity.h | 211 ++++++ core/polkittqt1-subject.cpp | 205 ++++++ core/polkittqt1-subject.h | 262 ++++++++ core/polkittqt1-temporaryauthorization.cpp | 117 ++++ core/polkittqt1-temporaryauthorization.h | 124 ++++ debian/changelog | 18 +- debian/control | 22 +- debian/copyright | 4 +- debian/libpolkit-qt-1-1.install | 3 - debian/libpolkit-qt-1-1.lintian-overrides | 1 - debian/libpolkit-qt-1-1.symbols | 305 --------- debian/libpolkit-qt-1-dev.install | 33 - debian/libpolkit-tqt-1-1.install | 3 + debian/libpolkit-tqt-1-1.lintian-overrides | 1 + debian/libpolkit-tqt-1-dev.install | 33 + examples/PkExampleHelper.cpp | 10 +- examples/PkExampleHelper.h | 2 +- examples/agent/CMakeLists.txt | 8 +- examples/agent/klistener.cpp | 6 +- examples/agent/klistener.h | 12 +- examples/agent/pkagentexample.cpp | 2 +- examples/org.qt.policykit.examples.conf | 20 - examples/org.qt.policykit.examples.policy | 81 --- examples/org.qt.policykit.examples.policy.in | 85 --- examples/org.qt.policykit.examples.service.in | 5 - examples/org.qt.policykit.examples.xml | 11 - examples/org.tqt.policykit.examples.conf | 20 + examples/org.tqt.policykit.examples.policy | 81 +++ examples/org.tqt.policykit.examples.policy.in | 85 +++ examples/org.tqt.policykit.examples.service.in | 5 + examples/org.tqt.policykit.examples.xml | 11 + gui/CMakeLists.txt | 28 +- gui/polkitqt1-gui-action.cpp | 515 --------------- gui/polkitqt1-gui-action.h | 304 --------- gui/polkitqt1-gui-actionbutton.cpp | 166 ----- gui/polkitqt1-gui-actionbutton.h | 145 ----- gui/polkitqt1-gui-actionbutton_p.h | 50 -- gui/polkitqt1-gui-actionbuttons.cpp | 73 --- gui/polkitqt1-gui-actionbuttons.h | 114 ---- gui/polkitqt1-gui-actionbuttons_p.h | 36 -- gui/polkittqt1-gui-action.cpp | 515 +++++++++++++++ gui/polkittqt1-gui-action.h | 304 +++++++++ gui/polkittqt1-gui-actionbutton.cpp | 166 +++++ gui/polkittqt1-gui-actionbutton.h | 145 +++++ gui/polkittqt1-gui-actionbutton_p.h | 50 ++ gui/polkittqt1-gui-actionbuttons.cpp | 73 +++ gui/polkittqt1-gui-actionbuttons.h | 114 ++++ gui/polkittqt1-gui-actionbuttons_p.h | 36 ++ includes/PolkitQt1/ActionDescription | 1 - includes/PolkitQt1/Agent/Listener | 1 - includes/PolkitQt1/Agent/Session | 1 - includes/PolkitQt1/Authority | 1 - includes/PolkitQt1/Details | 1 - includes/PolkitQt1/Gui/Action | 1 - includes/PolkitQt1/Gui/ActionButton | 1 - includes/PolkitQt1/Gui/ActionButtons | 1 - includes/PolkitQt1/Identity | 1 - includes/PolkitQt1/Subject | 1 - includes/PolkitQt1/TemporaryAuthorization | 1 - includes/PolkitTQt1/ActionDescription | 1 + includes/PolkitTQt1/Agent/Listener | 1 + includes/PolkitTQt1/Agent/Session | 1 + includes/PolkitTQt1/Authority | 1 + includes/PolkitTQt1/Details | 1 + includes/PolkitTQt1/Gui/Action | 1 + includes/PolkitTQt1/Gui/ActionButton | 1 + includes/PolkitTQt1/Gui/ActionButtons | 1 + includes/PolkitTQt1/Identity | 1 + includes/PolkitTQt1/Subject | 1 + includes/PolkitTQt1/TemporaryAuthorization | 1 + polkit-qt-1.pc.cmake | 11 - polkit-qt-agent-1.pc.cmake | 11 - polkit-qt-core-1.pc.cmake | 11 - polkit-qt-gui-1.pc.cmake | 11 - polkit-tqt-1.pc.cmake | 11 + polkit-tqt-agent-1.pc.cmake | 11 + polkit-tqt-core-1.pc.cmake | 11 + polkit-tqt-gui-1.pc.cmake | 11 + polkitqt1-export.h | 44 -- polkitqt1-version.h.cmake | 106 --- polkittqt1-export.h | 44 ++ polkittqt1-version.h.cmake | 106 +++ test/CMakeLists.txt | 14 +- test/test.cpp | 38 +- 125 files changed, 5228 insertions(+), 5576 deletions(-) delete mode 100644 PolkitQt-1Config.cmake.in create mode 100644 Polkittqt-1Config.cmake.in delete mode 100644 README.porting delete mode 100644 TODO delete mode 100644 core/polkitqt1-actiondescription.cpp delete mode 100644 core/polkitqt1-actiondescription.h delete mode 100644 core/polkitqt1-authority.cpp delete mode 100644 core/polkitqt1-authority.h delete mode 100644 core/polkitqt1-details.cpp delete mode 100644 core/polkitqt1-details.h delete mode 100644 core/polkitqt1-identity.cpp delete mode 100644 core/polkitqt1-identity.h delete mode 100644 core/polkitqt1-subject.cpp delete mode 100644 core/polkitqt1-subject.h delete mode 100644 core/polkitqt1-temporaryauthorization.cpp delete mode 100644 core/polkitqt1-temporaryauthorization.h create mode 100644 core/polkittqt1-actiondescription.cpp create mode 100644 core/polkittqt1-actiondescription.h create mode 100644 core/polkittqt1-authority.cpp create mode 100644 core/polkittqt1-authority.h create mode 100644 core/polkittqt1-details.cpp create mode 100644 core/polkittqt1-details.h create mode 100644 core/polkittqt1-identity.cpp create mode 100644 core/polkittqt1-identity.h create mode 100644 core/polkittqt1-subject.cpp create mode 100644 core/polkittqt1-subject.h create mode 100644 core/polkittqt1-temporaryauthorization.cpp create mode 100644 core/polkittqt1-temporaryauthorization.h delete mode 100644 debian/libpolkit-qt-1-1.install delete mode 100644 debian/libpolkit-qt-1-1.lintian-overrides delete mode 100644 debian/libpolkit-qt-1-1.symbols delete mode 100644 debian/libpolkit-qt-1-dev.install create mode 100644 debian/libpolkit-tqt-1-1.install create mode 100644 debian/libpolkit-tqt-1-1.lintian-overrides create mode 100644 debian/libpolkit-tqt-1-dev.install delete mode 100644 examples/org.qt.policykit.examples.conf delete mode 100644 examples/org.qt.policykit.examples.policy delete mode 100644 examples/org.qt.policykit.examples.policy.in delete mode 100644 examples/org.qt.policykit.examples.service.in delete mode 100644 examples/org.qt.policykit.examples.xml create mode 100644 examples/org.tqt.policykit.examples.conf create mode 100644 examples/org.tqt.policykit.examples.policy create mode 100644 examples/org.tqt.policykit.examples.policy.in create mode 100644 examples/org.tqt.policykit.examples.service.in create mode 100644 examples/org.tqt.policykit.examples.xml delete mode 100644 gui/polkitqt1-gui-action.cpp delete mode 100644 gui/polkitqt1-gui-action.h delete mode 100644 gui/polkitqt1-gui-actionbutton.cpp delete mode 100644 gui/polkitqt1-gui-actionbutton.h delete mode 100644 gui/polkitqt1-gui-actionbutton_p.h delete mode 100644 gui/polkitqt1-gui-actionbuttons.cpp delete mode 100644 gui/polkitqt1-gui-actionbuttons.h delete mode 100644 gui/polkitqt1-gui-actionbuttons_p.h create mode 100644 gui/polkittqt1-gui-action.cpp create mode 100644 gui/polkittqt1-gui-action.h create mode 100644 gui/polkittqt1-gui-actionbutton.cpp create mode 100644 gui/polkittqt1-gui-actionbutton.h create mode 100644 gui/polkittqt1-gui-actionbutton_p.h create mode 100644 gui/polkittqt1-gui-actionbuttons.cpp create mode 100644 gui/polkittqt1-gui-actionbuttons.h create mode 100644 gui/polkittqt1-gui-actionbuttons_p.h delete mode 100644 includes/PolkitQt1/ActionDescription delete mode 100644 includes/PolkitQt1/Agent/Listener delete mode 100644 includes/PolkitQt1/Agent/Session delete mode 100644 includes/PolkitQt1/Authority delete mode 100644 includes/PolkitQt1/Details delete mode 100644 includes/PolkitQt1/Gui/Action delete mode 100644 includes/PolkitQt1/Gui/ActionButton delete mode 100644 includes/PolkitQt1/Gui/ActionButtons delete mode 100644 includes/PolkitQt1/Identity delete mode 100644 includes/PolkitQt1/Subject delete mode 100644 includes/PolkitQt1/TemporaryAuthorization create mode 100644 includes/PolkitTQt1/ActionDescription create mode 100644 includes/PolkitTQt1/Agent/Listener create mode 100644 includes/PolkitTQt1/Agent/Session create mode 100644 includes/PolkitTQt1/Authority create mode 100644 includes/PolkitTQt1/Details create mode 100644 includes/PolkitTQt1/Gui/Action create mode 100644 includes/PolkitTQt1/Gui/ActionButton create mode 100644 includes/PolkitTQt1/Gui/ActionButtons create mode 100644 includes/PolkitTQt1/Identity create mode 100644 includes/PolkitTQt1/Subject create mode 100644 includes/PolkitTQt1/TemporaryAuthorization delete mode 100644 polkit-qt-1.pc.cmake delete mode 100644 polkit-qt-agent-1.pc.cmake delete mode 100644 polkit-qt-core-1.pc.cmake delete mode 100644 polkit-qt-gui-1.pc.cmake create mode 100644 polkit-tqt-1.pc.cmake create mode 100644 polkit-tqt-agent-1.pc.cmake create mode 100644 polkit-tqt-core-1.pc.cmake create mode 100644 polkit-tqt-gui-1.pc.cmake delete mode 100644 polkitqt1-export.h delete mode 100644 polkitqt1-version.h.cmake create mode 100644 polkittqt1-export.h create mode 100644 polkittqt1-version.h.cmake diff --git a/AUTHORS b/AUTHORS index 172f2ad39..69d666898 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1,6 @@ +Ported to TQt3 by Michele Calgaro + +Polkit-Qt original authors and contributors: Main Authors: - Daniel Nicoletti - Dario Freddi @@ -6,4 +9,4 @@ Main Authors: Contributors: - Pino Toscano - Lukas Tinkl -- Radek Novacek \ No newline at end of file +- Radek Novacek diff --git a/CMakeLists.txt b/CMakeLists.txt index cc67452f2..756f1679a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,11 @@ -## Polkit Qt Library -project("PolkitQt-1") +## Polkit TQt Library +project("PolkitTQt-1") cmake_minimum_required(VERSION 2.6.0) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH}) -set(QT_MIN_VERSION "4.4.0") +set(TQT_MIN_VERSION "4.4.0") find_package(Qt4 REQUIRED) find_package(Automoc4 REQUIRED) @@ -13,9 +13,9 @@ find_package(Polkit REQUIRED) find_package(GObject REQUIRED) find_package(GIO REQUIRED) -add_definitions(-DQT_NO_KEYWORDS) +add_definitions(-DTQT_NO_KEYWORDS) -include (${QT_USE_FILE}) +include (${TQT_USE_FILE}) include (InstallSettings) include (MacroWriteBasicCMakeVersionFile) include (CheckFunctionExists) @@ -30,7 +30,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/core ${CMAKE_CURRENT_SOURCE_DIR}/includes - ${QT_QTXML_INCLUDE_DIR} + ${TQT_TQTXML_INCLUDE_DIR} ) # Check for older polkit @@ -40,70 +40,70 @@ check_function_exists(polkit_agent_listener_register HAVE_POLKIT_AGENT_LISTENER_ check_function_exists(polkit_authority_get_sync HAVE_POLKIT_AUTHORITY_GET_SYNC) if (NOT HAVE_POLKIT_AGENT_LISTENER_REGISTER OR NOT HAVE_POLKIT_AUTHORITY_GET_SYNC) - message(STATUS "You have an older polkit-1 version: Polkit-Qt-1 will be built in compatibility mode") - add_definitions(-DPOLKIT_QT_1_COMPATIBILITY_MODE) + message(STATUS "You have an older polkit-1 version: Polkit-TQt-1 will be built in compatibility mode") + add_definitions(-DPOLKIT_TQT_1_COMPATIBILITY_MODE) endif (NOT HAVE_POLKIT_AGENT_LISTENER_REGISTER OR NOT HAVE_POLKIT_AUTHORITY_GET_SYNC) if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.6.2) option(USE_COMMON_CMAKE_PACKAGE_CONFIG_DIR "Prefer to install the Config.cmake files to lib/cmake/ instead of lib//cmake" TRUE) endif(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.6.2) -set(POLKITQT-1_VERSION_MAJOR 0 CACHE INT "PolkitQt-1's major version number" FORCE) -set(POLKITQT-1_VERSION_MINOR 103 CACHE INT "PolkitQt-1's minor version number" FORCE) -set(POLKITQT-1_VERSION_PATCH 0 CACHE INT "PolkitQt-1's release version number" FORCE) -set(POLKITQT-1_VERSION_STRING - "${POLKITQT-1_VERSION_MAJOR}.${POLKITQT-1_VERSION_MINOR}.${POLKITQT-1_VERSION_PATCH}") +set(POLKITTQT-1_VERSION_MAJOR 0 CACHE INT "PolkitTQt-1's major version number" FORCE) +set(POLKITTQT-1_VERSION_MINOR 103 CACHE INT "PolkitTQt-1's minor version number" FORCE) +set(POLKITTQT-1_VERSION_PATCH 0 CACHE INT "PolkitTQt-1's release version number" FORCE) +set(POLKITTQT-1_VERSION_STRING + "${POLKITTQT-1_VERSION_MAJOR}.${POLKITTQT-1_VERSION_MINOR}.${POLKITTQT-1_VERSION_PATCH}") # The SONUMBER of the polkit-qt-1 libraries -set(POLKITQT-1_ABI_VERSION 1) +set(POLKITTQT-1_ABI_VERSION 1) # The version number of the polkit-qt-1 libraries -set(POLKITQT-1_LIBRARY_VERSION "${POLKITQT-1_ABI_VERSION}.${POLKITQT-1_VERSION_MINOR}.${POLKITQT-1_VERSION_PATCH}") +set(POLKITTQT-1_LIBRARY_VERSION "${POLKITTQT-1_ABI_VERSION}.${POLKITTQT-1_VERSION_MINOR}.${POLKITTQT-1_VERSION_PATCH}") -configure_file(polkitqt1-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/polkitqt1-version.h) +configure_file(polkittqt1-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/polkittqt1-version.h) install(FILES - gui/polkitqt1-gui-action.h - gui/polkitqt1-gui-actionbutton.h - gui/polkitqt1-gui-actionbuttons.h + gui/polkittqt1-gui-action.h + gui/polkittqt1-gui-actionbutton.h + gui/polkittqt1-gui-actionbuttons.h - core/polkitqt1-authority.h - core/polkitqt1-details.h - core/polkitqt1-identity.h - core/polkitqt1-subject.h - core/polkitqt1-temporaryauthorization.h - core/polkitqt1-actiondescription.h + core/polkittqt1-authority.h + core/polkittqt1-details.h + core/polkittqt1-identity.h + core/polkittqt1-subject.h + core/polkittqt1-temporaryauthorization.h + core/polkittqt1-actiondescription.h - agent/polkitqt1-agent-listener.h - agent/polkitqt1-agent-session.h + agent/polkittqt1-agent-listener.h + agent/polkittqt1-agent-session.h - ${CMAKE_CURRENT_BINARY_DIR}/polkitqt1-version.h - polkitqt1-export.h + ${CMAKE_CURRENT_BINARY_DIR}/polkittqt1-version.h + polkittqt1-export.h DESTINATION ${INCLUDE_INSTALL_DIR}/polkit-qt-1 COMPONENT Devel) install(FILES - includes/PolkitQt1/Authority - includes/PolkitQt1/Details - includes/PolkitQt1/Identity - includes/PolkitQt1/Subject - includes/PolkitQt1/TemporaryAuthorization - includes/PolkitQt1/ActionDescription + includes/PolkitTQt1/Authority + includes/PolkitTQt1/Details + includes/PolkitTQt1/Identity + includes/PolkitTQt1/Subject + includes/PolkitTQt1/TemporaryAuthorization + includes/PolkitTQt1/ActionDescription DESTINATION - ${INCLUDE_INSTALL_DIR}/polkit-qt-1/PolkitQt1 COMPONENT Devel) + ${INCLUDE_INSTALL_DIR}/polkit-qt-1/PolkitTQt1 COMPONENT Devel) install(FILES - includes/PolkitQt1/Gui/Action - includes/PolkitQt1/Gui/ActionButton - includes/PolkitQt1/Gui/ActionButtons + includes/PolkitTQt1/Gui/Action + includes/PolkitTQt1/Gui/ActionButton + includes/PolkitTQt1/Gui/ActionButtons DESTINATION - ${INCLUDE_INSTALL_DIR}/polkit-qt-1/PolkitQt1/Gui COMPONENT Devel) + ${INCLUDE_INSTALL_DIR}/polkit-qt-1/PolkitTQt1/Gui COMPONENT Devel) install(FILES - includes/PolkitQt1/Agent/Listener - includes/PolkitQt1/Agent/Session + includes/PolkitTQt1/Agent/Listener + includes/PolkitTQt1/Agent/Session DESTINATION - ${INCLUDE_INSTALL_DIR}/polkit-qt-1/PolkitQt1/Agent COMPONENT Devel) + ${INCLUDE_INSTALL_DIR}/polkit-qt-1/PolkitTQt1/Agent COMPONENT Devel) if(NOT WIN32) # Pkgconfig @@ -120,21 +120,21 @@ if(NOT WIN32) endif(NOT WIN32) # CMake Config files -configure_file(PolkitQt-1Config.cmake.in "${CMAKE_BINARY_DIR}/PolkitQt-1Config.cmake" @ONLY) +configure_file(PolkitTQt-1Config.cmake.in "${CMAKE_BINARY_DIR}/PolkitTQt-1Config.cmake" @ONLY) # this file is used by to check if the installed version can be used. -macro_write_basic_cmake_version_file(${CMAKE_BINARY_DIR}/PolkitQt-1ConfigVersion.cmake - ${POLKITQT-1_VERSION_MAJOR} ${POLKITQT-1_VERSION_MINOR} ${POLKITQT-1_VERSION_PATCH}) +macro_write_basic_cmake_version_file(${CMAKE_BINARY_DIR}/PolkitTQt-1ConfigVersion.cmake + ${POLKITTQT-1_VERSION_MAJOR} ${POLKITTQT-1_VERSION_MINOR} ${POLKITTQT-1_VERSION_PATCH}) if(USE_COMMON_CMAKE_PACKAGE_CONFIG_DIR) - set(_PolkitQt-1Config_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/PolkitQt-1) + set(_PolkitTQt-1Config_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/PolkitTQt-1) else(USE_COMMON_CMAKE_PACKAGE_CONFIG_DIR) - set(_PolkitQt-1Config_INSTALL_DIR ${LIB_INSTALL_DIR}/PolkitQt-1/cmake) + set(_PolkitTQt-1Config_INSTALL_DIR ${LIB_INSTALL_DIR}/PolkitTQt-1/cmake) endif(USE_COMMON_CMAKE_PACKAGE_CONFIG_DIR) -install(FILES ${CMAKE_BINARY_DIR}/PolkitQt-1ConfigVersion.cmake - ${CMAKE_BINARY_DIR}/PolkitQt-1Config.cmake - DESTINATION ${_PolkitQt-1Config_INSTALL_DIR} ) +install(FILES ${CMAKE_BINARY_DIR}/PolkitTQt-1ConfigVersion.cmake + ${CMAKE_BINARY_DIR}/PolkitTQt-1Config.cmake + DESTINATION ${_PolkitTQt-1Config_INSTALL_DIR} ) option(BUILD_EXAMPLES "Builds a set of examples for polkit-qt-1" OFF) if (BUILD_EXAMPLES) @@ -153,4 +153,4 @@ add_subdirectory(gui) add_subdirectory(agent) # Always last! -include (PolkitQt-1Dist) +include (PolkitTQt-1Dist) diff --git a/INSTALL b/INSTALL index dc5890022..3146eb72d 100644 --- a/INSTALL +++ b/INSTALL @@ -1,6 +1,6 @@ -Polkit-qt's build system uses cmake. +Polkit-tqt's build system uses cmake. -So to compile Polkit-qt first create a build dir +So to compile Polkit-tqt first create a build dir mkdir build cd build @@ -15,7 +15,7 @@ cmake then presents a configuration summary. At this point you may want to install missing dependancies (if you do, remove the CMakeCache.txt) and run cmake again. -Finally build Polkit-qt: +Finally build Polkit-tqt: make diff --git a/Mainpage.dox b/Mainpage.dox index 90b34e08b..1fceaafdd 100644 --- a/Mainpage.dox +++ b/Mainpage.dox @@ -1,67 +1,59 @@ /** -\mainpage Polkit-qt-1 - Qt wrapper around polkit-1 +\mainpage Polkit-tqt-1 - TQt wrapper around polkit-1 -\section polkitqt1_overview Overview +\section polkittqt1_overview Overview -\note Please note that if you're developing an application on the KDE Development - Platform and not just with Qt, you might want to use KAuth (kdelibs/core/auth) - -polkit-qt-1 aims to make it easy for Qt developers to take advantage of +polkit-tqt-1 aims to make it easy for TQt developers to take advantage of polkit API. It is a convenience wrapper around QAction and QAbstractButton that lets you integrate those two components easily with polkit. -polkit-qt-1 is not a direct replacement of polkit-qt: it is based on polkit-1, which is not -backwards compatible in any way with Policykit <= 0.9, which was the backend of polkit-qt. -You are encouraged to port polkit-qt applications to polkit-qt or KAuth, if based on the KDE -Development Platform, since PolicyKit <= 0.9 is no longer maintained. - -polkit-qt-1 is split in three libraries: polkit-qt-core-1, polkit-qt-gui-1 and polkit-qt-agent-1 +polkit-tqt-1 is split in three libraries: polkit-tqt-core-1, polkit-tqt-gui-1 and polkit-tqt-agent-1 -\b polkit-qt-core-1 lets you control actions and authentication without a GUI, with some very +\b polkit-tqt-core-1 lets you control actions and authentication without a GUI, with some very simple functions. It also lets you retrieve and control useful informations on the polkit authority. You will be mostly interested in the \c Authority class. -\b polkit-qt-gui-1 lets you easily associate GUI items with polkit actions. Through some simple +\b polkit-tqt-gui-1 lets you easily associate GUI items with polkit actions. Through some simple wrapper classes you are able to associate QAction and QAbstractButton to a polkit action, and get their properties changed accordingly to polkit's result. It includes the classes Action, ActionButton and ActionButtons -\b polkit-qt-agent-1 lets you write your own polkit authentication agents in a very simple way. +\b polkit-tqt-agent-1 lets you write your own polkit authentication agents in a very simple way. -\li A sample usage of polkit-qt-1 can be found in \ref polkitqt1_example +\li A sample usage of polkit-tqt-1 can be found in \ref polkittqt1_example \li Alphabetical Class List \li Class Hierarchy -\page polkitqt1_example Polkit-qt-1 usage example +\page polkittqt1_example Polkit-tqt-1 usage example -You can find an example usage of Polkit-qt-1 in the examples/ dir. You can +You can find an example usage of Polkit-tqt-1 in the examples/ dir. You can build it by passing \c -DBUILD_EXAMPLES=TRUE to your cmake line. The structure consists of a .ui file and a main class, to demonstrate how easy it is to integrate polkit support in an existing application. Let's see some details about it: \code -bt = new ActionButton(kickPB, "org.qt.policykit.examples.kick", this); +bt = new ActionButton(kickPB, "org.tqt.policykit.examples.kick", this); bt->setText("Kick... (long)"); // here we set the behavior of PolKitResul = No bt->setVisible(true, Action::No); bt->setEnabled(true, Action::No); bt->setText("Kick (long)", Action::No); -bt->setIcon(QPixmap(":/Icons/custom-no.png"), Action::No); +bt->setIcon(TQPixmap(":/Icons/custom-no.png"), Action::No); bt->setToolTip("If your admin wasn't annoying, you could do this", Action::No); // here we set the behavior of PolKitResul = Auth bt->setVisible(true, Action::Auth); bt->setEnabled(true, Action::Auth); bt->setText("Kick... (long)", Action::Auth); -bt->setIcon(QPixmap(":/Icons/action-locked-default.png"), Action::Auth); +bt->setIcon(TQPixmap(":/Icons/action-locked-default.png"), Action::Auth); bt->setToolTip("Only card carrying tweakers can do this!", Action::Auth); // here we set the behavior of PolKitResul = Yes bt->setVisible(true, Action::Yes); bt->setEnabled(true, Action::Yes); bt->setText("Kick! (long)", Action::Yes); -bt->setIcon(QPixmap(":/Icons/custom-yes.png"), Action::Yes); +bt->setIcon(TQPixmap(":/Icons/custom-yes.png"), Action::Yes); bt->setToolTip("Go ahead, kick kick kick!", Action::Yes); \endcode @@ -70,10 +62,10 @@ UI file, \c kickPB . As you can see, you can set custom properties on your butto on the action status/result. The code is mostly self-explainatory \code -bt = new ActionButtons(QList() << listenPB << listenCB, - "org.qt.policykit.examples.listen", this); -bt->setIcon(QPixmap(":/Icons/action-locked.png")); -bt->setIcon(QPixmap(":/Icons/action-unlocked.png"), Action::Yes); +bt = new ActionButtons(TQList() << listenPB << listenCB, + "org.tqt.policykit.examples.listen", this); +bt->setIcon(TQPixmap(":/Icons/action-locked.png")); +bt->setIcon(TQPixmap(":/Icons/action-unlocked.png"), Action::Yes); bt->setText("Click to make changes..."); \endcode @@ -83,7 +75,7 @@ are kept in sync with the action. \code connect(bt, SIGNAL(triggered(bool)), this, SLOT(activateAction())); -connect(bt, SIGNAL(clicked(QAbstractButton*,bool)), bt, SLOT(activate())); +connect(bt, SIGNAL(clicked(TQAbstractButton*,bool)), bt, SLOT(activate())); connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated())); \endcode @@ -93,14 +85,12 @@ with even more ease, just by manually connecting the signal to ActionButton::act to understand why this connection doesn't happen automatically), and Action::authorized() signal notifies you when polkit has authorized you to perform the action. -As you can see, usage of polkit-qt-1 is extremely simple. Have a look at the complete example +As you can see, usage of polkit-tqt-1 is extremely simple. Have a look at the complete example and to the API Docs for more details. */ // DOXYGEN_PROJECTVERSION=0.96.1 -// DOXYGEN_PROJECTNAME=PolkitQt-1 +// DOXYGEN_PROJECTNAME=polkittqt-1 // DOXYGEN_ENABLE=YES - -// vim:ts=4:sw=4:expandtab:filetype=doxygen diff --git a/PolkitQt-1Config.cmake.in b/PolkitQt-1Config.cmake.in deleted file mode 100644 index f24e35f4b..000000000 --- a/PolkitQt-1Config.cmake.in +++ /dev/null @@ -1,41 +0,0 @@ -# PolkitTQt-1Config.cmake is generated by CMake from PolkitTQt-1Config.cmake.in. -# Any changed value in this file will be overwritten by CMake. - -# set the PolkitTQt-1 version number -set(POLKITQT-1_VERSION_MAJOR @POLKITQT-1_VERSION_MAJOR@) -set(POLKITQT-1_VERSION_MINOR @POLKITQT-1_VERSION_MINOR@) -set(POLKITQT-1_VERSION_PATCH @POLKITQT-1_VERSION_PATCH@) -set(POLKITQT-1_VERSION @POLKITQT-1_VERSION_STRING@) -set(POLKITQT-1_VERSION_STRING "@POLKITQT-1_VERSION_STRING@") - -# set the directories -if(NOT POLKITQT-1_INSTALL_DIR) - set(POLKITQT-1_INSTALL_DIR "@CMAKE_INSTALL_PREFIX@") -endif(NOT POLKITQT-1_INSTALL_DIR) - -set(POLKITQT-1_INCLUDE_DIR "@INCLUDE_INSTALL_DIR@/polkit-qt-1") -set(POLKITQT-1_LIB_DIR "@LIB_INSTALL_DIR@") -set(POLKITQT-1_POLICY_FILES_INSTALL_DIR "${POLKITQT-1_INSTALL_DIR}/share/polkit-1/actions") - -# Compatibility -if(WIN32) -if(MINGW) - set(POLKITQT-1_CORE_LIBRARY "${POLKITQT-1_LIB_DIR}/libpolkit-qt-core-1.dll.a") - set(POLKITQT-1_AGENT_LIBRARY "${POLKITQT-1_LIB_DIR}/libpolkit-qt-agent-1.dll.a") - set(POLKITQT-1_GUI_LIBRARY "${POLKITQT-1_LIB_DIR}/libpolkit-qt-gui-1.dll.a") -else(MINGW) - set(POLKITQT-1_CORE_LIBRARY "${POLKITQT-1_LIB_DIR}/polkit-qt-core-1.lib") - set(POLKITQT-1_AGENT_LIBRARY "${POLKITQT-1_LIB_DIR}/polkit-qt-agent-1.lib") - set(POLKITQT-1_GUI_LIBRARY "${POLKITQT-1_LIB_DIR}/polkit-qt-gui-1.lib") -endif(MINGW) -elseif(APPLE) - set(POLKITQT-1_CORE_LIBRARY "${POLKITQT-1_LIB_DIR}/libpolkit-qt-core-1.dylib") - set(POLKITQT-1_AGENT_LIBRARY "${POLKITQT-1_LIB_DIR}/libpolkit-qt-agent-1.dylib") - set(POLKITQT-1_GUI_LIBRARY "${POLKITQT-1_LIB_DIR}/libpolkit-qt-gui-1.dylib") -else() - set(POLKITQT-1_CORE_LIBRARY "${POLKITQT-1_LIB_DIR}/libpolkit-qt-core-1.so") - set(POLKITQT-1_AGENT_LIBRARY "${POLKITQT-1_LIB_DIR}/libpolkit-qt-agent-1.so") - set(POLKITQT-1_GUI_LIBRARY "${POLKITQT-1_LIB_DIR}/libpolkit-qt-gui-1.so") -endif() - -set(POLKITQT-1_LIBRARIES ${POLKITQT-1_GUI_LIBRARY} ${POLKITQT-1_CORE_LIBRARY} ${POLKITQT-1_AGENT_LIBRARY}) diff --git a/Polkittqt-1Config.cmake.in b/Polkittqt-1Config.cmake.in new file mode 100644 index 000000000..6b033c381 --- /dev/null +++ b/Polkittqt-1Config.cmake.in @@ -0,0 +1,41 @@ +# PolkitTQt-1Config.cmake is generated by CMake from PolkitTQt-1Config.cmake.in. +# Any changed value in this file will be overwritten by CMake. + +# set the PolkitTQt-1 version number +set(POLKITTQT-1_VERSION_MAJOR @POLKITTQT-1_VERSION_MAJOR@) +set(POLKITTQT-1_VERSION_MINOR @POLKITTQT-1_VERSION_MINOR@) +set(POLKITTQT-1_VERSION_PATCH @POLKITTQT-1_VERSION_PATCH@) +set(POLKITTQT-1_VERSION @POLKITTQT-1_VERSION_STRING@) +set(POLKITTQT-1_VERSION_STRING "@POLKITTQT-1_VERSION_STRING@") + +# set the directories +if(NOT POLKITTQT-1_INSTALL_DIR) + set(POLKITTQT-1_INSTALL_DIR "@CMAKE_INSTALL_PREFIX@") +endif(NOT POLKITTQT-1_INSTALL_DIR) + +set(POLKITTQT-1_INCLUDE_DIR "@INCLUDE_INSTALL_DIR@/polkit-tqt-1") +set(POLKITTQT-1_LIB_DIR "@LIB_INSTALL_DIR@") +set(POLKITTQT-1_POLICY_FILES_INSTALL_DIR "${POLKITTQT-1_INSTALL_DIR}/share/polkit-1/actions") + +# Compatibility +if(WIN32) +if(MINGW) + set(POLKITTQT-1_CORE_LIBRARY "${POLKITTQT-1_LIB_DIR}/libpolkit-tqt-core-1.dll.a") + set(POLKITTQT-1_AGENT_LIBRARY "${POLKITTQT-1_LIB_DIR}/libpolkit-tqt-agent-1.dll.a") + set(POLKITTQT-1_GUI_LIBRARY "${POLKITTQT-1_LIB_DIR}/libpolkit-tqt-gui-1.dll.a") +else(MINGW) + set(POLKITTQT-1_CORE_LIBRARY "${POLKITTQT-1_LIB_DIR}/polkit-tqt-core-1.lib") + set(POLKITTQT-1_AGENT_LIBRARY "${POLKITTQT-1_LIB_DIR}/polkit-tqt-agent-1.lib") + set(POLKITTQT-1_GUI_LIBRARY "${POLKITTQT-1_LIB_DIR}/polkit-tqt-gui-1.lib") +endif(MINGW) +elseif(APPLE) + set(POLKITTQT-1_CORE_LIBRARY "${POLKITTQT-1_LIB_DIR}/libpolkit-tqt-core-1.dylib") + set(POLKITTQT-1_AGENT_LIBRARY "${POLKITTQT-1_LIB_DIR}/libpolkit-tqt-agent-1.dylib") + set(POLKITTQT-1_GUI_LIBRARY "${POLKITTQT-1_LIB_DIR}/libpolkit-tqt-gui-1.dylib") +else() + set(POLKITTQT-1_CORE_LIBRARY "${POLKITTQT-1_LIB_DIR}/libpolkit-tqt-core-1.so") + set(POLKITTQT-1_AGENT_LIBRARY "${POLKITTQT-1_LIB_DIR}/libpolkit-tqt-agent-1.so") + set(POLKITTQT-1_GUI_LIBRARY "${POLKITTQT-1_LIB_DIR}/libpolkit-tqt-gui-1.so") +endif() + +set(POLKITTQT-1_LIBRARIES ${POLKITTQT-1_GUI_LIBRARY} ${POLKITTQT-1_CORE_LIBRARY} ${POLKITTQT-1_AGENT_LIBRARY}) diff --git a/README b/README index efc31d867..f7c87ad1a 100644 --- a/README +++ b/README @@ -1,10 +1,10 @@ -Polkit-qt -======== +Polkit-tqt +========== -What is Polkit-qt? +What is Polkit-tqt? ------------------ -Polkit-qt is a library that lets developers use the PolicyKit API through a nice -Qt-styled API. It is mainly a wrapper around QAction and QAbstractButton that +Polkit-tqt is a library that lets developers use the PolicyKit API through a nice +TQt-styled API. It is mainly a wrapper around TQAction and TQAbstractButton that lets you integrate those two component easily with PolicyKit This directory contains the sources of the library. @@ -14,7 +14,7 @@ Structure * cmake/ Contains the cmake checks that are needed to build the library, - and a FindPolkitQt.cmake module. + and a FindPolkitTQt.cmake module. * . Contains the sources of the library diff --git a/README.porting b/README.porting deleted file mode 100644 index d2074ea97..000000000 --- a/README.porting +++ /dev/null @@ -1,25 +0,0 @@ -Policy Kit 1 support for polkit-qt -================================== - -This is initial port to PK1. - -What's working? ---------------- -polkit-qt-core -polkit-qt-gui - -TO-DO ------ -* polkit-qt-core - - temporary authorization handling functions - - move from Auth namespace to Authority class? - - tests - -Documentation -------------- -http://fedoraproject.org/wiki/Features/PolicyKitOne -http://hal.freedesktop.org/docs/polkit/index.html - -Porting guide -------------- -http://cgit.freedesktop.org/PolicyKit/tree/docs/PORTING-GUIDE diff --git a/TODO b/TODO deleted file mode 100644 index 596936ff0..000000000 --- a/TODO +++ /dev/null @@ -1,11 +0,0 @@ -TODO -==== - -- Policy Kit 1 port - * polkit-qt - + Console Kit support - - * polkit-qt-gui - + authorization checking for non privileged user - -- document Listener and co. diff --git a/agent/CMakeLists.txt b/agent/CMakeLists.txt index 80d1bd3b2..d131071b1 100644 --- a/agent/CMakeLists.txt +++ b/agent/CMakeLists.txt @@ -3,23 +3,23 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) -set(polkit_qt_agent_SRCS - polkitqt1-agent-session.cpp - polkitqt1-agent-listener.cpp +set(polkit_tqt_agent_SRCS + polkittqt1-agent-session.cpp + polkittqt1-agent-listener.cpp listeneradapter.cpp - polkitqtlistener.cpp + polkittqtlistener.cpp ) -automoc4_add_library(polkit-qt-agent-1 SHARED ${polkit_qt_agent_SRCS}) +automoc4_add_library(polkit-tqt-agent-1 SHARED ${polkit_tqt_agent_SRCS}) -target_link_libraries(polkit-qt-agent-1 +target_link_libraries(polkit-tqt-agent-1 ${POLKIT_LIBRARIES} - ${QT_QTCORE_LIBRARY} + ${TQT_TQTCORE_LIBRARY} ${POLKIT_AGENT_LIBRARY} - polkit-qt-core-1 + polkit-tqt-core-1 ) -set_target_properties(polkit-qt-agent-1 PROPERTIES VERSION ${POLKITQT-1_LIBRARY_VERSION} - SOVERSION ${POLKITQT-1_ABI_VERSION} - DEFINE_SYMBOL MAKE_POLKITQT1_LIB) +set_target_properties(polkit-tqt-agent-1 PROPERTIES VERSION ${POLKITTQT-1_LIBRARY_VERSION} + SOVERSION ${POLKITTQT-1_ABI_VERSION} + DEFINE_SYMBOL MAKE_POLKITTQT1_LIB) -install(TARGETS polkit-qt-agent-1 ${INSTALL_TARGETS_DEFAULT_ARGS}) +install(TARGETS polkit-tqt-agent-1 ${INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/agent/listeneradapter.cpp b/agent/listeneradapter.cpp index 231d7d752..7a531dfd5 100644 --- a/agent/listeneradapter.cpp +++ b/agent/listeneradapter.cpp @@ -1,5 +1,5 @@ /* - * This file is part of the Polkit-qt project + * This file is part of the Polkit-tqt project * Copyright (C) 2009 Jaroslav Reznik * * This library is free software; you can redistribute it and/or @@ -39,7 +39,7 @@ public: ListenerAdapter *q; }; -Q_GLOBAL_STATIC(ListenerAdapterHelper, s_globalListenerAdapter) +TQ_GLOBAL_STATIC(ListenerAdapterHelper, s_globalListenerAdapter) ListenerAdapter *ListenerAdapter::instance() { @@ -61,7 +61,7 @@ Listener* ListenerAdapter::findListener(PolkitAgentListener *listener) { Listener *listItem; - Q_FOREACH(listItem, m_listeners) { + TQ_FOREACH(listItem, m_listeners) { Q_ASSERT(listItem); if (listItem->listener() == listener) { @@ -72,7 +72,7 @@ Listener* ListenerAdapter::findListener(PolkitAgentListener *listener) return NULL; } -void ListenerAdapter::polkit_qt_listener_initiate_authentication(PolkitAgentListener *listener, +void ListenerAdapter::polkit_tqt_listener_initiate_authentication(PolkitAgentListener *listener, const gchar *action_id, const gchar *message, const gchar *icon_name, @@ -82,7 +82,7 @@ void ListenerAdapter::polkit_qt_listener_initiate_authentication(PolkitAgentList GCancellable *cancellable, GSimpleAsyncResult *result) { - tqDebug() << "polkit_qt_listener_initiate_authentication callback for " << listener; + tqDebug() << "polkit_tqt_listener_initiate_authentication callback for " << listener; PolkitTQt1::Identity::List idents; PolkitTQt1::Details dets(details); @@ -102,11 +102,11 @@ void ListenerAdapter::polkit_qt_listener_initiate_authentication(PolkitAgentList new AsyncResult(result)); } -gboolean ListenerAdapter::polkit_qt_listener_initiate_authentication_finish(PolkitAgentListener *listener, +gboolean ListenerAdapter::polkit_tqt_listener_initiate_authentication_finish(PolkitAgentListener *listener, GAsyncResult *res, GError **error) { - tqDebug() << "polkit_qt_listener_initiate_authentication_finish callback for " << listener; + tqDebug() << "polkit_tqt_listener_initiate_authentication_finish callback for " << listener; GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT(res); if (g_simple_async_result_propagate_error(simple, error)) { diff --git a/agent/listeneradapter_p.h b/agent/listeneradapter_p.h index 4bf754694..ed85f0470 100644 --- a/agent/listeneradapter_p.h +++ b/agent/listeneradapter_p.h @@ -1,5 +1,5 @@ /* - * This file is part of the Polkit-qt project + * This file is part of the Polkit-tqt project * Copyright (C) 2009 Jaroslav Reznik * * This library is free software; you can redistribute it and/or @@ -23,9 +23,9 @@ #include -#include "polkitqt1-agent-listener.h" -#include "polkitqt1-identity.h" -#include "polkitqt1-details.h" +#include "polkittqt1-agent-listener.h" +#include "polkittqt1-identity.h" +#include "polkittqt1-details.h" typedef struct _GList GList; typedef struct _GCancellable GCancellable; @@ -51,7 +51,7 @@ public: static ListenerAdapter* instance(); ~ListenerAdapter() {} - void polkit_qt_listener_initiate_authentication(PolkitAgentListener *listener, + void polkit_tqt_listener_initiate_authentication(PolkitAgentListener *listener, const gchar *action_id, const gchar *message, const gchar *icon_name, @@ -61,7 +61,7 @@ public: GCancellable *cancellable, GSimpleAsyncResult *result); - gboolean polkit_qt_listener_initiate_authentication_finish(PolkitAgentListener *listener, + gboolean polkit_tqt_listener_initiate_authentication_finish(PolkitAgentListener *listener, GAsyncResult *res, GError **error); void cancelled_cb(PolkitAgentListener *listener); diff --git a/agent/polkitqt1-agent-listener.cpp b/agent/polkitqt1-agent-listener.cpp index c6bf63cba..e6e3a9b00 100644 --- a/agent/polkitqt1-agent-listener.cpp +++ b/agent/polkitqt1-agent-listener.cpp @@ -1,5 +1,5 @@ /* - * This file is part of the Polkit-qt project + * This file is part of the Polkit-tqt project * Copyright (C) 2009 Jaroslav Reznik * * This library is free software; you can redistribute it and/or @@ -18,16 +18,16 @@ * Boston, MA 02110-1301, USA. */ -#include "polkitqt1-agent-listener.h" +#include "polkittqt1-agent-listener.h" #include -#include "polkitqtlistener_p.h" +#include "polkittqtlistener_p.h" -#include "polkitqt1-authority.h" -#include "polkitqt1-subject.h" -#include "polkitqt1-identity.h" -#include "polkitqt1-details.h" +#include "polkittqt1-authority.h" +#include "polkittqt1-subject.h" +#include "polkittqt1-identity.h" +#include "polkittqt1-details.h" namespace PolkitTQt1 { @@ -39,7 +39,7 @@ class ListenerPrivate { public: PolkitAgentListener *listener; -#ifndef POLKIT_QT_1_COMPATIBILITY_MODE +#ifndef POLKIT_TQT_1_COMPATIBILITY_MODE void *registeredHandle; #endif }; @@ -49,7 +49,7 @@ Listener::Listener(TQObject *parent) { g_type_init(); - d->listener = polkit_qt_listener_new(); + d->listener = polkit_tqt_listener_new(); tqDebug() << "New PolkitAgentListener " << d->listener; @@ -69,7 +69,7 @@ Listener::~Listener() tqDebug("Destroying listener"); ListenerAdapter::instance()->removeListener(this); -#ifndef POLKIT_QT_1_COMPATIBILITY_MODE +#ifndef POLKIT_TQT_1_COMPATIBILITY_MODE if (d->registeredHandle) { polkit_agent_listener_unregister(d->registeredHandle); } @@ -83,7 +83,7 @@ bool Listener::registerListener(const PolkitTQt1::Subject &subject, const TQStri { GError *error = NULL; -#ifndef POLKIT_QT_1_COMPATIBILITY_MODE +#ifndef POLKIT_TQT_1_COMPATIBILITY_MODE d->registeredHandle = polkit_agent_listener_register(d->listener, POLKIT_AGENT_REGISTER_FLAGS_NONE, #else @@ -91,7 +91,7 @@ bool Listener::registerListener(const PolkitTQt1::Subject &subject, const TQStri #endif subject.subject(), objectPath.toAscii().data(), -#ifndef POLKIT_QT_1_COMPATIBILITY_MODE +#ifndef POLKIT_TQT_1_COMPATIBILITY_MODE NULL, #endif &error); @@ -101,7 +101,7 @@ bool Listener::registerListener(const PolkitTQt1::Subject &subject, const TQStri g_error_free(error); return false; } -#ifndef POLKIT_QT_1_COMPATIBILITY_MODE +#ifndef POLKIT_TQT_1_COMPATIBILITY_MODE if (d->registeredHandle == NULL) { tqWarning() << TQString("Cannot register authentication agent!"); return false; @@ -121,4 +121,4 @@ const PolkitAgentListener *Listener::listener() } -#include "polkitqt1-agent-listener.moc" +#include "polkittqt1-agent-listener.moc" diff --git a/agent/polkitqt1-agent-listener.h b/agent/polkitqt1-agent-listener.h index ed48509e1..a5f2a0d40 100644 --- a/agent/polkitqt1-agent-listener.h +++ b/agent/polkitqt1-agent-listener.h @@ -1,5 +1,5 @@ /* - * This file is part of the Polkit-qt project + * This file is part of the Polkit-tqt project * Copyright (C) 2009 Jaroslav Reznik * * This library is free software; you can redistribute it and/or @@ -18,14 +18,14 @@ * Boston, MA 02110-1301, USA. */ -#ifndef POLKITQT1_AGENT_LISTENER_H -#define POLKITQT1_AGENT_LISTENER_H +#ifndef POLKITTQT1_AGENT_LISTENER_H +#define POLKITTQT1_AGENT_LISTENER_H -#include "polkitqt1-export.h" +#include "polkittqt1-export.h" #include -#include "polkitqt1-agent-session.h" +#include "polkittqt1-agent-session.h" #define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1 @@ -46,7 +46,7 @@ namespace Agent class ListenerPrivate; /** - * \class Listener polkitqt1-agent-listener.h Listener + * \class Listener polkittqt1-agent-listener.h Listener * \author Jaroslav Reznik * * \brief Listener is abstract class used for implementing authentication agents. @@ -58,7 +58,7 @@ class ListenerPrivate; * You can also use Session class to authenticate users however it isn't required. * \sa Session */ -class POLKITQT1_EXPORT Listener : public TQObject +class POLKITTQT1_EXPORT Listener : public TQObject { Q_OBJECT TQ_DISABLE_COPY(Listener) @@ -91,7 +91,7 @@ public: * * \param subject Subject that listener will be registered for * \param objectPath DBus object path - * \return \c True if the polkitqt1-agent-listener.has been registered, \c False otherwise + * \return \c True if the polkittqt1-agent-listener.has been registered, \c False otherwise */ bool registerListener(const PolkitTQt1::Subject &subject, const TQString &objectPath); diff --git a/agent/polkitqt1-agent-session.cpp b/agent/polkitqt1-agent-session.cpp index add3d95b1..c39600ff2 100644 --- a/agent/polkitqt1-agent-session.cpp +++ b/agent/polkitqt1-agent-session.cpp @@ -1,5 +1,5 @@ /* - * This file is part of the PolKit1-qt project + * This file is part of the PolKit1-tqt project * Copyright (C) 2009 Radek Novacek * * This library is free software; you can redistribute it and/or @@ -18,11 +18,11 @@ * Boston, MA 02110-1301, USA. */ -#include "polkitqt1-agent-session.h" +#include "polkittqt1-agent-session.h" #include -#include "polkitqt1-identity.h" +#include "polkittqt1-identity.h" #define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1 #include @@ -104,7 +104,7 @@ void Session::Private::completed(PolkitAgentSession *s, gboolean gained_authoriz { tqDebug() << "COMPLETED"; Session *session = (Session *)user_data; - Q_EMIT(session)->completed(gained_authorization); + TQ_EMIT(session)->completed(gained_authorization); //free session here as polkit documentation asks g_object_unref(session->d->polkitAgentSession); @@ -114,19 +114,19 @@ void Session::Private::completed(PolkitAgentSession *s, gboolean gained_authoriz void Session::Private::request(PolkitAgentSession *s, gchar *request, gboolean echo_on, gpointer user_data) { tqDebug() << "REQUEST"; - Q_EMIT((Session *)user_data)->request(TQString::fromUtf8(request), echo_on); + TQ_EMIT((Session *)user_data)->request(TQString::fromUtf8(request), echo_on); } void Session::Private::showError(PolkitAgentSession *s, gchar *text, gpointer user_data) { tqDebug() << "showError"; - Q_EMIT((Session *)user_data)->showError(TQString::fromUtf8(text)); + TQ_EMIT((Session *)user_data)->showError(TQString::fromUtf8(text)); } void Session::Private::showInfo(PolkitAgentSession *s, gchar *text, gpointer user_data) { tqDebug() << "showInfo"; - Q_EMIT((Session *)user_data)->showInfo(TQString::fromUtf8(text)); + TQ_EMIT((Session *)user_data)->showInfo(TQString::fromUtf8(text)); } // @@ -166,4 +166,4 @@ void AsyncResult::setError(const TQString &text) g_simple_async_result_set_error(d->result, POLKIT_ERROR, POLKIT_ERROR_FAILED, "%s", text.toUtf8().data()); } -#include "polkitqt1-agent-session.moc" +#include "polkittqt1-agent-session.moc" diff --git a/agent/polkitqt1-agent-session.h b/agent/polkitqt1-agent-session.h index f4f4ff49c..a40b5b867 100644 --- a/agent/polkitqt1-agent-session.h +++ b/agent/polkitqt1-agent-session.h @@ -1,5 +1,5 @@ /* - * This file is part of the PolKit1-qt project + * This file is part of the PolKit1-tqt project * Copyright (C) 2009 Radek Novacek * * This library is free software; you can redistribute it and/or @@ -18,11 +18,11 @@ * Boston, MA 02110-1301, USA. */ -#ifndef POLKITQT1_AGENT_SESSION_H -#define POLKITQT1_AGENT_SESSION_H +#ifndef POLKITTQT1_AGENT_SESSION_H +#define POLKITTQT1_AGENT_SESSION_H #include -#include "polkitqt1-identity.h" +#include "polkittqt1-identity.h" typedef struct _GSimpleAsyncResult GSimpleAsyncResult; typedef struct _PolkitAgentSession PolkitAgentSession; @@ -45,7 +45,7 @@ namespace Agent * \internal * \brief Encapsulation of GSimpleAsyncResult to TQObject class */ -class POLKITQT1_EXPORT AsyncResult +class POLKITTQT1_EXPORT AsyncResult { public: explicit AsyncResult(GSimpleAsyncResult *result); @@ -70,14 +70,14 @@ private: }; /** - * \class Session polkitqt1-agent-session.h Session + * \class Session polkittqt1-agent-session.h Session * \author Radek Novacek * * This class is interface for interacting with native * authentication system for obtaining authorizations. * */ -class POLKITQT1_EXPORT Session : public TQObject +class POLKITTQT1_EXPORT Session : public TQObject { Q_OBJECT TQ_DISABLE_COPY(Session) @@ -137,7 +137,7 @@ public: Q_SIGNALS: /** * This signal will be emitted when the authentication - * polkitqt1-agent-session.has been completed or cancelled. + * polkittqt1-agent-session.has been completed or cancelled. * * \param gainedAuthorization \c True if authorization was successfully obtained. */ diff --git a/agent/polkitqtlistener.cpp b/agent/polkitqtlistener.cpp index ea0ad2dbf..dc5beb052 100644 --- a/agent/polkitqtlistener.cpp +++ b/agent/polkitqtlistener.cpp @@ -1,5 +1,5 @@ /* - * This file is part of the Polkit-qt project + * This file is part of the Polkit-tqt project * Copyright (C) 2009 Jaroslav Reznik * * This library is free software; you can redistribute it and/or @@ -17,11 +17,11 @@ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * - * polkit-qt-listener based on code by David Zeuthen + * polkit-tqt-listener based on code by David Zeuthen */ -#include "polkitqtlistener_p.h" +#include "polkittqtlistener_p.h" #include #include @@ -44,7 +44,7 @@ struct _PolkitTQtListenerClass { PolkitAgentListenerClass parent_class; }; -static void polkit_qt_listener_initiate_authentication(PolkitAgentListener *listener, +static void polkit_tqt_listener_initiate_authentication(PolkitAgentListener *listener, const gchar *action_id, const gchar *message, const gchar *icon_name, @@ -55,29 +55,29 @@ static void polkit_qt_listener_initiate_authentication(PolkitAgentListener *lis GAsyncReadyCallback callback, gpointer user_data); -static gboolean polkit_qt_listener_initiate_authentication_finish(PolkitAgentListener *listener, +static gboolean polkit_tqt_listener_initiate_authentication_finish(PolkitAgentListener *listener, GAsyncResult *res, GError **error); -G_DEFINE_TYPE(PolkitTQtListener, polkit_qt_listener, POLKIT_AGENT_TYPE_LISTENER); +G_DEFINE_TYPE(PolkitTQtListener, polkit_tqt_listener, POLKIT_AGENT_TYPE_LISTENER); -static void polkit_qt_listener_init(PolkitTQtListener *listener) +static void polkit_tqt_listener_init(PolkitTQtListener *listener) { g_type_init(); } -static void polkit_qt_listener_finalize(GObject *object) +static void polkit_tqt_listener_finalize(GObject *object) { PolkitTQtListener *listener; - listener = POLKIT_QT_LISTENER(object); + listener = POLKIT_TQT_LISTENER(object); - if (G_OBJECT_CLASS(polkit_qt_listener_parent_class)->finalize != NULL) { - G_OBJECT_CLASS(polkit_qt_listener_parent_class)->finalize(object); + if (G_OBJECT_CLASS(polkit_tqt_listener_parent_class)->finalize != NULL) { + G_OBJECT_CLASS(polkit_tqt_listener_parent_class)->finalize(object); } } -static void polkit_qt_listener_class_init(PolkitTQtListenerClass *klass) +static void polkit_tqt_listener_class_init(PolkitTQtListenerClass *klass) { GObjectClass *gobject_class; PolkitAgentListenerClass *listener_class; @@ -85,15 +85,15 @@ static void polkit_qt_listener_class_init(PolkitTQtListenerClass *klass) gobject_class = G_OBJECT_CLASS(klass); listener_class = POLKIT_AGENT_LISTENER_CLASS(klass); - gobject_class->finalize = polkit_qt_listener_finalize; + gobject_class->finalize = polkit_tqt_listener_finalize; - listener_class->initiate_authentication = polkit_qt_listener_initiate_authentication; - listener_class->initiate_authentication_finish = polkit_qt_listener_initiate_authentication_finish; + listener_class->initiate_authentication = polkit_tqt_listener_initiate_authentication; + listener_class->initiate_authentication_finish = polkit_tqt_listener_initiate_authentication_finish; } -PolkitAgentListener *polkit_qt_listener_new(void) +PolkitAgentListener *polkit_tqt_listener_new(void) { - return POLKIT_AGENT_LISTENER(g_object_new(POLKIT_QT_TYPE_LISTENER, NULL)); + return POLKIT_AGENT_LISTENER(g_object_new(POLKIT_TQT_TYPE_LISTENER, NULL)); } static void cancelled_cb(GCancellable *cancellable, gpointer user_data) @@ -101,7 +101,7 @@ static void cancelled_cb(GCancellable *cancellable, gpointer user_data) ListenerAdapter::instance()->cancelled_cb((PolkitAgentListener *)user_data); } -static void polkit_qt_listener_initiate_authentication(PolkitAgentListener *agent_listener, +static void polkit_tqt_listener_initiate_authentication(PolkitAgentListener *agent_listener, const gchar *action_id, const gchar *message, const gchar *icon_name, @@ -112,14 +112,14 @@ static void polkit_qt_listener_initiate_authentication(PolkitAgentListener *age GAsyncReadyCallback callback, gpointer user_data) { - tqDebug() << "Listener adapter polkit_qt_listener_initiate_authentication"; - PolkitTQtListener *listener = POLKIT_QT_LISTENER(agent_listener); + tqDebug() << "Listener adapter polkit_tqt_listener_initiate_authentication"; + PolkitTQtListener *listener = POLKIT_TQT_LISTENER(agent_listener); // The result of asynchronous method will be created here and it will be pushed to the listener. GSimpleAsyncResult *result = g_simple_async_result_new((GObject *) listener, callback, user_data, agent_listener); tqDebug() << "GSimpleAsyncResult:" << result; - ListenerAdapter::instance()->polkit_qt_listener_initiate_authentication(agent_listener, + ListenerAdapter::instance()->polkit_tqt_listener_initiate_authentication(agent_listener, action_id, message, icon_name, @@ -138,12 +138,12 @@ static void polkit_qt_listener_initiate_authentication(PolkitAgentListener *age } -static gboolean polkit_qt_listener_initiate_authentication_finish(PolkitAgentListener *listener, +static gboolean polkit_tqt_listener_initiate_authentication_finish(PolkitAgentListener *listener, GAsyncResult *res, GError **error) { - tqDebug() << "Listener adapter polkit_qt_listener_initiate_authentication_finish"; - return ListenerAdapter::instance()->polkit_qt_listener_initiate_authentication_finish(listener, + tqDebug() << "Listener adapter polkit_tqt_listener_initiate_authentication_finish"; + return ListenerAdapter::instance()->polkit_tqt_listener_initiate_authentication_finish(listener, res, error); } diff --git a/agent/polkitqtlistener_p.h b/agent/polkitqtlistener_p.h index c289b3973..b9f7faace 100644 --- a/agent/polkitqtlistener_p.h +++ b/agent/polkitqtlistener_p.h @@ -1,5 +1,5 @@ /* - * This file is part of the Polkit-qt project + * This file is part of the Polkit-tqt project * Copyright (C) 2009 Jaroslav Reznik * * This library is free software; you can redistribute it and/or @@ -17,11 +17,11 @@ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * - * polkit-qt-listener based on code by David Zeuthen + * polkit-tqt-listener based on code by David Zeuthen */ -#ifndef POLKIQT_LISTENER_P_H -#define POLKIQT_LISTENER_P_H +#ifndef POLKITTQT_LISTENER_P_H +#define POLKITTQT_LISTENER_P_H #define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1 @@ -31,19 +31,19 @@ G_BEGIN_DECLS -#define POLKIT_QT_TYPE_LISTENER (polkit_qt_listener_get_type()) -#define POLKIT_QT_LISTENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_QT_TYPE_LISTENER, PolkitTQtListener)) -#define POLKIT_QT_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_QT_TYPE_LISTENER, PolkitTQtListenerClass)) -#define POLKIT_QT_LISTENER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_QT_TYPE_LISTENER, PolkitTQtListenerClass)) -#define POLKIT_QT_IS_LISTENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_QT_TYPE_LISTENER)) -#define POLKIT_QT_IS_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_QT_TYPE_LISTENER)) +#define POLKIT_TQT_TYPE_LISTENER (polkit_tqt_listener_get_type()) +#define POLKIT_TQT_LISTENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_TQT_TYPE_LISTENER, PolkitTQtListener)) +#define POLKIT_TQT_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_TQT_TYPE_LISTENER, PolkitTQtListenerClass)) +#define POLKIT_TQT_LISTENER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_TQT_TYPE_LISTENER, PolkitTQtListenerClass)) +#define POLKIT_TQT_IS_LISTENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_TQT_TYPE_LISTENER)) +#define POLKIT_TQT_IS_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_TQT_TYPE_LISTENER)) typedef struct _PolkitTQtListener PolkitTQtListener; typedef struct _PolkitTQtListenerClass PolkitTQtListenerClass; -GType polkit_qt_listener_get_type(void) G_GNUC_CONST; -PolkitAgentListener *polkit_qt_listener_new(void); +GType polkit_tqt_listener_get_type(void) G_GNUC_CONST; +PolkitAgentListener *polkit_tqt_listener_new(void); G_END_DECLS -#endif /* POLKIT_QT_LISTENER_H */ +#endif /* POLKIT_TQT_LISTENER_H */ diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt index 37511d618..fe17d7a0b 100644 --- a/cmake/modules/CMakeLists.txt +++ b/cmake/modules/CMakeLists.txt @@ -1,7 +1,7 @@ ## install the cmake files -#file( GLOB cmakeFiles FindPolkitQt.cmake ) +#file( GLOB cmakeFiles FindPolkitTQt.cmake ) #set(module_install_dir ${CMAKE_ROOT}/Modules ) #install( FILES ${cmakeFiles} diff --git a/cmake/modules/FindPolkitQt-1.cmake b/cmake/modules/FindPolkitQt-1.cmake index f28c494e4..2ba20aab4 100644 --- a/cmake/modules/FindPolkitQt-1.cmake +++ b/cmake/modules/FindPolkitQt-1.cmake @@ -1,13 +1,13 @@ # - Try to find PolkitTQt-1 # Once done this will define # -# POLKITQT-1_FOUND - system has Polkit-qt -# POLKITQT-1_INCLUDE_DIR - the Polkit-qt include directory -# POLKITQT-1_LIBRARIES - Link these to use all Polkit-qt libs -# POLKITQT-1_CORE_LIBRARY - Link this to use the polkit-qt-core library only -# POLKITQT-1_GUI_LIBRARY - Link this to use GUI elements in polkit-qt (polkit-qt-gui) -# POLKITQT-1_AGENT_LIBRARY - Link this to use the agent wrapper in polkit-qt -# POLKITQT-1_DEFINITIONS - Compiler switches required for using Polkit-qt +# POLKITTQT-1_FOUND - system has Polkit-tqt +# POLKITTQT-1_INCLUDE_DIR - the Polkit-tqt include directory +# POLKITTQT-1_LIBRARIES - Link these to use all Polkit-tqt libs +# POLKITTQT-1_CORE_LIBRARY - Link this to use the polkit-tqt-core library only +# POLKITTQT-1_GUI_LIBRARY - Link this to use GUI elements in polkit-tqt (polkit-tqt-gui) +# POLKITTQT-1_AGENT_LIBRARY - Link this to use the agent wrapper in polkit-tqt +# POLKITTQT-1_DEFINITIONS - Compiler switches required for using Polkit-tqt # # The minimum required version of PolkitTQt-1 can be specified using the # standard syntax, e.g. find_package(PolkitTQt-1 1.0) @@ -17,10 +17,10 @@ # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. -# Support POLKITQT-1_MIN_VERSION for compatibility: -if ( NOT PolkitTQt-1_FIND_VERSION AND POLKITQT-1_MIN_VERSION ) - set ( PolkitTQt-1_FIND_VERSION ${POLKITQT-1_MIN_VERSION} ) -endif ( NOT PolkitTQt-1_FIND_VERSION AND POLKITQT-1_MIN_VERSION ) +# Support POLKITTQT-1_MIN_VERSION for compatibility: +if ( NOT PolkitTQt-1_FIND_VERSION AND POLKITTQT-1_MIN_VERSION ) + set ( PolkitTQt-1_FIND_VERSION ${POLKITTQT-1_MIN_VERSION} ) +endif ( NOT PolkitTQt-1_FIND_VERSION AND POLKITTQT-1_MIN_VERSION ) set( _PolkitTQt-1_FIND_QUIETLY ${PolkitTQt-1_FIND_QUIETLY} ) find_package( PolkitTQt-1 ${PolkitTQt-1_FIND_VERSION} TQUIET NO_MODULE PATHS ${LIB_INSTALL_DIR}/PolkitTQt-1/cmake ) @@ -29,9 +29,9 @@ set( PolkitTQt-1_FIND_QUIETLY ${_PolkitTQt-1_FIND_QUIETLY} ) include( FindPackageHandleStandardArgs ) find_package_handle_standard_args( PolkitTQt-1 DEFAULT_MSG PolkitTQt-1_CONFIG ) -if (POLKITQT-1_FOUND) - if (NOT POLKITQT-1_INSTALL_DIR STREQUAL CMAKE_INSTALL_PREFIX) +if (POLKITTQT-1_FOUND) + if (NOT POLKITTQT-1_INSTALL_DIR STREQUAL CMAKE_INSTALL_PREFIX) message("WARNING: Installation prefix does not match PolicyKit install prefixes. You probably will need to move files installed " - "in POLICY_FILES_INSTALL_DIR and by dbus_add_activation_system_service to the ${POLKITQT-1_INSTALL_DIR} prefix") - endif (NOT POLKITQT-1_INSTALL_DIR STREQUAL CMAKE_INSTALL_PREFIX) -endif (POLKITQT-1_FOUND) + "in POLICY_FILES_INSTALL_DIR and by dbus_add_activation_system_service to the ${POLKITTQT-1_INSTALL_DIR} prefix") + endif (NOT POLKITTQT-1_INSTALL_DIR STREQUAL CMAKE_INSTALL_PREFIX) +endif (POLKITTQT-1_FOUND) diff --git a/cmake/modules/PolkitQt-1Dist.cmake b/cmake/modules/PolkitQt-1Dist.cmake index 99122ddfd..ea23fe5cd 100644 --- a/cmake/modules/PolkitQt-1Dist.cmake +++ b/cmake/modules/PolkitQt-1Dist.cmake @@ -1,13 +1,13 @@ -SET(CPACK_PACKAGE_NAME "polkit-qt-1") -SET(CPACK_PACKAGE_VERSION_MAJOR "${POLKITQT-1_VERSION_MAJOR}") -SET(CPACK_PACKAGE_VERSION_MINOR "${POLKITQT-1_VERSION_MINOR}") -SET(CPACK_PACKAGE_VERSION_PATCH "${POLKITQT-1_VERSION_PATCH}") +SET(CPACK_PACKAGE_NAME "polkit-tqt-1") +SET(CPACK_PACKAGE_VERSION_MAJOR "${POLKITTQT-1_VERSION_MAJOR}") +SET(CPACK_PACKAGE_VERSION_MINOR "${POLKITTQT-1_VERSION_MINOR}") +SET(CPACK_PACKAGE_VERSION_PATCH "${POLKITTQT-1_VERSION_PATCH}") set(CPACK_SOURCE_GENERATOR "TBZ2") -set(CPACK_SOURCE_PACKAGE_FILE_NAME "polkit-qt-1-${POLKITQT-1_VERSION_MAJOR}.${POLKITQT-1_VERSION_MINOR}.${POLKITQT-1_VERSION_PATCH}") +set(CPACK_SOURCE_PACKAGE_FILE_NAME "polkit-tqt-1-${POLKITTQT-1_VERSION_MAJOR}.${POLKITTQT-1_VERSION_MINOR}.${POLKITTQT-1_VERSION_PATCH}") set(CPACK_SOURCE_IGNORE_FILES "/\\\\.svn/" "/\\\\.git/" "makechangelog") -set(ARCHIVE_NAME ${CPACK_PACKAGE_NAME}-${POLKITQT-1_VERSION_STRING}) +set(ARCHIVE_NAME ${CPACK_PACKAGE_NAME}-${POLKITTQT-1_VERSION_STRING}) add_custom_target(dist COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD | bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2 diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index f2efca4de..feca7c96d 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -3,29 +3,29 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) -set(polkit_qt_core_SRCS - polkitqt1-authority.cpp - polkitqt1-identity.cpp - polkitqt1-subject.cpp - polkitqt1-temporaryauthorization.cpp - polkitqt1-details.cpp - polkitqt1-actiondescription.cpp +set(polkit_tqt_core_SRCS + polkittqt1-authority.cpp + polkittqt1-identity.cpp + polkittqt1-subject.cpp + polkittqt1-temporaryauthorization.cpp + polkittqt1-details.cpp + polkittqt1-actiondescription.cpp ) -automoc4_add_library(polkit-qt-core-1 SHARED ${polkit_qt_core_SRCS}) +automoc4_add_library(polkit-tqt-core-1 SHARED ${polkit_tqt_core_SRCS}) -target_link_libraries(polkit-qt-core-1 - ${QT_QTCORE_LIBRARY} - ${QT_QTDBUS_LIBRARY} - ${QT_QTXML_LIBRARY} +target_link_libraries(polkit-tqt-core-1 + ${TQT_TQTCORE_LIBRARY} + ${TQT_TQTDBUS_LIBRARY} + ${TQT_TQTXML_LIBRARY} ${POLKIT_LIBRARIES} ${GLIB2_LIBRARIES} ${GOBJECT_LIBRARIES} ${GIO_LIBRARIES} ) -set_target_properties(polkit-qt-core-1 PROPERTIES VERSION ${POLKITQT-1_LIBRARY_VERSION} - SOVERSION ${POLKITQT-1_ABI_VERSION} - DEFINE_SYMBOL MAKE_POLKITQT1_LIB) +set_target_properties(polkit-tqt-core-1 PROPERTIES VERSION ${POLKITTQT-1_LIBRARY_VERSION} + SOVERSION ${POLKITTQT-1_ABI_VERSION} + DEFINE_SYMBOL MAKE_POLKITTQT1_LIB) -install(TARGETS polkit-qt-core-1 ${INSTALL_TARGETS_DEFAULT_ARGS}) +install(TARGETS polkit-tqt-core-1 ${INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/core/polkitqt1-actiondescription.cpp b/core/polkitqt1-actiondescription.cpp deleted file mode 100644 index 764510668..000000000 --- a/core/polkitqt1-actiondescription.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * This file is part of the Polkit-qt project - * Copyright (C) 2009 Jaroslav Reznik - * Copyright (C) 2010 Dario Freddi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "polkitqt1-actiondescription.h" - -#include - -#include - -namespace PolkitTQt1 -{ - -class ActionDescription::Data : public TQSharedData -{ -public: - Data() {} - Data(const Data& other) - : TQSharedData(other) - , actionId(other.actionId) - , description(other.description) - , message(other.message) - , vendorName(other.vendorName) - , vendorUrl(other.vendorUrl) - , iconName(other.iconName) - , implicitAny(other.implicitAny) - , implicitInactive(other.implicitInactive) - , implicitActive(other.implicitActive) - { - } - virtual ~Data() {} - - TQString actionId; - TQString description; - TQString message; - TQString vendorName; - TQString vendorUrl; - TQString iconName; - - ActionDescription::ImplicitAuthorization implicitAny; - ActionDescription::ImplicitAuthorization implicitInactive; - ActionDescription::ImplicitAuthorization implicitActive; -}; - -ActionDescription::ActionDescription() - : d(new Data) -{ - -} - -ActionDescription::ActionDescription(PolkitActionDescription *polkitActionDescription) - : d(new Data) -{ - g_type_init(); - - d->actionId = TQString::fromUtf8(polkit_action_description_get_action_id(polkitActionDescription)); - d->description = TQString::fromUtf8(polkit_action_description_get_description(polkitActionDescription)); - d->message = TQString::fromUtf8(polkit_action_description_get_message(polkitActionDescription)); - d->vendorName = TQString::fromUtf8(polkit_action_description_get_vendor_name(polkitActionDescription)); - d->vendorUrl = TQString::fromUtf8(polkit_action_description_get_vendor_url(polkitActionDescription)); - d->iconName = TQString::fromUtf8(polkit_action_description_get_icon_name(polkitActionDescription)); - - d->implicitAny = static_cast(polkit_action_description_get_implicit_any( - polkitActionDescription)); - d->implicitInactive = static_cast(polkit_action_description_get_implicit_inactive( - polkitActionDescription)); - d->implicitActive = static_cast(polkit_action_description_get_implicit_active( - polkitActionDescription)); -} - -ActionDescription::ActionDescription(const PolkitTQt1::ActionDescription& other) - : d(other.d) -{ -} - -ActionDescription& ActionDescription::operator=(const PolkitTQt1::ActionDescription& other) -{ - d = other.d; - return *this; -} - -ActionDescription::~ActionDescription() -{ -} - -TQString ActionDescription::actionId() const -{ - return d->actionId; -} - -TQString ActionDescription::description() const -{ - return d->description; -} - -TQString ActionDescription::message() const -{ - return d->message; -} - -TQString ActionDescription::vendorName() const -{ - return d->vendorName; -} - -TQString ActionDescription::vendorUrl() const -{ - return d->vendorUrl; -} - -TQString ActionDescription::iconName() const -{ - return d->iconName; -} - -ActionDescription::ImplicitAuthorization ActionDescription::implicitAny() const -{ - return d->implicitAny; -} - -ActionDescription::ImplicitAuthorization ActionDescription::implicitInactive() const -{ - return d->implicitInactive; -} - -ActionDescription::ImplicitAuthorization ActionDescription::implicitActive() const -{ - return d->implicitActive; -} - -} diff --git a/core/polkitqt1-actiondescription.h b/core/polkitqt1-actiondescription.h deleted file mode 100644 index fac4812fb..000000000 --- a/core/polkitqt1-actiondescription.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * This file is part of the Polkit-qt project - * Copyright (C) 2009 Jaroslav Reznik - * Copyright (C) 2010 Dario Freddi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef POLKITQT1_ACTION_DESCRIPTION_H -#define POLKITQT1_ACTION_DESCRIPTION_H - -#include "polkitqt1-export.h" - -#include -#include -#include - -typedef struct _PolkitActionDescription PolkitActionDescription; - -namespace PolkitTQt1 -{ -/** - * \class ActionDescription polkitqt1-actiondescription.h ActionDescription - * \author Jaroslav Reznik - * \author Dario Freddi - * - * \brief Class used to encapsulate a registered action. - */ -class POLKITQT1_EXPORT ActionDescription -{ -public: - enum ImplicitAuthorization { - /** Unknown whether the subject is authorized, never returned in any public API. **/ - Unknown = -1, - /** Subject is not authorized. **/ - NotAuthorized = 0, - /** Authentication is required. **/ - AuthenticationRequired = 1, - /** Authentication as an administrator is required. **/ - AdministratorAuthenticationRequired = 2, - /** Authentication is required. If the authorization is obtained, it is retained. **/ - AuthenticationRequiredRetained = 3, - /** Authentication as an administrator is required. If the authorization is obtained, it is retained. **/ - AdministratorAuthenticationRequiredRetained = 4, - /** The subject is authorized. **/ - Authorized = 5 - }; - - typedef TQList< ActionDescription > List; - - ActionDescription(); - /** - * \brief Constructor of ActionDescription object from PolkitActionDescription - * - * \warning Use this only if you are completely aware of what are you doing! - * - * \param actionDesciption PolkitActionDescription - */ - explicit ActionDescription(PolkitActionDescription *actionDescription); - ActionDescription(const ActionDescription &other); - ~ActionDescription(); - - ActionDescription &operator=(const ActionDescription &other); - - /** - * \brief Gets the action id for ActionDescription - * - * \return id of the action - */ - TQString actionId() const; - - /** - * \brief Gets the description used of ActionDescription - * - * \return description of the action - */ - TQString description() const; - - /** - * \brief Gets the message user for ActionDescription - * - * \return action message - */ - TQString message() const; - - /** - * \brief Gets the vendor name for ActionDescription, if any - * - * \return vendor name - */ - TQString vendorName() const; - - /** - * \brief Gets the vendor URL for ActionDescription, if any - * - * \return vendor URL or empty TQString if there is no vendor URL - */ - TQString vendorUrl() const; - - /** - * \brief Gets the icon name for ActionDescription, if any - * - * \return icon name or empty TQString if there is no icon - */ - TQString iconName() const; - - /** - * \brief Gets the implicit authorization for ActionDescription used for any subject - * - * \return A value from ImplicitAuthorization enumeration - */ - ActionDescription::ImplicitAuthorization implicitAny() const; - - /** - * \brief Gets the implicit authorization for ActionDescription used for subjects in inactive session on a local console - * - * \return A value from ImplicitAuthorization enumeration - */ - ActionDescription::ImplicitAuthorization implicitInactive() const; - - /** - * \brief Gets the implicit authorization for ActionDescription used for subjects in active session on a local console - * - * \return A value from ImplicitAuthorization enumeration - */ - ActionDescription::ImplicitAuthorization implicitActive() const; - -private: - class Data; - TQSharedDataPointer< Data > d; -}; -} - -Q_DECLARE_METATYPE(PolkitTQt1::ActionDescription::List) - -#endif //POLKIT_QT_ACTION_DESCRIPTION_H diff --git a/core/polkitqt1-authority.cpp b/core/polkitqt1-authority.cpp deleted file mode 100644 index d7cf300b8..000000000 --- a/core/polkitqt1-authority.cpp +++ /dev/null @@ -1,855 +0,0 @@ -/* - * This file is part of the Polkit-qt project - * Copyright (C) 2009 Daniel Nicoletti - * Copyright (C) 2009 Dario Freddi - * Copyright (C) 2009 Jaroslav Reznik - * Copyright (C) 2009 Radek Novacek - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "polkitqt1-authority.h" - -#include -#include - -#include - -namespace PolkitTQt1 -{ - -class AuthorityHelper -{ -public: - AuthorityHelper() : q(0) {} - ~AuthorityHelper() { - delete q; - } - Authority *q; -}; - -Q_GLOBAL_STATIC(AuthorityHelper, s_globalAuthority) - -Authority *Authority::instance(PolkitAuthority *authority) -{ - if (!s_globalAuthority()->q) { - new Authority(authority); - } - - return s_globalAuthority()->q; -} - -Authority::Result polkitResultToResult(PolkitAuthorizationResult *result) -{ - if (polkit_authorization_result_get_is_challenge(result)) { - return Authority::Challenge; - } else if (polkit_authorization_result_get_is_authorized(result)) { - return Authority::Yes; - } else { - return Authority::No; - } -} - -ActionDescription::List actionsToListAndFree(GList *glist) -{ - ActionDescription::List result; - for (GList *glist2 = glist; glist2; glist2 = g_list_next(glist2)) { - gpointer i = glist2->data; - result.append(ActionDescription(static_cast(i))); - g_object_unref(i); - } - - g_list_free(glist); - return result; -} - -class Authority::Private -{ -public: - // Polkit will return NULL on failures, hence we use it instead of 0 - Private(Authority *qq) : q(qq) - , pkAuthority(NULL) - , m_hasError(false) {} - - ~Private(); - - void init(); - - /** Use this method to set the error message to \p message. Set recover to \c true - * to try to reinitialize this object with init() method - */ - void setError(Authority::ErrorCode code, const TQString &details = TQString(), bool recover = false); - - void dbusFilter(const TQDBusMessage &message); - void dbusSignalAdd(const TQString &service, const TQString &path, const TQString &interface, const TQString &name); - void seatSignalsConnect(const TQString &seat); - - Authority *q; - PolkitAuthority *pkAuthority; - bool m_hasError; - Authority::ErrorCode m_lastError; - TQString m_errorDetails; - TQDBusConnection *m_systemBus; - GCancellable *m_checkAuthorizationCancellable, - *m_enumerateActionsCancellable, - *m_registerAuthenticationAgentCancellable, - *m_unregisterAuthenticationAgentCancellable, - *m_authenticationAgentResponseCancellable, - *m_enumerateTemporaryAuthorizationsCancellable, - *m_revokeTemporaryAuthorizationsCancellable, - *m_revokeTemporaryAuthorizationCancellable; - - - static void pk_config_changed(); - static void checkAuthorizationCallback(GObject *object, GAsyncResult *result, gpointer user_data); - static void enumerateActionsCallback(GObject *object, GAsyncResult *result, gpointer user_data); - static void registerAuthenticationAgentCallback(GObject *object, GAsyncResult *result, gpointer user_data); - static void unregisterAuthenticationAgentCallback(GObject *object, GAsyncResult *result, gpointer user_data); - static void authenticationAgentResponseCallback(GObject *object, GAsyncResult *result, gpointer user_data); - static void enumerateTemporaryAuthorizationsCallback(GObject *object, GAsyncResult *result, gpointer user_data); - static void revokeTemporaryAuthorizationsCallback(GObject *object, GAsyncResult *result, gpointer user_data); - static void revokeTemporaryAuthorizationCallback(GObject *object, GAsyncResult *result, gpointer user_data); -}; - -Authority::Private::~Private() -{ - g_object_unref(m_checkAuthorizationCancellable); - g_object_unref(m_enumerateActionsCancellable); - g_object_unref(m_registerAuthenticationAgentCancellable); - g_object_unref(m_unregisterAuthenticationAgentCancellable); - g_object_unref(m_authenticationAgentResponseCancellable); - g_object_unref(m_enumerateTemporaryAuthorizationsCancellable); - g_object_unref(m_revokeTemporaryAuthorizationsCancellable); - g_object_unref(m_revokeTemporaryAuthorizationCancellable); -} - -Authority::Authority(PolkitAuthority *authority, TQObject *parent) - : TQObject(parent) - , d(new Private(this)) -{ - qRegisterMetaType (); - qRegisterMetaType(); - - Q_ASSERT(!s_globalAuthority()->q); - s_globalAuthority()->q = this; - - if (authority) { - d->pkAuthority = authority; - } - - d->init(); -} - -Authority::~Authority() -{ - if (d->pkAuthority != NULL) { - g_object_unref(d->pkAuthority); - } - - delete d; -} - -void Authority::Private::init() -{ - TQDBusError error; - TQDBusError dbus_error; - - g_type_init(); - - m_checkAuthorizationCancellable = g_cancellable_new(); - m_enumerateActionsCancellable = g_cancellable_new(); - m_registerAuthenticationAgentCancellable = g_cancellable_new(); - m_unregisterAuthenticationAgentCancellable = g_cancellable_new(); - m_authenticationAgentResponseCancellable = g_cancellable_new(); - m_enumerateTemporaryAuthorizationsCancellable = g_cancellable_new(); - m_revokeTemporaryAuthorizationsCancellable = g_cancellable_new(); - m_revokeTemporaryAuthorizationCancellable = g_cancellable_new(); - -#ifndef POLKIT_QT_1_COMPATIBILITY_MODE - GError *gerror = NULL; -#endif - if (pkAuthority == NULL) { -#ifndef POLKIT_QT_1_COMPATIBILITY_MODE - pkAuthority = polkit_authority_get_sync(NULL, &gerror); - if (gerror != NULL) { - setError(E_GetAuthority, gerror->message); - g_error_free(gerror); - return; - } -#else - pkAuthority = polkit_authority_get(); -#endif - } - - if (pkAuthority == NULL) { -#ifdef POLKIT_QT_1_COMPATIBILITY_MODE - (E_GetAuthority); -#endif - return; - } - - // connect changed signal - g_signal_connect(G_OBJECT(pkAuthority), "changed", G_CALLBACK(pk_config_changed), NULL); - - // need to listen to NameOwnerChanged - dbusSignalAdd("org.freedesktop.DBus", "/", "org.freedesktop.DBus", "NameOwnerChanged"); - - TQString consoleKitService("org.freedesktop.ConsoleKit"); - TQString consoleKitManagerPath("/org/freedesktop/ConsoleKit/Manager"); - TQString consoleKitManagerInterface("org.freedesktop.ConsoleKit.Manager"); - TQString consoleKitSeatInterface("org.freedesktop.ConsoleKit.Seat"); - - // first, add signals SeadAdded and SeatRemoved from ConsoleKit Manager - dbusSignalAdd(consoleKitService, consoleKitManagerPath, consoleKitManagerInterface, "SeatAdded"); - dbusSignalAdd(consoleKitService, consoleKitManagerPath, consoleKitManagerInterface, "SeatRemoved"); - - // then we need to extract all seats from ConsoleKit - TQDBusMessage msg = TQDBusMessage::createMethodCall(consoleKitService, consoleKitManagerPath, consoleKitManagerInterface, "GetSeats"); - msg = TQDBusConnection::systemBus().call(msg); - if (!msg.arguments().isEmpty()) { - // this method returns a list with present seats - TQList seats; - qVariantValue (msg.arguments()[0]) >> seats; - // it can be multiple seats present so connect all their signals - Q_FOREACH(const TQString &seat, seats) { - seatSignalsConnect(seat); - } - } -} - -void Authority::Private::setError(Authority::ErrorCode code, const TQString &details, bool recover) -{ - if (recover) { - init(); - } - m_lastError = code; - m_errorDetails = details; - m_hasError = true; -} - -void Authority::Private::seatSignalsConnect(const TQString &seat) -{ - TQString consoleKitService("org.freedesktop.ConsoleKit"); - TQString consoleKitSeatInterface("org.freedesktop.ConsoleKit.Seat"); - // we want to connect to all slots of the seat - dbusSignalAdd(consoleKitService, seat, consoleKitSeatInterface, "DeviceAdded"); - dbusSignalAdd(consoleKitService, seat, consoleKitSeatInterface, "DeviceRemoved"); - dbusSignalAdd(consoleKitService, seat, consoleKitSeatInterface, "SessionAdded"); - dbusSignalAdd(consoleKitService, seat, consoleKitSeatInterface, "SessionRemoved"); - dbusSignalAdd(consoleKitService, seat, consoleKitSeatInterface, "ActiveSessionChanged"); -} - -void Authority::Private::dbusSignalAdd(const TQString &service, const TQString &path, const TQString &interface, const TQString &name) -{ - // FIXME: This code seems to be nonfunctional - it needs to be fixed somewhere (is it TQt BUG?) - TQDBusConnection::systemBus().connect(service, path, interface, name, - q, SLOT(dbusFilter(const TQDBusMessage &))); -} - -void Authority::Private::dbusFilter(const TQDBusMessage &message) -{ - if (message.type() == TQDBusMessage::SignalMessage) { - Q_EMIT q->consoleKitDBChanged(); - - // TODO: Test this with the multiseat support - if (message.member() == "SeatAdded") { - seatSignalsConnect(qVariantValue (message.arguments()[0]).path()); - } - } -} - -bool Authority::hasError() const -{ - return d->m_hasError; -} - -Authority::ErrorCode Authority::lastError() const -{ - return d->m_lastError; -} - -const TQString Authority::errorDetails() const -{ - if (d->m_lastError == E_None) { - return TQString(); - } else { - return d->m_errorDetails; - } -} - -void Authority::clearError() -{ - d->m_hasError = false; - d->m_lastError = E_None; -} - -void Authority::Private::pk_config_changed() -{ - Q_EMIT Authority::instance()->configChanged(); -} - -PolkitAuthority *Authority::polkitAuthority() const -{ - return d->pkAuthority; -} - -Authority::Result Authority::checkAuthorizationSync(const TQString &actionId, const Subject &subject, AuthorizationFlags flags) -{ - PolkitAuthorizationResult *pk_result; - GError *error = NULL; - - if (Authority::instance()->hasError()) { - return Unknown; - } - - if (!subject.isValid()) { - d->setError(E_WrongSubject); - return Unknown; - } - - pk_result = polkit_authority_check_authorization_sync(d->pkAuthority, - subject.subject(), - actionId.toAscii().data(), - NULL, - (PolkitCheckAuthorizationFlags)(int)flags, - NULL, - &error); - - if (error != NULL) { - d->setError(E_CheckFailed, error->message); - g_error_free(error); - return Unknown; - } - - if (!pk_result) { - d->setError(E_UnknownResult); - return Unknown; - } else { - Authority::Result res = polkitResultToResult(pk_result); - g_object_unref(pk_result); - return res; - } -} - -void Authority::checkAuthorization(const TQString &actionId, const Subject &subject, AuthorizationFlags flags) -{ - if (Authority::instance()->hasError()) { - return; - } - - if (!subject.isValid()) { - d->setError(E_WrongSubject); - return; - } - - polkit_authority_check_authorization(d->pkAuthority, - subject.subject(), - actionId.toAscii().data(), - NULL, - (PolkitCheckAuthorizationFlags)(int)flags, - d->m_checkAuthorizationCancellable, - d->checkAuthorizationCallback, this); -} - -void Authority::Private::checkAuthorizationCallback(GObject *object, GAsyncResult *result, gpointer user_data) -{ - Authority *authority = (Authority *) user_data; - - Q_ASSERT(authority != NULL); - - GError *error = NULL; - PolkitAuthorizationResult *pkResult = polkit_authority_check_authorization_finish((PolkitAuthority *) object, result, &error); - - if (error != NULL) { - // We don't want to set error if this is cancellation of some action - if (error->code != 1) { - authority->d->setError(E_CheckFailed, error->message); - } - g_error_free(error); - return; - } - if (pkResult != NULL) { - Q_EMIT authority->checkAuthorizationFinished(polkitResultToResult(pkResult)); - g_object_unref(pkResult); - } else { - authority->d->setError(E_UnknownResult); - } -} - -void Authority::checkAuthorizationCancel() -{ - if (!g_cancellable_is_cancelled(d->m_checkAuthorizationCancellable)) { - g_cancellable_cancel(d->m_checkAuthorizationCancellable); - } -} - -ActionDescription::List Authority::enumerateActionsSync() -{ - if (Authority::instance()->hasError()) { - return ActionDescription::List(); - } - - GError *error = NULL; - - GList *glist = polkit_authority_enumerate_actions_sync(d->pkAuthority, - NULL, - &error); - - if (error != NULL) { - d->setError(E_EnumFailed, error->message); - g_error_free(error); - return ActionDescription::List(); - } - - return actionsToListAndFree(glist); -} - -void Authority::enumerateActions() -{ - if (Authority::instance()->hasError()) { - return; - } - - polkit_authority_enumerate_actions(d->pkAuthority, - d->m_enumerateActionsCancellable, - d->enumerateActionsCallback, - Authority::instance()); -} - -void Authority::Private::enumerateActionsCallback(GObject *object, GAsyncResult *result, gpointer user_data) -{ - Authority *authority = (Authority *) user_data; - Q_ASSERT(authority != NULL); - GError *error = NULL; - GList *list = polkit_authority_enumerate_actions_finish((PolkitAuthority *) object, result, &error); - if (error != NULL) { - // We don't want to set error if this is cancellation of some action - if (error->code != 1) { - authority->d->setError(E_EnumFailed, error->message); - } - g_error_free(error); - return; - } - - Q_EMIT authority->enumerateActionsFinished(actionsToListAndFree(list)); -} - -void Authority::enumerateActionsCancel() -{ - if (!g_cancellable_is_cancelled(d->m_enumerateActionsCancellable)) { - g_cancellable_cancel(d->m_enumerateActionsCancellable); - } -} - -bool Authority::registerAuthenticationAgentSync(const Subject &subject, const TQString &locale, const TQString &objectPath) -{ - if (Authority::instance()->hasError()) { - return false; - } - - gboolean result; - GError *error = NULL; - - if (!subject.isValid()) { - d->setError(E_WrongSubject); - return false; - } - - result = polkit_authority_register_authentication_agent_sync(d->pkAuthority, - subject.subject(), locale.toAscii().data(), - objectPath.toAscii().data(), NULL, &error); - - if (error) { - d->setError(E_RegisterFailed, error->message); - g_error_free(error); - return false; - } - - return result; -} - -void Authority::registerAuthenticationAgent(const Subject &subject, const TQString &locale, const TQString &objectPath) -{ - if (Authority::instance()->hasError()) { - return; - } - - if (!subject.isValid()) { - d->setError(E_WrongSubject); - return; - } - - polkit_authority_register_authentication_agent(d->pkAuthority, - subject.subject(), - locale.toAscii().data(), - objectPath.toAscii().data(), - d->m_registerAuthenticationAgentCancellable, - d->registerAuthenticationAgentCallback, - this); -} - -void Authority::Private::registerAuthenticationAgentCallback(GObject *object, GAsyncResult *result, gpointer user_data) -{ - Authority *authority = (Authority *) user_data; - Q_ASSERT(authority != NULL); - GError *error = NULL; - bool res = polkit_authority_register_authentication_agent_finish((PolkitAuthority *) object, result, &error); - if (error != NULL) { - // We don't want to set error if this is cancellation of some action - if (error->code != 1) { - authority->d->setError(E_EnumFailed , error->message); - } - g_error_free(error); - return; - } - - Q_EMIT authority->registerAuthenticationAgentFinished(res); -} - -void Authority::registerAuthenticationAgentCancel() -{ - if (!g_cancellable_is_cancelled(d->m_registerAuthenticationAgentCancellable)) { - g_cancellable_cancel(d->m_registerAuthenticationAgentCancellable); - } -} - -bool Authority::unregisterAuthenticationAgentSync(const Subject &subject, const TQString &objectPath) -{ - if (d->pkAuthority) { - return false; - } - - if (!subject.isValid()) { - d->setError(E_WrongSubject); - return false; - } - - GError *error = NULL; - - bool result = polkit_authority_unregister_authentication_agent_sync(d->pkAuthority, - subject.subject(), - objectPath.toUtf8().data(), - NULL, - &error); - - if (error != NULL) { - d->setError(E_UnregisterFailed, error->message); - g_error_free(error); - return false; - } - - return result; -} - -void Authority::unregisterAuthenticationAgent(const Subject &subject, const TQString &objectPath) -{ - if (Authority::instance()->hasError()) { - return; - } - - if (!subject.isValid()) { - d->setError(E_WrongSubject); - return; - } - - polkit_authority_unregister_authentication_agent(d->pkAuthority, - subject.subject(), - objectPath.toUtf8().data(), - d->m_unregisterAuthenticationAgentCancellable, - d->unregisterAuthenticationAgentCallback, - this); -} - -void Authority::Private::unregisterAuthenticationAgentCallback(GObject *object, GAsyncResult *result, gpointer user_data) -{ - Authority *authority = (Authority *) user_data; - Q_ASSERT(authority); - GError *error = NULL; - bool res = polkit_authority_unregister_authentication_agent_finish((PolkitAuthority *) object, result, &error); - if (error != NULL) { - // We don't want to set error if this is cancellation of some action - if (error->code != 1) { - authority->d->setError(E_UnregisterFailed, error->message); - } - g_error_free(error); - return; - } - - Q_EMIT authority->unregisterAuthenticationAgentFinished(res); -} - -void Authority::unregisterAuthenticationAgentCancel() -{ - if (!g_cancellable_is_cancelled(d->m_unregisterAuthenticationAgentCancellable)) { - g_cancellable_cancel(d->m_unregisterAuthenticationAgentCancellable); - } -} - -bool Authority::authenticationAgentResponseSync(const TQString &cookie, const Identity &identity) -{ - if (Authority::instance()->hasError()) { - return false; - } - - if (cookie.isEmpty() || !identity.isValid()) { - d->setError(E_CookieOrIdentityEmpty); - return false; - } - - GError *error = NULL; - - bool result = polkit_authority_authentication_agent_response_sync(d->pkAuthority, - cookie.toUtf8().data(), - identity.identity(), - NULL, - &error); - if (error != NULL) { - d->setError(E_AgentResponseFailed, error->message); - g_error_free(error); - return false; - } - - return result; -} - -void Authority::authenticationAgentResponse(const TQString &cookie, const Identity &identity) -{ - if (Authority::instance()->hasError()) { - return; - } - - if (cookie.isEmpty() || !identity.isValid()) { - d->setError(E_CookieOrIdentityEmpty); - return; - } - - polkit_authority_authentication_agent_response(d->pkAuthority, - cookie.toUtf8().data(), - identity.identity(), - d->m_authenticationAgentResponseCancellable, - d->authenticationAgentResponseCallback, - this); -} - -void Authority::Private::authenticationAgentResponseCallback(GObject *object, GAsyncResult *result, gpointer user_data) -{ - Authority *authority = (Authority *) user_data; - Q_ASSERT(authority); - GError *error = NULL; - bool res = polkit_authority_authentication_agent_response_finish((PolkitAuthority *) object, result, &error); - if (error != NULL) { - // We don't want to set error if this is cancellation of some action - if (error->code != 1) { - authority->d->setError(E_AgentResponseFailed, error->message); - } - g_error_free(error); - return; - } - - Q_EMIT authority->authenticationAgentResponseFinished(res); -} - -void Authority::authenticationAgentResponseCancel() -{ - if (!g_cancellable_is_cancelled(d->m_authenticationAgentResponseCancellable)) { - g_cancellable_cancel(d->m_authenticationAgentResponseCancellable); - } -} - -TemporaryAuthorization::List Authority::enumerateTemporaryAuthorizationsSync(const Subject &subject) -{ - TemporaryAuthorization::List result; - - GError *error = NULL; - GList *glist = polkit_authority_enumerate_temporary_authorizations_sync(d->pkAuthority, - subject.subject(), - NULL, - &error); - if (error != NULL) { - d->setError(E_EnumFailed, error->message); - g_error_free(error); - return result; - } - - GList *glist2; - for (glist2 = glist; glist2 != NULL; glist2 = g_list_next(glist2)) { - result.append(TemporaryAuthorization((PolkitTemporaryAuthorization *) glist2->data)); - g_object_unref(glist2->data); - } - - g_list_free(glist); - - return result; -} - -void Authority::Private::enumerateTemporaryAuthorizationsCallback(GObject *object, GAsyncResult *result, gpointer user_data) -{ - Authority *authority = (Authority *) user_data; - Q_ASSERT(authority); - GError *error = NULL; - - GList *glist = polkit_authority_enumerate_temporary_authorizations_finish((PolkitAuthority *) object, result, &error); - - if (error != NULL) { - // We don't want to set error if this is cancellation of some action - if (error->code != 1) { - authority->d->setError(E_EnumFailed, error->message); - } - g_error_free(error); - return; - } - TemporaryAuthorization::List res; - GList *glist2; - for (glist2 = glist; glist2 != NULL; glist2 = g_list_next(glist2)) { - res.append(TemporaryAuthorization((PolkitTemporaryAuthorization *) glist2->data)); - g_object_unref(glist2->data); - } - - g_list_free(glist); - - Q_EMIT authority->enumerateTemporaryAuthorizationsFinished(res); -} - -void Authority::enumerateTemporaryAuthorizationsCancel() -{ - if (!g_cancellable_is_cancelled(d->m_enumerateTemporaryAuthorizationsCancellable)) { - g_cancellable_cancel(d->m_enumerateTemporaryAuthorizationsCancellable); - } -} - -bool Authority::revokeTemporaryAuthorizationsSync(const Subject &subject) -{ - bool result; - if (Authority::instance()->hasError()) { - return false; - } - - GError *error = NULL; - result = polkit_authority_revoke_temporary_authorizations_sync(d->pkAuthority, - subject.subject(), - NULL, - &error); - if (error != NULL) { - d->setError(E_RevokeFailed, error->message); - g_error_free(error); - return false; - } - return result; -} - -void Authority::revokeTemporaryAuthorizations(const Subject &subject) -{ - if (Authority::instance()->hasError()) { - return; - } - - polkit_authority_revoke_temporary_authorizations(d->pkAuthority, - subject.subject(), - d->m_revokeTemporaryAuthorizationsCancellable, - d->revokeTemporaryAuthorizationsCallback, - this); -} - -void Authority::Private::revokeTemporaryAuthorizationsCallback(GObject *object, GAsyncResult *result, gpointer user_data) -{ - Authority *authority = (Authority *) user_data; - Q_ASSERT(authority != NULL); - GError *error = NULL; - - bool res = polkit_authority_revoke_temporary_authorizations_finish((PolkitAuthority *) object, result, &error); - - if (error != NULL) { - // We don't want to set error if this is cancellation of some action - if (error->code != 1) { - authority->d->setError(E_RevokeFailed, error->message); - } - g_error_free(error); - return; - } - - Q_EMIT authority->revokeTemporaryAuthorizationsFinished(res); -} - -void Authority::revokeTemporaryAuthorizationsCancel() -{ - if (!g_cancellable_is_cancelled(d->m_revokeTemporaryAuthorizationsCancellable)) { - g_cancellable_cancel(d->m_revokeTemporaryAuthorizationsCancellable); - } -} - -bool Authority::revokeTemporaryAuthorizationSync(const TQString &id) -{ - bool result; - if (Authority::instance()->hasError()) { - return false; - } - - GError *error = NULL; - result = polkit_authority_revoke_temporary_authorization_by_id_sync(d->pkAuthority, - id.toUtf8().data(), - NULL, - &error); - if (error != NULL) { - d->setError(E_RevokeFailed, error->message); - g_error_free(error); - return false; - } - return result; -} - -void Authority::revokeTemporaryAuthorization(const TQString &id) -{ - if (Authority::instance()->hasError()) { - return; - } - - polkit_authority_revoke_temporary_authorization_by_id(d->pkAuthority, - id.toUtf8().data(), - d->m_revokeTemporaryAuthorizationCancellable, - d->revokeTemporaryAuthorizationCallback, - this); -} - -void Authority::Private::revokeTemporaryAuthorizationCallback(GObject *object, GAsyncResult *result, gpointer user_data) -{ - Authority *authority = (Authority *) user_data; - Q_ASSERT(authority != NULL); - GError *error = NULL; - - bool res = polkit_authority_revoke_temporary_authorization_by_id_finish((PolkitAuthority *) object, result, &error); - - if (error != NULL) { - // We don't want to set error if this is cancellation of some action - if (error->code != 1) { - authority->d->setError(E_RevokeFailed, error->message); - } - g_error_free(error); - return; - } - - Q_EMIT authority->revokeTemporaryAuthorizationFinished(res); -} - -void Authority::revokeTemporaryAuthorizationCancel() -{ - if (!g_cancellable_is_cancelled(d->m_revokeTemporaryAuthorizationCancellable)) { - g_cancellable_cancel(d->m_revokeTemporaryAuthorizationCancellable); - } -} - -} - -#include "polkitqt1-authority.moc" diff --git a/core/polkitqt1-authority.h b/core/polkitqt1-authority.h deleted file mode 100644 index 6a0bb1f8e..000000000 --- a/core/polkitqt1-authority.h +++ /dev/null @@ -1,539 +0,0 @@ -/* - * This file is part of the Polkit-qt project - * Copyright (C) 2009 Daniel Nicoletti - * Copyright (C) 2009 Dario Freddi - * Copyright (C) 2009 Jaroslav Reznik - * Copyright (C) 2009 Radek Novacek - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef POLKITQT1_AUTHORITY_H -#define POLKITQT1_AUTHORITY_H - -#include "polkitqt1-export.h" -#include "polkitqt1-identity.h" -#include "polkitqt1-subject.h" -#include "polkitqt1-temporaryauthorization.h" -#include "polkitqt1-actiondescription.h" - -#include -#include - -typedef struct _PolkitAuthority PolkitAuthority; -class TQStringList; - -/** - * \namespace PolkitTQt1 PolkitTQt - * - * \brief Namespace wrapping Polkit-TQt classes - * - * This namespace wraps all Polkit-TQt classes. - */ -namespace PolkitTQt1 -{ - -/** - * \class Authority polkitqt1-authority.h Authority - * \author Daniel Nicoletti - * \author Dario Freddi - * \author Jaroslav Reznik - * - * \brief Convenience class for TQt/KDE applications - * - * This class is a singleton that provides makes easy the usage - * of PolKitAuthority. It emits configChanged() - * whenever PolicyKit files change (e.g. the PolicyKit.conf - * or .policy files) or when ConsoleKit reports activities changes. - * - * \note This class is a singleton, its constructor is private. - * Call Authority::instance() to get an instance of the Authority object. - * Do not delete Authority::instance(), cleanup will be done automatically. - */ -class POLKITQT1_EXPORT Authority : public TQObject -{ - Q_OBJECT - TQ_DISABLE_COPY(Authority) - TQ_ENUMS(Result) - TQ_ENUMS(ErrorCode) -public: - enum Result { - /** Result unknown */ - Unknown = 0x00, - /** The subject is authorized for the specified action */ - Yes = 0x01, - /** The subject is not authorized for the specified action */ - No = 0x02, - /** The subject is authorized if more information is provided */ - Challenge = 0x03 - }; - - enum AuthorizationFlag { - /** No flags set **/ - None = 0x00, - /** If the subject can obtain the authorization through authentication, - * and an authentication agent is available, then attempt to do so. - * - * Note, this means that the method used for checking authorization is likely - * to block for a long time. **/ - AllowUserInteraction = 0x01 - }; - Q_DECLARE_FLAGS(AuthorizationFlags, AuthorizationFlag) - - /** Error codes for the authority class */ - enum ErrorCode { - /** No error occurred **/ - E_None = 0x00, - /** Authority cannot be obtained **/ - E_GetAuthority = 0x01, - /** Authority check failed **/ - E_CheckFailed = 0x02, - /** Wrong or empty subject was given **/ - E_WrongSubject = 0x03, - /** Action returned unknown result **/ - E_UnknownResult = 0x04, - /** Enumerating actions failed **/ - E_EnumFailed = 0x05, - /** Registration of authentication agent failed **/ - E_RegisterFailed = 0x06, - /** Unregistration of authentication agent failed **/ - E_UnregisterFailed = 0x07, - /** Cookie or polkitqt1-identity.handled to the action is empty **/ - E_CookieOrIdentityEmpty = 0x08, - /** Response of auth agent failed **/ - E_AgentResponseFailed = 0x09, - /** Revoke temporary authorizations failed **/ - E_RevokeFailed = 0x0A - }; - - /** - * \brief Returns the instance of Authority - * - * Returns the current instance of Authority. Call this function whenever - * you need to access the Authority class. - * - * \note Authority is a singleton. Memory is handled by polkit-qt, so you just - * need to call this function to get a working instance of Authority. - * Don't delete the object after having used it. - * - * \param authority use this if you want to set an explicit PolkitAuthority. If you - * don't know what this implies, simply ignore the parameter. In case - * you want to use it, be sure of streaming it the first time you call - * this function, otherwise it will have no effect. - * - * \return The current authority instance - */ - static Authority *instance(PolkitAuthority *authority = 0); - - ~Authority(); - - /** - * You should always call this method after every action. No action will be allowed - * if the object is in error state. Use clearError() to clear the error message. - * - * \see lastError - * \see clearError - * - * \return \c true if an error occurred, \c false if the library is ready - */ - bool hasError() const; - - /** - * \return the code of last error - */ - ErrorCode lastError() const; - - /** - * Get detail information about error that occurred. - * - * \return detail message - */ - const TQString errorDetails() const; - - /** - * Use this method to clear the error message. - */ - void clearError(); - - /** - * Returns the current instance of PolkitAuthority. If you are handling - * it through Polkit-qt (which is quite likely, since you are calling - * this function), DO NOT use any PolicyKit API's specific method that - * modifies the instance on it, unless you're completely aware of what you're doing and - * of the possible consequencies. Use this instance only to gather information. - * - * \return the current PolkitAuthority instance - */ - PolkitAuthority *polkitAuthority() const; - - /** - * This function should be used by mechanisms (e.g.: helper applications). - * It returns the action should be carried out, so if the caller was - * actually authorized to perform it. The result is in form of a Result, so that - * you can have more control over the whole process, and detect an eventual error. - * Most of the times you simply want to check if the result is == to \c Result::Yes, - * if you don't have specific needs. - * - * It is CRITICAL that you call this function - * and check what it returns before doing anything in your helper, since otherwise - * you could be actually performing an action from an unknown or unauthorized caller. - * - * When operation is finished, signal checkAuthorizationFinish is emitted - * with result of authorization check in its parameter. - * - * \see checkAuthorizationSync Synchronous version of this method. - * \see checkAuthorizationFinished Signal that is emitted when this method finishes. - * \see checkAuthorizationCancel Use it to cancel execution of this method. - * - * \param actionId the Id of the action in question - * \param subject subject that the action is authorized for (e.g. unix process) - * \param flags flags that influences the authorization checking - * - * \return \c Result::Yes if the caller is authorized and the action should be performed - * \c otherwise if the caller was not authorized and the action should not be performed, - * or an error has occurred - * - */ - void checkAuthorization(const TQString &actionId, const Subject &subject, - AuthorizationFlags flags); - - /** - * Synchronous version of the checkAuthorization method. - * - * \param actionId the Id of the action in question - * \param subject subject that the action is authorized for (e.g. unix process) - * \param flags flags that influences the authorization checking - * - * \see checkAuthorization Asynchronous version of this method. - */ - Result checkAuthorizationSync(const TQString &actionId, const Subject &subject, - AuthorizationFlags flags); - - /** - * This method can be used to cancel last authorization check. - */ - void checkAuthorizationCancel(); - - /** - * Asynchronously retrieves all registered actions. - * - * When operation is finished, signal checkAuthorizationFinish is emitted - * with result of authorization check in its parameter. - * - * \see enumerateActionsSync Synchronous version of this method. - * \see enumerateActionsFinished Signal that is emitted when this method finishes. - * \see enumerateActionsCancel Use it to cancel execution of this method. - */ - void enumerateActions(); - - /** - * Synchronously retrieves all registered actions. - * - * \see enumerateActions Asynchronous version of this method. - * - * \return a list of Action IDs - */ - ActionDescription::List enumerateActionsSync(); - - /** - * This method can be used to cancel enumeration of actions - */ - void enumerateActionsCancel(); - - /** - * Registers an authentication agent. - * - * \see registerAuthenticationAgentSync Synchronous version of this method. - * \see registerAuthenticationAgentFinished Signal that is emitted when this method finishes. - * \see registerAuthenticationAgentCancel Use it to cancel execution of this method. - * - * \param subject caller subject - * \param locale the locale of the authentication agent - * \param objectPath the object path for the authentication agent - */ - void registerAuthenticationAgent(const Subject &subject, const TQString &locale, - const TQString &objectPath); - - /** - * Registers an authentication agent. - * - * \see registerAuthenticationAgent Asynchronous version of this method. - * - * \param subject caller subject - * \param locale the locale of the authentication agent - * \param objectPath the object path for the authentication agent - * - * \return \c true if the Authentication agent has been successfully registered - * \c false if the Authentication agent registration failed - */ - bool registerAuthenticationAgentSync(const Subject &subject, const TQString &locale, - const TQString &objectPath); - - /** - * This method can be used to cancel the registration of the authentication agent. - */ - void registerAuthenticationAgentCancel(); - - /** - * Unregisters an Authentication agent. - * - * \see unregisterAuthenticationAgentSync Synchronous version of this method. - * \see unregisterAuthenticationAgentFinished Signal that is emitted when this method finishes. - * \see unregisterAuthenticationAgentCancel Use it to cancel execution of this method. - * - * \param subject caller subject - * \param objectPath the object path for the Authentication agent - * - * \return \c true if the Authentication agent has been successfully unregistered - * \c false if the Authentication agent unregistration failed - */ - void unregisterAuthenticationAgent(const Subject &subject, const TQString &objectPath); - - /** - * Unregisters an Authentication agent. - * - * \see unregisterAuthenticationAgent Asynchronous version of this method. - * - * \param subject caller subject - * \param objectPath the object path for the Authentication agent - * - * \return \c true if the Authentication agent has been successfully unregistered - * \c false if the Authentication agent unregistration failed - */ - bool unregisterAuthenticationAgentSync(const Subject &subject, const TQString &objectPath); - - /** - * This method can be used to cancel the unregistration of the authentication agent. - */ - void unregisterAuthenticationAgentCancel(); - - /** - * Provide response that \p identity successfully authenticated for the authentication request identified by \p cookie. - * - * \see authenticationAgentResponseSync Synchronous version of this method. - * \see authenticationAgentResponseFinished Signal that is emitted when this method finishes. - * \see authenticationAgentResponseCancel Use it to cancel execution of this method. - * - * \param cookie The cookie passed to the authentication agent from the authority. - * \param identity The identity that was authenticated. - */ - void authenticationAgentResponse(const TQString &cookie, const Identity &identity); - - /** - * Provide response that \p identity successfully authenticated for the authentication request identified by \p cookie. - * - * \see authenticationAgentResponse Asynchronous version of this method. - * - * \param cookie The cookie passed to the authentication agent from the authority. - * \param identity The identity that was authenticated. - * - * \return \c true if authority acknowledged the call, \c false if error is set. - * - */ - bool authenticationAgentResponseSync(const TQString& cookie, const PolkitTQt1::Identity& identity); - - /** - * This method can be used to cancel the authenticationAgentResponseAsync method. - */ - void authenticationAgentResponseCancel(); - - /** - * Retrieves all temporary action that applies to \p subject. - * - * \see enumerateTemporaryAuthorizationsSync Synchronous version of this method. - * \see enumerateTemporaryAuthorizationsFinished Signal that is emitted when this method finishes. - * \see enumerateTemporaryAuthorizationsCancel Use it to cancel execution of this method. - * - * \param subject the subject to get temporary authorizations for - * - */ - void enumerateTemporaryAuthorizations(const Subject &subject); - - /** - * Retrieves all temporary action that applies to \p subject - * - * \see enumerateTemporaryAuthorizations Asynchronous version of this method. - * - * \param subject the subject to get temporary authorizations for - * - * \note Free all TemporaryAuthorization objects using \p delete operator. - * - * \return List of all temporary authorizations - */ - TemporaryAuthorization::List enumerateTemporaryAuthorizationsSync(const Subject &subject); - - /** - * This method can be used to cancel the enumerateTemporaryAuthorizationsAsync method. - */ - void enumerateTemporaryAuthorizationsCancel(); - - /** - * Revokes all temporary authorizations that applies to \p subject - * - * \see revokeTemporaryAuthorizationsSync Synchronous version of this method. - * \see revokeTemporaryAuthorizationsFinished Signal that is emitted when this method finishes. - * \see revokeTemporaryAuthorizationsCancel Use it to cancel execution of this method. - - * \param subject the subject to revoke temporary authorizations from - */ - void revokeTemporaryAuthorizations(const Subject &subject); - - /** - * Revokes all temporary authorizations that applies to \p subject - * - * \see revokeTemporaryAuthorizations Asynchronous version of this method. - * - * \param subject the subject to revoke temporary authorizations from - * - * \return \c true if all temporary authorization were revoked - * \c false if the revoking failed - */ - bool revokeTemporaryAuthorizationsSync(const Subject &subject); - - /** - * This method can be used to cancel the method revokeTemporaryAuthorizationsAsync. - */ - void revokeTemporaryAuthorizationsCancel(); - - /** - * Revokes temporary authorization by \p id - * - * \see revokeTemporaryAuthorizationSync Synchronous version of this method. - * \see revokeTemporaryAuthorizationFinished Signal that is emitted when this method finishes. - * \see revokeTemporaryAuthorizationCancel Use it to cancel execution of this method. - * - * \param id the identifier of the temporary authorization - */ - void revokeTemporaryAuthorization(const TQString &id); - - /** - * Revokes temporary authorization by \p id - * - * \see revokeTemporaryAuthorization Asynchronous version of this method. - * - * \param id the identifier of the temporary authorization - * - * \return \c true if the temporary authorization was revoked - * \c false if the revoking failed - */ - bool revokeTemporaryAuthorizationSync(const TQString &id); - - /** - * This method can be used to cancel the method revokeTemporaryAuthorizationAsync. - */ - void revokeTemporaryAuthorizationCancel(); - -Q_SIGNALS: - /** - * This signal will be emitted when a configuration - * file gets changed (e.g. /etc/PolicyKit/PolicyKit.conf or - * .policy files). - * Connect to this signal if you want to track down - * actions. - */ - void configChanged(); - - /** - * This signal is emitted when ConsoleKit configuration - * changes. This might happen when a session becomes active - * or inactive. - * - * If you want to track your actions directly you should - * connect to this signal, as this might change the return value - * PolicyKit will give you. - * - * \note If you use Action you'll probably prefer to - * use the dataChanged() signal to track Action changes. - */ - void consoleKitDBChanged(); - - /** - * This signal is emitted when asynchronous method checkAuthorization finishes. - * - * The argument is the result of authorization. - */ - void checkAuthorizationFinished(PolkitTQt1::Authority::Result); - - /** - * This signal is emitted when asynchronous method enumerateActions finishes. - * - * The argument is the list of all Action IDs. - */ - void enumerateActionsFinished(PolkitTQt1::ActionDescription::List); - - /** - * This signal is emitted when asynchronous method registerAuthenticationAgent finishes. - * - * The argument is \c true if the Authentication agent has been successfully registered - * \c false if the Authentication agent registration failed - */ - void registerAuthenticationAgentFinished(bool); - - /** - * This signal is emitted when asynchronous method unregisterAuthenticationAgent finishes. - * - * The argument is \c true if the Authentication agent has been successfully unregistered - * \c false if the Authentication agent unregistration failed - */ - void unregisterAuthenticationAgentFinished(bool); - - /** - * This signal is emitted when asynchronous method authenticationAgentResponse finishes. - * - * The argument is \c true if authority acknowledged the call, \c false if error is set. - */ - void authenticationAgentResponseFinished(bool); - - /** - * This signal is emmited when asynchronous method enumerateTemporaryAuthorizations finishes. - * - * The argument is list of all temporary authorizations. - * - * \note Free all TemporaryAuthorization objects using \p delete operator. - */ - void enumerateTemporaryAuthorizationsFinished(PolkitTQt1::TemporaryAuthorization::List); - - /** - * This signal is emmited when asynchronous method revokeTemporaryAuthorizations finishes. - * - * The argument is \c true if all temporary authorizations were revoked - * \c false if the revoking failed - */ - void revokeTemporaryAuthorizationsFinished(bool); - - /** - * This signal is emmited when asynchronous method revokeTemporaryAuthorization finishes. - * \return \c true if the temporary authorization was revoked - * \c false if the revoking failed - */ - void revokeTemporaryAuthorizationFinished(bool); - -private: - explicit Authority(PolkitAuthority *context, TQObject *parent = 0); - - class Private; - friend class Private; - Private * const d; - - Q_PRIVATE_SLOT(d, void dbusFilter(const TQDBusMessage &message)) -}; - -} - -Q_DECLARE_OPERATORS_FOR_FLAGS(PolkitTQt1::Authority::AuthorizationFlags) -Q_DECLARE_METATYPE(PolkitTQt1::Authority::Result) - -#endif diff --git a/core/polkitqt1-details.cpp b/core/polkitqt1-details.cpp deleted file mode 100644 index 65d028b26..000000000 --- a/core/polkitqt1-details.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the Polkit-qt project - * Copyright (C) 2009 Radek Novacek - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "polkitqt1-details.h" - -#include - -#include - -namespace PolkitTQt1 -{ - -class Details::Data : public TQSharedData -{ -public: - Data() {} - Data(const Data &other) - : TQSharedData(other) - , polkitDetails(other.polkitDetails) - { - g_object_ref(polkitDetails); - } - ~Data() - { - g_object_unref(polkitDetails); - } - - PolkitDetails *polkitDetails; -}; - -Details::Details() - : d(new Data) -{ - g_type_init(); - d->polkitDetails = polkit_details_new(); -} - -Details::Details(PolkitDetails *pkDetails) - : d(new Data) -{ - g_type_init(); - d->polkitDetails = pkDetails; -} - -Details::~Details() -{ -} - -Details& Details::operator=(const PolkitTQt1::Details& other) -{ - d = other.d; - return *this; -} - -TQString Details::lookup(const TQString &key) const -{ - const gchar *result = polkit_details_lookup(d->polkitDetails, key.toUtf8().data()); - if (result != NULL) { - return TQString::fromUtf8(result); - } else { - return TQString(); - } -} - -void Details::insert(const TQString &key, const TQString &value) -{ - polkit_details_insert(d->polkitDetails, key.toUtf8().data(), value.toUtf8().data()); -} - -TQStringList Details::keys() const -{ - gchar **result = polkit_details_get_keys(d->polkitDetails); - TQStringList list; - int len = g_strv_length(result); - for (int i = 0; i < len; i++) { - list.append(TQString::fromUtf8(result[i])); - } - g_strfreev(result); - return list; -} - -} diff --git a/core/polkitqt1-details.h b/core/polkitqt1-details.h deleted file mode 100644 index 2cb18163c..000000000 --- a/core/polkitqt1-details.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * This file is part of the Polkit-qt project - * Copyright (C) 2009 Radek Novacek - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef POLKITQT1_DETAILS_H -#define POLKITQT1_DETAILS_H - -#include "polkitqt1-export.h" - -#include -#include - -typedef struct _PolkitDetails PolkitDetails; - -/** - * \namespace PolkitTQt1 PolkitTQt - * - * \brief Namespace wrapping Polkit-TQt classes - * - * This namespace wraps all Polkit-TQt classes. - */ -namespace PolkitTQt1 -{ - -/** - * \class Details polkitqt1-details.h Details - * \author Radek Novacek - * - * \brief Class used for passing details around. - */ -class POLKITQT1_EXPORT Details -{ -public: - /** - * Creates a new Details object - */ - Details(); - - /** - * Creates Details object from PolkitDetails - * - * \warning Use this only if you are completely aware of what are you doing! - * - * \param pkDetails PolkitDetails object - */ - explicit Details(PolkitDetails *pkDetails); - - ~Details(); - - Details &operator=(const Details &other); - - /** - * Get the value for \p key - * - * \param key A key - * \return Value of the key \p key, otherwise empty TQString. - */ - TQString lookup(const TQString &key) const; - - /** - * Inserts key \p key with value \p value. - * - * \param key A key. - * \param value A value. - */ - void insert(const TQString &key, const TQString &value); - - /** - * Gets a list of all keys. - * - * \return List of all keys. - */ - TQStringList keys() const; -private: - class Data; - TQExplicitlySharedDataPointer< Data > d; -}; - -} - -#endif // DETAILS_H diff --git a/core/polkitqt1-identity.cpp b/core/polkitqt1-identity.cpp deleted file mode 100644 index 1e03dda9a..000000000 --- a/core/polkitqt1-identity.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/* - * This file is part of the Polkit-qt project - * Copyright (C) 2009 Lukas Tinkl - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "polkitqt1-identity.h" - -#include - -#include - -namespace PolkitTQt1 -{ - -class Identity::Data : public TQSharedData -{ -public: - Data() : identity(0) {} - Data(const Data& other) - : TQSharedData(other) - , identity(other.identity) - { - if (identity) { - g_object_ref(identity); - } - } - ~Data() - { - if (identity) { - g_object_unref(identity); - } - } - - PolkitIdentity *identity; -}; - -Identity::Identity() - : d(new Data) -{ - g_type_init(); -} - -Identity::Identity(PolkitIdentity *polkitIdentity) - : d(new Data) -{ - g_type_init(); - d->identity = polkitIdentity; - - if (d->identity) { - g_object_ref(d->identity); - } -} - -Identity::Identity(const PolkitTQt1::Identity& other) - : d(other.d) -{ - -} - -Identity::~Identity() -{ -} - -Identity& Identity::operator=(const PolkitTQt1::Identity& other) -{ - d = other.d; - return *this; -} - -bool Identity::isValid() const -{ - return d->identity != NULL; -} - -PolkitIdentity *Identity::identity() const -{ - return d->identity; -} - -void Identity::setIdentity(PolkitIdentity *identity) -{ - if (d->identity == identity) { - return; - } - - if (d->identity) { - g_object_unref(d->identity); - } - - d->identity = identity; - - if (d->identity) { - g_object_ref(d->identity); - } -} - -TQString Identity::toString() const -{ - Q_ASSERT(d->identity); - return TQString::fromUtf8(polkit_identity_to_string(d->identity)); -} - -Identity Identity::fromString(const TQString &string) -{ - GError *error = NULL; - PolkitIdentity *pkIdentity = polkit_identity_from_string(string.toUtf8().data(), &error); - if (error != NULL) { - tqWarning() << TQString("Cannot create Identity from string: %1").arg(error->message); - return Identity(); - } - return Identity(pkIdentity); -} - -UnixGroupIdentity Identity::toUnixGroupIdentity() -{ - UnixGroupIdentity *ugid = static_cast< UnixGroupIdentity* >(this); - if (!ugid) { - return UnixGroupIdentity(); - } - - return *ugid; -} - -UnixUserIdentity Identity::toUnixUserIdentity() -{ - UnixUserIdentity *uuid = static_cast< UnixUserIdentity* >(this); - if (!uuid) { - return UnixUserIdentity(); - } - - return *uuid; -} - -UnixUserIdentity::UnixUserIdentity(const TQString &name) - : Identity() -{ - GError *error = NULL; - setIdentity(polkit_unix_user_new_for_name(name.toUtf8().data(), &error)); - if (error != NULL) { - tqWarning() << TQString("Cannot create UnixUserIdentity: %1").arg(error->message); - setIdentity(NULL); - } -} - -UnixUserIdentity::UnixUserIdentity(uid_t uid) - : Identity() -{ - setIdentity(polkit_unix_user_new(uid)); -} - -UnixUserIdentity::UnixUserIdentity(PolkitUnixUser *pkUnixUser) - : Identity((PolkitIdentity *)pkUnixUser) -{ - -} - -UnixUserIdentity::UnixUserIdentity() - : Identity() -{ - -} - -uid_t UnixUserIdentity::uid() const -{ - return polkit_unix_user_get_uid((PolkitUnixUser *) identity()); -} - -void UnixUserIdentity::setUid(uid_t uid) -{ - polkit_unix_user_set_uid((PolkitUnixUser *) identity(), uid); -} - -UnixGroupIdentity::UnixGroupIdentity(const TQString &name) - : Identity() -{ - GError *error = NULL; - setIdentity(polkit_unix_group_new_for_name(name.toUtf8().data(), &error)); - if (error != NULL) { - tqWarning() << TQString("Cannot create UnixGroupIdentity: %1").arg(error->message); - setIdentity(NULL); - } -} - -UnixGroupIdentity::UnixGroupIdentity(gid_t gid) - : Identity() -{ - setIdentity(polkit_unix_group_new(gid)); -} - -UnixGroupIdentity::UnixGroupIdentity(PolkitUnixGroup *pkUnixGroup) - : Identity((PolkitIdentity *) pkUnixGroup) -{ - -} - -UnixGroupIdentity::UnixGroupIdentity() - : Identity() -{ - -} - -gid_t UnixGroupIdentity::gid() const -{ - return polkit_unix_group_get_gid((PolkitUnixGroup *) identity()); -} - -void UnixGroupIdentity::setGid(gid_t gid) -{ - polkit_unix_group_set_gid((PolkitUnixGroup *) identity(), gid); -} - -} diff --git a/core/polkitqt1-identity.h b/core/polkitqt1-identity.h deleted file mode 100644 index e1f4dde90..000000000 --- a/core/polkitqt1-identity.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - * This file is part of the Polkit-qt project - * Copyright (C) 2009 Lukas Tinkl - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef POLKITQT1_IDENTITY_H -#define POLKITQT1_IDENTITY_H - -#include "polkitqt1-export.h" - -#include - -#include -#include - -typedef struct _PolkitIdentity PolkitIdentity; -typedef struct _PolkitUnixUser PolkitUnixUser; -typedef struct _PolkitUnixGroup PolkitUnixGroup; - -/** - * \namespace PolkitTQt1 PolkitTQt - * - * \brief Namespace wrapping Polkit-TQt classes - * - * This namespace wraps all Polkit-TQt classes. - */ -namespace PolkitTQt1 -{ - -class UnixUserIdentity; -class UnixGroupIdentity; - -/** - * \class Identity polkitqt1-identity.h Identity - * \author Lukas Tinkl - * - * This class encapsulates the PolkitIdentity interface. - * - * \brief Abstract class representing identities - * - * \see UnixGroup - * \see UnixUser - */ -class POLKITQT1_EXPORT Identity -{ -public: - typedef TQList< Identity > List; - - Identity(); - explicit Identity(PolkitIdentity *polkitIdentity); - Identity(const Identity &other); - - ~Identity(); - - Identity &operator=(const Identity &other); - - bool isValid() const; - - /** - * Serialization of object to the string - * - * \return Serialized Identity object - */ - TQString toString() const; - - /** - * Creates the Identity object from string representation - * - * \param string string representation of the object - * - * \return Pointer to new Identity instance - */ - static Identity fromString(const TQString &string); - - UnixUserIdentity toUnixUserIdentity(); - UnixGroupIdentity toUnixGroupIdentity(); - - /** - * Gets PolkitIdentity object. - * - * \warning It shouldn't be used directly unless you are completely aware of what are you doing - * - * \return Pointer to PolkitIdentity instance - */ - PolkitIdentity *identity() const; -protected: - void setIdentity(PolkitIdentity *identity); - -private: - class Data; - TQExplicitlySharedDataPointer< Data > d; -}; - -/** - * \class UnixUserIdentity polkitqt1-identity.h Identity - * - * An object representing a user identity on a UNIX system. - * - * \brief UNIX user identity - * \sa Identity - */ -class POLKITQT1_EXPORT UnixUserIdentity : public Identity -{ -public: - UnixUserIdentity(); - /** - * Creates UnixUser object by UID of the user - * - * \param uid user id - */ - explicit UnixUserIdentity(uid_t uid); - - /** - * Creates UnixUser object by unix name of the user - * - * \param name Unix name - */ - explicit UnixUserIdentity(const TQString &name); - - /** - * Creates UnixUser object from PolkitUnixUser object - * - * \warning Use this only if you are completely aware of what are you doing! - * - * \param pkUnixUser The PolkitUnixUser object - */ - explicit UnixUserIdentity(PolkitUnixUser *pkUnixUser); - - /** - * Gets an user id - * - * \return user id - */ - uid_t uid() const; - - /** - * Sets the id of user - * - * \param uid user id - */ - void setUid(uid_t uid); -}; - -/** - * \class UnixGroupIdentity polkitqt1-identity.h Identity - * - * An object representing a group identity on a UNIX system. - * - * \brief UNIX group identity - * \sa Identity - */ -class POLKITQT1_EXPORT UnixGroupIdentity : public Identity -{ -public: - UnixGroupIdentity(); - /** - * Creates UnixGroup object by GID of the group - * - * \param gid group id - */ - explicit UnixGroupIdentity(gid_t gid); - - /** - * Creates UnixGroup object by unix name of the group - * - * \param name group name - */ - explicit UnixGroupIdentity(const TQString &name); - - /** - * Creates UnixGroup object from PolkitUnixGroup object - * - * \warning Use this only if you are completely aware of what are you doing! - * - * \param pkUnixGroup The PolkitUnixGroup object - */ - explicit UnixGroupIdentity(PolkitUnixGroup *pkUnixGroup); - - /** - * Gets a group id - * - * \return group id - */ - gid_t gid() const; - - /** - * Sets the id of group - * - * \param gid group id - */ - void setGid(gid_t gid); -}; - -} - -#endif // POLKIT_QT_IDENTITY_H diff --git a/core/polkitqt1-subject.cpp b/core/polkitqt1-subject.cpp deleted file mode 100644 index dea13d9f2..000000000 --- a/core/polkitqt1-subject.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/* - * This file is part of the Polkit-qt project - * Copyright (C) 2009 Jaroslav Reznik - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "polkitqt1-subject.h" - -#include -#include - -namespace PolkitTQt1 -{ - -class Subject::Data : public TQSharedData -{ -public: - Data() - : TQSharedData() - , subject(0) - {} - Data(const Data& other) - : TQSharedData(other) - , subject(other.subject) - { - g_object_ref(subject); - } - ~Data() - { - g_object_unref(subject); - } - - PolkitSubject *subject; -}; - -Subject::Subject() - : d(new Data) -{ - g_type_init(); -} - -Subject::Subject(PolkitSubject *subject) - : d(new Data) -{ - g_type_init(); - d->subject = subject; -} - -Subject::Subject(const PolkitTQt1::Subject& other) - : d(other.d) -{ - -} - -Subject& Subject::operator=(const PolkitTQt1::Subject& other) -{ - d = other.d; - return *this; -} - -Subject::~Subject() -{ -} - -bool Subject::isValid() const -{ - return d->subject != NULL; -} - -PolkitSubject *Subject::subject() const -{ - return d->subject; -} - -void Subject::setSubject(PolkitSubject *subject) -{ - d->subject = subject; -} - -TQString Subject::toString() const -{ - Q_ASSERT(d->subject); - return TQString::fromUtf8(polkit_subject_to_string(d->subject)); -} - -Subject Subject::fromString(const TQString &string) -{ - // should be in polkit library!!! but for strange reason it's necessary to have it here - g_type_init(); - - Subject subject; - GError *error = NULL; - subject.d->subject = polkit_subject_from_string(string.toUtf8().data(), &error); - if (error != NULL) { - tqWarning() << TQString("Cannot create Subject from string: %1").arg(error->message); - return NULL; - } - return subject; -} - -UnixProcessSubject::UnixProcessSubject(qint64 pid) - : Subject() -{ - setSubject(polkit_unix_process_new(pid)); -} - -UnixProcessSubject::UnixProcessSubject(qint64 pid, tquint64 startTime) - : Subject() -{ - setSubject(polkit_unix_process_new_full(pid, startTime)); -} - -UnixProcessSubject::UnixProcessSubject(PolkitUnixProcess *pkUnixProcess) - : Subject((PolkitSubject *) pkUnixProcess) -{ - -} - -qint64 UnixProcessSubject::pid() const -{ - return polkit_unix_process_get_pid((PolkitUnixProcess *) subject()); -} - -qint64 UnixProcessSubject::startTime() const -{ - return polkit_unix_process_get_start_time((PolkitUnixProcess *) subject()); -} - -void UnixProcessSubject::setPid(qint64 pid) -{ - polkit_unix_process_set_pid((PolkitUnixProcess *) subject(), pid); -} - -// ----- SystemBusName -SystemBusNameSubject::SystemBusNameSubject(const TQString &name) - : Subject() -{ - setSubject(polkit_system_bus_name_new(name.toUtf8().data())); -} - -SystemBusNameSubject::SystemBusNameSubject(PolkitSystemBusName *pkSystemBusName) - : Subject((PolkitSubject *) pkSystemBusName) -{ - -} - -TQString SystemBusNameSubject::name() const -{ - return TQString::fromUtf8(polkit_system_bus_name_get_name((PolkitSystemBusName *) subject())); -} - -void SystemBusNameSubject::setName(const TQString &name) -{ - polkit_system_bus_name_set_name((PolkitSystemBusName *) subject(), name.toUtf8().data()); -} - -// ----- SystemSession -UnixSessionSubject::UnixSessionSubject(const TQString &sessionId) - : Subject() -{ - setSubject(polkit_unix_session_new(sessionId.toUtf8().data())); -} - -UnixSessionSubject::UnixSessionSubject(qint64 pid) - : Subject() -{ - GError *error = NULL; - setSubject(polkit_unix_session_new_for_process_sync(pid, NULL, &error)); - if (error != NULL) { - tqWarning() << TQString("Cannot create unix session: %1").arg(error->message); - setSubject(NULL); - } -} - -UnixSessionSubject::UnixSessionSubject(PolkitSystemBusName *pkUnixSession) - : Subject((PolkitSubject *) pkUnixSession) -{ - -} - -TQString UnixSessionSubject::sessionId() const -{ - return TQString::fromUtf8(polkit_unix_session_get_session_id((PolkitUnixSession *) subject())); -} - -void UnixSessionSubject::setSessionId(const TQString &sessionId) -{ - polkit_unix_session_set_session_id((PolkitUnixSession *) subject(), sessionId.toUtf8().data()); -} - -} diff --git a/core/polkitqt1-subject.h b/core/polkitqt1-subject.h deleted file mode 100644 index 25d986097..000000000 --- a/core/polkitqt1-subject.h +++ /dev/null @@ -1,262 +0,0 @@ -/* - * This file is part of the PolKit1-qt project - * Copyright (C) 2009 Jaroslav Reznik - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef POLKITQT1_SUBJECT_H -#define POLKITQT1_SUBJECT_H - -#include "polkitqt1-export.h" - -#include -#include - -typedef struct _PolkitSubject PolkitSubject; -typedef struct _PolkitUnixProcess PolkitUnixProcess; -typedef struct _PolkitSystemBusName PolkitSystemBusName; - -/** - * \namespace PolkitTQt1 PolkitTQt - * - * \brief Namespace wrapping PolicyKit-TQt classes - * - * This namespace wraps all PolicyKit-TQt classes. - */ -namespace PolkitTQt1 -{ - -/** - * \class Subject polkitqt1-subject.h Subject - * \author Jaroslav Reznik - * - * \brief This class represents PolicyKit subjects - * - * This class encapsulates the PolkitSubject interface. - * - * \see UnixProcess - * \see SystemBusName - * \see UnixSession - */ -class POLKITQT1_EXPORT Subject -{ -public: - Subject(); - Subject(const Subject &other); - ~Subject(); - - Subject &operator=(const Subject &other); - - bool isValid() const; - - /** - * Serialization of object to the string - * - * \return Serialized Subject object - */ - TQString toString() const; - - /** - * Creates the Subject object from string reprezentation - * - * \param string string reprezentation of the object - * - * \return Pointer to new Subject instance - */ - static Subject fromString(const TQString &string); - - /** - * Gets PolkitSubject object. - * - * \warning It shouldn't be used directly unless you are completely aware of what are you doing - * - * \return Pointer to PolkitSubject instance - */ - PolkitSubject *subject() const; - -protected: - Subject(PolkitSubject *subject); - - void setSubject(PolkitSubject *subject); - -private: - class Data; - TQExplicitlySharedDataPointer< Data > d; -}; - -/** - * \class UnixProcessSubject polkitqt1-subject.h Subject - * \author Jaroslav Reznik - * - * \brief A class for representing a UNIX process. - * - * To uniquely identify processes, both the process - * id and the start time of the process (a monotonic - * increasing value representing the time since the - * kernel was started) is used. - * - * \sa Subject - */ -class POLKITQT1_EXPORT UnixProcessSubject : public Subject -{ -public: - /** - * Subject constructor, takes one parameter - PID. The start time - * of process will be looked automatically. - * - * \param pid An Unix process PID. - */ - explicit UnixProcessSubject(qint64 pid); - - /** - * Subject constructor, takes two parameters - PID and start time. - * - * \param pid An Unix process PID. - * \param startTime An Unix process start time. - */ - UnixProcessSubject(qint64 pid, tquint64 startTime); - - /** - * Subject constructor, it creates UnixProcess object from PolkitUnixProcess object - * - * \warning Use this only if you are completely aware of what are you doing! - * - * \param process PolkitUnixProcess object - */ - explicit UnixProcessSubject(PolkitUnixProcess *process); - - /** - * Returns Unix process PID. - * - * \return A PID of associated Unix process. - */ - qint64 pid() const; - - /** - * Returns Unix process start time. - * - * \return A start time of associated Unix process. - */ - qint64 startTime() const; - - /** - * Sets Unix process PID. - * - * \param pid An Unix process PID. - */ - void setPid(qint64 pid); -}; - -/** - * \class SystemBusNameSubject polkitqt1-subject.h Subject - * \author Jaroslav Reznik - * - * \brief A class for representing a process owning a unique name on the system bus. - * - * \sa Subject - */ -class POLKITQT1_EXPORT SystemBusNameSubject : public Subject -{ -public: - /** - * Subject constructor, takes one parameter - system bus name. - * - * \param name A unique system bus name. - */ - explicit SystemBusNameSubject(const TQString &name); - - /** - * Subject constructor, it creates SystemBusName object from PolkitSystemBusName object - * - * \warning Use this only if you are completely aware of what are you doing! - * - * \param pkSystemBusName PolkitSystemBusName object - */ - explicit SystemBusNameSubject(PolkitSystemBusName *pkSystemBusName); - - /** - * Returns system bus name. - * - * \return A unique system bus name. - */ - TQString name() const; - - /** - * Sets system bus name. - * - * \param name System bus name. - */ - void setName(const TQString &name); -}; - -/** - * \class UnixSessionSubject polkitqt1-subject.h Subject - * \author Jaroslav Reznik - * - * \brief A class for representing unix session. - * - * The session id is an opaque string obtained from - * ConsoleKit. - * - * \sa Subject - */ -class POLKITQT1_EXPORT UnixSessionSubject : public Subject -{ -public: - /** - * Subject constructor, takes one parameter - session id. - * - * \param sessionId The session id. - */ - explicit UnixSessionSubject(const TQString &sessionId); - - /** - * Subject constructor, takes one parameter - pid of process. - * - * Synchronous! - * - * \param pid The session's process pid. - */ - explicit UnixSessionSubject(qint64 pid); - - /** - * Subject constructor, it creates UnixSession object from PolkitUnixSession object - * - * \warning Use this only if you are completely aware of what are you doing! - * - * \param pkUnixSession PolkitUnixSession object - */ - explicit UnixSessionSubject(PolkitSystemBusName *pkUnixSession); - - /** - * Returns session id. - * - * \return A session id. - */ - TQString sessionId() const; - - /** - * Sets session id. - * - * \param sessionId A session id. - */ - void setSessionId(const TQString &sessionId); -}; - -} - -#endif diff --git a/core/polkitqt1-temporaryauthorization.cpp b/core/polkitqt1-temporaryauthorization.cpp deleted file mode 100644 index 7614089d4..000000000 --- a/core/polkitqt1-temporaryauthorization.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * This file is part of the PolKit1-qt project - * Copyright (C) 2009 Radek Novacek - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "polkitqt1-temporaryauthorization.h" -#include "polkitqt1-authority.h" - -#include - -namespace PolkitTQt1 -{ - -class TemporaryAuthorization::Data : public TQSharedData -{ -public: - Data() {} - Data(const Data& other) - : TQSharedData(other) - , id(other.id) - , actionId(other.actionId) - , subject(other.subject) - , timeObtained(other.timeObtained) - , timeExpires(other.timeExpires) - { - } - ~Data() {} - - TQString id; - TQString actionId; - Subject subject; - TQDateTime timeObtained; - TQDateTime timeExpires; -}; - -TemporaryAuthorization::TemporaryAuthorization(PolkitTemporaryAuthorization *pkTemporaryAuthorization) - : d(new Data) -{ - g_type_init(); - d->id = TQString::fromUtf8(polkit_temporary_authorization_get_id(pkTemporaryAuthorization)); - d->actionId = TQString::fromUtf8(polkit_temporary_authorization_get_action_id(pkTemporaryAuthorization)); - d->subject = Subject::fromString(polkit_subject_to_string(polkit_temporary_authorization_get_subject(pkTemporaryAuthorization))); - d->timeObtained = TQDateTime::fromTime_t(polkit_temporary_authorization_get_time_obtained(pkTemporaryAuthorization)); - d->timeExpires = TQDateTime::fromTime_t(polkit_temporary_authorization_get_time_expires(pkTemporaryAuthorization)); - g_object_unref(pkTemporaryAuthorization); -} - -TemporaryAuthorization::TemporaryAuthorization(const PolkitTQt1::TemporaryAuthorization& other) - : d(other.d) -{ - -} - -TemporaryAuthorization::TemporaryAuthorization() - : d(new Data) -{ - -} - -TemporaryAuthorization& TemporaryAuthorization::operator=(const PolkitTQt1::TemporaryAuthorization& other) -{ - d = other.d; - return *this; -} - -TemporaryAuthorization::~TemporaryAuthorization() -{ -} - -TQString TemporaryAuthorization::id() const -{ - return d->id; -} - -TQString TemporaryAuthorization::actionId() const -{ - return d->actionId; -} - -Subject TemporaryAuthorization::subject() const -{ - //tqFatal(polkit_subject_to_string(polkit_temporary_authorization_get_subject(d->temporaryAuthorization))); - return d->subject;//Subject::fromString(polkit_subject_to_string(d->subject)); -} - -TQDateTime TemporaryAuthorization::obtainedAt() const -{ - return d->timeObtained; -} - -TQDateTime TemporaryAuthorization::expirationTime() const -{ - return d->timeExpires; -} - -bool TemporaryAuthorization::revoke() -{ - Authority::instance()->revokeTemporaryAuthorization(id()); - return true; -} - -} diff --git a/core/polkitqt1-temporaryauthorization.h b/core/polkitqt1-temporaryauthorization.h deleted file mode 100644 index 04deabb2c..000000000 --- a/core/polkitqt1-temporaryauthorization.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * This file is part of the PolKit1-qt project - * Copyright (C) 2009 Radek Novacek - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef POLKITQT1_TEMPORARYAUTHORIZATION_H -#define POLKITQT1_TEMPORARYAUTHORIZATION_H - -#include "polkitqt1-subject.h" - -#include -#include -#include -#include - -typedef struct _PolkitTemporaryAuthorization PolkitTemporaryAuthorization; - -/** - * \namespace PolkitTQt1 PolkitTQt - * - * \brief Namespace wrapping PolicyKit-TQt classes - * - * This namespace wraps all PolicyKit-TQt classes. - */ -namespace PolkitTQt1 -{ - -/** - * \class TemporaryAuthorization polkitqt1-temporaryauthorization.h TemporaryAuthorization - * \author Radek Novacek - * - * \brief This class represents PolicyKit temporary authorization - * - * This class encapsulates the PolkitTemporaryAuthorization interface. - */ -class POLKITQT1_EXPORT TemporaryAuthorization -{ -public: - typedef TQList< TemporaryAuthorization > List; - TemporaryAuthorization(); - /** - * Creates TemporaryAuthorization object from PolkitTemporaryAuthorization - * - * \warning It shouldn't be used directly unless you are completely aware of what are you doing - * - * \param pkTemporaryAuthorization PolkitTemporaryAuthorization object - * \param parent - */ - explicit TemporaryAuthorization(PolkitTemporaryAuthorization *pkTemporaryAuthorization); - TemporaryAuthorization(const TemporaryAuthorization &other); - - ~TemporaryAuthorization(); - - TemporaryAuthorization &operator=(const TemporaryAuthorization &other); - - /** - * \brief Gets the identifier for the authorization. - * - * This identifier can be user by the revokeTemporaryAuthorization function - * - * \return Unique identifier for the authorization - */ - TQString id() const; - - /** - * \brief Gets the identifier of the action that authorization is for - * - * \return String that identifies the action - */ - TQString actionId() const; - - /** - * \brief Gets the subject that authorization is for - * - * \return A Subject. - */ - Subject subject() const; - - /** - * \brief Gets the time when authorization was obtained - * - * \return Time of obtaining the authorization - */ - TQDateTime obtainedAt() const; - - /** - * \brief Gets the time when authorizaton will expire - * - * \return Time of expiration - */ - TQDateTime expirationTime() const; - - /** - * \brief Revoke temporary authorization - * - * \return \c true Authorization has been revoked - * \c false Revoking authorization failed - */ - bool revoke(); - -private: - class Data; - TQSharedDataPointer< Data > d; -}; -} - -Q_DECLARE_METATYPE(PolkitTQt1::TemporaryAuthorization::List) - -#endif // TEMPORARYAUTHORIZATION_H diff --git a/core/polkittqt1-actiondescription.cpp b/core/polkittqt1-actiondescription.cpp new file mode 100644 index 000000000..1cf9cf621 --- /dev/null +++ b/core/polkittqt1-actiondescription.cpp @@ -0,0 +1,148 @@ +/* + * This file is part of the Polkit-tqt project + * Copyright (C) 2009 Jaroslav Reznik + * Copyright (C) 2010 Dario Freddi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "polkittqt1-actiondescription.h" + +#include + +#include + +namespace PolkitTQt1 +{ + +class ActionDescription::Data : public TQSharedData +{ +public: + Data() {} + Data(const Data& other) + : TQSharedData(other) + , actionId(other.actionId) + , description(other.description) + , message(other.message) + , vendorName(other.vendorName) + , vendorUrl(other.vendorUrl) + , iconName(other.iconName) + , implicitAny(other.implicitAny) + , implicitInactive(other.implicitInactive) + , implicitActive(other.implicitActive) + { + } + virtual ~Data() {} + + TQString actionId; + TQString description; + TQString message; + TQString vendorName; + TQString vendorUrl; + TQString iconName; + + ActionDescription::ImplicitAuthorization implicitAny; + ActionDescription::ImplicitAuthorization implicitInactive; + ActionDescription::ImplicitAuthorization implicitActive; +}; + +ActionDescription::ActionDescription() + : d(new Data) +{ + +} + +ActionDescription::ActionDescription(PolkitActionDescription *polkitActionDescription) + : d(new Data) +{ + g_type_init(); + + d->actionId = TQString::fromUtf8(polkit_action_description_get_action_id(polkitActionDescription)); + d->description = TQString::fromUtf8(polkit_action_description_get_description(polkitActionDescription)); + d->message = TQString::fromUtf8(polkit_action_description_get_message(polkitActionDescription)); + d->vendorName = TQString::fromUtf8(polkit_action_description_get_vendor_name(polkitActionDescription)); + d->vendorUrl = TQString::fromUtf8(polkit_action_description_get_vendor_url(polkitActionDescription)); + d->iconName = TQString::fromUtf8(polkit_action_description_get_icon_name(polkitActionDescription)); + + d->implicitAny = static_cast(polkit_action_description_get_implicit_any( + polkitActionDescription)); + d->implicitInactive = static_cast(polkit_action_description_get_implicit_inactive( + polkitActionDescription)); + d->implicitActive = static_cast(polkit_action_description_get_implicit_active( + polkitActionDescription)); +} + +ActionDescription::ActionDescription(const PolkitTQt1::ActionDescription& other) + : d(other.d) +{ +} + +ActionDescription& ActionDescription::operator=(const PolkitTQt1::ActionDescription& other) +{ + d = other.d; + return *this; +} + +ActionDescription::~ActionDescription() +{ +} + +TQString ActionDescription::actionId() const +{ + return d->actionId; +} + +TQString ActionDescription::description() const +{ + return d->description; +} + +TQString ActionDescription::message() const +{ + return d->message; +} + +TQString ActionDescription::vendorName() const +{ + return d->vendorName; +} + +TQString ActionDescription::vendorUrl() const +{ + return d->vendorUrl; +} + +TQString ActionDescription::iconName() const +{ + return d->iconName; +} + +ActionDescription::ImplicitAuthorization ActionDescription::implicitAny() const +{ + return d->implicitAny; +} + +ActionDescription::ImplicitAuthorization ActionDescription::implicitInactive() const +{ + return d->implicitInactive; +} + +ActionDescription::ImplicitAuthorization ActionDescription::implicitActive() const +{ + return d->implicitActive; +} + +} diff --git a/core/polkittqt1-actiondescription.h b/core/polkittqt1-actiondescription.h new file mode 100644 index 000000000..666f3be67 --- /dev/null +++ b/core/polkittqt1-actiondescription.h @@ -0,0 +1,149 @@ +/* + * This file is part of the Polkit-tqt project + * Copyright (C) 2009 Jaroslav Reznik + * Copyright (C) 2010 Dario Freddi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef POLKITTQT1_ACTION_DESCRIPTION_H +#define POLKITTQT1_ACTION_DESCRIPTION_H + +#include "polkittqt1-export.h" + +#include +#include +#include + +typedef struct _PolkitActionDescription PolkitActionDescription; + +namespace PolkitTQt1 +{ +/** + * \class ActionDescription polkittqt1-actiondescription.h ActionDescription + * \author Jaroslav Reznik + * \author Dario Freddi + * + * \brief Class used to encapsulate a registered action. + */ +class POLKITTQT1_EXPORT ActionDescription +{ +public: + enum ImplicitAuthorization { + /** Unknown whether the subject is authorized, never returned in any public API. **/ + Unknown = -1, + /** Subject is not authorized. **/ + NotAuthorized = 0, + /** Authentication is required. **/ + AuthenticationRequired = 1, + /** Authentication as an administrator is required. **/ + AdministratorAuthenticationRequired = 2, + /** Authentication is required. If the authorization is obtained, it is retained. **/ + AuthenticationRequiredRetained = 3, + /** Authentication as an administrator is required. If the authorization is obtained, it is retained. **/ + AdministratorAuthenticationRequiredRetained = 4, + /** The subject is authorized. **/ + Authorized = 5 + }; + + typedef TQList< ActionDescription > List; + + ActionDescription(); + /** + * \brief Constructor of ActionDescription object from PolkitActionDescription + * + * \warning Use this only if you are completely aware of what are you doing! + * + * \param actionDesciption PolkitActionDescription + */ + explicit ActionDescription(PolkitActionDescription *actionDescription); + ActionDescription(const ActionDescription &other); + ~ActionDescription(); + + ActionDescription &operator=(const ActionDescription &other); + + /** + * \brief Gets the action id for ActionDescription + * + * \return id of the action + */ + TQString actionId() const; + + /** + * \brief Gets the description used of ActionDescription + * + * \return description of the action + */ + TQString description() const; + + /** + * \brief Gets the message user for ActionDescription + * + * \return action message + */ + TQString message() const; + + /** + * \brief Gets the vendor name for ActionDescription, if any + * + * \return vendor name + */ + TQString vendorName() const; + + /** + * \brief Gets the vendor URL for ActionDescription, if any + * + * \return vendor URL or empty TQString if there is no vendor URL + */ + TQString vendorUrl() const; + + /** + * \brief Gets the icon name for ActionDescription, if any + * + * \return icon name or empty TQString if there is no icon + */ + TQString iconName() const; + + /** + * \brief Gets the implicit authorization for ActionDescription used for any subject + * + * \return A value from ImplicitAuthorization enumeration + */ + ActionDescription::ImplicitAuthorization implicitAny() const; + + /** + * \brief Gets the implicit authorization for ActionDescription used for subjects in inactive session on a local console + * + * \return A value from ImplicitAuthorization enumeration + */ + ActionDescription::ImplicitAuthorization implicitInactive() const; + + /** + * \brief Gets the implicit authorization for ActionDescription used for subjects in active session on a local console + * + * \return A value from ImplicitAuthorization enumeration + */ + ActionDescription::ImplicitAuthorization implicitActive() const; + +private: + class Data; + TQSharedDataPointer< Data > d; +}; +} + +TQ_DECLARE_METATYPE(PolkitTQt1::ActionDescription::List) + +#endif //POLKIT_TQT_ACTION_DESCRIPTION_H diff --git a/core/polkittqt1-authority.cpp b/core/polkittqt1-authority.cpp new file mode 100644 index 000000000..8ec922d2e --- /dev/null +++ b/core/polkittqt1-authority.cpp @@ -0,0 +1,855 @@ +/* + * This file is part of the Polkit-tqt project + * Copyright (C) 2009 Daniel Nicoletti + * Copyright (C) 2009 Dario Freddi + * Copyright (C) 2009 Jaroslav Reznik + * Copyright (C) 2009 Radek Novacek + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "polkittqt1-authority.h" + +#include +#include + +#include + +namespace PolkitTQt1 +{ + +class AuthorityHelper +{ +public: + AuthorityHelper() : q(0) {} + ~AuthorityHelper() { + delete q; + } + Authority *q; +}; + +TQ_GLOBAL_STATIC(AuthorityHelper, s_globalAuthority) + +Authority *Authority::instance(PolkitAuthority *authority) +{ + if (!s_globalAuthority()->q) { + new Authority(authority); + } + + return s_globalAuthority()->q; +} + +Authority::Result polkitResultToResult(PolkitAuthorizationResult *result) +{ + if (polkit_authorization_result_get_is_challenge(result)) { + return Authority::Challenge; + } else if (polkit_authorization_result_get_is_authorized(result)) { + return Authority::Yes; + } else { + return Authority::No; + } +} + +ActionDescription::List actionsToListAndFree(GList *glist) +{ + ActionDescription::List result; + for (GList *glist2 = glist; glist2; glist2 = g_list_next(glist2)) { + gpointer i = glist2->data; + result.append(ActionDescription(static_cast(i))); + g_object_unref(i); + } + + g_list_free(glist); + return result; +} + +class Authority::Private +{ +public: + // Polkit will return NULL on failures, hence we use it instead of 0 + Private(Authority *qq) : q(qq) + , pkAuthority(NULL) + , m_hasError(false) {} + + ~Private(); + + void init(); + + /** Use this method to set the error message to \p message. Set recover to \c true + * to try to reinitialize this object with init() method + */ + void setError(Authority::ErrorCode code, const TQString &details = TQString(), bool recover = false); + + void dbusFilter(const TQDBusMessage &message); + void dbusSignalAdd(const TQString &service, const TQString &path, const TQString &interface, const TQString &name); + void seatSignalsConnect(const TQString &seat); + + Authority *q; + PolkitAuthority *pkAuthority; + bool m_hasError; + Authority::ErrorCode m_lastError; + TQString m_errorDetails; + TQDBusConnection *m_systemBus; + GCancellable *m_checkAuthorizationCancellable, + *m_enumerateActionsCancellable, + *m_registerAuthenticationAgentCancellable, + *m_unregisterAuthenticationAgentCancellable, + *m_authenticationAgentResponseCancellable, + *m_enumerateTemporaryAuthorizationsCancellable, + *m_revokeTemporaryAuthorizationsCancellable, + *m_revokeTemporaryAuthorizationCancellable; + + + static void pk_config_changed(); + static void checkAuthorizationCallback(GObject *object, GAsyncResult *result, gpointer user_data); + static void enumerateActionsCallback(GObject *object, GAsyncResult *result, gpointer user_data); + static void registerAuthenticationAgentCallback(GObject *object, GAsyncResult *result, gpointer user_data); + static void unregisterAuthenticationAgentCallback(GObject *object, GAsyncResult *result, gpointer user_data); + static void authenticationAgentResponseCallback(GObject *object, GAsyncResult *result, gpointer user_data); + static void enumerateTemporaryAuthorizationsCallback(GObject *object, GAsyncResult *result, gpointer user_data); + static void revokeTemporaryAuthorizationsCallback(GObject *object, GAsyncResult *result, gpointer user_data); + static void revokeTemporaryAuthorizationCallback(GObject *object, GAsyncResult *result, gpointer user_data); +}; + +Authority::Private::~Private() +{ + g_object_unref(m_checkAuthorizationCancellable); + g_object_unref(m_enumerateActionsCancellable); + g_object_unref(m_registerAuthenticationAgentCancellable); + g_object_unref(m_unregisterAuthenticationAgentCancellable); + g_object_unref(m_authenticationAgentResponseCancellable); + g_object_unref(m_enumerateTemporaryAuthorizationsCancellable); + g_object_unref(m_revokeTemporaryAuthorizationsCancellable); + g_object_unref(m_revokeTemporaryAuthorizationCancellable); +} + +Authority::Authority(PolkitAuthority *authority, TQObject *parent) + : TQObject(parent) + , d(new Private(this)) +{ + qRegisterMetaType (); + qRegisterMetaType(); + + Q_ASSERT(!s_globalAuthority()->q); + s_globalAuthority()->q = this; + + if (authority) { + d->pkAuthority = authority; + } + + d->init(); +} + +Authority::~Authority() +{ + if (d->pkAuthority != NULL) { + g_object_unref(d->pkAuthority); + } + + delete d; +} + +void Authority::Private::init() +{ + TQDBusError error; + TQDBusError dbus_error; + + g_type_init(); + + m_checkAuthorizationCancellable = g_cancellable_new(); + m_enumerateActionsCancellable = g_cancellable_new(); + m_registerAuthenticationAgentCancellable = g_cancellable_new(); + m_unregisterAuthenticationAgentCancellable = g_cancellable_new(); + m_authenticationAgentResponseCancellable = g_cancellable_new(); + m_enumerateTemporaryAuthorizationsCancellable = g_cancellable_new(); + m_revokeTemporaryAuthorizationsCancellable = g_cancellable_new(); + m_revokeTemporaryAuthorizationCancellable = g_cancellable_new(); + +#ifndef POLKIT_TQT_1_COMPATIBILITY_MODE + GError *gerror = NULL; +#endif + if (pkAuthority == NULL) { +#ifndef POLKIT_TQT_1_COMPATIBILITY_MODE + pkAuthority = polkit_authority_get_sync(NULL, &gerror); + if (gerror != NULL) { + setError(E_GetAuthority, gerror->message); + g_error_free(gerror); + return; + } +#else + pkAuthority = polkit_authority_get(); +#endif + } + + if (pkAuthority == NULL) { +#ifdef POLKIT_TQT_1_COMPATIBILITY_MODE + (E_GetAuthority); +#endif + return; + } + + // connect changed signal + g_signal_connect(G_OBJECT(pkAuthority), "changed", G_CALLBACK(pk_config_changed), NULL); + + // need to listen to NameOwnerChanged + dbusSignalAdd("org.freedesktop.DBus", "/", "org.freedesktop.DBus", "NameOwnerChanged"); + + TQString consoleKitService("org.freedesktop.ConsoleKit"); + TQString consoleKitManagerPath("/org/freedesktop/ConsoleKit/Manager"); + TQString consoleKitManagerInterface("org.freedesktop.ConsoleKit.Manager"); + TQString consoleKitSeatInterface("org.freedesktop.ConsoleKit.Seat"); + + // first, add signals SeadAdded and SeatRemoved from ConsoleKit Manager + dbusSignalAdd(consoleKitService, consoleKitManagerPath, consoleKitManagerInterface, "SeatAdded"); + dbusSignalAdd(consoleKitService, consoleKitManagerPath, consoleKitManagerInterface, "SeatRemoved"); + + // then we need to extract all seats from ConsoleKit + TQDBusMessage msg = TQDBusMessage::createMethodCall(consoleKitService, consoleKitManagerPath, consoleKitManagerInterface, "GetSeats"); + msg = TQDBusConnection::systemBus().call(msg); + if (!msg.arguments().isEmpty()) { + // this method returns a list with present seats + TQList seats; + qVariantValue (msg.arguments()[0]) >> seats; + // it can be multiple seats present so connect all their signals + TQ_FOREACH(const TQString &seat, seats) { + seatSignalsConnect(seat); + } + } +} + +void Authority::Private::setError(Authority::ErrorCode code, const TQString &details, bool recover) +{ + if (recover) { + init(); + } + m_lastError = code; + m_errorDetails = details; + m_hasError = true; +} + +void Authority::Private::seatSignalsConnect(const TQString &seat) +{ + TQString consoleKitService("org.freedesktop.ConsoleKit"); + TQString consoleKitSeatInterface("org.freedesktop.ConsoleKit.Seat"); + // we want to connect to all slots of the seat + dbusSignalAdd(consoleKitService, seat, consoleKitSeatInterface, "DeviceAdded"); + dbusSignalAdd(consoleKitService, seat, consoleKitSeatInterface, "DeviceRemoved"); + dbusSignalAdd(consoleKitService, seat, consoleKitSeatInterface, "SessionAdded"); + dbusSignalAdd(consoleKitService, seat, consoleKitSeatInterface, "SessionRemoved"); + dbusSignalAdd(consoleKitService, seat, consoleKitSeatInterface, "ActiveSessionChanged"); +} + +void Authority::Private::dbusSignalAdd(const TQString &service, const TQString &path, const TQString &interface, const TQString &name) +{ + // FIXME: This code seems to be nonfunctional - it needs to be fixed somewhere (is it TQt BUG?) + TQDBusConnection::systemBus().connect(service, path, interface, name, + q, SLOT(dbusFilter(const TQDBusMessage &))); +} + +void Authority::Private::dbusFilter(const TQDBusMessage &message) +{ + if (message.type() == TQDBusMessage::SignalMessage) { + TQ_EMIT q->consoleKitDBChanged(); + + // TODO: Test this with the multiseat support + if (message.member() == "SeatAdded") { + seatSignalsConnect(qVariantValue (message.arguments()[0]).path()); + } + } +} + +bool Authority::hasError() const +{ + return d->m_hasError; +} + +Authority::ErrorCode Authority::lastError() const +{ + return d->m_lastError; +} + +const TQString Authority::errorDetails() const +{ + if (d->m_lastError == E_None) { + return TQString(); + } else { + return d->m_errorDetails; + } +} + +void Authority::clearError() +{ + d->m_hasError = false; + d->m_lastError = E_None; +} + +void Authority::Private::pk_config_changed() +{ + TQ_EMIT Authority::instance()->configChanged(); +} + +PolkitAuthority *Authority::polkitAuthority() const +{ + return d->pkAuthority; +} + +Authority::Result Authority::checkAuthorizationSync(const TQString &actionId, const Subject &subject, AuthorizationFlags flags) +{ + PolkitAuthorizationResult *pk_result; + GError *error = NULL; + + if (Authority::instance()->hasError()) { + return Unknown; + } + + if (!subject.isValid()) { + d->setError(E_WrongSubject); + return Unknown; + } + + pk_result = polkit_authority_check_authorization_sync(d->pkAuthority, + subject.subject(), + actionId.toAscii().data(), + NULL, + (PolkitCheckAuthorizationFlags)(int)flags, + NULL, + &error); + + if (error != NULL) { + d->setError(E_CheckFailed, error->message); + g_error_free(error); + return Unknown; + } + + if (!pk_result) { + d->setError(E_UnknownResult); + return Unknown; + } else { + Authority::Result res = polkitResultToResult(pk_result); + g_object_unref(pk_result); + return res; + } +} + +void Authority::checkAuthorization(const TQString &actionId, const Subject &subject, AuthorizationFlags flags) +{ + if (Authority::instance()->hasError()) { + return; + } + + if (!subject.isValid()) { + d->setError(E_WrongSubject); + return; + } + + polkit_authority_check_authorization(d->pkAuthority, + subject.subject(), + actionId.toAscii().data(), + NULL, + (PolkitCheckAuthorizationFlags)(int)flags, + d->m_checkAuthorizationCancellable, + d->checkAuthorizationCallback, this); +} + +void Authority::Private::checkAuthorizationCallback(GObject *object, GAsyncResult *result, gpointer user_data) +{ + Authority *authority = (Authority *) user_data; + + Q_ASSERT(authority != NULL); + + GError *error = NULL; + PolkitAuthorizationResult *pkResult = polkit_authority_check_authorization_finish((PolkitAuthority *) object, result, &error); + + if (error != NULL) { + // We don't want to set error if this is cancellation of some action + if (error->code != 1) { + authority->d->setError(E_CheckFailed, error->message); + } + g_error_free(error); + return; + } + if (pkResult != NULL) { + Q_EMIT authority->checkAuthorizationFinished(polkitResultToResult(pkResult)); + g_object_unref(pkResult); + } else { + authority->d->setError(E_UnknownResult); + } +} + +void Authority::checkAuthorizationCancel() +{ + if (!g_cancellable_is_cancelled(d->m_checkAuthorizationCancellable)) { + g_cancellable_cancel(d->m_checkAuthorizationCancellable); + } +} + +ActionDescription::List Authority::enumerateActionsSync() +{ + if (Authority::instance()->hasError()) { + return ActionDescription::List(); + } + + GError *error = NULL; + + GList *glist = polkit_authority_enumerate_actions_sync(d->pkAuthority, + NULL, + &error); + + if (error != NULL) { + d->setError(E_EnumFailed, error->message); + g_error_free(error); + return ActionDescription::List(); + } + + return actionsToListAndFree(glist); +} + +void Authority::enumerateActions() +{ + if (Authority::instance()->hasError()) { + return; + } + + polkit_authority_enumerate_actions(d->pkAuthority, + d->m_enumerateActionsCancellable, + d->enumerateActionsCallback, + Authority::instance()); +} + +void Authority::Private::enumerateActionsCallback(GObject *object, GAsyncResult *result, gpointer user_data) +{ + Authority *authority = (Authority *) user_data; + Q_ASSERT(authority != NULL); + GError *error = NULL; + GList *list = polkit_authority_enumerate_actions_finish((PolkitAuthority *) object, result, &error); + if (error != NULL) { + // We don't want to set error if this is cancellation of some action + if (error->code != 1) { + authority->d->setError(E_EnumFailed, error->message); + } + g_error_free(error); + return; + } + + TQ_EMIT authority->enumerateActionsFinished(actionsToListAndFree(list)); +} + +void Authority::enumerateActionsCancel() +{ + if (!g_cancellable_is_cancelled(d->m_enumerateActionsCancellable)) { + g_cancellable_cancel(d->m_enumerateActionsCancellable); + } +} + +bool Authority::registerAuthenticationAgentSync(const Subject &subject, const TQString &locale, const TQString &objectPath) +{ + if (Authority::instance()->hasError()) { + return false; + } + + gboolean result; + GError *error = NULL; + + if (!subject.isValid()) { + d->setError(E_WrongSubject); + return false; + } + + result = polkit_authority_register_authentication_agent_sync(d->pkAuthority, + subject.subject(), locale.toAscii().data(), + objectPath.toAscii().data(), NULL, &error); + + if (error) { + d->setError(E_RegisterFailed, error->message); + g_error_free(error); + return false; + } + + return result; +} + +void Authority::registerAuthenticationAgent(const Subject &subject, const TQString &locale, const TQString &objectPath) +{ + if (Authority::instance()->hasError()) { + return; + } + + if (!subject.isValid()) { + d->setError(E_WrongSubject); + return; + } + + polkit_authority_register_authentication_agent(d->pkAuthority, + subject.subject(), + locale.toAscii().data(), + objectPath.toAscii().data(), + d->m_registerAuthenticationAgentCancellable, + d->registerAuthenticationAgentCallback, + this); +} + +void Authority::Private::registerAuthenticationAgentCallback(GObject *object, GAsyncResult *result, gpointer user_data) +{ + Authority *authority = (Authority *) user_data; + Q_ASSERT(authority != NULL); + GError *error = NULL; + bool res = polkit_authority_register_authentication_agent_finish((PolkitAuthority *) object, result, &error); + if (error != NULL) { + // We don't want to set error if this is cancellation of some action + if (error->code != 1) { + authority->d->setError(E_EnumFailed , error->message); + } + g_error_free(error); + return; + } + + TQ_EMIT authority->registerAuthenticationAgentFinished(res); +} + +void Authority::registerAuthenticationAgentCancel() +{ + if (!g_cancellable_is_cancelled(d->m_registerAuthenticationAgentCancellable)) { + g_cancellable_cancel(d->m_registerAuthenticationAgentCancellable); + } +} + +bool Authority::unregisterAuthenticationAgentSync(const Subject &subject, const TQString &objectPath) +{ + if (d->pkAuthority) { + return false; + } + + if (!subject.isValid()) { + d->setError(E_WrongSubject); + return false; + } + + GError *error = NULL; + + bool result = polkit_authority_unregister_authentication_agent_sync(d->pkAuthority, + subject.subject(), + objectPath.toUtf8().data(), + NULL, + &error); + + if (error != NULL) { + d->setError(E_UnregisterFailed, error->message); + g_error_free(error); + return false; + } + + return result; +} + +void Authority::unregisterAuthenticationAgent(const Subject &subject, const TQString &objectPath) +{ + if (Authority::instance()->hasError()) { + return; + } + + if (!subject.isValid()) { + d->setError(E_WrongSubject); + return; + } + + polkit_authority_unregister_authentication_agent(d->pkAuthority, + subject.subject(), + objectPath.toUtf8().data(), + d->m_unregisterAuthenticationAgentCancellable, + d->unregisterAuthenticationAgentCallback, + this); +} + +void Authority::Private::unregisterAuthenticationAgentCallback(GObject *object, GAsyncResult *result, gpointer user_data) +{ + Authority *authority = (Authority *) user_data; + Q_ASSERT(authority); + GError *error = NULL; + bool res = polkit_authority_unregister_authentication_agent_finish((PolkitAuthority *) object, result, &error); + if (error != NULL) { + // We don't want to set error if this is cancellation of some action + if (error->code != 1) { + authority->d->setError(E_UnregisterFailed, error->message); + } + g_error_free(error); + return; + } + + TQ_EMIT authority->unregisterAuthenticationAgentFinished(res); +} + +void Authority::unregisterAuthenticationAgentCancel() +{ + if (!g_cancellable_is_cancelled(d->m_unregisterAuthenticationAgentCancellable)) { + g_cancellable_cancel(d->m_unregisterAuthenticationAgentCancellable); + } +} + +bool Authority::authenticationAgentResponseSync(const TQString &cookie, const Identity &identity) +{ + if (Authority::instance()->hasError()) { + return false; + } + + if (cookie.isEmpty() || !identity.isValid()) { + d->setError(E_CookieOrIdentityEmpty); + return false; + } + + GError *error = NULL; + + bool result = polkit_authority_authentication_agent_response_sync(d->pkAuthority, + cookie.toUtf8().data(), + identity.identity(), + NULL, + &error); + if (error != NULL) { + d->setError(E_AgentResponseFailed, error->message); + g_error_free(error); + return false; + } + + return result; +} + +void Authority::authenticationAgentResponse(const TQString &cookie, const Identity &identity) +{ + if (Authority::instance()->hasError()) { + return; + } + + if (cookie.isEmpty() || !identity.isValid()) { + d->setError(E_CookieOrIdentityEmpty); + return; + } + + polkit_authority_authentication_agent_response(d->pkAuthority, + cookie.toUtf8().data(), + identity.identity(), + d->m_authenticationAgentResponseCancellable, + d->authenticationAgentResponseCallback, + this); +} + +void Authority::Private::authenticationAgentResponseCallback(GObject *object, GAsyncResult *result, gpointer user_data) +{ + Authority *authority = (Authority *) user_data; + Q_ASSERT(authority); + GError *error = NULL; + bool res = polkit_authority_authentication_agent_response_finish((PolkitAuthority *) object, result, &error); + if (error != NULL) { + // We don't want to set error if this is cancellation of some action + if (error->code != 1) { + authority->d->setError(E_AgentResponseFailed, error->message); + } + g_error_free(error); + return; + } + + TQ_EMIT authority->authenticationAgentResponseFinished(res); +} + +void Authority::authenticationAgentResponseCancel() +{ + if (!g_cancellable_is_cancelled(d->m_authenticationAgentResponseCancellable)) { + g_cancellable_cancel(d->m_authenticationAgentResponseCancellable); + } +} + +TemporaryAuthorization::List Authority::enumerateTemporaryAuthorizationsSync(const Subject &subject) +{ + TemporaryAuthorization::List result; + + GError *error = NULL; + GList *glist = polkit_authority_enumerate_temporary_authorizations_sync(d->pkAuthority, + subject.subject(), + NULL, + &error); + if (error != NULL) { + d->setError(E_EnumFailed, error->message); + g_error_free(error); + return result; + } + + GList *glist2; + for (glist2 = glist; glist2 != NULL; glist2 = g_list_next(glist2)) { + result.append(TemporaryAuthorization((PolkitTemporaryAuthorization *) glist2->data)); + g_object_unref(glist2->data); + } + + g_list_free(glist); + + return result; +} + +void Authority::Private::enumerateTemporaryAuthorizationsCallback(GObject *object, GAsyncResult *result, gpointer user_data) +{ + Authority *authority = (Authority *) user_data; + Q_ASSERT(authority); + GError *error = NULL; + + GList *glist = polkit_authority_enumerate_temporary_authorizations_finish((PolkitAuthority *) object, result, &error); + + if (error != NULL) { + // We don't want to set error if this is cancellation of some action + if (error->code != 1) { + authority->d->setError(E_EnumFailed, error->message); + } + g_error_free(error); + return; + } + TemporaryAuthorization::List res; + GList *glist2; + for (glist2 = glist; glist2 != NULL; glist2 = g_list_next(glist2)) { + res.append(TemporaryAuthorization((PolkitTemporaryAuthorization *) glist2->data)); + g_object_unref(glist2->data); + } + + g_list_free(glist); + + TQ_EMIT authority->enumerateTemporaryAuthorizationsFinished(res); +} + +void Authority::enumerateTemporaryAuthorizationsCancel() +{ + if (!g_cancellable_is_cancelled(d->m_enumerateTemporaryAuthorizationsCancellable)) { + g_cancellable_cancel(d->m_enumerateTemporaryAuthorizationsCancellable); + } +} + +bool Authority::revokeTemporaryAuthorizationsSync(const Subject &subject) +{ + bool result; + if (Authority::instance()->hasError()) { + return false; + } + + GError *error = NULL; + result = polkit_authority_revoke_temporary_authorizations_sync(d->pkAuthority, + subject.subject(), + NULL, + &error); + if (error != NULL) { + d->setError(E_RevokeFailed, error->message); + g_error_free(error); + return false; + } + return result; +} + +void Authority::revokeTemporaryAuthorizations(const Subject &subject) +{ + if (Authority::instance()->hasError()) { + return; + } + + polkit_authority_revoke_temporary_authorizations(d->pkAuthority, + subject.subject(), + d->m_revokeTemporaryAuthorizationsCancellable, + d->revokeTemporaryAuthorizationsCallback, + this); +} + +void Authority::Private::revokeTemporaryAuthorizationsCallback(GObject *object, GAsyncResult *result, gpointer user_data) +{ + Authority *authority = (Authority *) user_data; + Q_ASSERT(authority != NULL); + GError *error = NULL; + + bool res = polkit_authority_revoke_temporary_authorizations_finish((PolkitAuthority *) object, result, &error); + + if (error != NULL) { + // We don't want to set error if this is cancellation of some action + if (error->code != 1) { + authority->d->setError(E_RevokeFailed, error->message); + } + g_error_free(error); + return; + } + + TQ_EMIT authority->revokeTemporaryAuthorizationsFinished(res); +} + +void Authority::revokeTemporaryAuthorizationsCancel() +{ + if (!g_cancellable_is_cancelled(d->m_revokeTemporaryAuthorizationsCancellable)) { + g_cancellable_cancel(d->m_revokeTemporaryAuthorizationsCancellable); + } +} + +bool Authority::revokeTemporaryAuthorizationSync(const TQString &id) +{ + bool result; + if (Authority::instance()->hasError()) { + return false; + } + + GError *error = NULL; + result = polkit_authority_revoke_temporary_authorization_by_id_sync(d->pkAuthority, + id.toUtf8().data(), + NULL, + &error); + if (error != NULL) { + d->setError(E_RevokeFailed, error->message); + g_error_free(error); + return false; + } + return result; +} + +void Authority::revokeTemporaryAuthorization(const TQString &id) +{ + if (Authority::instance()->hasError()) { + return; + } + + polkit_authority_revoke_temporary_authorization_by_id(d->pkAuthority, + id.toUtf8().data(), + d->m_revokeTemporaryAuthorizationCancellable, + d->revokeTemporaryAuthorizationCallback, + this); +} + +void Authority::Private::revokeTemporaryAuthorizationCallback(GObject *object, GAsyncResult *result, gpointer user_data) +{ + Authority *authority = (Authority *) user_data; + Q_ASSERT(authority != NULL); + GError *error = NULL; + + bool res = polkit_authority_revoke_temporary_authorization_by_id_finish((PolkitAuthority *) object, result, &error); + + if (error != NULL) { + // We don't want to set error if this is cancellation of some action + if (error->code != 1) { + authority->d->setError(E_RevokeFailed, error->message); + } + g_error_free(error); + return; + } + + TQ_EMIT authority->revokeTemporaryAuthorizationFinished(res); +} + +void Authority::revokeTemporaryAuthorizationCancel() +{ + if (!g_cancellable_is_cancelled(d->m_revokeTemporaryAuthorizationCancellable)) { + g_cancellable_cancel(d->m_revokeTemporaryAuthorizationCancellable); + } +} + +} + +#include "polkittqt1-authority.moc" diff --git a/core/polkittqt1-authority.h b/core/polkittqt1-authority.h new file mode 100644 index 000000000..6ced45ad6 --- /dev/null +++ b/core/polkittqt1-authority.h @@ -0,0 +1,539 @@ +/* + * This file is part of the Polkit-tqt project + * Copyright (C) 2009 Daniel Nicoletti + * Copyright (C) 2009 Dario Freddi + * Copyright (C) 2009 Jaroslav Reznik + * Copyright (C) 2009 Radek Novacek + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef POLKITTQT1_AUTHORITY_H +#define POLKITTQT1_AUTHORITY_H + +#include "polkittqt1-export.h" +#include "polkittqt1-identity.h" +#include "polkittqt1-subject.h" +#include "polkittqt1-temporaryauthorization.h" +#include "polkittqt1-actiondescription.h" + +#include +#include + +typedef struct _PolkitAuthority PolkitAuthority; +class TQStringList; + +/** + * \namespace PolkitTQt1 PolkitTQt + * + * \brief Namespace wrapping Polkit-TQt classes + * + * This namespace wraps all Polkit-TQt classes. + */ +namespace PolkitTQt1 +{ + +/** + * \class Authority polkittqt1-authority.h Authority + * \author Daniel Nicoletti + * \author Dario Freddi + * \author Jaroslav Reznik + * + * \brief Convenience class for TQt/KDE applications + * + * This class is a singleton that provides makes easy the usage + * of PolKitAuthority. It emits configChanged() + * whenever PolicyKit files change (e.g. the PolicyKit.conf + * or .policy files) or when ConsoleKit reports activities changes. + * + * \note This class is a singleton, its constructor is private. + * Call Authority::instance() to get an instance of the Authority object. + * Do not delete Authority::instance(), cleanup will be done automatically. + */ +class POLKITTQT1_EXPORT Authority : public TQObject +{ + Q_OBJECT + TQ_DISABLE_COPY(Authority) + TQ_ENUMS(Result) + TQ_ENUMS(ErrorCode) +public: + enum Result { + /** Result unknown */ + Unknown = 0x00, + /** The subject is authorized for the specified action */ + Yes = 0x01, + /** The subject is not authorized for the specified action */ + No = 0x02, + /** The subject is authorized if more information is provided */ + Challenge = 0x03 + }; + + enum AuthorizationFlag { + /** No flags set **/ + None = 0x00, + /** If the subject can obtain the authorization through authentication, + * and an authentication agent is available, then attempt to do so. + * + * Note, this means that the method used for checking authorization is likely + * to block for a long time. **/ + AllowUserInteraction = 0x01 + }; + TQ_DECLARE_FLAGS(AuthorizationFlags, AuthorizationFlag) + + /** Error codes for the authority class */ + enum ErrorCode { + /** No error occurred **/ + E_None = 0x00, + /** Authority cannot be obtained **/ + E_GetAuthority = 0x01, + /** Authority check failed **/ + E_CheckFailed = 0x02, + /** Wrong or empty subject was given **/ + E_WrongSubject = 0x03, + /** Action returned unknown result **/ + E_UnknownResult = 0x04, + /** Enumerating actions failed **/ + E_EnumFailed = 0x05, + /** Registration of authentication agent failed **/ + E_RegisterFailed = 0x06, + /** Unregistration of authentication agent failed **/ + E_UnregisterFailed = 0x07, + /** Cookie or polkittqt1-identity.handled to the action is empty **/ + E_CookieOrIdentityEmpty = 0x08, + /** Response of auth agent failed **/ + E_AgentResponseFailed = 0x09, + /** Revoke temporary authorizations failed **/ + E_RevokeFailed = 0x0A + }; + + /** + * \brief Returns the instance of Authority + * + * Returns the current instance of Authority. Call this function whenever + * you need to access the Authority class. + * + * \note Authority is a singleton. Memory is handled by polkit-tqt, so you just + * need to call this function to get a working instance of Authority. + * Don't delete the object after having used it. + * + * \param authority use this if you want to set an explicit PolkitAuthority. If you + * don't know what this implies, simply ignore the parameter. In case + * you want to use it, be sure of streaming it the first time you call + * this function, otherwise it will have no effect. + * + * \return The current authority instance + */ + static Authority *instance(PolkitAuthority *authority = 0); + + ~Authority(); + + /** + * You should always call this method after every action. No action will be allowed + * if the object is in error state. Use clearError() to clear the error message. + * + * \see lastError + * \see clearError + * + * \return \c true if an error occurred, \c false if the library is ready + */ + bool hasError() const; + + /** + * \return the code of last error + */ + ErrorCode lastError() const; + + /** + * Get detail information about error that occurred. + * + * \return detail message + */ + const TQString errorDetails() const; + + /** + * Use this method to clear the error message. + */ + void clearError(); + + /** + * Returns the current instance of PolkitAuthority. If you are handling + * it through Polkit-tqt (which is quite likely, since you are calling + * this function), DO NOT use any PolicyKit API's specific method that + * modifies the instance on it, unless you're completely aware of what you're doing and + * of the possible consequencies. Use this instance only to gather information. + * + * \return the current PolkitAuthority instance + */ + PolkitAuthority *polkitAuthority() const; + + /** + * This function should be used by mechanisms (e.g.: helper applications). + * It returns the action should be carried out, so if the caller was + * actually authorized to perform it. The result is in form of a Result, so that + * you can have more control over the whole process, and detect an eventual error. + * Most of the times you simply want to check if the result is == to \c Result::Yes, + * if you don't have specific needs. + * + * It is CRITICAL that you call this function + * and check what it returns before doing anything in your helper, since otherwise + * you could be actually performing an action from an unknown or unauthorized caller. + * + * When operation is finished, signal checkAuthorizationFinish is emitted + * with result of authorization check in its parameter. + * + * \see checkAuthorizationSync Synchronous version of this method. + * \see checkAuthorizationFinished Signal that is emitted when this method finishes. + * \see checkAuthorizationCancel Use it to cancel execution of this method. + * + * \param actionId the Id of the action in question + * \param subject subject that the action is authorized for (e.g. unix process) + * \param flags flags that influences the authorization checking + * + * \return \c Result::Yes if the caller is authorized and the action should be performed + * \c otherwise if the caller was not authorized and the action should not be performed, + * or an error has occurred + * + */ + void checkAuthorization(const TQString &actionId, const Subject &subject, + AuthorizationFlags flags); + + /** + * Synchronous version of the checkAuthorization method. + * + * \param actionId the Id of the action in question + * \param subject subject that the action is authorized for (e.g. unix process) + * \param flags flags that influences the authorization checking + * + * \see checkAuthorization Asynchronous version of this method. + */ + Result checkAuthorizationSync(const TQString &actionId, const Subject &subject, + AuthorizationFlags flags); + + /** + * This method can be used to cancel last authorization check. + */ + void checkAuthorizationCancel(); + + /** + * Asynchronously retrieves all registered actions. + * + * When operation is finished, signal checkAuthorizationFinish is emitted + * with result of authorization check in its parameter. + * + * \see enumerateActionsSync Synchronous version of this method. + * \see enumerateActionsFinished Signal that is emitted when this method finishes. + * \see enumerateActionsCancel Use it to cancel execution of this method. + */ + void enumerateActions(); + + /** + * Synchronously retrieves all registered actions. + * + * \see enumerateActions Asynchronous version of this method. + * + * \return a list of Action IDs + */ + ActionDescription::List enumerateActionsSync(); + + /** + * This method can be used to cancel enumeration of actions + */ + void enumerateActionsCancel(); + + /** + * Registers an authentication agent. + * + * \see registerAuthenticationAgentSync Synchronous version of this method. + * \see registerAuthenticationAgentFinished Signal that is emitted when this method finishes. + * \see registerAuthenticationAgentCancel Use it to cancel execution of this method. + * + * \param subject caller subject + * \param locale the locale of the authentication agent + * \param objectPath the object path for the authentication agent + */ + void registerAuthenticationAgent(const Subject &subject, const TQString &locale, + const TQString &objectPath); + + /** + * Registers an authentication agent. + * + * \see registerAuthenticationAgent Asynchronous version of this method. + * + * \param subject caller subject + * \param locale the locale of the authentication agent + * \param objectPath the object path for the authentication agent + * + * \return \c true if the Authentication agent has been successfully registered + * \c false if the Authentication agent registration failed + */ + bool registerAuthenticationAgentSync(const Subject &subject, const TQString &locale, + const TQString &objectPath); + + /** + * This method can be used to cancel the registration of the authentication agent. + */ + void registerAuthenticationAgentCancel(); + + /** + * Unregisters an Authentication agent. + * + * \see unregisterAuthenticationAgentSync Synchronous version of this method. + * \see unregisterAuthenticationAgentFinished Signal that is emitted when this method finishes. + * \see unregisterAuthenticationAgentCancel Use it to cancel execution of this method. + * + * \param subject caller subject + * \param objectPath the object path for the Authentication agent + * + * \return \c true if the Authentication agent has been successfully unregistered + * \c false if the Authentication agent unregistration failed + */ + void unregisterAuthenticationAgent(const Subject &subject, const TQString &objectPath); + + /** + * Unregisters an Authentication agent. + * + * \see unregisterAuthenticationAgent Asynchronous version of this method. + * + * \param subject caller subject + * \param objectPath the object path for the Authentication agent + * + * \return \c true if the Authentication agent has been successfully unregistered + * \c false if the Authentication agent unregistration failed + */ + bool unregisterAuthenticationAgentSync(const Subject &subject, const TQString &objectPath); + + /** + * This method can be used to cancel the unregistration of the authentication agent. + */ + void unregisterAuthenticationAgentCancel(); + + /** + * Provide response that \p identity successfully authenticated for the authentication request identified by \p cookie. + * + * \see authenticationAgentResponseSync Synchronous version of this method. + * \see authenticationAgentResponseFinished Signal that is emitted when this method finishes. + * \see authenticationAgentResponseCancel Use it to cancel execution of this method. + * + * \param cookie The cookie passed to the authentication agent from the authority. + * \param identity The identity that was authenticated. + */ + void authenticationAgentResponse(const TQString &cookie, const Identity &identity); + + /** + * Provide response that \p identity successfully authenticated for the authentication request identified by \p cookie. + * + * \see authenticationAgentResponse Asynchronous version of this method. + * + * \param cookie The cookie passed to the authentication agent from the authority. + * \param identity The identity that was authenticated. + * + * \return \c true if authority acknowledged the call, \c false if error is set. + * + */ + bool authenticationAgentResponseSync(const TQString& cookie, const PolkitTQt1::Identity& identity); + + /** + * This method can be used to cancel the authenticationAgentResponseAsync method. + */ + void authenticationAgentResponseCancel(); + + /** + * Retrieves all temporary action that applies to \p subject. + * + * \see enumerateTemporaryAuthorizationsSync Synchronous version of this method. + * \see enumerateTemporaryAuthorizationsFinished Signal that is emitted when this method finishes. + * \see enumerateTemporaryAuthorizationsCancel Use it to cancel execution of this method. + * + * \param subject the subject to get temporary authorizations for + * + */ + void enumerateTemporaryAuthorizations(const Subject &subject); + + /** + * Retrieves all temporary action that applies to \p subject + * + * \see enumerateTemporaryAuthorizations Asynchronous version of this method. + * + * \param subject the subject to get temporary authorizations for + * + * \note Free all TemporaryAuthorization objects using \p delete operator. + * + * \return List of all temporary authorizations + */ + TemporaryAuthorization::List enumerateTemporaryAuthorizationsSync(const Subject &subject); + + /** + * This method can be used to cancel the enumerateTemporaryAuthorizationsAsync method. + */ + void enumerateTemporaryAuthorizationsCancel(); + + /** + * Revokes all temporary authorizations that applies to \p subject + * + * \see revokeTemporaryAuthorizationsSync Synchronous version of this method. + * \see revokeTemporaryAuthorizationsFinished Signal that is emitted when this method finishes. + * \see revokeTemporaryAuthorizationsCancel Use it to cancel execution of this method. + + * \param subject the subject to revoke temporary authorizations from + */ + void revokeTemporaryAuthorizations(const Subject &subject); + + /** + * Revokes all temporary authorizations that applies to \p subject + * + * \see revokeTemporaryAuthorizations Asynchronous version of this method. + * + * \param subject the subject to revoke temporary authorizations from + * + * \return \c true if all temporary authorization were revoked + * \c false if the revoking failed + */ + bool revokeTemporaryAuthorizationsSync(const Subject &subject); + + /** + * This method can be used to cancel the method revokeTemporaryAuthorizationsAsync. + */ + void revokeTemporaryAuthorizationsCancel(); + + /** + * Revokes temporary authorization by \p id + * + * \see revokeTemporaryAuthorizationSync Synchronous version of this method. + * \see revokeTemporaryAuthorizationFinished Signal that is emitted when this method finishes. + * \see revokeTemporaryAuthorizationCancel Use it to cancel execution of this method. + * + * \param id the identifier of the temporary authorization + */ + void revokeTemporaryAuthorization(const TQString &id); + + /** + * Revokes temporary authorization by \p id + * + * \see revokeTemporaryAuthorization Asynchronous version of this method. + * + * \param id the identifier of the temporary authorization + * + * \return \c true if the temporary authorization was revoked + * \c false if the revoking failed + */ + bool revokeTemporaryAuthorizationSync(const TQString &id); + + /** + * This method can be used to cancel the method revokeTemporaryAuthorizationAsync. + */ + void revokeTemporaryAuthorizationCancel(); + +Q_SIGNALS: + /** + * This signal will be emitted when a configuration + * file gets changed (e.g. /etc/PolicyKit/PolicyKit.conf or + * .policy files). + * Connect to this signal if you want to track down + * actions. + */ + void configChanged(); + + /** + * This signal is emitted when ConsoleKit configuration + * changes. This might happen when a session becomes active + * or inactive. + * + * If you want to track your actions directly you should + * connect to this signal, as this might change the return value + * PolicyKit will give you. + * + * \note If you use Action you'll probably prefer to + * use the dataChanged() signal to track Action changes. + */ + void consoleKitDBChanged(); + + /** + * This signal is emitted when asynchronous method checkAuthorization finishes. + * + * The argument is the result of authorization. + */ + void checkAuthorizationFinished(PolkitTQt1::Authority::Result); + + /** + * This signal is emitted when asynchronous method enumerateActions finishes. + * + * The argument is the list of all Action IDs. + */ + void enumerateActionsFinished(PolkitTQt1::ActionDescription::List); + + /** + * This signal is emitted when asynchronous method registerAuthenticationAgent finishes. + * + * The argument is \c true if the Authentication agent has been successfully registered + * \c false if the Authentication agent registration failed + */ + void registerAuthenticationAgentFinished(bool); + + /** + * This signal is emitted when asynchronous method unregisterAuthenticationAgent finishes. + * + * The argument is \c true if the Authentication agent has been successfully unregistered + * \c false if the Authentication agent unregistration failed + */ + void unregisterAuthenticationAgentFinished(bool); + + /** + * This signal is emitted when asynchronous method authenticationAgentResponse finishes. + * + * The argument is \c true if authority acknowledged the call, \c false if error is set. + */ + void authenticationAgentResponseFinished(bool); + + /** + * This signal is emmited when asynchronous method enumerateTemporaryAuthorizations finishes. + * + * The argument is list of all temporary authorizations. + * + * \note Free all TemporaryAuthorization objects using \p delete operator. + */ + void enumerateTemporaryAuthorizationsFinished(PolkitTQt1::TemporaryAuthorization::List); + + /** + * This signal is emmited when asynchronous method revokeTemporaryAuthorizations finishes. + * + * The argument is \c true if all temporary authorizations were revoked + * \c false if the revoking failed + */ + void revokeTemporaryAuthorizationsFinished(bool); + + /** + * This signal is emmited when asynchronous method revokeTemporaryAuthorization finishes. + * \return \c true if the temporary authorization was revoked + * \c false if the revoking failed + */ + void revokeTemporaryAuthorizationFinished(bool); + +private: + explicit Authority(PolkitAuthority *context, TQObject *parent = 0); + + class Private; + friend class Private; + Private * const d; + + Q_PRIVATE_SLOT(d, void dbusFilter(const TQDBusMessage &message)) +}; + +} + +Q_DECLARE_OPERATORS_FOR_FLAGS(PolkitTQt1::Authority::AuthorizationFlags) +Q_DECLARE_METATYPE(PolkitTQt1::Authority::Result) + +#endif diff --git a/core/polkittqt1-details.cpp b/core/polkittqt1-details.cpp new file mode 100644 index 000000000..3175926c8 --- /dev/null +++ b/core/polkittqt1-details.cpp @@ -0,0 +1,99 @@ +/* + * This file is part of the Polkit-tqt project + * Copyright (C) 2009 Radek Novacek + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "polkittqt1-details.h" + +#include + +#include + +namespace PolkitTQt1 +{ + +class Details::Data : public TQSharedData +{ +public: + Data() {} + Data(const Data &other) + : TQSharedData(other) + , polkitDetails(other.polkitDetails) + { + g_object_ref(polkitDetails); + } + ~Data() + { + g_object_unref(polkitDetails); + } + + PolkitDetails *polkitDetails; +}; + +Details::Details() + : d(new Data) +{ + g_type_init(); + d->polkitDetails = polkit_details_new(); +} + +Details::Details(PolkitDetails *pkDetails) + : d(new Data) +{ + g_type_init(); + d->polkitDetails = pkDetails; +} + +Details::~Details() +{ +} + +Details& Details::operator=(const PolkitTQt1::Details& other) +{ + d = other.d; + return *this; +} + +TQString Details::lookup(const TQString &key) const +{ + const gchar *result = polkit_details_lookup(d->polkitDetails, key.toUtf8().data()); + if (result != NULL) { + return TQString::fromUtf8(result); + } else { + return TQString(); + } +} + +void Details::insert(const TQString &key, const TQString &value) +{ + polkit_details_insert(d->polkitDetails, key.toUtf8().data(), value.toUtf8().data()); +} + +TQStringList Details::keys() const +{ + gchar **result = polkit_details_get_keys(d->polkitDetails); + TQStringList list; + int len = g_strv_length(result); + for (int i = 0; i < len; i++) { + list.append(TQString::fromUtf8(result[i])); + } + g_strfreev(result); + return list; +} + +} diff --git a/core/polkittqt1-details.h b/core/polkittqt1-details.h new file mode 100644 index 000000000..89e4e5b80 --- /dev/null +++ b/core/polkittqt1-details.h @@ -0,0 +1,97 @@ +/* + * This file is part of the Polkit-tqt project + * Copyright (C) 2009 Radek Novacek + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef POLKITTQT1_DETAILS_H +#define POLKITTQT1_DETAILS_H + +#include "polkittqt1-export.h" + +#include +#include + +typedef struct _PolkitDetails PolkitDetails; + +/** + * \namespace PolkitTQt1 PolkitTQt + * + * \brief Namespace wrapping Polkit-TQt classes + * + * This namespace wraps all Polkit-TQt classes. + */ +namespace PolkitTQt1 +{ + +/** + * \class Details polkittqt1-details.h Details + * \author Radek Novacek + * + * \brief Class used for passing details around. + */ +class POLKITTQT1_EXPORT Details +{ +public: + /** + * Creates a new Details object + */ + Details(); + + /** + * Creates Details object from PolkitDetails + * + * \warning Use this only if you are completely aware of what are you doing! + * + * \param pkDetails PolkitDetails object + */ + explicit Details(PolkitDetails *pkDetails); + + ~Details(); + + Details &operator=(const Details &other); + + /** + * Get the value for \p key + * + * \param key A key + * \return Value of the key \p key, otherwise empty TQString. + */ + TQString lookup(const TQString &key) const; + + /** + * Inserts key \p key with value \p value. + * + * \param key A key. + * \param value A value. + */ + void insert(const TQString &key, const TQString &value); + + /** + * Gets a list of all keys. + * + * \return List of all keys. + */ + TQStringList keys() const; +private: + class Data; + TQExplicitlySharedDataPointer< Data > d; +}; + +} + +#endif // DETAILS_H diff --git a/core/polkittqt1-identity.cpp b/core/polkittqt1-identity.cpp new file mode 100644 index 000000000..8be2b55dc --- /dev/null +++ b/core/polkittqt1-identity.cpp @@ -0,0 +1,227 @@ +/* + * This file is part of the Polkit-tqt project + * Copyright (C) 2009 Lukas Tinkl + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "polkittqt1-identity.h" + +#include + +#include + +namespace PolkitTQt1 +{ + +class Identity::Data : public TQSharedData +{ +public: + Data() : identity(0) {} + Data(const Data& other) + : TQSharedData(other) + , identity(other.identity) + { + if (identity) { + g_object_ref(identity); + } + } + ~Data() + { + if (identity) { + g_object_unref(identity); + } + } + + PolkitIdentity *identity; +}; + +Identity::Identity() + : d(new Data) +{ + g_type_init(); +} + +Identity::Identity(PolkitIdentity *polkitIdentity) + : d(new Data) +{ + g_type_init(); + d->identity = polkitIdentity; + + if (d->identity) { + g_object_ref(d->identity); + } +} + +Identity::Identity(const PolkitTQt1::Identity& other) + : d(other.d) +{ + +} + +Identity::~Identity() +{ +} + +Identity& Identity::operator=(const PolkitTQt1::Identity& other) +{ + d = other.d; + return *this; +} + +bool Identity::isValid() const +{ + return d->identity != NULL; +} + +PolkitIdentity *Identity::identity() const +{ + return d->identity; +} + +void Identity::setIdentity(PolkitIdentity *identity) +{ + if (d->identity == identity) { + return; + } + + if (d->identity) { + g_object_unref(d->identity); + } + + d->identity = identity; + + if (d->identity) { + g_object_ref(d->identity); + } +} + +TQString Identity::toString() const +{ + Q_ASSERT(d->identity); + return TQString::fromUtf8(polkit_identity_to_string(d->identity)); +} + +Identity Identity::fromString(const TQString &string) +{ + GError *error = NULL; + PolkitIdentity *pkIdentity = polkit_identity_from_string(string.toUtf8().data(), &error); + if (error != NULL) { + tqWarning() << TQString("Cannot create Identity from string: %1").arg(error->message); + return Identity(); + } + return Identity(pkIdentity); +} + +UnixGroupIdentity Identity::toUnixGroupIdentity() +{ + UnixGroupIdentity *ugid = static_cast< UnixGroupIdentity* >(this); + if (!ugid) { + return UnixGroupIdentity(); + } + + return *ugid; +} + +UnixUserIdentity Identity::toUnixUserIdentity() +{ + UnixUserIdentity *uuid = static_cast< UnixUserIdentity* >(this); + if (!uuid) { + return UnixUserIdentity(); + } + + return *uuid; +} + +UnixUserIdentity::UnixUserIdentity(const TQString &name) + : Identity() +{ + GError *error = NULL; + setIdentity(polkit_unix_user_new_for_name(name.toUtf8().data(), &error)); + if (error != NULL) { + tqWarning() << TQString("Cannot create UnixUserIdentity: %1").arg(error->message); + setIdentity(NULL); + } +} + +UnixUserIdentity::UnixUserIdentity(uid_t uid) + : Identity() +{ + setIdentity(polkit_unix_user_new(uid)); +} + +UnixUserIdentity::UnixUserIdentity(PolkitUnixUser *pkUnixUser) + : Identity((PolkitIdentity *)pkUnixUser) +{ + +} + +UnixUserIdentity::UnixUserIdentity() + : Identity() +{ + +} + +uid_t UnixUserIdentity::uid() const +{ + return polkit_unix_user_get_uid((PolkitUnixUser *) identity()); +} + +void UnixUserIdentity::setUid(uid_t uid) +{ + polkit_unix_user_set_uid((PolkitUnixUser *) identity(), uid); +} + +UnixGroupIdentity::UnixGroupIdentity(const TQString &name) + : Identity() +{ + GError *error = NULL; + setIdentity(polkit_unix_group_new_for_name(name.toUtf8().data(), &error)); + if (error != NULL) { + tqWarning() << TQString("Cannot create UnixGroupIdentity: %1").arg(error->message); + setIdentity(NULL); + } +} + +UnixGroupIdentity::UnixGroupIdentity(gid_t gid) + : Identity() +{ + setIdentity(polkit_unix_group_new(gid)); +} + +UnixGroupIdentity::UnixGroupIdentity(PolkitUnixGroup *pkUnixGroup) + : Identity((PolkitIdentity *) pkUnixGroup) +{ + +} + +UnixGroupIdentity::UnixGroupIdentity() + : Identity() +{ + +} + +gid_t UnixGroupIdentity::gid() const +{ + return polkit_unix_group_get_gid((PolkitUnixGroup *) identity()); +} + +void UnixGroupIdentity::setGid(gid_t gid) +{ + polkit_unix_group_set_gid((PolkitUnixGroup *) identity(), gid); +} + +} diff --git a/core/polkittqt1-identity.h b/core/polkittqt1-identity.h new file mode 100644 index 000000000..600eba5e8 --- /dev/null +++ b/core/polkittqt1-identity.h @@ -0,0 +1,211 @@ +/* + * This file is part of the Polkit-tqt project + * Copyright (C) 2009 Lukas Tinkl + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef POLKITTQT1_IDENTITY_H +#define POLKITTQT1_IDENTITY_H + +#include "polkittqt1-export.h" + +#include + +#include +#include + +typedef struct _PolkitIdentity PolkitIdentity; +typedef struct _PolkitUnixUser PolkitUnixUser; +typedef struct _PolkitUnixGroup PolkitUnixGroup; + +/** + * \namespace PolkitTQt1 PolkitTQt + * + * \brief Namespace wrapping Polkit-TQt classes + * + * This namespace wraps all Polkit-TQt classes. + */ +namespace PolkitTQt1 +{ + +class UnixUserIdentity; +class UnixGroupIdentity; + +/** + * \class Identity polkittqt1-identity.h Identity + * \author Lukas Tinkl + * + * This class encapsulates the PolkitIdentity interface. + * + * \brief Abstract class representing identities + * + * \see UnixGroup + * \see UnixUser + */ +class POLKITTQT1_EXPORT Identity +{ +public: + typedef TQList< Identity > List; + + Identity(); + explicit Identity(PolkitIdentity *polkitIdentity); + Identity(const Identity &other); + + ~Identity(); + + Identity &operator=(const Identity &other); + + bool isValid() const; + + /** + * Serialization of object to the string + * + * \return Serialized Identity object + */ + TQString toString() const; + + /** + * Creates the Identity object from string representation + * + * \param string string representation of the object + * + * \return Pointer to new Identity instance + */ + static Identity fromString(const TQString &string); + + UnixUserIdentity toUnixUserIdentity(); + UnixGroupIdentity toUnixGroupIdentity(); + + /** + * Gets PolkitIdentity object. + * + * \warning It shouldn't be used directly unless you are completely aware of what are you doing + * + * \return Pointer to PolkitIdentity instance + */ + PolkitIdentity *identity() const; +protected: + void setIdentity(PolkitIdentity *identity); + +private: + class Data; + TQExplicitlySharedDataPointer< Data > d; +}; + +/** + * \class UnixUserIdentity polkittqt1-identity.h Identity + * + * An object representing a user identity on a UNIX system. + * + * \brief UNIX user identity + * \sa Identity + */ +class POLKITTQT1_EXPORT UnixUserIdentity : public Identity +{ +public: + UnixUserIdentity(); + /** + * Creates UnixUser object by UID of the user + * + * \param uid user id + */ + explicit UnixUserIdentity(uid_t uid); + + /** + * Creates UnixUser object by unix name of the user + * + * \param name Unix name + */ + explicit UnixUserIdentity(const TQString &name); + + /** + * Creates UnixUser object from PolkitUnixUser object + * + * \warning Use this only if you are completely aware of what are you doing! + * + * \param pkUnixUser The PolkitUnixUser object + */ + explicit UnixUserIdentity(PolkitUnixUser *pkUnixUser); + + /** + * Gets an user id + * + * \return user id + */ + uid_t uid() const; + + /** + * Sets the id of user + * + * \param uid user id + */ + void setUid(uid_t uid); +}; + +/** + * \class UnixGroupIdentity polkittqt1-identity.h Identity + * + * An object representing a group identity on a UNIX system. + * + * \brief UNIX group identity + * \sa Identity + */ +class POLKITTQT1_EXPORT UnixGroupIdentity : public Identity +{ +public: + UnixGroupIdentity(); + /** + * Creates UnixGroup object by GID of the group + * + * \param gid group id + */ + explicit UnixGroupIdentity(gid_t gid); + + /** + * Creates UnixGroup object by unix name of the group + * + * \param name group name + */ + explicit UnixGroupIdentity(const TQString &name); + + /** + * Creates UnixGroup object from PolkitUnixGroup object + * + * \warning Use this only if you are completely aware of what are you doing! + * + * \param pkUnixGroup The PolkitUnixGroup object + */ + explicit UnixGroupIdentity(PolkitUnixGroup *pkUnixGroup); + + /** + * Gets a group id + * + * \return group id + */ + gid_t gid() const; + + /** + * Sets the id of group + * + * \param gid group id + */ + void setGid(gid_t gid); +}; + +} + +#endif // POLKIT_TQT_IDENTITY_H diff --git a/core/polkittqt1-subject.cpp b/core/polkittqt1-subject.cpp new file mode 100644 index 000000000..bafeaee56 --- /dev/null +++ b/core/polkittqt1-subject.cpp @@ -0,0 +1,205 @@ +/* + * This file is part of the Polkit-tqt project + * Copyright (C) 2009 Jaroslav Reznik + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "polkittqt1-subject.h" + +#include +#include + +namespace PolkitTQt1 +{ + +class Subject::Data : public TQSharedData +{ +public: + Data() + : TQSharedData() + , subject(0) + {} + Data(const Data& other) + : TQSharedData(other) + , subject(other.subject) + { + g_object_ref(subject); + } + ~Data() + { + g_object_unref(subject); + } + + PolkitSubject *subject; +}; + +Subject::Subject() + : d(new Data) +{ + g_type_init(); +} + +Subject::Subject(PolkitSubject *subject) + : d(new Data) +{ + g_type_init(); + d->subject = subject; +} + +Subject::Subject(const PolkitTQt1::Subject& other) + : d(other.d) +{ + +} + +Subject& Subject::operator=(const PolkitTQt1::Subject& other) +{ + d = other.d; + return *this; +} + +Subject::~Subject() +{ +} + +bool Subject::isValid() const +{ + return d->subject != NULL; +} + +PolkitSubject *Subject::subject() const +{ + return d->subject; +} + +void Subject::setSubject(PolkitSubject *subject) +{ + d->subject = subject; +} + +TQString Subject::toString() const +{ + Q_ASSERT(d->subject); + return TQString::fromUtf8(polkit_subject_to_string(d->subject)); +} + +Subject Subject::fromString(const TQString &string) +{ + // should be in polkit library!!! but for strange reason it's necessary to have it here + g_type_init(); + + Subject subject; + GError *error = NULL; + subject.d->subject = polkit_subject_from_string(string.toUtf8().data(), &error); + if (error != NULL) { + tqWarning() << TQString("Cannot create Subject from string: %1").arg(error->message); + return NULL; + } + return subject; +} + +UnixProcessSubject::UnixProcessSubject(tqint64 pid) + : Subject() +{ + setSubject(polkit_unix_process_new(pid)); +} + +UnixProcessSubject::UnixProcessSubject(tqint64 pid, tquint64 startTime) + : Subject() +{ + setSubject(polkit_unix_process_new_full(pid, startTime)); +} + +UnixProcessSubject::UnixProcessSubject(PolkitUnixProcess *pkUnixProcess) + : Subject((PolkitSubject *) pkUnixProcess) +{ + +} + +tqint64 UnixProcessSubject::pid() const +{ + return polkit_unix_process_get_pid((PolkitUnixProcess *) subject()); +} + +tqint64 UnixProcessSubject::startTime() const +{ + return polkit_unix_process_get_start_time((PolkitUnixProcess *) subject()); +} + +void UnixProcessSubject::setPid(tqint64 pid) +{ + polkit_unix_process_set_pid((PolkitUnixProcess *) subject(), pid); +} + +// ----- SystemBusName +SystemBusNameSubject::SystemBusNameSubject(const TQString &name) + : Subject() +{ + setSubject(polkit_system_bus_name_new(name.toUtf8().data())); +} + +SystemBusNameSubject::SystemBusNameSubject(PolkitSystemBusName *pkSystemBusName) + : Subject((PolkitSubject *) pkSystemBusName) +{ + +} + +TQString SystemBusNameSubject::name() const +{ + return TQString::fromUtf8(polkit_system_bus_name_get_name((PolkitSystemBusName *) subject())); +} + +void SystemBusNameSubject::setName(const TQString &name) +{ + polkit_system_bus_name_set_name((PolkitSystemBusName *) subject(), name.toUtf8().data()); +} + +// ----- SystemSession +UnixSessionSubject::UnixSessionSubject(const TQString &sessionId) + : Subject() +{ + setSubject(polkit_unix_session_new(sessionId.toUtf8().data())); +} + +UnixSessionSubject::UnixSessionSubject(tqint64 pid) + : Subject() +{ + GError *error = NULL; + setSubject(polkit_unix_session_new_for_process_sync(pid, NULL, &error)); + if (error != NULL) { + tqWarning() << TQString("Cannot create unix session: %1").arg(error->message); + setSubject(NULL); + } +} + +UnixSessionSubject::UnixSessionSubject(PolkitSystemBusName *pkUnixSession) + : Subject((PolkitSubject *) pkUnixSession) +{ + +} + +TQString UnixSessionSubject::sessionId() const +{ + return TQString::fromUtf8(polkit_unix_session_get_session_id((PolkitUnixSession *) subject())); +} + +void UnixSessionSubject::setSessionId(const TQString &sessionId) +{ + polkit_unix_session_set_session_id((PolkitUnixSession *) subject(), sessionId.toUtf8().data()); +} + +} diff --git a/core/polkittqt1-subject.h b/core/polkittqt1-subject.h new file mode 100644 index 000000000..3f3b10279 --- /dev/null +++ b/core/polkittqt1-subject.h @@ -0,0 +1,262 @@ +/* + * This file is part of the PolKit1-tqt project + * Copyright (C) 2009 Jaroslav Reznik + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef POLKITTQT1_SUBJECT_H +#define POLKITTQT1_SUBJECT_H + +#include "polkittqt1-export.h" + +#include +#include + +typedef struct _PolkitSubject PolkitSubject; +typedef struct _PolkitUnixProcess PolkitUnixProcess; +typedef struct _PolkitSystemBusName PolkitSystemBusName; + +/** + * \namespace PolkitTQt1 PolkitTQt + * + * \brief Namespace wrapping PolicyKit-TQt classes + * + * This namespace wraps all PolicyKit-TQt classes. + */ +namespace PolkitTQt1 +{ + +/** + * \class Subject polkittqt1-subject.h Subject + * \author Jaroslav Reznik + * + * \brief This class represents PolicyKit subjects + * + * This class encapsulates the PolkitSubject interface. + * + * \see UnixProcess + * \see SystemBusName + * \see UnixSession + */ +class POLKITTQT1_EXPORT Subject +{ +public: + Subject(); + Subject(const Subject &other); + ~Subject(); + + Subject &operator=(const Subject &other); + + bool isValid() const; + + /** + * Serialization of object to the string + * + * \return Serialized Subject object + */ + TQString toString() const; + + /** + * Creates the Subject object from string reprezentation + * + * \param string string reprezentation of the object + * + * \return Pointer to new Subject instance + */ + static Subject fromString(const TQString &string); + + /** + * Gets PolkitSubject object. + * + * \warning It shouldn't be used directly unless you are completely aware of what are you doing + * + * \return Pointer to PolkitSubject instance + */ + PolkitSubject *subject() const; + +protected: + Subject(PolkitSubject *subject); + + void setSubject(PolkitSubject *subject); + +private: + class Data; + TQExplicitlySharedDataPointer< Data > d; +}; + +/** + * \class UnixProcessSubject polkittqt1-subject.h Subject + * \author Jaroslav Reznik + * + * \brief A class for representing a UNIX process. + * + * To uniquely identify processes, both the process + * id and the start time of the process (a monotonic + * increasing value representing the time since the + * kernel was started) is used. + * + * \sa Subject + */ +class POLKITTQT1_EXPORT UnixProcessSubject : public Subject +{ +public: + /** + * Subject constructor, takes one parameter - PID. The start time + * of process will be looked automatically. + * + * \param pid An Unix process PID. + */ + explicit UnixProcessSubject(tqint64 pid); + + /** + * Subject constructor, takes two parameters - PID and start time. + * + * \param pid An Unix process PID. + * \param startTime An Unix process start time. + */ + UnixProcessSubject(tqint64 pid, tquint64 startTime); + + /** + * Subject constructor, it creates UnixProcess object from PolkitUnixProcess object + * + * \warning Use this only if you are completely aware of what are you doing! + * + * \param process PolkitUnixProcess object + */ + explicit UnixProcessSubject(PolkitUnixProcess *process); + + /** + * Returns Unix process PID. + * + * \return A PID of associated Unix process. + */ + tqint64 pid() const; + + /** + * Returns Unix process start time. + * + * \return A start time of associated Unix process. + */ + tqint64 startTime() const; + + /** + * Sets Unix process PID. + * + * \param pid An Unix process PID. + */ + void setPid(tqint64 pid); +}; + +/** + * \class SystemBusNameSubject polkittqt1-subject.h Subject + * \author Jaroslav Reznik + * + * \brief A class for representing a process owning a unique name on the system bus. + * + * \sa Subject + */ +class POLKITTQT1_EXPORT SystemBusNameSubject : public Subject +{ +public: + /** + * Subject constructor, takes one parameter - system bus name. + * + * \param name A unique system bus name. + */ + explicit SystemBusNameSubject(const TQString &name); + + /** + * Subject constructor, it creates SystemBusName object from PolkitSystemBusName object + * + * \warning Use this only if you are completely aware of what are you doing! + * + * \param pkSystemBusName PolkitSystemBusName object + */ + explicit SystemBusNameSubject(PolkitSystemBusName *pkSystemBusName); + + /** + * Returns system bus name. + * + * \return A unique system bus name. + */ + TQString name() const; + + /** + * Sets system bus name. + * + * \param name System bus name. + */ + void setName(const TQString &name); +}; + +/** + * \class UnixSessionSubject polkittqt1-subject.h Subject + * \author Jaroslav Reznik + * + * \brief A class for representing unix session. + * + * The session id is an opaque string obtained from + * ConsoleKit. + * + * \sa Subject + */ +class POLKITTQT1_EXPORT UnixSessionSubject : public Subject +{ +public: + /** + * Subject constructor, takes one parameter - session id. + * + * \param sessionId The session id. + */ + explicit UnixSessionSubject(const TQString &sessionId); + + /** + * Subject constructor, takes one parameter - pid of process. + * + * Synchronous! + * + * \param pid The session's process pid. + */ + explicit UnixSessionSubject(tqint64 pid); + + /** + * Subject constructor, it creates UnixSession object from PolkitUnixSession object + * + * \warning Use this only if you are completely aware of what are you doing! + * + * \param pkUnixSession PolkitUnixSession object + */ + explicit UnixSessionSubject(PolkitSystemBusName *pkUnixSession); + + /** + * Returns session id. + * + * \return A session id. + */ + TQString sessionId() const; + + /** + * Sets session id. + * + * \param sessionId A session id. + */ + void setSessionId(const TQString &sessionId); +}; + +} + +#endif diff --git a/core/polkittqt1-temporaryauthorization.cpp b/core/polkittqt1-temporaryauthorization.cpp new file mode 100644 index 000000000..e0aa01871 --- /dev/null +++ b/core/polkittqt1-temporaryauthorization.cpp @@ -0,0 +1,117 @@ +/* + * This file is part of the PolKit1-tqt project + * Copyright (C) 2009 Radek Novacek + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "polkittqt1-temporaryauthorization.h" +#include "polkittqt1-authority.h" + +#include + +namespace PolkitTQt1 +{ + +class TemporaryAuthorization::Data : public TQSharedData +{ +public: + Data() {} + Data(const Data& other) + : TQSharedData(other) + , id(other.id) + , actionId(other.actionId) + , subject(other.subject) + , timeObtained(other.timeObtained) + , timeExpires(other.timeExpires) + { + } + ~Data() {} + + TQString id; + TQString actionId; + Subject subject; + TQDateTime timeObtained; + TQDateTime timeExpires; +}; + +TemporaryAuthorization::TemporaryAuthorization(PolkitTemporaryAuthorization *pkTemporaryAuthorization) + : d(new Data) +{ + g_type_init(); + d->id = TQString::fromUtf8(polkit_temporary_authorization_get_id(pkTemporaryAuthorization)); + d->actionId = TQString::fromUtf8(polkit_temporary_authorization_get_action_id(pkTemporaryAuthorization)); + d->subject = Subject::fromString(polkit_subject_to_string(polkit_temporary_authorization_get_subject(pkTemporaryAuthorization))); + d->timeObtained = TQDateTime::fromTime_t(polkit_temporary_authorization_get_time_obtained(pkTemporaryAuthorization)); + d->timeExpires = TQDateTime::fromTime_t(polkit_temporary_authorization_get_time_expires(pkTemporaryAuthorization)); + g_object_unref(pkTemporaryAuthorization); +} + +TemporaryAuthorization::TemporaryAuthorization(const PolkitTQt1::TemporaryAuthorization& other) + : d(other.d) +{ + +} + +TemporaryAuthorization::TemporaryAuthorization() + : d(new Data) +{ + +} + +TemporaryAuthorization& TemporaryAuthorization::operator=(const PolkitTQt1::TemporaryAuthorization& other) +{ + d = other.d; + return *this; +} + +TemporaryAuthorization::~TemporaryAuthorization() +{ +} + +TQString TemporaryAuthorization::id() const +{ + return d->id; +} + +TQString TemporaryAuthorization::actionId() const +{ + return d->actionId; +} + +Subject TemporaryAuthorization::subject() const +{ + //tqFatal(polkit_subject_to_string(polkit_temporary_authorization_get_subject(d->temporaryAuthorization))); + return d->subject;//Subject::fromString(polkit_subject_to_string(d->subject)); +} + +TQDateTime TemporaryAuthorization::obtainedAt() const +{ + return d->timeObtained; +} + +TQDateTime TemporaryAuthorization::expirationTime() const +{ + return d->timeExpires; +} + +bool TemporaryAuthorization::revoke() +{ + Authority::instance()->revokeTemporaryAuthorization(id()); + return true; +} + +} diff --git a/core/polkittqt1-temporaryauthorization.h b/core/polkittqt1-temporaryauthorization.h new file mode 100644 index 000000000..8fbbaaa94 --- /dev/null +++ b/core/polkittqt1-temporaryauthorization.h @@ -0,0 +1,124 @@ +/* + * This file is part of the PolKit1-qt project + * Copyright (C) 2009 Radek Novacek + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef POLKITTQT1_TEMPORARYAUTHORIZATION_H +#define POLKITTQT1_TEMPORARYAUTHORIZATION_H + +#include "polkittqt1-subject.h" + +#include +#include +#include +#include + +typedef struct _PolkitTemporaryAuthorization PolkitTemporaryAuthorization; + +/** + * \namespace PolkitTQt1 PolkitTQt + * + * \brief Namespace wrapping PolicyKit-TQt classes + * + * This namespace wraps all PolicyKit-TQt classes. + */ +namespace PolkitTQt1 +{ + +/** + * \class TemporaryAuthorization polkittqt1-temporaryauthorization.h TemporaryAuthorization + * \author Radek Novacek + * + * \brief This class represents PolicyKit temporary authorization + * + * This class encapsulates the PolkitTemporaryAuthorization interface. + */ +class POLKITTQT1_EXPORT TemporaryAuthorization +{ +public: + typedef TQList< TemporaryAuthorization > List; + TemporaryAuthorization(); + /** + * Creates TemporaryAuthorization object from PolkitTemporaryAuthorization + * + * \warning It shouldn't be used directly unless you are completely aware of what are you doing + * + * \param pkTemporaryAuthorization PolkitTemporaryAuthorization object + * \param parent + */ + explicit TemporaryAuthorization(PolkitTemporaryAuthorization *pkTemporaryAuthorization); + TemporaryAuthorization(const TemporaryAuthorization &other); + + ~TemporaryAuthorization(); + + TemporaryAuthorization &operator=(const TemporaryAuthorization &other); + + /** + * \brief Gets the identifier for the authorization. + * + * This identifier can be user by the revokeTemporaryAuthorization function + * + * \return Unique identifier for the authorization + */ + TQString id() const; + + /** + * \brief Gets the identifier of the action that authorization is for + * + * \return String that identifies the action + */ + TQString actionId() const; + + /** + * \brief Gets the subject that authorization is for + * + * \return A Subject. + */ + Subject subject() const; + + /** + * \brief Gets the time when authorization was obtained + * + * \return Time of obtaining the authorization + */ + TQDateTime obtainedAt() const; + + /** + * \brief Gets the time when authorizaton will expire + * + * \return Time of expiration + */ + TQDateTime expirationTime() const; + + /** + * \brief Revoke temporary authorization + * + * \return \c true Authorization has been revoked + * \c false Revoking authorization failed + */ + bool revoke(); + +private: + class Data; + TQSharedDataPointer< Data > d; +}; +} + +TQ_DECLARE_METATYPE(PolkitTQt1::TemporaryAuthorization::List) + +#endif // TEMPORARYAUTHORIZATION_H diff --git a/debian/changelog b/debian/changelog index 0491bf8d7..8552b3f5b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -polkit-qt-1 (0.103.0-1) unstable; urgency=low +polkit-tqt-1 (0.103.0-1) unstable; urgency=low * New upstream release. - fix annoying crash on shutdown. (Closes: #651815) @@ -12,14 +12,14 @@ polkit-qt-1 (0.103.0-1) unstable; urgency=low -- Debian Qt/KDE Maintainers Wed, 14 Dec 2011 09:15:10 -0500 -polkit-qt-1 (0.99.0-3) unstable; urgency=low +polkit-tqt-1 (0.99.0-3) unstable; urgency=low [ Modestas Vainius ] * Update symbol files. -- Debian Qt/KDE Maintainers Thu, 26 May 2011 00:31:01 +0300 -polkit-qt-1 (0.99.0-2) experimental; urgency=low +polkit-tqt-1 (0.99.0-2) experimental; urgency=low * Bump Standards-Version to 3.9.2: no changes needed. * Build library with -fvisibility=hidden -fvisibility-inlines-hidden. @@ -27,7 +27,7 @@ polkit-qt-1 (0.99.0-2) experimental; urgency=low -- Modestas Vainius Thu, 28 Apr 2011 11:53:35 +0300 -polkit-qt-1 (0.99.0-1) experimental; urgency=low +polkit-tqt-1 (0.99.0-1) experimental; urgency=low * New upstream release. @@ -37,11 +37,11 @@ polkit-qt-1 (0.99.0-1) experimental; urgency=low * Bump Standards-Version to 3.9.1: no changes needed. * Remove dupe "Section" field from debian/control. * Include verbatim BSD license to debian/copyright. - * Override lintian libpolkit-qt-1-0: package-name-doesnt-match-sonames. - * Use more failsafe wildcards in libpolkit-qt-1-0.install. + * Override lintian libpolkit-tqt-1-0: package-name-doesnt-match-sonames. + * Use more failsafe wildcards in libpolkit-tqt-1-0.install. * Add myself to Uploaders. - * SONAME bumped: rename libpolkit-qt-1-0 to libpolkit-qt-1-1. - * Add symbol file for libpolkit-qt-1-1. + * SONAME bumped: rename libpolkit-tqt-1-0 to libpolkit-tqt-1-1. + * Add symbol file for libpolkit-tqt-1-1. * Update debian/copyright. [ Didier Raboud ] @@ -52,7 +52,7 @@ polkit-qt-1 (0.99.0-1) experimental; urgency=low -- Modestas Vainius Mon, 14 Mar 2011 01:03:06 +0200 -polkit-qt-1 (0.95.1-1) unstable; urgency=low +polkit-tqt-1 (0.95.1-1) unstable; urgency=low * Initial release. (Closes: #565395) diff --git a/debian/control b/debian/control index 6c6625300..581bf1fea 100644 --- a/debian/control +++ b/debian/control @@ -1,4 +1,4 @@ -Source: polkit-qt-1 +Source: polkit-tqt-1 Priority: extra Maintainer: Debian Qt/KDE Maintainers Uploaders: Fathi Boudra , Modestas Vainius @@ -11,14 +11,14 @@ Build-Depends: automoc, pkg-kde-tools (>= 0.11) Standards-Version: 3.9.2 Section: libs -Vcs-Git: git://git.debian.org/pkg-kde/kde-req/polkit-qt-1.git -Vcs-Browser: http://git.debian.org/?p=pkg-kde/kde-req/polkit-qt-1.git +Vcs-Git: git://git.debian.org/pkg-kde/kde-req/polkit-tqt-1.git +Vcs-Browser: http://git.debian.org/?p=pkg-kde/kde-req/polkit-tqt-1.git -Package: libpolkit-qt-1-dev +Package: libpolkit-tqt-1-dev Section: libdevel Architecture: any -Depends: libpolkit-qt-1-1 (= ${binary:Version}), libqt4-dev, ${misc:Depends} -Description: PolicyKit-qt-1 development files +Depends: libpolkit-tqt-1-1 (= ${binary:Version}), libqt4-dev, ${misc:Depends} +Description: PolicyKit-tqt-1 development files PolicyKit is an application-level toolkit for defining and handling the policy that allows unprivileged processes to speak to privileged processes. . @@ -26,15 +26,15 @@ Description: PolicyKit-qt-1 development files granting access to privileged operations (like calling the HAL Mount() method) for unprivileged (desktop) applications. . - libpolkit-qt-1 provides convenience classes and methods for Qt/KDE + libpolkit-tqt-1 provides convenience classes and methods for TQt/TDE applications that want to use PolicyKit-1. . This package contains the development libraries and headers. -Package: libpolkit-qt-1-1 +Package: libpolkit-tqt-1-1 Architecture: any Depends: ${misc:Depends}, ${shlibs:Depends} -Description: PolicyKit-qt-1 library +Description: PolicyKit-tqt-1 library PolicyKit is an application-level toolkit for defining and handling the policy that allows unprivileged processes to speak to privileged processes. . @@ -42,8 +42,8 @@ Description: PolicyKit-qt-1 library granting access to privileged operations (like calling the HAL Mount() method) for unprivileged (desktop) applications. . - libpolkit-qt-1 provides convenience classes and methods for Qt/KDE + libpolkit-tqt-1 provides convenience classes and methods for TQt/TDE applications that want to use PolicyKit. . This package contains the files necessary for running applications that use - the libpolkit-qt-1 library. + the libpolkit-tqt-1 library. diff --git a/debian/copyright b/debian/copyright index 6175225b6..a915b05f7 100644 --- a/debian/copyright +++ b/debian/copyright @@ -21,12 +21,12 @@ Copyright: Copyright (C) 2009 Radek Novacek Copyright (C) 2009 Lukas Tinkl -Copyright for polkitqt1-export.h file: +Copyright for polkittqt1-export.h file: Copyright (C) 2009 Dario Freddi Copyright (C) 2007 David Faure -Copyright for polkitqt1-version.h.cmake file: +Copyright for polkittqt1-version.h.cmake file: Copyright (C) 2009 Dario Freddi Copyright (C) 2007 Sebastian Trueg diff --git a/debian/libpolkit-qt-1-1.install b/debian/libpolkit-qt-1-1.install deleted file mode 100644 index 73b68a291..000000000 --- a/debian/libpolkit-qt-1-1.install +++ /dev/null @@ -1,3 +0,0 @@ -usr/lib/libpolkit-qt-agent-1.so.1* -usr/lib/libpolkit-qt-core-1.so.1* -usr/lib/libpolkit-qt-gui-1.so.1* diff --git a/debian/libpolkit-qt-1-1.lintian-overrides b/debian/libpolkit-qt-1-1.lintian-overrides deleted file mode 100644 index 2e2ee4bb1..000000000 --- a/debian/libpolkit-qt-1-1.lintian-overrides +++ /dev/null @@ -1 +0,0 @@ -libpolkit-qt-1-1: package-name-doesnt-match-sonames libpolkit-qt-agent-1-1 libpolkit-qt-core-1-1 libpolkit-qt-gui-1-1 diff --git a/debian/libpolkit-qt-1-1.symbols b/debian/libpolkit-qt-1-1.symbols deleted file mode 100644 index af367261b..000000000 --- a/debian/libpolkit-qt-1-1.symbols +++ /dev/null @@ -1,305 +0,0 @@ -# SymbolsHelper-Confirmed: 0.99.0 amd64 armel hurd-i386 i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips powerpc s390 sparc -libpolkit-qt-agent-1.so.1 libpolkit-qt-1-1 #MINVER# -* Build-Depends-Package: libpolkit-qt-1-dev - _ZN9PolkitQt15Agent11AsyncResult12setCompletedEv@Base 0.99.0 - _ZN9PolkitQt15Agent11AsyncResult8setErrorERK7QString@Base 0.99.0 - _ZN9PolkitQt15Agent11AsyncResultC1EP19_GSimpleAsyncResult@Base 0.99.0 - _ZN9PolkitQt15Agent11AsyncResultC2EP19_GSimpleAsyncResult@Base 0.99.0 - _ZN9PolkitQt15Agent11AsyncResultD0Ev@Base 0.99.0 - _ZN9PolkitQt15Agent11AsyncResultD1Ev@Base 0.99.0 - _ZN9PolkitQt15Agent11AsyncResultD2Ev@Base 0.99.0 - _ZN9PolkitQt15Agent7Session11qt_metacallEN11QMetaObject4CallEiPPv@Base 0.99.0 - _ZN9PolkitQt15Agent7Session11qt_metacastEPKc@Base 0.99.0 - _ZN9PolkitQt15Agent7Session11setResponseERK7QString@Base 0.99.0 - _ZN9PolkitQt15Agent7Session16staticMetaObjectE@Base 0.99.0 - _ZN9PolkitQt15Agent7Session6cancelEv@Base 0.99.0 - _ZN9PolkitQt15Agent7Session6resultEv@Base 0.99.0 - _ZN9PolkitQt15Agent7Session7Private7requestEP19_PolkitAgentSessionPciPv@Base 0.99.0 - _ZN9PolkitQt15Agent7Session7Private8showInfoEP19_PolkitAgentSessionPcPv@Base 0.99.0 - _ZN9PolkitQt15Agent7Session7Private9completedEP19_PolkitAgentSessioniPv@Base 0.99.0 - _ZN9PolkitQt15Agent7Session7Private9showErrorEP19_PolkitAgentSessionPcPv@Base 0.99.0 - _ZN9PolkitQt15Agent7Session7PrivateD1Ev@Base 0.99.0 - _ZN9PolkitQt15Agent7Session7PrivateD2Ev@Base 0.99.0 - _ZN9PolkitQt15Agent7Session7requestERK7QStringb@Base 0.99.0 - _ZN9PolkitQt15Agent7Session8initiateEv@Base 0.99.0 - _ZN9PolkitQt15Agent7Session8showInfoERK7QString@Base 0.99.0 - _ZN9PolkitQt15Agent7Session9completedEb@Base 0.99.0 - _ZN9PolkitQt15Agent7Session9showErrorERK7QString@Base 0.99.0 - _ZN9PolkitQt15Agent7SessionC1EP19_PolkitAgentSessionP7QObject@Base 0.99.0 - _ZN9PolkitQt15Agent7SessionC1ERKNS_8IdentityERK7QStringPNS0_11AsyncResultEP7QObject@Base 0.99.0 - _ZN9PolkitQt15Agent7SessionC2EP19_PolkitAgentSessionP7QObject@Base 0.99.0 - _ZN9PolkitQt15Agent7SessionC2ERKNS_8IdentityERK7QStringPNS0_11AsyncResultEP7QObject@Base 0.99.0 - _ZN9PolkitQt15Agent7SessionD0Ev@Base 0.99.0 - _ZN9PolkitQt15Agent7SessionD1Ev@Base 0.99.0 - _ZN9PolkitQt15Agent7SessionD2Ev@Base 0.99.0 - _ZN9PolkitQt15Agent8Listener11qt_metacallEN11QMetaObject4CallEiPPv@Base 0.99.0 - _ZN9PolkitQt15Agent8Listener11qt_metacastEPKc@Base 0.99.0 - _ZN9PolkitQt15Agent8Listener16registerListenerERKNS_7SubjectERK7QString@Base 0.99.0 - _ZN9PolkitQt15Agent8Listener16staticMetaObjectE@Base 0.99.0 - _ZN9PolkitQt15Agent8Listener8listenerEv@Base 0.99.0 - _ZN9PolkitQt15Agent8ListenerC1EP20_PolkitAgentListenerP7QObject@Base 0.99.0 - _ZN9PolkitQt15Agent8ListenerC1EP7QObject@Base 0.99.0 - _ZN9PolkitQt15Agent8ListenerC2EP20_PolkitAgentListenerP7QObject@Base 0.99.0 - _ZN9PolkitQt15Agent8ListenerC2EP7QObject@Base 0.99.0 - _ZN9PolkitQt15Agent8ListenerD0Ev@Base 0.99.0 - _ZN9PolkitQt15Agent8ListenerD1Ev@Base 0.99.0 - _ZN9PolkitQt15Agent8ListenerD2Ev@Base 0.99.0 - _ZNK9PolkitQt15Agent7Session10metaObjectEv@Base 0.99.0 - _ZNK9PolkitQt15Agent8Listener10metaObjectEv@Base 0.99.0 - _ZTIN9PolkitQt15Agent11AsyncResultE@Base 0.99.0 - _ZTIN9PolkitQt15Agent7SessionE@Base 0.99.0 - _ZTIN9PolkitQt15Agent8ListenerE@Base 0.99.0 - _ZTSN9PolkitQt15Agent11AsyncResultE@Base 0.99.0 - _ZTSN9PolkitQt15Agent7SessionE@Base 0.99.0 - _ZTSN9PolkitQt15Agent8ListenerE@Base 0.99.0 - _ZTVN9PolkitQt15Agent11AsyncResultE@Base 0.99.0 - _ZTVN9PolkitQt15Agent7SessionE@Base 0.99.0 - _ZTVN9PolkitQt15Agent8ListenerE@Base 0.99.0 -libpolkit-qt-core-1.so.1 libpolkit-qt-1-1 #MINVER# -* Build-Depends-Package: libpolkit-qt-1-dev - _ZN9PolkitQt116UnixUserIdentity6setUidEj@Base 0.99.0 - _ZN9PolkitQt116UnixUserIdentityC1EP15_PolkitUnixUser@Base 0.99.0 - _ZN9PolkitQt116UnixUserIdentityC1ERK7QString@Base 0.99.0 - _ZN9PolkitQt116UnixUserIdentityC1Ej@Base 0.99.0 - _ZN9PolkitQt116UnixUserIdentityC1Ev@Base 0.99.0 - _ZN9PolkitQt116UnixUserIdentityC2EP15_PolkitUnixUser@Base 0.99.0 - _ZN9PolkitQt116UnixUserIdentityC2ERK7QString@Base 0.99.0 - _ZN9PolkitQt116UnixUserIdentityC2Ej@Base 0.99.0 - _ZN9PolkitQt116UnixUserIdentityC2Ev@Base 0.99.0 - _ZN9PolkitQt117ActionDescriptionC1EP24_PolkitActionDescription@Base 0.99.0 - _ZN9PolkitQt117ActionDescriptionC1ERKS0_@Base 0.99.0 - _ZN9PolkitQt117ActionDescriptionC1Ev@Base 0.99.0 - _ZN9PolkitQt117ActionDescriptionC2EP24_PolkitActionDescription@Base 0.99.0 - _ZN9PolkitQt117ActionDescriptionC2ERKS0_@Base 0.99.0 - _ZN9PolkitQt117ActionDescriptionC2Ev@Base 0.99.0 - _ZN9PolkitQt117ActionDescriptionD1Ev@Base 0.99.0 - _ZN9PolkitQt117ActionDescriptionD2Ev@Base 0.99.0 - _ZN9PolkitQt117ActionDescriptionaSERKS0_@Base 0.99.0 - _ZN9PolkitQt117UnixGroupIdentity6setGidEj@Base 0.99.0 - _ZN9PolkitQt117UnixGroupIdentityC1EP16_PolkitUnixGroup@Base 0.99.0 - _ZN9PolkitQt117UnixGroupIdentityC1ERK7QString@Base 0.99.0 - _ZN9PolkitQt117UnixGroupIdentityC1Ej@Base 0.99.0 - _ZN9PolkitQt117UnixGroupIdentityC1Ev@Base 0.99.0 - _ZN9PolkitQt117UnixGroupIdentityC2EP16_PolkitUnixGroup@Base 0.99.0 - _ZN9PolkitQt117UnixGroupIdentityC2ERK7QString@Base 0.99.0 - _ZN9PolkitQt117UnixGroupIdentityC2Ej@Base 0.99.0 - _ZN9PolkitQt117UnixGroupIdentityC2Ev@Base 0.99.0 - _ZN9PolkitQt118UnixProcessSubject6setPidEx@Base 0.99.0 - _ZN9PolkitQt118UnixProcessSubjectC1EP18_PolkitUnixProcess@Base 0.99.0 - _ZN9PolkitQt118UnixProcessSubjectC1Ex@Base 0.99.0 - _ZN9PolkitQt118UnixProcessSubjectC1Exy@Base 0.99.0 - _ZN9PolkitQt118UnixProcessSubjectC2EP18_PolkitUnixProcess@Base 0.99.0 - _ZN9PolkitQt118UnixProcessSubjectC2Ex@Base 0.99.0 - _ZN9PolkitQt118UnixProcessSubjectC2Exy@Base 0.99.0 - _ZN9PolkitQt118UnixSessionSubject12setSessionIdERK7QString@Base 0.99.0 - _ZN9PolkitQt118UnixSessionSubjectC1EP20_PolkitSystemBusName@Base 0.99.0 - _ZN9PolkitQt118UnixSessionSubjectC1ERK7QString@Base 0.99.0 - _ZN9PolkitQt118UnixSessionSubjectC1Ex@Base 0.99.0 - _ZN9PolkitQt118UnixSessionSubjectC2EP20_PolkitSystemBusName@Base 0.99.0 - _ZN9PolkitQt118UnixSessionSubjectC2ERK7QString@Base 0.99.0 - _ZN9PolkitQt118UnixSessionSubjectC2Ex@Base 0.99.0 - _ZN9PolkitQt120SystemBusNameSubject7setNameERK7QString@Base 0.99.0 - _ZN9PolkitQt120SystemBusNameSubjectC1EP20_PolkitSystemBusName@Base 0.99.0 - _ZN9PolkitQt120SystemBusNameSubjectC1ERK7QString@Base 0.99.0 - _ZN9PolkitQt120SystemBusNameSubjectC2EP20_PolkitSystemBusName@Base 0.99.0 - _ZN9PolkitQt120SystemBusNameSubjectC2ERK7QString@Base 0.99.0 - _ZN9PolkitQt122TemporaryAuthorization6revokeEv@Base 0.99.0 - _ZN9PolkitQt122TemporaryAuthorizationC1EP29_PolkitTemporaryAuthorization@Base 0.99.0 - _ZN9PolkitQt122TemporaryAuthorizationC1ERKS0_@Base 0.99.0 - _ZN9PolkitQt122TemporaryAuthorizationC1Ev@Base 0.99.0 - _ZN9PolkitQt122TemporaryAuthorizationC2EP29_PolkitTemporaryAuthorization@Base 0.99.0 - _ZN9PolkitQt122TemporaryAuthorizationC2ERKS0_@Base 0.99.0 - _ZN9PolkitQt122TemporaryAuthorizationC2Ev@Base 0.99.0 - _ZN9PolkitQt122TemporaryAuthorizationD1Ev@Base 0.99.0 - _ZN9PolkitQt122TemporaryAuthorizationD2Ev@Base 0.99.0 - _ZN9PolkitQt122TemporaryAuthorizationaSERKS0_@Base 0.99.0 - _ZN9PolkitQt17Details6insertERK7QStringS3_@Base 0.99.0 - _ZN9PolkitQt17DetailsC1EP14_PolkitDetails@Base 0.99.0 - _ZN9PolkitQt17DetailsC1Ev@Base 0.99.0 - _ZN9PolkitQt17DetailsC2EP14_PolkitDetails@Base 0.99.0 - _ZN9PolkitQt17DetailsC2Ev@Base 0.99.0 - _ZN9PolkitQt17DetailsD1Ev@Base 0.99.0 - _ZN9PolkitQt17DetailsD2Ev@Base 0.99.0 - _ZN9PolkitQt17DetailsaSERKS0_@Base 0.99.0 - _ZN9PolkitQt17Subject10fromStringERK7QString@Base 0.99.0 - _ZN9PolkitQt17Subject10setSubjectEP14_PolkitSubject@Base 0.99.0 - _ZN9PolkitQt17SubjectC1EP14_PolkitSubject@Base 0.99.0 - _ZN9PolkitQt17SubjectC1ERKS0_@Base 0.99.0 - _ZN9PolkitQt17SubjectC1Ev@Base 0.99.0 - _ZN9PolkitQt17SubjectC2EP14_PolkitSubject@Base 0.99.0 - _ZN9PolkitQt17SubjectC2ERKS0_@Base 0.99.0 - _ZN9PolkitQt17SubjectC2Ev@Base 0.99.0 - _ZN9PolkitQt17SubjectD1Ev@Base 0.99.0 - _ZN9PolkitQt17SubjectD2Ev@Base 0.99.0 - _ZN9PolkitQt17SubjectaSERKS0_@Base 0.99.0 - _ZN9PolkitQt18Identity10fromStringERK7QString@Base 0.99.0 - _ZN9PolkitQt18Identity11setIdentityEP15_PolkitIdentity@Base 0.99.0 - _ZN9PolkitQt18Identity18toUnixUserIdentityEv@Base 0.99.0 - _ZN9PolkitQt18Identity19toUnixGroupIdentityEv@Base 0.99.0 - _ZN9PolkitQt18IdentityC1EP15_PolkitIdentity@Base 0.99.0 - _ZN9PolkitQt18IdentityC1ERKS0_@Base 0.99.0 - _ZN9PolkitQt18IdentityC1Ev@Base 0.99.0 - _ZN9PolkitQt18IdentityC2EP15_PolkitIdentity@Base 0.99.0 - _ZN9PolkitQt18IdentityC2ERKS0_@Base 0.99.0 - _ZN9PolkitQt18IdentityC2Ev@Base 0.99.0 - _ZN9PolkitQt18IdentityD1Ev@Base 0.99.0 - _ZN9PolkitQt18IdentityD2Ev@Base 0.99.0 - _ZN9PolkitQt18IdentityaSERKS0_@Base 0.99.0 - _ZN9PolkitQt19Authority10clearErrorEv@Base 0.99.0 - _ZN9PolkitQt19Authority11qt_metacallEN11QMetaObject4CallEiPPv@Base 0.99.0 - _ZN9PolkitQt19Authority11qt_metacastEPKc@Base 0.99.0 - _ZN9PolkitQt19Authority13configChangedEv@Base 0.99.0 - _ZN9PolkitQt19Authority16enumerateActionsEv@Base 0.99.0 - _ZN9PolkitQt19Authority16staticMetaObjectE@Base 0.99.0 - _ZN9PolkitQt19Authority18checkAuthorizationERK7QStringRKNS_7SubjectE6QFlagsINS0_17AuthorizationFlagEE@Base 0.99.0 - _ZN9PolkitQt19Authority19consoleKitDBChangedEv@Base 0.99.0 - _ZN9PolkitQt19Authority20enumerateActionsSyncEv@Base 0.99.0 - _ZN9PolkitQt19Authority22checkAuthorizationSyncERK7QStringRKNS_7SubjectE6QFlagsINS0_17AuthorizationFlagEE@Base 0.99.0 - _ZN9PolkitQt19Authority22enumerateActionsCancelEv@Base 0.99.0 - _ZN9PolkitQt19Authority24checkAuthorizationCancelEv@Base 0.99.0 - _ZN9PolkitQt19Authority24enumerateActionsFinishedE5QListINS_17ActionDescriptionEE@Base 0.99.0 - _ZN9PolkitQt19Authority26checkAuthorizationFinishedENS0_6ResultE@Base 0.99.0 - _ZN9PolkitQt19Authority27authenticationAgentResponseERK7QStringRKNS_8IdentityE@Base 0.99.0 - _ZN9PolkitQt19Authority27registerAuthenticationAgentERKNS_7SubjectERK7QStringS6_@Base 0.99.0 - _ZN9PolkitQt19Authority28revokeTemporaryAuthorizationERK7QString@Base 0.99.0 - _ZN9PolkitQt19Authority29revokeTemporaryAuthorizationsERKNS_7SubjectE@Base 0.99.0 - _ZN9PolkitQt19Authority29unregisterAuthenticationAgentERKNS_7SubjectERK7QString@Base 0.99.0 - _ZN9PolkitQt19Authority31authenticationAgentResponseSyncERK7QStringRKNS_8IdentityE@Base 0.99.0 - _ZN9PolkitQt19Authority31registerAuthenticationAgentSyncERKNS_7SubjectERK7QStringS6_@Base 0.99.0 - _ZN9PolkitQt19Authority32revokeTemporaryAuthorizationSyncERK7QString@Base 0.99.0 - _ZN9PolkitQt19Authority33authenticationAgentResponseCancelEv@Base 0.99.0 - _ZN9PolkitQt19Authority33registerAuthenticationAgentCancelEv@Base 0.99.0 - _ZN9PolkitQt19Authority33revokeTemporaryAuthorizationsSyncERKNS_7SubjectE@Base 0.99.0 - _ZN9PolkitQt19Authority33unregisterAuthenticationAgentSyncERKNS_7SubjectERK7QString@Base 0.99.0 - _ZN9PolkitQt19Authority34revokeTemporaryAuthorizationCancelEv@Base 0.99.0 - _ZN9PolkitQt19Authority35authenticationAgentResponseFinishedEb@Base 0.99.0 - _ZN9PolkitQt19Authority35registerAuthenticationAgentFinishedEb@Base 0.99.0 - _ZN9PolkitQt19Authority35revokeTemporaryAuthorizationsCancelEv@Base 0.99.0 - _ZN9PolkitQt19Authority35unregisterAuthenticationAgentCancelEv@Base 0.99.0 - _ZN9PolkitQt19Authority36enumerateTemporaryAuthorizationsSyncERKNS_7SubjectE@Base 0.99.0 - _ZN9PolkitQt19Authority36revokeTemporaryAuthorizationFinishedEb@Base 0.99.0 - _ZN9PolkitQt19Authority37revokeTemporaryAuthorizationsFinishedEb@Base 0.99.0 - _ZN9PolkitQt19Authority37unregisterAuthenticationAgentFinishedEb@Base 0.99.0 - _ZN9PolkitQt19Authority38enumerateTemporaryAuthorizationsCancelEv@Base 0.99.0 - _ZN9PolkitQt19Authority40enumerateTemporaryAuthorizationsFinishedE5QListINS_22TemporaryAuthorizationEE@Base 0.99.0 - _ZN9PolkitQt19Authority7Private10dbusFilterERK12QDBusMessage@Base 0.99.0 - _ZN9PolkitQt19Authority7Private13dbusSignalAddERK7QStringS4_S4_S4_@Base 0.99.0 - _ZN9PolkitQt19Authority7Private17pk_config_changedEv@Base 0.99.0 - _ZN9PolkitQt19Authority7Private18seatSignalsConnectERK7QString@Base 0.99.0 - _ZN9PolkitQt19Authority7Private24enumerateActionsCallbackEP8_GObjectP13_GAsyncResultPv@Base 0.99.0 - _ZN9PolkitQt19Authority7Private26checkAuthorizationCallbackEP8_GObjectP13_GAsyncResultPv@Base 0.99.0 - _ZN9PolkitQt19Authority7Private35authenticationAgentResponseCallbackEP8_GObjectP13_GAsyncResultPv@Base 0.99.0 - _ZN9PolkitQt19Authority7Private35registerAuthenticationAgentCallbackEP8_GObjectP13_GAsyncResultPv@Base 0.99.0 - _ZN9PolkitQt19Authority7Private36revokeTemporaryAuthorizationCallbackEP8_GObjectP13_GAsyncResultPv@Base 0.99.0 - _ZN9PolkitQt19Authority7Private37revokeTemporaryAuthorizationsCallbackEP8_GObjectP13_GAsyncResultPv@Base 0.99.0 - _ZN9PolkitQt19Authority7Private37unregisterAuthenticationAgentCallbackEP8_GObjectP13_GAsyncResultPv@Base 0.99.0 - _ZN9PolkitQt19Authority7Private40enumerateTemporaryAuthorizationsCallbackEP8_GObjectP13_GAsyncResultPv@Base 0.99.0 - _ZN9PolkitQt19Authority7Private4initEv@Base 0.99.0 - _ZN9PolkitQt19Authority7Private8setErrorENS0_9ErrorCodeERK7QStringb@Base 0.99.0 - _ZN9PolkitQt19Authority7PrivateD1Ev@Base 0.99.0 - _ZN9PolkitQt19Authority7PrivateD2Ev@Base 0.99.0 - _ZN9PolkitQt19Authority8instanceEP16_PolkitAuthority@Base 0.99.0 - _ZN9PolkitQt19AuthorityC1EP16_PolkitAuthorityP7QObject@Base 0.99.0 - _ZN9PolkitQt19AuthorityC2EP16_PolkitAuthorityP7QObject@Base 0.99.0 - _ZN9PolkitQt19AuthorityD0Ev@Base 0.99.0 - _ZN9PolkitQt19AuthorityD1Ev@Base 0.99.0 - _ZN9PolkitQt19AuthorityD2Ev@Base 0.99.0 - _ZNK9PolkitQt116UnixUserIdentity3uidEv@Base 0.99.0 - _ZNK9PolkitQt117ActionDescription10vendorNameEv@Base 0.99.0 - _ZNK9PolkitQt117ActionDescription11descriptionEv@Base 0.99.0 - _ZNK9PolkitQt117ActionDescription11implicitAnyEv@Base 0.99.0 - _ZNK9PolkitQt117ActionDescription14implicitActiveEv@Base 0.99.0 - _ZNK9PolkitQt117ActionDescription16implicitInactiveEv@Base 0.99.0 - _ZNK9PolkitQt117ActionDescription7messageEv@Base 0.99.0 - _ZNK9PolkitQt117ActionDescription8actionIdEv@Base 0.99.0 - _ZNK9PolkitQt117ActionDescription8iconNameEv@Base 0.99.0 - _ZNK9PolkitQt117ActionDescription9vendorUrlEv@Base 0.99.0 - _ZNK9PolkitQt117UnixGroupIdentity3gidEv@Base 0.99.0 - _ZNK9PolkitQt118UnixProcessSubject3pidEv@Base 0.99.0 - _ZNK9PolkitQt118UnixProcessSubject9startTimeEv@Base 0.99.0 - _ZNK9PolkitQt118UnixSessionSubject9sessionIdEv@Base 0.99.0 - _ZNK9PolkitQt120SystemBusNameSubject4nameEv@Base 0.99.0 - _ZNK9PolkitQt122TemporaryAuthorization10obtainedAtEv@Base 0.99.0 - _ZNK9PolkitQt122TemporaryAuthorization14expirationTimeEv@Base 0.99.0 - _ZNK9PolkitQt122TemporaryAuthorization2idEv@Base 0.99.0 - _ZNK9PolkitQt122TemporaryAuthorization7subjectEv@Base 0.99.0 - _ZNK9PolkitQt122TemporaryAuthorization8actionIdEv@Base 0.99.0 - _ZNK9PolkitQt17Details4keysEv@Base 0.99.0 - _ZNK9PolkitQt17Details6lookupERK7QString@Base 0.99.0 - _ZNK9PolkitQt17Subject7isValidEv@Base 0.99.0 - _ZNK9PolkitQt17Subject7subjectEv@Base 0.99.0 - _ZNK9PolkitQt17Subject8toStringEv@Base 0.99.0 - _ZNK9PolkitQt18Identity7isValidEv@Base 0.99.0 - _ZNK9PolkitQt18Identity8identityEv@Base 0.99.0 - _ZNK9PolkitQt18Identity8toStringEv@Base 0.99.0 - _ZNK9PolkitQt19Authority10metaObjectEv@Base 0.99.0 - _ZNK9PolkitQt19Authority12errorDetailsEv@Base 0.99.0 - _ZNK9PolkitQt19Authority15polkitAuthorityEv@Base 0.99.0 - _ZNK9PolkitQt19Authority8hasErrorEv@Base 0.99.0 - _ZNK9PolkitQt19Authority9lastErrorEv@Base 0.99.0 - _ZTIN9PolkitQt117ActionDescription4DataE@Base 0.99.0 - _ZTIN9PolkitQt19AuthorityE@Base 0.99.0 - _ZTSN9PolkitQt117ActionDescription4DataE@Base 0.99.0 - _ZTSN9PolkitQt19AuthorityE@Base 0.99.0 - _ZTVN9PolkitQt117ActionDescription4DataE@Base 0.99.0 - _ZTVN9PolkitQt19AuthorityE@Base 0.99.0 -libpolkit-qt-gui-1.so.1 libpolkit-qt-1-1 #MINVER# -* Build-Depends-Package: libpolkit-qt-1-dev - _ZN9PolkitQt13Gui12ActionButton11qt_metacallEN11QMetaObject4CallEiPPv@Base 0.99.0 - _ZN9PolkitQt13Gui12ActionButton11qt_metacastEPKc@Base 0.99.0 - _ZN9PolkitQt13Gui12ActionButton16staticMetaObjectE@Base 0.99.0 - _ZN9PolkitQt13Gui12ActionButton7clickedEP15QAbstractButtonb@Base 0.99.0 - _ZN9PolkitQt13Gui12ActionButton8activateEv@Base 0.99.0 - _ZN9PolkitQt13Gui12ActionButton9setButtonEP15QAbstractButton@Base 0.99.0 - _ZN9PolkitQt13Gui12ActionButtonC1EP15QAbstractButtonRK7QStringP7QObject@Base 0.99.0 - _ZN9PolkitQt13Gui12ActionButtonC1ERNS0_19ActionButtonPrivateERK7QStringP7QObject@Base 0.99.0 - _ZN9PolkitQt13Gui12ActionButtonC2EP15QAbstractButtonRK7QStringP7QObject@Base 0.99.0 - _ZN9PolkitQt13Gui12ActionButtonC2ERNS0_19ActionButtonPrivateERK7QStringP7QObject@Base 0.99.0 - _ZN9PolkitQt13Gui12ActionButtonD0Ev@Base 0.99.0 - _ZN9PolkitQt13Gui12ActionButtonD1Ev@Base 0.99.0 - _ZN9PolkitQt13Gui12ActionButtonD2Ev@Base 0.99.0 - _ZN9PolkitQt13Gui6Action10authorizedEv@Base 0.99.0 - _ZN9PolkitQt13Gui6Action10setCheckedEb@Base 0.99.0 - _ZN9PolkitQt13Gui6Action10setEnabledEb6QFlagsINS1_5StateEE@Base 0.99.0 - _ZN9PolkitQt13Gui6Action10setToolTipERK7QString6QFlagsINS1_5StateEE@Base 0.99.0 - _ZN9PolkitQt13Gui6Action10setVisibleEb6QFlagsINS1_5StateEE@Base 0.99.0 - _ZN9PolkitQt13Gui6Action11dataChangedEv@Base 0.99.0 - _ZN9PolkitQt13Gui6Action11qt_metacallEN11QMetaObject4CallEiPPv@Base 0.99.0 - _ZN9PolkitQt13Gui6Action11qt_metacastEPKc@Base 0.99.0 - _ZN9PolkitQt13Gui6Action12setTargetPIDEx@Base 0.99.0 - _ZN9PolkitQt13Gui6Action12setWhatsThisERK7QString6QFlagsINS1_5StateEE@Base 0.99.0 - _ZN9PolkitQt13Gui6Action15setPolkitActionERK7QString@Base 0.99.0 - _ZN9PolkitQt13Gui6Action16staticMetaObjectE@Base 0.99.0 - _ZN9PolkitQt13Gui6Action6revokeEv@Base 0.99.0 - _ZN9PolkitQt13Gui6Action7Private12updateActionEv@Base 0.99.0 - _ZN9PolkitQt13Gui6Action7Private13configChangedEv@Base 0.99.0 - _ZN9PolkitQt13Gui6Action7Private15computePkResultEv@Base 0.99.0 - _ZN9PolkitQt13Gui6Action7PrivateC1EPS1_@Base 0.99.0 - _ZN9PolkitQt13Gui6Action7PrivateC2EPS1_@Base 0.99.0 - _ZN9PolkitQt13Gui6Action7setIconERK5QIcon6QFlagsINS1_5StateEE@Base 0.99.0 - _ZN9PolkitQt13Gui6Action7setTextERK7QString6QFlagsINS1_5StateEE@Base 0.99.0 - _ZN9PolkitQt13Gui6Action8activateEv@Base 0.99.0 - _ZN9PolkitQt13Gui6ActionC1ERK7QStringP7QObject@Base 0.99.0 - _ZN9PolkitQt13Gui6ActionC2ERK7QStringP7QObject@Base 0.99.0 - _ZN9PolkitQt13Gui6ActionD0Ev@Base 0.99.0 - _ZN9PolkitQt13Gui6ActionD1Ev@Base 0.99.0 - _ZN9PolkitQt13Gui6ActionD2Ev@Base 0.99.0 - _ZNK9PolkitQt13Gui12ActionButton10metaObjectEv@Base 0.99.0 - _ZNK9PolkitQt13Gui12ActionButton6buttonEv@Base 0.99.0 - _ZNK9PolkitQt13Gui6Action10metaObjectEv@Base 0.99.0 - _ZNK9PolkitQt13Gui6Action2isERK7QString@Base 0.99.0 - _ZNK9PolkitQt13Gui6Action4iconENS1_5StateE@Base 0.99.0 - _ZNK9PolkitQt13Gui6Action4textENS1_5StateE@Base 0.99.0 - _ZNK9PolkitQt13Gui6Action7toolTipENS1_5StateE@Base 0.99.0 - _ZNK9PolkitQt13Gui6Action8actionIdEv@Base 0.99.0 - _ZNK9PolkitQt13Gui6Action9isAllowedEv@Base 0.99.0 - _ZNK9PolkitQt13Gui6Action9isEnabledENS1_5StateE@Base 0.99.0 - _ZNK9PolkitQt13Gui6Action9isVisibleENS1_5StateE@Base 0.99.0 - _ZNK9PolkitQt13Gui6Action9targetPIDEv@Base 0.99.0 - _ZNK9PolkitQt13Gui6Action9whatsThisENS1_5StateE@Base 0.99.0 - _ZTIN9PolkitQt13Gui12ActionButtonE@Base 0.99.0 - _ZTIN9PolkitQt13Gui6ActionE@Base 0.99.0 - _ZTSN9PolkitQt13Gui12ActionButtonE@Base 0.99.0 - _ZTSN9PolkitQt13Gui6ActionE@Base 0.99.0 - _ZTVN9PolkitQt13Gui12ActionButtonE@Base 0.99.0 - _ZTVN9PolkitQt13Gui6ActionE@Base 0.99.0 diff --git a/debian/libpolkit-qt-1-dev.install b/debian/libpolkit-qt-1-dev.install deleted file mode 100644 index 337a7a0a2..000000000 --- a/debian/libpolkit-qt-1-dev.install +++ /dev/null @@ -1,33 +0,0 @@ -usr/include/polkit-qt-1/PolkitQt1/ActionDescription -usr/include/polkit-qt-1/PolkitQt1/Agent/Listener -usr/include/polkit-qt-1/PolkitQt1/Agent/Session -usr/include/polkit-qt-1/PolkitQt1/Authority -usr/include/polkit-qt-1/PolkitQt1/Details -usr/include/polkit-qt-1/PolkitQt1/Gui/Action -usr/include/polkit-qt-1/PolkitQt1/Gui/ActionButton -usr/include/polkit-qt-1/PolkitQt1/Gui/ActionButtons -usr/include/polkit-qt-1/PolkitQt1/Identity -usr/include/polkit-qt-1/PolkitQt1/Subject -usr/include/polkit-qt-1/PolkitQt1/TemporaryAuthorization -usr/include/polkit-qt-1/polkitqt1-actiondescription.h -usr/include/polkit-qt-1/polkitqt1-agent-listener.h -usr/include/polkit-qt-1/polkitqt1-agent-session.h -usr/include/polkit-qt-1/polkitqt1-authority.h -usr/include/polkit-qt-1/polkitqt1-details.h -usr/include/polkit-qt-1/polkitqt1-export.h -usr/include/polkit-qt-1/polkitqt1-gui-action.h -usr/include/polkit-qt-1/polkitqt1-gui-actionbutton.h -usr/include/polkit-qt-1/polkitqt1-gui-actionbuttons.h -usr/include/polkit-qt-1/polkitqt1-identity.h -usr/include/polkit-qt-1/polkitqt1-subject.h -usr/include/polkit-qt-1/polkitqt1-temporaryauthorization.h -usr/include/polkit-qt-1/polkitqt1-version.h -usr/lib/cmake/PolkitQt-1/PolkitQt-1Config.cmake -usr/lib/cmake/PolkitQt-1/PolkitQt-1ConfigVersion.cmake -usr/lib/libpolkit-qt-agent-1.so -usr/lib/libpolkit-qt-core-1.so -usr/lib/libpolkit-qt-gui-1.so -usr/lib/pkgconfig/polkit-qt-1.pc -usr/lib/pkgconfig/polkit-qt-agent-1.pc -usr/lib/pkgconfig/polkit-qt-core-1.pc -usr/lib/pkgconfig/polkit-qt-gui-1.pc diff --git a/debian/libpolkit-tqt-1-1.install b/debian/libpolkit-tqt-1-1.install new file mode 100644 index 000000000..661ce7afe --- /dev/null +++ b/debian/libpolkit-tqt-1-1.install @@ -0,0 +1,3 @@ +usr/lib/libpolkit-tqt-agent-1.so.1* +usr/lib/libpolkit-tqt-core-1.so.1* +usr/lib/libpolkit-tqt-gui-1.so.1* diff --git a/debian/libpolkit-tqt-1-1.lintian-overrides b/debian/libpolkit-tqt-1-1.lintian-overrides new file mode 100644 index 000000000..0a9d86566 --- /dev/null +++ b/debian/libpolkit-tqt-1-1.lintian-overrides @@ -0,0 +1 @@ +libpolkit-tqt-1-1: package-name-doesnt-match-sonames libpolkit-tqt-agent-1-1 libpolkit-tqt-core-1-1 libpolkit-tqt-gui-1-1 diff --git a/debian/libpolkit-tqt-1-dev.install b/debian/libpolkit-tqt-1-dev.install new file mode 100644 index 000000000..a25b331f7 --- /dev/null +++ b/debian/libpolkit-tqt-1-dev.install @@ -0,0 +1,33 @@ +usr/include/polkit-tqt-1/PolkitTQt1/ActionDescription +usr/include/polkit-tqt-1/PolkitTQt1/Agent/Listener +usr/include/polkit-tqt-1/PolkitTQt1/Agent/Session +usr/include/polkit-tqt-1/PolkitTQt1/Authority +usr/include/polkit-tqt-1/PolkitTQt1/Details +usr/include/polkit-tqt-1/PolkitTQt1/Gui/Action +usr/include/polkit-tqt-1/PolkitTQt1/Gui/ActionButton +usr/include/polkit-tqt-1/PolkitTQt1/Gui/ActionButtons +usr/include/polkit-tqt-1/PolkitTQt1/Identity +usr/include/polkit-tqt-1/PolkitTQt1/Subject +usr/include/polkit-tqt-1/PolkitTQt1/TemporaryAuthorization +usr/include/polkit-tqt-1/polkittqt1-actiondescription.h +usr/include/polkit-tqt-1/polkittqt1-agent-listener.h +usr/include/polkit-tqt-1/polkittqt1-agent-session.h +usr/include/polkit-tqt-1/polkittqt1-authority.h +usr/include/polkit-tqt-1/polkittqt1-details.h +usr/include/polkit-tqt-1/polkittqt1-export.h +usr/include/polkit-tqt-1/polkittqt1-gui-action.h +usr/include/polkit-tqt-1/polkittqt1-gui-actionbutton.h +usr/include/polkit-tqt-1/polkittqt1-gui-actionbuttons.h +usr/include/polkit-tqt-1/polkittqt1-identity.h +usr/include/polkit-tqt-1/polkittqt1-subject.h +usr/include/polkit-tqt-1/polkittqt1-temporaryauthorization.h +usr/include/polkit-tqt-1/polkittqt1-version.h +usr/lib/cmake/PolkitTQt-1/PolkitTQt-1Config.cmake +usr/lib/cmake/PolkitTQt-1/PolkitTQt-1ConfigVersion.cmake +usr/lib/libpolkit-tqt-agent-1.so +usr/lib/libpolkit-tqt-core-1.so +usr/lib/libpolkit-tqt-gui-1.so +usr/lib/pkgconfig/polkit-tqt-1.pc +usr/lib/pkgconfig/polkit-tqt-agent-1.pc +usr/lib/pkgconfig/polkit-tqt-core-1.pc +usr/lib/pkgconfig/polkit-tqt-gui-1.pc diff --git a/examples/PkExampleHelper.cpp b/examples/PkExampleHelper.cpp index d6ecfdc7f..97a634411 100644 --- a/examples/PkExampleHelper.cpp +++ b/examples/PkExampleHelper.cpp @@ -22,7 +22,7 @@ #include "PkExampleHelper.h" #include "examplesadaptor.h" -#include "polkitqt1-authority.h" +#include "polkittqt-authority.h" #include #include @@ -39,7 +39,7 @@ PkExampleHelper::PkExampleHelper(int &argc, char **argv) tqDebug() << "Creating Helper"; (void) new ExamplesAdaptor(this); // Register the DBus service - if (!TQDBusConnection::systemBus().registerService("org.qt.policykit.examples")) { + if (!TQDBusConnection::systemBus().registerService("org.tqt.policykit.examples")) { tqDebug() << TQDBusConnection::systemBus().lastError().message();; TQTimer::singleShot(0, this, SLOT(quit())); return; @@ -68,7 +68,7 @@ bool PkExampleHelper::set(const TQString &action) Authority::Result result; SystemBusNameSubject subject(message().service()); - result = Authority::instance()->checkAuthorizationSync("org.qt.policykit.examples.set", + result = Authority::instance()->checkAuthorizationSync("org.tqt.policykit.examples.set", subject , Authority::AllowUserInteraction); if (result == Authority::Yes) { tqDebug() << message().service() << TQString("Implicit authorization set to") << action; @@ -86,14 +86,14 @@ bool PkExampleHelper::setValue(const TQString &action) // This action must be authorized first. It will set the implicit // authorization for the Shout action by editing the .policy file TQDomDocument doc = TQDomDocument("policy"); - TQFile file("/usr/share/polkit-1/actions/org.qt.policykit.examples.policy"); + TQFile file("/usr/share/polkit-1/actions/org.tqt.policykit.examples.policy"); if (!file.open(TQIODevice::ReadOnly)) return false; doc.setContent(&file); file.close(); TQDomElement el = doc.firstChildElement("policyconfig"). firstChildElement("action"); - while (!el.isNull() && el.attribute("id", TQString()) != "org.qt.policykit.examples.shout") { + while (!el.isNull() && el.attribute("id", TQString()) != "org.tqt.policykit.examples.shout") { el = el.nextSiblingElement("action"); } el = el.firstChildElement("defaults"); diff --git a/examples/PkExampleHelper.h b/examples/PkExampleHelper.h index 825a14bf0..4b7d256ef 100644 --- a/examples/PkExampleHelper.h +++ b/examples/PkExampleHelper.h @@ -28,7 +28,7 @@ class PkExampleHelper : public TQCoreApplication, protected TQDBusContext { Q_OBJECT - TQ_CLASSINFO("D-Bus Interface", "org.qt.policykit.examples") + TQ_CLASSINFO("D-Bus Interface", "org.tqt.policykit.examples") public: PkExampleHelper(int &argc, char **argv); ~PkExampleHelper(); diff --git a/examples/agent/CMakeLists.txt b/examples/agent/CMakeLists.txt index ba708cb46..17dc16272 100644 --- a/examples/agent/CMakeLists.txt +++ b/examples/agent/CMakeLists.txt @@ -17,8 +17,8 @@ add_executable(polkit-agent-example ) target_link_libraries(polkit-agent-example - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - polkit-qt-agent-1 - polkit-qt-core-1 + ${TQT_TQTCORE_LIBRARY} + ${TQT_TQTGUI_LIBRARY} + polkit-tqt-agent-1 + polkit-tqt-core-1 ) diff --git a/examples/agent/klistener.cpp b/examples/agent/klistener.cpp index 147b95a67..e78b3d081 100644 --- a/examples/agent/klistener.cpp +++ b/examples/agent/klistener.cpp @@ -1,5 +1,5 @@ /* - * This file is part of the Polkit-qt project + * This file is part of the Polkit-tqt project * Copyright (C) 2009 Jaroslav Reznik * * This library is free software; you can redistribute it and/or @@ -22,7 +22,7 @@ #include #include "klistener.h" -#include "agent/polkitqt1-agent-session.h" +#include "agent/polkittqt1-agent-session.h" using namespace PolkitTQt1::Agent; @@ -47,7 +47,7 @@ void KListener::initiateAuthentication(const TQString &actionId, tqDebug() << details.keys(); tqDebug() << "cookie" << cookie; - Q_FOREACH (const PolkitTQt1::Identity &identity, identities) { + TQ_FOREACH (const PolkitTQt1::Identity &identity, identities) { tqDebug() << identity.toString(); Session *session; session = new Session(identity, cookie, result); diff --git a/examples/agent/klistener.h b/examples/agent/klistener.h index d0e45c6ba..67c3722cc 100644 --- a/examples/agent/klistener.h +++ b/examples/agent/klistener.h @@ -18,16 +18,16 @@ * Boston, MA 02110-1301, USA. */ -#ifndef POLKIT_QT_AGENT_KDE_LISTENER_H -#define POLKIT_QT_AGENT_KDE_LISTENER_H +#ifndef POLKIT_TQT_AGENT_KDE_LISTENER_H +#define POLKIT_TQT_AGENT_KDE_LISTENER_H #include #include -#include "agent/polkitqt1-agent-listener.h" -#include "core/polkitqt1-identity.h" -#include "core/polkitqt1-details.h" -#include "agent/polkitqt1-agent-session.h" +#include "agent/polkittqt1-agent-listener.h" +#include "core/polkittqt1-identity.h" +#include "core/polkittqt1-details.h" +#include "agent/polkittqt1-agent-session.h" class KListener : public PolkitTQt1::Agent::Listener { diff --git a/examples/agent/pkagentexample.cpp b/examples/agent/pkagentexample.cpp index 858376c22..8537aa832 100644 --- a/examples/agent/pkagentexample.cpp +++ b/examples/agent/pkagentexample.cpp @@ -4,7 +4,7 @@ #include "pkagentexample.h" #include #include -#include "polkitqt1-subject.h" +#include "polkittqt1-subject.h" PkAgentExample::PkAgentExample(int &argc, char **argv) : TQCoreApplication(argc, argv) diff --git a/examples/org.qt.policykit.examples.conf b/examples/org.qt.policykit.examples.conf deleted file mode 100644 index 304d269f6..000000000 --- a/examples/org.qt.policykit.examples.conf +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/examples/org.qt.policykit.examples.policy b/examples/org.qt.policykit.examples.policy deleted file mode 100644 index e42430c84..000000000 --- a/examples/org.qt.policykit.examples.policy +++ /dev/null @@ -1,81 +0,0 @@ - - - - KDE - http://www.kde.org - - - Kick - Prevents PolicyKit-Qt example from kicking - - no - no - - - - - Cry - Prevents PolicyKit-Qt example from crying - - no - yes - - - - - Bleed - Prevents PolicyKit-Qt example from bleeding - - no - auth_self - - - - - Play - Prevents PolicyKit-Qt example from playing - - no - auth_admin - - - - - Listen - Prevents PolicyKit-Qt example from listening - - no - auth_self_keep - - - - - Delete - Prevents PolicyKit-Qt example from deleting - - no - auth_admin_keep - - - - - Push - Prevents PolicyKit-Qt example from setting permissions for the shout action - - no - auth_admin_keep - - - - - Shout - Prevents PolicyKit-Qt example from shouting - - no - yes - - foo - - diff --git a/examples/org.qt.policykit.examples.policy.in b/examples/org.qt.policykit.examples.policy.in deleted file mode 100644 index ddab0a9f2..000000000 --- a/examples/org.qt.policykit.examples.policy.in +++ /dev/null @@ -1,85 +0,0 @@ - - - - KDE - http://www.kde.org - - Kick - Prevents PolicyKit-Qt example from kicking - - no - no - - - - Cry - Prevents PolicyKit-Qt example from crying - - no - yes - - - - Play - Prevents PolicyKit-Qt example from playing - - no - auth_self - - - - Bleed - Prevents PolicyKit-Qt example from bleeding - - no - auth_admin - - - - Listen - Prevents PolicyKit-Qt example from listening - - no - auth_self_keep - - - - Delete - Prevents PolicyKit-Qt example from deleting - - no - auth_admin_keep - - - - diff --git a/examples/org.qt.policykit.examples.service.in b/examples/org.qt.policykit.examples.service.in deleted file mode 100644 index ae5edffd8..000000000 --- a/examples/org.qt.policykit.examples.service.in +++ /dev/null @@ -1,5 +0,0 @@ -[D-BUS Service] -Name=org.qt.policykit.examples -Exec=@BIN_INSTALL_DIR@/polkit-example-helper -User=root - diff --git a/examples/org.qt.policykit.examples.xml b/examples/org.qt.policykit.examples.xml deleted file mode 100644 index e97c67e45..000000000 --- a/examples/org.qt.policykit.examples.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/examples/org.tqt.policykit.examples.conf b/examples/org.tqt.policykit.examples.conf new file mode 100644 index 000000000..a655a7a75 --- /dev/null +++ b/examples/org.tqt.policykit.examples.conf @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + diff --git a/examples/org.tqt.policykit.examples.policy b/examples/org.tqt.policykit.examples.policy new file mode 100644 index 000000000..070feedd3 --- /dev/null +++ b/examples/org.tqt.policykit.examples.policy @@ -0,0 +1,81 @@ + + + + KDE + http://www.kde.org + + + Kick + Prevents PolicyKit-TQt example from kicking + + no + no + + + + + Cry + Prevents PolicyKit-TQt example from crying + + no + yes + + + + + Bleed + Prevents PolicyKit-TQt example from bleeding + + no + auth_self + + + + + Play + Prevents PolicyKit-TQt example from playing + + no + auth_admin + + + + + Listen + Prevents PolicyKit-TQt example from listening + + no + auth_self_keep + + + + + Delete + Prevents PolicyKit-TQt example from deleting + + no + auth_admin_keep + + + + + Push + Prevents PolicyKit-TQt example from setting permissions for the shout action + + no + auth_admin_keep + + + + + Shout + Prevents PolicyKit-TQt example from shouting + + no + yes + + foo + + diff --git a/examples/org.tqt.policykit.examples.policy.in b/examples/org.tqt.policykit.examples.policy.in new file mode 100644 index 000000000..fd0006a8c --- /dev/null +++ b/examples/org.tqt.policykit.examples.policy.in @@ -0,0 +1,85 @@ + + + + KDE + http://www.kde.org + + Kick + Prevents PolicyKit-TQt example from kicking + + no + no + + + + Cry + Prevents PolicyKit-TQt example from crying + + no + yes + + + + Play + Prevents PolicyKit-TQt example from playing + + no + auth_self + + + + Bleed + Prevents PolicyKit-TQt example from bleeding + + no + auth_admin + + + + Listen + Prevents PolicyKit-TQt example from listening + + no + auth_self_keep + + + + Delete + Prevents PolicyKit-TQt example from deleting + + no + auth_admin_keep + + + + diff --git a/examples/org.tqt.policykit.examples.service.in b/examples/org.tqt.policykit.examples.service.in new file mode 100644 index 000000000..0f57d7592 --- /dev/null +++ b/examples/org.tqt.policykit.examples.service.in @@ -0,0 +1,5 @@ +[D-BUS Service] +Name=org.tqt.policykit.examples +Exec=@BIN_INSTALL_DIR@/polkit-example-helper +User=root + diff --git a/examples/org.tqt.policykit.examples.xml b/examples/org.tqt.policykit.examples.xml new file mode 100644 index 000000000..edf62de4b --- /dev/null +++ b/examples/org.tqt.policykit.examples.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 44abb7582..ca420fb79 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -3,24 +3,24 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) -set(polkit_qt_gui_SRCS - polkitqt1-gui-action.cpp - polkitqt1-gui-actionbutton.cpp - polkitqt1-gui-actionbuttons.cpp +set(polkit_tqt_gui_SRCS + polkittqt1-gui-action.cpp + polkittqt1-gui-actionbutton.cpp + polkittqt1-gui-actionbuttons.cpp ) -automoc4_add_library(polkit-qt-gui-1 SHARED ${polkit_qt_gui_SRCS}) +automoc4_add_library(polkit-tqt-gui-1 SHARED ${polkit_tqt_gui_SRCS}) -target_link_libraries(polkit-qt-gui-1 - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${QT_QTDBUS_LIBRARY} +target_link_libraries(polkit-tqt-gui-1 + ${TQT_TQTCORE_LIBRARY} + ${TQT_TQTGUI_LIBRARY} + ${TQT_TQTDBUS_LIBRARY} ${POLKIT_LIBRARIES} - polkit-qt-core-1 + polkit-tqt-core-1 ) -set_target_properties(polkit-qt-gui-1 PROPERTIES VERSION ${POLKITQT-1_LIBRARY_VERSION} - SOVERSION ${POLKITQT-1_ABI_VERSION} - DEFINE_SYMBOL MAKE_POLKITQT1_LIB) +set_target_properties(polkit-tqt-gui-1 PROPERTIES VERSION ${POLKITTQT-1_LIBRARY_VERSION} + SOVERSION ${POLKITTQT-1_ABI_VERSION} + DEFINE_SYMBOL MAKE_POLKITTQT1_LIB) -install(TARGETS polkit-qt-gui-1 ${INSTALL_TARGETS_DEFAULT_ARGS}) +install(TARGETS polkit-tqt-gui-1 ${INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/gui/polkitqt1-gui-action.cpp b/gui/polkitqt1-gui-action.cpp deleted file mode 100644 index d591c7b52..000000000 --- a/gui/polkitqt1-gui-action.cpp +++ /dev/null @@ -1,515 +0,0 @@ -/* - * This file is part of the Polkit-qt project - * Copyright (C) 2009 Daniel Nicoletti - * Copyright (C) 2009 Dario Freddi - * Copyright (C) 2009 Jaroslav Reznik - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "polkitqt1-gui-action.h" -#include "polkitqt1-authority.h" -#include "polkitqt1-subject.h" - -#include - -namespace PolkitTQt1 -{ - -namespace Gui -{ - -/** - * \internal - */ -class Action::Private -{ -public: - Private(Action *p); - - Action *parent; - - TQString actionId; - Authority::Result pkResult; - qint64 targetPID; - - void updateAction(); - bool computePkResult(); - void configChanged(); - - bool initiallyChecked; - - // states data - bool selfBlockedVisible; - bool selfBlockedEnabled; - TQString selfBlockedText; - TQString selfBlockedWhatsThis; - TQString selfBlockedToolTip; - TQIcon selfBlockedIcon; - - bool noVisible; - bool noEnabled; - TQString noText; - TQString noWhatsThis; - TQString noToolTip; - TQIcon noIcon; - - bool authVisible; - bool authEnabled; - TQString authText; - TQString authWhatsThis; - TQString authToolTip; - TQIcon authIcon; - - bool yesVisible; - bool yesEnabled; - TQString yesText; - TQString yesWhatsThis; - TQString yesToolTip; - TQIcon yesIcon; -}; - -Action::Private::Private(Action *p) - : parent(p) - , targetPID(getpid()) -{ - initiallyChecked = false; - - // Set the default values - selfBlockedVisible = true; - selfBlockedEnabled = false; - - noVisible = true; - noEnabled = false; - - authVisible = true; - authEnabled = true; - - yesVisible = true; - yesEnabled = true; -} - -Action::Action(const TQString &actionId, TQObject *parent) - : TQAction(parent) - , d(new Private(this)) -{ - // this must be called AFTER the values initialization - setPolkitAction(actionId); - - // track the config changes to update the action - connect(Authority::instance(), SIGNAL(configChanged()), - this, SLOT(configChanged())); - // for now we call config changed.. - connect(Authority::instance(), SIGNAL(consoleKitDBChanged()), - this, SLOT(configChanged())); -} - -Action::~Action() -{ - delete d; -} - -bool Action::activate() -{ - switch (d->pkResult) { - case Authority::Yes: - case Authority::Challenge: - // just Q_EMIT the 'activated' signal - Q_EMIT authorized(); - return true; - break; - default: - case Authority::No: - if (d->noEnabled) { - /* If PolicyKit says no... and we got here.. it means - * that the user set the property "no-enabled" to - * TRUE.. - * - * Hence, they probably have a good reason for doing - * this so do let the 'activate' signal propagate.. - */ - Q_EMIT authorized(); - return true; - } - break; - } - return false; -} - -void Action::setChecked(bool checked) -{ - // We store this as initiallyChecked - // to be able to undo changes in case the auth fails - d->initiallyChecked = checked; - TQAction::setChecked(checked); -} - -void Action::Private::updateAction() -{ - if (Authority::instance()->hasError()) { - return; - } - - switch (pkResult) { - default: - case Authority::Unknown: - case Authority::No: - qobject_cast(parent)->setVisible(noVisible); - qobject_cast(parent)->setEnabled(noEnabled); - qobject_cast(parent)->setText(noText); - if (!noWhatsThis.isNull()) { - qobject_cast(parent)->setWhatsThis(noWhatsThis); - } - if (!noToolTip.isNull()) { - qobject_cast(parent)->setToolTip(noToolTip); - } - qobject_cast(parent)->setIcon(noIcon); - break; - - case Authority::Challenge: - qobject_cast(parent)->setVisible(authVisible); - qobject_cast(parent)->setEnabled(authEnabled); - qobject_cast(parent)->setText(authText); - if (!authWhatsThis.isNull()) { - qobject_cast(parent)->setWhatsThis(authWhatsThis); - } - if (!authToolTip.isNull()) { - qobject_cast(parent)->setToolTip(authToolTip); - } - qobject_cast(parent)->setIcon(authIcon); - break; - case Authority::Yes: - qobject_cast(parent)->setVisible(yesVisible); - qobject_cast(parent)->setEnabled(yesEnabled); - qobject_cast(parent)->setText(yesText); - if (!yesWhatsThis.isNull()) { - qobject_cast(parent)->setWhatsThis(yesWhatsThis); - } - if (!yesToolTip.isNull()) { - qobject_cast(parent)->setToolTip(yesToolTip); - } - qobject_cast(parent)->setIcon(yesIcon); - if (parent->isCheckable()) { - qobject_cast(parent)->setChecked(!initiallyChecked); - } - break; - } - Q_EMIT parent->dataChanged(); -} - -void Action::Private::configChanged() -{ - bool result_changed; - result_changed = computePkResult(); - if (result_changed) { - updateAction(); - } -} - -bool Action::Private::computePkResult() -{ - Authority::Result old_result; - UnixProcessSubject subject(parent->targetPID()); - - old_result = pkResult; - pkResult = Authority::Unknown; - - pkResult = Authority::instance()->checkAuthorizationSync(actionId, subject, Authority::None); - - return old_result != pkResult; -} - -qint64 Action::targetPID() const -{ - if (d->targetPID != 0) { - return d->targetPID; - } else { - return TQCoreApplication::applicationPid(); - } -} - -void Action::setTargetPID(qint64 pid) -{ - d->targetPID = pid; - - d->computePkResult(); - d->updateAction(); -} - -bool Action::isAllowed() const -{ - return d->pkResult == Authority::Yes; -} - -bool Action::is(const TQString &other) const -{ - return d->actionId == other; -} - -void Action::revoke() -{ - /*TODO: implement it? no negative authorizations available, no authorization db*/ -} - -void Action::setText(const TQString &text, States states) -{ - if (states & All) { - d->selfBlockedText = text; - d->noText = text; - d->authText = text; - d->yesText = text; - } else if (states & Auth) { - d->authText = text; - } else if (states & No) { - d->noText = text; - } else if (states & SelfBlocked) { - d->selfBlockedText = text; - } else if (states & Yes) { - d->yesText = text; - } - - d->updateAction(); -} - -TQString Action::text(Action::State state) const -{ - switch (state) { - case Yes: - return d->yesText; - case No: - return d->noText; - case Auth: - return d->authText; - case SelfBlocked: - return d->selfBlockedText; - case None: - return TQAction::text(); - default: - return TQString(); - } -} - -void Action::setToolTip(const TQString &toolTip, States states) -{ - if (states & All) { - d->selfBlockedToolTip = toolTip; - d->noToolTip = toolTip; - d->authToolTip = toolTip; - d->yesToolTip = toolTip; - } else if (states & Auth) { - d->authToolTip = toolTip; - } else if (states & No) { - d->noToolTip = toolTip; - } else if (states & SelfBlocked) { - d->selfBlockedToolTip = toolTip; - } else if (states & Yes) { - d->yesToolTip = toolTip; - } - - d->updateAction(); -} - -TQString Action::toolTip(Action::State state) const -{ - switch (state) { - case Yes: - return d->yesToolTip; - case No: - return d->noToolTip; - case Auth: - return d->authToolTip; - case SelfBlocked: - return d->selfBlockedToolTip; - case None: - return TQAction::toolTip(); - default: - return TQString(); - } -} - -void Action::setWhatsThis(const TQString &whatsThis, States states) -{ - if (states & All) { - d->selfBlockedWhatsThis = whatsThis; - d->noWhatsThis = whatsThis; - d->authWhatsThis = whatsThis; - d->yesWhatsThis = whatsThis; - } else if (states & Auth) { - d->authWhatsThis = whatsThis; - } else if (states & No) { - d->noWhatsThis = whatsThis; - } else if (states & SelfBlocked) { - d->selfBlockedWhatsThis = whatsThis; - } else if (states & Yes) { - d->yesWhatsThis = whatsThis; - } - - d->updateAction(); -} - -TQString Action::whatsThis(Action::State state) const -{ - switch (state) { - case Yes: - return d->yesWhatsThis; - case No: - return d->noWhatsThis; - case Auth: - return d->authWhatsThis; - case SelfBlocked: - return d->selfBlockedWhatsThis; - case None: - return TQAction::whatsThis(); - default: - return TQString(); - } -} - -void Action::setIcon(const TQIcon &icon, States states) -{ - if (states & All) { - d->selfBlockedIcon = icon; - d->noIcon = icon; - d->authIcon = icon; - d->yesIcon = icon; - } else if (states & Auth) { - d->authIcon = icon; - } else if (states & No) { - d->noIcon = icon; - } else if (states & SelfBlocked) { - d->selfBlockedIcon = icon; - } else if (states & Yes) { - d->yesIcon = icon; - } - - d->updateAction(); -} - -TQIcon Action::icon(Action::State state) const -{ - switch (state) { - case Yes: - return d->yesIcon; - case No: - return d->noIcon; - case Auth: - return d->authIcon; - case SelfBlocked: - return d->selfBlockedIcon; - case None: - return TQAction::icon(); - default: - return TQIcon(); - } -} - -void Action::setEnabled(bool enabled, States states) -{ - if (states & All) { - d->selfBlockedEnabled = enabled; - d->noEnabled = enabled; - d->authEnabled = enabled; - d->yesEnabled = enabled; - } else if (states & Auth) { - d->authEnabled = enabled; - } else if (states & No) { - d->noEnabled = enabled; - } else if (states & SelfBlocked) { - d->selfBlockedEnabled = enabled; - } else if (states & Yes) { - d->yesEnabled = enabled; - } - - d->updateAction(); -} - -bool Action::isEnabled(Action::State state) const -{ - switch (state) { - case Yes: - return d->yesEnabled; - case No: - return d->noEnabled; - case Auth: - return d->authEnabled; - case SelfBlocked: - return d->selfBlockedEnabled; - case None: - return TQAction::isEnabled(); - default: - return false; - } -} - -void Action::setVisible(bool visible, States states) -{ - if (states & All) { - d->selfBlockedVisible = visible; - d->noVisible = visible; - d->authVisible = visible; - d->yesVisible = visible; - } else if (states & Auth) { - d->authVisible = visible; - } else if (states & No) { - d->noVisible = visible; - } else if (states & SelfBlocked) { - d->selfBlockedVisible = visible; - } else if (states & Yes) { - d->yesVisible = visible; - } - - d->updateAction(); -} - -bool Action::isVisible(Action::State state) const -{ - switch (state) { - case Yes: - return d->yesVisible; - case No: - return d->noVisible; - case Auth: - return d->authVisible; - case SelfBlocked: - return d->selfBlockedVisible; - case None: - return TQAction::isVisible(); - default: - return false; - } -} - -void Action::setPolkitAction(const TQString &actionId) -{ - //TODO: - d->actionId = actionId; - - d->computePkResult(); - d->updateAction(); -} - -//-------------------------------------------------- - -TQString Action::actionId() const -{ - return d->actionId; -} - -} - -} - -#include "polkitqt1-gui-action.moc" diff --git a/gui/polkitqt1-gui-action.h b/gui/polkitqt1-gui-action.h deleted file mode 100644 index 0b8763e8d..000000000 --- a/gui/polkitqt1-gui-action.h +++ /dev/null @@ -1,304 +0,0 @@ -/* - * This file is part of the Polkit-qt project - * Copyright (C) 2009 Daniel Nicoletti - * Copyright (C) 2009 Dario Freddi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef POLKITQT1_GUI_ACTION_H -#define POLKITQT1_GUI_ACTION_H - -#include "polkitqt1-export.h" - -#include - -namespace PolkitTQt1 -{ - -namespace Gui -{ - -/** - * \class Action polkitqt1-gui-action.h Action - * \author Daniel Nicoletti - * \author Dario Freddi - * - * \brief Class used to manage actions - * - * This class is an interface around PolicyKit Actions. - * By using this class, you are able to track the result of a - * given action. - * - * Most of the times, you would want to use this class combined - * with a TQAbstractButton. In this case, you can use the more - * comfortable ActionButton class that manages button's properties - * update for you. - * - * \see ActionButton - */ -class POLKITQT1_EXPORT Action : public TQAction -{ - Q_OBJECT - TQ_DISABLE_COPY(Action) -public: - - enum State { - None = 0, - SelfBlocked = 1, - Yes = 2, - No = 4, - Auth = 8, - // Future usage = 16, - // Future usage = 32, - // Future usage = 64, - // Future usage = 128, - // Future usage = 256, - All = 512 - }; - Q_DECLARE_FLAGS(States, State) - - /** - * Constructs a new Action item - * - * \param actionId the PolicyKit action Id (e.g.: org.freedesktop.policykit.read) - * \param parent the object parent - */ - explicit Action(const TQString &actionId = TQString(), TQObject *parent = 0); - ~Action(); - -Q_SIGNALS: - /** - * Emitted when the PolicyKit result (PolKitResult) - * for the given action or the internal data changes - * (i.e. the user called one of the set methods). - * You should connect to this signal if you want - * to track these changes. - */ - void dataChanged(); - - /** - * Emitted when using this class as a proxy - * for a given action, It's only emitted if the - * activate() slot is called and the auth permits - * the action - * - * \see activate() - */ - void authorized(); - -public Q_SLOTS: - /** - * Use this slot if you want to activate - * the action. authorized() will be emitted - * if the action gets authorized. - * - * \return \c true if the caller can do the action - * - * \see authorized() - */ - bool activate(); - - /** - * Defines the checked state. The opposite state will - * trigger authentication for this actions. For example, if - * you set this to \c true, when the action's checked state - * will become \c false, the authentication will be triggered. - * - * \param checked the new checked state - */ - void setChecked(bool checked); - - /** - * This method can be used to revoke the authorization - * obtained for this action. - */ - void revoke(); - -public: - /** - * Changes the action being tracked - * - * \param actionId The new action ID - */ - void setPolkitAction(const TQString &actionId); - - /** - * Returns the current action ID. - * - * \return The action ID - * - */ - TQString actionId() const; - - /** - * Sets the text for the current action. This will - * be shown only in the states specified in the \c states parameter. - * \param text the new text for the action - * \param states the states of the Polkit action on which the setting - * will be applied - */ - void setText(const TQString &text, States states = All); - - /** - * Sets the tooltip for the current action. This will - * be shown only in the states specified in the \c states parameter. - * \param toolTip the new tooltip for the action - * \param states the states of the Polkit action on which the setting - * will be applied - */ - void setToolTip(const TQString &toolTip, States states = All); - - /** - * Sets the whatsthis for the current action. This will - * be shown only in the states specified in the \c states parameter. - * \param whatsThis the new whatsthis for the action - * \param states the states of the Polkit action on which the setting - * will be applied - */ - void setWhatsThis(const TQString &whatsThis, States states = All); - - /** - * Sets the icon for the current action. This will - * be shown only in the states specified in the \c states parameter. - * \note You need to pass a TQIcon here. You can easily - * create one from a Pixmap, or pass a KIcon - * \param icon the new icon for the action - * \param states the states of the Polkit action on which the setting - * will be applied - */ - void setIcon(const TQIcon &icon, States states = All); - - /** - * Sets whether the current action is visible or not. This will - * be applied only in the states specified in the \c states parameter. - * \param visible visibility of the action - * \param states the states of the Polkit action on which the setting - * will be applied - */ - void setVisible(bool visible, States states = All); - - /** - * Sets whether the current action is enabled or not. This will - * be shown only in the states specified in the \c states parameter. - * \param enabled whether the Action will be enabled or not - * \param states the states of the Polkit action on which the setting - * will be applied - */ - void setEnabled(bool enabled, States states = All); - - /** - * This function sets the process id of the target that - * should receive the authorization. Set this to 0 to set - * the current process as the target. - * - * \param pid The target process id; 0 if it is the current process - */ - void setTargetPID(qint64 pid); - - /** - * Gets the text of the action when it is in the specified state - * - * \note Passing None will return the current value - * \param state The state to be checked - * \returns The text shown when the action is in the specified state - */ - TQString text(State state = None) const; - - /** - * Gets the tooltip of the action when it is in the specified state - * - * \note Passing None will return the current value - * \param state The state to be checked - * \returns The tooltip shown when the action is in the specified state - */ - TQString toolTip(State state = None) const; - - /** - * Gets the whatsThis of the action when it is in the specified state - * - * \param state The state to be checked - * \returns The whatsThis shown when the action is in the specified state - */ - TQString whatsThis(State state = None) const; - - /** - * Gets the icon of the action when it is in the specified state - * - * \note Passing None will return the current value - * \param state The state to be checked - * \returns The icon shown when the action is in the specified state - */ - TQIcon icon(State state = None) const; - - /** - * Gets whether the action is visible or not when it is in the specified state - * - * \note Passing None will return the current value - * \param state The state to be checked - * \returns Whether the action is visible or not in the specified state - */ - bool isVisible(State state = None) const; - - /** - * Gets whether the action is enabled or not when it is in the specified state - * - * \note Passing None will return the current value - * \param state The state to be checked - * \returns Whether the action is enabled or not in the specified state - */ - bool isEnabled(State state = None) const; - - /** - * \see setTargetPID - */ - qint64 targetPID() const; - - /** - * This method can be used to check the if the current action - * can be performed (i.e. PolKitResult is YES). - * \note This method does not call the authentication dialog, use - * activate() instead - * \return \c true if the action can be performed - */ - bool isAllowed() const; - - /** - * This method compares a PolicyKit action Id with the - * current one of the object. - * - * \see actionId() - * - * \param actionId the action Id to compare - * - * \return \c true if the actionId is the same as this object's one - */ - bool is(const TQString &actionId) const; - -private: - class Private; - Private * const d; - - Q_PRIVATE_SLOT(d, void configChanged()) -}; - -} - -} - -Q_DECLARE_OPERATORS_FOR_FLAGS(PolkitTQt1::Gui::Action::States) - -#endif diff --git a/gui/polkitqt1-gui-actionbutton.cpp b/gui/polkitqt1-gui-actionbutton.cpp deleted file mode 100644 index fefb831cf..000000000 --- a/gui/polkitqt1-gui-actionbutton.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* - * This file is part of the Polkit-qt project - * Copyright (C) 2009 Daniel Nicoletti - * Copyright (C) 2009 Dario Freddi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "polkitqt1-gui-actionbutton.h" - -#include "polkitqt1-gui-actionbutton_p.h" - -namespace PolkitTQt1 -{ - -namespace Gui -{ - -ActionButton::ActionButton(TQAbstractButton *button, const TQString &actionId, TQObject *parent) - : Action(actionId, parent) - , d_ptr(new ActionButtonPrivate(TQList() << button)) -{ - d_ptr->q_ptr = this; - - setButton(button); - connect(this, SIGNAL(dataChanged()), SLOT(updateButton())); -} - -ActionButton::ActionButton(ActionButtonPrivate &dd, const TQString &actionId, TQObject *parent) - : Action(actionId, parent) - , d_ptr(&dd) -{ - d_ptr->q_ptr = this; - - connect(this, SIGNAL(dataChanged()), SLOT(updateButton())); -} - -ActionButton::~ActionButton() -{ - delete d_ptr; -} - -void ActionButtonPrivate::updateButton() -{ - Q_Q(ActionButton); - - Q_FOREACH(TQAbstractButton *ent, buttons) { - ent->setVisible(q->isVisible()); - ent->setEnabled(q->isEnabled()); - ent->setText(q->text()); - if (!q->toolTip().isNull()) { - ent->setToolTip(q->toolTip()); - } - if (!q->whatsThis().isNull()) { - ent->setWhatsThis(q->whatsThis()); - } - ent->setIcon(q->icon()); - // if the item cannot do the action anymore - // lets revert to the initial state - if (ent->isCheckable()) { - ent->setChecked(q->isChecked()); - } - } -} - -bool ActionButton::activate() -{ - Q_D(ActionButton); - - bool tg = false; - Q_FOREACH(TQAbstractButton *ent, d->buttons) { - if (ent->isCheckable()) { - // we set the the current Action state - ent->setChecked(isChecked()); - // toggle the action cause we are not directly connected there.. - tg = true; - } - } - - if (tg) { - toggle(); - } - - return Action::activate(); -} - -void ActionButton::setButton(TQAbstractButton *button) -{ - Q_D(ActionButton); - - // First, let's clear the list - Q_FOREACH(TQAbstractButton *ent, d->buttons) { - d->removeButton(ent); - } - - // And then add it - d->addButton(button); -} - -void ActionButtonPrivate::addButton(TQAbstractButton *button) -{ - Q_Q(ActionButton); - - buttons.append(button); - TQObject::connect(button, SIGNAL(clicked(bool)), q, SLOT(streamClicked(bool))); - TQObject::connect(q, SIGNAL(toggled(bool)), button, SLOT(toggle())); - if (q->isCheckable()) { - // the button should follow our first buttons - button->setCheckable(true); - } else if (button->isCheckable()) { - // if we are not checkable BUT the button - // is (eg a TQCheckBox) we should set all buttons to - // checkable. - Q_FOREACH(TQAbstractButton *ent, buttons) { - ent->setCheckable(true); - } - // set the checkable state of Action to store the initial state - q->setCheckable(true); - } - // call this after m_activateOnCheck receives the value - updateButton(); -} - -void ActionButtonPrivate::removeButton(TQAbstractButton *button) -{ - Q_Q(ActionButton); - - if (buttons.contains(button)) { - TQObject::disconnect(button, SIGNAL(clicked(bool)), q, SLOT(streamClicked(bool))); - TQObject::disconnect(q, SIGNAL(toggled(bool)), button, SLOT(toggle())); - buttons.removeOne(button); - } -} - -TQAbstractButton *ActionButton::button() const -{ - Q_D(const ActionButton); - - return d->buttons.first(); -} - -void ActionButtonPrivate::streamClicked(bool c) -{ - Q_Q(ActionButton); - - Q_EMIT q->clicked(qobject_cast(q->sender()), c); -} - -} - -} - -#include "polkitqt1-gui-actionbutton.moc" diff --git a/gui/polkitqt1-gui-actionbutton.h b/gui/polkitqt1-gui-actionbutton.h deleted file mode 100644 index 67fdba347..000000000 --- a/gui/polkitqt1-gui-actionbutton.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * This file is part of the Polkit-qt project - * Copyright (C) 2009 Daniel Nicoletti - * Copyright (C) 2009 Dario Freddi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef POLKITQT1_GUI_ACTIONBUTTON_H -#define POLKITQT1_GUI_ACTIONBUTTON_H - -#include "polkitqt1-export.h" -#include "polkitqt1-gui-action.h" - -class TQAbstractButton; - -namespace PolkitTQt1 -{ - -namespace Gui -{ - -class ActionButtonPrivate; -/** - * \class ActionButton polkitqt1-gui-actionbutton.h ActionButton - * \author Daniel Nicoletti - * \author Dario Freddi - * - * \brief Class used to hold and update a TQAbstractButton - * - * This class allows you to associate TQAbstractButtons - * (i.e. TQPushButton) to a PolicyKit Action. It will update the - * button properties according to the PolicyKit Action automatically. - * - * \note You should connect the activated() signal to receive - * a notification when the user clicked the button and gets - * permission to perform the given action. If you set 'noEnabled' - * to \c true it will be emitted when PolKitResult is NO. - */ -class POLKITQT1_EXPORT ActionButton : public Action -{ - Q_OBJECT - Q_DECLARE_PRIVATE(ActionButton) - TQ_DISABLE_COPY(ActionButton) - -public: - /** - * Constructs a new ActionButton. You need to pass this - * constructor an existing TQAbstractButton, whose properties - * will be modified according to the underlying Action - * object. As ActionButton inherits from Action, you can - * define your button's behavior right through this wrapper. - * - * \see Action - * - * \param button the TQAbstractButton to associate to this ActionButton - * \param actionId the action Id to create the underlying Action - * \param parent the parent object - */ - explicit ActionButton(TQAbstractButton *button, const TQString &actionId = TQString(), TQObject *parent = 0); - virtual ~ActionButton(); - - /** - * Sets the button associated to the underlying action. - * - * \note If you are calling this function, you're probably - * changing the button the action is referring to. If this - * is the case, please note that Polkit-TQt does not handle - * the previous button's memory, so you should take care of - * deleting it yourself (if needed). You can retrieve it by - * using button() - * - * \see button - * - * \param button the new button associated with the underlying action - */ - void setButton(TQAbstractButton *button); - - /** - * Returns the current button - * - * \return the button currently associated with the underlying action - */ - TQAbstractButton *button() const; - -public Q_SLOTS: - /** - * Connect clicked() signals to this slot. This should be - * manually done, as in some cases we might want - * to manually call this. Calling this will emit authorized(). - * - * \note This slot is reentrant which is likely to only be a problem - * if you are creating an interface to setup PolicyKit policies. - * \note If you have a checkbox, connect to its' clicked() signal - * to avoid an infinite loop as this function internally calls setChecked(). - * You can always use the clicked(bool) signal in this class to - * connect to here. - * \warning if you use this class take care to not call Action::activate - * otherwise your checkable buttons won't be properly updated. - */ - bool activate(); - -Q_SIGNALS: - /** - * Emitted when the abstract button clicked(bool) signal - * is emitted. This allows you to use qobject_cast(sender()) - * in a slot connected to this signal and call activate() on it. - * - * \note you will normally want to connect this signal - * to the activate slot. - * - * \param button the button that has been clicked - * \param checked the checked state, if applicable. Otherwise \c false - * - */ - void clicked(TQAbstractButton *button, bool checked = false); - -protected: - ActionButton(ActionButtonPrivate &dd, const TQString &actionId, TQObject *parent = 0); - - ActionButtonPrivate * const d_ptr; - -private: - Q_PRIVATE_SLOT(d_func(), void updateButton()) - Q_PRIVATE_SLOT(d_func(), void streamClicked(bool)) -}; - -} - -} - -#endif diff --git a/gui/polkitqt1-gui-actionbutton_p.h b/gui/polkitqt1-gui-actionbutton_p.h deleted file mode 100644 index fce14de64..000000000 --- a/gui/polkitqt1-gui-actionbutton_p.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of the Polkit-qt project - * Copyright (C) 2009 Dario Freddi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef POLKITQT1_GUI_ACTIONBUTTON_P_H -#define POLKITQT1_GUI_ACTIONBUTTON_P_H - -#include - -#include -#include - -/** - * \internal - */ -class PolkitTQt1::Gui::ActionButtonPrivate -{ -public: - ActionButtonPrivate(const TQList &b) - : buttons(b) {} - virtual ~ActionButtonPrivate() {} - - void addButton(TQAbstractButton *button); - void removeButton(TQAbstractButton *button); - void updateButton(); - void streamClicked(bool); - - Q_DECLARE_PUBLIC(ActionButton) - ActionButton *q_ptr; - - TQList buttons; -}; - -#endif /* ACTIONBUTTON_P_H */ diff --git a/gui/polkitqt1-gui-actionbuttons.cpp b/gui/polkitqt1-gui-actionbuttons.cpp deleted file mode 100644 index 125c0959f..000000000 --- a/gui/polkitqt1-gui-actionbuttons.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This file is part of the Polkit-qt project - * Copyright (C) 2009 Dario Freddi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "polkitqt1-gui-actionbuttons.h" - -#include "polkitqt1-gui-actionbuttons_p.h" - -namespace PolkitTQt1 -{ - -namespace Gui -{ - -ActionButtons::ActionButtons(const TQList &buttons, const TQString &actionId, TQObject *parent) - : ActionButton(*new ActionButtonsPrivate(buttons), actionId, parent) -{ - setButtons(buttons); -} - -ActionButtons::~ActionButtons() -{ -} - -void ActionButtons::setButtons(const TQList &buttons) -{ - Q_FOREACH(TQAbstractButton *ent, buttons) { - addButton(ent); - } -} - -TQList ActionButtons::buttons() const -{ - Q_D(const ActionButtons); - - return d->buttons; -} - -void ActionButtons::addButton(TQAbstractButton *button) -{ - Q_D(ActionButtons); - - d->addButton(button); -} - -void ActionButtons::removeButton(TQAbstractButton *button) -{ - Q_D(ActionButtons); - - d->removeButton(button); -} - -} - -} - -#include "polkitqt1-gui-actionbuttons.moc" diff --git a/gui/polkitqt1-gui-actionbuttons.h b/gui/polkitqt1-gui-actionbuttons.h deleted file mode 100644 index 4e5988fd0..000000000 --- a/gui/polkitqt1-gui-actionbuttons.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * This file is part of the Polkit-qt project - * Copyright (C) 2009 Dario Freddi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef POLKITQT1_GUI_ACTIONBUTTONS_H -#define POLKITQT1_GUI_ACTIONBUTTONS_H - -#include "polkitqt1-gui-actionbutton.h" - -namespace PolkitTQt1 -{ - -namespace Gui -{ - -class ActionButtonsPrivate; -/** - * \class ActionButtons polkitqt1-gui-actionbuttons.h ActionButtons - * \author Dario Freddi - * - * \brief Class used to hold and update a list of TQAbstractButtons - * - * This class is a convenience wrapper around ActionButton that lets - * you associate an undefined number of TQAbstractButtons with a single - * action. Every button will be updated accordingly upon action's properties - * changes. - * - * \see ActionButton - */ -class ActionButtons : public ActionButton -{ - Q_OBJECT - Q_DECLARE_PRIVATE(ActionButtons) - TQ_DISABLE_COPY(ActionButtons) - -public: - /** - * Constructs a new ActionButton. You need to pass this - * constructor an existing list of TQAbstractButtons, whose properties - * will be modified according to the underlying Action - * object. As ActionButtons inherits from Action, you can - * define your buttons' behavior right through this wrapper. - * - * \see Action - * - * \param buttons the TQAbstractButton to associate to this ActionButton - * \param actionId the action Id to create the underlying Action - * \param parent the parent object - */ - explicit ActionButtons(const TQList &buttons, const TQString &actionId = TQString(), TQObject *parent = 0); - virtual ~ActionButtons(); - - /** - * Sets a list of buttons associated to the underlying action. - * - * \note If you are calling this function, you're probably - * changing the buttons list the action is referring to. If this - * is the case, please note that Polkit-TQt does not handle - * the previous buttons' memory, so you should take care of - * deleting them yourself (if needed). You can retrieve it by - * using buttons() - * - * \see buttons - * - * \param buttons the new buttons associated with the underlying action - */ - void setButtons(const TQList &buttons); - - /** - * Returns the current buttons list - * - * \return the buttons currently associated with the underlying action - */ - TQList buttons() const; - - /** - * Adds a button to the current button list. The button's properties - * will be updated according to the action upon adding. - * - * \param button the button to add - */ - void addButton(TQAbstractButton *button); - - /** - * Removes a button from the current list. Please note that Polkit-TQt - * does not handle the removed button's memory, so you should take care of - * deleting it yourself (if needed). - * - * \param button the button to remove - */ - void removeButton(TQAbstractButton *button); -}; - -} - -} - -#endif diff --git a/gui/polkitqt1-gui-actionbuttons_p.h b/gui/polkitqt1-gui-actionbuttons_p.h deleted file mode 100644 index b6b8518f4..000000000 --- a/gui/polkitqt1-gui-actionbuttons_p.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of the Polkit-qt project - * Copyright (C) 2009 Dario Freddi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef POLKITQT1_GUI_ACTIONBUTTONS_P_H -#define POLKITQT1_GUI_ACTIONBUTTONS_P_H - -#include "polkitqt1-gui-actionbutton_p.h" - -/** - * \internal - */ -class PolkitTQt1::Gui::ActionButtonsPrivate : public ActionButtonPrivate -{ -public: - ActionButtonsPrivate(const TQList &b) - : ActionButtonPrivate(b) {} -}; - -#endif /* ACTIONBUTTONS_P_H */ diff --git a/gui/polkittqt1-gui-action.cpp b/gui/polkittqt1-gui-action.cpp new file mode 100644 index 000000000..31f01cfb7 --- /dev/null +++ b/gui/polkittqt1-gui-action.cpp @@ -0,0 +1,515 @@ +/* + * This file is part of the Polkit-tqt project + * Copyright (C) 2009 Daniel Nicoletti + * Copyright (C) 2009 Dario Freddi + * Copyright (C) 2009 Jaroslav Reznik + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "polkittqt1-gui-action.h" +#include "polkittqt1-authority.h" +#include "polkittqt1-subject.h" + +#include + +namespace PolkitTQt1 +{ + +namespace Gui +{ + +/** + * \internal + */ +class Action::Private +{ +public: + Private(Action *p); + + Action *parent; + + TQString actionId; + Authority::Result pkResult; + tqint64 targetPID; + + void updateAction(); + bool computePkResult(); + void configChanged(); + + bool initiallyChecked; + + // states data + bool selfBlockedVisible; + bool selfBlockedEnabled; + TQString selfBlockedText; + TQString selfBlockedWhatsThis; + TQString selfBlockedToolTip; + TQIcon selfBlockedIcon; + + bool noVisible; + bool noEnabled; + TQString noText; + TQString noWhatsThis; + TQString noToolTip; + TQIcon noIcon; + + bool authVisible; + bool authEnabled; + TQString authText; + TQString authWhatsThis; + TQString authToolTip; + TQIcon authIcon; + + bool yesVisible; + bool yesEnabled; + TQString yesText; + TQString yesWhatsThis; + TQString yesToolTip; + TQIcon yesIcon; +}; + +Action::Private::Private(Action *p) + : parent(p) + , targetPID(getpid()) +{ + initiallyChecked = false; + + // Set the default values + selfBlockedVisible = true; + selfBlockedEnabled = false; + + noVisible = true; + noEnabled = false; + + authVisible = true; + authEnabled = true; + + yesVisible = true; + yesEnabled = true; +} + +Action::Action(const TQString &actionId, TQObject *parent) + : TQAction(parent) + , d(new Private(this)) +{ + // this must be called AFTER the values initialization + setPolkitAction(actionId); + + // track the config changes to update the action + connect(Authority::instance(), SIGNAL(configChanged()), + this, SLOT(configChanged())); + // for now we call config changed.. + connect(Authority::instance(), SIGNAL(consoleKitDBChanged()), + this, SLOT(configChanged())); +} + +Action::~Action() +{ + delete d; +} + +bool Action::activate() +{ + switch (d->pkResult) { + case Authority::Yes: + case Authority::Challenge: + // just Q_EMIT the 'activated' signal + TQ_EMIT authorized(); + return true; + break; + default: + case Authority::No: + if (d->noEnabled) { + /* If PolicyKit says no... and we got here.. it means + * that the user set the property "no-enabled" to + * TRUE.. + * + * Hence, they probably have a good reason for doing + * this so do let the 'activate' signal propagate.. + */ + TQ_EMIT authorized(); + return true; + } + break; + } + return false; +} + +void Action::setChecked(bool checked) +{ + // We store this as initiallyChecked + // to be able to undo changes in case the auth fails + d->initiallyChecked = checked; + TQAction::setChecked(checked); +} + +void Action::Private::updateAction() +{ + if (Authority::instance()->hasError()) { + return; + } + + switch (pkResult) { + default: + case Authority::Unknown: + case Authority::No: + qobject_cast(parent)->setVisible(noVisible); + qobject_cast(parent)->setEnabled(noEnabled); + qobject_cast(parent)->setText(noText); + if (!noWhatsThis.isNull()) { + qobject_cast(parent)->setWhatsThis(noWhatsThis); + } + if (!noToolTip.isNull()) { + qobject_cast(parent)->setToolTip(noToolTip); + } + qobject_cast(parent)->setIcon(noIcon); + break; + + case Authority::Challenge: + qobject_cast(parent)->setVisible(authVisible); + qobject_cast(parent)->setEnabled(authEnabled); + qobject_cast(parent)->setText(authText); + if (!authWhatsThis.isNull()) { + qobject_cast(parent)->setWhatsThis(authWhatsThis); + } + if (!authToolTip.isNull()) { + qobject_cast(parent)->setToolTip(authToolTip); + } + qobject_cast(parent)->setIcon(authIcon); + break; + case Authority::Yes: + qobject_cast(parent)->setVisible(yesVisible); + qobject_cast(parent)->setEnabled(yesEnabled); + qobject_cast(parent)->setText(yesText); + if (!yesWhatsThis.isNull()) { + qobject_cast(parent)->setWhatsThis(yesWhatsThis); + } + if (!yesToolTip.isNull()) { + qobject_cast(parent)->setToolTip(yesToolTip); + } + qobject_cast(parent)->setIcon(yesIcon); + if (parent->isCheckable()) { + qobject_cast(parent)->setChecked(!initiallyChecked); + } + break; + } + TQ_EMIT parent->dataChanged(); +} + +void Action::Private::configChanged() +{ + bool result_changed; + result_changed = computePkResult(); + if (result_changed) { + updateAction(); + } +} + +bool Action::Private::computePkResult() +{ + Authority::Result old_result; + UnixProcessSubject subject(parent->targetPID()); + + old_result = pkResult; + pkResult = Authority::Unknown; + + pkResult = Authority::instance()->checkAuthorizationSync(actionId, subject, Authority::None); + + return old_result != pkResult; +} + +tqint64 Action::targetPID() const +{ + if (d->targetPID != 0) { + return d->targetPID; + } else { + return TQCoreApplication::applicationPid(); + } +} + +void Action::setTargetPID(tqint64 pid) +{ + d->targetPID = pid; + + d->computePkResult(); + d->updateAction(); +} + +bool Action::isAllowed() const +{ + return d->pkResult == Authority::Yes; +} + +bool Action::is(const TQString &other) const +{ + return d->actionId == other; +} + +void Action::revoke() +{ + /*TODO: implement it? no negative authorizations available, no authorization db*/ +} + +void Action::setText(const TQString &text, States states) +{ + if (states & All) { + d->selfBlockedText = text; + d->noText = text; + d->authText = text; + d->yesText = text; + } else if (states & Auth) { + d->authText = text; + } else if (states & No) { + d->noText = text; + } else if (states & SelfBlocked) { + d->selfBlockedText = text; + } else if (states & Yes) { + d->yesText = text; + } + + d->updateAction(); +} + +TQString Action::text(Action::State state) const +{ + switch (state) { + case Yes: + return d->yesText; + case No: + return d->noText; + case Auth: + return d->authText; + case SelfBlocked: + return d->selfBlockedText; + case None: + return TQAction::text(); + default: + return TQString(); + } +} + +void Action::setToolTip(const TQString &toolTip, States states) +{ + if (states & All) { + d->selfBlockedToolTip = toolTip; + d->noToolTip = toolTip; + d->authToolTip = toolTip; + d->yesToolTip = toolTip; + } else if (states & Auth) { + d->authToolTip = toolTip; + } else if (states & No) { + d->noToolTip = toolTip; + } else if (states & SelfBlocked) { + d->selfBlockedToolTip = toolTip; + } else if (states & Yes) { + d->yesToolTip = toolTip; + } + + d->updateAction(); +} + +TQString Action::toolTip(Action::State state) const +{ + switch (state) { + case Yes: + return d->yesToolTip; + case No: + return d->noToolTip; + case Auth: + return d->authToolTip; + case SelfBlocked: + return d->selfBlockedToolTip; + case None: + return TQAction::toolTip(); + default: + return TQString(); + } +} + +void Action::setWhatsThis(const TQString &whatsThis, States states) +{ + if (states & All) { + d->selfBlockedWhatsThis = whatsThis; + d->noWhatsThis = whatsThis; + d->authWhatsThis = whatsThis; + d->yesWhatsThis = whatsThis; + } else if (states & Auth) { + d->authWhatsThis = whatsThis; + } else if (states & No) { + d->noWhatsThis = whatsThis; + } else if (states & SelfBlocked) { + d->selfBlockedWhatsThis = whatsThis; + } else if (states & Yes) { + d->yesWhatsThis = whatsThis; + } + + d->updateAction(); +} + +TQString Action::whatsThis(Action::State state) const +{ + switch (state) { + case Yes: + return d->yesWhatsThis; + case No: + return d->noWhatsThis; + case Auth: + return d->authWhatsThis; + case SelfBlocked: + return d->selfBlockedWhatsThis; + case None: + return TQAction::whatsThis(); + default: + return TQString(); + } +} + +void Action::setIcon(const TQIcon &icon, States states) +{ + if (states & All) { + d->selfBlockedIcon = icon; + d->noIcon = icon; + d->authIcon = icon; + d->yesIcon = icon; + } else if (states & Auth) { + d->authIcon = icon; + } else if (states & No) { + d->noIcon = icon; + } else if (states & SelfBlocked) { + d->selfBlockedIcon = icon; + } else if (states & Yes) { + d->yesIcon = icon; + } + + d->updateAction(); +} + +TQIcon Action::icon(Action::State state) const +{ + switch (state) { + case Yes: + return d->yesIcon; + case No: + return d->noIcon; + case Auth: + return d->authIcon; + case SelfBlocked: + return d->selfBlockedIcon; + case None: + return TQAction::icon(); + default: + return TQIcon(); + } +} + +void Action::setEnabled(bool enabled, States states) +{ + if (states & All) { + d->selfBlockedEnabled = enabled; + d->noEnabled = enabled; + d->authEnabled = enabled; + d->yesEnabled = enabled; + } else if (states & Auth) { + d->authEnabled = enabled; + } else if (states & No) { + d->noEnabled = enabled; + } else if (states & SelfBlocked) { + d->selfBlockedEnabled = enabled; + } else if (states & Yes) { + d->yesEnabled = enabled; + } + + d->updateAction(); +} + +bool Action::isEnabled(Action::State state) const +{ + switch (state) { + case Yes: + return d->yesEnabled; + case No: + return d->noEnabled; + case Auth: + return d->authEnabled; + case SelfBlocked: + return d->selfBlockedEnabled; + case None: + return TQAction::isEnabled(); + default: + return false; + } +} + +void Action::setVisible(bool visible, States states) +{ + if (states & All) { + d->selfBlockedVisible = visible; + d->noVisible = visible; + d->authVisible = visible; + d->yesVisible = visible; + } else if (states & Auth) { + d->authVisible = visible; + } else if (states & No) { + d->noVisible = visible; + } else if (states & SelfBlocked) { + d->selfBlockedVisible = visible; + } else if (states & Yes) { + d->yesVisible = visible; + } + + d->updateAction(); +} + +bool Action::isVisible(Action::State state) const +{ + switch (state) { + case Yes: + return d->yesVisible; + case No: + return d->noVisible; + case Auth: + return d->authVisible; + case SelfBlocked: + return d->selfBlockedVisible; + case None: + return TQAction::isVisible(); + default: + return false; + } +} + +void Action::setPolkitAction(const TQString &actionId) +{ + //TODO: + d->actionId = actionId; + + d->computePkResult(); + d->updateAction(); +} + +//-------------------------------------------------- + +TQString Action::actionId() const +{ + return d->actionId; +} + +} + +} + +#include "polkittqt1-gui-action.moc" diff --git a/gui/polkittqt1-gui-action.h b/gui/polkittqt1-gui-action.h new file mode 100644 index 000000000..6ee42179c --- /dev/null +++ b/gui/polkittqt1-gui-action.h @@ -0,0 +1,304 @@ +/* + * This file is part of the Polkit-tqt project + * Copyright (C) 2009 Daniel Nicoletti + * Copyright (C) 2009 Dario Freddi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef POLKITTQT1_GUI_ACTION_H +#define POLKITTQT1_GUI_ACTION_H + +#include "polkittqt1-export.h" + +#include + +namespace PolkitTQt1 +{ + +namespace Gui +{ + +/** + * \class Action polkittqt1-gui-action.h Action + * \author Daniel Nicoletti + * \author Dario Freddi + * + * \brief Class used to manage actions + * + * This class is an interface around PolicyKit Actions. + * By using this class, you are able to track the result of a + * given action. + * + * Most of the times, you would want to use this class combined + * with a TQAbstractButton. In this case, you can use the more + * comfortable ActionButton class that manages button's properties + * update for you. + * + * \see ActionButton + */ +class POLKITTQT1_EXPORT Action : public TQAction +{ + Q_OBJECT + TQ_DISABLE_COPY(Action) +public: + + enum State { + None = 0, + SelfBlocked = 1, + Yes = 2, + No = 4, + Auth = 8, + // Future usage = 16, + // Future usage = 32, + // Future usage = 64, + // Future usage = 128, + // Future usage = 256, + All = 512 + }; + TQ_DECLARE_FLAGS(States, State) + + /** + * Constructs a new Action item + * + * \param actionId the PolicyKit action Id (e.g.: org.freedesktop.policykit.read) + * \param parent the object parent + */ + explicit Action(const TQString &actionId = TQString(), TQObject *parent = 0); + ~Action(); + +Q_SIGNALS: + /** + * Emitted when the PolicyKit result (PolKitResult) + * for the given action or the internal data changes + * (i.e. the user called one of the set methods). + * You should connect to this signal if you want + * to track these changes. + */ + void dataChanged(); + + /** + * Emitted when using this class as a proxy + * for a given action, It's only emitted if the + * activate() slot is called and the auth permits + * the action + * + * \see activate() + */ + void authorized(); + +public Q_SLOTS: + /** + * Use this slot if you want to activate + * the action. authorized() will be emitted + * if the action gets authorized. + * + * \return \c true if the caller can do the action + * + * \see authorized() + */ + bool activate(); + + /** + * Defines the checked state. The opposite state will + * trigger authentication for this actions. For example, if + * you set this to \c true, when the action's checked state + * will become \c false, the authentication will be triggered. + * + * \param checked the new checked state + */ + void setChecked(bool checked); + + /** + * This method can be used to revoke the authorization + * obtained for this action. + */ + void revoke(); + +public: + /** + * Changes the action being tracked + * + * \param actionId The new action ID + */ + void setPolkitAction(const TQString &actionId); + + /** + * Returns the current action ID. + * + * \return The action ID + * + */ + TQString actionId() const; + + /** + * Sets the text for the current action. This will + * be shown only in the states specified in the \c states parameter. + * \param text the new text for the action + * \param states the states of the Polkit action on which the setting + * will be applied + */ + void setText(const TQString &text, States states = All); + + /** + * Sets the tooltip for the current action. This will + * be shown only in the states specified in the \c states parameter. + * \param toolTip the new tooltip for the action + * \param states the states of the Polkit action on which the setting + * will be applied + */ + void setToolTip(const TQString &toolTip, States states = All); + + /** + * Sets the whatsthis for the current action. This will + * be shown only in the states specified in the \c states parameter. + * \param whatsThis the new whatsthis for the action + * \param states the states of the Polkit action on which the setting + * will be applied + */ + void setWhatsThis(const TQString &whatsThis, States states = All); + + /** + * Sets the icon for the current action. This will + * be shown only in the states specified in the \c states parameter. + * \note You need to pass a TQIcon here. You can easily + * create one from a Pixmap, or pass a KIcon + * \param icon the new icon for the action + * \param states the states of the Polkit action on which the setting + * will be applied + */ + void setIcon(const TQIcon &icon, States states = All); + + /** + * Sets whether the current action is visible or not. This will + * be applied only in the states specified in the \c states parameter. + * \param visible visibility of the action + * \param states the states of the Polkit action on which the setting + * will be applied + */ + void setVisible(bool visible, States states = All); + + /** + * Sets whether the current action is enabled or not. This will + * be shown only in the states specified in the \c states parameter. + * \param enabled whether the Action will be enabled or not + * \param states the states of the Polkit action on which the setting + * will be applied + */ + void setEnabled(bool enabled, States states = All); + + /** + * This function sets the process id of the target that + * should receive the authorization. Set this to 0 to set + * the current process as the target. + * + * \param pid The target process id; 0 if it is the current process + */ + void setTargetPID(tqint64 pid); + + /** + * Gets the text of the action when it is in the specified state + * + * \note Passing None will return the current value + * \param state The state to be checked + * \returns The text shown when the action is in the specified state + */ + TQString text(State state = None) const; + + /** + * Gets the tooltip of the action when it is in the specified state + * + * \note Passing None will return the current value + * \param state The state to be checked + * \returns The tooltip shown when the action is in the specified state + */ + TQString toolTip(State state = None) const; + + /** + * Gets the whatsThis of the action when it is in the specified state + * + * \param state The state to be checked + * \returns The whatsThis shown when the action is in the specified state + */ + TQString whatsThis(State state = None) const; + + /** + * Gets the icon of the action when it is in the specified state + * + * \note Passing None will return the current value + * \param state The state to be checked + * \returns The icon shown when the action is in the specified state + */ + TQIcon icon(State state = None) const; + + /** + * Gets whether the action is visible or not when it is in the specified state + * + * \note Passing None will return the current value + * \param state The state to be checked + * \returns Whether the action is visible or not in the specified state + */ + bool isVisible(State state = None) const; + + /** + * Gets whether the action is enabled or not when it is in the specified state + * + * \note Passing None will return the current value + * \param state The state to be checked + * \returns Whether the action is enabled or not in the specified state + */ + bool isEnabled(State state = None) const; + + /** + * \see setTargetPID + */ + tqint64 targetPID() const; + + /** + * This method can be used to check the if the current action + * can be performed (i.e. PolKitResult is YES). + * \note This method does not call the authentication dialog, use + * activate() instead + * \return \c true if the action can be performed + */ + bool isAllowed() const; + + /** + * This method compares a PolicyKit action Id with the + * current one of the object. + * + * \see actionId() + * + * \param actionId the action Id to compare + * + * \return \c true if the actionId is the same as this object's one + */ + bool is(const TQString &actionId) const; + +private: + class Private; + Private * const d; + + Q_PRIVATE_SLOT(d, void configChanged()) +}; + +} + +} + +TQ_DECLARE_OPERATORS_FOR_FLAGS(PolkitTQt1::Gui::Action::States) + +#endif diff --git a/gui/polkittqt1-gui-actionbutton.cpp b/gui/polkittqt1-gui-actionbutton.cpp new file mode 100644 index 000000000..f817088c1 --- /dev/null +++ b/gui/polkittqt1-gui-actionbutton.cpp @@ -0,0 +1,166 @@ +/* + * This file is part of the Polkit-tqt project + * Copyright (C) 2009 Daniel Nicoletti + * Copyright (C) 2009 Dario Freddi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "polkittqt1-gui-actionbutton.h" + +#include "polkittqt1-gui-actionbutton_p.h" + +namespace PolkitTQt1 +{ + +namespace Gui +{ + +ActionButton::ActionButton(TQAbstractButton *button, const TQString &actionId, TQObject *parent) + : Action(actionId, parent) + , d_ptr(new ActionButtonPrivate(TQList() << button)) +{ + d_ptr->q_ptr = this; + + setButton(button); + connect(this, SIGNAL(dataChanged()), SLOT(updateButton())); +} + +ActionButton::ActionButton(ActionButtonPrivate &dd, const TQString &actionId, TQObject *parent) + : Action(actionId, parent) + , d_ptr(&dd) +{ + d_ptr->q_ptr = this; + + connect(this, SIGNAL(dataChanged()), SLOT(updateButton())); +} + +ActionButton::~ActionButton() +{ + delete d_ptr; +} + +void ActionButtonPrivate::updateButton() +{ + TQ_Q(ActionButton); + + TQ_FOREACH(TQAbstractButton *ent, buttons) { + ent->setVisible(q->isVisible()); + ent->setEnabled(q->isEnabled()); + ent->setText(q->text()); + if (!q->toolTip().isNull()) { + ent->setToolTip(q->toolTip()); + } + if (!q->whatsThis().isNull()) { + ent->setWhatsThis(q->whatsThis()); + } + ent->setIcon(q->icon()); + // if the item cannot do the action anymore + // lets revert to the initial state + if (ent->isCheckable()) { + ent->setChecked(q->isChecked()); + } + } +} + +bool ActionButton::activate() +{ + TQ_D(ActionButton); + + bool tg = false; + TQ_FOREACH(TQAbstractButton *ent, d->buttons) { + if (ent->isCheckable()) { + // we set the the current Action state + ent->setChecked(isChecked()); + // toggle the action cause we are not directly connected there.. + tg = true; + } + } + + if (tg) { + toggle(); + } + + return Action::activate(); +} + +void ActionButton::setButton(TQAbstractButton *button) +{ + TQ_D(ActionButton); + + // First, let's clear the list + TQ_FOREACH(TQAbstractButton *ent, d->buttons) { + d->removeButton(ent); + } + + // And then add it + d->addButton(button); +} + +void ActionButtonPrivate::addButton(TQAbstractButton *button) +{ + TQ_Q(ActionButton); + + buttons.append(button); + TQObject::connect(button, SIGNAL(clicked(bool)), q, SLOT(streamClicked(bool))); + TQObject::connect(q, SIGNAL(toggled(bool)), button, SLOT(toggle())); + if (q->isCheckable()) { + // the button should follow our first buttons + button->setCheckable(true); + } else if (button->isCheckable()) { + // if we are not checkable BUT the button + // is (eg a TQCheckBox) we should set all buttons to + // checkable. + TQ_FOREACH(TQAbstractButton *ent, buttons) { + ent->setCheckable(true); + } + // set the checkable state of Action to store the initial state + q->setCheckable(true); + } + // call this after m_activateOnCheck receives the value + updateButton(); +} + +void ActionButtonPrivate::removeButton(TQAbstractButton *button) +{ + TQ_Q(ActionButton); + + if (buttons.contains(button)) { + TQObject::disconnect(button, SIGNAL(clicked(bool)), q, SLOT(streamClicked(bool))); + TQObject::disconnect(q, SIGNAL(toggled(bool)), button, SLOT(toggle())); + buttons.removeOne(button); + } +} + +TQAbstractButton *ActionButton::button() const +{ + TQ_D(const ActionButton); + + return d->buttons.first(); +} + +void ActionButtonPrivate::streamClicked(bool c) +{ + TQ_Q(ActionButton); + + TQ_EMIT q->clicked(qobject_cast(q->sender()), c); +} + +} + +} + +#include "polkittqt1-gui-actionbutton.moc" diff --git a/gui/polkittqt1-gui-actionbutton.h b/gui/polkittqt1-gui-actionbutton.h new file mode 100644 index 000000000..c47a9bcc0 --- /dev/null +++ b/gui/polkittqt1-gui-actionbutton.h @@ -0,0 +1,145 @@ +/* + * This file is part of the Polkit-tqt project + * Copyright (C) 2009 Daniel Nicoletti + * Copyright (C) 2009 Dario Freddi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef POLKITTQT1_GUI_ACTIONBUTTON_H +#define POLKITTQT1_GUI_ACTIONBUTTON_H + +#include "polkittqt1-export.h" +#include "polkittqt1-gui-action.h" + +class TQAbstractButton; + +namespace PolkitTQt1 +{ + +namespace Gui +{ + +class ActionButtonPrivate; +/** + * \class ActionButton polkittqt1-gui-actionbutton.h ActionButton + * \author Daniel Nicoletti + * \author Dario Freddi + * + * \brief Class used to hold and update a TQAbstractButton + * + * This class allows you to associate TQAbstractButtons + * (i.e. TQPushButton) to a PolicyKit Action. It will update the + * button properties according to the PolicyKit Action automatically. + * + * \note You should connect the activated() signal to receive + * a notification when the user clicked the button and gets + * permission to perform the given action. If you set 'noEnabled' + * to \c true it will be emitted when PolKitResult is NO. + */ +class POLKITTQT1_EXPORT ActionButton : public Action +{ + Q_OBJECT + TQ_DECLARE_PRIVATE(ActionButton) + TQ_DISABLE_COPY(ActionButton) + +public: + /** + * Constructs a new ActionButton. You need to pass this + * constructor an existing TQAbstractButton, whose properties + * will be modified according to the underlying Action + * object. As ActionButton inherits from Action, you can + * define your button's behavior right through this wrapper. + * + * \see Action + * + * \param button the TQAbstractButton to associate to this ActionButton + * \param actionId the action Id to create the underlying Action + * \param parent the parent object + */ + explicit ActionButton(TQAbstractButton *button, const TQString &actionId = TQString(), TQObject *parent = 0); + virtual ~ActionButton(); + + /** + * Sets the button associated to the underlying action. + * + * \note If you are calling this function, you're probably + * changing the button the action is referring to. If this + * is the case, please note that Polkit-TQt does not handle + * the previous button's memory, so you should take care of + * deleting it yourself (if needed). You can retrieve it by + * using button() + * + * \see button + * + * \param button the new button associated with the underlying action + */ + void setButton(TQAbstractButton *button); + + /** + * Returns the current button + * + * \return the button currently associated with the underlying action + */ + TQAbstractButton *button() const; + +public Q_SLOTS: + /** + * Connect clicked() signals to this slot. This should be + * manually done, as in some cases we might want + * to manually call this. Calling this will emit authorized(). + * + * \note This slot is reentrant which is likely to only be a problem + * if you are creating an interface to setup PolicyKit policies. + * \note If you have a checkbox, connect to its' clicked() signal + * to avoid an infinite loop as this function internally calls setChecked(). + * You can always use the clicked(bool) signal in this class to + * connect to here. + * \warning if you use this class take care to not call Action::activate + * otherwise your checkable buttons won't be properly updated. + */ + bool activate(); + +Q_SIGNALS: + /** + * Emitted when the abstract button clicked(bool) signal + * is emitted. This allows you to use qobject_cast(sender()) + * in a slot connected to this signal and call activate() on it. + * + * \note you will normally want to connect this signal + * to the activate slot. + * + * \param button the button that has been clicked + * \param checked the checked state, if applicable. Otherwise \c false + * + */ + void clicked(TQAbstractButton *button, bool checked = false); + +protected: + ActionButton(ActionButtonPrivate &dd, const TQString &actionId, TQObject *parent = 0); + + ActionButtonPrivate * const d_ptr; + +private: + Q_PRIVATE_SLOT(d_func(), void updateButton()) + Q_PRIVATE_SLOT(d_func(), void streamClicked(bool)) +}; + +} + +} + +#endif diff --git a/gui/polkittqt1-gui-actionbutton_p.h b/gui/polkittqt1-gui-actionbutton_p.h new file mode 100644 index 000000000..5d4154ef1 --- /dev/null +++ b/gui/polkittqt1-gui-actionbutton_p.h @@ -0,0 +1,50 @@ +/* + * This file is part of the Polkit-tqt project + * Copyright (C) 2009 Dario Freddi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef POLKITTQT1_GUI_ACTIONBUTTON_P_H +#define POLKITTQT1_GUI_ACTIONBUTTON_P_H + +#include + +#include +#include + +/** + * \internal + */ +class PolkitTQt1::Gui::ActionButtonPrivate +{ +public: + ActionButtonPrivate(const TQList &b) + : buttons(b) {} + virtual ~ActionButtonPrivate() {} + + void addButton(TQAbstractButton *button); + void removeButton(TQAbstractButton *button); + void updateButton(); + void streamClicked(bool); + + TQ_DECLARE_PUBLIC(ActionButton) + ActionButton *q_ptr; + + TQList buttons; +}; + +#endif /* ACTIONBUTTON_P_H */ diff --git a/gui/polkittqt1-gui-actionbuttons.cpp b/gui/polkittqt1-gui-actionbuttons.cpp new file mode 100644 index 000000000..4a3def78b --- /dev/null +++ b/gui/polkittqt1-gui-actionbuttons.cpp @@ -0,0 +1,73 @@ +/* + * This file is part of the Polkit-tqt project + * Copyright (C) 2009 Dario Freddi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "polkittqt1-gui-actionbuttons.h" + +#include "polkittqt1-gui-actionbuttons_p.h" + +namespace PolkitTQt1 +{ + +namespace Gui +{ + +ActionButtons::ActionButtons(const TQList &buttons, const TQString &actionId, TQObject *parent) + : ActionButton(*new ActionButtonsPrivate(buttons), actionId, parent) +{ + setButtons(buttons); +} + +ActionButtons::~ActionButtons() +{ +} + +void ActionButtons::setButtons(const TQList &buttons) +{ + TQ_FOREACH(TQAbstractButton *ent, buttons) { + addButton(ent); + } +} + +TQList ActionButtons::buttons() const +{ + TQ_D(const ActionButtons); + + return d->buttons; +} + +void ActionButtons::addButton(TQAbstractButton *button) +{ + TQ_D(ActionButtons); + + d->addButton(button); +} + +void ActionButtons::removeButton(TQAbstractButton *button) +{ + TQ_D(ActionButtons); + + d->removeButton(button); +} + +} + +} + +#include "polkittqt1-gui-actionbuttons.moc" diff --git a/gui/polkittqt1-gui-actionbuttons.h b/gui/polkittqt1-gui-actionbuttons.h new file mode 100644 index 000000000..753a5e5c4 --- /dev/null +++ b/gui/polkittqt1-gui-actionbuttons.h @@ -0,0 +1,114 @@ +/* + * This file is part of the Polkit-tqt project + * Copyright (C) 2009 Dario Freddi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef POLKITTQT1_GUI_ACTIONBUTTONS_H +#define POLKITTQT1_GUI_ACTIONBUTTONS_H + +#include "polkittqt1-gui-actionbutton.h" + +namespace PolkitTQt1 +{ + +namespace Gui +{ + +class ActionButtonsPrivate; +/** + * \class ActionButtons polkittqt1-gui-actionbuttons.h ActionButtons + * \author Dario Freddi + * + * \brief Class used to hold and update a list of TQAbstractButtons + * + * This class is a convenience wrapper around ActionButton that lets + * you associate an undefined number of TQAbstractButtons with a single + * action. Every button will be updated accordingly upon action's properties + * changes. + * + * \see ActionButton + */ +class ActionButtons : public ActionButton +{ + Q_OBJECT + TQ_DECLARE_PRIVATE(ActionButtons) + TQ_DISABLE_COPY(ActionButtons) + +public: + /** + * Constructs a new ActionButton. You need to pass this + * constructor an existing list of TQAbstractButtons, whose properties + * will be modified according to the underlying Action + * object. As ActionButtons inherits from Action, you can + * define your buttons' behavior right through this wrapper. + * + * \see Action + * + * \param buttons the TQAbstractButton to associate to this ActionButton + * \param actionId the action Id to create the underlying Action + * \param parent the parent object + */ + explicit ActionButtons(const TQList &buttons, const TQString &actionId = TQString(), TQObject *parent = 0); + virtual ~ActionButtons(); + + /** + * Sets a list of buttons associated to the underlying action. + * + * \note If you are calling this function, you're probably + * changing the buttons list the action is referring to. If this + * is the case, please note that Polkit-TQt does not handle + * the previous buttons' memory, so you should take care of + * deleting them yourself (if needed). You can retrieve it by + * using buttons() + * + * \see buttons + * + * \param buttons the new buttons associated with the underlying action + */ + void setButtons(const TQList &buttons); + + /** + * Returns the current buttons list + * + * \return the buttons currently associated with the underlying action + */ + TQList buttons() const; + + /** + * Adds a button to the current button list. The button's properties + * will be updated according to the action upon adding. + * + * \param button the button to add + */ + void addButton(TQAbstractButton *button); + + /** + * Removes a button from the current list. Please note that Polkit-TQt + * does not handle the removed button's memory, so you should take care of + * deleting it yourself (if needed). + * + * \param button the button to remove + */ + void removeButton(TQAbstractButton *button); +}; + +} + +} + +#endif diff --git a/gui/polkittqt1-gui-actionbuttons_p.h b/gui/polkittqt1-gui-actionbuttons_p.h new file mode 100644 index 000000000..433fb3a57 --- /dev/null +++ b/gui/polkittqt1-gui-actionbuttons_p.h @@ -0,0 +1,36 @@ +/* + * This file is part of the Polkit-tqt project + * Copyright (C) 2009 Dario Freddi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef POLKITTQT1_GUI_ACTIONBUTTONS_P_H +#define POLKITTQT1_GUI_ACTIONBUTTONS_P_H + +#include "polkittqt1-gui-actionbutton_p.h" + +/** + * \internal + */ +class PolkitTQt1::Gui::ActionButtonsPrivate : public ActionButtonPrivate +{ +public: + ActionButtonsPrivate(const TQList &b) + : ActionButtonPrivate(b) {} +}; + +#endif /* ACTIONBUTTONS_P_H */ diff --git a/includes/PolkitQt1/ActionDescription b/includes/PolkitQt1/ActionDescription deleted file mode 100644 index f6dff44c3..000000000 --- a/includes/PolkitQt1/ActionDescription +++ /dev/null @@ -1 +0,0 @@ -#include "../polkitqt1-actiondescription.h" diff --git a/includes/PolkitQt1/Agent/Listener b/includes/PolkitQt1/Agent/Listener deleted file mode 100644 index 3da871e04..000000000 --- a/includes/PolkitQt1/Agent/Listener +++ /dev/null @@ -1 +0,0 @@ -#include "../../polkitqt1-agent-listener.h" diff --git a/includes/PolkitQt1/Agent/Session b/includes/PolkitQt1/Agent/Session deleted file mode 100644 index 20eb9ffb8..000000000 --- a/includes/PolkitQt1/Agent/Session +++ /dev/null @@ -1 +0,0 @@ -#include "../../polkitqt1-agent-session.h" diff --git a/includes/PolkitQt1/Authority b/includes/PolkitQt1/Authority deleted file mode 100644 index 523b3c2c0..000000000 --- a/includes/PolkitQt1/Authority +++ /dev/null @@ -1 +0,0 @@ -#include "../polkitqt1-authority.h" diff --git a/includes/PolkitQt1/Details b/includes/PolkitQt1/Details deleted file mode 100644 index 27da49aa1..000000000 --- a/includes/PolkitQt1/Details +++ /dev/null @@ -1 +0,0 @@ -#include "../polkitqt1-details.h" diff --git a/includes/PolkitQt1/Gui/Action b/includes/PolkitQt1/Gui/Action deleted file mode 100644 index 210911de2..000000000 --- a/includes/PolkitQt1/Gui/Action +++ /dev/null @@ -1 +0,0 @@ -#include "../../polkitqt1-gui-action.h" diff --git a/includes/PolkitQt1/Gui/ActionButton b/includes/PolkitQt1/Gui/ActionButton deleted file mode 100644 index 2076f277e..000000000 --- a/includes/PolkitQt1/Gui/ActionButton +++ /dev/null @@ -1 +0,0 @@ -#include "../../polkitqt1-gui-actionbutton.h" diff --git a/includes/PolkitQt1/Gui/ActionButtons b/includes/PolkitQt1/Gui/ActionButtons deleted file mode 100644 index 555098f77..000000000 --- a/includes/PolkitQt1/Gui/ActionButtons +++ /dev/null @@ -1 +0,0 @@ -#include "../../polkitqt1-gui-actionbuttons.h" diff --git a/includes/PolkitQt1/Identity b/includes/PolkitQt1/Identity deleted file mode 100644 index 999f5ae88..000000000 --- a/includes/PolkitQt1/Identity +++ /dev/null @@ -1 +0,0 @@ -#include "../polkitqt1-identity.h" diff --git a/includes/PolkitQt1/Subject b/includes/PolkitQt1/Subject deleted file mode 100644 index 919a66f52..000000000 --- a/includes/PolkitQt1/Subject +++ /dev/null @@ -1 +0,0 @@ -#include "../polkitqt1-subject.h" diff --git a/includes/PolkitQt1/TemporaryAuthorization b/includes/PolkitQt1/TemporaryAuthorization deleted file mode 100644 index b676a19e5..000000000 --- a/includes/PolkitQt1/TemporaryAuthorization +++ /dev/null @@ -1 +0,0 @@ -#include "../polkitqt1-temporaryauthorization.h" diff --git a/includes/PolkitTQt1/ActionDescription b/includes/PolkitTQt1/ActionDescription new file mode 100644 index 000000000..5fe9e8e19 --- /dev/null +++ b/includes/PolkitTQt1/ActionDescription @@ -0,0 +1 @@ +#include "../polkittqt1-actiondescription.h" diff --git a/includes/PolkitTQt1/Agent/Listener b/includes/PolkitTQt1/Agent/Listener new file mode 100644 index 000000000..bb0ddc8b0 --- /dev/null +++ b/includes/PolkitTQt1/Agent/Listener @@ -0,0 +1 @@ +#include "../../polkittqt1-agent-listener.h" diff --git a/includes/PolkitTQt1/Agent/Session b/includes/PolkitTQt1/Agent/Session new file mode 100644 index 000000000..94601c8a5 --- /dev/null +++ b/includes/PolkitTQt1/Agent/Session @@ -0,0 +1 @@ +#include "../../polkittqt1-agent-session.h" diff --git a/includes/PolkitTQt1/Authority b/includes/PolkitTQt1/Authority new file mode 100644 index 000000000..de04f0e48 --- /dev/null +++ b/includes/PolkitTQt1/Authority @@ -0,0 +1 @@ +#include "../polkittqt1-authority.h" diff --git a/includes/PolkitTQt1/Details b/includes/PolkitTQt1/Details new file mode 100644 index 000000000..248de1843 --- /dev/null +++ b/includes/PolkitTQt1/Details @@ -0,0 +1 @@ +#include "../polkittqt1-details.h" diff --git a/includes/PolkitTQt1/Gui/Action b/includes/PolkitTQt1/Gui/Action new file mode 100644 index 000000000..4c711ca82 --- /dev/null +++ b/includes/PolkitTQt1/Gui/Action @@ -0,0 +1 @@ +#include "../../polkittqt1-gui-action.h" diff --git a/includes/PolkitTQt1/Gui/ActionButton b/includes/PolkitTQt1/Gui/ActionButton new file mode 100644 index 000000000..9e030b15d --- /dev/null +++ b/includes/PolkitTQt1/Gui/ActionButton @@ -0,0 +1 @@ +#include "../../polkittqt1-gui-actionbutton.h" diff --git a/includes/PolkitTQt1/Gui/ActionButtons b/includes/PolkitTQt1/Gui/ActionButtons new file mode 100644 index 000000000..0c4440999 --- /dev/null +++ b/includes/PolkitTQt1/Gui/ActionButtons @@ -0,0 +1 @@ +#include "../../polkittqt1-gui-actionbuttons.h" diff --git a/includes/PolkitTQt1/Identity b/includes/PolkitTQt1/Identity new file mode 100644 index 000000000..d5e7a30c2 --- /dev/null +++ b/includes/PolkitTQt1/Identity @@ -0,0 +1 @@ +#include "../polkittqt1-identity.h" diff --git a/includes/PolkitTQt1/Subject b/includes/PolkitTQt1/Subject new file mode 100644 index 000000000..701a04727 --- /dev/null +++ b/includes/PolkitTQt1/Subject @@ -0,0 +1 @@ +#include "../polkittqt1-subject.h" diff --git a/includes/PolkitTQt1/TemporaryAuthorization b/includes/PolkitTQt1/TemporaryAuthorization new file mode 100644 index 000000000..c8cd55082 --- /dev/null +++ b/includes/PolkitTQt1/TemporaryAuthorization @@ -0,0 +1 @@ +#include "../polkittqt1-temporaryauthorization.h" diff --git a/polkit-qt-1.pc.cmake b/polkit-qt-1.pc.cmake deleted file mode 100644 index 8daa5b193..000000000 --- a/polkit-qt-1.pc.cmake +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=@CMAKE_INSTALL_PREFIX@ -libdir=@LIB_INSTALL_DIR@ -includedir=@CMAKE_INSTALL_PREFIX@/include - -Name: polkit-qt-1 -Description: Convenience library for using polkit with a TQt-styled API -Version: @POLKITQT-1_VERSION_STRING@ -Requires: polkit-qt-core-1 polkit-qt-gui-1 polkit-qt-agent-1 -Libs: -L${libdir} -lpolkit-qt-core-1 -lpolkit-qt-gui-1 -lpolkit-qt-agent-1 -Cflags: -I${includedir} diff --git a/polkit-qt-agent-1.pc.cmake b/polkit-qt-agent-1.pc.cmake deleted file mode 100644 index 5e794b973..000000000 --- a/polkit-qt-agent-1.pc.cmake +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=@CMAKE_INSTALL_PREFIX@ -libdir=@LIB_INSTALL_DIR@ -includedir=@CMAKE_INSTALL_PREFIX@/include - -Name: polkit-qt-agent-1 -Description: Convenience library for using polkit Agent with a TQt-styled API -Version: @POLKITQT-1_VERSION_STRING@ -Requires: TQtCore TQtGui -Libs: -L${libdir} -lpolkit-qt-agent-1 -Cflags: -I${includedir} diff --git a/polkit-qt-core-1.pc.cmake b/polkit-qt-core-1.pc.cmake deleted file mode 100644 index de469b286..000000000 --- a/polkit-qt-core-1.pc.cmake +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=@CMAKE_INSTALL_PREFIX@ -libdir=@LIB_INSTALL_DIR@ -includedir=@CMAKE_INSTALL_PREFIX@/include - -Name: polkit-qt-core-1 -Description: Convenience library for using polkit with a TQt-styled API, non-GUI classes -Version: @POLKITQT-1_VERSION_STRING@ -Requires: TQtCore -Libs: -L${libdir} -lpolkit-qt-core-1 -Cflags: -I${includedir} diff --git a/polkit-qt-gui-1.pc.cmake b/polkit-qt-gui-1.pc.cmake deleted file mode 100644 index 60e0a3f73..000000000 --- a/polkit-qt-gui-1.pc.cmake +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=@CMAKE_INSTALL_PREFIX@ -libdir=@LIB_INSTALL_DIR@ -includedir=@CMAKE_INSTALL_PREFIX@/include - -Name: polkit-qt-gui-1 -Description: Convenience library for using polkit with a TQt-styled API, GUI classes -Version: @POLKITQT-1_VERSION_STRING@ -Requires: TQtCore TQtGui polkit-qt-core-1 -Libs: -L${libdir} -lpolkit-qt-gui-1 -Cflags: -I${includedir} diff --git a/polkit-tqt-1.pc.cmake b/polkit-tqt-1.pc.cmake new file mode 100644 index 000000000..550314a83 --- /dev/null +++ b/polkit-tqt-1.pc.cmake @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@LIB_INSTALL_DIR@ +includedir=@CMAKE_INSTALL_PREFIX@/include + +Name: polkit-tqt-1 +Description: Convenience library for using polkit with a TQt-styled API +Version: @POLKITTQT-1_VERSION_STRING@ +Requires: polkit-tqt-core-1 polkit-tqt-gui-1 polkit-tqt-agent-1 +Libs: -L${libdir} -lpolkit-tqt-core-1 -lpolkit-tqt-gui-1 -lpolkit-tqt-agent-1 +Cflags: -I${includedir} diff --git a/polkit-tqt-agent-1.pc.cmake b/polkit-tqt-agent-1.pc.cmake new file mode 100644 index 000000000..1a52eea85 --- /dev/null +++ b/polkit-tqt-agent-1.pc.cmake @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@LIB_INSTALL_DIR@ +includedir=@CMAKE_INSTALL_PREFIX@/include + +Name: polkit-tqt-agent-1 +Description: Convenience library for using polkit Agent with a TQt-styled API +Version: @POLKITTQT-1_VERSION_STRING@ +Requires: TQtCore TQtGui +Libs: -L${libdir} -lpolkit-tqt-agent-1 +Cflags: -I${includedir} diff --git a/polkit-tqt-core-1.pc.cmake b/polkit-tqt-core-1.pc.cmake new file mode 100644 index 000000000..e497a8016 --- /dev/null +++ b/polkit-tqt-core-1.pc.cmake @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@LIB_INSTALL_DIR@ +includedir=@CMAKE_INSTALL_PREFIX@/include + +Name: polkit-tqt-core-1 +Description: Convenience library for using polkit with a TQt-styled API, non-GUI classes +Version: @POLKITTQT-1_VERSION_STRING@ +Requires: TQtCore +Libs: -L${libdir} -lpolkit-tqt-core-1 +Cflags: -I${includedir} diff --git a/polkit-tqt-gui-1.pc.cmake b/polkit-tqt-gui-1.pc.cmake new file mode 100644 index 000000000..220eba3a8 --- /dev/null +++ b/polkit-tqt-gui-1.pc.cmake @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@LIB_INSTALL_DIR@ +includedir=@CMAKE_INSTALL_PREFIX@/include + +Name: polkit-tqt-gui-1 +Description: Convenience library for using polkit with a TQt-styled API, GUI classes +Version: @POLKITTQT-1_VERSION_STRING@ +Requires: TQtCore TQtGui polkit-tqt-core-1 +Libs: -L${libdir} -lpolkit-tqt-gui-1 +Cflags: -I${includedir} diff --git a/polkitqt1-export.h b/polkitqt1-export.h deleted file mode 100644 index 4885e827b..000000000 --- a/polkitqt1-export.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of the Polkit-qt project - * Copyright (C) 2009 Dario Freddi - * Copyright (C) 2007 David Faure - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef POLKITQT1_EXPORT_H -#define POLKITQT1_EXPORT_H - -/** \file polkitqt1-export.h - \brief Contains Macros for exporting symbols - - This file contains macros needed for exporting/importing symbols -*/ - -#include - -#ifndef POLKITQT1_EXPORT -# if defined(MAKE_POLKITQT1_LIB) -/* We are building this library */ -# define POLKITQT1_EXPORT Q_DECL_EXPORT -# else -/* We are using this library */ -# define POLKITQT1_EXPORT Q_DECL_IMPORT -# endif -#endif - -#endif /*POLKITQT1_EXPORT_H*/ - diff --git a/polkitqt1-version.h.cmake b/polkitqt1-version.h.cmake deleted file mode 100644 index eaab33071..000000000 --- a/polkitqt1-version.h.cmake +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2007 Sebastian Trueg - * Copyright (C) 2009 Dario Freddi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _POLKITQT1_VERSION_H_ -#define _POLKITQT1_VERSION_H_ - -#include "polkitqt1-export.h" - -/// @brief PolkitTQt-1 version as string at compile time. -#define POLKITQT1_VERSION_STRING "${POLKITQT-1_VERSION_STRING}" - -/// @brief The major PolkitTQt-1 version number at compile time -#define POLKITQT1_VERSION_MAJOR ${POLKITQT-1_VERSION_MAJOR} - -/// @brief The minor PolkitTQt-1 version number at compile time -#define POLKITQT1_VERSION_MINOR ${POLKITQT-1_VERSION_MINOR} - -/// @brief The PolkitTQt-1 patch version number at compile time -#define POLKITQT1_VERSION_PATCH ${POLKITQT-1_VERSION_PATCH} - -/** - * \brief Create a unique number from the major, minor and release number of a %PolkitTQt-1 version - * - * This function can be used for preprocessing. For version information at runtime - * use the version methods in the PolkitTQt-1 namespace. - */ -#define POLKITQT1_MAKE_VERSION( a,b,c ) (((a) << 16) | ((b) << 8) | (c)) - -/** - * \brief %PolkitTQt-1 Version as a unique number at compile time - * - * This macro calculates the %PolkitTQt-1 version into a number. It is mainly used - * through POLKITQT1_IS_VERSION in preprocessing. For version information at runtime - * use the version methods in the PolkitTQt-1 namespace. - */ -#define POLKITQT1_VERSION \ - POLKITQT1_MAKE_VERSION(POLKITQT1_VERSION_MAJOR,POLKITQT1_VERSION_MINOR,POLKITQT1_VERSION_PATCH) - -/** - * \brief Check if the %PolkitTQt-1 version matches a certain version or is higher - * - * This macro is typically used to compile conditionally a part of code: - * \code - * #if POLKITQT1_IS_VERSION(2,1) - * // Code for PolkitTQt-1 2.1 - * #else - * // Code for PolkitTQt-1 2.0 - * #endif - * \endcode - * - * For version information at runtime - * use the version methods in the PolkitTQt-1 namespace. - */ -#define POLKITQT1_IS_VERSION(a,b,c) ( POLKITQT1_VERSION >= POLKITQT1_MAKE_VERSION(a,b,c) ) - - -namespace PolkitTQt1 { - /** - * @brief Returns the major number of PolkitTQt-1's version, e.g. - * 1 for %PolkitTQt-1 1.0.2. - * @return the major version number at runtime. - */ - POLKITQT1_EXPORT unsigned int versionMajor(); - - /** - * @brief Returns the minor number of PolkitTQt-1's version, e.g. - * 0 for %PolkitTQt-1 1.0.2. - * @return the minor version number at runtime. - */ - POLKITQT1_EXPORT unsigned int versionMinor(); - - /** - * @brief Returns the patch number of PolkitTQt-1's version, e.g. - * 2 for %PolkitTQt-1 1.0.2. - * @return the release number at runtime. - */ - POLKITQT1_EXPORT unsigned int versionPatch(); - - /** - * @brief Returns the %PolkitTQt-1 version as string, e.g. "1.0.2". - * - * On contrary to the macro POLKITQT1_VERSION_STRING this function returns - * the version number of PolkitTQt-1 at runtime. - * @return the %PolkitTQt-1 version. You can keep the string forever - */ - POLKITQT1_EXPORT const char* versionString(); -} - -#endif diff --git a/polkittqt1-export.h b/polkittqt1-export.h new file mode 100644 index 000000000..0161cc66c --- /dev/null +++ b/polkittqt1-export.h @@ -0,0 +1,44 @@ +/* + * This file is part of the Polkit-tqt project + * Copyright (C) 2009 Dario Freddi + * Copyright (C) 2007 David Faure + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef POLKITTQT1_EXPORT_H +#define POLKITTQT1_EXPORT_H + +/** \file polkittqt1-export.h + \brief Contains Macros for exporting symbols + + This file contains macros needed for exporting/importing symbols +*/ + +#include + +#ifndef POLKITTQT1_EXPORT +# if defined(MAKE_POLKITTQT1_LIB) +/* We are building this library */ +# define POLKITTQT1_EXPORT Q_DECL_EXPORT +# else +/* We are using this library */ +# define POLKITTQT1_EXPORT Q_DECL_IMPORT +# endif +#endif + +#endif /*POLKITTQT1_EXPORT_H*/ + diff --git a/polkittqt1-version.h.cmake b/polkittqt1-version.h.cmake new file mode 100644 index 000000000..3fd1bb6cb --- /dev/null +++ b/polkittqt1-version.h.cmake @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2007 Sebastian Trueg + * Copyright (C) 2009 Dario Freddi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _POLKITTQT1_VERSION_H_ +#define _POLKITTQT1_VERSION_H_ + +#include "polkittqt1-export.h" + +/// @brief PolkitTQt-1 version as string at compile time. +#define POLKITTQT1_VERSION_STRING "${POLKITTQT-1_VERSION_STRING}" + +/// @brief The major PolkitTQt-1 version number at compile time +#define POLKITTQT1_VERSION_MAJOR ${POLKITTQT-1_VERSION_MAJOR} + +/// @brief The minor PolkitTQt-1 version number at compile time +#define POLKITTQT1_VERSION_MINOR ${POLKITTQT-1_VERSION_MINOR} + +/// @brief The PolkitTQt-1 patch version number at compile time +#define POLKITTQT1_VERSION_PATCH ${POLKITTQT-1_VERSION_PATCH} + +/** + * \brief Create a unique number from the major, minor and release number of a %PolkitTQt-1 version + * + * This function can be used for preprocessing. For version information at runtime + * use the version methods in the PolkitTQt-1 namespace. + */ +#define POLKITTQT1_MAKE_VERSION( a,b,c ) (((a) << 16) | ((b) << 8) | (c)) + +/** + * \brief %PolkitTQt-1 Version as a unique number at compile time + * + * This macro calculates the %PolkitTQt-1 version into a number. It is mainly used + * through POLKITTQT1_IS_VERSION in preprocessing. For version information at runtime + * use the version methods in the PolkitTQt-1 namespace. + */ +#define POLKITTQT1_VERSION \ + POLKITTQT1_MAKE_VERSION(POLKITTQT1_VERSION_MAJOR,POLKITTQT1_VERSION_MINOR,POLKITTQT1_VERSION_PATCH) + +/** + * \brief Check if the %PolkitTQt-1 version matches a certain version or is higher + * + * This macro is typically used to compile conditionally a part of code: + * \code + * #if POLKITTQT1_IS_VERSION(2,1) + * // Code for PolkitTQt-1 2.1 + * #else + * // Code for PolkitTQt-1 2.0 + * #endif + * \endcode + * + * For version information at runtime + * use the version methods in the PolkitTQt-1 namespace. + */ +#define POLKITTQT1_IS_VERSION(a,b,c) ( POLKITTQT1_VERSION >= POLKITTQT1_MAKE_VERSION(a,b,c) ) + + +namespace PolkitTQt1 { + /** + * @brief Returns the major number of PolkitTQt-1's version, e.g. + * 1 for %PolkitTQt-1 1.0.2. + * @return the major version number at runtime. + */ + POLKITTQT1_EXPORT unsigned int versionMajor(); + + /** + * @brief Returns the minor number of PolkitTQt-1's version, e.g. + * 0 for %PolkitTQt-1 1.0.2. + * @return the minor version number at runtime. + */ + POLKITTQT1_EXPORT unsigned int versionMinor(); + + /** + * @brief Returns the patch number of PolkitTQt-1's version, e.g. + * 2 for %PolkitTQt-1 1.0.2. + * @return the release number at runtime. + */ + POLKITTQT1_EXPORT unsigned int versionPatch(); + + /** + * @brief Returns the %PolkitTQt-1 version as string, e.g. "1.0.2". + * + * On contrary to the macro POLKITTQT1_VERSION_STRING this function returns + * the version number of PolkitTQt-1 at runtime. + * @return the %PolkitTQt-1 version. You can keep the string forever + */ + POLKITTQT1_EXPORT const char* versionString(); +} + +#endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7e7c9fd1f..f862c0b14 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,15 +6,15 @@ include_directories( ${CMAKE_SOURCE_DIR}/agent ) -automoc4_add_executable(polkit-qt-test +automoc4_add_executable(polkit-tqt-test test.cpp ) -target_link_libraries(polkit-qt-test - ${QT_QTCORE_LIBRARY} - ${QT_QTTEST_LIBRARY} - ${QT_QTGUI_LIBRARY} - polkit-qt-core-1 +target_link_libraries(polkit-tqt-test + ${TQT_TQTCORE_LIBRARY} + ${TQT_TQTTEST_LIBRARY} + ${TQT_TQTGUI_LIBRARY} + polkit-tqt-core-1 ) -add_test(BaseTest ${CMAKE_CURRENT_BINARY_DIR}/polkit-qt-test) +add_test(BaseTest ${CMAKE_CURRENT_BINARY_DIR}/polkit-tqt-test) diff --git a/test/test.cpp b/test/test.cpp index 6112dc4f5..e2358f4e6 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -1,9 +1,9 @@ #include "test.h" -#include "core/polkitqt1-authority.h" -#include "agent/polkitqt1-agent-session.h" -#include "core/polkitqt1-details.h" +#include "core/polkittqt1-authority.h" +#include "agent/polkittqt1-agent-session.h" +#include "core/polkittqt1-details.h" #include #include #include @@ -22,25 +22,25 @@ void wait() void TestAuth::test_Auth_checkAuthorization() { - // This needs the file org.qt.policykit.examples.policy from examples to be installed + // This needs the file org.tqt.policykit.examples.policy from examples to be installed UnixProcessSubject process(TQCoreApplication::applicationPid()); Authority::Result result; // Check if this method returns good authorization results Authority *authority = Authority::instance(); - result = authority->checkAuthorizationSync("org.qt.policykit.examples.kick", process, Authority::None); + result = authority->checkAuthorizationSync("org.tqt.policykit.examples.kick", process, Authority::None); TQCOMPARE(result, Authority::No); TQVERIFY(!authority->hasError()); - result = authority->checkAuthorizationSync("org.qt.policykit.examples.cry", process, Authority::None); + result = authority->checkAuthorizationSync("org.tqt.policykit.examples.cry", process, Authority::None); TQCOMPARE(result, Authority::Yes); TQVERIFY(!authority->hasError()); - result = authority->checkAuthorizationSync("org.qt.policykit.examples.bleed", process, Authority::None); + result = authority->checkAuthorizationSync("org.tqt.policykit.examples.bleed", process, Authority::None); TQCOMPARE(result, Authority::Challenge); TQVERIFY(!authority->hasError()); // Now we try async methods TQSignalSpy spy(authority, SIGNAL(checkAuthorizationFinished(PolkitTQt1::Authority::Result))); // Call asynchronous checkAuthorization - authority->checkAuthorization("org.qt.policykit.examples.kick", process, Authority::None); + authority->checkAuthorization("org.tqt.policykit.examples.kick", process, Authority::None); // Give the polkit time to obtain the result and emit the signal with it wait(); // Test if the signal was emitted @@ -52,14 +52,14 @@ void TestAuth::test_Auth_checkAuthorization() spy.clear(); // Let's test the cancellability - authority->checkAuthorization("org.qt.policykit.examples.kick", process, Authority::None); + authority->checkAuthorization("org.tqt.policykit.examples.kick", process, Authority::None); authority->checkAuthorizationCancel(); // Wait and check if the signal arrieved wait(); TQCOMPARE(spy.count(), 0); // Check if it can cancel user authentication dialog - authority->checkAuthorization("org.qt.policykit.examples.bleed", process, Authority::AllowUserInteraction); + authority->checkAuthorization("org.tqt.policykit.examples.bleed", process, Authority::AllowUserInteraction); // Show it for second sleep(1); // And now kill it @@ -71,15 +71,15 @@ void TestAuth::test_Auth_checkAuthorization() void TestAuth::test_Auth_enumerateActions() { - // This needs the file org.qt.policykit.examples.policy from examples to be installed + // This needs the file org.tqt.policykit.examples.policy from examples to be installed ActionDescription::List list = Authority::instance()->enumerateActionsSync(); TQVERIFY(!Authority::instance()->hasError()); // Check whether enumerateAction returns at least example actions int count = 0; Q_FOREACH(const ActionDescription &ad, list) { - if ((ad.actionId() == "org.qt.policykit.examples.kick") || - (ad.actionId() == "org.qt.policykit.examples.cry") || - (ad.actionId() == "org.qt.policykit.examples.bleed")) + if ((ad.actionId() == "org.tqt.policykit.examples.kick") || + (ad.actionId() == "org.tqt.policykit.examples.cry") || + (ad.actionId() == "org.tqt.policykit.examples.bleed")) count++; } TQCOMPARE(count, 3); @@ -95,9 +95,9 @@ void TestAuth::test_Auth_enumerateActions() list = qVariantValue (spy.takeFirst()[0]); TQVERIFY(!Authority::instance()->hasError()); Q_FOREACH(const ActionDescription &ad, list) { - if ((ad.actionId() == "org.qt.policykit.examples.kick") || - (ad.actionId() == "org.qt.policykit.examples.cry") || - (ad.actionId() == "org.qt.policykit.examples.bleed")) + if ((ad.actionId() == "org.tqt.policykit.examples.kick") || + (ad.actionId() == "org.tqt.policykit.examples.cry") || + (ad.actionId() == "org.tqt.policykit.examples.bleed")) count++; } TQCOMPARE(count, 3); @@ -176,7 +176,7 @@ void TestAuth::test_Authority() void TestAuth::test_Subject() { // Get pid of this appication - qint64 pid = TQCoreApplication::applicationPid(); + tqint64 pid = TQCoreApplication::applicationPid(); // Create unix process for it UnixProcessSubject *process = new UnixProcessSubject(pid); // Test if pid doesn't differ @@ -205,7 +205,7 @@ void TestAuth::test_Session() TQCOMPARE(spy_completed.count(), 1); //UnixProcess *process = new UnixProcess(TQCoreApplication::applicationPid()); - //Authority::instance()->checkAuthorization("org.qt.policykit.examples.kick", process, Authority::None); + //Authority::instance()->checkAuthorization("org.tqt.policykit.examples.kick", process, Authority::None); tqDebug() << "COMPLETED:" << spy_completed.count(); tqDebug() << "REQUEST:" << spy_request.count(); -- cgit v1.2.1