summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2021-12-28 09:48:56 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2021-12-28 09:59:28 +0900
commiteb684d7fa3c107977074672615c957086e7e9088 (patch)
tree60a255e522fa34a81aab3a701b2859454f09175e
parentab12cfe230b06ba2a4505e681d7b8ce6ea35fb34 (diff)
downloadpolkit-agent-tde-eb684d7f.tar.gz
polkit-agent-tde-eb684d7f.zip
Conversion of package functionality.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r--CMakeLists.txt.ORI17
-rw-r--r--src/AuthDetailsWidget.ui94
-rw-r--r--src/AuthDialog.cpp587
-rw-r--r--src/AuthDialog.h78
-rw-r--r--src/AuthDialog.ui171
-rw-r--r--src/AuthDialogWidget.ui168
-rw-r--r--src/CMakeLists.txt9
-rw-r--r--src/authdetails.ui91
-rw-r--r--src/main.cpp48
-rw-r--r--src/org.freedesktop.PolicyKit.AuthenticationAgent.xml2
-rw-r--r--src/org.kde.Polkit1AuthAgent.xml10
-rw-r--r--src/policykitlistener.cpp237
-rw-r--r--src/policykitlistener.h80
-rw-r--r--src/polkit-agent-tde.cpp (renamed from src/policykitkde.h)25
-rw-r--r--src/polkit-agent-tde.h (renamed from src/policykitkde.cpp)35
-rw-r--r--src/polkit-listener.cpp226
-rw-r--r--src/polkit-listener.h71
17 files changed, 941 insertions, 1008 deletions
diff --git a/CMakeLists.txt.ORI b/CMakeLists.txt.ORI
new file mode 100644
index 0000000..8b2ebe7
--- /dev/null
+++ b/CMakeLists.txt.ORI
@@ -0,0 +1,17 @@
+kde4_add_executable(polkit-kde-authentication-agent-1 ${policykit_SRCS})
+
+target_link_libraries(polkit-kde-authentication-agent-1
+ ${KDE4_TDEUI_LIBS}
+ ${POLKITQT-1_LIBRARIES}
+)
+
+configure_file(polkit-kde-authentication-agent-1.desktop.in ${CMAKE_BINARY_DIR}/polkit-kde-authentication-agent-1.desktop)
+
+install(TARGETS polkit-kde-authentication-agent-1 DESTINATION ${LIBEXEC_INSTALL_DIR})
+
+install(FILES ${CMAKE_BINARY_DIR}/polkit-kde-authentication-agent-1.desktop DESTINATION ${AUTOSTART_INSTALL_DIR})
+
+install(FILES policykit1-kde.notifyrc DESTINATION ${DATA_INSTALL_DIR}/policykit1-kde)
+
+include(MacroOptionalAddSubdirectory)
+macro_optional_add_subdirectory( po )
diff --git a/src/AuthDetailsWidget.ui b/src/AuthDetailsWidget.ui
new file mode 100644
index 0000000..cf2976d
--- /dev/null
+++ b/src/AuthDetailsWidget.ui
@@ -0,0 +1,94 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+ <class>AuthDetailsWidget</class>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>AuthDetailsWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>273</width>
+ <height>80</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>gridLayout</cstring>
+ </property>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>label</cstring>
+ </property>
+ <property name="text">
+ <string>Application:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="0">
+ <property name="name">
+ <cstring>label_3</cstring>
+ </property>
+ <property name="text">
+ <string>Action:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="3" column="0">
+ <property name="name">
+ <cstring>vendorL</cstring>
+ </property>
+ <property name="text">
+ <string>Vendor:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="1" colspan="3">
+ <property name="name">
+ <cstring>action_label</cstring>
+ </property>
+ <property name="text">
+ <string>Action:</string>
+ </property>
+ </widget>
+ <widget class="KURLLabel" row="3" column="1" colspan="3">
+ <property name="name">
+ <cstring>vendorUL</cstring>
+ </property>
+ <property name="text">
+ <string>Vendor:</string>
+ </property>
+ <property name="tipText">
+ <string/>
+ </property>
+ <property name="useTips">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="Line" row="0" column="0" colspan="4">
+ <property name="name">
+ <cstring>line</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="1" colspan="3">
+ <property name="name">
+ <cstring>app_label</cstring>
+ </property>
+ <property name="text">
+ <string>Application:</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <includes>
+ <include location="global" impldecl="in implementation">kurllabel.h</include>
+ </includes>
+</UI>
diff --git a/src/AuthDialog.cpp b/src/AuthDialog.cpp
index e90a851..2079bca 100644
--- a/src/AuthDialog.cpp
+++ b/src/AuthDialog.cpp
@@ -1,4 +1,4 @@
-/* This file is part of the KDE project
+/* This file is part of the TDE project
Copyright (C) 2007-2008 Gökçen Eraslan <gokcen@pardus.org.tr>
Copyright (C) 2008 Dirk Mueller <mueller@kde.org>
Copyright (C) 2008 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
@@ -18,116 +18,100 @@
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 "AuthDialog.h"
-
-#include <TQtCore/TQProcess>
-#include <TQtGui/TQPainter>
-#include <TQtGui/TQStandardItemModel>
-#include <KDebug>
-
-#include <TDEToolInvocation>
-#include <KUser>
-
-#include <PolkitTQt1/Authority>
-#include <PolkitTQt1/Details>
-
-#include <KWindowSystem>
-#include <KNotification>
-
-AuthDialog::AuthDialog(const TQString &actionId,
- const TQString &message,
- const TQString &iconName,
- const PolkitTQt1::Details &details,
- const PolkitTQt1::Identity::List &identities,
- WId parent)
- : KDialog(0)
+#include "AuthDialogWidget.h"
+
+#include <tqlabel.h>
+#include <tqprocess.h>
+#include <tqpainter.h>
+
+#include <kcombobox.h>
+#include <kdebug.h>
+#include <kiconloader.h>
+#include <klineedit.h>
+#include "kuniqueapplication.h"
+#include <kurllabel.h>
+#include <kuser.h>
+#include <tdelocale.h>
+
+#include <PolkitTQt/Authority>
+#include <PolkitTQt/Details>
+
+using namespace PolkitTQt;
+
+AuthDialog::AuthDialog(const TQString &actionId, const TQString &message,
+ const TQString &iconName, const PolkitTQt::Details &details,
+ const Identity::List &identities) :
+ KDialogBase(0, 0, true, TQString::null, Ok|Cancel|Details, Ok),
+ m_authWidget(new AuthDialogWidget(this))
{
- // KAuth is able to circumvent polkit's limitations, and manages to send the wId to the auth agent.
- // If we received it, we use KWindowSystem to associate this dialog correctly.
- if (parent > 0) {
- kDebug() << "Associating the dialog with " << parent << " this dialog is " << winId();
-
- // Set the parent
- KWindowSystem::setMainWindow(this, parent);
-
- // Set modal
- KWindowSystem::setState(winId(), NET::Modal);
- }
-
- setupUi(mainWidget());
- setButtons(Ok | Cancel | Details);
-
- if (message.isEmpty()) {
- kWarning() << "Could not get action message for action.";
- lblHeader->hide();
- } else {
- kDebug() << "Message of action: " << message;
- lblHeader->setText("<h3>" + message + "</h3>");
- setCaption(message);
- m_message = message;
- }
-
- // loads the standard key icon
- TQPixmap icon = TDEIconLoader::global()->loadIcon("dialog-password",
- TDEIconLoader::NoGroup,
- TDEIconLoader::SizeHuge,
- TDEIconLoader::DefaultState);
- // create a painter to paint the action icon over the key icon
- TQPainter painter(&icon);
- const int iconSize = icon.size().width();
- // the the emblem icon to size 32
- int overlaySize = 32;
- // try to load the action icon
- const TQPixmap pixmap = TDEIconLoader::global()->loadIcon(iconName,
- TDEIconLoader::NoGroup,
- overlaySize,
- TDEIconLoader::DefaultState,
- TQStringList(),
- 0,
- true);
- // if we're able to load the action icon paint it over the
- // key icon.
- if (!pixmap.isNull()) {
- TQPoint startPoint;
- // bottom right corner
- startPoint = TQPoint(iconSize - overlaySize - 2,
- iconSize - overlaySize - 2);
- painter.drawPixmap(startPoint, pixmap);
- }
-
- setWindowIcon(icon);
- lblPixmap->setPixmap(icon);
-
- // find action description for actionId
- foreach(const PolkitTQt1::ActionDescription &desc, PolkitTQt1::Authority::instance()->enumerateActionsSync()) {
- if (actionId == desc.actionId()) {
- m_actionDescription = desc;
- kDebug() << "Action description has been found" ;
- break;
- }
- }
-
- AuthDetails *detailsDialog = new AuthDetails(details, m_actionDescription, m_appname, this);
- setDetailsWidget(detailsDialog);
-
- userCB->hide();
- lePassword->setFocus();
-
- errorMessageKTW->hide();
-
- // If there is more than 1 identity we will show the combobox for user selection
- if (identities.size() > 1) {
- connect(userCB, SIGNAL(currentIndexChanged(int)),
- this, SLOT(on_userCB_currentIndexChanged(int)));
-
- createUserCB(identities);
- } else {
- userCB->addItem("", TQVariant(identities[0].toString()));
- userCB->setCurrentIndex(0);
+ setMainWidget(m_authWidget);
+
+ if (message.isEmpty())
+ {
+ kdWarning() << "Could not get action message for action." << endl;
+ m_authWidget->lblHeader->hide();
+ }
+ else
+ {
+ kdDebug() << "Message of action: " << message << endl;
+ m_authWidget->lblHeader->setText("<h3>" + message + "</h3>");
+ setCaption(message);
+ m_message = message;
+ }
+
+ // loads the standard key icon
+ TQPixmap icon = TDEGlobal::iconLoader()->loadIcon("password", TDEIcon::NoGroup,
+ TDEIcon::SizeHuge, TDEIcon::DefaultState);
+ // create a painter to paint the action icon over the key icon
+ TQPainter painter(&icon);
+ const int iconSize = icon.size().width();
+ int overlaySize = 32;
+ const TQPixmap pixmap = TDEGlobal::iconLoader()->loadIcon(iconName, TDEIcon::NoGroup,
+ overlaySize, TDEIcon::DefaultState, 0, true);
+ if (!pixmap.isNull())
+ {
+ // bottom right corner
+ TQPoint startPoint = TQPoint(iconSize - overlaySize - 2, iconSize - overlaySize - 2);
+ painter.drawPixmap(startPoint, pixmap);
+ }
+
+ setIcon(icon);
+ m_authWidget->lblPixmap->setPixmap(icon);
+
+ // find action description for actionId
+ for (const ActionDescription &desc : Authority::instance()->enumerateActionsSync())
+ {
+ if (actionId == desc.actionId())
+ {
+ m_actionDescription = desc;
+ kdDebug() << "Action description has been found" << endl;
+ break;
}
+ }
+
+ AuthDetails *detailsDialog = new AuthDetails(details, m_actionDescription, m_appname, this);
+ setDetailsWidget(detailsDialog);
+
+ m_authWidget->userCB->hide();
+ m_authWidget->lePassword->setFocus();
+ m_authWidget->errorMessageKTW->hide();
+
+ // If there is more than 1 identity we will show the combobox for user selection
+ if (identities.size() > 1)
+ {
+ connect(m_authWidget->userCB, SIGNAL(activated(int)),
+ this, SLOT(on_userCB_currentIndexChanged(int)));
+ createUserCB(identities);
+ }
+ else
+ {
+ m_authWidget->userCB->insertItem("");
+ m_userData.append(identities[0].toString());
+ m_authWidget->userCB->setCurrentItem(0);
+ }
}
AuthDialog::~AuthDialog()
@@ -136,242 +120,229 @@ AuthDialog::~AuthDialog()
void AuthDialog::accept()
{
- // Do nothing, do not close the dialog. This is needed so that the dialog stays
- lePassword->setEnabled(false);
- return;
+ // Do nothing, do not close the dialog. This is needed so that the dialog stays
+ m_authWidget->lePassword->setEnabled(false);
+ return;
}
void AuthDialog::setRequest(const TQString &request, bool requiresAdmin)
{
- kDebug() << request;
- PolkitTQt1::Identity identity = adminUserSelected();
- if (request.startsWith(TQLatin1String("password:"), TQt::CaseInsensitive)) {
- if (requiresAdmin) {
- if (!identity.isValid()) {
- lblPassword->setText(i18n("Password for root:"));
- } else {
- lblPassword->setText(i18n("Password for %1:",
- identity.toString().remove("unix-user:")));
- }
- } else {
- lblPassword->setText(i18n("Password:"));
- }
- } else if (request.startsWith(TQLatin1String("password or swipe finger:"),
- TQt::CaseInsensitive)) {
- if (requiresAdmin) {
- if (!identity.isValid()) {
- lblPassword->setText(i18n("Password or swipe finger for root:"));
- } else {
- lblPassword->setText(i18n("Password or swipe finger for %1:",
- identity.toString().remove("unix-user:")));
- }
- } else {
- lblPassword->setText(i18n("Password or swipe finger:"));
- }
- } else {
- lblPassword->setText(request);
+ kdDebug() << request << endl;
+ Identity identity = adminUserSelected();
+ if (request.startsWith("password:", false))
+ {
+ if (requiresAdmin)
+ {
+ if (!identity.isValid())
+ {
+ m_authWidget->lblPassword->setText(i18n("Password for root:"));
+ }
+ else
+ {
+ TQString username = identity.toString().remove("unix-user:");
+ m_authWidget->lblPassword->setText(i18n("Password for %1:").arg(username));
+ }
}
-
+ else
+ {
+ m_authWidget->lblPassword->setText(i18n("Password:"));
+ }
+ }
+ else if (request.startsWith("password or swipe finger:"), false)
+ {
+ if (requiresAdmin)
+ {
+ if (!identity.isValid())
+ {
+ m_authWidget->lblPassword->setText(i18n("Password or swipe finger for root:"));
+ }
+ else
+ {
+ TQString username = identity.toString().remove("unix-user:");
+ m_authWidget->lblPassword->setText(i18n("Password or swipe finger for %1:").arg(username));
+ }
+ }
+ else
+ {
+ m_authWidget->lblPassword->setText(i18n("Password or swipe finger:"));
+ }
+ }
+ else
+ {
+ m_authWidget->lblPassword->setText(request);
+ }
}
void AuthDialog::setOptions()
{
- lblContent->setText(i18n("An application is attempting to perform an action that requires privileges."
- " Authentication is required to perform this action."));
+ m_authWidget->lblContent->setText(i18n("An application is attempting to perform an action "
+ "that requires privileges. Authentication is required to perform this action."));
}
-void AuthDialog::createUserCB(const PolkitTQt1::Identity::List &identities)
+void AuthDialog::createUserCB(const Identity::List &identities)
{
- /* if we've already built the list of admin users once, then avoid
- * doing it again.. (this is mainly used when the user entered the
- * wrong password and the dialog is recycled)
- */
- if (identities.count() && (userCB->count() - 1) != identities.count()) {
- // Clears the combobox in the case some user be added
- userCB->clear();
-
- // Adds a Dummy user
- userCB->addItem(i18n("Select User"), qVariantFromValue<TQString> (TQString()));
- qobject_cast<TQStandardItemModel *>(userCB->model())->item(userCB->count()-1)->setEnabled(false);
-
- // For each user
- int index = 1; // Start at 1 because of the "Select User" entry
- int currentUserIndex = -1;
- const KUser currentUser;
- foreach(const PolkitTQt1::Identity &identity, identities) {
- // First check to see if the user is valid
- kDebug() << "User: " << identity.toString();
- const KUser user(identity.toString().remove("unix-user:"));
- if (!user.isValid()) {
- kWarning() << "User invalid: " << user.loginName();
- continue;
- }
-
- // Display user Full Name IF available
- TQString display;
- if (!user.property(KUser::FullName).toString().isEmpty()) {
- display = i18nc("%1 is the full user name, %2 is the user login name", "%1 (%2)", user.property(KUser::FullName).toString(), user.loginName());
- } else {
- display = user.loginName();
- }
-
- TDEIcon icon;
- // load user icon face
- if (!user.faceIconPath().isEmpty()) {
- icon = TDEIcon(user.faceIconPath());
- } else {
- icon = TDEIcon("user-identity");
- }
- // appends the user item
- userCB->addItem(icon, display, qVariantFromValue<TQString> (identity.toString()));
-
- if (user == currentUser) {
- currentUserIndex = index;
- }
- ++index;
- }
-
- // Show the widget and set focus
- if (currentUserIndex != -1) {
- userCB->setCurrentIndex(currentUserIndex);
- }
- userCB->show();
+ /* if we've already built the list of admin users once, then avoid
+ * doing it again.. (this is mainly used when the user entered the
+ * wrong password and the dialog is recycled)
+ */
+ if (identities.count() && (m_authWidget->userCB->count() - 1) != identities.count())
+ {
+ // Clears the combobox in the case some user be added
+ m_authWidget->userCB->clear();
+ m_userData.clear();
+
+ // Adds a Dummy user
+ m_authWidget->userCB->insertItem(i18n("Select User"));
+ m_userData.append(TQString::null);
+
+ // For each user
+ int index = 1; // Start at 1 because of the "Select User" entry
+ int currentUserIndex = -1;
+ const KUser currentUser;
+ for (const Identity &identity : identities)
+ {
+ // First check to see if the user is valid
+ kdDebug() << "User: " << identity.toString() << endl;
+ const KUser user(identity.toString().remove("unix-user:"));
+ if (!user.isValid())
+ {
+ kdWarning() << "User invalid: " << user.loginName() << endl;
+ continue;
+ }
+
+ // Display user full Name if available
+ TQString display;
+ if (!user.fullName().isEmpty())
+ {
+ display = user.fullName() + " (" + user.loginName() + ")";
+ }
+ else
+ {
+ display = user.loginName();
+ }
+ m_authWidget->userCB->insertItem(display);
+ m_userData.append(identity.toString());
+
+ if (user == currentUser)
+ {
+ currentUserIndex = index;
+ }
+ ++index;
+ }
+
+ // Show the widget and set focus
+ if (currentUserIndex != -1)
+ {
+ m_authWidget->userCB->setCurrentItem(currentUserIndex);
}
+ m_authWidget->userCB->show();
+ }
}
-PolkitTQt1::Identity AuthDialog::adminUserSelected() const
+Identity AuthDialog::adminUserSelected() const
{
- if (userCB->currentIndex() == -1)
- return PolkitTQt1::Identity();
-
- TQString id = userCB->itemData(userCB->currentIndex()).toString();
- if (id.isEmpty())
- return PolkitTQt1::Identity();
- return PolkitTQt1::Identity::fromString(id);
+ if (m_authWidget->userCB->currentItem() == -1)
+ {
+ return Identity();
+ }
+
+ TQString id = m_userData[m_authWidget->userCB->currentItem()];
+ if (id.isEmpty())
+ {
+ return Identity();
+ }
+ return Identity::fromString(id);
}
void AuthDialog::on_userCB_currentIndexChanged(int /*index*/)
{
- PolkitTQt1::Identity identity = adminUserSelected();
- // itemData is Null when "Select user" is selected
- if (!identity.isValid()) {
- lePassword->setEnabled(false);
- lblPassword->setEnabled(false);
- enableButtonOk(false);
- } else {
- lePassword->setEnabled(true);
- lblPassword->setEnabled(true);
- enableButtonOk(true);
- // We need this to restart the auth with the new user
- emit adminUserSelected(identity);
- // git password label focus
- lePassword->setFocus();
- }
+ Identity identity = adminUserSelected();
+ // identity is now valid when "Select user" is selected
+ if (!identity.isValid())
+ {
+ m_authWidget->lePassword->setEnabled(false);
+ m_authWidget->lblPassword->setEnabled(false);
+ enableButtonOK(false);
+ }
+ else
+ {
+ m_authWidget->lePassword->setEnabled(true);
+ m_authWidget->lblPassword->setEnabled(true);
+ enableButtonOK(true);
+ // We need this to restart the auth with the new user
+ emit adminUserSelected(identity);
+ // give password label focus
+ m_authWidget->lePassword->setFocus();
+ }
}
TQString AuthDialog::password() const
{
- return lePassword->text();
+ return m_authWidget->lePassword->text();
}
void AuthDialog::authenticationFailure()
{
- errorMessageKTW->setText(i18n("Authentication failure, please try again."), KTitleWidget::ErrorMessage);
- TQFont bold = font();
- bold.setBold(true);
- lblPassword->setFont(bold);
- lePassword->setEnabled(true);
- lePassword->clear();
- lePassword->setFocus();
+ // TODO errorMessageKTW->setText(i18n("Authentication failure, please try again."), KTitleWidget::ErrorMessage);
+ TQFont bold = font();
+ bold.setBold(true);
+ m_authWidget->errorMessageKTW->setText(i18n("Authentication failure, please try again."));
+ m_authWidget->errorMessageKTW->setFont(bold);
+ m_authWidget->errorMessageKTW->show();
+ m_authWidget->lePassword->setEnabled(true);
+ m_authWidget->lePassword->clear();
+ m_authWidget->lePassword->setFocus();
}
-void AuthDialog::showEvent(TQShowEvent *event)
+AuthDetails::AuthDetails(const Details &details, const ActionDescription &actionDescription,
+ const TQString &appname, TQWidget *parent) : AuthDetailsWidget(parent)
{
- KDialog::showEvent(event);
- if (winId() != KWindowSystem::activeWindow())
- {
- KNotification *notification = new KNotification("authenticate", this,
- KNotification::Persistent | KNotification::CloseWhenWidgetActivated);
- kDebug() << "Notificate: " << notification->eventId();
- notification->setText(m_message);
- TQPixmap icon = TDEIconLoader::global()->loadIcon("dialog-password",
- TDEIconLoader::NoGroup,
- TDEIconLoader::SizeHuge,
- TDEIconLoader::DefaultState);
- notification->setPixmap(icon);
- notification->setActions(TQStringList() << i18n("Switch to dialog") << i18n("Cancel"));
-
- connect(notification, SIGNAL(activated(uint)), this, SLOT(notificationActivated(uint)));
- notification->sendEvent();
- }
-
+ app_label->setText(appname);
+
+ for (const TQString &key : details.keys())
+ {
+ int row = AuthDetailsWidgetLayout->numRows() + 1;
+
+ TQLabel *keyLabel = new TQLabel(this);
+ keyLabel->setText(key);
+ AuthDetailsWidgetLayout->addWidget(keyLabel, row, 0);
+
+ TQLabel *valueLabel = new TQLabel(this);
+ valueLabel->setText(details.lookup(key));
+ AuthDetailsWidgetLayout->addWidget(valueLabel, row, 1);
+ }
+
+ action_label->setText(actionDescription.description());
+
+ TQString vendor = actionDescription.vendorName();
+ TQString vendorUrl = actionDescription.vendorUrl();
+
+ if (!vendor.isEmpty())
+ {
+ vendorUL->setText(vendor);
+ vendorUL->setTipText(vendorUrl);
+ vendorUL->setURL(vendorUrl);
+ }
+ else if (!vendorUrl.isEmpty())
+ {
+ vendorUL->setText(vendorUrl);
+ vendorUL->setTipText(vendorUrl);
+ vendorUL->setURL(vendorUrl);
+ }
+ else
+ {
+ vendorL->hide();
+ vendorUL->hide();
+ }
+
+ connect(vendorUL, TQT_SIGNAL(leftClickedURL(const TQString&)),
+ TQT_SLOT(openUrl(const TQString&)));
}
-void AuthDialog::notificationActivated(unsigned int action)
+void AuthDetails::openUrl(const TQString &url)
{
- kDebug() << "notificationActivated: " << action;
- if (action == 1)
- {
- KWindowSystem::forceActiveWindow(winId());
- }
-}
-
-AuthDetails::AuthDetails(const PolkitTQt1::Details &details,
- const PolkitTQt1::ActionDescription &actionDescription,
- const TQString &appname,
- TQWidget *parent)
- : TQWidget(parent)
-{
- setupUi(this);
-
- app_label->setText(appname);
-
- foreach(const TQString &key, details.keys()) { //krazy:exclude=foreach (Details is not a map/hash, but rather a method)
- int row = gridLayout->rowCount() + 1;
-
- TQLabel *keyLabel = new TQLabel(this);
- keyLabel->setText(i18nc("%1 is the name of a detail about the current action "
- "provided by polkit", "%1:", key));
- gridLayout->addWidget(keyLabel, row, 0);
-
- TQLabel *valueLabel = new TQLabel(this);
- valueLabel->setText(details.lookup(key));
- gridLayout->addWidget(valueLabel, row, 1);
- }
-
- action_label->setText(actionDescription.description());
-
- action_label->setTipText(i18n("Click to edit %1", actionDescription.actionId()));
- action_label->setUrl(actionDescription.actionId());
-
- TQString vendor = actionDescription.vendorName();
- TQString vendorUrl = actionDescription.vendorUrl();
-
- if (!vendor.isEmpty()) {
- vendorUL->setText(vendor);
- vendorUL->setTipText(i18n("Click to open %1", vendorUrl));
- vendorUL->setUrl(vendorUrl);
- } else if (!vendorUrl.isEmpty()) {
- vendorUL->setText(vendorUrl);
- vendorUL->setTipText(i18n("Click to open %1", vendorUrl));
- vendorUL->setUrl(vendorUrl);
- } else {
- vendorL->hide();
- vendorUL->hide();
- }
-
- connect(vendorUL, SIGNAL(leftClickedUrl(TQString)), SLOT(openUrl(TQString)));
- connect(action_label, SIGNAL(leftClickedUrl(TQString)), SLOT(openAction(TQString)));
-}
-
-void AuthDetails::openUrl(const TQString& url)
-{
- TDEToolInvocation::invokeBrowser(url);
-}
-
-void AuthDetails::openAction(const TQString &url)
-{
- TQProcess::startDetached("polkit-kde-authorization", TQStringList() << url);
+ kapp->invokeBrowser(url);
}
#include "AuthDialog.moc"
+
diff --git a/src/AuthDialog.h b/src/AuthDialog.h
index 7aa42eb..9c8cb65 100644
--- a/src/AuthDialog.h
+++ b/src/AuthDialog.h
@@ -1,4 +1,4 @@
-/* This file is part of the KDE project
+/* This file is part of the TDE project
Copyright (C) 2007-2008 Gökçen Eraslan <gokcen@pardus.org.tr>
Copyright (C) 2008 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
Copyright (C) 2010 Dario Freddi <drf@kde.org>
@@ -17,74 +17,72 @@
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 AUTHDIALOG_H
#define AUTHDIALOG_H
-#include "ui_AuthDialog.h"
-#include "ui_authdetails.h"
+#include <kdialogbase.h>
+#include "AuthDetailsWidget.h"
-#include <PolkitTQt1/Identity>
-#include <PolkitTQt1/ActionDescription>
+#include <PolkitTQt/Identity>
+#include <PolkitTQt/ActionDescription>
-namespace PolkitTQt1
+namespace PolkitTQt
{
class Details;
}
-class AuthDialog : public KDialog, private Ui::AuthDialog
+class AuthDialogWidget;
+
+class AuthDialog : public KDialogBase
{
- Q_OBJECT
-public:
- AuthDialog(const TQString &actionId,
- const TQString &message,
- const TQString &iconName,
- const PolkitTQt1::Details &details,
- const PolkitTQt1::Identity::List &identities,
- WId parent);
+ Q_OBJECT
+
+ public:
+ AuthDialog(const TQString &actionId, const TQString &message,
+ const TQString &iconName, const PolkitTQt::Details &details,
+ const PolkitTQt::Identity::List &identities);
~AuthDialog();
void setRequest(const TQString &request, bool requiresAdmin);
void setOptions();
- TQString password() const;
void authenticationFailure();
+ TQString password() const;
+ PolkitTQt::Identity adminUserSelected() const;
- PolkitTQt1::Identity adminUserSelected() const;
-
- PolkitTQt1::ActionDescription m_actionDescription;
+ PolkitTQt::ActionDescription m_actionDescription;
-signals:
- void adminUserSelected(PolkitTQt1::Identity);
+ signals:
+ void adminUserSelected(const PolkitTQt::Identity&);
-public slots:
+ public slots:
virtual void accept();
-private slots:
+ private slots:
void on_userCB_currentIndexChanged(int index);
- void notificationActivated(unsigned int action);
-private:
+ private:
TQString m_appname;
TQString m_message;
+ AuthDialogWidget *m_authWidget;
+ TQStringList m_userData;
- void createUserCB(const PolkitTQt1::Identity::List &identities);
- void showEvent(TQShowEvent *);
+ void createUserCB(const PolkitTQt::Identity::List &identities);
};
-class AuthDetails : public TQWidget, private Ui::AuthDetails
+class AuthDetails : public AuthDetailsWidget
{
- Q_OBJECT
-public:
- AuthDetails(const PolkitTQt1::Details &details,
- const PolkitTQt1::ActionDescription &actionDescription,
- const TQString &appname,
- TQWidget *parent);
-
-private slots:
- void openUrl(const TQString&);
- void openAction(const TQString&);
+ Q_OBJECT
+
+ public:
+ AuthDetails(const PolkitTQt::Details &details,
+ const PolkitTQt::ActionDescription &actionDescription,
+ const TQString &appname, TQWidget *parent);
+
+ private slots:
+ void openUrl(const TQString &url);
};
-#endif // AUTHDIALOG_H
+#endif
+
diff --git a/src/AuthDialog.ui b/src/AuthDialog.ui
deleted file mode 100644
index 43282f1..0000000
--- a/src/AuthDialog.ui
+++ /dev/null
@@ -1,171 +0,0 @@
-<ui version="4.0" >
- <class>AuthDialog</class>
- <widget class="TQWidget" name="AuthDialog" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>335</width>
- <height>193</height>
- </rect>
- </property>
- <property name="sizePolicy" >
- <sizepolicy vsizetype="MinimumExpanding" hsizetype="MinimumExpanding" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <layout class="TQGridLayout" name="gridLayout" >
- <item rowspan="6" row="0" column="0" >
- <layout class="TQVBoxLayout" name="verticalLayout" >
- <item>
- <widget class="TQLabel" name="lblPixmap" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text" >
- <string notr="true">Lock Icon here</string>
- </property>
- <property name="wordWrap" >
- <bool>false</bool>
- </property>
- <property name="buddy" >
- <cstring>lePassword</cstring>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer" >
- <property name="orientation" >
- <enum>TQt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>20</width>
- <height>92</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item row="0" column="1" colspan="3" >
- <layout class="TQVBoxLayout" name="verticalLayout_2" >
- <item>
- <widget class="TQLabel" name="lblHeader" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="MinimumExpanding" hsizetype="MinimumExpanding" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text" >
- <string notr="true">&lt;b>Header is here!&lt;/b></string>
- </property>
- <property name="wordWrap" >
- <bool>true</bool>
- </property>
- <property name="buddy" >
- <cstring>lePassword</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="TQLabel" name="lblContent" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="MinimumExpanding" hsizetype="MinimumExpanding" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text" >
- <string notr="true">&lt;i>Content&lt;/i></string>
- </property>
- <property name="wordWrap" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="2" column="1" colspan="3" >
- <widget class="KTitleWidget" name="errorMessageKTW" />
- </item>
- <item row="3" column="1" colspan="2" >
- <widget class="TQLabel" name="lblPassword" >
- <property name="text" >
- <string>Password:</string>
- </property>
- <property name="buddy" >
- <cstring>lePassword</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="3" >
- <widget class="KLineEdit" name="lePassword" >
- <property name="echoMode" >
- <enum>TQLineEdit::Password</enum>
- </property>
- <property name="passwordMode" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="1" colspan="3" >
- <widget class="KComboBox" name="userCB" />
- </item>
- </layout>
- <zorder>errorMessageKTW</zorder>
- <zorder>lblPassword</zorder>
- <zorder>lePassword</zorder>
- <zorder>cbRemember</zorder>
- <zorder>cbSessionOnly</zorder>
- <zorder>horizontalSpacer</zorder>
- <zorder>userCB</zorder>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>TQComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>TQLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
- <class>KTitleWidget</class>
- <extends>TQWidget</extends>
- <header>ktitlewidget.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>userCB</tabstop>
- <tabstop>lePassword</tabstop>
- <tabstop>cbRemember</tabstop>
- <tabstop>cbSessionOnly</tabstop>
- </tabstops>
- <resources/>
- <connections>
- <connection>
- <sender>cbRemember</sender>
- <signal>toggled(bool)</signal>
- <receiver>cbSessionOnly</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>259</x>
- <y>161</y>
- </hint>
- <hint type="destinationlabel" >
- <x>161</x>
- <y>169</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/src/AuthDialogWidget.ui b/src/AuthDialogWidget.ui
new file mode 100644
index 0000000..0425eb1
--- /dev/null
+++ b/src/AuthDialogWidget.ui
@@ -0,0 +1,168 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+ <class>AuthDialogWidget</class>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>AuthDialogWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>335</width>
+ <height>193</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>gridLayout</cstring>
+ </property>
+ <widget class="TQLayoutWidget" rowspan="6" row="0" column="0">
+ <property name="name">
+ <cstring>verticalLayout</cstring>
+ </property>
+ <vbox>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>lblPixmap</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Lock Icon here</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak</set>
+ </property>
+ <property name="buddy">
+ <cstring>lePassword</cstring>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>verticalSpacer</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>92</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="TQLayoutWidget" row="0" column="1" colspan="3">
+ <property name="name">
+ <cstring>verticalLayout_2</cstring>
+ </property>
+ <vbox>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>lblHeader</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&lt;b>Header is here!&lt;/b></string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak</set>
+ </property>
+ <property name="buddy">
+ <cstring>lePassword</cstring>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>lblContent</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string notr="true">&lt;i>Content&lt;/i></string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak</set>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="TQLabel" row="2" column="1" colspan="3">
+ <property name="name">
+ <cstring>errorMessageKTW</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="3" column="1" colspan="2">
+ <property name="name">
+ <cstring>lblPassword</cstring>
+ </property>
+ <property name="text">
+ <string>Password:</string>
+ </property>
+ <property name="buddy">
+ <cstring>lePassword</cstring>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="3" column="3">
+ <property name="name">
+ <cstring>lePassword</cstring>
+ </property>
+ <property name="echoMode">
+ <enum>Password</enum>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="1" column="1" colspan="3">
+ <property name="name">
+ <cstring>userCB</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <!--customwidgets>
+ <customwidget>
+ <class>KTitleWidget</class>
+ <extends>TQWidget</extends>
+ <header>ktitlewidget.h</header>
+ </customwidget>
+ </customwidgets-->
+ <tabstops>
+ <tabstop>userCB</tabstop>
+ <tabstop>lePassword</tabstop>
+ </tabstops>
+</UI>
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0f1b794..c6d65bf 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -12,10 +12,12 @@
include_directories(
${CMAKE_SOURCE_DIR}
+ ${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${TQT_INCLUDE_DIRS}
${TDE_INCLUDE_DIR}
+ ${POLKIT_TQT_INCLUDE_DIRS}
)
link_directories(
@@ -26,7 +28,8 @@ link_directories(
##### executables #########################
tde_add_executable( polkit-agent-tde AUTOMOC
- SOURCES main.cpp
- LINK tdecore-shared tdeui-shared
- DESTINATION ${BIN_INSTALL_DIR}
+ SOURCES AuthDialogWidget.ui AuthDetailsWidget.ui AuthDialog.h AuthDialog.cpp
+ polkit-listener.h polkit-listener.cpp polkit-agent-tde.h polkit-agent-tde.cpp main.cpp
+ LINK tdecore-shared tdeui-shared polkit-tqt-core polkit-tqt-agent
+ DESTINATION ${BIN_INSTALL_DIR}
)
diff --git a/src/authdetails.ui b/src/authdetails.ui
deleted file mode 100644
index 04a2957..0000000
--- a/src/authdetails.ui
+++ /dev/null
@@ -1,91 +0,0 @@
-<ui version="4.0" >
- <class>AuthDetails</class>
- <widget class="TQWidget" name="AuthDetails" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>273</width>
- <height>80</height>
- </rect>
- </property>
- <property name="sizePolicy" >
- <sizepolicy vsizetype="MinimumExpanding" hsizetype="MinimumExpanding" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <layout class="TQGridLayout" name="gridLayout" >
- <item row="1" column="0" >
- <widget class="TQLabel" name="label" >
- <property name="text" >
- <string>Application:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0" >
- <widget class="TQLabel" name="label_3" >
- <property name="text" >
- <string>Action:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0" >
- <widget class="TQLabel" name="vendorL" >
- <property name="text" >
- <string>Vendor:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1" colspan="3" >
- <widget class="KUrlLabel" name="vendorUL" >
- <property name="text" >
- <string>Vendor:</string>
- </property>
- <property name="tipText" >
- <string/>
- </property>
- <property name="useTips" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="1" colspan="3" >
- <widget class="KUrlLabel" name="action_label" >
- <property name="text" >
- <string>Action:</string>
- </property>
- <property name="tipText" >
- <string/>
- </property>
- <property name="useTips" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="0" colspan="4" >
- <widget class="Line" name="line" >
- <property name="orientation" >
- <enum>TQt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item row="1" column="1" colspan="3" >
- <widget class="TQLabel" name="app_label" >
- <property name="text" >
- <string>Application:</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KUrlLabel</class>
- <extends>TQLabel</extends>
- <header>kurllabel.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
diff --git a/src/main.cpp b/src/main.cpp
index 11a62c5..041413b 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -22,37 +22,25 @@
#include <tdecmdlineargs.h>
#include <tdelocale.h>
-#include <tqpushbutton.h>
-#include <tdeapplication.h>
-//#include "policykitkde.h"
+#include "polkit-agent-tde.h"
int main(int argc, char *argv[])
{
- TDEAboutData aboutData("polkit-agent-tde", I18N_NOOP("Polkit-Agent-TDE"), "0.99.1",
- I18N_NOOP("A Polkit authentication agent for TDE"), TDEAboutData::License_GPL,
- I18N_NOOP("(c) 2009 Red Hat, Inc."));
- aboutData.addAuthor(I18N_NOOP("Jaroslav Reznik"), I18N_NOOP("Maintainer"), "jreznik@redhat.com");
- aboutData.setProductName("policykit-agent-tde");
-
- TDECmdLineArgs::init(argc, argv, &aboutData);
- TDEApplication app;
- TQPushButton *pbQuit = new TQPushButton("Quit", 0);
- app.setMainWidget(pbQuit);
- app.connect(&app, TQT_SIGNAL(lastWindowClosed()), TQT_SLOT(quit()));
- app.connect(pbQuit, TQT_SIGNAL(clicked()), &app, TQT_SLOT(quit()));
- pbQuit->show();
- return app.exec();
-
- /*
- if (!PolicyKitKDE::start()) {
- tqWarning("PolicyKitKDE is already running!\n");
- return 0;
- }
-
- TDECrash::setFlags(TDECrash::AutoRestart);
-
- PolicyKitKDE agent;
- agent.disableSessionManagement();
- agent.exec();
- */
+ TDEAboutData aboutData("polkit-agent-tde", I18N_NOOP("Polkit-Agent-TDE"), "0.99.1",
+ I18N_NOOP("A Polkit authentication agent for TDE"), TDEAboutData::License_GPL,
+ I18N_NOOP("(c) 2009 Red Hat, Inc."));
+ aboutData.addAuthor(I18N_NOOP("Jaroslav Reznik"), I18N_NOOP("Maintainer"), "jreznik@redhat.com");
+ aboutData.setProductName("policykit-agent-tde");
+
+ TDECmdLineArgs::init(argc, argv, &aboutData);
+
+ if (!PolkitAgentTDE::start())
+ {
+ tqWarning("PolkitAgentTDE is already running!\n");
+ return 0;
+ }
+
+ PolkitAgentTDE agent;
+ agent.disableSessionManagement();
+ return agent.exec();
}
diff --git a/src/org.freedesktop.PolicyKit.AuthenticationAgent.xml b/src/org.freedesktop.PolicyKit.AuthenticationAgent.xml
index f5aa8ef..8881b62 100644
--- a/src/org.freedesktop.PolicyKit.AuthenticationAgent.xml
+++ b/src/org.freedesktop.PolicyKit.AuthenticationAgent.xml
@@ -4,8 +4,6 @@
<method name="ObtainAuthorization" >
<!-- IN: PolicyKit action identifier; see PolKitAction -->
<arg direction="in" type="s" name="action_id" />
- <!-- IN: X11 window ID for the top-level X11 window the dialog will be transient for. -->
- <arg direction="in" type="u" name="xid" />
<!-- IN: Process ID to grant authorization to -->
<arg direction="in" type="u" name="pid" />
<!-- OUT: whether the user gained the authorization -->
diff --git a/src/org.kde.Polkit1AuthAgent.xml b/src/org.kde.Polkit1AuthAgent.xml
deleted file mode 100644
index 0aa39de..0000000
--- a/src/org.kde.Polkit1AuthAgent.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<!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.kde.Polkit1AuthAgent">
- <method name="setWIdForAction">
- <arg type="s" direction="in" />
- <arg type="t" direction="in" />
- </method>
- </interface>
-</node>
diff --git a/src/policykitlistener.cpp b/src/policykitlistener.cpp
deleted file mode 100644
index c2ea924..0000000
--- a/src/policykitlistener.cpp
+++ /dev/null
@@ -1,237 +0,0 @@
-/* This file is part of the KDE project
- Copyright (C) 2009 Jaroslav Reznik <jreznik@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 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 "policykitlistener.h"
-#include "AuthDialog.h"
-
-#include <KDebug>
-#include <KWindowSystem>
-
-#include <PolkitTQt1/Agent/Listener>
-#include <PolkitTQt1/Agent/Session>
-#include <PolkitTQt1/Subject>
-#include <PolkitTQt1/Identity>
-#include <PolkitTQt1/Details>
-#include <TQtDBus/TQDBusConnection>
-
-#include "polkit1authagentadaptor.h"
-
-PolicyKitListener::PolicyKitListener(TQObject *parent)
- : Listener(parent)
- , m_inProgress(false)
- , m_selectedUser(0)
-{
- (void) new Polkit1AuthAgentAdaptor(this);
-
- if (!TQDBusConnection::sessionBus().registerObject("/org/kde/Polkit1AuthAgent", this,
- TQDBusConnection::ExportScriptableSlots |
- TQDBusConnection::ExportScriptableProperties |
- TQDBusConnection::ExportAdaptors)) {
- kWarning() << "Could not initiate DBus helper!";
- }
-
- kDebug() << "Listener online";
-}
-
-PolicyKitListener::~PolicyKitListener()
-{
-}
-
-void PolicyKitListener::setWIdForAction(const TQString& action, qulonglong wID)
-{
- kDebug() << "On to the handshake";
- m_actionsToWID[action] = wID;
-}
-
-void PolicyKitListener::initiateAuthentication(const TQString &actionId,
- const TQString &message,
- const TQString &iconName,
- const PolkitTQt1::Details &details,
- const TQString &cookie,
- const PolkitTQt1::Identity::List &identities,
- PolkitTQt1::Agent::AsyncResult* result)
-{
- kDebug() << "Initiating authentication";
-
- if (m_inProgress) {
- result->setError(i18n("Another client is already authenticating, please try again later."));
- result->setCompleted();
- kDebug() << "Another client is already authenticating, please try again later.";
- return;
- }
-
- m_identities = identities;
- m_cookie = cookie;
- m_result = result;
- m_session.clear();
-
- m_inProgress = true;
-
- WId parentId = 0;
-
- if (m_actionsToWID.contains(actionId)) {
- parentId = m_actionsToWID[actionId];
- }
-
- m_dialog = new AuthDialog(actionId, message, iconName, details, identities, parentId);
- connect(m_dialog.data(), SIGNAL(okClicked()), SLOT(dialogAccepted()));
- connect(m_dialog.data(), SIGNAL(cancelClicked()), SLOT(dialogCanceled()));
- connect(m_dialog.data(), SIGNAL(adminUserSelected(PolkitTQt1::Identity)), SLOT(userSelected(PolkitTQt1::Identity)));
-
- kDebug() << "WinId of the dialog is " << m_dialog.data()->winId() << m_dialog.data()->effectiveWinId();
- m_dialog.data()->setOptions();
- m_dialog.data()->show();
- KWindowSystem::forceActiveWindow(m_dialog.data()->winId());
- kDebug() << "WinId of the shown dialog is " << m_dialog.data()->winId() << m_dialog.data()->effectiveWinId();
-
- if (identities.length() == 1) {
- m_selectedUser = identities[0];
- } else {
- m_selectedUser = m_dialog.data()->adminUserSelected();
- }
-
- m_numTries = 0;
- tryAgain();
-}
-
-void PolicyKitListener::tryAgain()
-{
- kDebug() << "Trying again";
-// test!!!
- m_wasCancelled = false;
-
- // We will create new session only when some user is selected
- if (m_selectedUser.isValid()) {
- m_session = new Session(m_selectedUser, m_cookie, m_result);
- connect(m_session.data(), SIGNAL(request(TQString,bool)), this, SLOT(request(TQString,bool)));
- connect(m_session.data(), SIGNAL(completed(bool)), this, SLOT(completed(bool)));
- connect(m_session.data(), SIGNAL(showError(TQString)), this, SLOT(showError(TQString)));
-
- m_session.data()->initiate();
- }
-
-}
-
-void PolicyKitListener::finishObtainPrivilege()
-{
- kDebug() << "Finishing obtaining privileges";
-
- // Number of tries increase only when some user is selected
- if (m_selectedUser.isValid()) {
- m_numTries++;
- }
-
- if (!m_gainedAuthorization && !m_wasCancelled && !m_dialog.isNull()) {
- m_dialog.data()->authenticationFailure();
-
- if (m_numTries < 3) {
- m_session.data()->deleteLater();
-
- tryAgain();
- return;
- }
- }
-
- if (!m_session.isNull()) {
- m_session.data()->result()->setCompleted();
- } else {
- m_result->setCompleted();
- }
- m_session.data()->deleteLater();
-
- if (!m_dialog.isNull()) {
- m_dialog.data()->hide();
- m_dialog.data()->deleteLater();
- }
-
- m_inProgress = false;
-
- kDebug() << "Finish obtain authorization:" << m_gainedAuthorization;
-}
-
-bool PolicyKitListener::initiateAuthenticationFinish()
-{
- kDebug() << "Finishing authentication";
- return true;
-}
-
-void PolicyKitListener::cancelAuthentication()
-{
- kDebug() << "Cancelling authentication";
-
- m_wasCancelled = true;
- finishObtainPrivilege();
-}
-
-void PolicyKitListener::request(const TQString &request, bool echo)
-{
- Q_UNUSED(echo);
- kDebug() << "Request: " << request;
-
- if (!m_dialog.isNull()) {
- m_dialog.data()->setRequest(request, m_selectedUser.isValid() &&
- m_selectedUser.toString() == "unix-user:root");
- }
-}
-
-void PolicyKitListener::completed(bool gainedAuthorization)
-{
- kDebug() << "Completed: " << gainedAuthorization;
-
- m_gainedAuthorization = gainedAuthorization;
-
- finishObtainPrivilege();
-}
-
-void PolicyKitListener::showError(const TQString &text)
-{
- kDebug() << "Error: " << text;
-}
-
-void PolicyKitListener::dialogAccepted()
-{
- kDebug() << "Dialog accepted";
-
- if (!m_dialog.isNull()) {
- m_session.data()->setResponse(m_dialog.data()->password());
- }
-}
-
-void PolicyKitListener::dialogCanceled()
-{
- kDebug() << "Dialog cancelled";
-
- m_wasCancelled = true;
- if (!m_session.isNull()) {
- m_session.data()->cancel();
- }
-
- finishObtainPrivilege();
-}
-
-void PolicyKitListener::userSelected(const PolkitTQt1::Identity &identity)
-{
- m_selectedUser = identity;
- // If some user is selected we must destroy existing session
- if (!m_session.isNull()) {
- m_session.data()->deleteLater();
- }
- tryAgain();
-}
diff --git a/src/policykitlistener.h b/src/policykitlistener.h
deleted file mode 100644
index f7906e4..0000000
--- a/src/policykitlistener.h
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef POLICYKITLISTENER_H
-#define POLICYKITLISTENER_H
-
-/* This file is part of the KDE project
- Copyright (C) 2009 Jaroslav Reznik <jreznik@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 library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
-*/
-
-#include <PolkitTQt1/Agent/Listener>
-
-#include <TQtCore/TQWeakPointer>
-#include <TQtCore/TQHash>
-
-class AuthDialog;
-
-using namespace PolkitTQt1::Agent;
-
-class PolicyKitListener : public Listener
-{
- Q_OBJECT
- TQ_CLASSINFO("D-Bus Interface", "org.kde.Polkit1AuthAgent")
-public:
- PolicyKitListener(TQObject *parent = 0);
- virtual ~PolicyKitListener();
-
-public slots:
- void initiateAuthentication(const TQString &actionId,
- const TQString &message,
- const TQString &iconName,
- const PolkitTQt1::Details &details,
- const TQString &cookie,
- const PolkitTQt1::Identity::List &identities,
- PolkitTQt1::Agent::AsyncResult* result);
- bool initiateAuthenticationFinish();
- void cancelAuthentication();
-
- void tryAgain();
- void finishObtainPrivilege();
-
- void request(const TQString &request, bool echo);
- void completed(bool gainedAuthorization);
- void showError(const TQString &text);
-
- void setWIdForAction(const TQString &action, qulonglong wID);
- /* void showInfo(const TQString &text); */
-private:
- TQWeakPointer<AuthDialog> m_dialog;
- TQWeakPointer<Session> m_session;
- bool m_inProgress;
- bool m_gainedAuthorization;
- bool m_wasCancelled;
- int m_numTries;
- PolkitTQt1::Identity::List m_identities;
- PolkitTQt1::Agent::AsyncResult* m_result;
- TQString m_cookie;
- PolkitTQt1::Identity m_selectedUser;
- TQHash< TQString, qulonglong > m_actionsToWID;
-
-private slots:
- void dialogAccepted();
- void dialogCanceled();
- void userSelected(const PolkitTQt1::Identity &identity);
-};
-
-#endif
diff --git a/src/policykitkde.h b/src/polkit-agent-tde.cpp
index 85ce6b2..6fa9e74 100644
--- a/src/policykitkde.h
+++ b/src/polkit-agent-tde.cpp
@@ -18,21 +18,16 @@
*/
-#ifndef POLICYKITKDE_H
-#define POLICYKITKDE_H
+#include "polkit-agent-tde.h"
-#include <KUniqueApplication>
-
-#include "policykitlistener.h"
-
-class PolicyKitKDE : public KUniqueApplication
+PolkitAgentTDE::PolkitAgentTDE() : m_listener(new PolkitListener(this))
{
- Q_OBJECT
-public:
- PolicyKitKDE();
- virtual ~PolicyKitKDE();
-private:
- PolicyKitListener *m_listener;
-};
+}
-#endif
+PolkitAgentTDE::~PolkitAgentTDE()
+{
+ if (m_listener)
+ {
+ delete m_listener;
+ }
+}
diff --git a/src/policykitkde.cpp b/src/polkit-agent-tde.h
index a6727c8..ba25556 100644
--- a/src/policykitkde.cpp
+++ b/src/polkit-agent-tde.h
@@ -1,4 +1,4 @@
-/* This file is part of the KDE project
+/* This file is part of the TDE project
Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
This program is free software; you can redistribute it and/or
@@ -18,29 +18,22 @@
*/
-#include "policykitkde.h"
+#ifndef POLKIT_AGENT_TDE_H
+#define POLKIT_AGENT_TDE_H
-#include <KDebug>
-#include <PolkitTQt1/Subject>
+#include <kuniqueapplication.h>
-PolicyKitKDE::PolicyKitKDE()
- : m_listener(new PolicyKitListener(this))
-{
- setQuitOnLastWindowClosed(false);
-
- PolkitTQt1::UnixSessionSubject session(getpid());
+#include "polkit-listener.h"
- bool result = m_listener->registerListener(session, "/org/kde/PolicyKit1/AuthenticationAgent");
+class PolkitAgentTDE : public KUniqueApplication
+{
+ public:
+ PolkitAgentTDE();
+ virtual ~PolkitAgentTDE();
- kDebug() << result;
+ private:
+ PolkitListener *m_listener;
+};
- if (!result) {
- kDebug() << "Couldn't register listener!";
- exit(1);
- }
-}
+#endif
-PolicyKitKDE::~PolicyKitKDE()
-{
- m_listener->deleteLater();
-}
diff --git a/src/polkit-listener.cpp b/src/polkit-listener.cpp
new file mode 100644
index 0000000..efd5261
--- /dev/null
+++ b/src/polkit-listener.cpp
@@ -0,0 +1,226 @@
+/* This file is part of the KDE project
+ Copyright (C) 2009 Jaroslav Reznik <jreznik@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 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 "polkit-listener.h"
+#include "AuthDialog.h"
+
+#include <kdebug.h>
+#include <tdelocale.h>
+
+#include <PolkitTQt/Agent/Listener>
+#include <PolkitTQt/Agent/Session>
+#include <PolkitTQt/Subject>
+#include <PolkitTQt/Identity>
+#include <PolkitTQt/Details>
+
+using namespace PolkitTQt;
+using namespace PolkitTQt::Agent;
+
+PolkitListener::PolkitListener(TQObject *parent) : Listener(parent), m_inProgress(false),
+ m_selectedUser(0), m_result(nullptr), m_session(nullptr)
+{
+ PolkitTQt::UnixSessionSubject session(getpid());
+ if (!registerListener(session, "/org/trinitydesktop/PolKit1AuthAgent"))
+ {
+ kdWarning() << "Could not initiate DBus listener!" << endl;
+ }
+ kdDebug() << "Listener online" << endl;
+}
+
+void PolkitListener::clearSession()
+{
+ if (m_session)
+ {
+ m_session->deleteLater();
+ m_session = nullptr;
+ }
+}
+
+void PolkitListener::initiateAuthentication(const TQString &actionId, const TQString &message,
+ const TQString &iconName, const PolkitTQt::Details &details,
+ const TQString &cookie, const Identity::List &identities, AsyncResult* result)
+{
+ kdDebug() << "Initiating authentication" << endl;
+
+ if (m_inProgress)
+ {
+ result->setError(i18n("Another client is already authenticating, please try again later."));
+ result->setCompleted();
+ kdDebug() << "Another client is already authenticating, please try again later." << endl;
+ return;
+ }
+
+ m_identities = identities;
+ m_cookie = cookie;
+ m_result = result;
+ clearSession();
+
+ m_inProgress = true;
+
+ m_dialog = new AuthDialog(actionId, message, iconName, details, identities);
+ connect(m_dialog, TQT_SIGNAL(okClicked()), TQT_SLOT(dialogAccepted()));
+ connect(m_dialog, TQT_SIGNAL(cancelClicked()), TQT_SLOT(dialogCanceled()));
+ connect(m_dialog, TQT_SIGNAL(adminUserSelected(const PolkitTQt::Identity&)),
+ TQT_SLOT(userSelected(const PolkitTQt::Identity&)));
+
+ m_dialog->setOptions();
+ m_dialog->show();
+
+ if (identities.count() == 1)
+ {
+ m_selectedUser = identities[0];
+ }
+ else
+ {
+ m_selectedUser = m_dialog->adminUserSelected();
+ }
+
+ m_numTries = 0;
+ tryAgain();
+}
+
+void PolkitListener::tryAgain()
+{
+ kdDebug() << "Trying again" << endl;
+ // test!!!
+ m_wasCancelled = false;
+
+ // We will create new session only when some user is selected
+ if (m_selectedUser.isValid())
+ {
+ m_session = new Session(m_selectedUser, m_cookie, m_result);
+ connect(m_session, TQT_SIGNAL(request(const TQString&, bool)), this,
+ TQT_SLOT(request(const TQString&, bool)));
+ connect(m_session, TQT_SIGNAL(completed(bool)), this, TQT_SLOT(completed(bool)));
+ connect(m_session, TQT_SIGNAL(showError(const TQString&)), this,
+ TQT_SLOT(showError(const TQString&)));
+ m_session->initiate();
+ }
+}
+
+void PolkitListener::finishObtainPrivilege()
+{
+ kdDebug() << "Finishing obtaining privileges" << endl;
+
+ // Number of tries increase only when some user is selected
+ if (m_selectedUser.isValid())
+ {
+ m_numTries++;
+ }
+
+ if (!m_gainedAuthorization && !m_wasCancelled && m_dialog)
+ {
+ m_dialog->authenticationFailure();
+
+ if (m_numTries < 3)
+ {
+ clearSession();
+ tryAgain();
+ return;
+ }
+ }
+
+ if (m_session)
+ {
+ m_session->result()->setCompleted();
+ }
+ else
+ {
+ m_result->setCompleted();
+ }
+ clearSession();
+
+ if (m_dialog)
+ {
+ m_dialog->hide();
+ m_dialog->deleteLater();
+ m_dialog = nullptr;
+ }
+
+ m_inProgress = false;
+
+ kdDebug() << "Finish obtain authorization:" << m_gainedAuthorization << endl;
+}
+
+bool PolkitListener::initiateAuthenticationFinish()
+{
+ kdDebug() << "Finishing authentication" << endl;
+ return true;
+}
+
+void PolkitListener::cancelAuthentication()
+{
+ kdDebug() << "Cancelling authentication" << endl;
+ m_wasCancelled = true;
+ finishObtainPrivilege();
+}
+
+void PolkitListener::request(const TQString &request, bool _)
+{
+ kdDebug() << "Request: " << request << endl;
+ if (m_dialog)
+ {
+ m_dialog->setRequest(request, m_selectedUser.isValid() &&
+ m_selectedUser.toString() == "unix-user:root");
+ }
+}
+
+void PolkitListener::completed(bool gainedAuthorization)
+{
+ kdDebug() << "Completed: " << gainedAuthorization << endl;
+ m_gainedAuthorization = gainedAuthorization;
+ finishObtainPrivilege();
+}
+
+void PolkitListener::showError(const TQString &text)
+{
+ kdDebug() << "Error: " << text << endl;
+}
+
+void PolkitListener::dialogAccepted()
+{
+ kdDebug() << "Dialog accepted" << endl;
+ if (m_session)
+ {
+ m_session->setResponse(m_dialog->password());
+ }
+}
+
+void PolkitListener::dialogCanceled()
+{
+ kdDebug() << "Dialog cancelled" << endl;
+ m_wasCancelled = true;
+ if (m_session)
+ {
+ m_session->cancel();
+ }
+ finishObtainPrivilege();
+}
+
+void PolkitListener::userSelected(const PolkitTQt::Identity &identity)
+{
+ m_selectedUser = identity;
+ // If some user is selected we must destroy existing session
+ clearSession();
+ tryAgain();
+}
+
+#include "polkit-listener.moc"
+
diff --git a/src/polkit-listener.h b/src/polkit-listener.h
new file mode 100644
index 0000000..bffd21a
--- /dev/null
+++ b/src/polkit-listener.h
@@ -0,0 +1,71 @@
+/* This file is part of the TDE project
+ Copyright (C) 2009 Jaroslav Reznik <jreznik@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 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_LISTENER_H
+#define POLKIT_LISTENER_H
+
+#include <PolkitTQt/Agent/Listener>
+
+class AuthDialog;
+
+class PolkitListener : public PolkitTQt::Agent::Listener
+{
+ Q_OBJECT
+
+ public:
+ PolkitListener(TQObject *parent = 0);
+
+ public slots:
+ void initiateAuthentication(const TQString &actionId, const TQString &message,
+ const TQString &iconName, const PolkitTQt::Details &details,
+ const TQString &cookie, const PolkitTQt::Identity::List &identities,
+ PolkitTQt::Agent::AsyncResult* result);
+ bool initiateAuthenticationFinish();
+ void cancelAuthentication();
+
+ void tryAgain();
+ void finishObtainPrivilege();
+
+ void request(const TQString &request, bool _);
+ void completed(bool gainedAuthorization);
+ void showError(const TQString &text);
+
+ private:
+ void clearSession();
+
+ AuthDialog *m_dialog;
+ bool m_inProgress;
+ bool m_gainedAuthorization;
+ bool m_wasCancelled;
+ int m_numTries;
+ TQString m_cookie;
+ PolkitTQt::Identity::List m_identities;
+ PolkitTQt::Identity m_selectedUser;
+ PolkitTQt::Agent::AsyncResult* m_result;
+ PolkitTQt::Agent::Session *m_session;
+
+ private slots:
+ void dialogAccepted();
+ void dialogCanceled();
+ void userSelected(const PolkitTQt::Identity &identity);
+};
+
+#endif
+