Adding upstream version 0.9.0.

Signed-off-by: Andrew Lee's avatarAndrew Lee (李健秋) <ajqlee@debian.org>
parents
Upstream Authors:
LXQt team: http://lxqt.org
Razor team: http://razor-qt.org
Copyright:
Copyright (c) 2010-2012 Razor team
Copyright (c) 2012-2014 LXQt team
License: GPL-2 and LGPL-2.1+
The full text of the licenses can be found in the 'COPYING' file.
cmake_minimum_required(VERSION 2.8.11)
project(lxqt-policykit-agent)
option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF)
find_package(PkgConfig)
pkg_check_modules(POLKIT_AGENT REQUIRED polkit-agent-1)
message(STATUS "polkit agent: ${POLKIT_AGENT_INCLUDE_DIRS} ${POLKIT_AGENT_LIBRARIES}")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_AUTOMOC ON)
find_package(PolkitQt5-1 REQUIRED)
find_package(Qt5Widgets REQUIRED QUIET)
find_package(Qt5LinguistTools REQUIRED QUIET)
find_package(lxqt REQUIRED QUIET)
find_package(qt5xdg REQUIRED QUIET)
include(${LXQT_USE_FILE})
include(${QTXDG_USE_FILE})
include(LXQtTranslate)
# Deal with a bug in polkit-qt5
if (NOT IS_ABSOLUTE "${POLKITQT-1_INCLUDE_DIR}")
set(POLKITQT-1_INCLUDE_DIR "${POLKITQT-1_INSTALL_DIR}/${POLKITQT-1_INCLUDE_DIR}")
set(POLKITQT-1_AGENT_LIBRARY "${POLKITQT-1_INSTALL_DIR}/${POLKITQT-1_AGENT_LIBRARY}")
set(POLKITQT-1_CORE_LIBRARY "${POLKITQT-1_INSTALL_DIR}/${POLKITQT-1_CORE_LIBRARY}")
endif()
message(STATUS "PolkitQt-1: ${POLKITQT-1_VERSION_STRING}")
message(STATUS " install: ${POLKITQT-1_INSTALL_DIR}")
message(STATUS " libs: ${POLKITQT-1_CORE_LIBRARY} ${POLKITQT-1_AGENT_LIBRARY}")
message(STATUS " include: ${POLKITQT-1_INCLUDE_DIR}")
# TODO/FIXME: pkg-config for hardcoded paths
# pkg-config --cflags glib-2.0
# pkg-config --cflags polkit-agent-1
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/src"
"${CMAKE_CURRENT_BINARY_DIR}"
${POLKIT_AGENT_INCLUDE_DIRS}
"${POLKITQT-1_INCLUDE_DIR}"
)
set(lxqt-policykit-agent_SRCS
src/main.cpp
src/policykitagent.cpp
src/policykitagentgui.cpp
)
set(lxqt-policykit-agent_H
src/policykitagent.h
src/policykitagentgui.h
)
set(lxqt-policykit-agent_UI
src/policykitagentgui.ui
)
# Translations
lxqt_translate_ts(lxqt-policykit-agent_QM_FILES
UPDATE_TRANSLATIONS
${UPDATE_TRANSLATIONS}
SOURCES
${lxqt-policykit-agent_H}
${lxqt-policykit-agent_SRCS}
${lxqt-policykit-agent_UI}
INSTALL_DIR
"${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}"
)
lxqt_app_translation_loader(QM_LOADER ${PROJECT_NAME})
qt5_wrap_ui(lxqt-policykit-agent_UI_CPP ${lxqt-policykit-agent_UI})
add_executable(lxqt-policykit-agent
${lxqt-policykit-agent_SRCS}
${lxqt-policykit-agent_MOCS}
${lxqt-policykit-agent_UI_CPP}
${lxqt-policykit-agent_QM_FILES}
${QM_LOADER}
)
target_link_libraries(lxqt-policykit-agent
Qt5::Widgets
${QTXDG_LIBRARY}
${LXQT_LIBRARIES}
${POLKITQT-1_CORE_LIBRARY}
${POLKITQT-1_AGENT_LIBRARY}
${POLKIT_AGENT_LIBRARIES}
)
# install
install(TARGETS lxqt-policykit-agent DESTINATION bin)
# building tarball with CPack -------------------------------------------------
include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_VERSION_MAJOR ${LXQT_MAJOR_VERSION})
set(CPACK_PACKAGE_VERSION_MINOR ${LXQT_MINOR_VERSION})
set(CPACK_PACKAGE_VERSION_PATCH ${LXQT_PATCH_VERSION})
set(CPACK_GENERATOR TBZ2)
set(CPACK_SOURCE_GENERATOR TBZ2)
set(CPACK_SOURCE_IGNORE_FILES /build/;.gitignore;.*~;.git;.kdev4;temp)
include(CPack)
This diff is collapsed.
.TH lxqt-policykit-agent "1" "September 2012" "LxQt\-qt\ 0.5.0" "LxQt\-Qt\ Module"
.SH NAME
lxqt-policykit-agent \- Polkit agent for \fBLXDE-Qt\fR: the faster and lighter QT Desktop Environment
.SH SYNOPSIS
.B lxqt-policykit-agent
[\fICurrently No command line arguments\fR]
.br
.SH DESCRIPTION
This module handles policykit for \fBLXDE-Qt\fR. The polkit module, will perform
security tast over scale action privilegies.
.P
The \fBLXDE-Qt modules\fR are desktop independent tools,
and operate as daemons for the local user for desktop specific operations.
.P
\fBLXDE-Qt\fR is an advanced, easy-to-use, and fast desktop environment based on Qt
technologies, ships several core desktop components, all of which are optional:
.P
* Panel
* Desktop
* Application launcher
* Settings center
* Session handler
* Polkit handler \fI(this)\fR
* Display manager handler
.P
These components perform similar actions to those available in other desktop
environments, and their name is self-descriptive. They are usually not launched
by hand but automatically, when choosing a LxQt\-Qt session in the Display
Manager.
.SH BEHAVIOR
The module detected on shares privilege escalation, and maintain a security dialog
that ask for the user's key need for action.
.SH AUTOSTART
The module only are showed on \fBLXDE-Qt\fR desktop, but u can create an autostart action
for u prefered desktop environment.
.SH "REPORTING BUGS"
Report bugs to https://github.com/LXDE-Qt/LXDE-Qt/issues
.SH "SEE ALSO"
\fBLXDE-Qt\fR it has been tailored for users who value simplicity, speed, and
an intuitive interface, also intended for less powerful machines. See:
.\" any module must refers to session app, for more info on start it
.P
\fBlxqt-session.1\fR LXDE-Qt for manage LXDE-Qt complete environment
.P
\fBstart-lxqt.1\fR LXDE-Qt display management independient starup.
.P
\fBlxqt-config-session.1\fR LXDE-Qt application for performing session autostart applications
.P
.SH AUTHOR
This manual page was created by \fBPICCORO Lenz McKAY\fR \fI<mckaygerhard@gmail.com>\fR
for \fBLXDE-Qt\fR project and VENENUX GNU/Linux but can be used by others.
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* LXDE-Qt - a lightweight, Qt based, desktop toolset
* http://razor-qt.org
*
* Copyright: 2011-2012 Razor team
* Authors:
* Petr Vanek <petr@scribus.info>
*
* This program or 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.1 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
*
* END_COMMON_COPYRIGHT_HEADER */
#include <LXQt/Application>
#include <glib-object.h>
#include <XdgIcon>
#include <LXQt/Settings>
#include "policykitagent.h"
int main(int argc, char *argv[])
{
#if !GLIB_CHECK_VERSION(2, 36, 0)
g_type_init();
#endif
LxQt::Application app(argc, argv);
app.setQuitOnLastWindowClosed(false);
LxQtPolicykit::PolicykitAgent agent;
return app.exec();
}
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* LXDE-Qt - a lightweight, Qt based, desktop toolset
* http://razor-qt.org
*
* Copyright: 2011-2012 Razor team
* Authors:
* Petr Vanek <petr@scribus.info>
*
* This program or 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.1 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
*
* END_COMMON_COPYRIGHT_HEADER */
#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1
#include <polkitagent/polkitagent.h>
#include <PolkitQt1/Subject>
#include <QMessageBox>
#include "policykitagent.h"
#include "policykitagentgui.h"
namespace LxQtPolicykit
{
PolicykitAgent::PolicykitAgent(QObject *parent)
: PolkitQt1::Agent::Listener(parent),
m_inProgress(false),
m_gui(0)
{
PolkitQt1::UnixSessionSubject session(getpid());
registerListener(session, "/org/lxqt/PolicyKit1/AuthenticationAgent");
}
PolicykitAgent::~PolicykitAgent()
{
if (m_gui)
{
m_gui->blockSignals(true);
m_gui->deleteLater();
}
}
void PolicykitAgent::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)
{
if (m_inProgress)
{
QMessageBox::information(0, tr("PolicyKit Information"), "Another authentization in progress. Please try it again later");
return;
}
m_inProgress = true;
m_SessionIdentity.clear();
if (m_gui)
{
delete m_gui;
m_gui = 0;
}
m_gui = new PolicykitAgentGUI(actionId, message, iconName, details, identities);
foreach (PolkitQt1::Identity i, identities)
{
PolkitQt1::Agent::Session *session;
session = new PolkitQt1::Agent::Session(i, cookie, result);
Q_ASSERT(session);
m_SessionIdentity[session] = i;
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 PolicykitAgent::initiateAuthenticationFinish()
{
// dunno what are those for...
m_inProgress = false;
return true;
}
void PolicykitAgent::cancelAuthentication()
{
// dunno what are those for...
m_inProgress = false;
}
void PolicykitAgent::request(const QString &request, bool echo)
{
PolkitQt1::Agent::Session *session = qobject_cast<PolkitQt1::Agent::Session *>(sender());
Q_ASSERT(session);
Q_ASSERT(m_gui);
PolkitQt1::Identity identity = m_SessionIdentity[session];
m_gui->setPrompt(identity, request, echo);
if (m_gui->exec())
session->setResponse(m_gui->response());
else
session->setResponse("");
}
void PolicykitAgent::completed(bool gainedAuthorization)
{
PolkitQt1::Agent::Session * session = qobject_cast<PolkitQt1::Agent::Session *>(sender());
Q_ASSERT(session);
if (!gainedAuthorization)
{
QMessageBox::information(0, tr("Authorization Failed"), tr("Authorization failed for some reason"));
}
session->result()->setCompleted();
delete session;
m_inProgress = false;
}
void PolicykitAgent::showError(const QString &text)
{
QMessageBox::warning(0, tr("PolicyKit Error"), text);
}
void PolicykitAgent::showInfo(const QString &text)
{
QMessageBox::information(0, tr("PolicyKit Information"), text);
}
} //namespace
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* LXDE-Qt - a lightweight, Qt based, desktop toolset
* http://razor-qt.org
*
* Copyright: 2011-2012 Razor team
* Authors:
* Petr Vanek <petr@scribus.info>
*
* This program or 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.1 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
*
* END_COMMON_COPYRIGHT_HEADER */
#ifndef POLICYKITAGENT_H
#define POLICYKITAGENT_H
#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1
#include <PolkitQt1/Agent/Listener>
#include <PolkitQt1/Agent/Session>
#include <PolkitQt1/Details>
#include <PolkitQt1/Identity>
#include <QApplication>
#include <QHash>
namespace LxQtPolicykit
{
class PolicykitAgentGUI;
class PolicykitAgent : public PolkitQt1::Agent::Listener
{
Q_OBJECT
public:
PolicykitAgent(QObject *parent = 0);
~PolicykitAgent();
public 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);
private:
bool m_inProgress;
PolicykitAgentGUI * m_gui;
QHash<PolkitQt1::Agent::Session*,PolkitQt1::Identity> m_SessionIdentity;
};
} // namespace
#endif
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* LXDE-Qt - a lightweight, Qt based, desktop toolset
* http://razor-qt.org
*
* Copyright: 2011-2012 Razor team
* Authors:
* Petr Vanek <petr@scribus.info>
*
* This program or 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.1 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
*
* END_COMMON_COPYRIGHT_HEADER */
#include <XdgIcon>
#include "policykitagentgui.h"
namespace LxQtPolicykit
{
PolicykitAgentGUI::PolicykitAgentGUI(const QString &actionId,
const QString &message,
const QString &iconName,
const PolkitQt1::Details &details,
const PolkitQt1::Identity::List &identities)
: QDialog(0, Qt::WindowStaysOnTopHint)
{
setupUi(this);
Q_UNUSED(actionId);
Q_UNUSED(details); // it seems too confusing for end user (=me)
messageLabel->setText(message);
iconLabel->setPixmap(XdgIcon::fromTheme(iconName).pixmap(64, 64));
foreach (PolkitQt1::Identity identity, identities)
{
m_identityMap[identity.toString()] = identity;
identityComboBox->addItem(identity.toString());
}
}
void PolicykitAgentGUI::setPrompt(const PolkitQt1::Identity &identity, const QString &text, bool echo)
{
int ix = identityComboBox->findText(identity.toString());
if (ix != -1)
{
identityComboBox->setCurrentIndex(ix);
passwordEdit->setFocus(Qt::OtherFocusReason);
}
promptLabel->setText(text);
passwordEdit->setEchoMode(echo ? QLineEdit::Normal : QLineEdit::Password);
}
PolkitQt1::Identity PolicykitAgentGUI::identity()
{
return m_identityMap[identityComboBox->currentText()];
}
QString PolicykitAgentGUI::response()
{
return passwordEdit->text();
}
} // namespace
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* LXDE-Qt - a lightweight, Qt based, desktop toolset
* http://razor-qt.org
*
* Copyright: 2011-2012 Razor team
* Authors:
* Petr Vanek <petr@scribus.info>
*
* This program or 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.1 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
*
* END_COMMON_COPYRIGHT_HEADER */
#ifndef POLICYKITAGENTGUI_H
#define POLICYKITAGENTGUI_H
#include <PolkitQt1/Details>
#include <PolkitQt1/Identity>
#include "ui_policykitagentgui.h"
namespace LxQtPolicykit
{
class PolicykitAgentGUI : public QDialog, public Ui::PolicykitAgentGUI
{
Q_OBJECT
public:
PolicykitAgentGUI(const QString &actionId,
const QString &message,
const QString &iconName,
const PolkitQt1::Details &details,
const PolkitQt1::Identity::List &identities);
void setPrompt(const PolkitQt1::Identity &identity, const QString &text, bool echo);
PolkitQt1::Identity identity();
QString response();
private:
QHash<QString,PolkitQt1::Identity> m_identityMap;
};
} // namespace
#endif
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PolicykitAgentGUI</class>
<widget class="QDialog" name="PolicykitAgentGUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>310</width>
<height>173</height>
</rect>
</property>
<property name="windowTitle">
<string>Authentication Required</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="iconLabel">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string notr="true">iconLabel</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="messageLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">messageLabel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Identity:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="identityComboBox"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="promptLabel">
<property name="text">
<string>Password:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="passwordEdit">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>PolicykitAgentGUI</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>PolicykitAgentGUI</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>295</x>
<y>261</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
#!/bin/bash
pkexec --user root /usr/bin/pk-example-frobnicate
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="en_US">
<context>
<name>PolicykitAgentGUI</name>
<message>
<source>Authentication Required</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Identity:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Password:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LxQtPolicykit::PolicykitAgent</name>
<message>
<source>PolicyKit Information</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Authorization Failed</source>
<translation type="unfinished"></translation>