2009-09-02 04:27:16 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2009 <r.scheepmaker@student.utwente.nl>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2009-11-25 02:08:35 +01:00
|
|
|
#include "pinpairingdialog_p.h"
|
2009-09-02 04:27:16 +02:00
|
|
|
|
|
|
|
#include "authorizationrule.h"
|
|
|
|
#include "clientpinrequest.h"
|
|
|
|
#include "ui_pinpairing.h"
|
|
|
|
|
|
|
|
#include <kdebug.h>
|
2009-09-03 01:49:46 +02:00
|
|
|
#include <kdialog.h>
|
2009-09-02 04:27:16 +02:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
class PinPairingDialogPrivate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PinPairingDialogPrivate(AuthorizationRule *rule, ClientPinRequest *request, PinPairingDialog *q)
|
|
|
|
: q(q),
|
|
|
|
rule(rule),
|
|
|
|
request(request),
|
|
|
|
dialog(new KDialog(0))
|
|
|
|
{
|
|
|
|
QWidget *widget = new QWidget(dialog);
|
|
|
|
pairingUI.setupUi(widget);
|
|
|
|
dialog->setMainWidget(widget);
|
|
|
|
if (rule) {
|
|
|
|
dialog->setCaption(i18n("Incoming connection request"));
|
|
|
|
pairingUI.descriptionLabel->setText(rule->description());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (request) {
|
|
|
|
dialog->setCaption(i18n("Connect with remote widget"));
|
2009-09-03 01:49:46 +02:00
|
|
|
pairingUI.persistentCheckbox->setVisible(false);
|
|
|
|
pairingUI.allServicesCheckbox->setVisible(false);
|
2009-09-02 04:27:16 +02:00
|
|
|
pairingUI.descriptionLabel->setText(request->description());
|
|
|
|
}
|
|
|
|
|
|
|
|
dialog->setButtons(KDialog::Ok | KDialog::Cancel);
|
|
|
|
dialog->show();
|
|
|
|
|
|
|
|
q->connect(dialog, SIGNAL(okClicked()), q, SLOT(slotAccept()));
|
|
|
|
q->connect(dialog, SIGNAL(cancelClicked()), q, SLOT(slotReject()));
|
|
|
|
}
|
|
|
|
|
|
|
|
~PinPairingDialogPrivate()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void slotAccept()
|
|
|
|
{
|
|
|
|
kDebug();
|
|
|
|
if (rule) {
|
|
|
|
rule->setPin(pairingUI.password->text());
|
2009-09-03 01:49:46 +02:00
|
|
|
if (pairingUI.allServicesCheckbox->isChecked()) {
|
2009-09-02 04:27:16 +02:00
|
|
|
rule->setPolicy(AuthorizationRule::PinRequired);
|
|
|
|
rule->setTargets(AuthorizationRule::AllServices);
|
|
|
|
} else {
|
|
|
|
rule->setPolicy(AuthorizationRule::PinRequired);
|
|
|
|
}
|
2009-09-03 01:49:46 +02:00
|
|
|
if (pairingUI.persistentCheckbox->isChecked()) {
|
|
|
|
rule->setPersistence(AuthorizationRule::Persistent);
|
|
|
|
}
|
2009-09-02 04:27:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (request) {
|
|
|
|
request->setPin(pairingUI.password->text());
|
|
|
|
}
|
|
|
|
|
|
|
|
q->deleteLater();
|
|
|
|
}
|
|
|
|
|
|
|
|
void slotReject()
|
|
|
|
{
|
|
|
|
q->deleteLater();
|
|
|
|
}
|
|
|
|
|
|
|
|
PinPairingDialog *q;
|
|
|
|
AuthorizationRule *rule;
|
|
|
|
ClientPinRequest *request;
|
|
|
|
Ui::pairingDialog pairingUI;
|
|
|
|
KDialog *dialog;
|
|
|
|
};
|
|
|
|
|
|
|
|
PinPairingDialog::PinPairingDialog(AuthorizationRule &rule, QObject *parent)
|
|
|
|
: QObject(parent),
|
|
|
|
d(new PinPairingDialogPrivate(&rule, 0, this))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PinPairingDialog::PinPairingDialog(ClientPinRequest &request, QObject *parent)
|
|
|
|
: QObject(parent),
|
|
|
|
d(new PinPairingDialogPrivate(0, &request, this))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PinPairingDialog::~PinPairingDialog()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-11-25 02:08:35 +01:00
|
|
|
#include "pinpairingdialog_p.moc"
|