summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2021-12-06 00:02:47 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2021-12-08 19:24:33 +0900
commit7d1585c071206dd8460ed624eff764de5464dde7 (patch)
tree6e3a6fa7a9e1eb1d5dd510a6d4ae0e39bd915cb1
parent26fc60d30352bb3bbf00f8a392bbc695ff8cf29f (diff)
downloadpolkit-tqt-7d1585c0.tar.gz
polkit-tqt-7d1585c0.zip
Converted first part of examples code.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r--CMakeLists.txt58
-rw-r--r--ConfigureChecks.cmake6
-rw-r--r--debian/control27
-rw-r--r--debian/libpolkit-tqt-examples.install8
-rwxr-xr-xdebian/rules3
-rw-r--r--examples/CMakeLists.txt132
-rw-r--r--examples/COPYING14
-rw-r--r--examples/PkExample.cpp520
-rw-r--r--examples/PkExample.h54
-rw-r--r--examples/PkExample.ui234
-rw-r--r--examples/PkExampleHelper.cpp179
-rw-r--r--examples/PkExampleHelper.h22
-rw-r--r--examples/icons/CMakeLists.txt16
-rw-r--r--examples/icons/icons.qrc9
-rw-r--r--examples/main.cpp11
-rw-r--r--examples/mainHelper.cpp5
-rw-r--r--examples/org.tqt.policykit.examples.policy.in85
-rw-r--r--examples/org.tqt.policykit.examples.service.cmake (renamed from examples/org.tqt.policykit.examples.service.in)2
-rw-r--r--gui/polkit-tqt-gui-action.h4
-rw-r--r--gui/polkit-tqt-gui-actionbutton.cpp17
-rw-r--r--gui/polkit-tqt-gui-actionbutton.h2
21 files changed, 661 insertions, 747 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fc3526b0f..aebddb2fe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -36,6 +36,13 @@ option( WITH_ALL_OPTIONS "Enable all optional support" OFF )
option( WITH_GCC_VISIBILITY "Enable fvisibility and fvisibility-inlines-hidden" ${WITH_ALL_OPTIONS} )
+##### user requested modules
+
+option( BUILD_ALL "Build all" OFF )
+option( BUILD_EXAMPLES "Build examples" ${BUILD_ALL} )
+option( BUILD_TESTS "Builds unit tests" ${BUILD_ALL} )
+
+
##### configure checks ##########################
include( ConfigureChecks.cmake )
@@ -48,6 +55,8 @@ tde_setup_install_path( BIN_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/bin" )
tde_setup_install_path( LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX}" )
tde_setup_install_path( INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/${CMAKE_PROJECT_NAME}" )
tde_setup_install_path( PKGCONFIG_INSTALL_DIR "${LIB_INSTALL_DIR}/pkgconfig" )
+tde_setup_install_path( SHARE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share" )
+tde_setup_install_path( DATA_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/apps" )
##### write pkgconfig file ######################
@@ -80,10 +89,11 @@ add_definitions(
##### source directories ########################
-add_subdirectory(core)
-add_subdirectory(gui)
-add_subdirectory(agent)
-add_subdirectory(tests)
+add_subdirectory( core )
+add_subdirectory( gui )
+add_subdirectory( agent )
+tde_conditional_add_subdirectory( BUILD_EXAMPLES examples )
+tde_conditional_add_subdirectory( BUILD_TESTS tests )
##### install files #### ########################
@@ -125,23 +135,6 @@ install(
${INCLUDE_INSTALL_DIR} )
##
-## include (${TQT_USE_FILE})
-## include (InstallSettings)
-## include (MacroWriteBasicCMakeVersionFile)
-## include (CheckFunctionExists)
-##
-## include_directories(
-## ${CMAKE_CURRENT_BINARY_DIR}
-## ${POLKIT_AGENT_INCLUDE_DIR}
-## ${GLIB2_INCLUDE_DIR}
-## ${GOBJECT_INCLUDE_DIR}
-## ${GIO_INCLUDE_DIR}
-## ${CMAKE_CURRENT_SOURCE_DIR}
-## ${CMAKE_CURRENT_SOURCE_DIR}/core
-## ${CMAKE_CURRENT_SOURCE_DIR}/includes
-## ${TQT_TQTXML_INCLUDE_DIR}
-## )
-##
## 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 <package>Config.cmake files to lib/cmake/<package> instead of lib/<package>/cmake" TRUE)
## endif(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.6.2)
@@ -153,18 +146,6 @@ install(
##
## configure_file(polkittqt1-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/polkittqt1-version.h)
##
-## install(FILES
-##
-## agent/polkittqt1-agent-listener.h
-## agent/polkittqt1-agent-session.h
-##
-## ${CMAKE_CURRENT_BINARY_DIR}/polkittqt1-version.h
-## polkit-tqt-export.h
-##
-## DESTINATION
-## ${INCLUDE_INSTALL_DIR}/polkit-qt-1 )
-##
-##
## # CMake Config files
## configure_file(PolkitTQt-1Config.cmake.in "${CMAKE_BINARY_DIR}/PolkitTQt-1Config.cmake" @ONLY)
##
@@ -182,15 +163,4 @@ install(
## ${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)
-## add_subdirectory(examples)
-## endif (BUILD_EXAMPLES)
-##
-## add_subdirectory(cmake)
-##
-## option(BUILD_TEST "Builds unit tests for polkit-qt-1" OFF)
-## if (BUILD_TEST)
-## add_subdirectory(test)
-## endif (BUILD_TEST)
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 0d7047c52..16ee5caad 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -34,6 +34,12 @@ if( NOT POLKIT_AGENT_FOUND )
tde_message_fatal( "polkit-agent-1 is required, but was not found on your system" )
endif( )
+# check for dbus-1-tqt
+pkg_search_module( DBUS_TQT dbus-1-tqt )
+if( NOT DBUS_TQT_FOUND )
+ tde_message_fatal( "dbus-1-tqt is required, but was not found on your system" )
+endif( )
+
# gcc visibility
if( WITH_GCC_VISIBILITY )
tde_setup_gcc_visibility( )
diff --git a/debian/control b/debian/control
index 84f37b250..7cfeca4df 100644
--- a/debian/control
+++ b/debian/control
@@ -4,22 +4,20 @@ Priority: optional
Maintainer: TDE Debian Team <team-debian@trinitydesktop.org>
XSBC-Original-Maintainer: Debian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>
Build-Depends: cdbs, debhelper (>= 9~), quilt, cmake-trinity, ninja-build, libtqtinterface-dev,
- libpolkit-gobject-1-dev, libpolkit-agent-1-dev
+ libpolkit-gobject-1-dev, libpolkit-agent-1-dev, libdbus-1-tqt-dev
Standards-Version: 3.9.2
Package: libpolkit-tqt-dev
Section: libdevel
Architecture: any
Depends: libpolkit-tqt (= ${binary:Version}), libtqtinterface-dev
-#, libdbus-1-dev (>= 0.90)
-#, libqt4-dev, ${misc:Depends}
+Suggests: libpolkit-tqt-examples
Description: PolicyKit-tqt development files
PolicyKit is an application-level toolkit for defining and handling the policy
that allows unprivileged processes to speak to privileged processes.
.
It is a framework for centralizing the decision making process with respect to
- granting access to privileged operations (like calling the HAL Mount() method)
- for unprivileged (desktop) applications.
+ granting access to privileged operations for unprivileged (desktop) applications.
.
libpolkit-tqt provides convenience classes and methods for TQt/TDE
applications that want to use PolicyKit.
@@ -35,8 +33,7 @@ Description: PolicyKit-tqt library
that allows unprivileged processes to speak to privileged processes.
.
It is a framework for centralizing the decision making process with respect to
- granting access to privileged operations (like calling the HAL Mount() method)
- for unprivileged (desktop) applications.
+ granting access to privileged operations for unprivileged (desktop) applications.
.
libpolkit-tqt provides convenience classes and methods for TQt/TDE
applications that want to use PolicyKit.
@@ -44,3 +41,19 @@ Description: PolicyKit-tqt library
This package contains the files necessary for running applications that use
the libpolkit-tqt library.
+Package: libpolkit-tqt-examples
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, policykit-1
+Description: PolicyKit-tqt library example files
+ PolicyKit is an application-level toolkit for defining and handling the policy
+ that allows unprivileged processes to speak to privileged processes.
+ .
+ It is a framework for centralizing the decision making process with respect to
+ granting access to privileged operations for unprivileged (desktop) applications.
+ .
+ libpolkit-tqt provides convenience classes and methods for TQt/TDE
+ applications that want to use PolicyKit.
+ .
+ This package contains example files and applications.
+
diff --git a/debian/libpolkit-tqt-examples.install b/debian/libpolkit-tqt-examples.install
new file mode 100644
index 000000000..7486b823c
--- /dev/null
+++ b/debian/libpolkit-tqt-examples.install
@@ -0,0 +1,8 @@
+debian/tmp/etc/dbus-1/system.d/org.tqt.policykit.examples.conf
+debian/tmp/usr/bin/polkit-tqt-example
+debian/tmp/usr/bin/polkit-tqt-example-helper
+debian/tmp/usr/share/apps/polkit-tqt/examples/*
+debian/tmp/usr/share/apps/polkit-tqt/icons/*
+debian/tmp/usr/share/dbus-1/system-services/org.tqt.policykit.examples.service
+debian/tmp/usr/share/polkit-1/actions/org.tqt.policykit.examples.policy
+
diff --git a/debian/rules b/debian/rules
index e06abc709..f1ab72756 100755
--- a/debian/rules
+++ b/debian/rules
@@ -10,7 +10,8 @@ DEB_CMAKE_EXTRA_FLAGS := \
-DCMAKE_SKIP_RPATH="OFF" \
-DCMAKE_VERBOSE_MAKEFILE="ON" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
- -DWITH_ALL_OPTIONS="ON"
+ -DWITH_ALL_OPTIONS="ON" \
+ -DBUILD_ALL="ON"
DEB_MAKE_CHECK_TARGET = check
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index f6af3fa10..d3b3a8407 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,89 +1,99 @@
+#################################################
+#
+# (C) 2021 Michele Calgaro
+# Michele (DOT) Calgaro (AT) yahoo.it
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
-install(FILES org.qt.policykit.examples.policy DESTINATION ${SHARE_INSTALL_PREFIX}/polkit-1/actions/)
include_directories(
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}
- ${CMAKE_SOURCE_DIR}/gui
+ ${CMAKE_SOURCE_DIR}
+ ${CMAKE_SOURCE_DIR}/core
+ ${CMAKE_SOURCE_DIR}/gui
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${TQT_INCLUDE_DIRS}
+ ${DBUS_TQT_INCLUDE_DIRS}
)
-set(polkit_example_SRCS
- main.cpp
- PkExample.cpp
+link_directories(
+ ${TQT_LIBRARY_DIRS}
)
-SET(polkit_example_RESOUCES
- icons/icons.qrc
-)
-QT4_WRAP_CPP(polkit_example_MOC_SRCS
- PkExample.h
-)
+##### install paths setup #######################
-QT4_WRAP_UI(polkit_example_UI_SRCS
- PkExample.ui
-)
+tde_setup_dbus( dbus-1-tqt )
+
+set( POLKIT_TQT_EXAMPLE "${DATA_INSTALL_DIR}/polkit-tqt/examples/" )
-QT4_ADD_RESOURCES (qtsourceview_RC_SRCS ${polkit_example_RESOUCES})
+##### install examples runtime config ###########################
-add_executable(polkit-example
- ${polkit_example_SRCS}
- ${polkit_example_MOC_SRCS}
- ${polkit_example_UI_SRCS}
- ${qtsourceview_RC_SRCS}
+configure_file( org.tqt.policykit.examples.service.cmake org.tqt.policykit.examples.service @ONLY )
+
+install(
+ FILES org.tqt.policykit.examples.policy
+ DESTINATION ${SHARE_INSTALL_PREFIX}/polkit-1/actions/
)
-target_link_libraries(polkit-example
- ${QT_QTCORE_LIBRARY}
- ${QT_QTGUI_LIBRARY}
- polkit-qt-gui-1
- polkit-qt-core-1
+install(
+ FILES org.tqt.policykit.examples.conf
+ DESTINATION ${DBUS_SYSTEM_CONF_DIRECTORY}
)
-#--------Helper Application
-
-# This macro is defined in FindPolkitQt.cmake
-macro(dbus_add_activation_system_service _sources)
- foreach (_i ${_sources})
- get_filename_component(_service_file ${_i} ABSOLUTE)
- string(REGEX REPLACE "\\.service.*$" ".service" _output_file ${_i})
- set(_target ${CMAKE_CURRENT_BINARY_DIR}/${_output_file})
- configure_file(${_service_file} ${_target})
- install(FILES ${_target} DESTINATION ${SHARE_INSTALL_PREFIX}/dbus-1/system-services )
- #install(FILES ${_target} DESTINATION ${_install_dir})
- endforeach (_i ${ARGN})
-endmacro(dbus_add_activation_system_service _sources)
-
-set(polkit_example_helper_SRCS
- PkExampleHelper.cpp
- mainHelper.cpp
+install(
+ FILES ${CMAKE_CURRENT_BINARY_DIR}/org.tqt.policykit.examples.service
+ DESTINATION ${DBUS_SERVICE_DIRECTORY}
)
-qt4_add_dbus_adaptor(polkit_example_helper_SRCS
- org.qt.policykit.examples.xml
- PkExampleHelper.h
- PkExampleHelper
+
+##### install examples source code ###########################
+
+install(
+ FILES COPYING
+ DESTINATION ${POLKIT_TQT_EXAMPLE}
)
-QT4_WRAP_CPP(polkit_example_helper_MOC_SRCS
- PkExampleHelper.h
+install(
+ FILES
+ org.tqt.policykit.examples.conf
+ org.tqt.policykit.examples.policy
+ org.tqt.policykit.examples.xml
+ ${CMAKE_CURRENT_BINARY_DIR}/org.tqt.policykit.examples.service
+ DESTINATION ${POLKIT_TQT_EXAMPLE}/config
)
-add_executable(polkit-example-helper
- ${polkit_example_helper_SRCS}
- ${polkit_example_helper_MOC_SRCS}
+install(
+ FILES PkExample.h PkExample.cpp main.cpp
+ DESTINATION ${POLKIT_TQT_EXAMPLE}/main
)
-# see our helper is pretty small :D
-target_link_libraries(polkit-example-helper
- ${QT_QTCORE_LIBRARY}
- polkit-qt-core-1
+install(
+ FILES PkExampleHelper.h PkExampleHelper.cpp mainHelper.cpp
+ DESTINATION ${POLKIT_TQT_EXAMPLE}/helper
)
-install(TARGETS polkit-example-helper DESTINATION ${BIN_INSTALL_DIR})
-dbus_add_activation_system_service(org.qt.policykit.examples.service.in)
+##### install icons ###########################
-install(FILES org.qt.policykit.examples.conf DESTINATION ${SYSCONF_INSTALL_DIR}/dbus-1/system.d)
+add_subdirectory( icons )
+
+
+##### example executables #########################
+
+tde_add_executable( polkit-tqt-example AUTOMOC
+ SOURCES PkExample.cpp main.cpp
+ LINK ${TQT_LIBRARIES} ${DBUS_TQT_LIBRARIES} polkit-tqt-core-shared polkit-tqt-gui-shared
+ DESTINATION ${BIN_INSTALL_DIR}
+)
+
+tde_add_executable( polkit-tqt-example-helper AUTOMOC
+ SOURCES PkExampleHelper.cpp mainHelper.cpp
+ LINK ${TQT_LIBRARIES} ${DBUS_TQT_LIBRARIES} polkit-tqt-core-shared
+ DESTINATION ${BIN_INSTALL_DIR}
+)
-add_subdirectory(agent)
diff --git a/examples/COPYING b/examples/COPYING
index d511905c1..94fb84639 100644
--- a/examples/COPYING
+++ b/examples/COPYING
@@ -1,12 +1,12 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
- Preamble
+ Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
@@ -56,7 +56,7 @@ patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
- GNU GENERAL PUBLIC LICENSE
+ GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
@@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
- NO WARRANTY
+ NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
@@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
- END OF TERMS AND CONDITIONS
+ END OF TERMS AND CONDITIONS
- How to Apply These Terms to Your New Programs
+ How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
diff --git a/examples/PkExample.cpp b/examples/PkExample.cpp
index 7366b4eaa..da2405ef5 100644
--- a/examples/PkExample.cpp
+++ b/examples/PkExample.cpp
@@ -21,220 +21,346 @@
#include "PkExample.h"
-#include "gui/polkitqt1-gui-actionbutton.h"
-#include "gui/polkitqt1-gui-actionbuttons.h"
-#include "core/polkitqt1-authority.h"
-#include <TQtCore/TQDebug>
+#include "gui/polkit-tqt-gui-actionbutton.h"
+#include "gui/polkit-tqt-gui-actionbuttons.h"
+#include "core/polkit-tqt-authority.h"
-#include <TQtDBus/TQDBusMessage>
-#include <TQtDBus/TQDBusConnection>
+#include <tqdbusconnection.h>
+#include <tqdbuserror.h>
+#include <tqdbusmessage.h>
+#include <tqdbusproxy.h>
+
+#include <tqvariant.h>
+#include <tqlabel.h>
+#include <tqpushbutton.h>
+#include <tqcombobox.h>
+#include <tqheader.h>
+#include <tqlistview.h>
+#include <tqlayout.h>
+#include <tqtooltip.h>
+#include <tqwhatsthis.h>
+#include <tqaction.h>
+#include <tqmenubar.h>
+#include <tqpopupmenu.h>
+#include <tqtoolbar.h>
using namespace PolkitTQt;
using namespace PolkitTQt::Gui;
-PkExample::PkExample(TQMainWindow *parent)
- : TQMainWindow(parent)
+
+PkExample::PkExample() : TQMainWindow(0, "Polkit tqt example application", WDestructiveClose)
{
- setupUi(this);
-
- ActionButton *bt;
-
- // Here we create an ActionButton that is a subclass of Action
- // always pass a TQButton pointer and action id
- // You can change the action id later if you want
- bt = new ActionButton(kickPB, "org.qt.policykit.examples.kick", this);
- // Here we are setting the text and icon to all four states
- // an action might have
- bt->setText("Kick!");
- bt->setIcon(TQPixmap(":/Icons/custom-no.png"));
- // By using set{Yes|No|Auth}Enabled you can set the states
- // when the button is enabled
- bt->setEnabled(true, Action::No);
- // As ActionButton is also an Action we cast it to add to menu
- menuActions->addAction(qobject_cast<Action *>(bt));
- toolBar->addAction(qobject_cast<Action *>(bt));
- // this signal is emitted when the user click on the action,
- // it will only happen if it was inserted in a TQMenu or a TQToolBar
- connect(bt, SIGNAL(triggered(bool)), this, SLOT(activateAction()));
- // This signal was propagated from the TQButton just for
- // convenience in this case we don't have any benefit but the code
- // look cleaner
- connect(bt, SIGNAL(clicked(TQButton *, bool)), bt, SLOT(activate()));
- // this is the Action activated signal, it is always emmited whenever
- // someone click and get authorized to do the action
- connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated()));
-
- bt = new ActionButton(cryPB, "org.qt.policykit.examples.cry", this);
- bt->setText("Cry!");
- bt->setIcon(TQPixmap(":/Icons/custom-yes.png"));
- menuActions->addAction(qobject_cast<Action *>(bt));
- toolBar->addAction(qobject_cast<Action *>(bt));
- connect(bt, SIGNAL(triggered(bool)), this, SLOT(activateAction()));
- connect(bt, SIGNAL(clicked(TQButton *, bool)), bt, SLOT(activate()));
- connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated()));
-
- bt = new ActionButton(bleedPB, "org.qt.policykit.examples.bleed", this);
- bt->setText("Bleed!");
- bt->setIcon(TQPixmap(":/Icons/action-locked-default.png"));
- menuActions->addAction(qobject_cast<Action *>(bt));
- toolBar->addAction(qobject_cast<Action *>(bt));
- connect(bt, SIGNAL(triggered(bool)), this, SLOT(activateAction()));
- connect(bt, SIGNAL(clicked(TQButton *, bool)), bt, SLOT(activate()));
- connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated()));
-
- // This action is more customized
- bt = new ActionButton(playPB, "org.qt.policykit.examples.play", this);
- bt->setText("Play!");
- bt->setVisible(true, Action::No | Action::Auth | Action::Yes);
- bt->setEnabled(true, Action::No | Action::Auth | Action::Yes);
- // here we set the behavior of PolKitResul = No
- bt->setText("Can't play!", 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->setText("Play?", 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->setText("Play!", Action::Yes);
- bt->setIcon(TQPixmap(":/Icons/custom-yes.png"), Action::Yes);
- bt->setToolTip("Go ahead, play!", Action::Yes);
-
- menuActions->addAction(qobject_cast<Action *>(bt));
- toolBar->addAction(qobject_cast<Action *>(bt));
- connect(bt, SIGNAL(triggered(bool)), this, SLOT(activateAction()));
- connect(bt, SIGNAL(clicked(TQButton *, bool)), bt, SLOT(activate()));
- connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated()));
-
- bt = new ActionButton(deletePB, "org.qt.policykit.examples.delete", this);
- bt->setText("Delete!");
- bt->setIcon(TQPixmap(":/Icons/custom-no.png"), Action::No);
- bt->setIcon(TQPixmap(":/Icons/action-locked-default.png"), Action::Auth);
- bt->setIcon(TQPixmap(":/Icons/custom-yes.png"), Action::Yes);
- menuActions->addAction(qobject_cast<Action *>(bt));
- toolBar->addAction(qobject_cast<Action *>(bt));
- connect(bt, SIGNAL(triggered(bool)), this, SLOT(activateAction()));
- connect(bt, SIGNAL(clicked(TQButton *, bool)), bt, SLOT(activate()));
- connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated()));
-
- bt = new ActionButton(listenPB, "org.qt.policykit.examples.listen", this);
- bt->setText("Listen!");
- bt->setIcon(TQPixmap(":/Icons/custom-no.png"), Action::No);
- bt->setIcon(TQPixmap(":/Icons/action-locked-default.png"), Action::Auth);
- bt->setIcon(TQPixmap(":/Icons/custom-yes.png"), Action::Yes);
- menuActions->addAction(qobject_cast<Action *>(bt));
- toolBar->addAction(qobject_cast<Action *>(bt));
- connect(bt, SIGNAL(triggered(bool)), this, SLOT(activateAction()));
- connect(bt, SIGNAL(clicked(TQButton *, bool)), bt, SLOT(activate()));
- connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated()));
-
- bt = new ActionButton(setPB, "org.qt.policykit.examples.set", this);
- bt->setText("Set!");
- bt->setIcon(TQPixmap(":/Icons/custom-no.png"), Action::No);
- bt->setIcon(TQPixmap(":/Icons/action-locked-default.png"), Action::Auth);
- bt->setIcon(TQPixmap(":/Icons/custom-yes.png"), Action::Yes);
- menuActions->addAction(qobject_cast<Action *>(bt));
- toolBar->addAction(qobject_cast<Action *>(bt));
- connect(bt, SIGNAL(triggered(bool)), this, SLOT(activateAction()));
- connect(bt, SIGNAL(clicked(TQButton *, bool)), bt, SLOT(activate()));
- connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated()));
-
- bt = new ActionButton(shoutPB, "org.qt.policykit.examples.shout", this);
- bt->setIcon(TQPixmap(":/Icons/custom-no.png"), Action::No);
- bt->setIcon(TQPixmap(":/Icons/action-locked-default.png"), Action::Auth);
- bt->setIcon(TQPixmap(":/Icons/custom-yes.png"), Action::Yes);
- bt->setText("Can't shout!", Action::No);
- bt->setText("Shout?", Action::Auth);
- bt->setText("Shout!", Action::Yes);
- menuActions->addAction(qobject_cast<Action *>(bt));
- toolBar->addAction(qobject_cast<Action *>(bt));
- connect(bt, SIGNAL(triggered(bool)), this, SLOT(activateAction()));
- connect(bt, SIGNAL(clicked(TQButton *, bool)), bt, SLOT(activate()));
- connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated()));
-
- // test configChanged
+ TQWidget *privateLayoutWidget = new TQWidget(this, "qt_central_widget");
+ setCentralWidget(privateLayoutWidget);
+
+ grid = new TQGridLayout(0, 9, 1, 0, 6, "grid");
+ grid->setColSpacing(0, 700);
+ grid->setColSpacing(1, 200);
+
+ kickL = new TQLabel(privateLayoutWidget, "kickL");
+ kickPB = new TQPushButton(privateLayoutWidget, "kickPB");
+ grid->addWidget(kickL, 0, 0);
+ grid->addWidget(kickPB, 0, 1);
+
+ cryL = new TQLabel(privateLayoutWidget, "cryL");
+ cryPB = new TQPushButton(privateLayoutWidget, "cryPB");
+ grid->addWidget(cryL, 1, 0);
+ grid->addWidget(cryPB, 1, 1);
+
+ bleedL = new TQLabel(privateLayoutWidget, "bleedL");
+ bleedPB = new TQPushButton(privateLayoutWidget, "bleedPB");
+ grid->addWidget(bleedL, 2, 0);
+ grid->addWidget(bleedPB, 2, 1);
+
+ playL = new TQLabel(privateLayoutWidget, "playL");
+ playPB = new TQPushButton(privateLayoutWidget, "playPB");
+ grid->addWidget(playL, 3, 0);
+ grid->addWidget(playPB, 3, 1);
+
+ listenL = new TQLabel(privateLayoutWidget, "listenL");
+ listenPB = new TQPushButton(privateLayoutWidget, "listenPB");
+ grid->addWidget(listenL, 4, 0);
+ grid->addWidget(listenPB, 4, 1);
+
+ deleteL = new TQLabel(privateLayoutWidget, "deleteL");
+ deletePB = new TQPushButton(privateLayoutWidget, "deletePB");
+ grid->addWidget(deleteL, 5, 0);
+ grid->addWidget(deletePB, 5, 1);
+
+ deleteL_2 = new TQLabel(privateLayoutWidget, "deleteL_2");
+ setCB = new TQComboBox(FALSE, privateLayoutWidget, "setCB");
+ grid->addMultiCellWidget(deleteL_2, 6, 7, 0, 0);
+ grid->addWidget(setCB, 6, 1);
+
+ setPB = new TQPushButton(privateLayoutWidget, "setPB");
+ deleteL_3 = new TQLabel(privateLayoutWidget, "deleteL_3");
+ grid->addWidget(setPB, 7, 1);
+ grid->addWidget(deleteL_3, 8, 0);
+
+ shoutPB = new TQPushButton(privateLayoutWidget, "shoutPB");
+ grid->addWidget(shoutPB, 8, 1);
+
+ vLayout = new TQVBoxLayout(privateLayoutWidget, 11, 6, "vLayout");
+ vLayout->addLayout(grid);
+
+ actionList = new TQListView(privateLayoutWidget);
+ actionList->addColumn("Action");
+ actionList->addColumn("Result");
+ actionList->setSorting(-1);
+
+ vLayout->addWidget(actionList);
+
+ // menubar
+ menubar = new TQMenuBar(this, "menubar");
+ menubar->setGeometry(TQRect(0, 0, 800, 22));
+ menuActions = new TQPopupMenu(this);
+ menubar->insertItem(TQString(""), menuActions, 2);
+
+ // toolbars
+ toolBar = new TQToolBar(TQString(""), this, DockTop);
+
+ // statusbar
+ statusBar();
+
+ languageChange();
+ resize(TQSize(900, 700).expandedTo(minimumSizeHint()));
+ clearWState(WState_Polished);
+
+ // Setup actions
+ ActionButton *bt;
+
+ // Here we create an ActionButton that is a subclass of Action
+ // always pass a TQButton pointer and action id
+ // You can change the action id later if you want
+ bt = new ActionButton(kickPB, "org.tqt.policykit.examples.kick", this);
+ // Here we are setting the text and icon to all four states
+ // an action might have
+ bt->setText("Kick!");
+ bt->setIconSet(TQPixmap("/usr/share/apps/polkit-tqt/icons/custom-no.png"));
+ // By using set{Yes|No|Auth}Enabled you can set the states
+ // when the button is enabled
+ bt->setEnabled(true, Action::No);
+ // As ActionButton is also an Action we cast it to add to menu
+ ::tqt_cast<TQAction*>(bt)->addTo(menuActions);
+ ::tqt_cast<TQAction*>(bt)->addTo(toolBar);
+ // this signal is emitted when the user click on the action,
+ // it will only happen if it was inserted in a TQMenu or a TQToolBar
+ connect(bt, SIGNAL(activated()), this, SLOT(activateAction()));
+ // This signal was propagated from the TQButton just for
+ // convenience in this case we don't have any benefit but the code
+ // look cleaner
+ connect(bt, SIGNAL(clicked(TQButton*, bool)), bt, SLOT(activate()));
+ // this is the Action activated signal, it is always emmited whenever
+ // someone click and get authorized to do the action
+ connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated()));
+
+ bt = new ActionButton(cryPB, "org.tqt.policykit.examples.cry", this);
+ bt->setText("Cry!");
+ bt->setIconSet(TQPixmap("/usr/share/apps/polkit-tqt/icons/custom-yes.png"));
+ ::tqt_cast<TQAction*>(bt)->addTo(menuActions);
+ ::tqt_cast<TQAction*>(bt)->addTo(toolBar);
+ connect(bt, SIGNAL(activated()), this, SLOT(activateAction()));
+ connect(bt, SIGNAL(clicked(TQButton*, bool)), bt, SLOT(activate()));
+ connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated()));
+
+ bt = new ActionButton(bleedPB, "org.tqt.policykit.examples.bleed", this);
+ bt->setText("Bleed!");
+ bt->setIconSet(TQPixmap("/usr/share/apps/polkit-tqt/icons/action-locked-default.png"));
+ ::tqt_cast<TQAction*>(bt)->addTo(menuActions);
+ ::tqt_cast<TQAction*>(bt)->addTo(toolBar);
+ connect(bt, SIGNAL(activated()), this, SLOT(activateAction()));
+ connect(bt, SIGNAL(clicked(TQButton*, bool)), bt, SLOT(activate()));
+ connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated()));
+
+ // This action is more customized
+ bt = new ActionButton(playPB, "org.tqt.policykit.examples.play", this);
+ bt->setText("Play!");
+ bt->setVisible(true, (Action::States)(Action::No | Action::Auth | Action::Yes));
+ bt->setEnabled(true, (Action::States)(Action::No | Action::Auth | Action::Yes));
+ // here we set the behavior of PolKitResul = No
+ bt->setText("Can't play!", Action::No);
+ bt->setIconSet(TQPixmap("/usr/share/apps/polkit-tqt/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->setText("Play?", Action::Auth);
+ bt->setIconSet(TQPixmap("/usr/share/apps/polkit-tqt/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->setText("Play!", Action::Yes);
+ bt->setIconSet(TQPixmap("/usr/share/apps/polkit-tqt/icons/custom-yes.png"), Action::Yes);
+ bt->setToolTip("Go ahead, play!", Action::Yes);
+ ::tqt_cast<TQAction*>(bt)->addTo(menuActions);
+ ::tqt_cast<TQAction*>(bt)->addTo(toolBar);
+ connect(bt, SIGNAL(activated()), this, SLOT(activateAction()));
+ connect(bt, SIGNAL(clicked(TQButton*, bool)), bt, SLOT(activate()));
+ connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated()));
+
+ bt = new ActionButton(listenPB, "org.tqt.policykit.examples.listen", this);
+ bt->setText("Listen!");
+ bt->setIconSet(TQPixmap("/usr/share/apps/polkit-tqt/icons/custom-no.png"), Action::No);
+ bt->setIconSet(TQPixmap("/usr/share/apps/polkit-tqt/icons/action-locked-default.png"), Action::Auth);
+ bt->setIconSet(TQPixmap("/usr/share/apps/polkit-tqt/icons/custom-yes.png"), Action::Yes);
+ ::tqt_cast<TQAction*>(bt)->addTo(menuActions);
+ ::tqt_cast<TQAction*>(bt)->addTo(toolBar);
+ connect(bt, SIGNAL(activated()), this, SLOT(activateAction()));
+ connect(bt, SIGNAL(clicked(TQButton*, bool)), bt, SLOT(activate()));
+ connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated()));
+
+ bt = new ActionButton(deletePB, "org.tqt.policykit.examples.delete", this);
+ bt->setText("Delete!");
+ bt->setIconSet(TQPixmap("/usr/share/apps/polkit-tqt/icons/custom-no.png"), Action::No);
+ bt->setIconSet(TQPixmap("/usr/share/apps/polkit-tqt/icons/action-locked-default.png"), Action::Auth);
+ bt->setIconSet(TQPixmap("/usr/share/apps/polkit-tqt/icons/custom-yes.png"), Action::Yes);
+ ::tqt_cast<TQAction*>(bt)->addTo(menuActions);
+ ::tqt_cast<TQAction*>(bt)->addTo(toolBar);
+ connect(bt, SIGNAL(activated()), this, SLOT(activateAction()));
+ connect(bt, SIGNAL(clicked(TQButton*, bool)), bt, SLOT(activate()));
+ connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated()));
+
+ bt = new ActionButton(setPB, "org.tqt.policykit.examples.set", this);
+ bt->setText("Set!");
+ bt->setIconSet(TQPixmap("/usr/share/apps/polkit-tqt/icons/custom-no.png"), Action::No);
+ bt->setIconSet(TQPixmap("/usr/share/apps/polkit-tqt/icons/action-locked-default.png"), Action::Auth);
+ bt->setIconSet(TQPixmap("/usr/share/apps/polkit-tqt/icons/custom-yes.png"), Action::Yes);
+ ::tqt_cast<TQAction*>(bt)->addTo(menuActions);
+ ::tqt_cast<TQAction*>(bt)->addTo(toolBar);
+ connect(bt, SIGNAL(activated()), this, SLOT(activateAction()));
+ connect(bt, SIGNAL(clicked(TQButton*, bool)), bt, SLOT(activate()));
+ connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated()));
+
+ bt = new ActionButton(shoutPB, "org.tqt.policykit.examples.shout", this);
+ bt->setIconSet(TQPixmap("/usr/share/apps/polkit-tqt/icons/custom-no.png"), Action::No);
+ bt->setIconSet(TQPixmap("/usr/share/apps/polkit-tqt/icons/action-locked-default.png"), Action::Auth);
+ bt->setIconSet(TQPixmap("/usr/share/apps/polkit-tqt/icons/custom-yes.png"), Action::Yes);
+ bt->setText("Can't shout!", Action::No);
+ bt->setText("Shout?", Action::Auth);
+ bt->setText("Shout!", Action::Yes);
+ ::tqt_cast<TQAction*>(bt)->addTo(menuActions);
+ ::tqt_cast<TQAction*>(bt)->addTo(toolBar);
+ connect(bt, SIGNAL(activated()), this, SLOT(activateAction()));
+ connect(bt, SIGNAL(clicked(TQButton*, bool)), bt, SLOT(activate()));
+ connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated()));
}
-PkExample::~PkExample()
+void PkExample::languageChange()
{
+ setCaption(tr("PolicyKit-tqt example"));
+ kickL->setText(tr("Making the helper <b>Kick</b> is not allowed. Action cannot be activated."));
+ kickPB->setText(tr("Kick!"));
+ cryL->setText(tr("Making the helper <b>Cry</b> is always allowed. Action can be activated without authentication."));
+ cryPB->setText(tr("Cry!"));
+ bleedL->setText(tr("Making the helper <b>Bleed</b> requires the user to authenticate. This is a one-shot authorization."));
+ bleedPB->setText(tr("Bleed!"));
+ playL->setText(tr("Making the helper <b>Play</b> requires a system administrator to authenticate. This is a one-shot authorization."));
+ playPB->setText(tr("Play!"));
+ listenL->setText(tr("Making the helper <b>Listen</b> requires the user to authenticate. The authorization will be kept for a brief period."));
+ listenPB->setText(tr("Listen!"));
+ deleteL->setText(tr("Making the helper <b>Delete</b> requires a system administrator to authenticate. The authorization will be kept for a brief period."));
+ deletePB->setText(tr("Delete!"));
+ deleteL_2->setText(tr("<b>Set</b> is special action. It sets the permissions for the <b>Shout</b> action by actually using the helper application to change the implicit authorization."));
+ setCB->clear();
+ setCB->insertItem(tr("no"));
+ setCB->insertItem(tr("yes"));
+ setCB->insertItem(tr("auth_self"));
+ setCB->insertItem(tr("auth_admin"));
+ setCB->insertItem(tr("auth_self_keep"));
+ setCB->insertItem(tr("auth_admin_keep"));
+ setPB->setText(tr("Set!"));
+ deleteL_3->setText(tr("The implicit authorization for the <b>Shout</b> action is set by the <b>Set</b> action. You can watch how different options can change behaviour of this action."));
+ shoutPB->setText(tr("Shout!"));
+ toolBar->setCaption(tr("toolBar"));
+ if (menubar->findItem(2))
+ {
+ menubar->findItem(2)->setText(tr("&Actions"));
+ }
}
void PkExample::activateAction()
{
- // Here we cast the sender() to an Action and call activate()
- // on it.
- // Be careful in doing the same for ActionButton won't work as expected
- // as action->activate() is calling Action::activate() and
- // not ActionButton::activate which are different.
- // You can cast then to ActionButton but be carefull
- // an Action casted to ActionButton may crash you app
- Action *action = qobject_cast<Action *>(sender());
- // calling activate with winId() makes the auth dialog
- // be correct parented with your application.
- action->activate();
+ // Here we cast the sender() to an Action and call activate() on it.
+ // Be careful in doing the same for ActionButton won't work as expected
+ // as action->activate() is calling Action::activate() and
+ // not ActionButton::activate which are different.
+ // You can cast then to ActionButton but be carefull
+ // an Action casted to ActionButton may crash you app
+ Action *action = ::tqt_cast<Action*>(sender());
+ // calling activate with winId() makes the auth dialog
+ // be correct parented with your application.
+ action->activate();
}
void PkExample::actionActivated()
{
- // This slot is called whenever an action is allowed
- // here you will do your dirt job by calling a helper application
- // that might erase your hardrive ;)
- Action *action = qobject_cast<Action *>(sender());
-
- // this is our Special Action that after allowed will call the helper
- if (action->is("org.qt.policykit.examples.set")) {
- tqDebug() << "toggled for: org.qt.policykit.examples.set";
-
- TQDBusMessage message;
- message = TQDBusMessage::createMethodCall("org.qt.policykit.examples",
- "/",
- "org.qt.policykit.examples",
- TQLatin1String("set"));
- TQList<TQVariant> argumentList;
- argumentList << qVariantFromValue(setCB->currentText());
- message.setArguments(argumentList);
- // notice the systemBus here..
- TQDBusMessage reply = TQDBusConnection::systemBus().call(message);
- if (reply.type() == TQDBusMessage::ReplyMessage
- && reply.arguments().size() == 1) {
- // the reply can be anything, here we receive a bool
- TQListWidgetItem *item;
- if (reply.arguments().first().toBool())
- item = new TQListWidgetItem(TQPixmap(":/Icons/custom-yes.png"),
- TQString("Implicit authorization for shout has been set to %0")
- .arg(setCB->currentText()));
- else
- item = new TQListWidgetItem(TQPixmap(":/Icons/custom-no.png"),
- TQString("Can't change the implicit authorization. Denied."));
- actionList->addItem(item);
- tqDebug() << reply.arguments().first().toString();
- } else if (reply.type() == TQDBusMessage::MethodCallMessage) {
- tqWarning() << "Message did not receive a reply (timeout by message bus)";
- }
- return;
- }
+ // This slot is called whenever an action is allowed
+ // here you will do your dirt job by calling a helper application
+ // that might erase your hardrive ;)
+ Action *action = ::tqt_cast<Action*>(sender());
- // As debug message says we are pretending to be the mechanism for the
- // following action, here you will actually call your DBus helper that
- // will run as root (setuid is not needed, see DBus docs).
- // In the helper application you will issue checkAuthorizationSync,
- // passing the action id and the caller pid (which DBus will tell you).
- tqDebug() << "pretending to be the mechanism for action:" << action->actionId();
-
- Authority::Result result;
- UnixProcessSubject subject(static_cast<uint>(TQCoreApplication::applicationPid()));
-
- result = Authority::instance()->checkAuthorizationSync(action->actionId(), subject,
- Authority::AllowUserInteraction);
- if (result == Authority::Yes) {
- // in the helper you will do the action
- tqDebug() << "caller is authorized to do:" << action->actionId();
- TQListWidgetItem *item = new TQListWidgetItem(TQPixmap(":/Icons/custom-yes.png"), action->actionId());
- actionList->addItem(item);
- } else {
- // OR return false to notify the caller that the action is not authorized.
- tqDebug() << "caller is NOT authorized to do:" << action->actionId();
- TQListWidgetItem *item = new TQListWidgetItem(TQIcon(":/Icons/custom-no.png"), action->actionId());
- actionList->addItem(item);
+ // this is our Special Action that after allowed will call the helper
+ if (action->is("org.tqt.policykit.examples.set"))
+ {
+ tqDebug("toggled for: org.tqt.policykit.examples.set");
+
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ TQT_DBusProxy exampleProxy("org.tqt.policykit.examples", "/", "org.tqt.policykit.examples", dbusConn);
+ TQT_DBusError error;
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromString(setCB->currentText());
+ TQT_DBusMessage reply = exampleProxy.sendWithReply("set", params, &error);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1)
+ {
+ // the reply can be anything, here we receive a bool
+ TQListViewItem *item;
+ if (reply[0].toBool())
+ {
+ item = new TQListViewItem(actionList);
+ item->setText(0, TQString("Implicit authorization for shout has been set to ") +
+ setCB->currentText());
+ item->setPixmap(1, TQPixmap("/usr/share/apps/polkit-tqt/icons/custom-yes.png"));
+ }
+ else
+ {
+ item = new TQListViewItem(actionList);
+ item->setText(0, TQString("Can't change the implicit authorization. Denied."));
+ item->setPixmap(1, TQPixmap("/usr/share/apps/icons/custom-no.png"));
+ }
+ actionList->insertItem(item);
+ }
+ else if (reply.type() == TQT_DBusMessage::MethodCallMessage)
+ {
+ tqDebug("Message did not receive a reply (timeout by message bus)");
}
+ return;
+ }
+
+ // As debug message says we are pretending to be the mechanism for the
+ // following action, here you will actually call your DBus helper that
+ // will run as root (setuid is not needed, see DBus docs).
+ // In the helper application you will issue checkAuthorizationSync,
+ // passing the action id and the caller pid (which DBus will tell you).
+ tqDebug("Pretending to be the mechanism for action " + action->actionId());
+
+ Authority::Result result;
+ UnixProcessSubject subject(static_cast<uint>(getpid()));
+ result = Authority::instance()->checkAuthorizationSync(action->actionId(), subject,
+ Authority::AllowUserInteraction);
+ TQListViewItem *item;
+ item = new TQListViewItem(actionList);
+ item->setText(0, action->actionId());
+ if (result == Authority::Yes)
+ {
+ // in the helper you will do the action
+ tqDebug("caller is authorized to do: " + action->actionId());
+ item->setPixmap(1, TQPixmap("/usr/share/apps/polkit-tqt/icons/custom-yes.png"));
+ }
+ else
+ {
+ // or return false to notify the caller that the action is not authorized.
+ tqDebug("caller is NOT authorized to do: " + action->actionId());
+ item->setPixmap(1, TQPixmap("/usr/share/apps/polkit-tqt/icons/custom-no.png"));
+ }
+ actionList->insertItem(item);
}
+
+#include "PkExample.moc"
+
diff --git a/examples/PkExample.h b/examples/PkExample.h
index 30958821b..8621a3129 100644
--- a/examples/PkExample.h
+++ b/examples/PkExample.h
@@ -22,20 +22,60 @@
#ifndef PKEXAMPLE_H
#define PKEXAMPLE_H
-#include "ui_PkExample.h"
+#include <tqvariant.h>
+#include <tqmainwindow.h>
-class PkExample : public TQMainWindow, Ui::PkExample
+class TQVBoxLayout;
+class TQGridLayout;
+class TQSpacerItem;
+class TQToolBar;
+class TQPopupMenu;
+class TQLabel;
+class TQPushButton;
+class TQComboBox;
+class TQListView;
+
+class PkExample : public TQMainWindow
{
- Q_OBJECT
+ TQ_OBJECT
public:
- PkExample(TQMainWindow *parent = 0);
- ~PkExample();
+ PkExample();
+
+ TQLabel *kickL;
+ TQPushButton *kickPB;
+ TQLabel *cryL;
+ TQPushButton *cryPB;
+ TQLabel *bleedL;
+ TQPushButton *bleedPB;
+ TQLabel *playL;
+ TQPushButton *playPB;
+ TQLabel *listenL;
+ TQPushButton *listenPB;
+ TQLabel *deleteL;
+ TQPushButton *deletePB;
+ TQLabel *deleteL_2;
+ TQComboBox *setCB;
+ TQPushButton *setPB;
+ TQLabel *deleteL_3;
+ TQPushButton *shoutPB;
+ TQListView *actionList;
+ TQMenuBar *menubar;
+ TQPopupMenu *menuActions;
+ TQToolBar *toolBar;
+
+ protected:
+ TQVBoxLayout *vLayout;
+ TQGridLayout *grid;
+
+ protected slots:
+ virtual void languageChange();
-private Q_SLOTS:
+ private slots:
void activateAction();
void actionActivated();
-};
+};
#endif
+
diff --git a/examples/PkExample.ui b/examples/PkExample.ui
deleted file mode 100644
index 8b49cf205..000000000
--- a/examples/PkExample.ui
+++ /dev/null
@@ -1,234 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>PkExample</class>
- <widget class="TQMainWindow" name="PkExample">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>800</width>
- <height>600</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>PolicyKit-qt example</string>
- </property>
- <widget class="TQWidget" name="centralwidget">
- <layout class="TQHBoxLayout" name="horizontalLayout">
- <item>
- <layout class="TQGridLayout" name="gridLayout" columnstretch="3,1">
- <item row="0" column="0">
- <widget class="TQLabel" name="kickL">
- <property name="text">
- <string>Making the helper &lt;b&gt;Kick&lt;/b&gt; is not allowed. Action cannot be triggered.</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="TQPushButton" name="kickPB">
- <property name="text">
- <string>Kick!</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="TQLabel" name="cryL">
- <property name="text">
- <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
-&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
-p, li { white-space: pre-wrap; }
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Making the helper &lt;span style=&quot; font-weight:600;&quot;&gt;Cry&lt;/span&gt; is always allowed. Action can be triggered without authentication.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="TQPushButton" name="cryPB">
- <property name="text">
- <string>Cry!</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="TQLabel" name="bleedL">
- <property name="text">
- <string>Making the helper &lt;b&gt;Bleed&lt;/b&gt; requires the user to authenticate. This is a one-shot authorization.</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="TQPushButton" name="bleedPB">
- <property name="text">
- <string>Bleed!</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="TQLabel" name="playL">
- <property name="text">
- <string>Making the helper &lt;b&gt;Play&lt;/b&gt; requires a system administrator to authenticate. This is a one-shot authorization.</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="TQPushButton" name="playPB">
- <property name="text">
- <string>Play!</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="TQLabel" name="listenL">
- <property name="text">
- <string>Making the helper &lt;b&gt;Listen&lt;/b&gt; requires the user to authenticate. The authorization will be kept for a brief period.</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="TQPushButton" name="listenPB">
- <property name="text">
- <string>Listen!</string>
- </property>
- </widget>
- </item>
- <item row="5" column="0">
- <widget class="TQLabel" name="deleteL">
- <property name="text">
- <string>Making the helper &lt;b&gt;Delete&lt;/b&gt; requires a system administrator to authenticate. The authorization will be kept for a brief period.</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="TQPushButton" name="deletePB">
- <property name="text">
- <string>Delete!</string>
- </property>
- </widget>
- </item>
- <item row="6" column="0" rowspan="2">
- <widget class="TQLabel" name="deleteL_2">
- <property name="text">
- <string>&lt;b&gt;Set&lt;/b&gt; is special action. It sets the permissions for the &lt;b&gt;Shout&lt;/b&gt; action by actually using the helper application to change the implicit authorization.</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="6" column="1">
- <widget class="TQComboBox" name="setCB">
- <item>
- <property name="text">
- <string>no</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>yes</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>auth_self</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>auth_admin</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>auth_self_keep</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>auth_admin_keep</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="7" column="1">
- <widget class="TQPushButton" name="setPB">
- <property name="text">
- <string>Set!</string>
- </property>
- </widget>
- </item>
- <item row="8" column="0">
- <widget class="TQLabel" name="deleteL_3">
- <property name="text">
- <string>The implicit authorization for the &lt;b&gt;Shout&lt;/b&gt; action is set by the &lt;b&gt;Set&lt;/b&gt; action. You can watch how different options can change behaviour of this action.</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="8" column="1">
- <widget class="TQPushButton" name="shoutPB">
- <property name="text">
- <string>Shout!</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="TQListWidget" name="actionList"/>
- </item>
- </layout>
- </widget>
- <widget class="TQMenuBar" name="menubar">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>800</width>
- <height>22</height>
- </rect>
- </property>
- <widget class="TQMenu" name="menuActions">
- <property name="title">
- <string>Actions</string>
- </property>
- </widget>
- <addaction name="menuActions"/>
- </widget>
- <widget class="TQToolBar" name="toolBar">
- <property name="windowTitle">
- <string>toolBar</string>
- </property>
- <property name="toolButtonStyle">
- <enum>TQt::ToolButtonTextUnderIcon</enum>
- </property>
- <attribute name="toolBarArea">
- <enum>TopToolBarArea</enum>
- </attribute>
- <attribute name="toolBarBreak">
- <bool>false</bool>
- </attribute>
- </widget>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/PkExampleHelper.cpp b/examples/PkExampleHelper.cpp
index 45b9efed4..a6d169207 100644
--- a/examples/PkExampleHelper.cpp
+++ b/examples/PkExampleHelper.cpp
@@ -20,91 +20,134 @@
***************************************************************************/
#include "PkExampleHelper.h"
-#include "examplesadaptor.h"
-#include "polkittqt-authority.h"
+#include "polkit-tqt-authority.h"
-#include <TQtDBus/TQDBusConnection>
-#include <TQtCore/TQTimer>
-#include <TQtCore/TQDebug>
-#include <TQtXml/TQDomDocument>
-
-#define MINUTE 60000
+#include <tqdbusdatalist.h>
+#include <tqdbuserror.h>
+#include <tqdbusmessage.h>
+#include <tqdom.h>
+#include <tqfile.h>
+#include <tqtimer.h>
using namespace PolkitTQt;
-PkExampleHelper::PkExampleHelper(int &argc, char **argv)
- : TQCoreApplication(argc, argv)
-{
- tqDebug() << "Creating Helper";
- (void) new ExamplesAdaptor(this);
- // Register the DBus service
- if (!TQDBusConnection::systemBus().registerService("org.tqt.policykit.examples")) {
- tqDebug() << TQDBusConnection::systemBus().lastError().message();;
- TQTimer::singleShot(0, this, SLOT(quit()));
- return;
- }
- if (!TQDBusConnection::systemBus().registerObject("/", this)) {
- tqDebug() << "unable to register service interface to dbus";
- TQTimer::singleShot(0, this, SLOT(quit()));
- return;
- }
- // Normally you will set a timeout so your application can
- // free some resources of the poor client machine ;)
- TQTimer::singleShot(MINUTE, this, SLOT(quit()));
+PkExampleHelper::PkExampleHelper(int &argc, char **argv) : TQApplication(argc, argv, false)
+{
+ tqDebug("Creating Helper");
+ // Register the DBus service
+ m_connection = TQT_DBusConnection::systemBus();
+ if (!m_connection.registerObject("/", this))
+ {
+ tqDebug("unable to register 'org.tqt.policykit.examples' service interface to dbus");
+ tqDebug(m_connection.lastError().message());
+ return;
+ }
+ if (!m_connection.requestName("org.tqt.policykit.examples"))
+ {
+ tqDebug("unable to acquire 'org.tqt.policykit.examples' service interface to dbus");
+ tqDebug(m_connection.lastError().message());
+ return;
+ }
+ // Exit if not used for 10 minutes
+ TQTimer::singleShot(600000, this, TQT_SLOT(quit()));
+ tqDebug("Register successful");
}
PkExampleHelper::~PkExampleHelper()
{
- tqDebug() << "Destroying Helper";
+ tqDebug("Destroying Helper");
+ m_connection.unregisterObject("org.tqt.policykit.examples");
}
-bool PkExampleHelper::set(const TQString &action)
+bool PkExampleHelper::handleMethodCall(const TQT_DBusMessage& message)
{
- tqDebug() << "PkExampleHelper::set" << action;
- // message().service() is the service name of the caller
- // We can check if the caller is authorized to the following action
- Authority::Result result;
- SystemBusNameSubject subject(message().service());
+ if (message.interface() != "org.tqt.policykit.examples")
+ {
+ return false;
+ }
- 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;
- // Caller is authorized so we can perform the action
- return setValue(action);
- } else {
- tqDebug() << message().service() << TQString("Can't set the implicit authorization");
- // Caller is not authorized so the action can't be performed
- return false;
+ if (message.member() == "set")
+ {
+ // check parameters
+ if (message.count() != 1 || message[0].type() != TQT_DBusData::String)
+ {
+ // method signature not what we expected
+ TQT_DBusError error = TQT_DBusError::stdInvalidArgs(
+ "Expected one argument of type string");
+ TQT_DBusMessage reply = TQT_DBusMessage::methodError(message, error);
+ m_connection.send(reply);
+ return true;
}
+
+ bool res = set(message[0].toString());
+ TQT_DBusMessage reply = TQT_DBusMessage::methodReply(message);
+ reply << TQT_DBusData::fromBool(res);
+ m_connection.send(reply);
+ return true;
+ }
+
+ TQT_DBusMessage reply = TQT_DBusMessage::methodReply(message);
+ reply << TQT_DBusData::fromString("Bad request");
+ m_connection.send(reply);
+ return true;
+}
+
+bool PkExampleHelper::set(const TQString &action)
+{
+ // We can check if the caller is authorized to the following action
+ SystemBusNameSubject subject(m_connection.uniqueName());
+ Authority::Result result;
+ result = Authority::instance()->checkAuthorizationSync("org.tqt.policykit.examples.set",
+ subject , Authority::AllowUserInteraction);
+ if (result == Authority::Yes)
+ {
+ // Caller is authorized so we can perform the action
+ tqDebug(TQString("Implicit authorization set to ") + action);
+ return setValue(action);
+ }
+ else
+ {
+ // Caller is not authorized so the action can't be performed
+ tqDebug(TQString("Can't set the implicit authorization to ") + action);
+ return false;
+ }
}
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.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.tqt.policykit.examples.shout") {
- el = el.nextSiblingElement("action");
- }
- el = el.firstChildElement("defaults");
- el = el.firstChildElement("allow_active");
- if (el.isNull())
- return false;
- el.firstChild().toText().setData(action);
- if (!file.open(TQIODevice::WriteOnly))
- return false;
- TQTextStream stream(&file);
- doc.save(stream, 2);
- file.close();
- return true;
+ // 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.tqt.policykit.examples.policy");
+ if (!file.open(IO_ReadOnly))
+ {
+ return false;
+ }
+ doc.setContent(&file);
+ file.close();
+ TQDomElement el = doc.namedItem("policyconfig").namedItem("action").toElement();
+ while (!el.isNull() && el.attribute("id") != "org.tqt.policykit.examples.shout")
+ {
+ el = el.nextSibling().toElement();
+ }
+ el = el.namedItem("defaults").toElement();
+ el = el.namedItem("allow_active").toElement();
+ if (el.isNull())
+ {
+ return false;
+ }
+ el.firstChild().toText().setData(action);
+ if (!file.open(IO_WriteOnly))
+ {
+ return false;
+ }
+ TQTextStream stream(&file);
+ doc.save(stream, 2);
+ file.close();
+ return true;
}
+
+#include "PkExampleHelper.moc"
+
diff --git a/examples/PkExampleHelper.h b/examples/PkExampleHelper.h
index 4b7d256ef..f4b13786b 100644
--- a/examples/PkExampleHelper.h
+++ b/examples/PkExampleHelper.h
@@ -22,21 +22,27 @@
#ifndef PKEXAMPLE_HELPER_H
#define PKEXAMPLE_HELPER_H
-#include <TQtDBus/TQDBusContext>
-#include <TQtCore/TQCoreApplication>
+#include <tqdbusobject.h>
+#include <tqdbusconnection.h>
+#include "tqapplication.h"
-class PkExampleHelper : public TQCoreApplication, protected TQDBusContext
+class PkExampleHelper : public TQApplication, public TQT_DBusObjectBase
{
- Q_OBJECT
- TQ_CLASSINFO("D-Bus Interface", "org.tqt.policykit.examples")
-public:
+ Q_OBJECT
+
+ public:
PkExampleHelper(int &argc, char **argv);
~PkExampleHelper();
-public Q_SLOTS:
bool set(const TQString &action);
bool setValue(const TQString &action);
-};
+ protected:
+ bool handleMethodCall(const TQT_DBusMessage& message);
+
+ private:
+ TQT_DBusConnection m_connection;
+};
#endif
+
diff --git a/examples/icons/CMakeLists.txt b/examples/icons/CMakeLists.txt
new file mode 100644
index 000000000..f2a2c4e71
--- /dev/null
+++ b/examples/icons/CMakeLists.txt
@@ -0,0 +1,16 @@
+#################################################
+#
+# (C) 2021 Michele Calgaro
+# Michele (DOT) Calgaro (AT) yahoo.it
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+install(
+ FILES action-locked-default.png action-locked.png action-unlocked.png custom-yes.png custom-no.png
+ DESTINATION ${DATA_INSTALL_DIR}/polkit-tqt/icons
+)
+
diff --git a/examples/icons/icons.qrc b/examples/icons/icons.qrc
deleted file mode 100644
index 9e90e6f21..000000000
--- a/examples/icons/icons.qrc
+++ /dev/null
@@ -1,9 +0,0 @@
-<RCC>
- <qresource prefix="Icons" >
- <file>action-locked-default.png</file>
- <file>action-locked.png</file>
- <file>action-unlocked.png</file>
- <file>custom-no.png</file>
- <file>custom-yes.png</file>
- </qresource>
-</RCC>
diff --git a/examples/main.cpp b/examples/main.cpp
index 602721d00..81cc4c20d 100644
--- a/examples/main.cpp
+++ b/examples/main.cpp
@@ -19,14 +19,15 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
-#include <TQtGui/TQApplication>
+#include <tqapplication.h>
#include "PkExample.h"
int main(int argc, char *argv[])
{
- TQApplication app(argc, argv);
- PkExample example;
- example.show();
- return app.exec();
+ TQApplication app(argc, argv);
+ PkExample *example = new PkExample;
+ example->show();
+ app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
+ return app.exec();
}
diff --git a/examples/mainHelper.cpp b/examples/mainHelper.cpp
index 4a690599c..21e7d61fd 100644
--- a/examples/mainHelper.cpp
+++ b/examples/mainHelper.cpp
@@ -21,8 +21,9 @@
#include "PkExampleHelper.h"
+
int main(int argc, char *argv[])
{
- PkExampleHelper example(argc, argv);
- return example.exec();
+ PkExampleHelper example(argc, argv);
+ return example.exec();
}
diff --git a/examples/org.tqt.policykit.examples.policy.in b/examples/org.tqt.policykit.examples.policy.in
deleted file mode 100644
index fd0006a8c..000000000
--- a/examples/org.tqt.policykit.examples.policy.in
+++ /dev/null
@@ -1,85 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE policyconfig PUBLIC
- "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
-<policyconfig>
- <vendor>KDE</vendor>
- <vendor_url>http://www.kde.org</vendor_url>
- <action id="org.tqt.policykit.examples.kick">
- <description>Kick</description>
- <message>Prevents PolicyKit-TQt example from kicking</message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>no</allow_active>
- </defaults>
- </action>
- <action id="org.tqt.policykit.examples.cry">
- <description>Cry</description>
- <message>Prevents PolicyKit-TQt example from crying</message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>yes</allow_active>
- </defaults>
- </action>
- <action id="org.tqt.policykit.examples.play">
- <description>Play</description>
- <message>Prevents PolicyKit-TQt example from playing</message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>auth_self</allow_active>
- </defaults>
- </action>
- <action id="org.tqt.policykit.examples.bleed">
- <description>Bleed</description>
- <message>Prevents PolicyKit-TQt example from bleeding</message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>auth_admin</allow_active>
- </defaults>
- </action>
- <action id="org.tqt.policykit.examples.listen">
- <description>Listen</description>
- <message>Prevents PolicyKit-TQt example from listening</message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>auth_self_keep</allow_active>
- </defaults>
- </action>
- <action id="org.tqt.policykit.examples.delete">
- <description>Delete</description>
- <message>Prevents PolicyKit-TQt example from deleting</message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>auth_admin_keep</allow_active>
- </defaults>
- </action>
-<!--
- <action id="org.tqt.policykit.examples.shout">
- <description>Shout</description>
- <message>Prevents PolicyKit-TQt example from shouting</message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>yes</allow_active>
- </defaults>
- <annotate key="org.tqt.policykit.examples.shout">foo</annotate>
- </action>
- <action id="org.tqt.policykit.examples.push">
- <description>Push</description>
- <message>Prevents PolicyKit-TQt example from pushing</message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>yes</allow_active>
- </defaults>
- <annotate key="org.tqt.policykit.examples.push">bar</annotate>
- </action>
- <action id="org.tqt.policykit.examples.blow-up">
- <description>Blow Up</description>
- <message>Prevents PolicyKit-TQt example from blowing up</message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>yes</allow_active>
- </defaults>
- <annotate key="org.tqt.policykit.examples.blow-up">booo</annotate>
- </action>
--->
-</policyconfig>
diff --git a/examples/org.tqt.policykit.examples.service.in b/examples/org.tqt.policykit.examples.service.cmake
index 0f57d7592..ac82ed689 100644
--- a/examples/org.tqt.policykit.examples.service.in
+++ b/examples/org.tqt.policykit.examples.service.cmake
@@ -1,5 +1,5 @@
[D-BUS Service]
Name=org.tqt.policykit.examples
-Exec=@BIN_INSTALL_DIR@/polkit-example-helper
+Exec=@BIN_INSTALL_DIR@/polkit-tqt-example-helper
User=root
diff --git a/gui/polkit-tqt-gui-action.h b/gui/polkit-tqt-gui-action.h
index 3149fff92..4f5bb2e2d 100644
--- a/gui/polkit-tqt-gui-action.h
+++ b/gui/polkit-tqt-gui-action.h
@@ -100,7 +100,7 @@ class POLKIT_TQT_EXPORT Action : public TQAction
*/
void authorized();
-public slots:
+ public slots:
/**
* Use this slot if you want to activate the action.
* authorized() will be emitted if the action gets authorized.
@@ -127,7 +127,7 @@ public slots:
*/
void revoke();
-public:
+ public:
/**
* Changes the action being tracked
*
diff --git a/gui/polkit-tqt-gui-actionbutton.cpp b/gui/polkit-tqt-gui-actionbutton.cpp
index 1447bab66..ffcdc2f28 100644
--- a/gui/polkit-tqt-gui-actionbutton.cpp
+++ b/gui/polkit-tqt-gui-actionbutton.cpp
@@ -40,8 +40,8 @@ namespace Gui
void ActionButtonPrivate::addButton(TQButton *button)
{
buttons.append(button);
- TQObject::connect(button, SIGNAL(clicked(bool)), q, SLOT(streamClicked(bool)));
- TQObject::connect(q, SIGNAL(toggled(bool)), button, SLOT(toggle()));
+ TQObject::connect(button, TQT_SIGNAL(clicked()), q, TQT_SLOT(streamClicked()));
+ TQObject::connect(q, TQT_SIGNAL(toggled(bool)), button, TQT_SLOT(toggle()));
q->updateButton();
}
@@ -49,7 +49,7 @@ void ActionButtonPrivate::removeButton(TQButton *button)
{
if (buttons.contains(button))
{
- TQObject::disconnect(button, SIGNAL(clicked(bool)), q, SLOT(streamClicked(bool)));
+ TQObject::disconnect(button, SIGNAL(clicked(bool)), q, SLOT(streamClicked()));
TQObject::disconnect(q, SIGNAL(toggled(bool)), button, SLOT(toggle()));
TQValueList<TQButton*>::iterator butIt = buttons.find(button);
if (butIt != buttons.end())
@@ -67,7 +67,7 @@ ActionButton::ActionButton(ActionButtonPrivate &dd, const TQString &actionId, TQ
: Action(actionId, parent), d(&dd)
{
d->q = this;
- connect(this, SIGNAL(dataChanged()), SLOT(updateButton()));
+ connect(this, TQT_SIGNAL(dataChanged()), this, TQT_SLOT(updateButton()));
}
ActionButton::ActionButton(TQButton *button, const TQString &actionId, TQObject *parent)
@@ -77,7 +77,7 @@ ActionButton::ActionButton(TQButton *button, const TQString &actionId, TQObject
d->buttons.append(button);
setButton(button);
- connect(this, SIGNAL(dataChanged()), SLOT(updateButton()));
+ connect(this, TQT_SIGNAL(dataChanged()), this, TQT_SLOT(updateButton()));
}
ActionButton::~ActionButton()
@@ -85,9 +85,9 @@ ActionButton::~ActionButton()
delete d;
}
-void ActionButton::streamClicked(bool c)
+void ActionButton::streamClicked()
{
- emit clicked(::tqt_cast<TQButton*>(this->sender()), c);
+ emit clicked(::tqt_cast<TQButton*>(this->sender()));
}
void ActionButton::updateButton()
@@ -105,7 +105,6 @@ void ActionButton::updateButton()
ent->hide();
}
ent->setEnabled(isEnabled());
- ent->setText(text());
//if (!toolTip().isNull())
//{
// ent->setToolTip(toolTip());
@@ -115,6 +114,8 @@ void ActionButton::updateButton()
// ent->setWhatsThis(whatsThis());
//}
ent->setPixmap(iconSet().pixmap());
+ // setPixmap() clears the button text, so setText() must be called afterwards
+ ent->setText(text());
// if the item cannot do the action anymore
// lets revert to the initial state
if (ent->isToggleButton())
diff --git a/gui/polkit-tqt-gui-actionbutton.h b/gui/polkit-tqt-gui-actionbutton.h
index 44faff4ac..7ec45f296 100644
--- a/gui/polkit-tqt-gui-actionbutton.h
+++ b/gui/polkit-tqt-gui-actionbutton.h
@@ -144,7 +144,7 @@ class POLKIT_TQT_EXPORT ActionButton : public Action
private slots:
void updateButton();
- void streamClicked(bool);
+ void streamClicked();
};
}