1
/***************************************************************************
2
* Copyright (C) 2010 Alejandro Fiestas Olivares <alex@eyeos.org> *
3
* Copyright (C) 2010 Eduardo Robles Elvira <edulix@gmail.com> *
4
* Copyright (C) 2010 UFO Coders <info@ufocoders.com> *
6
* This program is free software; you can redistribute it and/or modify *
7
* it under the terms of the GNU General Public License as published by *
8
* the Free Software Foundation; either version 2 of the License, or *
9
* (at your option) any later version. *
11
* This program is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU General Public License for more details. *
16
* You should have received a copy of the GNU General Public License *
17
* along with this program; if not, write to the *
18
* Free Software Foundation, Inc., *
19
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20
***************************************************************************/
22
#include "authorize.h"
24
#include <QtCore/QDebug>
25
#include <QtCore/QCoreApplication>
26
#include <QtCore/QTimer>
30
#include <kiconloader.h>
31
#include <knotification.h>
33
#include <bluedevil/bluedevil.h>
35
Authorize::Authorize()
38
KNotification *notification = new KNotification("bluedevilAuthorize",
39
KNotification::Persistent, this);
41
notification->setText(i18nc(
42
"Show a notification asking for authorize or deny access to this computer from Bluetooth the %1 is the name of the bluetooth device",
43
"%1 is requesting access to this computer", qApp->arguments()[1])
47
actions.append(i18nc("Button to trust a bluetooth remote device and authorize it to connect", "Trust and Authorize"));
48
actions.append(i18nc("Button to authorize a bluetooth remote device to connect ", "Authorize Only"));
49
actions.append(i18nc("Deny access to a remote bluetooth device", "Deny"));
51
notification->setActions(actions);
53
connect(notification, SIGNAL(action1Activated()),this, SLOT(trust()));
54
connect(notification, SIGNAL(action2Activated()),this, SLOT(authorize()));
55
connect(notification, SIGNAL(action3Activated()),this, SLOT(deny()));
56
connect(notification, SIGNAL(closed()), this, SLOT(deny()));
57
connect(notification, SIGNAL(ignored()), this, SLOT(deny()));
59
notification->setPixmap(KIcon("preferences-system-bluetooth").pixmap(42, 42));
61
// We're using persistent notifications so we have to use our own timeout (10s)
62
QTimer::singleShot(10000, notification, SLOT(close()));
63
notification->sendEvent();
66
void Authorize::trust()
68
qDebug() << "Trusted";
69
BlueDevil::Manager::self()->defaultAdapter()->deviceForUBI(qApp->arguments()[2])->setTrusted(true);
73
void Authorize::authorize()
75
qDebug() << "Accepted";
79
void Authorize::deny()
81
qDebug() << "Rejected";