diff options
Diffstat (limited to 'examples/PkExample.cpp')
-rw-r--r-- | examples/PkExample.cpp | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/examples/PkExample.cpp b/examples/PkExample.cpp index 2168a9117..5c0e57d22 100644 --- a/examples/PkExample.cpp +++ b/examples/PkExample.cpp @@ -24,29 +24,29 @@ #include "gui/polkitqt1-gui-actionbutton.h" #include "gui/polkitqt1-gui-actionbuttons.h" #include "core/polkitqt1-authority.h" -#include <QtCore/QDebug> +#include <TQtCore/TQDebug> -#include <QtDBus/QDBusMessage> -#include <QtDBus/QDBusConnection> +#include <TQtDBus/TQDBusMessage> +#include <TQtDBus/TQDBusConnection> -using namespace PolkitQt1; -using namespace PolkitQt1::Gui; +using namespace PolkitTQt1; +using namespace PolkitTQt1::Gui; -PkExample::PkExample(QMainWindow *parent) - : QMainWindow(parent) +PkExample::PkExample(TQMainWindow *parent) + : TQMainWindow(parent) { setupUi(this); ActionButton *bt; // Here we create an ActionButton that is a subclass of Action - // always pass a QAbstractButton pointer and action id + // always pass a TQAbstractButton 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")); + bt->setIcon(TQPixmap(":/Icons/custom-no.png")); // By using set{Yes|No|Auth}Enabled you can set the states // when the button is enabled bt->setEnabled(true, Action::No); @@ -54,32 +54,32 @@ PkExample::PkExample(QMainWindow *parent) 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 + // it will only happen if it was inserted in a TQMenu or a TQToolBar connect(bt, SIGNAL(triggered(bool)), this, SLOT(activateAction())); - // This signal was propagated from the QAbstractButton just for + // This signal was propagated from the TQAbstractButton 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())); + connect(bt, SIGNAL(clicked(TQAbstractButton *, 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")); + bt->setIcon(TQPixmap(":/Icons/custom-yes.png")); menuActions->addAction(qobject_cast<Action *>(bt)); toolBar->addAction(qobject_cast<Action *>(bt)); connect(bt, SIGNAL(triggered(bool)), this, SLOT(activateAction())); - connect(bt, SIGNAL(clicked(QAbstractButton *, bool)), bt, SLOT(activate())); + connect(bt, SIGNAL(clicked(TQAbstractButton *, 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")); + bt->setIcon(TQPixmap(":/Icons/action-locked-default.png")); menuActions->addAction(qobject_cast<Action *>(bt)); toolBar->addAction(qobject_cast<Action *>(bt)); connect(bt, SIGNAL(triggered(bool)), this, SLOT(activateAction())); - connect(bt, SIGNAL(clicked(QAbstractButton *, bool)), bt, SLOT(activate())); + connect(bt, SIGNAL(clicked(TQAbstractButton *, bool)), bt, SLOT(activate())); connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated())); // This action is more customized @@ -89,67 +89,67 @@ PkExample::PkExample(QMainWindow *parent) 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->setIcon(TQPixmap(":/Icons/custom-no.png"), Action::No); bt->setToolTip("If your admin wasn't annoying, you could do this", Action::No); // here we set the behavior of PolKitResul = Auth bt->setText("Play?", Action::Auth); - bt->setIcon(QPixmap(":/Icons/action-locked-default.png"), Action::Auth); + bt->setIcon(TQPixmap(":/Icons/action-locked-default.png"), Action::Auth); bt->setToolTip("Only card carrying tweakers can do this!", Action::Auth); // here we set the behavior of PolKitResul = Yes bt->setText("Play!", Action::Yes); - bt->setIcon(QPixmap(":/Icons/custom-yes.png"), Action::Yes); + bt->setIcon(TQPixmap(":/Icons/custom-yes.png"), Action::Yes); bt->setToolTip("Go ahead, play!", Action::Yes); menuActions->addAction(qobject_cast<Action *>(bt)); toolBar->addAction(qobject_cast<Action *>(bt)); connect(bt, SIGNAL(triggered(bool)), this, SLOT(activateAction())); - connect(bt, SIGNAL(clicked(QAbstractButton *, bool)), bt, SLOT(activate())); + connect(bt, SIGNAL(clicked(TQAbstractButton *, 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); + bt->setIcon(TQPixmap(":/Icons/custom-no.png"), Action::No); + bt->setIcon(TQPixmap(":/Icons/action-locked-default.png"), Action::Auth); + bt->setIcon(TQPixmap(":/Icons/custom-yes.png"), Action::Yes); menuActions->addAction(qobject_cast<Action *>(bt)); toolBar->addAction(qobject_cast<Action *>(bt)); connect(bt, SIGNAL(triggered(bool)), this, SLOT(activateAction())); - connect(bt, SIGNAL(clicked(QAbstractButton *, bool)), bt, SLOT(activate())); + connect(bt, SIGNAL(clicked(TQAbstractButton *, 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); + bt->setIcon(TQPixmap(":/Icons/custom-no.png"), Action::No); + bt->setIcon(TQPixmap(":/Icons/action-locked-default.png"), Action::Auth); + bt->setIcon(TQPixmap(":/Icons/custom-yes.png"), Action::Yes); menuActions->addAction(qobject_cast<Action *>(bt)); toolBar->addAction(qobject_cast<Action *>(bt)); connect(bt, SIGNAL(triggered(bool)), this, SLOT(activateAction())); - connect(bt, SIGNAL(clicked(QAbstractButton *, bool)), bt, SLOT(activate())); + connect(bt, SIGNAL(clicked(TQAbstractButton *, 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); + bt->setIcon(TQPixmap(":/Icons/custom-no.png"), Action::No); + bt->setIcon(TQPixmap(":/Icons/action-locked-default.png"), Action::Auth); + bt->setIcon(TQPixmap(":/Icons/custom-yes.png"), Action::Yes); menuActions->addAction(qobject_cast<Action *>(bt)); toolBar->addAction(qobject_cast<Action *>(bt)); connect(bt, SIGNAL(triggered(bool)), this, SLOT(activateAction())); - connect(bt, SIGNAL(clicked(QAbstractButton *, bool)), bt, SLOT(activate())); + connect(bt, SIGNAL(clicked(TQAbstractButton *, 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->setIcon(TQPixmap(":/Icons/custom-no.png"), Action::No); + bt->setIcon(TQPixmap(":/Icons/action-locked-default.png"), Action::Auth); + bt->setIcon(TQPixmap(":/Icons/custom-yes.png"), Action::Yes); bt->setText("Can't shout!", Action::No); bt->setText("Shout?", Action::Auth); bt->setText("Shout!", Action::Yes); menuActions->addAction(qobject_cast<Action *>(bt)); toolBar->addAction(qobject_cast<Action *>(bt)); connect(bt, SIGNAL(triggered(bool)), this, SLOT(activateAction())); - connect(bt, SIGNAL(clicked(QAbstractButton *, bool)), bt, SLOT(activate())); + connect(bt, SIGNAL(clicked(TQAbstractButton *, bool)), bt, SLOT(activate())); connect(bt, SIGNAL(authorized()), this, SLOT(actionActivated())); // test configChanged @@ -183,33 +183,33 @@ void PkExample::actionActivated() // 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"; + tqDebug() << "toggled for: org.qt.policykit.examples.set"; - QDBusMessage message; - message = QDBusMessage::createMethodCall("org.qt.policykit.examples", + TQDBusMessage message; + message = TQDBusMessage::createMethodCall("org.qt.policykit.examples", "/", "org.qt.policykit.examples", - QLatin1String("set")); - QList<QVariant> argumentList; + TQLatin1String("set")); + TQList<TQVariant> argumentList; argumentList << qVariantFromValue(setCB->currentText()); message.setArguments(argumentList); // notice the systemBus here.. - QDBusMessage reply = QDBusConnection::systemBus().call(message); - if (reply.type() == QDBusMessage::ReplyMessage + TQDBusMessage reply = TQDBusConnection::systemBus().call(message); + if (reply.type() == TQDBusMessage::ReplyMessage && reply.arguments().size() == 1) { // the reply can be anything, here we receive a bool - QListWidgetItem *item; + TQListWidgetItem *item; if (reply.arguments().first().toBool()) - item = new QListWidgetItem(QPixmap(":/Icons/custom-yes.png"), - QString("Implicit authorization for shout has been set to %0") + item = new TQListWidgetItem(TQPixmap(":/Icons/custom-yes.png"), + TQString("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.")); + item = new TQListWidgetItem(TQPixmap(":/Icons/custom-no.png"), + TQString("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)"; + tqDebug() << reply.arguments().first().toString(); + } else if (reply.type() == TQDBusMessage::MethodCallMessage) { + tqWarning() << "Message did not receive a reply (timeout by message bus)"; } return; } @@ -219,22 +219,22 @@ void PkExample::actionActivated() // 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(); + tqDebug() << "pretending to be the mechanism for action:" << action->actionId(); Authority::Result result; - UnixProcessSubject subject(static_cast<uint>(QCoreApplication::applicationPid())); + UnixProcessSubject subject(static_cast<uint>(TQCoreApplication::applicationPid())); result = Authority::instance()->checkAuthorizationSync(action->actionId(), subject, Authority::AllowUserInteraction); if (result == Authority::Yes) { // in the helper you will do the action - qDebug() << "caller is authorized to do:" << action->actionId(); - QListWidgetItem *item = new QListWidgetItem(QPixmap(":/Icons/custom-yes.png"), action->actionId()); + tqDebug() << "caller is authorized to do:" << action->actionId(); + TQListWidgetItem *item = new TQListWidgetItem(TQPixmap(":/Icons/custom-yes.png"), action->actionId()); actionList->addItem(item); } else { // OR return false to notify the caller that the action is not authorized. - qDebug() << "caller is NOT authorized to do:" << action->actionId(); - QListWidgetItem *item = new QListWidgetItem(QIcon(":/Icons/custom-no.png"), action->actionId()); + tqDebug() << "caller is NOT authorized to do:" << action->actionId(); + TQListWidgetItem *item = new TQListWidgetItem(TQIcon(":/Icons/custom-no.png"), action->actionId()); actionList->addItem(item); } } |