Initial import from polkit-qt-1 debian snapshot archive.

https://snapshot.debian.org/package/polkit-qt-1/0.103.0-1/

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/1/head
Michele Calgaro 3 years ago
commit 28de2ff84f
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -0,0 +1,9 @@
Main Authors:
- Daniel Nicoletti <dantti85-dev@yahoo.com.br>
- Dario Freddi <drf@kde.org>
- Jaroslav Reznik <jreznik@redhat.com>
Contributors:
- Pino Toscano <pino@kde.org>
- Lukas Tinkl <ltinkl@redhat.com>
- Radek Novacek <rnovacek@redhat.com>

@ -0,0 +1,156 @@
## Polkit Qt Library
project("PolkitQt-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")
find_package(Qt4 REQUIRED)
find_package(Automoc4 REQUIRED)
find_package(Polkit REQUIRED)
find_package(GObject REQUIRED)
find_package(GIO REQUIRED)
add_definitions(-DQT_NO_KEYWORDS)
include (${QT_USE_FILE})
include (InstallSettings)
include (MacroWriteBasicCMakeVersionFile)
include (CheckFunctionExists)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${POLKIT_INCLUDE_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
${QT_QTXML_INCLUDE_DIR}
)
# Check for older polkit
set(CMAKE_REQUIRED_INCLUDES ${POLKIT_INCLUDE_DIR} ${POLKIT_AGENT_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${POLKIT_LIBRARIES} ${POLKIT_AGENT_LIBRARY})
check_function_exists(polkit_agent_listener_register HAVE_POLKIT_AGENT_LISTENER_REGISTER)
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)
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 <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)
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}")
# The SONUMBER of the polkit-qt-1 libraries
set(POLKITQT-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}")
configure_file(polkitqt1-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/polkitqt1-version.h)
install(FILES
gui/polkitqt1-gui-action.h
gui/polkitqt1-gui-actionbutton.h
gui/polkitqt1-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
agent/polkitqt1-agent-listener.h
agent/polkitqt1-agent-session.h
${CMAKE_CURRENT_BINARY_DIR}/polkitqt1-version.h
polkitqt1-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
DESTINATION
${INCLUDE_INSTALL_DIR}/polkit-qt-1/PolkitQt1 COMPONENT Devel)
install(FILES
includes/PolkitQt1/Gui/Action
includes/PolkitQt1/Gui/ActionButton
includes/PolkitQt1/Gui/ActionButtons
DESTINATION
${INCLUDE_INSTALL_DIR}/polkit-qt-1/PolkitQt1/Gui COMPONENT Devel)
install(FILES
includes/PolkitQt1/Agent/Listener
includes/PolkitQt1/Agent/Session
DESTINATION
${INCLUDE_INSTALL_DIR}/polkit-qt-1/PolkitQt1/Agent COMPONENT Devel)
if(NOT WIN32)
# Pkgconfig
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/polkit-qt-1.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/polkit-qt-1.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/polkit-qt-1.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig )
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/polkit-qt-core-1.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/polkit-qt-core-1.pc
@ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/polkit-qt-core-1.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig )
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/polkit-qt-gui-1.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/polkit-qt-gui-1.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/polkit-qt-gui-1.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig )
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/polkit-qt-agent-1.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/polkit-qt-agent-1.pc
@ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/polkit-qt-agent-1.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig )
endif(NOT WIN32)
# CMake Config files
configure_file(PolkitQt-1Config.cmake.in "${CMAKE_BINARY_DIR}/PolkitQt-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})
if(USE_COMMON_CMAKE_PACKAGE_CONFIG_DIR)
set(_PolkitQt-1Config_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/PolkitQt-1)
else(USE_COMMON_CMAKE_PACKAGE_CONFIG_DIR)
set(_PolkitQt-1Config_INSTALL_DIR ${LIB_INSTALL_DIR}/PolkitQt-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} )
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)
add_subdirectory(core)
add_subdirectory(gui)
add_subdirectory(agent)
# Always last!
include (PolkitQt-1Dist)

@ -0,0 +1,504 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 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.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes 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
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

@ -0,0 +1,26 @@
Polkit-qt's build system uses cmake.
So to compile Polkit-qt first create a build dir
mkdir build
cd build
then run cmake:
cmake ..
(a typical cmake option that is often used is: -DCMAKE_INSTALL_PREFIX=<prefix>)
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:
make
And install it (in most cases root privileges are required):
make install
That's all :)

@ -0,0 +1,106 @@
/**
\mainpage Polkit-qt-1 - Qt wrapper around polkit-1
\section polkitqt1_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 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
\b polkit-qt-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
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.
\li A sample usage of polkit-qt-1 can be found in \ref polkitqt1_example
\li <a href="classes.html">Alphabetical Class List</a>
\li <a href="hierarchy.html">Class Hierarchy</a>
\page polkitqt1_example Polkit-qt-1 usage example
You can find an example usage of Polkit-qt-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->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->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->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->setToolTip("Go ahead, kick kick kick!", Action::Yes);
\endcode
This small paragraph sets up an action button using an existing button defined in the
UI file, \c kickPB . As you can see, you can set custom properties on your button depending
on the action status/result. The code is mostly self-explainatory
\code
bt = new ActionButtons(QList<QAbstractButton*>() << 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->setText("Click to make changes...");
\endcode
This demonstrates the use of ActionButtons, that lets you associate multiple buttons with a
single action with extreme ease. \c listenPB and \c listenCB, both defined in the ui file,
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(authorized()), this, SLOT(actionActivated()));
\endcode
Those three signals are all you need to control the action and the activation. Action::triggered()
lets you start the activation/revoke when needed, ActionButton::clicked() lets you do the same thing
with even more ease, just by manually connecting the signal to ActionButton::activate() (see the docs
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
and to the API Docs for more details.
*/
// DOXYGEN_PROJECTVERSION=0.96.1
// DOXYGEN_PROJECTNAME=PolkitQt-1
// DOXYGEN_ENABLE=YES
// vim:ts=4:sw=4:expandtab:filetype=doxygen

@ -0,0 +1,41 @@
# PolkitQt-1Config.cmake is generated by CMake from PolkitQt-1Config.cmake.in.
# Any changed value in this file will be overwritten by CMake.
# set the PolkitQt-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})

@ -0,0 +1,23 @@
Polkit-qt
========
What is Polkit-qt?
------------------
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
lets you integrate those two component easily with PolicyKit
This directory contains the sources of the library.
Structure
----------
* cmake/
Contains the cmake checks that are needed to build the library,
and a FindPolkitQt.cmake module.
* .
Contains the sources of the library
See INSTALL for installation instructions.

@ -0,0 +1,25 @@
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

11
TODO

@ -0,0 +1,11 @@
TODO
====
- Policy Kit 1 port
* polkit-qt
+ Console Kit support
* polkit-qt-gui
+ authorization checking for non privileged user
- document Listener and co.

@ -0,0 +1,25 @@
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
set(polkit_qt_agent_SRCS
polkitqt1-agent-session.cpp
polkitqt1-agent-listener.cpp
listeneradapter.cpp
polkitqtlistener.cpp
)
automoc4_add_library(polkit-qt-agent-1 SHARED ${polkit_qt_agent_SRCS})
target_link_libraries(polkit-qt-agent-1
${POLKIT_LIBRARIES}
${QT_QTCORE_LIBRARY}
${POLKIT_AGENT_LIBRARY}
polkit-qt-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)
install(TARGETS polkit-qt-agent-1 ${INSTALL_TARGETS_DEFAULT_ARGS})

@ -0,0 +1,146 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
*
* 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 "listeneradapter_p.h"
#include <QtCore/QDebug>
#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1
#include <polkitagent/polkitagent.h>
namespace PolkitQt1
{
namespace Agent
{
class ListenerAdapterHelper
{
public:
ListenerAdapterHelper() : q(0) {}
~ListenerAdapterHelper() {
delete q;
}
ListenerAdapter *q;
};
Q_GLOBAL_STATIC(ListenerAdapterHelper, s_globalListenerAdapter)
ListenerAdapter *ListenerAdapter::instance()
{
if (!s_globalListenerAdapter()->q) {
new ListenerAdapter();
}
return s_globalListenerAdapter()->q;
}
ListenerAdapter::ListenerAdapter(QObject *parent)
: QObject(parent)
{
Q_ASSERT(!s_globalListenerAdapter()->q);
s_globalListenerAdapter()->q = this;
}
Listener* ListenerAdapter::findListener(PolkitAgentListener *listener)
{
Listener *listItem;
Q_FOREACH(listItem, m_listeners) {
Q_ASSERT(listItem);
if (listItem->listener() == listener) {
return listItem;
}
}
return NULL;
}
void ListenerAdapter::polkit_qt_listener_initiate_authentication(PolkitAgentListener *listener,
const gchar *action_id,
const gchar *message,
const gchar *icon_name,
PolkitDetails *details,
const gchar *cookie,
GList *identities,
GCancellable *cancellable,
GSimpleAsyncResult *result)
{
qDebug() << "polkit_qt_listener_initiate_authentication callback for " << listener;
PolkitQt1::Identity::List idents;
PolkitQt1::Details dets(details);
Listener *list = findListener(listener);
for (GList *identity = g_list_first(identities); identity != NULL; identity = g_list_next(identity)) {
idents.append(PolkitQt1::Identity((PolkitIdentity *)identity->data));
}
list->initiateAuthentication(QString::fromUtf8(action_id),
QString::fromUtf8(message),
QString::fromUtf8(icon_name),
dets,
QString::fromUtf8(cookie),
idents,
new AsyncResult(result));
}
gboolean ListenerAdapter::polkit_qt_listener_initiate_authentication_finish(PolkitAgentListener *listener,
GAsyncResult *res,
GError **error)
{
qDebug() << "polkit_qt_listener_initiate_authentication_finish callback for " << listener;
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT(res);
if (g_simple_async_result_propagate_error(simple, error)) {
return false;
}
return true;
}
void ListenerAdapter::cancelled_cb(PolkitAgentListener *listener)
{
qDebug() << "cancelled_cb for " << listener;
Listener *list = findListener(listener);
list->cancelAuthentication();
}
void ListenerAdapter::addListener(Listener *listener)
{
qDebug() << "Adding new listener " << listener << "for " << listener->listener();
m_listeners.append(listener);
}
void ListenerAdapter::removeListener(Listener *listener)
{
qDebug() << "Removing listener " << listener;
// should be safe as we don't have more than one same listener registered in one time
m_listeners.removeOne(listener);
}
}
}
#include "listeneradapter_p.moc"

@ -0,0 +1,83 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
*
* 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 LISTENER_ADAPTER_P_H
#define LISTENER_ADAPTER_P_H
#include <QtCore/QObject>
#include "polkitqt1-agent-listener.h"
#include "polkitqt1-identity.h"
#include "polkitqt1-details.h"
typedef struct _GList GList;
typedef struct _GCancellable GCancellable;
typedef struct _GAsyncResult GAsyncResult;
typedef struct _GSimpleAsyncResult GSimpleAsyncResult;
typedef struct _GError GError;
typedef int gboolean;
typedef char gchar;
namespace PolkitQt1
{
namespace Agent
{
class AsyncResult;
class Listener;
class ListenerAdapter : public QObject
{
Q_OBJECT
Q_DISABLE_COPY(ListenerAdapter)
public:
static ListenerAdapter* instance();
~ListenerAdapter() {}
void polkit_qt_listener_initiate_authentication(PolkitAgentListener *listener,
const gchar *action_id,
const gchar *message,
const gchar *icon_name,
PolkitDetails *details,
const gchar *cookie,
GList *identities,
GCancellable *cancellable,
GSimpleAsyncResult *result);
gboolean polkit_qt_listener_initiate_authentication_finish(PolkitAgentListener *listener,
GAsyncResult *res,
GError **error);
void cancelled_cb(PolkitAgentListener *listener);
private:
void addListener(Listener *listener);
void removeListener(Listener *listener);
Listener* findListener(PolkitAgentListener *listener);
explicit ListenerAdapter(QObject *parent = 0);
QList<Listener *> m_listeners;
friend class Listener;
};
}
}
#endif

@ -0,0 +1,124 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
*
* 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-agent-listener.h"
#include <QtCore/QDebug>
#include "polkitqtlistener_p.h"
#include "polkitqt1-authority.h"
#include "polkitqt1-subject.h"
#include "polkitqt1-identity.h"
#include "polkitqt1-details.h"
namespace PolkitQt1
{
namespace Agent
{
class ListenerPrivate
{
public:
PolkitAgentListener *listener;
#ifndef POLKIT_QT_1_COMPATIBILITY_MODE
void *registeredHandle;
#endif
};
Listener::Listener(QObject *parent)
: QObject(parent), d(new ListenerPrivate)
{
g_type_init();
d->listener = polkit_qt_listener_new();
qDebug() << "New PolkitAgentListener " << d->listener;
ListenerAdapter::instance()->addListener(this);
}
Listener::Listener(PolkitAgentListener *listener, QObject *parent)
: QObject(parent), d(new ListenerPrivate)
{
g_type_init();
d->listener = listener;
}
Listener::~Listener()
{
qDebug("Destroying listener");
ListenerAdapter::instance()->removeListener(this);
#ifndef POLKIT_QT_1_COMPATIBILITY_MODE
if (d->registeredHandle) {
polkit_agent_listener_unregister(d->registeredHandle);
}
#endif
if (d->listener != NULL) {
g_object_unref(d->listener);
}
}
bool Listener::registerListener(const PolkitQt1::Subject &subject, const QString &objectPath)
{
GError *error = NULL;
#ifndef POLKIT_QT_1_COMPATIBILITY_MODE
d->registeredHandle = polkit_agent_listener_register(d->listener,
POLKIT_AGENT_REGISTER_FLAGS_NONE,
#else
bool r = polkit_agent_register_listener(d->listener,
#endif
subject.subject(),
objectPath.toAscii().data(),
#ifndef POLKIT_QT_1_COMPATIBILITY_MODE
NULL,
#endif
&error);
if (error != NULL) {
qWarning() << QString("Cannot register authentication agent: %1").arg(error->message);
g_error_free(error);
return false;
}
#ifndef POLKIT_QT_1_COMPATIBILITY_MODE
if (d->registeredHandle == NULL) {
qWarning() << QString("Cannot register authentication agent!");
return false;
}
return true;
#else
return r;
#endif
}
const PolkitAgentListener *Listener::listener()
{
return d->listener;
}
}
}
#include "polkitqt1-agent-listener.moc"

@ -0,0 +1,161 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
*
* 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_AGENT_LISTENER_H
#define POLKITQT1_AGENT_LISTENER_H
#include "polkitqt1-export.h"
#include <QtCore/QObject>
#include "polkitqt1-agent-session.h"
#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1
typedef struct _PolkitAgentListener PolkitAgentListener;
namespace PolkitQt1
{
class Subject;
class Identity;
class Details;
}
namespace PolkitQt1
{
namespace Agent
{
class ListenerPrivate;
/**
* \class Listener polkitqt1-agent-listener.h Listener
* \author Jaroslav Reznik <jreznik@redhat.com>
*
* \brief Listener is abstract class used for implementing authentication agents.
*
* To implement an authentication agent, just subclass this class and implement
* virtual functions initiateAuthentication, initiateAuthenticationFinish
* and cancelAuthentication.
*
* You can also use Session class to authenticate users however it isn't required.
* \sa Session
*/
class POLKITQT1_EXPORT Listener : public QObject
{
Q_OBJECT
Q_DISABLE_COPY(Listener)
public:
/**
* \brief Constructor of Listener class
*/
Listener(QObject *parent = 0);
/**
* \brief Constructor of Listener class from PolkitAgentListener
*
* \warning Use this only if you are completely aware of what are you doing!
*
* \param listener Pointer to the PolkitAgentListener
* \param parent
*/
explicit Listener(PolkitAgentListener *listener, QObject *parent = 0);
virtual ~Listener();
/**
* \brief Registers listener with polkit daemon as an authentication agent for \p subject.
*
* This is implemented by registering a DBus object at \p objectPath on the unique
* name assigned by the system message bus.
*
* Whenever the polkit daemon needs to authenticate a processes that is related to \p subject,
* the methods initiateAuthentication and initiateAuthenticationFinish will be evoked.
*
* \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
*/
bool registerListener(const PolkitQt1::Subject &subject, const QString &objectPath);
/**
* \brief Returns pointer to the PolkitAgentListener.
*
* \warning Use this only if you are completely aware of what are you doing!
*
* \return PolkitAgentListener
*/
const PolkitAgentListener *listener();
public Q_SLOTS:
/**
* \brief Initiate authentication for the action
*
* This method will be called on a registered authentication agent when the user owning
* the session needs to prove he is one of the identities listed in \p identities.
*
* \note You have to reimplement this method in the subclass.
*
* \param actionId The action to authenticate for
* \param message The message to present to the user
* \param iconName The name of the icon which is representing the action
* \param details Details describing the action
* \param cookie The cookie for the authentization request
* \param identities A list of Identity object that the user can choose to authenticate as
* \param result This AsyncResult MUST be completed by using complete() method when the
* authentication is done. You can pass it to the constructor of the Session class
* and then call session->result()->complete() to mark the action as done.
*/
virtual void initiateAuthentication(const QString &actionId,
const QString &message,
const QString &iconName,
const PolkitQt1::Details &details,
const QString &cookie,
const PolkitQt1::Identity::List &identities,
AsyncResult *result) = 0;
/**
* TODO: Is this method really required ?
* \brief Finishes an authentication request from the polkit daemon.
*
* \note You have to reimplement this method in the subclass.
*
* \see initiateAuthentication
*/
virtual bool initiateAuthenticationFinish() = 0;
/**
* TODO: Is this method really required ?
* \brief Cancels an authentication request from the polkit daemon.
*
* \note You have to reimplement this method in the subclass.
*
* \see initiateAuthentication
*/
virtual void cancelAuthentication() = 0;
private:
ListenerPrivate * const d;
};
}
}
#endif

@ -0,0 +1,169 @@
/*
* This file is part of the PolKit1-qt project
* Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com>
*
* 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-agent-session.h"
#include <QtCore/QDebug>
#include "polkitqt1-identity.h"
#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1
#include <polkitagent/polkitagent.h>
using namespace PolkitQt1::Agent;
class Session::Private
{
public:
Private() {}
~Private();
static void completed(PolkitAgentSession *s, gboolean gained_authorization, gpointer user_data);
static void request(PolkitAgentSession *s, gchar *request, gboolean echo_on, gpointer user_data);
static void showError(PolkitAgentSession *s, gchar *text, gpointer user_data);
static void showInfo(PolkitAgentSession *s, gchar *text, gpointer user_data);
AsyncResult *result;
PolkitAgentSession *polkitAgentSession;
};
Session::Private::~Private()
{
// polkitAgentSession is freed in Session d'tor
}
Session::Session(const PolkitQt1::Identity &identity, const QString &cookie, AsyncResult *result, QObject *parent)
: QObject(parent)
, d(new Private)
{
d->result = result;
d->polkitAgentSession = polkit_agent_session_new(identity.identity(), cookie.toUtf8().data());
g_signal_connect(G_OBJECT(d->polkitAgentSession), "completed", G_CALLBACK(Private::completed), this);
g_signal_connect(G_OBJECT(d->polkitAgentSession), "request", G_CALLBACK(Private::request), this);
g_signal_connect(G_OBJECT(d->polkitAgentSession), "show-error", G_CALLBACK(Private::showError), this);
g_signal_connect(G_OBJECT(d->polkitAgentSession), "show-info", G_CALLBACK(Private::showInfo), this);
}
Session::Session(PolkitAgentSession *pkAgentSession, QObject *parent)
: QObject(parent)
, d(new Private)
{
d->polkitAgentSession = pkAgentSession;
g_signal_connect(G_OBJECT(d->polkitAgentSession), "completed", G_CALLBACK(Private::completed), this);
g_signal_connect(G_OBJECT(d->polkitAgentSession), "request", G_CALLBACK(Private::request), this);
g_signal_connect(G_OBJECT(d->polkitAgentSession), "show-error", G_CALLBACK(Private::showError), this);
g_signal_connect(G_OBJECT(d->polkitAgentSession), "show-info", G_CALLBACK(Private::showInfo), this);
}
Session::~Session()
{
if (d->polkitAgentSession)
g_object_unref(d->polkitAgentSession);
delete d;
}
void Session::initiate()
{
polkit_agent_session_initiate(d->polkitAgentSession);
}
void Session::setResponse(const QString &response)
{
polkit_agent_session_response(d->polkitAgentSession, response.toUtf8().data());
}
void Session::cancel()
{
polkit_agent_session_cancel(d->polkitAgentSession);
}
AsyncResult *Session::result()
{
return d->result;
}
void Session::Private::completed(PolkitAgentSession *s, gboolean gained_authorization, gpointer user_data)
{
qDebug() << "COMPLETED";
Session *session = (Session *)user_data;
Q_EMIT(session)->completed(gained_authorization);
//free session here as polkit documentation asks
g_object_unref(session->d->polkitAgentSession);
session->d->polkitAgentSession = 0;
}
void Session::Private::request(PolkitAgentSession *s, gchar *request, gboolean echo_on, gpointer user_data)
{
qDebug() << "REQUEST";
Q_EMIT((Session *)user_data)->request(QString::fromUtf8(request), echo_on);
}
void Session::Private::showError(PolkitAgentSession *s, gchar *text, gpointer user_data)
{
qDebug() << "showError";
Q_EMIT((Session *)user_data)->showError(QString::fromUtf8(text));
}
void Session::Private::showInfo(PolkitAgentSession *s, gchar *text, gpointer user_data)
{
qDebug() << "showInfo";
Q_EMIT((Session *)user_data)->showInfo(QString::fromUtf8(text));
}
//
class AsyncResult::Private
{
public:
Private(GSimpleAsyncResult *r) : result(r) {};
GSimpleAsyncResult *result;
};
AsyncResult::AsyncResult(GSimpleAsyncResult *result)
: d(new Private(result))
{
}
AsyncResult::~AsyncResult()
{
if (d->result)
g_object_unref(d->result);
}
void AsyncResult::setCompleted()
{
if (d->result == NULL)
return;
g_simple_async_result_complete(d->result);
// Assure that completed won't be called twice
g_object_unref(d->result);
d->result = NULL;
}
void AsyncResult::setError(const QString &text)
{
Q_ASSERT(d->result);
g_simple_async_result_set_error(d->result, POLKIT_ERROR, POLKIT_ERROR_FAILED, "%s", text.toUtf8().data());
}
#include "polkitqt1-agent-session.moc"

@ -0,0 +1,180 @@
/*
* This file is part of the PolKit1-qt project
* Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com>
*
* 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_AGENT_SESSION_H
#define POLKITQT1_AGENT_SESSION_H
#include <QtCore/QObject>
#include "polkitqt1-identity.h"
typedef struct _GSimpleAsyncResult GSimpleAsyncResult;
typedef struct _PolkitAgentSession PolkitAgentSession;
namespace PolkitQt1
{
/**
* \namespace Agent Agent
*
* \brief Namespace wrapping Polkit-Qt Agent classes
*
* This namespace wraps all Polkit-Qt Agent classes.
*/
namespace Agent
{
/**
* \internal
* \brief Encapsulation of GSimpleAsyncResult to QObject class
*/
class POLKITQT1_EXPORT AsyncResult
{
public:
explicit AsyncResult(GSimpleAsyncResult *result);
virtual ~AsyncResult();
/**
* \brief Mark the action that is tied to this result as completed.
*/
void setCompleted();
/**
* \brief Sets an error for the asynchronous result.
* Method complete() must be called anyway.
*
* \param text text of the error message
*/
void setError(const QString &text);
private:
class Private;
Private * const d;
};
/**
* \class Session polkitqt1-agent-session.h Session
* \author Radek Novacek <rnovacek@redhat.com>
*
* This class is interface for interacting with native
* authentication system for obtaining authorizations.
*
*/
class POLKITQT1_EXPORT Session : public QObject
{
Q_OBJECT
Q_DISABLE_COPY(Session)
public:
/**
* Create a new authentication session.
*
* \param identity The identity to authenticate
* \param cookie The cookie obtained from the PolicyKit daemon
* \param result Result of the authentication action. Must be finished using complete() method.
* \param parent
*/
Session(const PolkitQt1::Identity& identity, const QString &cookie, AsyncResult *result = 0, QObject *parent = 0);
/**
* Create a new authentication session from PolkitAgentSession object
*
* \warning Use this only if you are completely aware of what are you doing!
*
* \param pkAgentSession PolkitAgentSession object
* \param parent
*/
explicit Session(PolkitAgentSession *pkAgentSession, QObject *parent = 0);
/**
* Destroy authentication session.
*/
~Session();
/**
* Initiate the authentication session.
*
* Use cancel() to cancel the session.
*/
void initiate();
/**
* Method for providing response to requests received via request signal.
*
* \param response Response from the user, typically a password
*/
void setResponse(const QString &response);
/**
* Cancel the authentication session.
* This will emit the completed() signal.
*/
void cancel();
/**
* Get AsyncResult that can be used to finish authentication operation
*
* \return AsyncResult object or NULL if it is not set
*/
AsyncResult *result();
Q_SIGNALS:
/**
* This signal will be emitted when the authentication
* polkitqt1-agent-session.has been completed or cancelled.
*
* \param gainedAuthorization \c True if authorization was successfully obtained.
*/
void completed(bool gainedAuthorization);
/**
* This signal will be emitted when user is requested to answer a question.
*
* \param request The request to show the user, e.g. "name: " or "password: ".
* \param echo \c True if the response to the request SHOULD be echoed on the screen,
* \c False if the response MUST NOT be echoed to the screen.
*/
void request(const QString &request, bool echo);
/**
* This signal will be emitted when there is information
* related to an error condition to be displayed to the user.
*
* \param text An error string to display to the user.
*/
void showError(const QString &text);
/**
* This signal will be emitted when there is information
* to be displayed to the user.
*
* \param text A string to be displayed to the user.
*/
void showInfo(const QString &text);
private:
class Private;
Private * const d;
};
}
}
#endif // SESSION_H

@ -0,0 +1,150 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
*
* 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.
*
* polkit-qt-listener based on code by David Zeuthen <davidz@redhat.com>
*/
#include "polkitqtlistener_p.h"
#include <stdio.h>
#include <QtCore/QDebug>
#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1
using namespace PolkitQt1::Agent;
/**
* \internal
*/
struct _PolkitQtListener {
PolkitAgentListener parent_instance;
};
/**
* \internal
*/
struct _PolkitQtListenerClass {
PolkitAgentListenerClass parent_class;
};
static void polkit_qt_listener_initiate_authentication(PolkitAgentListener *listener,
const gchar *action_id,
const gchar *message,
const gchar *icon_name,
PolkitDetails *details,
const gchar *cookie,
GList *identities,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
static gboolean polkit_qt_listener_initiate_authentication_finish(PolkitAgentListener *listener,
GAsyncResult *res,
GError **error);
G_DEFINE_TYPE(PolkitQtListener, polkit_qt_listener, POLKIT_AGENT_TYPE_LISTENER);
static void polkit_qt_listener_init(PolkitQtListener *listener)
{
g_type_init();
}
static void polkit_qt_listener_finalize(GObject *object)
{
PolkitQtListener *listener;
listener = POLKIT_QT_LISTENER(object);
if (G_OBJECT_CLASS(polkit_qt_listener_parent_class)->finalize != NULL) {
G_OBJECT_CLASS(polkit_qt_listener_parent_class)->finalize(object);
}
}
static void polkit_qt_listener_class_init(PolkitQtListenerClass *klass)
{
GObjectClass *gobject_class;
PolkitAgentListenerClass *listener_class;
gobject_class = G_OBJECT_CLASS(klass);
listener_class = POLKIT_AGENT_LISTENER_CLASS(klass);
gobject_class->finalize = polkit_qt_listener_finalize;
listener_class->initiate_authentication = polkit_qt_listener_initiate_authentication;
listener_class->initiate_authentication_finish = polkit_qt_listener_initiate_authentication_finish;
}
PolkitAgentListener *polkit_qt_listener_new(void)
{
return POLKIT_AGENT_LISTENER(g_object_new(POLKIT_QT_TYPE_LISTENER, NULL));
}
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,
const gchar *action_id,
const gchar *message,
const gchar *icon_name,
PolkitDetails *details,
const gchar *cookie,
GList *identities,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
qDebug() << "Listener adapter polkit_qt_listener_initiate_authentication";
PolkitQtListener *listener = POLKIT_QT_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);
qDebug() << "GSimpleAsyncResult:" << result;
ListenerAdapter::instance()->polkit_qt_listener_initiate_authentication(agent_listener,
action_id,
message,
icon_name,
details,
cookie,
identities,
cancellable,
result);
if (cancellable != NULL) {
g_signal_connect(cancellable,
"cancelled",
G_CALLBACK(cancelled_cb),
agent_listener);
}
}
static gboolean polkit_qt_listener_initiate_authentication_finish(PolkitAgentListener *listener,
GAsyncResult *res,
GError **error)
{
qDebug() << "Listener adapter polkit_qt_listener_initiate_authentication_finish";
return ListenerAdapter::instance()->polkit_qt_listener_initiate_authentication_finish(listener,
res,
error);
}

@ -0,0 +1,49 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
*
* 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.
*
* polkit-qt-listener based on code by David Zeuthen <davidz@redhat.com>
*/
#ifndef POLKITQT_LISTENER_P_H
#define POLKITQT_LISTENER_P_H
#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1
#include "listeneradapter_p.h"
#include <polkitagent/polkitagent.h>
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, PolkitQtListener))
#define POLKIT_QT_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_QT_TYPE_LISTENER, PolkitQtListenerClass))
#define POLKIT_QT_LISTENER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_QT_TYPE_LISTENER, PolkitQtListenerClass))
#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))
typedef struct _PolkitQtListener PolkitQtListener;
typedef struct _PolkitQtListenerClass PolkitQtListenerClass;
GType polkit_qt_listener_get_type(void) G_GNUC_CONST;
PolkitAgentListener *polkit_qt_listener_new(void);
G_END_DECLS
#endif /* POLKIT_QT_LISTENER_H */

@ -0,0 +1 @@
add_subdirectory(modules)

@ -0,0 +1,30 @@
# This is a very basic file for the new style find_package() search mode,
# i.e. Config-mode. It is used by MACRO_WRITE_BASIC_CMAKE_VERSION_FILE() from
# MacroWriteBasicCMakeVersionFile.cmake.
# In this mode find_package() searches for a <package>Config.cmake
# file and an associated <package>Version.cmake file, which it loads to check
# the version number.
# This file can be used with configure_file() to generate such a file for a project
# with very basic logic.
# It sets PACKAGE_VERSION_EXACT if the current version string and the requested
# version string are exactly the same and it sets PACKAGE_VERSION_COMPATIBLE
# if the current version is >= requested version.
# If this is not good enough for your project, you need to write your own
# improved <package>Version.cmake file.
# This file requires the following three variables to be set:
# PROJECT_VERSION_MAJOR
# PROJECT_VERSION_MINOR
# PROJECT_VERSION_PATCH
set(PACKAGE_VERSION @PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@)
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
endif("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )

@ -0,0 +1,9 @@
## install the cmake files
#file( GLOB cmakeFiles FindPolkitQt.cmake )
#set(module_install_dir ${CMAKE_ROOT}/Modules )
#install( FILES ${cmakeFiles}
# DESTINATION ${module_install_dir} )

@ -0,0 +1,81 @@
# - Try to find automoc4
# Once done this will define
#
# AUTOMOC4_FOUND - automoc4 has been found
# AUTOMOC4_EXECUTABLE - the automoc4 tool
# AUTOMOC4_VERSION - the full version of automoc4
# AUTOMOC4_VERSION_MAJOR, AUTOMOC4_VERSION_MINOR, AUTOMOC4_VERSION_PATCH - AUTOMOC4_VERSION
# broken into its components
#
# It also adds the following macros
# AUTOMOC4(<target> <SRCS_VAR>)
# Use this to run automoc4 on all files contained in the list <SRCS_VAR>.
#
# AUTOMOC4_MOC_HEADERS(<target> header1.h header2.h ...)
# Use this to add more header files to be processed with automoc4.
#
# AUTOMOC4_ADD_EXECUTABLE(<target_NAME> src1 src2 ...)
# This macro does the same as ADD_EXECUTABLE, but additionally
# adds automoc4 handling for all source files.
#
# AUTOMOC4_ADD_LIBRARY(<target_NAME> src1 src2 ...)
# This macro does the same as ADD_LIBRARY, but additionally
# adds automoc4 handling for all source files.
# Internal helper macro, may change or be removed anytime:
# _ADD_AUTOMOC4_TARGET(<target_NAME> <SRCS_VAR>)
#
# Since version 0.9.88:
# The following two macros are only to be used for KDE4 projects
# and do something which makes sure automoc4 works for KDE. Don't
# use them anywhere else.
# _AUTOMOC4_KDE4_PRE_TARGET_HANDLING(<target_NAME> <SRCS_VAR>)
# _AUTOMOC4_KDE4_POST_TARGET_HANDLING(<target_NAME>)
# Copyright (c) 2008-2009, Alexander Neundorf, <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# check if we are inside KDESupport
if("${KDESupport_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
# when building this project as part of kdesupport
set(AUTOMOC4_CONFIG_FILE "${KDESupport_SOURCE_DIR}/automoc/Automoc4Config.cmake")
else("${KDESupport_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
# when building this project outside kdesupport
# CMAKE_[SYSTEM_]PREFIX_PATH exists starting with cmake 2.6.0
file(TO_CMAKE_PATH "$ENV{CMAKE_PREFIX_PATH}" _env_CMAKE_PREFIX_PATH)
file(TO_CMAKE_PATH "$ENV{CMAKE_LIBRARY_PATH}" _env_CMAKE_LIBRARY_PATH)
find_file(AUTOMOC4_CONFIG_FILE NAMES Automoc4Config.cmake
PATH_SUFFIXES automoc4 lib/automoc4 lib64/automoc4
PATHS ${_env_CMAKE_PREFIX_PATH} ${CMAKE_PREFIX_PATH} ${CMAKE_SYSTEM_PREFIX_PATH}
${_env_CMAKE_LIBRARY_PATH} ${CMAKE_LIBRARY_PATH} ${CMAKE_SYSTEM_LIBRARY_PATH}
${CMAKE_INSTALL_PREFIX}
NO_DEFAULT_PATH )
endif("${KDESupport_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
if(AUTOMOC4_CONFIG_FILE)
include(${AUTOMOC4_CONFIG_FILE})
set(AUTOMOC4_FOUND TRUE)
else(AUTOMOC4_CONFIG_FILE)
set(AUTOMOC4_FOUND FALSE)
endif(AUTOMOC4_CONFIG_FILE)
if (AUTOMOC4_FOUND)
if (NOT Automoc4_FIND_QUIETLY)
message(STATUS "Found Automoc4: ${AUTOMOC4_EXECUTABLE}")
endif (NOT Automoc4_FIND_QUIETLY)
else (AUTOMOC4_FOUND)
if (Automoc4_FIND_REQUIRED)
message(FATAL_ERROR "Did not find automoc4 (part of kdesupport).")
else (Automoc4_FIND_REQUIRED)
if (NOT Automoc4_FIND_QUIETLY)
message(STATUS "Did not find automoc4 (part of kdesupport).")
endif (NOT Automoc4_FIND_QUIETLY)
endif (Automoc4_FIND_REQUIRED)
endif (AUTOMOC4_FOUND)

@ -0,0 +1,66 @@
# - Try to find the GIO libraries
# Once done this will define
#
# GIO_FOUND - system has GIO
# GIO_INCLUDE_DIR - the GIO include directory
# GIO_LIBRARIES - GIO library
if(GIO_INCLUDE_DIR AND GIO_LIBRARIES)
# Already in cache, be silent
set(GIO_FIND_QUIETLY TRUE)
endif(GIO_INCLUDE_DIR AND GIO_LIBRARIES)
if (NOT WIN32)
include(UsePkgConfig)
pkgconfig(gio-2.0 _LibGIOIncDir _LibGIOLinkDir _LibGIOLinkFlags _LibGIOCflags)
endif(NOT WIN32)
MESSAGE(STATUS "gio include dir: ${_LibGIOIncDir}")
# first try without default paths to respect PKG_CONFIG_PATH
find_path(GIO_MAIN_INCLUDE_DIR glib.h
PATH_SUFFIXES glib-2.0
PATHS ${_LibGIOIncDir}
NO_DEFAULT_PATH)
find_path(GIO_MAIN_INCLUDE_DIR glib.h
PATH_SUFFIXES glib-2.0
PATHS ${_LibGIOIncDir} )
MESSAGE(STATUS "found gio main include dir: ${GIO_MAIN_INCLUDE_DIR}")
# search the glibconfig.h include dir under the same root where the library is found
find_library(GIO_LIBRARIES
NAMES gio-2.0
PATHS ${_LibGIOLinkDir}
NO_DEFAULT_PATH)
find_library(GIO_LIBRARIES
NAMES gio-2.0
PATHS ${_LibGIOLinkDir})
get_filename_component(GIOLibDir "${GIO_LIBRARIES}" PATH)
find_path(GIO_INTERNAL_INCLUDE_DIR glibconfig.h
PATH_SUFFIXES glib-2.0/include
PATHS ${_LibGIOIncDir} "${GIOLibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH}
NO_DEFAULT_PATH)
find_path(GIO_INTERNAL_INCLUDE_DIR glibconfig.h
PATH_SUFFIXES glib-2.0/include
PATHS ${_LibGIOIncDir} "${GIOLibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH})
set(GIO_INCLUDE_DIR "${GIO_MAIN_INCLUDE_DIR}")
# not sure if this include dir is optional or required
# for now it is optional
if(GIO_INTERNAL_INCLUDE_DIR)
set(GIO_INCLUDE_DIR ${GIO_INCLUDE_DIR} "${GIO_INTERNAL_INCLUDE_DIR}")
endif(GIO_INTERNAL_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GIO DEFAULT_MSG GIO_LIBRARIES GIO_MAIN_INCLUDE_DIR)
mark_as_advanced(GIO_INCLUDE_DIR GIO_LIBRARIES)

@ -0,0 +1,55 @@
# - Try to find the GLIB2 libraries
# Once done this will define
#
# GLIB2_FOUND - system has glib2
# GLIB2_INCLUDE_DIR - the glib2 include directory
# GLIB2_LIBRARIES - glib2 library
# Copyright (c) 2008 Laurent Montel, <montel@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
# Already in cache, be silent
set(GLIB2_FIND_QUIETLY TRUE)
endif(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
if (NOT WIN32)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(PC_LibGLIB2 glib-2.0)
endif (PKG_CONFIG_FOUND)
endif(NOT WIN32)
if (PC_LibGLIB2_INCLUDEDIR)
set(GLIB2_MAIN_INCLUDE_DIR ${PC_LibGLIB2_INCLUDEDIR})
else (PC_LibGLIB2_INCLUDEDIR)
find_path(GLIB2_MAIN_INCLUDE_DIR NAMES glib.h PATH_SUFFIXES glib-2.0)
endif (PC_LibGLIB2_INCLUDEDIR)
# search the glibconfig.h include dir under the same root where the library is found
find_library(GLIB2_LIBRARIES
NAMES glib-2.0
HINTS ${PC_LibGLIB2_LIBDIR}
)
get_filename_component(glib2LibDir "${GLIB2_LIBRARIES}" PATH)
find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h
PATH_SUFFIXES glib-2.0/include
HINTS ${PC_LibGLIB2_INCLUDEDIR} "${glib2LibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH})
set(GLIB2_INCLUDE_DIR "${GLIB2_MAIN_INCLUDE_DIR}")
# not sure if this include dir is optional or required
# for now it is optional
if(GLIB2_INTERNAL_INCLUDE_DIR)
set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR} "${GLIB2_INTERNAL_INCLUDE_DIR}")
endif(GLIB2_INTERNAL_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_MAIN_INCLUDE_DIR)
mark_as_advanced(GLIB2_INCLUDE_DIR GLIB2_LIBRARIES)

@ -0,0 +1,75 @@
# - Try to find GObject
# Once done this will define
#
# GOBJECT_FOUND - system has GObject
# GOBJECT_INCLUDE_DIR - the GObject include directory
# GOBJECT_LIBRARIES - the libraries needed to use GObject
# GOBJECT_DEFINITIONS - Compiler switches required for using GObject
# Copyright (c) 2008 Helio Chissini de Castro, <helio@kde.org>
# (c)2006, Tim Beaulen <tbscope@gmail.com>
IF (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
# in cache already
SET(GObject_FIND_QUIETLY TRUE)
ELSE (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
SET(GObject_FIND_QUIETLY FALSE)
ENDIF (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
IF (NOT WIN32)
FIND_PACKAGE(PkgConfig)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
PKG_CHECK_MODULES(PKG_GOBJECT2 gobject-2.0)
SET(GOBJECT_DEFINITIONS ${PKG_GOBJECT2_CFLAGS})
ENDIF (NOT WIN32)
FIND_PATH(GOBJECT_INCLUDE_DIR gobject/gobject.h
PATHS
${PKG_GOBJECT2_INCLUDE_DIRS}
/usr/include/glib-2.0/
PATH_SUFFIXES glib-2.0
)
FIND_LIBRARY(_GObjectLibs NAMES gobject-2.0
PATHS
${PKG_GOBJECT2_LIBRARY_DIRS}
)
FIND_LIBRARY(_GModuleLibs NAMES gmodule-2.0
PATHS
${PKG_GOBJECT2_LIBRARY_DIRS}
)
FIND_LIBRARY(_GThreadLibs NAMES gthread-2.0
PATHS
${PKG_GOBJECT2_LIBRARY_DIRS}
)
FIND_LIBRARY(_GLibs NAMES glib-2.0
PATHS
${PKG_GOBJECT2_LIBRARY_DIRS}
)
IF (WIN32)
SET (GOBJECT_LIBRARIES ${_GObjectLibs} ${_GModuleLibs} ${_GThreadLibs} ${_GLibs})
ELSE (WIN32)
SET (GOBJECT_LIBRARIES ${PKG_GOBJECT2_LIBRARIES})
ENDIF (WIN32)
IF (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
SET(GOBJECT_FOUND TRUE)
ELSE (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
SET(GOBJECT_FOUND FALSE)
ENDIF (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
IF (GOBJECT_FOUND)
IF (NOT GObject_FIND_QUIETLY)
MESSAGE(STATUS "Found GObject libraries: ${GOBJECT_LIBRARIES}")
MESSAGE(STATUS "Found GObject includes : ${GOBJECT_INCLUDE_DIR}")
ENDIF (NOT GObject_FIND_QUIETLY)
ELSE (GOBJECT_FOUND)
IF (GObject_FIND_REQUIRED)
MESSAGE(STATUS "Could NOT find GObject")
ENDIF(GObject_FIND_REQUIRED)
ENDIF (GOBJECT_FOUND)
MARK_AS_ADVANCED(GOBJECT_INCLUDE_DIR GOBJECT_LIBRARIES)

@ -0,0 +1,75 @@
# - Try to find Polkit
# Once done this will define
#
# POLKIT_FOUND - system has Polkit
# POLKIT_INCLUDE_DIRS - Polkit's include directories
# POLKIT_AGENT_INCLUDE_DIRS - Polkit-agent's include directories
# POLKIT_LIBRARIES - Link this to use polkit's gobject library
# POLKIT_AGENT_LIBRARY - Link this to use the agent wrapper in polkit
# POLKIT_DEFINITIONS - Compiler switches required for using Polkit
# Copyright (c) 2009, Dario Freddi, <drf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if (POLKIT_INCLUDE_DIR AND POLKIT_LIB)
set(POLKIT_FIND_QUIETLY TRUE)
endif (POLKIT_INCLUDE_DIR AND POLKIT_LIB)
if (NOT WIN32)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
find_package(PkgConfig)
pkg_check_modules(PC_POLKIT polkit-gobject-1)
pkg_check_modules(PC_POLKIT_AGENT polkit-agent-1)
set(POLKIT_DEFINITIONS ${PC_POLKIT_CFLAGS_OTHER})
endif (NOT WIN32)
# We must include glib paths too... which sucks balls
find_package(GLIB2)
find_path( GLIB_CONFIG_INCLUDE_DIR
NAMES glibconfig.h
PATH_SUFFIXES glib-2.0/include
HINTS ${PC_POLKIT_INCLUDE_DIRS}
)
find_path( POLKIT_INCLUDE_DIR
NAMES polkit/polkit.h
PATH_SUFFIXES polkit-1
HINTS ${PC_POLKIT_INCLUDE_DIRS}
)
find_path( POLKIT_AGENT_INCLUDE_DIR
NAMES polkitagent/polkitagent.h
PATH_SUFFIXES polkit-1
HINTS ${PC_POLKIT_AGENT_INCLUDE_DIRS}
)
#set(POLKIT_INCLUDE_DIRS ${GLIB2_INCLUDE_DIR} ${_POLKIT_INCLUDE_DIR})
#set(POLKIT_AGENT_INCLUDE_DIRS ${GLIB2_INCLUDE_DIR} ${_POLKIT_AGENT_INCLUDE_DIR})
find_library( POLKIT_LIBRARIES
NAMES polkit-gobject-1
HINTS ${PC_POLKIT_LIBDIR}
)
find_library( POLKIT_AGENT_LIBRARY
NAMES polkit-agent-1
HINTS ${PC_POLKIT_AGENT_LIBDIR}
)
#set(POLKIT_LIBRARIES ${_POLKIT_LIBRARIES} ${GLIB2_LIBRARIES})
#set(POLKIT_AGENT_LIBRARY ${_POLKIT_AGENT_LIBRARY} ${GLIB2_LIBRARIES})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set POLKIT_FOUND to TRUE if
# all listed variables are TRUE
find_package_handle_standard_args(Polkit DEFAULT_MSG POLKIT_LIBRARIES POLKIT_AGENT_LIBRARY
POLKIT_INCLUDE_DIR POLKIT_AGENT_INCLUDE_DIR GLIB2_FOUND)
mark_as_advanced(POLKIT_INCLUDE_DIRS POLKIT_AGENT_INCLUDE_DIRS POLKIT_LIBRARIES POLKIT_AGENT_LIBRARY GLIB_INCLUDE_DIR)
set(POLKIT_POLICY_FILES_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/polkit-1/actions)

@ -0,0 +1,37 @@
# - Try to find PolkitQt-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
#
# The minimum required version of PolkitQt-1 can be specified using the
# standard syntax, e.g. find_package(PolkitQt-1 1.0)
# Copyright (c) 2010, Dario Freddi, <drf@kde.org>
#
# 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 PolkitQt-1_FIND_VERSION AND POLKITQT-1_MIN_VERSION )
set ( PolkitQt-1_FIND_VERSION ${POLKITQT-1_MIN_VERSION} )
endif ( NOT PolkitQt-1_FIND_VERSION AND POLKITQT-1_MIN_VERSION )
set( _PolkitQt-1_FIND_QUIETLY ${PolkitQt-1_FIND_QUIETLY} )
find_package( PolkitQt-1 ${PolkitQt-1_FIND_VERSION} QUIET NO_MODULE PATHS ${LIB_INSTALL_DIR}/PolkitQt-1/cmake )
set( PolkitQt-1_FIND_QUIETLY ${_PolkitQt-1_FIND_QUIETLY} )
include( FindPackageHandleStandardArgs )
find_package_handle_standard_args( PolkitQt-1 DEFAULT_MSG PolkitQt-1_CONFIG )
if (POLKITQT-1_FOUND)
if (NOT POLKITQT-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)

@ -0,0 +1,136 @@
# Copyright (c) 2008 Kevin Krammer <kevin.krammer@gmx.at>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
if (WIN32)
# use relative install prefix to avoid hardcoded install paths in cmake_install.cmake files
set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" ) # The subdirectory relative to the install prefix where libraries will be installed (default is ${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX})
set(EXEC_INSTALL_PREFIX "" ) # Base directory for executables and libraries
set(SHARE_INSTALL_PREFIX "share" ) # Base directory for files which go to share/
set(BIN_INSTALL_DIR "bin" ) # The install dir for executables (default ${EXEC_INSTALL_PREFIX}/bin)
set(SBIN_INSTALL_DIR "sbin" ) # The install dir for system executables (default ${EXEC_INSTALL_PREFIX}/sbin)
set(LIBEXEC_INSTALL_DIR "${BIN_INSTALL_DIR}" ) # The subdirectory relative to the install prefix where libraries will be installed (default is ${BIN_INSTALL_DIR})
set(INCLUDE_INSTALL_DIR "include" ) # The subdirectory to the header prefix
set(PLUGIN_INSTALL_DIR "lib${LIB_SUFFIX}/kde4" ) # "The subdirectory relative to the install prefix where plugins will be installed (default is ${LIB_INSTALL_DIR}/kde4)
set(CONFIG_INSTALL_DIR "share/config" ) # The config file install dir
set(DATA_INSTALL_DIR "share/apps" ) # The parent directory where applications can install their data
set(HTML_INSTALL_DIR "share/doc/HTML" ) # The HTML install dir for documentation
set(ICON_INSTALL_DIR "share/icons" ) # The icon install dir (default ${SHARE_INSTALL_PREFIX}/share/icons/)
set(KCFG_INSTALL_DIR "share/config.kcfg" ) # The install dir for kconfig files
set(LOCALE_INSTALL_DIR "share/locale" ) # The install dir for translations
set(MIME_INSTALL_DIR "share/mimelnk" ) # The install dir for the mimetype desktop files
set(SERVICES_INSTALL_DIR "share/kde4/services" ) # The install dir for service (desktop, protocol, ...) files
set(SERVICETYPES_INSTALL_DIR "share/kde4/servicetypes" ) # The install dir for servicestypes desktop files
set(SOUND_INSTALL_DIR "share/sounds" ) # The install dir for sound files
set(TEMPLATES_INSTALL_DIR "share/templates" ) # The install dir for templates (Create new file...)
set(WALLPAPER_INSTALL_DIR "share/wallpapers" ) # The install dir for wallpapers
set(DEMO_INSTALL_DIR "share/demos" ) # The install dir for demos
set(KCONF_UPDATE_INSTALL_DIR "share/apps/kconf_update" ) # The kconf_update install dir
set(AUTOSTART_INSTALL_DIR "share/autostart" ) # The install dir for autostart files
set(XDG_APPS_INSTALL_DIR "share/applications/kde4" ) # The XDG apps dir
set(XDG_DIRECTORY_INSTALL_DIR "share/desktop-directories" ) # The XDG directory
set(XDG_MIME_INSTALL_DIR "share/mime/packages" ) # The install dir for the xdg mimetypes
set(SYSCONF_INSTALL_DIR "etc" ) # The kde sysconfig install dir (default /etc)
set(MAN_INSTALL_DIR "share/man" ) # The kde man install dir (default ${SHARE_INSTALL_PREFIX}/man/)
set(INFO_INSTALL_DIR "share/info" ) # The kde info install dir (default ${SHARE_INSTALL_PREFIX}/info)")
set(DBUS_INTERFACES_INSTALL_DIR "share/dbus-1/interfaces" ) # The kde dbus interfaces install dir (default ${SHARE_INSTALL_PREFIX}/dbus-1/interfaces)")
set(DBUS_SERVICES_INSTALL_DIR "share/dbus-1/services" ) # The kde dbus services install dir (default ${SHARE_INSTALL_PREFIX}/dbus-1/services)")
else (WIN32)
# this macro implements some very special logic how to deal with the cache
# by default the various install locations inherit their value from theit "parent" variable
# so if you set CMAKE_INSTALL_PREFIX, then EXEC_INSTALL_PREFIX, PLUGIN_INSTALL_DIR will
# calculate their value by appending subdirs to CMAKE_INSTALL_PREFIX
# this would work completely without using the cache.
# but if somebody wants e.g. a different EXEC_INSTALL_PREFIX this value has to go into
# the cache, otherwise it will be forgotten on the next cmake run.
# Once a variable is in the cache, it doesn't depend on its "parent" variables
# anymore and you can only change it by editing it directly.
# this macro helps in this regard, because as long as you don't set one of the
# variables explicitely to some location, it will always calculate its value from its
# parents. So modifying CMAKE_INSTALL_PREFIX later on will have the desired effect.
# But once you decide to set e.g. EXEC_INSTALL_PREFIX to some special location
# this will go into the cache and it will no longer depend on CMAKE_INSTALL_PREFIX.
macro(_SET_FANCY _var _value _comment)
set(predefinedvalue "${_value}")
if (NOT DEFINED ${_var})
set(${_var} ${predefinedvalue})
else (NOT DEFINED ${_var})
set(${_var} "${${_var}}" CACHE PATH "${_comment}")
endif (NOT DEFINED ${_var})
endmacro(_SET_FANCY)
_set_fancy(EXEC_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" "Base directory for executables and libraries")
_set_fancy(SHARE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share" "Base directory for files which go to share/")
_set_fancy(BIN_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/bin" "The install dir for executables (default ${EXEC_INSTALL_PREFIX}/bin)")
_set_fancy(SBIN_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/sbin" "The install dir for system executables (default ${EXEC_INSTALL_PREFIX}/sbin)")
_set_fancy(LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX}" "The subdirectory relative to the install prefix where libraries will be installed (default is ${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX})")
_set_fancy(LIBEXEC_INSTALL_DIR "${LIB_INSTALL_DIR}/kde4/libexec" "The subdirectory relative to the install prefix where libraries will be installed (default is ${LIB_INSTALL_DIR}/kde4/libexec)")
_set_fancy(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" "The subdirectory to the header prefix")
_set_fancy(PLUGIN_INSTALL_DIR "${LIB_INSTALL_DIR}/kde4" "The subdirectory relative to the install prefix where plugins will be installed (default is ${LIB_INSTALL_DIR}/kde4)")
_set_fancy(CONFIG_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/config" "The config file install dir")
_set_fancy(DATA_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/apps" "The parent directory where applications can install their data")
_set_fancy(HTML_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/doc/HTML" "The HTML install dir for documentation")
_set_fancy(ICON_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/icons" "The icon install dir (default ${SHARE_INSTALL_PREFIX}/share/icons/)")
_set_fancy(KCFG_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/config.kcfg" "The install dir for kconfig files")
_set_fancy(LOCALE_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/locale" "The install dir for translations")
_set_fancy(MIME_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/mimelnk" "The install dir for the mimetype desktop files")
_set_fancy(SERVICES_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/kde4/services" "The install dir for service (desktop, protocol, ...) files")
_set_fancy(SERVICETYPES_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/kde4/servicetypes" "The install dir for servicestypes desktop files")
_set_fancy(SOUND_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/sounds" "The install dir for sound files")
_set_fancy(TEMPLATES_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/templates" "The install dir for templates (Create new file...)")
_set_fancy(WALLPAPER_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/wallpapers" "The install dir for wallpapers")
_set_fancy(DEMO_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/demos" "The install dir for demos")
_set_fancy(KCONF_UPDATE_INSTALL_DIR "${DATA_INSTALL_DIR}/kconf_update" "The kconf_update install dir")
_set_fancy(AUTOSTART_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/autostart" "The install dir for autostart files")
_set_fancy(XDG_APPS_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/applications/kde4" "The XDG apps dir")
_set_fancy(XDG_DIRECTORY_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/desktop-directories" "The XDG directory")
_set_fancy(XDG_MIME_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/mime/packages" "The install dir for the xdg mimetypes")
_set_fancy(SYSCONF_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/etc" "The kde sysconfig install dir (default ${CMAKE_INSTALL_PREFIX}/etc)")
_set_fancy(MAN_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/man" "The kde man install dir (default ${SHARE_INSTALL_PREFIX}/man/)")
_set_fancy(INFO_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/info" "The kde info install dir (default ${SHARE_INSTALL_PREFIX}/info)")
_set_fancy(DBUS_INTERFACES_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/dbus-1/interfaces" "The kde dbus interfaces install dir (default ${SHARE_INSTALL_PREFIX}/dbus-1/interfaces)")
_set_fancy(DBUS_SERVICES_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/dbus-1/services" "The kde dbus services install dir (default ${SHARE_INSTALL_PREFIX}/dbus-1/services)")
endif (WIN32)
# The INSTALL_TARGETS_DEFAULT_ARGS variable should be used when libraries are installed.
# The arguments are also ok for regular executables, i.e. executables which don't go
# into sbin/ or libexec/, but for installing executables the basic syntax
# INSTALL(TARGETS kate DESTINATION "${BIN_INSTALL_DIR}")
# is enough, so using this variable there doesn't help a lot.
# The variable must not be used for installing plugins.
# Usage is like this:
# install(TARGETS kdecore kdeui ${INSTALL_TARGETS_DEFAULT_ARGS} )
#
# This will install libraries correctly under UNIX, OSX and Windows (i.e. dll's go
# into bin/.
# Later on it will be possible to extend this for installing OSX frameworks
# The COMPONENT Devel argument has the effect that static libraries belong to the
# "Devel" install component. If we use this also for all install() commands
# for header files, it will be possible to install
# -everything: make install OR cmake -P cmake_install.cmake
# -only the development files: cmake -DCOMPONENT=Devel -P cmake_install.cmake
# -everything except the development files: cmake -DCOMPONENT=Unspecified -P cmake_install.cmake
# This can then also be used for packaging with cpack.
set(INSTALL_TARGETS_DEFAULT_ARGS RUNTIME DESTINATION "${BIN_INSTALL_DIR}"
LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
ARCHIVE DESTINATION "${LIB_INSTALL_DIR}" COMPONENT Devel )

@ -0,0 +1,47 @@
# this module defines two macros:
# MACRO_PUSH_REQUIRED_VARS()
# and
# MACRO_POP_REQUIRED_VARS()
# use these if you call cmake macros which use
# any of the CMAKE_REQUIRED_XXX variables
#
# Usage:
# MACRO_PUSH_REQUIRED_VARS()
# SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -DSOME_MORE_DEF)
# CHECK_FUNCTION_EXISTS(...)
# MACRO_POP_REQUIRED_VARS()
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
MACRO(MACRO_PUSH_REQUIRED_VARS)
IF(NOT DEFINED _PUSH_REQUIRED_VARS_COUNTER)
SET(_PUSH_REQUIRED_VARS_COUNTER 0)
ENDIF(NOT DEFINED _PUSH_REQUIRED_VARS_COUNTER)
MATH(EXPR _PUSH_REQUIRED_VARS_COUNTER "${_PUSH_REQUIRED_VARS_COUNTER}+1")
SET(_CMAKE_REQUIRED_INCLUDES_SAVE_${_PUSH_REQUIRED_VARS_COUNTER} ${CMAKE_REQUIRED_INCLUDES})
SET(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_PUSH_REQUIRED_VARS_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS})
SET(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_PUSH_REQUIRED_VARS_COUNTER} ${CMAKE_REQUIRED_LIBRARIES})
SET(_CMAKE_REQUIRED_FLAGS_SAVE_${_PUSH_REQUIRED_VARS_COUNTER} ${CMAKE_REQUIRED_FLAGS})
ENDMACRO(MACRO_PUSH_REQUIRED_VARS)
MACRO(MACRO_POP_REQUIRED_VARS)
# don't pop more than we pushed
IF("${_PUSH_REQUIRED_VARS_COUNTER}" GREATER "0")
SET(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_PUSH_REQUIRED_VARS_COUNTER}})
SET(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_PUSH_REQUIRED_VARS_COUNTER}})
SET(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_PUSH_REQUIRED_VARS_COUNTER}})
SET(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_PUSH_REQUIRED_VARS_COUNTER}})
MATH(EXPR _PUSH_REQUIRED_VARS_COUNTER "${_PUSH_REQUIRED_VARS_COUNTER}-1")
ENDIF("${_PUSH_REQUIRED_VARS_COUNTER}" GREATER "0")
ENDMACRO(MACRO_POP_REQUIRED_VARS)

@ -0,0 +1,22 @@
# MACRO_WRITE_BASIC_CMAKE_VERSION_FILE( _filename _major _minor _patch)
# Writes a file for use as <package>ConfigVersion.cmake file to <_filename>.
# See the documentation of FIND_PACKAGE() for details on this.
# _filename is the output filename, it should be in the build tree.
# _major is the major version number of the project to be installed
# _minor is the minor version number of the project to be installed
# _patch is the patch version number of the project to be installed
#
# Copyright (c) 2008, Alexander Neundorf, <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
get_filename_component(_currentListFileDir ${CMAKE_CURRENT_LIST_FILE} PATH)
function(MACRO_WRITE_BASIC_CMAKE_VERSION_FILE _filename _major _minor _patch)
set(PROJECT_VERSION_MAJOR ${_major})
set(PROJECT_VERSION_MINOR ${_minor})
set(PROJECT_VERSION_PATCH ${_patch})
configure_file(${_currentListFileDir}/BasicFindPackageVersion.cmake.in "${_filename}" @ONLY)
endfunction(MACRO_WRITE_BASIC_CMAKE_VERSION_FILE _major _minor _patch)

@ -0,0 +1,16 @@
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_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_IGNORE_FILES "/\\\\.svn/" "/\\\\.git/" "makechangelog")
set(ARCHIVE_NAME ${CPACK_PACKAGE_NAME}-${POLKITQT-1_VERSION_STRING})
add_custom_target(dist
COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
| bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
include(CPack) # needs to happen after the above variables are set

@ -0,0 +1,31 @@
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${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
)
automoc4_add_library(polkit-qt-core-1 SHARED ${polkit_qt_core_SRCS})
target_link_libraries(polkit-qt-core-1
${QT_QTCORE_LIBRARY}
${QT_QTDBUS_LIBRARY}
${QT_QTXML_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)
install(TARGETS polkit-qt-core-1 ${INSTALL_TARGETS_DEFAULT_ARGS})

@ -0,0 +1,148 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
* Copyright (C) 2010 Dario Freddi <drf@kde.org>
*
* 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 <QtCore/QString>
#include <polkit/polkit.h>
namespace PolkitQt1
{
class ActionDescription::Data : public QSharedData
{
public:
Data() {}
Data(const Data& other)
: QSharedData(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() {}
QString actionId;
QString description;
QString message;
QString vendorName;
QString vendorUrl;
QString 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 = QString::fromUtf8(polkit_action_description_get_action_id(polkitActionDescription));
d->description = QString::fromUtf8(polkit_action_description_get_description(polkitActionDescription));
d->message = QString::fromUtf8(polkit_action_description_get_message(polkitActionDescription));
d->vendorName = QString::fromUtf8(polkit_action_description_get_vendor_name(polkitActionDescription));
d->vendorUrl = QString::fromUtf8(polkit_action_description_get_vendor_url(polkitActionDescription));
d->iconName = QString::fromUtf8(polkit_action_description_get_icon_name(polkitActionDescription));
d->implicitAny = static_cast<ActionDescription::ImplicitAuthorization>(polkit_action_description_get_implicit_any(
polkitActionDescription));
d->implicitInactive = static_cast<ActionDescription::ImplicitAuthorization>(polkit_action_description_get_implicit_inactive(
polkitActionDescription));
d->implicitActive = static_cast<ActionDescription::ImplicitAuthorization>(polkit_action_description_get_implicit_active(
polkitActionDescription));
}
ActionDescription::ActionDescription(const PolkitQt1::ActionDescription& other)
: d(other.d)
{
}
ActionDescription& ActionDescription::operator=(const PolkitQt1::ActionDescription& other)
{
d = other.d;
return *this;
}
ActionDescription::~ActionDescription()
{
}
QString ActionDescription::actionId() const
{
return d->actionId;
}
QString ActionDescription::description() const
{
return d->description;
}
QString ActionDescription::message() const
{
return d->message;
}
QString ActionDescription::vendorName() const
{
return d->vendorName;
}
QString ActionDescription::vendorUrl() const
{
return d->vendorUrl;
}
QString 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;
}
}

@ -0,0 +1,149 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
* Copyright (C) 2010 Dario Freddi <drf@kde.org>
*
* 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 <QtCore/QList>
#include <QtCore/QMetaType>
#include <QtCore/QSharedData>
typedef struct _PolkitActionDescription PolkitActionDescription;
namespace PolkitQt1
{
/**
* \class ActionDescription polkitqt1-actiondescription.h ActionDescription
* \author Jaroslav Reznik <jreznik@redhat.com>
* \author Dario Freddi <drf@kde.org>
*
* \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 QList< 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
*/
QString actionId() const;
/**
* \brief Gets the description used of ActionDescription
*
* \return description of the action
*/
QString description() const;
/**
* \brief Gets the message user for ActionDescription
*
* \return action message
*/
QString message() const;
/**
* \brief Gets the vendor name for ActionDescription, if any
*
* \return vendor name
*/
QString vendorName() const;
/**
* \brief Gets the vendor URL for ActionDescription, if any
*
* \return vendor URL or empty QString if there is no vendor URL
*/
QString vendorUrl() const;
/**
* \brief Gets the icon name for ActionDescription, if any
*
* \return icon name or empty QString if there is no icon
*/
QString 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;
QSharedDataPointer< Data > d;
};
}
Q_DECLARE_METATYPE(PolkitQt1::ActionDescription::List)
#endif //POLKIT_QT_ACTION_DESCRIPTION_H

@ -0,0 +1,855 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
* Copyright (C) 2009 Dario Freddi <drf@kde.org>
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
* Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com>
*
* 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 <QtDBus/QDBusInterface>
#include <QtDBus/QDBusReply>
#include <polkit/polkit.h>
namespace PolkitQt1
{
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<PolkitActionDescription *>(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 QString &details = QString(), bool recover = false);
void dbusFilter(const QDBusMessage &message);
void dbusSignalAdd(const QString &service, const QString &path, const QString &interface, const QString &name);
void seatSignalsConnect(const QString &seat);
Authority *q;
PolkitAuthority *pkAuthority;
bool m_hasError;
Authority::ErrorCode m_lastError;
QString m_errorDetails;
QDBusConnection *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, QObject *parent)
: QObject(parent)
, d(new Private(this))
{
qRegisterMetaType<PolkitQt1::Authority::Result> ();
qRegisterMetaType<PolkitQt1::ActionDescription::List>();
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()
{
QDBusError error;
QDBusError 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");
QString consoleKitService("org.freedesktop.ConsoleKit");
QString consoleKitManagerPath("/org/freedesktop/ConsoleKit/Manager");
QString consoleKitManagerInterface("org.freedesktop.ConsoleKit.Manager");
QString 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
QDBusMessage msg = QDBusMessage::createMethodCall(consoleKitService, consoleKitManagerPath, consoleKitManagerInterface, "GetSeats");
msg = QDBusConnection::systemBus().call(msg);
if (!msg.arguments().isEmpty()) {
// this method returns a list with present seats
QList<QString> seats;
qVariantValue<QDBusArgument> (msg.arguments()[0]) >> seats;
// it can be multiple seats present so connect all their signals
Q_FOREACH(const QString &seat, seats) {
seatSignalsConnect(seat);
}
}
}
void Authority::Private::setError(Authority::ErrorCode code, const QString &details, bool recover)
{
if (recover) {
init();
}
m_lastError = code;
m_errorDetails = details;
m_hasError = true;
}
void Authority::Private::seatSignalsConnect(const QString &seat)
{
QString consoleKitService("org.freedesktop.ConsoleKit");
QString 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 QString &service, const QString &path, const QString &interface, const QString &name)
{
// FIXME: This code seems to be nonfunctional - it needs to be fixed somewhere (is it Qt BUG?)
QDBusConnection::systemBus().connect(service, path, interface, name,
q, SLOT(dbusFilter(const QDBusMessage &)));
}
void Authority::Private::dbusFilter(const QDBusMessage &message)
{
if (message.type() == QDBusMessage::SignalMessage) {
Q_EMIT q->consoleKitDBChanged();
// TODO: Test this with the multiseat support
if (message.member() == "SeatAdded") {
seatSignalsConnect(qVariantValue<QDBusObjectPath> (message.arguments()[0]).path());
}
}
}
bool Authority::hasError() const
{
return d->m_hasError;
}
Authority::ErrorCode Authority::lastError() const
{
return d->m_lastError;
}
const QString Authority::errorDetails() const
{
if (d->m_lastError == E_None) {
return QString();
} 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 QString &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 QString &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 QString &locale, const QString &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 QString &locale, const QString &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 QString &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 QString &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 QString &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 QString &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 QString &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 QString &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"

@ -0,0 +1,539 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
* Copyright (C) 2009 Dario Freddi <drf@kde.org>
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
* Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com>
*
* 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 <QtCore/QObject>
#include <QtCore/QMetaType>
typedef struct _PolkitAuthority PolkitAuthority;
class QStringList;
/**
* \namespace PolkitQt1 PolkitQt
*
* \brief Namespace wrapping Polkit-Qt classes
*
* This namespace wraps all Polkit-Qt classes.
*/
namespace PolkitQt1
{
/**
* \class Authority polkitqt1-authority.h Authority
* \author Daniel Nicoletti <dantti85-pk@yahoo.com.br>
* \author Dario Freddi <drf@kde.org>
* \author Jaroslav Reznik <jreznik@redhat.com>
*
* \brief Convenience class for Qt/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 QObject
{
Q_OBJECT
Q_DISABLE_COPY(Authority)
Q_ENUMS(Result)
Q_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 QString 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 QString &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 QString &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 QString &locale,
const QString &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 QString &locale,
const QString &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 QString &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 QString &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 QString &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 QString& cookie, const PolkitQt1::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 QString &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 QString &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(PolkitQt1::Authority::Result);
/**
* This signal is emitted when asynchronous method enumerateActions finishes.
*
* The argument is the list of all Action IDs.
*/
void enumerateActionsFinished(PolkitQt1::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(PolkitQt1::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, QObject *parent = 0);
class Private;
friend class Private;
Private * const d;
Q_PRIVATE_SLOT(d, void dbusFilter(const QDBusMessage &message))
};
}
Q_DECLARE_OPERATORS_FOR_FLAGS(PolkitQt1::Authority::AuthorizationFlags)
Q_DECLARE_METATYPE(PolkitQt1::Authority::Result)
#endif

@ -0,0 +1,99 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com>
*
* 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 <QtCore/QStringList>
#include <polkit/polkit.h>
namespace PolkitQt1
{
class Details::Data : public QSharedData
{
public:
Data() {}
Data(const Data &other)
: QSharedData(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 PolkitQt1::Details& other)
{
d = other.d;
return *this;
}
QString Details::lookup(const QString &key) const
{
const gchar *result = polkit_details_lookup(d->polkitDetails, key.toUtf8().data());
if (result != NULL) {
return QString::fromUtf8(result);
} else {
return QString();
}
}
void Details::insert(const QString &key, const QString &value)
{
polkit_details_insert(d->polkitDetails, key.toUtf8().data(), value.toUtf8().data());
}
QStringList Details::keys() const
{
gchar **result = polkit_details_get_keys(d->polkitDetails);
QStringList list;
int len = g_strv_length(result);
for (int i = 0; i < len; i++) {
list.append(QString::fromUtf8(result[i]));
}
g_strfreev(result);
return list;
}
}

@ -0,0 +1,97 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com>
*
* 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 <QtCore/QObject>
#include <QtCore/QSharedData>
typedef struct _PolkitDetails PolkitDetails;
/**
* \namespace PolkitQt1 PolkitQt
*
* \brief Namespace wrapping Polkit-Qt classes
*
* This namespace wraps all Polkit-Qt classes.
*/
namespace PolkitQt1
{
/**
* \class Details polkitqt1-details.h Details
* \author Radek Novacek <rnovacek@redhat.com>
*
* \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 QString.
*/
QString lookup(const QString &key) const;
/**
* Inserts key \p key with value \p value.
*
* \param key A key.
* \param value A value.
*/
void insert(const QString &key, const QString &value);
/**
* Gets a list of all keys.
*
* \return List of all keys.
*/
QStringList keys() const;
private:
class Data;
QExplicitlySharedDataPointer< Data > d;
};
}
#endif // DETAILS_H

@ -0,0 +1,227 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Lukas Tinkl <ltinkl@redhat.com>
*
* 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 <polkit/polkit.h>
#include <QtCore/QDebug>
namespace PolkitQt1
{
class Identity::Data : public QSharedData
{
public:
Data() : identity(0) {}
Data(const Data& other)
: QSharedData(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 PolkitQt1::Identity& other)
: d(other.d)
{
}
Identity::~Identity()
{
}
Identity& Identity::operator=(const PolkitQt1::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);
}
}
QString Identity::toString() const
{
Q_ASSERT(d->identity);
return QString::fromUtf8(polkit_identity_to_string(d->identity));
}
Identity Identity::fromString(const QString &string)
{
GError *error = NULL;
PolkitIdentity *pkIdentity = polkit_identity_from_string(string.toUtf8().data(), &error);
if (error != NULL) {
qWarning() << QString("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 QString &name)
: Identity()
{
GError *error = NULL;
setIdentity(polkit_unix_user_new_for_name(name.toUtf8().data(), &error));
if (error != NULL) {
qWarning() << QString("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 QString &name)
: Identity()
{
GError *error = NULL;
setIdentity(polkit_unix_group_new_for_name(name.toUtf8().data(), &error));
if (error != NULL) {
qWarning() << QString("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);
}
}

@ -0,0 +1,211 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Lukas Tinkl <ltinkl@redhat.com>
*
* 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 <unistd.h>
#include <QtCore/QObject>
#include <QtCore/QSharedData>
typedef struct _PolkitIdentity PolkitIdentity;
typedef struct _PolkitUnixUser PolkitUnixUser;
typedef struct _PolkitUnixGroup PolkitUnixGroup;
/**
* \namespace PolkitQt1 PolkitQt
*
* \brief Namespace wrapping Polkit-Qt classes
*
* This namespace wraps all Polkit-Qt classes.
*/
namespace PolkitQt1
{
class UnixUserIdentity;
class UnixGroupIdentity;
/**
* \class Identity polkitqt1-identity.h Identity
* \author Lukas Tinkl <ltinkl@redhat.com>
*
* This class encapsulates the PolkitIdentity interface.
*
* \brief Abstract class representing identities
*
* \see UnixGroup
* \see UnixUser
*/
class POLKITQT1_EXPORT Identity
{
public:
typedef QList< 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
*/
QString 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 QString &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;
QExplicitlySharedDataPointer< 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 QString &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 QString &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

@ -0,0 +1,205 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
*
* 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 <QtCore/QDebug>
#include <polkit/polkit.h>
namespace PolkitQt1
{
class Subject::Data : public QSharedData
{
public:
Data()
: QSharedData()
, subject(0)
{}
Data(const Data& other)
: QSharedData(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 PolkitQt1::Subject& other)
: d(other.d)
{
}
Subject& Subject::operator=(const PolkitQt1::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;
}
QString Subject::toString() const
{
Q_ASSERT(d->subject);
return QString::fromUtf8(polkit_subject_to_string(d->subject));
}
Subject Subject::fromString(const QString &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) {
qWarning() << QString("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, quint64 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 QString &name)
: Subject()
{
setSubject(polkit_system_bus_name_new(name.toUtf8().data()));
}
SystemBusNameSubject::SystemBusNameSubject(PolkitSystemBusName *pkSystemBusName)
: Subject((PolkitSubject *) pkSystemBusName)
{
}
QString SystemBusNameSubject::name() const
{
return QString::fromUtf8(polkit_system_bus_name_get_name((PolkitSystemBusName *) subject()));
}
void SystemBusNameSubject::setName(const QString &name)
{
polkit_system_bus_name_set_name((PolkitSystemBusName *) subject(), name.toUtf8().data());
}
// ----- SystemSession
UnixSessionSubject::UnixSessionSubject(const QString &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) {
qWarning() << QString("Cannot create unix session: %1").arg(error->message);
setSubject(NULL);
}
}
UnixSessionSubject::UnixSessionSubject(PolkitSystemBusName *pkUnixSession)
: Subject((PolkitSubject *) pkUnixSession)
{
}
QString UnixSessionSubject::sessionId() const
{
return QString::fromUtf8(polkit_unix_session_get_session_id((PolkitUnixSession *) subject()));
}
void UnixSessionSubject::setSessionId(const QString &sessionId)
{
polkit_unix_session_set_session_id((PolkitUnixSession *) subject(), sessionId.toUtf8().data());
}
}

@ -0,0 +1,262 @@
/*
* This file is part of the PolKit1-qt project
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
*
* 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 <QtCore/QObject>
#include <QtCore/QSharedData>
typedef struct _PolkitSubject PolkitSubject;
typedef struct _PolkitUnixProcess PolkitUnixProcess;
typedef struct _PolkitSystemBusName PolkitSystemBusName;
/**
* \namespace PolkitQt1 PolkitQt
*
* \brief Namespace wrapping PolicyKit-Qt classes
*
* This namespace wraps all PolicyKit-Qt classes.
*/
namespace PolkitQt1
{
/**
* \class Subject polkitqt1-subject.h Subject
* \author Jaroslav Reznik <jreznik@redhat.com>
*
* \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
*/
QString 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 QString &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;
QExplicitlySharedDataPointer< Data > d;
};
/**
* \class UnixProcessSubject polkitqt1-subject.h Subject
* \author Jaroslav Reznik <jreznik@redhat.com>
*
* \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, quint64 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 <jreznik@redhat.com>
*
* \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 QString &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.
*/
QString name() const;
/**
* Sets system bus name.
*
* \param name System bus name.
*/
void setName(const QString &name);
};
/**
* \class UnixSessionSubject polkitqt1-subject.h Subject
* \author Jaroslav Reznik <jreznik@redhat.com>
*
* \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 QString &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.
*/
QString sessionId() const;
/**
* Sets session id.
*
* \param sessionId A session id.
*/
void setSessionId(const QString &sessionId);
};
}
#endif

@ -0,0 +1,117 @@
/*
* This file is part of the PolKit1-qt project
* Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com>
*
* 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 <polkit/polkit.h>
namespace PolkitQt1
{
class TemporaryAuthorization::Data : public QSharedData
{
public:
Data() {}
Data(const Data& other)
: QSharedData(other)
, id(other.id)
, actionId(other.actionId)
, subject(other.subject)
, timeObtained(other.timeObtained)
, timeExpires(other.timeExpires)
{
}
~Data() {}
QString id;
QString actionId;
Subject subject;
QDateTime timeObtained;
QDateTime timeExpires;
};
TemporaryAuthorization::TemporaryAuthorization(PolkitTemporaryAuthorization *pkTemporaryAuthorization)
: d(new Data)
{
g_type_init();
d->id = QString::fromUtf8(polkit_temporary_authorization_get_id(pkTemporaryAuthorization));
d->actionId = QString::fromUtf8(polkit_temporary_authorization_get_action_id(pkTemporaryAuthorization));
d->subject = Subject::fromString(polkit_subject_to_string(polkit_temporary_authorization_get_subject(pkTemporaryAuthorization)));
d->timeObtained = QDateTime::fromTime_t(polkit_temporary_authorization_get_time_obtained(pkTemporaryAuthorization));
d->timeExpires = QDateTime::fromTime_t(polkit_temporary_authorization_get_time_expires(pkTemporaryAuthorization));
g_object_unref(pkTemporaryAuthorization);
}
TemporaryAuthorization::TemporaryAuthorization(const PolkitQt1::TemporaryAuthorization& other)
: d(other.d)
{
}
TemporaryAuthorization::TemporaryAuthorization()
: d(new Data)
{
}
TemporaryAuthorization& TemporaryAuthorization::operator=(const PolkitQt1::TemporaryAuthorization& other)
{
d = other.d;
return *this;
}
TemporaryAuthorization::~TemporaryAuthorization()
{
}
QString TemporaryAuthorization::id() const
{
return d->id;
}
QString TemporaryAuthorization::actionId() const
{
return d->actionId;
}
Subject TemporaryAuthorization::subject() const
{
//qFatal(polkit_subject_to_string(polkit_temporary_authorization_get_subject(d->temporaryAuthorization)));
return d->subject;//Subject::fromString(polkit_subject_to_string(d->subject));
}
QDateTime TemporaryAuthorization::obtainedAt() const
{
return d->timeObtained;
}
QDateTime TemporaryAuthorization::expirationTime() const
{
return d->timeExpires;
}
bool TemporaryAuthorization::revoke()
{
Authority::instance()->revokeTemporaryAuthorization(id());
return true;
}
}

@ -0,0 +1,124 @@
/*
* This file is part of the PolKit1-qt project
* Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com>
*
* 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 <QtCore/QObject>
#include <QtCore/QDateTime>
#include <QtCore/QMetaType>
#include <QtCore/QSharedData>
typedef struct _PolkitTemporaryAuthorization PolkitTemporaryAuthorization;
/**
* \namespace PolkitQt1 PolkitQt
*
* \brief Namespace wrapping PolicyKit-Qt classes
*
* This namespace wraps all PolicyKit-Qt classes.
*/
namespace PolkitQt1
{
/**
* \class TemporaryAuthorization polkitqt1-temporaryauthorization.h TemporaryAuthorization
* \author Radek Novacek <rnovacek@redhat.com>
*
* \brief This class represents PolicyKit temporary authorization
*
* This class encapsulates the PolkitTemporaryAuthorization interface.
*/
class POLKITQT1_EXPORT TemporaryAuthorization
{
public:
typedef QList< 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
*/
QString id() const;
/**
* \brief Gets the identifier of the action that authorization is for
*
* \return String that identifies the action
*/
QString 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
*/
QDateTime obtainedAt() const;
/**
* \brief Gets the time when authorizaton will expire
*
* \return Time of expiration
*/
QDateTime expirationTime() const;
/**
* \brief Revoke temporary authorization
*
* \return \c true Authorization has been revoked
* \c false Revoking authorization failed
*/
bool revoke();
private:
class Data;
QSharedDataPointer< Data > d;
};
}
Q_DECLARE_METATYPE(PolkitQt1::TemporaryAuthorization::List)
#endif // TEMPORARYAUTHORIZATION_H

59
debian/changelog vendored

@ -0,0 +1,59 @@
polkit-qt-1 (0.103.0-1) unstable; urgency=low
* New upstream release.
- fix annoying crash on shutdown. (Closes: #651815)
[ Felix Geyer ]
* Modify CFLAGS/CXXFLAGS after including debian-qt-kde.mk so the changes are
not overwritten.
[ Fathi Boudra ]
* Update debian/compat: bump to 8.
-- Debian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org> Wed, 14 Dec 2011 09:15:10 -0500
polkit-qt-1 (0.99.0-3) unstable; urgency=low
[ Modestas Vainius ]
* Update symbol files.
-- Debian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org> Thu, 26 May 2011 00:31:01 +0300
polkit-qt-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.
* Update symbol file: many private symbols are gone due to above.
-- Modestas Vainius <modax@debian.org> Thu, 28 Apr 2011 11:53:35 +0300
polkit-qt-1 (0.99.0-1) experimental; urgency=low
* New upstream release.
[ Modestas Vainius ]
* Add Vcs fields to debian/control.
* Switch debian/rules engine to qt-kde-team/2/*.
* 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.
* Add myself to Uploaders.
* SONAME bumped: rename libpolkit-qt-1-0 to libpolkit-qt-1-1.
* Add symbol file for libpolkit-qt-1-1.
* Update debian/copyright.
[ Didier Raboud ]
* Bump B-D of libpolkit to >= 0.98.
[ José Manuel Santamaría Lema ]
* Update installed files.
-- Modestas Vainius <modax@debian.org> Mon, 14 Mar 2011 01:03:06 +0200
polkit-qt-1 (0.95.1-1) unstable; urgency=low
* Initial release. (Closes: #565395)
-- Fathi Boudra <fabo@debian.org> Fri, 15 Jan 2010 12:50:13 +0100

1
debian/compat vendored

@ -0,0 +1 @@
8

49
debian/control vendored

@ -0,0 +1,49 @@
Source: polkit-qt-1
Priority: extra
Maintainer: Debian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>
Uploaders: Fathi Boudra <fabo@debian.org>, Modestas Vainius <modax@debian.org>
Build-Depends: automoc,
cmake,
debhelper (>= 8.0.0),
libpolkit-agent-1-dev (>= 0.98),
libpolkit-gobject-1-dev (>= 0.98),
libqt4-dev,
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
Package: libpolkit-qt-1-dev
Section: libdevel
Architecture: any
Depends: libpolkit-qt-1-1 (= ${binary:Version}), libqt4-dev, ${misc:Depends}
Description: PolicyKit-qt-1 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.
.
libpolkit-qt-1 provides convenience classes and methods for Qt/KDE
applications that want to use PolicyKit-1.
.
This package contains the development libraries and headers.
Package: libpolkit-qt-1-1
Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: PolicyKit-qt-1 library
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.
.
libpolkit-qt-1 provides convenience classes and methods for Qt/KDE
applications that want to use PolicyKit.
.
This package contains the files necessary for running applications that use
the libpolkit-qt-1 library.

96
debian/copyright vendored

@ -0,0 +1,96 @@
This work was packaged for Debian by:
Fathi Boudra <fabo@debian.org> on Fri, 15 Jan 2010 12:50:13 +0100
It was downloaded from ftp://ftp.kde.org/pub/kde/stable/apps/KDE4.x/admin/
Upstream Authors:
Daniel Nicoletti <dantti85-dev@yahoo.com.br>
Dario Freddi <drf@kde.org>
Jaroslav Reznik <jreznik@redhat.com>
Radek Novacek <rnovacek@redhat.com>
Lukas Tinkl <ltinkl@redhat.com>
Pino Toscano <pino@kde.org>
Copyright:
Copyright (C) 2008-2009 Daniel Nicoletti
Copyright (C) 2009-2010 Dario Freddi
Copyright (C) 2009 Jaroslav Reznik
Copyright (C) 2009 Radek Novacek
Copyright (C) 2009 Lukas Tinkl
Copyright for polkitqt1-export.h file:
Copyright (C) 2009 Dario Freddi <drf@kde.org>
Copyright (C) 2007 David Faure <faure@kde.org>
Copyright for polkitqt1-version.h.cmake file:
Copyright (C) 2009 Dario Freddi <drf@kde.org>
Copyright (C) 2007 Sebastian Trueg <trueg@kde.org>
Copyright for cmake/modules/FindAutomoc4.cmake file:
Copyright (C) 2008-2009 Alexander Neundorf <neundorf@kde.org>
Copyright for cmake/modules/MacroPushRequiredVars.cmake file:
Copyright (C) 2006 Alexander Neundorf <neundorf@kde.org>
Copyright for cmake/modules/InstallSettings.cmake file:
Copyright (C) 2008 Kevin Krammer <kevin.krammer@gmx.at>
License for cmake modules:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License:
This package is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This package 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this package; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
On Debian systems, the complete text of the GNU Lesser General
Public License can be found in `/usr/share/common-licenses/LGPL-2' and
`/usr/share/common-licenses/LGPL-3'.
The Debian packaging is:
Copyright (C) 2010 Fathi Boudra <fabo@debian.org>
Copyright (C) 2011 Modestas Vainius <modax@debian.org>
and is licensed under the GPL version 2 or any later version.

3
debian/docs vendored

@ -0,0 +1,3 @@
README
README.porting
TODO

@ -0,0 +1,3 @@
usr/lib/libpolkit-qt-agent-1.so.1*
usr/lib/libpolkit-qt-core-1.so.1*
usr/lib/libpolkit-qt-gui-1.so.1*

@ -0,0 +1 @@
libpolkit-qt-1-1: package-name-doesnt-match-sonames libpolkit-qt-agent-1-1 libpolkit-qt-core-1-1 libpolkit-qt-gui-1-1

@ -0,0 +1,305 @@
# 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

@ -0,0 +1,33 @@
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

13
debian/rules vendored

@ -0,0 +1,13 @@
#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
dh = --list-missing
include /usr/share/pkg-kde-tools/qt-kde-team/2/debian-qt-kde.mk
export CFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
export CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
.PHONY: override_dh_auto_test

@ -0,0 +1 @@
3.0 (quilt)

@ -0,0 +1,89 @@
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
)
set(polkit_example_SRCS
main.cpp
PkExample.cpp
)
SET(polkit_example_RESOUCES
icons/icons.qrc
)
QT4_WRAP_CPP(polkit_example_MOC_SRCS
PkExample.h
)
QT4_WRAP_UI(polkit_example_UI_SRCS
PkExample.ui
)
QT4_ADD_RESOURCES (qtsourceview_RC_SRCS ${polkit_example_RESOUCES})
add_executable(polkit-example
${polkit_example_SRCS}
${polkit_example_MOC_SRCS}
${polkit_example_UI_SRCS}
${qtsourceview_RC_SRCS}
)
target_link_libraries(polkit-example
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
polkit-qt-gui-1
polkit-qt-core-1
)
#--------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
)
qt4_add_dbus_adaptor(polkit_example_helper_SRCS
org.qt.policykit.examples.xml
PkExampleHelper.h
PkExampleHelper
)
QT4_WRAP_CPP(polkit_example_helper_MOC_SRCS
PkExampleHelper.h
)
add_executable(polkit-example-helper
${polkit_example_helper_SRCS}
${polkit_example_helper_MOC_SRCS}
)
# see our helper is pretty small :D
target_link_libraries(polkit-example-helper
${QT_QTCORE_LIBRARY}
polkit-qt-core-1
)
install(TARGETS polkit-example-helper DESTINATION ${BIN_INSTALL_DIR})
dbus_add_activation_system_service(org.qt.policykit.examples.service.in)
install(FILES org.qt.policykit.examples.conf DESTINATION ${SYSCONF_INSTALL_DIR}/dbus-1/system.d)
add_subdirectory(agent)

@ -0,0 +1,339 @@
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
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
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
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
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
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
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
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
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
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

@ -0,0 +1,240 @@
// This is an example not a library
/***************************************************************************
* Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com> *
* Copyright (C) 2008 Daniel Nicoletti <dantti85-pk@yahoo.com.br> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#include "PkExample.h"
#include "gui/polkitqt1-gui-actionbutton.h"
#include "gui/polkitqt1-gui-actionbuttons.h"
#include "core/polkitqt1-authority.h"
#include <QtCore/QDebug>
#include <QtDBus/QDBusMessage>
#include <QtDBus/QDBusConnection>
using namespace PolkitQt1;
using namespace PolkitQt1::Gui;
PkExample::PkExample(QMainWindow *parent)
: QMainWindow(parent)
{
setupUi(this);
ActionButton *bt;
// Here we create an ActionButton that is a subclass of Action
// always pass a QAbstractButton 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(QPixmap(":/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 QMenu or a QToolBar
connect(bt, SIGNAL(triggered(bool)), this, SLOT(activateAction()));
// This signal was propagated from the QAbstractButton just for
// convenience in this case we don't have any benefit but the code
// look cleaner
connect(bt, SIGNAL(clicked(QAbstractButton *, 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(QPixmap(":/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(QAbstractButton *, 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(QPixmap(":/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(QAbstractButton *, 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(QPixmap(":/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(QPixmap(":/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(QPixmap(":/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(QAbstractButton *, 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(QPixmap(":/Icons/custom-no.png"), Action::No);
bt->setIcon(QPixmap(":/Icons/action-locked-default.png"), Action::Auth);
bt->setIcon(QPixmap(":/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(QAbstractButton *, 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(QPixmap(":/Icons/custom-no.png"), Action::No);
bt->setIcon(QPixmap(":/Icons/action-locked-default.png"), Action::Auth);
bt->setIcon(QPixmap(":/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(QAbstractButton *, 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(QPixmap(":/Icons/custom-no.png"), Action::No);
bt->setIcon(QPixmap(":/Icons/action-locked-default.png"), Action::Auth);
bt->setIcon(QPixmap(":/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(QAbstractButton *, bool)), bt, SLOT(activate()));
connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated()));
bt = new ActionButton(shoutPB, "org.qt.policykit.examples.shout", this);
bt->setIcon(QPixmap(":/Icons/custom-no.png"), Action::No);
bt->setIcon(QPixmap(":/Icons/action-locked-default.png"), Action::Auth);
bt->setIcon(QPixmap(":/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(QAbstractButton *, bool)), bt, SLOT(activate()));
connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated()));
// test configChanged
}
PkExample::~PkExample()
{
}
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();
}
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")) {
qDebug() << "toggled for: org.qt.policykit.examples.set";
QDBusMessage message;
message = QDBusMessage::createMethodCall("org.qt.policykit.examples",
"/",
"org.qt.policykit.examples",
QLatin1String("set"));
QList<QVariant> argumentList;
argumentList << qVariantFromValue(setCB->currentText());
message.setArguments(argumentList);
// notice the systemBus here..
QDBusMessage reply = QDBusConnection::systemBus().call(message);
if (reply.type() == QDBusMessage::ReplyMessage
&& reply.arguments().size() == 1) {
// the reply can be anything, here we receive a bool
QListWidgetItem *item;
if (reply.arguments().first().toBool())
item = new QListWidgetItem(QPixmap(":/Icons/custom-yes.png"),
QString("Implicit authorization for shout has been set to %0")
.arg(setCB->currentText()));
else
item = new QListWidgetItem(QPixmap(":/Icons/custom-no.png"),
QString("Can't change the implicit authorization. Denied."));
actionList->addItem(item);
qDebug() << reply.arguments().first().toString();
} else if (reply.type() == QDBusMessage::MethodCallMessage) {
qWarning() << "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).
qDebug() << "pretending to be the mechanism for action:" << action->actionId();
Authority::Result result;
UnixProcessSubject subject(static_cast<uint>(QCoreApplication::applicationPid()));
result = Authority::instance()->checkAuthorizationSync(action->actionId(), subject,
Authority::AllowUserInteraction);
if (result == Authority::Yes) {
// in the helper you will do the action
qDebug() << "caller is authorized to do:" << action->actionId();
QListWidgetItem *item = new QListWidgetItem(QPixmap(":/Icons/custom-yes.png"), action->actionId());
actionList->addItem(item);
} else {
// OR return false to notify the caller that the action is not authorized.
qDebug() << "caller is NOT authorized to do:" << action->actionId();
QListWidgetItem *item = new QListWidgetItem(QIcon(":/Icons/custom-no.png"), action->actionId());
actionList->addItem(item);
}
}

@ -0,0 +1,41 @@
// This is an example not a library
/***************************************************************************
* Copyright (C) 2008 Daniel Nicoletti <dantti85-pk@yahoo.com.br> *
* Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#ifndef PKEXAMPLE_H
#define PKEXAMPLE_H
#include "ui_PkExample.h"
class PkExample : public QMainWindow, Ui::PkExample
{
Q_OBJECT
public:
PkExample(QMainWindow *parent = 0);
~PkExample();
private Q_SLOTS:
void activateAction();
void actionActivated();
};
#endif

@ -0,0 +1,234 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PkExample</class>
<widget class="QMainWindow" 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="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QGridLayout" name="gridLayout" columnstretch="3,1">
<item row="0" column="0">
<widget class="QLabel" 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="QPushButton" name="kickPB">
<property name="text">
<string>Kick!</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" 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="QPushButton" name="cryPB">
<property name="text">
<string>Cry!</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" 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="QPushButton" name="bleedPB">
<property name="text">
<string>Bleed!</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" 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="QPushButton" name="playPB">
<property name="text">
<string>Play!</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" 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="QPushButton" name="listenPB">
<property name="text">
<string>Listen!</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" 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="QPushButton" name="deletePB">
<property name="text">
<string>Delete!</string>
</property>
</widget>
</item>
<item row="6" column="0" rowspan="2">
<widget class="QLabel" 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="QComboBox" 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="QPushButton" name="setPB">
<property name="text">
<string>Set!</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" 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="QPushButton" name="shoutPB">
<property name="text">
<string>Shout!</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="actionList"/>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuActions">
<property name="title">
<string>Actions</string>
</property>
</widget>
<addaction name="menuActions"/>
</widget>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
</widget>
<resources/>
<connections/>
</ui>

@ -0,0 +1,110 @@
// This is an example not a library
/***************************************************************************
* Copyright (C) 2008 Daniel Nicoletti <dantti85-pk@yahoo.com.br> *
* Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#include "PkExampleHelper.h"
#include "examplesadaptor.h"
#include "polkitqt1-authority.h"
#include <QtDBus/QDBusConnection>
#include <QtCore/QTimer>
#include <QtCore/QDebug>
#include <QtXml/QDomDocument>
#define MINUTE 60000
using namespace PolkitQt1;
PkExampleHelper::PkExampleHelper(int &argc, char **argv)
: QCoreApplication(argc, argv)
{
qDebug() << "Creating Helper";
(void) new ExamplesAdaptor(this);
// Register the DBus service
if (!QDBusConnection::systemBus().registerService("org.qt.policykit.examples")) {
qDebug() << QDBusConnection::systemBus().lastError().message();;
QTimer::singleShot(0, this, SLOT(quit()));
return;
}
if (!QDBusConnection::systemBus().registerObject("/", this)) {
qDebug() << "unable to register service interface to dbus";
QTimer::singleShot(0, this, SLOT(quit()));
return;
}
// Normally you will set a timeout so your application can
// free some resources of the poor client machine ;)
QTimer::singleShot(MINUTE, this, SLOT(quit()));
}
PkExampleHelper::~PkExampleHelper()
{
qDebug() << "Destroying Helper";
}
bool PkExampleHelper::set(const QString &action)
{
qDebug() << "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());
result = Authority::instance()->checkAuthorizationSync("org.qt.policykit.examples.set",
subject , Authority::AllowUserInteraction);
if (result == Authority::Yes) {
qDebug() << message().service() << QString("Implicit authorization set to") << action;
// Caller is authorized so we can perform the action
return setValue(action);
} else {
qDebug() << message().service() << QString("Can't set the implicit authorization");
// Caller is not authorized so the action can't be performed
return false;
}
}
bool PkExampleHelper::setValue(const QString &action)
{
// This action must be authorized first. It will set the implicit
// authorization for the Shout action by editing the .policy file
QDomDocument doc = QDomDocument("policy");
QFile file("/usr/share/polkit-1/actions/org.qt.policykit.examples.policy");
if (!file.open(QIODevice::ReadOnly))
return false;
doc.setContent(&file);
file.close();
QDomElement el = doc.firstChildElement("policyconfig").
firstChildElement("action");
while (!el.isNull() && el.attribute("id", QString()) != "org.qt.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(QIODevice::WriteOnly))
return false;
QTextStream stream(&file);
doc.save(stream, 2);
file.close();
return true;
}

@ -0,0 +1,42 @@
// This is an example not a library
/***************************************************************************
* Copyright (C) 2008 Daniel Nicoletti <dantti85-pk@yahoo.com.br> *
* Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#ifndef PKEXAMPLE_HELPER_H
#define PKEXAMPLE_HELPER_H
#include <QtDBus/QDBusContext>
#include <QtCore/QCoreApplication>
class PkExampleHelper : public QCoreApplication, protected QDBusContext
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.qt.policykit.examples")
public:
PkExampleHelper(int &argc, char **argv);
~PkExampleHelper();
public Q_SLOTS:
bool set(const QString &action);
bool setValue(const QString &action);
};
#endif

@ -0,0 +1,24 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/agent
)
set(polkit_agent_example_SRCS
main.cpp
pkagentexample.cpp
klistener.cpp
)
automoc4(polkit-agent-example polkit_agent_example_SRCS)
add_executable(polkit-agent-example
${polkit_agent_example_SRCS}
)
target_link_libraries(polkit-agent-example
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
polkit-qt-agent-1
polkit-qt-core-1
)

@ -0,0 +1,100 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
*
* 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 <QtCore/QDebug>
#include <QInputDialog>
#include "klistener.h"
#include "agent/polkitqt1-agent-session.h"
using namespace PolkitQt1::Agent;
KListener::KListener(QObject *parent)
: Listener(parent)
{
qDebug() << "Registering KDE listener";
}
// README: this is just testing code...
void KListener::initiateAuthentication(const QString &actionId,
const QString &message,
const QString &iconName,
const PolkitQt1::Details &details,
const QString &cookie,
const PolkitQt1::Identity::List &identities,
AsyncResult *result)
{
qDebug() << "initiateAuthentication for " << actionId << " with message " << message;
qDebug() << "iconName " << iconName;
qDebug() << details.keys();
qDebug() << "cookie" << cookie;
Q_FOREACH (const PolkitQt1::Identity &identity, identities) {
qDebug() << identity.toString();
Session *session;
session = new Session(identity, cookie, result);
connect(session, SIGNAL(request(QString, bool)), this, SLOT(request(QString, bool)));
connect(session, SIGNAL(completed(bool)), this, SLOT(completed(bool)));
connect(session, SIGNAL(showError(QString)), this, SLOT(showError(QString)));
connect(session, SIGNAL(showInfo(QString)), this, SLOT(showInfo(QString)));
session->initiate();
}
}
bool KListener::initiateAuthenticationFinish()
{
qDebug() << "initiateAuthenticationFinish()";
return true;
}
void KListener::cancelAuthentication()
{
qDebug() << "Cancelling authentication";
}
void KListener::request(const QString &request, bool echo)
{
qDebug() << "Request: " << request;
Session *session = (Session *)sender();
session->setResponse("");
}
void KListener::completed(bool gainedAuthorization)
{
qDebug() << "Completed: " << gainedAuthorization;
Session *session = (Session *)sender();
session->result()->setCompleted();
delete session;
}
void KListener::showError(const QString &text)
{
qDebug() << "Error: " << text;
}
void KListener::showInfo(const QString &text)
{
qDebug() << "Info: " << text;
}

@ -0,0 +1,56 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
*
* 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 POLKIT_QT_AGENT_KDE_LISTENER_H
#define POLKIT_QT_AGENT_KDE_LISTENER_H
#include <QtCore/QObject>
#include <QtCore/QString>
#include "agent/polkitqt1-agent-listener.h"
#include "core/polkitqt1-identity.h"
#include "core/polkitqt1-details.h"
#include "agent/polkitqt1-agent-session.h"
class KListener : public PolkitQt1::Agent::Listener
{
Q_OBJECT
Q_DISABLE_COPY(KListener)
public:
KListener(QObject *parent = 0);
~KListener() {};
public Q_SLOTS:
void initiateAuthentication(const QString &actionId,
const QString &message,
const QString &iconName,
const PolkitQt1::Details &details,
const QString &cookie,
const PolkitQt1::Identity::List &identities,
PolkitQt1::Agent::AsyncResult *result);
bool initiateAuthenticationFinish();
void cancelAuthentication();
void request(const QString &request, bool echo);
void completed(bool gainedAuthorization);
void showError(const QString &text);
void showInfo(const QString &text);
};
#endif

@ -0,0 +1,30 @@
/***************************************************************************
* Copyright (C) 2009 Jaroslav Reznik *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#include <QApplication>
#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1
#include "pkagentexample.h"
int main(int argc, char *argv[])
{
PkAgentExample example(argc, argv);
return example.exec();
}

@ -0,0 +1,17 @@
#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1
#include <polkitagent/polkitagent.h>
#include "pkagentexample.h"
#include <glib-object.h>
#include <QtCore/QDebug>
#include "polkitqt1-subject.h"
PkAgentExample::PkAgentExample(int &argc, char **argv)
: QCoreApplication(argc, argv)
{
g_type_init();
PolkitQt1::UnixSessionSubject session(getpid());
m_listener.registerListener(session, "/org/kde/PolicyKit1/AuthenticationAgent");
}

@ -0,0 +1,42 @@
// This is an example not a library
/***************************************************************************
* Copyright (C) 2008 Daniel Nicoletti <dantti85-pk@yahoo.com.br> *
* Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#ifndef PKAGENTEXAMPLE_H
#define PKAGENTEXAMPLE_H
#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1
#include <QtDBus/QDBusContext>
#include <QCoreApplication>
#include "klistener.h"
class PkAgentExample : public QCoreApplication
{
Q_OBJECT
public:
PkAgentExample(int &argc, char **argv);
~PkAgentExample() {};
private:
KListener m_listener;
};
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

@ -0,0 +1,9 @@
<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>

@ -0,0 +1,32 @@
// This is an example not a library
/***************************************************************************
* Copyright (C) 2009 by Daniel Nicoletti *
* dantti85-pk@yahoo.com.br *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#include <QtGui/QApplication>
#include "PkExample.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
PkExample example;
example.show();
return app.exec();
}

@ -0,0 +1,28 @@
// This is an example not a library
/***************************************************************************
* Copyright (C) 2009 by Daniel Nicoletti *
* dantti85-pk@yahoo.com.br *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#include "PkExampleHelper.h"
int main(int argc, char *argv[])
{
PkExampleHelper example(argc, argv);
return example.exec();
}

@ -0,0 +1,20 @@
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- This configuration file specifies the required security policies
for the PolicyKit examples to work. -->
<!-- Only user root can own the PackageKit service -->
<policy user="root">
<allow own="org.qt.policykit.examples"/>
</policy>
<!-- Allow anyone to call into the service - we'll reject callers using PolicyKit -->
<policy context="default">
<allow send_destination="org.qt.policykit.examples"/>
</policy>
</busconfig>

@ -0,0 +1,81 @@
<?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.qt.policykit.examples.kick">
<description>Kick</description>
<message>Prevents PolicyKit-Qt example from kicking</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>no</allow_active>
</defaults>
</action>
<action id="org.qt.policykit.examples.cry">
<description>Cry</description>
<message>Prevents PolicyKit-Qt example from crying</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
</action>
<action id="org.qt.policykit.examples.bleed">
<description>Bleed</description>
<message>Prevents PolicyKit-Qt example from bleeding</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>auth_self</allow_active>
</defaults>
</action>
<action id="org.qt.policykit.examples.play">
<description>Play</description>
<message>Prevents PolicyKit-Qt example from playing</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
</action>
<action id="org.qt.policykit.examples.listen">
<description>Listen</description>
<message>Prevents PolicyKit-Qt example from listening</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>auth_self_keep</allow_active>
</defaults>
</action>
<action id="org.qt.policykit.examples.delete">
<description>Delete</description>
<message>Prevents PolicyKit-Qt example from deleting</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
</action>
<action id="org.qt.policykit.examples.set">
<description>Push</description>
<message>Prevents PolicyKit-Qt example from setting permissions for the shout action</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
</action>
<action id="org.qt.policykit.examples.shout">
<description>Shout</description>
<message>Prevents PolicyKit-Qt example from shouting</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
<annotate key="org.qt.policykit.examples.shout">foo</annotate>
</action>
</policyconfig>

@ -0,0 +1,85 @@
<?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.qt.policykit.examples.kick">
<description>Kick</description>
<message>Prevents PolicyKit-Qt example from kicking</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>no</allow_active>
</defaults>
</action>
<action id="org.qt.policykit.examples.cry">
<description>Cry</description>
<message>Prevents PolicyKit-Qt example from crying</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
</action>
<action id="org.qt.policykit.examples.play">
<description>Play</description>
<message>Prevents PolicyKit-Qt example from playing</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>auth_self</allow_active>
</defaults>
</action>
<action id="org.qt.policykit.examples.bleed">
<description>Bleed</description>
<message>Prevents PolicyKit-Qt example from bleeding</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
</action>
<action id="org.qt.policykit.examples.listen">
<description>Listen</description>
<message>Prevents PolicyKit-Qt example from listening</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>auth_self_keep</allow_active>
</defaults>
</action>
<action id="org.qt.policykit.examples.delete">
<description>Delete</description>
<message>Prevents PolicyKit-Qt example from deleting</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
</action>
<!--
<action id="org.qt.policykit.examples.shout">
<description>Shout</description>
<message>Prevents PolicyKit-Qt example from shouting</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
<annotate key="org.qt.policykit.examples.shout">foo</annotate>
</action>
<action id="org.qt.policykit.examples.push">
<description>Push</description>
<message>Prevents PolicyKit-Qt example from pushing</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
<annotate key="org.qt.policykit.examples.push">bar</annotate>
</action>
<action id="org.qt.policykit.examples.blow-up">
<description>Blow Up</description>
<message>Prevents PolicyKit-Qt example from blowing up</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
<annotate key="org.qt.policykit.examples.blow-up">booo</annotate>
</action>
-->
</policyconfig>

@ -0,0 +1,5 @@
[D-BUS Service]
Name=org.qt.policykit.examples
Exec=@BIN_INSTALL_DIR@/polkit-example-helper
User=root

@ -0,0 +1,11 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.qt.policykit.examples">
<method name="set" >
<!-- IN: system user -->
<arg direction="in" type="s" name="user" />
<!-- OUT: whether the user gained the authorization -->
<arg direction="out" type="b" name="shadow_line">
</method>
</interface>
</node>

@ -0,0 +1,26 @@
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
set(polkit_qt_gui_SRCS
polkitqt1-gui-action.cpp
polkitqt1-gui-actionbutton.cpp
polkitqt1-gui-actionbuttons.cpp
)
automoc4_add_library(polkit-qt-gui-1 SHARED ${polkit_qt_gui_SRCS})
target_link_libraries(polkit-qt-gui-1
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${QT_QTDBUS_LIBRARY}
${POLKIT_LIBRARIES}
polkit-qt-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)
install(TARGETS polkit-qt-gui-1 ${INSTALL_TARGETS_DEFAULT_ARGS})

@ -0,0 +1,515 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
* Copyright (C) 2009 Dario Freddi <drf@kde.org>
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
*
* 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 <QtCore/QCoreApplication>
namespace PolkitQt1
{
namespace Gui
{
/**
* \internal
*/
class Action::Private
{
public:
Private(Action *p);
Action *parent;
QString actionId;
Authority::Result pkResult;
qint64 targetPID;
void updateAction();
bool computePkResult();
void configChanged();
bool initiallyChecked;
// states data
bool selfBlockedVisible;
bool selfBlockedEnabled;
QString selfBlockedText;
QString selfBlockedWhatsThis;
QString selfBlockedToolTip;
QIcon selfBlockedIcon;
bool noVisible;
bool noEnabled;
QString noText;
QString noWhatsThis;
QString noToolTip;
QIcon noIcon;
bool authVisible;
bool authEnabled;
QString authText;
QString authWhatsThis;
QString authToolTip;
QIcon authIcon;
bool yesVisible;
bool yesEnabled;
QString yesText;
QString yesWhatsThis;
QString yesToolTip;
QIcon 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 QString &actionId, QObject *parent)
: QAction(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;
QAction::setChecked(checked);
}
void Action::Private::updateAction()
{
if (Authority::instance()->hasError()) {
return;
}
switch (pkResult) {
default:
case Authority::Unknown:
case Authority::No:
qobject_cast<QAction *>(parent)->setVisible(noVisible);
qobject_cast<QAction *>(parent)->setEnabled(noEnabled);
qobject_cast<QAction *>(parent)->setText(noText);
if (!noWhatsThis.isNull()) {
qobject_cast<QAction *>(parent)->setWhatsThis(noWhatsThis);
}
if (!noToolTip.isNull()) {
qobject_cast<QAction *>(parent)->setToolTip(noToolTip);
}
qobject_cast<QAction *>(parent)->setIcon(noIcon);
break;
case Authority::Challenge:
qobject_cast<QAction *>(parent)->setVisible(authVisible);
qobject_cast<QAction *>(parent)->setEnabled(authEnabled);
qobject_cast<QAction *>(parent)->setText(authText);
if (!authWhatsThis.isNull()) {
qobject_cast<QAction *>(parent)->setWhatsThis(authWhatsThis);
}
if (!authToolTip.isNull()) {
qobject_cast<QAction *>(parent)->setToolTip(authToolTip);
}
qobject_cast<QAction *>(parent)->setIcon(authIcon);
break;
case Authority::Yes:
qobject_cast<QAction *>(parent)->setVisible(yesVisible);
qobject_cast<QAction *>(parent)->setEnabled(yesEnabled);
qobject_cast<QAction *>(parent)->setText(yesText);
if (!yesWhatsThis.isNull()) {
qobject_cast<QAction *>(parent)->setWhatsThis(yesWhatsThis);
}
if (!yesToolTip.isNull()) {
qobject_cast<QAction *>(parent)->setToolTip(yesToolTip);
}
qobject_cast<QAction *>(parent)->setIcon(yesIcon);
if (parent->isCheckable()) {
qobject_cast<QAction *>(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 QCoreApplication::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 QString &other) const
{
return d->actionId == other;
}
void Action::revoke()
{
/*TODO: implement it? no negative authorizations available, no authorization db*/
}
void Action::setText(const QString &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();
}
QString 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 QAction::text();
default:
return QString();
}
}
void Action::setToolTip(const QString &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();
}
QString 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 QAction::toolTip();
default:
return QString();
}
}
void Action::setWhatsThis(const QString &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();
}
QString 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 QAction::whatsThis();
default:
return QString();
}
}
void Action::setIcon(const QIcon &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();
}
QIcon 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 QAction::icon();
default:
return QIcon();
}
}
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 QAction::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 QAction::isVisible();
default:
return false;
}
}
void Action::setPolkitAction(const QString &actionId)
{
//TODO:
d->actionId = actionId;
d->computePkResult();
d->updateAction();
}
//--------------------------------------------------
QString Action::actionId() const
{
return d->actionId;
}
}
}
#include "polkitqt1-gui-action.moc"

@ -0,0 +1,304 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
* Copyright (C) 2009 Dario Freddi <drf@kde.org>
*
* 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 <QtGui/QAction>
namespace PolkitQt1
{
namespace Gui
{
/**
* \class Action polkitqt1-gui-action.h Action
* \author Daniel Nicoletti <dantti85-pk@yahoo.com.br>
* \author Dario Freddi <drf@kde.org>
*
* \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 QAbstractButton. 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 QAction
{
Q_OBJECT
Q_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 QString &actionId = QString(), QObject *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 QString &actionId);
/**
* Returns the current action ID.
*
* \return The action ID
*
*/
QString 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 QString &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 QString &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 QString &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 QIcon 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 QIcon &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
*/
QString 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
*/
QString 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
*/
QString 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
*/
QIcon 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 QString &actionId) const;
private:
class Private;
Private * const d;
Q_PRIVATE_SLOT(d, void configChanged())
};
}
}
Q_DECLARE_OPERATORS_FOR_FLAGS(PolkitQt1::Gui::Action::States)
#endif

@ -0,0 +1,166 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
* Copyright (C) 2009 Dario Freddi <drf@kde.org>
*
* 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 PolkitQt1
{
namespace Gui
{
ActionButton::ActionButton(QAbstractButton *button, const QString &actionId, QObject *parent)
: Action(actionId, parent)
, d_ptr(new ActionButtonPrivate(QList<QAbstractButton *>() << button))
{
d_ptr->q_ptr = this;
setButton(button);
connect(this, SIGNAL(dataChanged()), SLOT(updateButton()));
}
ActionButton::ActionButton(ActionButtonPrivate &dd, const QString &actionId, QObject *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(QAbstractButton *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(QAbstractButton *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(QAbstractButton *button)
{
Q_D(ActionButton);
// First, let's clear the list
Q_FOREACH(QAbstractButton *ent, d->buttons) {
d->removeButton(ent);
}
// And then add it
d->addButton(button);
}
void ActionButtonPrivate::addButton(QAbstractButton *button)
{
Q_Q(ActionButton);
buttons.append(button);
QObject::connect(button, SIGNAL(clicked(bool)), q, SLOT(streamClicked(bool)));
QObject::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 QCheckBox) we should set all buttons to
// checkable.
Q_FOREACH(QAbstractButton *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(QAbstractButton *button)
{
Q_Q(ActionButton);
if (buttons.contains(button)) {
QObject::disconnect(button, SIGNAL(clicked(bool)), q, SLOT(streamClicked(bool)));
QObject::disconnect(q, SIGNAL(toggled(bool)), button, SLOT(toggle()));
buttons.removeOne(button);
}
}
QAbstractButton *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<QAbstractButton *>(q->sender()), c);
}
}
}
#include "polkitqt1-gui-actionbutton.moc"

@ -0,0 +1,145 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
* Copyright (C) 2009 Dario Freddi <drf@kde.org>
*
* 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 QAbstractButton;
namespace PolkitQt1
{
namespace Gui
{
class ActionButtonPrivate;
/**
* \class ActionButton polkitqt1-gui-actionbutton.h ActionButton
* \author Daniel Nicoletti <dantti85-pk@yahoo.com.br>
* \author Dario Freddi <drf@kde.org>
*
* \brief Class used to hold and update a QAbstractButton
*
* This class allows you to associate QAbstractButtons
* (i.e. QPushButton) 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)
Q_DISABLE_COPY(ActionButton)
public:
/**
* Constructs a new ActionButton. You need to pass this
* constructor an existing QAbstractButton, 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 QAbstractButton to associate to this ActionButton
* \param actionId the action Id to create the underlying Action
* \param parent the parent object
*/
explicit ActionButton(QAbstractButton *button, const QString &actionId = QString(), QObject *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-Qt 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(QAbstractButton *button);
/**
* Returns the current button
*
* \return the button currently associated with the underlying action
*/
QAbstractButton *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<ActionButton *>(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(QAbstractButton *button, bool checked = false);
protected:
ActionButton(ActionButtonPrivate &dd, const QString &actionId, QObject *parent = 0);
ActionButtonPrivate * const d_ptr;
private:
Q_PRIVATE_SLOT(d_func(), void updateButton())
Q_PRIVATE_SLOT(d_func(), void streamClicked(bool))
};
}
}
#endif

@ -0,0 +1,50 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Dario Freddi <drf@kde.org>
*
* 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 <polkitqt1-gui-actionbutton.h>
#include <QtCore/QList>
#include <QtGui/QAbstractButton>
/**
* \internal
*/
class PolkitQt1::Gui::ActionButtonPrivate
{
public:
ActionButtonPrivate(const QList<QAbstractButton *> &b)
: buttons(b) {}
virtual ~ActionButtonPrivate() {}
void addButton(QAbstractButton *button);
void removeButton(QAbstractButton *button);
void updateButton();
void streamClicked(bool);
Q_DECLARE_PUBLIC(ActionButton)
ActionButton *q_ptr;
QList<QAbstractButton *> buttons;
};
#endif /* ACTIONBUTTON_P_H */

@ -0,0 +1,73 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Dario Freddi <drf@kde.org>
*
* 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 PolkitQt1
{
namespace Gui
{
ActionButtons::ActionButtons(const QList<QAbstractButton *> &buttons, const QString &actionId, QObject *parent)
: ActionButton(*new ActionButtonsPrivate(buttons), actionId, parent)
{
setButtons(buttons);
}
ActionButtons::~ActionButtons()
{
}
void ActionButtons::setButtons(const QList<QAbstractButton *> &buttons)
{
Q_FOREACH(QAbstractButton *ent, buttons) {
addButton(ent);
}
}
QList<QAbstractButton *> ActionButtons::buttons() const
{
Q_D(const ActionButtons);
return d->buttons;
}
void ActionButtons::addButton(QAbstractButton *button)
{
Q_D(ActionButtons);
d->addButton(button);
}
void ActionButtons::removeButton(QAbstractButton *button)
{
Q_D(ActionButtons);
d->removeButton(button);
}
}
}
#include "polkitqt1-gui-actionbuttons.moc"

@ -0,0 +1,114 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Dario Freddi <drf@kde.org>
*
* 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 PolkitQt1
{
namespace Gui
{
class ActionButtonsPrivate;
/**
* \class ActionButtons polkitqt1-gui-actionbuttons.h ActionButtons
* \author Dario Freddi <drf@kde.org>
*
* \brief Class used to hold and update a list of QAbstractButtons
*
* This class is a convenience wrapper around ActionButton that lets
* you associate an undefined number of QAbstractButtons 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)
Q_DISABLE_COPY(ActionButtons)
public:
/**
* Constructs a new ActionButton. You need to pass this
* constructor an existing list of QAbstractButtons, 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 QAbstractButton to associate to this ActionButton
* \param actionId the action Id to create the underlying Action
* \param parent the parent object
*/
explicit ActionButtons(const QList<QAbstractButton *> &buttons, const QString &actionId = QString(), QObject *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-Qt 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 QList<QAbstractButton *> &buttons);
/**
* Returns the current buttons list
*
* \return the buttons currently associated with the underlying action
*/
QList<QAbstractButton *> 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(QAbstractButton *button);
/**
* Removes a button from the current list. Please note that Polkit-Qt
* 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(QAbstractButton *button);
};
}
}
#endif

@ -0,0 +1,36 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Dario Freddi <drf@kde.org>
*
* 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 PolkitQt1::Gui::ActionButtonsPrivate : public ActionButtonPrivate
{
public:
ActionButtonsPrivate(const QList<QAbstractButton *> &b)
: ActionButtonPrivate(b) {}
};
#endif /* ACTIONBUTTONS_P_H */

@ -0,0 +1 @@
#include "../polkitqt1-actiondescription.h"

@ -0,0 +1 @@
#include "../../polkitqt1-agent-listener.h"

@ -0,0 +1 @@
#include "../../polkitqt1-agent-session.h"

@ -0,0 +1 @@
#include "../polkitqt1-authority.h"

@ -0,0 +1 @@
#include "../polkitqt1-details.h"

@ -0,0 +1 @@
#include "../../polkitqt1-gui-action.h"

@ -0,0 +1 @@
#include "../../polkitqt1-gui-actionbutton.h"

@ -0,0 +1 @@
#include "../../polkitqt1-gui-actionbuttons.h"

@ -0,0 +1 @@
#include "../polkitqt1-identity.h"

@ -0,0 +1 @@
#include "../polkitqt1-subject.h"

@ -0,0 +1 @@
#include "../polkitqt1-temporaryauthorization.h"

@ -0,0 +1,11 @@
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 Qt-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}

@ -0,0 +1,11 @@
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 Qt-styled API
Version: @POLKITQT-1_VERSION_STRING@
Requires: QtCore QtGui
Libs: -L${libdir} -lpolkit-qt-agent-1
Cflags: -I${includedir}

@ -0,0 +1,11 @@
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 Qt-styled API, non-GUI classes
Version: @POLKITQT-1_VERSION_STRING@
Requires: QtCore
Libs: -L${libdir} -lpolkit-qt-core-1
Cflags: -I${includedir}

@ -0,0 +1,11 @@
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 Qt-styled API, GUI classes
Version: @POLKITQT-1_VERSION_STRING@
Requires: QtCore QtGui polkit-qt-core-1
Libs: -L${libdir} -lpolkit-qt-gui-1
Cflags: -I${includedir}

@ -0,0 +1,44 @@
/*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Dario Freddi <drf@kde.org>
* Copyright (C) 2007 David Faure <faure@kde.org>
*
* 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 <QtCore/QtGlobal>
#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*/

@ -0,0 +1,106 @@
/*
* Copyright (C) 2007 Sebastian Trueg <trueg@kde.org>
* Copyright (C) 2009 Dario Freddi <drf@kde.org>
*
* 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 PolkitQt-1 version as string at compile time.
#define POLKITQT1_VERSION_STRING "${POLKITQT-1_VERSION_STRING}"
/// @brief The major PolkitQt-1 version number at compile time
#define POLKITQT1_VERSION_MAJOR ${POLKITQT-1_VERSION_MAJOR}
/// @brief The minor PolkitQt-1 version number at compile time
#define POLKITQT1_VERSION_MINOR ${POLKITQT-1_VERSION_MINOR}
/// @brief The PolkitQt-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 %PolkitQt-1 version
*
* This function can be used for preprocessing. For version information at runtime
* use the version methods in the PolkitQt-1 namespace.
*/
#define POLKITQT1_MAKE_VERSION( a,b,c ) (((a) << 16) | ((b) << 8) | (c))
/**
* \brief %PolkitQt-1 Version as a unique number at compile time
*
* This macro calculates the %PolkitQt-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 PolkitQt-1 namespace.
*/
#define POLKITQT1_VERSION \
POLKITQT1_MAKE_VERSION(POLKITQT1_VERSION_MAJOR,POLKITQT1_VERSION_MINOR,POLKITQT1_VERSION_PATCH)
/**
* \brief Check if the %PolkitQt-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 PolkitQt-1 2.1
* #else
* // Code for PolkitQt-1 2.0
* #endif
* \endcode
*
* For version information at runtime
* use the version methods in the PolkitQt-1 namespace.
*/
#define POLKITQT1_IS_VERSION(a,b,c) ( POLKITQT1_VERSION >= POLKITQT1_MAKE_VERSION(a,b,c) )
namespace PolkitQt1 {
/**
* @brief Returns the major number of PolkitQt-1's version, e.g.
* 1 for %PolkitQt-1 1.0.2.
* @return the major version number at runtime.
*/
POLKITQT1_EXPORT unsigned int versionMajor();
/**
* @brief Returns the minor number of PolkitQt-1's version, e.g.
* 0 for %PolkitQt-1 1.0.2.
* @return the minor version number at runtime.
*/
POLKITQT1_EXPORT unsigned int versionMinor();
/**
* @brief Returns the patch number of PolkitQt-1's version, e.g.
* 2 for %PolkitQt-1 1.0.2.
* @return the release number at runtime.
*/
POLKITQT1_EXPORT unsigned int versionPatch();
/**
* @brief Returns the %PolkitQt-1 version as string, e.g. "1.0.2".
*
* On contrary to the macro POLKITQT1_VERSION_STRING this function returns
* the version number of PolkitQt-1 at runtime.
* @return the %PolkitQt-1 version. You can keep the string forever
*/
POLKITQT1_EXPORT const char* versionString();
}
#endif

@ -0,0 +1,20 @@
enable_testing()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/agent
)
automoc4_add_executable(polkit-qt-test
test.cpp
)
target_link_libraries(polkit-qt-test
${QT_QTCORE_LIBRARY}
${QT_QTTEST_LIBRARY}
${QT_QTGUI_LIBRARY}
polkit-qt-core-1
)
add_test(BaseTest ${CMAKE_CURRENT_BINARY_DIR}/polkit-qt-test)

@ -0,0 +1,235 @@
#include "test.h"
#include "core/polkitqt1-authority.h"
#include "agent/polkitqt1-agent-session.h"
#include "core/polkitqt1-details.h"
#include <stdlib.h>
#include <unistd.h>
#include <pwd.h>
#include <QtDBus/QDBusMessage>
#include <QtDBus/QDBusConnection>
using namespace PolkitQt1;
using namespace PolkitQt1::Agent;
void wait()
{
for (int i = 0; i < 100; i++) {
usleep(100);
QCoreApplication::processEvents();
}
}
void TestAuth::test_Auth_checkAuthorization()
{
// This needs the file org.qt.policykit.examples.policy from examples to be installed
UnixProcessSubject process(QCoreApplication::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);
QCOMPARE(result, Authority::No);
QVERIFY(!authority->hasError());
result = authority->checkAuthorizationSync("org.qt.policykit.examples.cry", process, Authority::None);
QCOMPARE(result, Authority::Yes);
QVERIFY(!authority->hasError());
result = authority->checkAuthorizationSync("org.qt.policykit.examples.bleed", process, Authority::None);
QCOMPARE(result, Authority::Challenge);
QVERIFY(!authority->hasError());
// Now we try async methods
QSignalSpy spy(authority, SIGNAL(checkAuthorizationFinished(PolkitQt1::Authority::Result)));
// Call asynchronous checkAuthorization
authority->checkAuthorization("org.qt.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
QCOMPARE(spy.count(), 1);
// Test the result
result = qVariantValue<PolkitQt1::Authority::Result> (spy.takeFirst()[0]);
QCOMPARE(result, Authority::No);
QVERIFY(!authority->hasError());
spy.clear();
// Let's test the cancellability
authority->checkAuthorization("org.qt.policykit.examples.kick", process, Authority::None);
authority->checkAuthorizationCancel();
// Wait and check if the signal arrieved
wait();
QCOMPARE(spy.count(), 0);
// Check if it can cancel user authentication dialog
authority->checkAuthorization("org.qt.policykit.examples.bleed", process, Authority::AllowUserInteraction);
// Show it for second
sleep(1);
// And now kill it
authority->checkAuthorizationCancel();
QVERIFY(!authority->hasError());
// But how to test if it was successful?
qWarning() << "You should see an authentication dialog for a short period.";
}
void TestAuth::test_Auth_enumerateActions()
{
// This needs the file org.qt.policykit.examples.policy from examples to be installed
ActionDescription::List list = Authority::instance()->enumerateActionsSync();
QVERIFY(!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"))
count++;
}
QCOMPARE(count, 3);
// Test asynchronous version as well
list.clear();
count = 0;
QSignalSpy spy(Authority::instance(), SIGNAL(enumerateActionsFinished(PolkitQt1::ActionDescription::List)));
Authority::instance()->enumerateActions();
wait();
QCOMPARE(spy.count(), 1);
list = qVariantValue<PolkitQt1::ActionDescription::List> (spy.takeFirst()[0]);
QVERIFY(!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"))
count++;
}
QCOMPARE(count, 3);
// Test cancelling the enumeration
spy.clear();
Authority::instance()->enumerateActions();
Authority::instance()->enumerateActionsCancel();
wait();
QCOMPARE(spy.count(), 0);
QVERIFY(!Authority::instance()->hasError());
}
void TestAuth::test_Identity()
{
// Get real name and id of current user and group
struct passwd *userinfo = getpwuid(getuid());
QString userName = userinfo->pw_name;
unsigned int userId = userinfo->pw_uid;
unsigned int groupId = userinfo->pw_gid;
// Try to create UnixUser from username
UnixUserIdentity user(userName);
QVERIFY(user.identity());
// Create generic Identity from UnixUser via string representation
Identity id = Identity::fromString(user.toString());
// Compare obtained uid with real uid
QCOMPARE(id.toUnixUserIdentity().uid(), userId);
// Create generic Identity from UnixGroup via string representation
UnixGroupIdentity group(groupId);
QVERIFY(group.identity());
id = Identity::fromString(group.toString());
QCOMPARE(id.toUnixGroupIdentity().gid(), groupId);
// Test setting gid to another value
group.setGid(9999U);
id = Identity::fromString(group.toString());
QCOMPARE(id.toUnixGroupIdentity().gid(), 9999U);
}
void TestAuth::test_Authority()
{
Authority *authority = Authority::instance();
QVERIFY(authority);
QVERIFY(!authority->hasError());
// Verify emiting of the signals
QSignalSpy spy(authority, SIGNAL(consoleKitDBChanged()));
QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.ConsoleKit",
"/org/freedesktop/ConsoleKit/Manager",
"org.freedesktop.ConsoleKit.Manager",
"OpenSession");
QDBusMessage reply = QDBusConnection::systemBus().call(msg);
QString cookie;
cookie = qVariantValue<QString> (reply.arguments()[0]);
msg = QDBusMessage::createMethodCall("org.freedesktop.ConsoleKit",
"/org/freedesktop/ConsoleKit/Manager",
"org.freedesktop.ConsoleKit.Manager",
"CloseSession");
msg.setArguments(QList<QVariant> () << cookie);
QDBusConnection::systemBus().call(msg);
// FIXME: Emitting consoleKitDBChanged is not working now
qWarning() << "Emitting consoleKitDBChanged is not working now, test will be skipped";
//QVERIFY(spy.count() > 0);
QVERIFY(!authority->hasError());
// configChanged signal from authority requires changing some policy files
// and it would require user interaction (typing the password)
// so this is not covered by this test
}
void TestAuth::test_Subject()
{
// Get pid of this appication
qint64 pid = QCoreApplication::applicationPid();
// Create unix process for it
UnixProcessSubject *process = new UnixProcessSubject(pid);
// Test if pid doesn't differ
QCOMPARE(process->pid(), pid);
// Serialize and deserialize subject
//Subject *subject = Subject::fromString(process->toString());
// and try it
//QCOMPARE(((UnixProcess *) subject)->pid(), pid);
delete process;
}
void TestAuth::test_Session()
{
/*
UnixUser user(getuid());
Session *session = new Session(&user, "/org/freedesktop/ConsoleKit/Session2");
QSignalSpy spy_completed(session, SIGNAL(completed(bool)));
QSignalSpy spy_request(session, SIGNAL(request(QString,bool)));
QSignalSpy spy_error(session, SIGNAL(showError(QString)));
QSignalSpy spy_info(session, SIGNAL(showInfo(QString)));
session->initiate();
session->response("aaa");
// Canceling should emit the "completed" signal
session->cancel();
QCOMPARE(spy_completed.count(), 1);
//UnixProcess *process = new UnixProcess(QCoreApplication::applicationPid());
//Authority::instance()->checkAuthorization("org.qt.policykit.examples.kick", process, Authority::None);
qDebug() << "COMPLETED:" << spy_completed.count();
qDebug() << "REQUEST:" << spy_request.count();
qDebug() << "ERROR:" << spy_error.count();
qDebug() << "INFO:" << spy_info.count();
*/
}
void TestAuth::test_Details()
{
Details details;
details.insert("1", "aaa");
details.insert("2", "bbb");
details.insert("3", "ccc");
details.insert("4", "ddd");
QCOMPARE(details.lookup("1"), QString("aaa"));
QCOMPARE(details.lookup("2"), QString("bbb"));
QCOMPARE(details.lookup("3"), QString("ccc"));
QCOMPARE(details.lookup("4"), QString("ddd"));
QList<QString> list = details.keys();
QVERIFY(list.contains("1"));
QVERIFY(list.contains("2"));
QVERIFY(list.contains("3"));
QVERIFY(list.contains("4"));
}
QTEST_MAIN(TestAuth)

@ -0,0 +1,20 @@
#ifndef TEST_H
#define TEST_H
#include <QtCore/QObject>
#include <QtTest/QtTest>
class TestAuth : public QObject
{
Q_OBJECT
private Q_SLOTS:
void test_Auth_checkAuthorization();
void test_Auth_enumerateActions();
void test_Identity();
void test_Authority();
void test_Subject();
void test_Session();
void test_Details();
};
#endif // TEST_H
Loading…
Cancel
Save