3
* kbluetooth - Another KDE Bluetooth tray icon application.
5
* Copyright (C) 2003 Fred Schaettgen <kbluetoothd@schaettgen.de>
6
* Copyright (C) 2006 Daniel Gollub <dgollub@suse.de>
9
* This file is part of kbluetooth.
11
* kbluetooth is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 2 of the License, or
14
* (at your option) any later version.
16
* libkbluetooth is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with libkbluetooth; if not, write to the Free Software
23
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
#include "pindialog.h"
29
#include "authorize.h"
32
#include "application.h"
34
KBluetoothApp::KBluetoothApp() :
37
m_config = new KConfig("kdebluetoothrc");
39
m_config->setGroup("General");
40
m_config->writeEntry("AutoStart", true);
44
bFirstNewInstance = true;
47
dbus = new DBusInit();
48
conn = dbus->getDBus();
54
manager = new Manager(conn);
55
if (!manager->listAdapters().count() || manager->defaultAdapter() == "") {
60
adapter = new Adapter(manager->defaultAdapter(), conn);
61
rfcomm = new RfcommPortListener(m_config,adapter);
67
// hcid = new DBusHcid(this);
69
// Register Default PasskeyAgent
70
passkeyagent = new PasskeyAgent(conn, "/org/kde/kbluetooth_1234");
71
passkeyagent->registerDefaultPasskeyAgent();
73
authagent = new AuthAgent(conn, "/org/kde/kbluetooth_auth_1234");
74
authagent->registerDefaultAuthorizationAgent();
79
connect(passkeyagent, SIGNAL(request(const QString&, const QString&, bool)), SLOT(slotPinDialog(const QString&, const QString&, bool)));
80
connect(authagent, SIGNAL(authorize(const QString&, const QString&, const QString&, const QString&)), SLOT(slotAuthDialog(const QString&, const QString&, const QString&, const QString&)));
82
connect(manager, SIGNAL(adapterAdded(const QString&)), SLOT(slotAdapterAdded(const QString&)));
83
connect(manager, SIGNAL(adapterRemoved(const QString&)), SLOT(slotAdapterRemoved(const QString&)));
84
trayIcon = new TrayIcon(this);
85
setMainWidget(trayIcon);
87
connect(trayIcon, SIGNAL(setKbtobexSrv(bool)), this, SLOT(slotKbtobexSrv(bool)));
89
// slotAuthDialog("/org/bluez/hci0", "00:00:00:ff:ff:ff", "foo", "0x213");
94
void KBluetoothApp::slotAdapterAdded(const QString& /*address*/) {
100
adapter = new Adapter(manager->defaultAdapter(), conn);
101
rfcomm = new RfcommPortListener(m_config,adapter);
106
void KBluetoothApp::slotAdapterRemoved(const QString& /*address*/) {
115
void KBluetoothApp::slotKbtobexSrv(bool status) {
117
rfcomm = new RfcommPortListener(m_config,adapter);
123
KBluetoothApp::~KBluetoothApp()
127
passkeyagent->unregisterDefaultPasskeyAgent();
136
int KBluetoothApp::newInstance()
138
// KBluetooth is started via autostart. If session management
139
// is activated it will be called twice after login. This would
140
// set the tray icon to visible every time, so we turn off
141
// session management.
142
disableSessionManagement();
144
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
145
// If kbluetooth is started while already running we
146
// make the tray icon permanently visible
147
if (bFirstNewInstance == false) {
148
if ((args->isSet("dontforceshow") == false) && trayIcon) {
149
trayIcon->setAlwaysShowIcon(true);
152
bFirstNewInstance = false;
156
void KBluetoothApp::slotPinDialog(const QString &path, const QString &address, bool isNumeric)
158
kdDebug() << k_funcinfo << " (" << path << "," << address << "," << isNumeric << ")" << endl;
160
PinDialog *dialog = new PinDialog(address, adapter->getRemoteName(address), passkeyagent);
162
kapp->updateUserTimestamp();
168
void KBluetoothApp::slotAuthDialog(const QString &path, const QString &address, const QString &service, const QString &uuid)
170
kdDebug() << k_funcinfo << " (" << path << "," << address << "," << service << "," << uuid << ")" << endl;
172
AuthorizeDialog *dialog = new AuthorizeDialog(address, adapter->getRemoteName(address), service, uuid, authagent);
174
kapp->updateUserTimestamp();
181
#include "application.moc"