bluedevil5/sync-with-master.patch

6364 lines
230 KiB
Diff
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 002f464148c98734cc58617135b8307a9c41d2b1..c5f2a2701a9e7d8955307446dab6ba600c43ae6e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,6 @@
project(bluedevil)
-set(PROJECT_VERSION "5.2.2")
+set(PROJECT_VERSION "5.2.90")
+set(PROJECT_VERSION_MAJOR 5)
cmake_minimum_required(VERSION 2.8.12)
@@ -8,7 +9,7 @@ configure_file(version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/version.h)
find_package(ECM REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
-set(QT_MIN_VERSION "5.2.0")
+set(QT_MIN_VERSION "5.4.0")
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
Widgets
diff --git a/README b/README
index b701b77d822dbc5509b4972faaa158e6c670e44f..b819ed7f170473ac0f3c232c5946b6b7a9d80ecf 100644
--- a/README
+++ b/README
@@ -1,14 +1,11 @@
BlueDevil runtime dependencies:
- -obex-data-server
+ -bluez5
+ -General Bluetooth management
+
+ -bluez-obexd
-Be able to "Browse File" aka kio_obexftp
+ -Be able to "Send Files" (bluedevil-sendfile)
-Be able to receive files
- -obexd-client
- -Be able to Send files (bluedevil-sendfile)
-
- -If you're using Alsa:
- The best way of having "automagical headset configuration" is having the bluetooth.conf hook
- enabled
-
- NOTE: Be sure to install only obexd-client and not obexd-server, since the last will conflic
- with obex-data-server.
\ No newline at end of file
+ -pulseaudio-module-bluetooth
+ -Be able to connect A2DP profile
diff --git a/src/XmlMessages.sh b/src/XmlMessages.sh
new file mode 100644
index 0000000000000000000000000000000000000000..05651f53259aaee2876b97570a8ba47e5f6d4cf5
--- /dev/null
+++ b/src/XmlMessages.sh
@@ -0,0 +1,22 @@
+function get_files
+{
+ echo bluedevil-mime.xml
+}
+
+function po_for_file
+{
+ case "$1" in
+ bluedevil-mime.xml)
+ echo bluedevil_xml_mimetypes.po
+ ;;
+ esac
+}
+
+function tags_for_file
+{
+ case "$1" in
+ bluedevil-mime.xml)
+ echo comment
+ ;;
+ esac
+}
diff --git a/src/bluedevil-mime.xml b/src/bluedevil-mime.xml
index 669147d204d1be05a40a0c9d3b10128fc02b1c45..dc4af15e8ac92684bfab6426aa939922cb80c97b 100644
--- a/src/bluedevil-mime.xml
+++ b/src/bluedevil-mime.xml
@@ -17,27 +17,195 @@ Notes:
<sub-class-of type="inode/directory"/>
<generic-icon name="video-display"/>
<comment>Known Device</comment>
+ <comment xml:lang="bs">Poznat uređaj</comment>
+ <comment xml:lang="ca">Dispositiu conegut</comment>
+ <comment xml:lang="cs">Známé zařízení</comment>
+ <comment xml:lang="da">Kendt enhed</comment>
+ <comment xml:lang="de">Bekanntes Gerät</comment>
+ <comment xml:lang="el">Γνωστή συσκευή</comment>
+ <comment xml:lang="en_GB">Known Device</comment>
+ <comment xml:lang="es">Dispositivo conocido</comment>
+ <comment xml:lang="fi">Tunnettu laite</comment>
+ <comment xml:lang="fr">Périphérique connu</comment>
+ <comment xml:lang="it">Dispositivo conosciuto</comment>
+ <comment xml:lang="nl">Bekend apparaat</comment>
+ <comment xml:lang="pl">Znane urządzenie</comment>
+ <comment xml:lang="pt">Dispositivo Conhecido</comment>
+ <comment xml:lang="pt_BR">Dispositivo conhecido</comment>
+ <comment xml:lang="sk">Známe zariadenie</comment>
+ <comment xml:lang="sl">Znana naprava</comment>
+ <comment xml:lang="sr">познати уређај</comment>
+ <comment xml:lang="sr@ijekavian">познати уређај</comment>
+ <comment xml:lang="sr@ijekavianlatin">poznati uređaj</comment>
+ <comment xml:lang="sr@latin">poznati uređaj</comment>
+ <comment xml:lang="sv">Känd enhet</comment>
+ <comment xml:lang="uk">Відомий пристрій</comment>
+ <comment xml:lang="zh_TW">已知的裝置</comment>
</mime-type>
<mime-type type="inode/vnd.kde.bluedevil.device.discovered">
<sub-class-of type="inode/vnd.kde.bluedevil.device"/>
<generic-icon name="video-display"/>
<comment>Discovered Device</comment>
+ <comment xml:lang="bs">Otkriven uređaj</comment>
+ <comment xml:lang="ca">Dispositiu descobert</comment>
+ <comment xml:lang="cs">Objevené zařízení</comment>
+ <comment xml:lang="da">Opdaget enhed</comment>
+ <comment xml:lang="de">Erkanntes Gerät</comment>
+ <comment xml:lang="el">Ευρεθείσα συσκευή</comment>
+ <comment xml:lang="en_GB">Discovered Device</comment>
+ <comment xml:lang="es">Dispositivo descubierto</comment>
+ <comment xml:lang="fi">Löydetty palvelu</comment>
+ <comment xml:lang="fr">Périphérique découvert</comment>
+ <comment xml:lang="it">Dispositivo scoperto</comment>
+ <comment xml:lang="nl">Gevonden apparaat</comment>
+ <comment xml:lang="pl">Odkryte urządzenie</comment>
+ <comment xml:lang="pt">Dispositivo Descoberto</comment>
+ <comment xml:lang="pt_BR">Dispositivo descoberto</comment>
+ <comment xml:lang="sk">Objavené zariadenie</comment>
+ <comment xml:lang="sl">Odkrita naprava</comment>
+ <comment xml:lang="sr">откривени уређај</comment>
+ <comment xml:lang="sr@ijekavian">откривени уређај</comment>
+ <comment xml:lang="sr@ijekavianlatin">otkriveni uređaj</comment>
+ <comment xml:lang="sr@latin">otkriveni uređaj</comment>
+ <comment xml:lang="sv">Upptäckt enhet</comment>
+ <comment xml:lang="uk">Виявлений пристрій</comment>
+ <comment xml:lang="zh_TW">已發現的裝置</comment>
</mime-type>
<mime-type type="inode/vnd.kde.bluedevil.service">
<sub-class-of type="inode/directory"/>
<generic-icon name="preferences-system-bluetooth"/>
<comment>Service</comment>
+ <comment xml:lang="bs">Usluga</comment>
+ <comment xml:lang="ca">Servei</comment>
+ <comment xml:lang="cs">Služba</comment>
+ <comment xml:lang="da">Tjeneste</comment>
+ <comment xml:lang="de">Dienst</comment>
+ <comment xml:lang="el">Υπηρεσία</comment>
+ <comment xml:lang="en_GB">Service</comment>
+ <comment xml:lang="es">Servicio</comment>
+ <comment xml:lang="fi">Palvelu</comment>
+ <comment xml:lang="fr">Service</comment>
+ <comment xml:lang="it">Servizio</comment>
+ <comment xml:lang="nl">Service</comment>
+ <comment xml:lang="pl">Usługa</comment>
+ <comment xml:lang="pt">Serviço</comment>
+ <comment xml:lang="pt_BR">Serviço</comment>
+ <comment xml:lang="sk">Služba</comment>
+ <comment xml:lang="sl">Storitev</comment>
+ <comment xml:lang="sr">сервис</comment>
+ <comment xml:lang="sr@ijekavian">сервис</comment>
+ <comment xml:lang="sr@ijekavianlatin">servis</comment>
+ <comment xml:lang="sr@latin">servis</comment>
+ <comment xml:lang="sv">Tjänst</comment>
+ <comment xml:lang="uk">Служба</comment>
+ <comment xml:lang="zh_TW">服務</comment>
</mime-type>
<mime-type type="application/vnd.kde.bluedevil-audio">
<comment>Service</comment>
+ <comment xml:lang="bs">Usluga</comment>
+ <comment xml:lang="ca">Servei</comment>
+ <comment xml:lang="cs">Služba</comment>
+ <comment xml:lang="da">Tjeneste</comment>
+ <comment xml:lang="de">Dienst</comment>
+ <comment xml:lang="el">Υπηρεσία</comment>
+ <comment xml:lang="en_GB">Service</comment>
+ <comment xml:lang="es">Servicio</comment>
+ <comment xml:lang="fi">Palvelu</comment>
+ <comment xml:lang="fr">Service</comment>
+ <comment xml:lang="it">Servizio</comment>
+ <comment xml:lang="nl">Service</comment>
+ <comment xml:lang="pl">Usługa</comment>
+ <comment xml:lang="pt">Serviço</comment>
+ <comment xml:lang="pt_BR">Serviço</comment>
+ <comment xml:lang="sk">Služba</comment>
+ <comment xml:lang="sl">Storitev</comment>
+ <comment xml:lang="sr">сервис</comment>
+ <comment xml:lang="sr@ijekavian">сервис</comment>
+ <comment xml:lang="sr@ijekavianlatin">servis</comment>
+ <comment xml:lang="sr@latin">servis</comment>
+ <comment xml:lang="sv">Tjänst</comment>
+ <comment xml:lang="uk">Служба</comment>
+ <comment xml:lang="zh_TW">服務</comment>
</mime-type>
<mime-type type="application/vnd.kde.bluedevil-network-panu">
<comment>Service</comment>
+ <comment xml:lang="bs">Usluga</comment>
+ <comment xml:lang="ca">Servei</comment>
+ <comment xml:lang="cs">Služba</comment>
+ <comment xml:lang="da">Tjeneste</comment>
+ <comment xml:lang="de">Dienst</comment>
+ <comment xml:lang="el">Υπηρεσία</comment>
+ <comment xml:lang="en_GB">Service</comment>
+ <comment xml:lang="es">Servicio</comment>
+ <comment xml:lang="fi">Palvelu</comment>
+ <comment xml:lang="fr">Service</comment>
+ <comment xml:lang="it">Servizio</comment>
+ <comment xml:lang="nl">Service</comment>
+ <comment xml:lang="pl">Usługa</comment>
+ <comment xml:lang="pt">Serviço</comment>
+ <comment xml:lang="pt_BR">Serviço</comment>
+ <comment xml:lang="sk">Služba</comment>
+ <comment xml:lang="sl">Storitev</comment>
+ <comment xml:lang="sr">сервис</comment>
+ <comment xml:lang="sr@ijekavian">сервис</comment>
+ <comment xml:lang="sr@ijekavianlatin">servis</comment>
+ <comment xml:lang="sr@latin">servis</comment>
+ <comment xml:lang="sv">Tjänst</comment>
+ <comment xml:lang="uk">Служба</comment>
+ <comment xml:lang="zh_TW">服務</comment>
</mime-type>
<mime-type type="application/vnd.kde.bluedevil-network-dun">
<comment>Service</comment>
+ <comment xml:lang="bs">Usluga</comment>
+ <comment xml:lang="ca">Servei</comment>
+ <comment xml:lang="cs">Služba</comment>
+ <comment xml:lang="da">Tjeneste</comment>
+ <comment xml:lang="de">Dienst</comment>
+ <comment xml:lang="el">Υπηρεσία</comment>
+ <comment xml:lang="en_GB">Service</comment>
+ <comment xml:lang="es">Servicio</comment>
+ <comment xml:lang="fi">Palvelu</comment>
+ <comment xml:lang="fr">Service</comment>
+ <comment xml:lang="it">Servizio</comment>
+ <comment xml:lang="nl">Service</comment>
+ <comment xml:lang="pl">Usługa</comment>
+ <comment xml:lang="pt">Serviço</comment>
+ <comment xml:lang="pt_BR">Serviço</comment>
+ <comment xml:lang="sk">Služba</comment>
+ <comment xml:lang="sl">Storitev</comment>
+ <comment xml:lang="sr">сервис</comment>
+ <comment xml:lang="sr@ijekavian">сервис</comment>
+ <comment xml:lang="sr@ijekavianlatin">servis</comment>
+ <comment xml:lang="sr@latin">servis</comment>
+ <comment xml:lang="sv">Tjänst</comment>
+ <comment xml:lang="uk">Служба</comment>
+ <comment xml:lang="zh_TW">服務</comment>
</mime-type>
<mime-type type="application/vnd.kde.bluedevil-sendfile">
<comment>Service</comment>
+ <comment xml:lang="bs">Usluga</comment>
+ <comment xml:lang="ca">Servei</comment>
+ <comment xml:lang="cs">Služba</comment>
+ <comment xml:lang="da">Tjeneste</comment>
+ <comment xml:lang="de">Dienst</comment>
+ <comment xml:lang="el">Υπηρεσία</comment>
+ <comment xml:lang="en_GB">Service</comment>
+ <comment xml:lang="es">Servicio</comment>
+ <comment xml:lang="fi">Palvelu</comment>
+ <comment xml:lang="fr">Service</comment>
+ <comment xml:lang="it">Servizio</comment>
+ <comment xml:lang="nl">Service</comment>
+ <comment xml:lang="pl">Usługa</comment>
+ <comment xml:lang="pt">Serviço</comment>
+ <comment xml:lang="pt_BR">Serviço</comment>
+ <comment xml:lang="sk">Služba</comment>
+ <comment xml:lang="sl">Storitev</comment>
+ <comment xml:lang="sr">сервис</comment>
+ <comment xml:lang="sr@ijekavian">сервис</comment>
+ <comment xml:lang="sr@ijekavianlatin">servis</comment>
+ <comment xml:lang="sr@latin">servis</comment>
+ <comment xml:lang="sv">Tjänst</comment>
+ <comment xml:lang="uk">Служба</comment>
+ <comment xml:lang="zh_TW">服務</comment>
</mime-type>
</mime-info>
diff --git a/src/bluedevil.notifyrc b/src/bluedevil.notifyrc
index 27b45743d42597b033158e51e5fdebbd8e32e4f4..4082c625e22c3c8555f0cd587d7634c9e8a720f5 100644
--- a/src/bluedevil.notifyrc
+++ b/src/bluedevil.notifyrc
@@ -241,6 +241,7 @@ Name[fr]=Demande de code « PIN »
Name[it]=Richiesta PIN
Name[nb]=Be om PIN
Name[nl]=Om PIN verzoeken
+Name[pa]=ਬੇਨਤੀ ਪਿਨ
Name[pl]=Żąda numeru PIN
Name[pt]=Pedir o PIN
Name[pt_BR]=Solicitar o PIN
@@ -299,6 +300,7 @@ Name[fr]=Fichier entrant
Name[it]=File in arrivo
Name[nb]=Innkommende fil
Name[nl]=Bestand aangeboden
+Name[pa]=ਆ ਰਹੀ ਫਾਇਲ
Name[pl]=Przychodzący plik
Name[pt]=Ficheiro Recebido
Name[pt_BR]=Arquivo recebido
diff --git a/src/daemon/helpers/authorize/authorize.cpp b/src/daemon/helpers/authorize/authorize.cpp
index c6f44daf2e770ef7ea1c220dae259dbb1267a599..6847ba94dd9a784c06b80f2fbe9976dfcdafaca9 100644
--- a/src/daemon/helpers/authorize/authorize.cpp
+++ b/src/daemon/helpers/authorize/authorize.cpp
@@ -39,33 +39,33 @@ Authorize::Authorize()
notification->setText(i18nc(
"Show a notification asking to authorize or deny access to this computer from Bluetooth. The %1 is the name of the bluetooth device",
- "%1 is requesting access to this computer", qApp->arguments()[1])
+ "%1 is requesting access to this computer", qApp->arguments().at(1))
);
QStringList actions;
actions.append(i18nc("Button to trust a bluetooth remote device and authorize it to connect", "Trust and Authorize"));
- actions.append(i18nc("Button to authorize a bluetooth remote device to connect ", "Authorize Only"));
+ actions.append(i18nc("Button to authorize a bluetooth remote device to connect", "Authorize Only"));
actions.append(i18nc("Deny access to a remote bluetooth device", "Deny"));
notification->setActions(actions);
- connect(notification, SIGNAL(action1Activated()),this, SLOT(trust()));
- connect(notification, SIGNAL(action2Activated()),this, SLOT(authorize()));
- connect(notification, SIGNAL(action3Activated()),this, SLOT(deny()));
- connect(notification, SIGNAL(closed()), this, SLOT(deny()));
- connect(notification, SIGNAL(ignored()), this, SLOT(deny()));
+ connect(notification, &KNotification::action1Activated, this, &Authorize::trust);
+ connect(notification, &KNotification::action2Activated, this, &Authorize::authorize);
+ connect(notification, &KNotification::action3Activated, this, &Authorize::deny);
+ connect(notification, &KNotification::closed, this, &Authorize::deny);
+ connect(notification, &KNotification::ignored, this, &Authorize::deny);
- notification->setPixmap(QIcon::fromTheme(QStringLiteral("preferences-system-bluetooth")).pixmap(42, 42));
+ notification->setPixmap(QIcon::fromTheme(QStringLiteral("preferences-system-bluetooth")).pixmap(42));
// We're using persistent notifications so we have to use our own timeout (10s)
- QTimer::singleShot(10000, notification, SLOT(close()));
+ QTimer::singleShot(10000, notification, &KNotification::close);
notification->sendEvent();
}
void Authorize::trust()
{
qDebug() << "Trusted";
- BlueDevil::Manager::self()->usableAdapter()->deviceForUBI(qApp->arguments()[2])->setTrusted(true);
+ BlueDevil::Manager::self()->usableAdapter()->deviceForUBI(qApp->arguments().at(2))->setTrusted(true);
qApp->exit(0);
}
diff --git a/src/daemon/helpers/authorize/authorize.h b/src/daemon/helpers/authorize/authorize.h
index d881baa0dd3d5f9d1244d70a28b7c4d6af03bdb3..b3b41902e56831091d6bb009254f8ee76e0e00ed 100644
--- a/src/daemon/helpers/authorize/authorize.h
+++ b/src/daemon/helpers/authorize/authorize.h
@@ -32,8 +32,7 @@
* Deny quits the app with 1 (which means denied)
* @internal
*/
-class Authorize
- : public QObject
+class Authorize : public QObject
{
Q_OBJECT
@@ -42,7 +41,7 @@ public:
* Launch the KNotification which the respective actions, also makes the needed connection
* between those actions and the slots
*/
- Authorize();
+ explicit Authorize();
private Q_SLOTS:
/**
@@ -60,4 +59,5 @@ private Q_SLOTS:
*/
void deny();
};
-#endif
+
+#endif // AUTHORIZE_H
diff --git a/src/daemon/helpers/authorize/main.cpp b/src/daemon/helpers/authorize/main.cpp
index 615245f4fcd38bb3d8a1e2ca65febbe4e123b647..8106ff697e861a18d468330c9d5c5050400bc4b1 100644
--- a/src/daemon/helpers/authorize/main.cpp
+++ b/src/daemon/helpers/authorize/main.cpp
@@ -18,15 +18,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
-
#include "authorize.h"
#include <QApplication>
-#include <KLocalizedString>
-
-static const KLocalizedString description = ki18n("KDE Bluetooth System");
-
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
diff --git a/src/daemon/helpers/confirmmodechange/confirmmodechange.cpp b/src/daemon/helpers/confirmmodechange/confirmmodechange.cpp
index 1328f74cba667fddf14c8ce23a3e7e4b54e45fdf..62eccd32840e48cb8919ee538844381db57d48d7 100644
--- a/src/daemon/helpers/confirmmodechange/confirmmodechange.cpp
+++ b/src/daemon/helpers/confirmmodechange/confirmmodechange.cpp
@@ -37,7 +37,7 @@ ConfirmModeChange::ConfirmModeChange()
notification->setText(i18nc(
"Showed in a notification when the Bluetooth mode is going to be changed (for example to flight mode), the %1 is the name of the mode",
- "Change Bluetooth mode to '%1'?", qApp->arguments()[1])
+ "Change Bluetooth mode to '%1'?", qApp->arguments().at(1))
);
QStringList actions;
@@ -46,14 +46,14 @@ ConfirmModeChange::ConfirmModeChange()
notification->setActions(actions);
- connect(notification, SIGNAL(action1Activated()),this, SLOT(confirm()));
- connect(notification, SIGNAL(action2Activated()),this, SLOT(deny()));
- connect(notification, SIGNAL(closed()), this, SLOT(deny()));
- connect(notification, SIGNAL(ignored()), this, SLOT(deny()));
+ connect(notification, &KNotification::action1Activated,this, &ConfirmModeChange::confirm);
+ connect(notification, &KNotification::action2Activated,this, &ConfirmModeChange::deny);
+ connect(notification, &KNotification::closed, this, &ConfirmModeChange::deny);
+ connect(notification, &KNotification::ignored, this, &ConfirmModeChange::deny);
// We're using persistent notifications so we have to use our own timeout (10s)
- QTimer::singleShot(10000, notification, SLOT(close()));
- notification->setPixmap(QIcon::fromTheme(QStringLiteral("preferences-system-bluetooth")).pixmap(42, 42));
+ QTimer::singleShot(10000, notification, &KNotification::close);
+ notification->setPixmap(QIcon::fromTheme(QStringLiteral("preferences-system-bluetooth")).pixmap(42));
notification->sendEvent();
}
@@ -68,4 +68,3 @@ void ConfirmModeChange::deny()
qDebug() << "Denied";
qApp->exit(1);
}
-
diff --git a/src/daemon/helpers/confirmmodechange/confirmmodechange.h b/src/daemon/helpers/confirmmodechange/confirmmodechange.h
index 4d79b02b16457e377dc364de32ab51d9ad41f156..572fb57e2a6544cce08a13fb48d13b17ad14e121 100644
--- a/src/daemon/helpers/confirmmodechange/confirmmodechange.h
+++ b/src/daemon/helpers/confirmmodechange/confirmmodechange.h
@@ -19,8 +19,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#ifndef AUTHORIZE_H
-#define AUTHORIZE_H
+#ifndef CONFIRM_MODE_CHANGE_H
+#define CONFIRM_MODE_CHANGE_H
#include <QObject>
@@ -32,8 +32,7 @@
* Deny quits the app with 1 (which means denied)
* @internal
*/
-class ConfirmModeChange
- : public QObject
+class ConfirmModeChange : public QObject
{
Q_OBJECT
@@ -42,7 +41,7 @@ public:
* Launch the KNotification which the respective actions, also makes the needed connection
* between those actions and the slots
*/
- ConfirmModeChange();
+ explicit ConfirmModeChange();
private Q_SLOTS:
/**
@@ -55,4 +54,5 @@ private Q_SLOTS:
*/
void deny();
};
-#endif
+
+#endif // CONFIRM_MODE_CHANGE_H
diff --git a/src/daemon/helpers/confirmmodechange/main.cpp b/src/daemon/helpers/confirmmodechange/main.cpp
index b4ed9463740c200643f468a44bebf5040ae30d70..a2e05bb510e3ea60032fe3c3760573c34595b3ed 100644
--- a/src/daemon/helpers/confirmmodechange/main.cpp
+++ b/src/daemon/helpers/confirmmodechange/main.cpp
@@ -18,15 +18,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
-
#include "confirmmodechange.h"
#include <QApplication>
-#include <KLocalizedString>
-
-static const KLocalizedString description = ki18n("KDE Bluetooth System");
-
int main(int argc, char *argv[])
{
QApplication app(argc,argv);
diff --git a/src/daemon/helpers/requestconfirmation/main.cpp b/src/daemon/helpers/requestconfirmation/main.cpp
index e7ecde08ffc89456739563f54350c49067352520..f32406041b35212154d6ac7e854a6a908588e65b 100644
--- a/src/daemon/helpers/requestconfirmation/main.cpp
+++ b/src/daemon/helpers/requestconfirmation/main.cpp
@@ -22,10 +22,6 @@
#include <QApplication>
-#include <KLocalizedString>
-
-static const KLocalizedString description = ki18n("KDE Bluetooth System");
-
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
diff --git a/src/daemon/helpers/requestconfirmation/requestconfirmation.cpp b/src/daemon/helpers/requestconfirmation/requestconfirmation.cpp
index ac24731af2f14c5978177cdd3f278c07323f78b3..31b15c361665763c0d2bb6fd5bd758d3adb899c9 100644
--- a/src/daemon/helpers/requestconfirmation/requestconfirmation.cpp
+++ b/src/daemon/helpers/requestconfirmation/requestconfirmation.cpp
@@ -35,7 +35,7 @@ RequestConfirmation::RequestConfirmation() : QObject()
notification->setText(i18nc(
"The text is shown in a notification to know if the PIN is correct, %1 is the remote bluetooth device and %2 is the pin",
- "%1 is asking if the PIN is correct: %2", qApp->arguments()[1], qApp->arguments()[2])
+ "%1 is asking if the PIN is correct: %2", qApp->arguments().at(1), qApp->arguments().at(2))
);
QStringList actions;
@@ -44,14 +44,14 @@ RequestConfirmation::RequestConfirmation() : QObject()
notification->setActions(actions);
- connect(notification, SIGNAL(action1Activated()),this, SLOT(pinCorrect()));
- connect(notification, SIGNAL(action2Activated()),this, SLOT(pinWrong()));
- connect(notification, SIGNAL(closed()), this, SLOT(pinWrong()));
- connect(notification, SIGNAL(ignored()), this, SLOT(pinWrong()));
+ connect(notification, &KNotification::action1Activated, this, &RequestConfirmation::pinCorrect);
+ connect(notification, &KNotification::action2Activated, this, &RequestConfirmation::pinWrong);
+ connect(notification, &KNotification::closed, this, &RequestConfirmation::pinWrong);
+ connect(notification, &KNotification::ignored, this, &RequestConfirmation::pinWrong);
- //We're using persistent notifications so we have to use our own timeout (10s)
- QTimer::singleShot(10000, notification, SLOT(close()));
- notification->setPixmap(QIcon::fromTheme(QStringLiteral("preferences-system-bluetooth")).pixmap(42,42));
+ // We're using persistent notifications so we have to use our own timeout (10s)
+ QTimer::singleShot(10000, notification, &KNotification::close);
+ notification->setPixmap(QIcon::fromTheme(QStringLiteral("preferences-system-bluetooth")).pixmap(42));
notification->sendEvent();
}
diff --git a/src/daemon/helpers/requestconfirmation/requestconfirmation.h b/src/daemon/helpers/requestconfirmation/requestconfirmation.h
index 60ebff85b074371422f1518902a70964dd1c20a7..59c6cfa4847d3738924e53b9996b7328d0edb1e1 100644
--- a/src/daemon/helpers/requestconfirmation/requestconfirmation.h
+++ b/src/daemon/helpers/requestconfirmation/requestconfirmation.h
@@ -19,8 +19,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#ifndef AUTHORIZE_H
-#define AUTHORIZE_H
+#ifndef REQUEST_CONFIRMATION_H
+#define REQUEST_CONFIRMATION_H
#include <QObject>
@@ -32,8 +32,7 @@
* Deny quits the app with 1 (which means denied)
* @internal
*/
-class RequestConfirmation
- : public QObject
+class RequestConfirmation : public QObject
{
Q_OBJECT
@@ -42,7 +41,7 @@ public:
* Launch the KNotification which the respective actions, also makes the needed connection
* between those actions and the slots
*/
- RequestConfirmation();
+ explicit RequestConfirmation();
private Q_SLOTS:
/**
@@ -55,4 +54,5 @@ private Q_SLOTS:
*/
void pinWrong();
};
-#endif
+
+#endif // REQUEST_CONFIRMATION_H
diff --git a/src/daemon/helpers/requestpin/dialogWidget.ui b/src/daemon/helpers/requestpin/dialogWidget.ui
index 478f1be9610ce09342b748ddc36bc0b408b4a5de..8e769a374a0e14fc3914560342750ef9395f919e 100644
--- a/src/daemon/helpers/requestpin/dialogWidget.ui
+++ b/src/daemon/helpers/requestpin/dialogWidget.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>259</width>
- <height>127</height>
+ <height>138</height>
</rect>
</property>
<property name="minimumSize">
@@ -61,12 +61,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="inputMask">
- <string notr="true"/>
- </property>
- <property name="maxLength">
- <number>32767</number>
- </property>
<property name="placeholderText">
<string>1234</string>
</property>
diff --git a/src/daemon/helpers/requestpin/main.cpp b/src/daemon/helpers/requestpin/main.cpp
index 8472108a253c064b5b4030b2d2e55d8b2a04bf95..e3cfb29961d8485e036897ad0676fe07b6c658b0 100644
--- a/src/daemon/helpers/requestpin/main.cpp
+++ b/src/daemon/helpers/requestpin/main.cpp
@@ -22,10 +22,6 @@
#include <QApplication>
-#include <KLocalizedString>
-
-static const KLocalizedString description = ki18n("KDE Bluetooth System");
-
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
diff --git a/src/daemon/helpers/requestpin/requestpin.cpp b/src/daemon/helpers/requestpin/requestpin.cpp
index 7402b25dbd16a16ad3b7bd9e057162101c8d1744..8b5f88c904c2237bf95b340c9ef8f0dbbfaff04a 100644
--- a/src/daemon/helpers/requestpin/requestpin.cpp
+++ b/src/daemon/helpers/requestpin/requestpin.cpp
@@ -37,9 +37,7 @@
#include <KNotification>
#include <KLocalizedString>
-using namespace std;
-RequestPin::RequestPin()
- : QObject()
+RequestPin::RequestPin() : QObject()
, m_dialogWidget(0)
{
m_notification = new KNotification(QStringLiteral("bluedevilRequestPin"),
@@ -47,7 +45,7 @@ RequestPin::RequestPin()
m_notification->setText(i18nc(
"Shown in a notification to announce that a PIN is needed to accomplish a pair action, %1 is the name of the bluetooth device",
- "PIN needed to pair with %1",qApp->arguments()[1])
+ "PIN needed to pair with %1", qApp->arguments().at(1))
);
QStringList actions;
@@ -58,17 +56,17 @@ RequestPin::RequestPin()
m_notification->setActions(actions);
- connect(m_notification, SIGNAL(action1Activated()),this, SLOT(introducePin()));
- connect(m_notification, SIGNAL(closed()), this, SLOT(quit()));
- connect(m_notification, SIGNAL(ignored()), this, SLOT(quit()));
+ connect(m_notification, &KNotification::action1Activated,this, &RequestPin::introducePin);
+ connect(m_notification, &KNotification::closed, this, &RequestPin::quit);
+ connect(m_notification, &KNotification::ignored, this, &RequestPin::quit);
- //We're using persistent notifications so we have to use our own timeout (10s)
+ // We're using persistent notifications so we have to use our own timeout (10s)
m_timer.setSingleShot(true);
m_timer.setInterval(10000);
m_timer.start();
- connect(&m_timer, SIGNAL(timeout()), m_notification, SLOT(close()));
+ connect(&m_timer, &QTimer::timeout, m_notification, &KNotification::close);
- m_notification->setPixmap(QIcon::fromTheme(QStringLiteral("preferences-system-bluetooth")).pixmap(42,42));
+ m_notification->setPixmap(QIcon::fromTheme(QStringLiteral("preferences-system-bluetooth")).pixmap(42));
m_notification->sendEvent();
}
@@ -90,27 +88,27 @@ void RequestPin::introducePin()
m_dialogWidget->descLabel->setText(i18nc(
"Shown in a dialog which asks to introduce a PIN that will be used to pair a Bluetooth device, %1 is the name of the Bluetooth device",
"In order to pair this computer with %1, you have to enter a PIN. Please do it below.",
- qApp->arguments()[1])
+ qApp->arguments().at(1))
);
- m_dialogWidget->pixmap->setPixmap(QIcon::fromTheme(QStringLiteral("preferences-system-bluetooth")).pixmap(64,64));
+ m_dialogWidget->pixmap->setPixmap(QIcon::fromTheme(QStringLiteral("preferences-system-bluetooth")).pixmap(64));
- connect(m_dialogWidget->pin, SIGNAL(textChanged(QString)), SLOT(checkPin(QString)));
- connect(m_dialogWidget->pin, SIGNAL(returnPressed()), dialog, SLOT(accept()));
+ connect(m_dialogWidget->pin, &KLineEdit::textChanged, this, &RequestPin::checkPin);
+ connect(m_dialogWidget->pin, &KLineEdit::returnPressed, dialog, &QDialog::accept);
m_dialogWidget->pin->setFocus(Qt::ActiveWindowFocusReason);
- qDebug() << qApp->arguments();
- if (qApp->arguments().count() > 2 && qApp->arguments()[2] == QLatin1String("numeric")) {
- m_dialogWidget->pin->setValidator(new QRegExpValidator(QRegExp(QStringLiteral("[0-9]{1,6}")), this ));
+
+ if (qApp->arguments().count() > 2 && qApp->arguments().at(2) == QLatin1String("numeric")) {
+ m_dialogWidget->pin->setValidator(new QRegExpValidator(QRegExp(QStringLiteral("[0-9]{1,6}")), this));
} else {
- m_dialogWidget->pin->setValidator(new QRegExpValidator(QRegExp(QStringLiteral("[A-Za-z0-9]{1,16}")), this ));
+ m_dialogWidget->pin->setValidator(new QRegExpValidator(QRegExp(QStringLiteral("[A-Za-z0-9]{1,16}")), this));
}
m_dialogWidget->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
dialog->setMinimumSize(dialog->sizeHint());
dialog->setMaximumSize(dialog->sizeHint());
if (dialog->exec()) {
- cout << m_dialogWidget->pin->text().toLatin1().constData();
- flush(cout);
+ std::cout << m_dialogWidget->pin->text().toLatin1().constData();
+ std::flush(std::cout);
delete dialog;
qApp->exit(0);
return;
@@ -120,7 +118,7 @@ void RequestPin::introducePin()
qApp->exit(1);
}
-void RequestPin::checkPin(const QString& pin)
+void RequestPin::checkPin(const QString &pin)
{
m_dialogWidget->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!pin.isEmpty());
}
diff --git a/src/daemon/helpers/requestpin/requestpin.h b/src/daemon/helpers/requestpin/requestpin.h
index 3cc09e6de018d22b035e19b70499cb556951cc22..bfa96dc859f4587b2d94ee14aa10db19f73c6db4 100644
--- a/src/daemon/helpers/requestpin/requestpin.h
+++ b/src/daemon/helpers/requestpin/requestpin.h
@@ -19,14 +19,15 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#ifndef REQUESTPIN_H
-#define REQUESTPIN_H
+#ifndef REQUEST_PIN_H
+#define REQUEST_PIN_H
#include <QObject>
#include <QTimer>
-namespace Ui {
-class dialogWidget;
+namespace Ui
+{
+ class dialogWidget;
}
class KNotification;
@@ -39,8 +40,7 @@ class KNotification;
* Deny quits the app with 1 (which means denied)
* @internal
*/
-class RequestPin
- : public QObject
+class RequestPin : public QObject
{
Q_OBJECT
@@ -49,7 +49,7 @@ public:
* Launch the KNotification which the respective actions, also makes the needed connection
* between those actions and the slots
*/
- RequestPin();
+ explicit RequestPin();
private Q_SLOTS:
/**
@@ -70,4 +70,5 @@ private:
Ui::dialogWidget *m_dialogWidget;
KNotification *m_notification;
};
-#endif //REQUESTPIN_H
+
+#endif // REQUEST_PIN_H
diff --git a/src/daemon/kded/BlueDevilDaemon.cpp b/src/daemon/kded/BlueDevilDaemon.cpp
index 12111036565365212f9d7a520b881197652ee3e6..0b59ce5d45ef33630408a933a4f67bffb6f14597 100644
--- a/src/daemon/kded/BlueDevilDaemon.cpp
+++ b/src/daemon/kded/BlueDevilDaemon.cpp
@@ -38,6 +38,7 @@
#include <KLocalizedString>
#include <kfileplacesmodel.h>
#include <kdirnotify.h>
+#include <ksharedconfig.h>
#include <bluedevil/bluedevilmanager.h>
#include <bluedevil/bluedeviladapter.h>
@@ -59,21 +60,21 @@ struct BlueDevilDaemon::Private
Offline
} m_status;
- BluezAgent *m_bluezAgent;
- KFilePlacesModel *m_placesModel;
- Adapter *m_adapter;
- QDBusServiceWatcher *m_monolithicWatcher;
- FileReceiver *m_fileReceiver;
- QList <DeviceInfo> m_discovered;
- QTimer m_timer;
+ BluezAgent *m_bluezAgent;
+ KFilePlacesModel *m_placesModel;
+ Adapter *m_adapter;
+ QDBusServiceWatcher *m_monolithicWatcher;
+ FileReceiver *m_fileReceiver;
+ KSharedConfig::Ptr m_config;
+ QTimer m_timer;
};
BlueDevilDaemon::BlueDevilDaemon(QObject *parent, const QList<QVariant>&)
: KDEDModule(parent)
, d(new Private)
{
- qDBusRegisterMetaType <DeviceInfo> ();
- qDBusRegisterMetaType <QMapDeviceInfo> ();
+ qDBusRegisterMetaType<DeviceInfo>();
+ qDBusRegisterMetaType<QMapDeviceInfo>();
d->m_bluezAgent = 0;
d->m_adapter = 0;
@@ -81,8 +82,8 @@ BlueDevilDaemon::BlueDevilDaemon(QObject *parent, const QList<QVariant>&)
d->m_fileReceiver = 0;
d->m_monolithicWatcher = new QDBusServiceWatcher(QStringLiteral("org.kde.bluedevilmonolithic")
, QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForUnregistration, this);
- d->m_timer.setInterval(20000);
d->m_timer.setSingleShot(true);
+ d->m_config = KSharedConfig::openConfig(QStringLiteral("bluedevilglobalrc"));
KAboutData aboutData(
QStringLiteral("bluedevildaemon"),
@@ -102,12 +103,25 @@ BlueDevilDaemon::BlueDevilDaemon(QObject *parent, const QList<QVariant>&)
aboutData.setComponentName(QStringLiteral("bluedevil"));
KAboutData::registerPluginData(aboutData);
- connect(d->m_monolithicWatcher, SIGNAL(serviceUnregistered(const QString &)), SLOT(monolithicFinished(const QString &)));
+ connect(d->m_monolithicWatcher, &QDBusServiceWatcher::serviceUnregistered, this, &BlueDevilDaemon::monolithicFinished);
+ connect(&d->m_timer, &QTimer::timeout, this, &BlueDevilDaemon::stopDiscovering);
- connect(Manager::self(), SIGNAL(usableAdapterChanged(Adapter*)),
- this, SLOT(usableAdapterChanged(Adapter*)));
+ connect(Manager::self(), &Manager::usableAdapterChanged, this, &BlueDevilDaemon::usableAdapterChanged);
+ connect(Manager::self(), &Manager::adapterAdded, this, &BlueDevilDaemon::adapterAdded);
+ connect(Manager::self(), &Manager::adapterRemoved, this, &BlueDevilDaemon::adapterRemoved);
+
+ // Catch suspend/resume events
+ QDBusConnection::systemBus().connect(QStringLiteral("org.freedesktop.login1"),
+ QStringLiteral("/org/freedesktop/login1"),
+ QStringLiteral("org.freedesktop.login1.Manager"),
+ QStringLiteral("PrepareForSleep"),
+ this,
+ SLOT(login1PrepareForSleep(bool))
+ );
d->m_status = Private::Offline;
+
+ restoreAdaptersState();
usableAdapterChanged(Manager::self()->usableAdapter());
if (!Manager::self()->adapters().isEmpty()) {
@@ -117,6 +131,8 @@ BlueDevilDaemon::BlueDevilDaemon(QObject *parent, const QList<QVariant>&)
BlueDevilDaemon::~BlueDevilDaemon()
{
+ saveAdaptersState();
+
if (d->m_status == Private::Online) {
offlineMode();
}
@@ -124,93 +140,111 @@ BlueDevilDaemon::~BlueDevilDaemon()
delete d;
}
-bool BlueDevilDaemon::isOnline()
+void BlueDevilDaemon::login1PrepareForSleep(bool active)
{
- if (d->m_status == Private::Offline) {
- return false;
+ if (active) {
+ qCDebug(BLUEDAEMON) << "About to suspend";
+ saveAdaptersState();
+ } else {
+ qCDebug(BLUEDAEMON) << "About to resume";
+ restoreAdaptersState();
}
- return true;
}
-QMapDeviceInfo BlueDevilDaemon::knownDevices()
+bool BlueDevilDaemon::isOnline()
+{
+ return d->m_status == Private::Online;
+}
+
+QMapDeviceInfo BlueDevilDaemon::allDevices()
{
QMapDeviceInfo devices;
+ QList<Device*> list = Manager::self()->usableAdapter()->devices();
- QList <Device* > list = Manager::self()->usableAdapter()->devices();
- qCDebug(BLUEDAEMON) << "List: " << list.length();
- DeviceInfo info;
- Q_FOREACH(Device *const device, list) {
- info[QStringLiteral("name")] = device->friendlyName();
- info[QStringLiteral("icon")] = device->icon();
- info[QStringLiteral("address")] = device->address();
- info[QStringLiteral("UUIDs")] = device->UUIDs().join(QStringLiteral(","));
- devices[device->address()] = info;
+ Q_FOREACH (Device *const device, list) {
+ devices[device->address()] = deviceToInfo(device);
}
- if (!d->m_timer.isActive()) {
- qCDebug(BLUEDAEMON) << "Start Discovery";
- Manager::self()->usableAdapter()->startStableDiscovery();
- d->m_discovered.clear();
- d->m_timer.start();
- }
+ return devices;
+}
- Q_FOREACH(const DeviceInfo& info, d->m_discovered) {
- if (!devices.contains(info[QStringLiteral("address")])) {
- devices[info[QStringLiteral("address")]] = info;
+DeviceInfo BlueDevilDaemon::device(const QString &address)
+{
+ Q_FOREACH (Device *const device, Manager::self()->devices()) {
+ if (device->address() == address) {
+ return deviceToInfo(device);
}
}
- return devices;
+
+ return DeviceInfo();
+}
+
+void BlueDevilDaemon::startDiscovering(quint32 timeout)
+{
+ if (!d->m_adapter) {
+ return;
+ }
+
+ qCDebug(BLUEDAEMON) << "Start discovering for" << timeout << "ms";
+
+ d->m_adapter->startDiscovery();
+
+ if (timeout > 0) {
+ d->m_timer.start(timeout);
+ }
}
void BlueDevilDaemon::stopDiscovering()
{
- qCDebug(BLUEDAEMON) << "Stopping discovering";
- d->m_timer.stop();
- Manager::self()->usableAdapter()->stopDiscovery();
+ if (!d->m_adapter) {
+ return;
+ }
+
+ qCDebug(BLUEDAEMON) << "Stop discovering";
+
+ if (d->m_adapter->isDiscovering()) {
+ d->m_adapter->stopDiscovery();
+ }
}
void BlueDevilDaemon::executeMonolithic()
{
- qCDebug(BLUEDAEMON);
-
QProcess process;
if (!process.startDetached(QStringLiteral("bluedevil-monolithic"))) {
- qCritical() << "Could not start bluedevil-monolithic";
+ qCCritical(BLUEDAEMON) << "Could not start bluedevil-monolithic";
}
}
void BlueDevilDaemon::killMonolithic()
{
- qCDebug(BLUEDAEMON);
QDBusMessage msg = QDBusMessage::createMethodCall(
QStringLiteral("org.kde.bluedevilmonolithic"),
QStringLiteral("/MainApplication"),
QStringLiteral("org.kde.KApplication"),
QStringLiteral("quit")
);
+
QDBusPendingCall pending = QDBusConnection::sessionBus().asyncCall(msg);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pending);
- connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(monolithicQuit(QDBusPendingCallWatcher*)));
+ connect(watcher, &QDBusPendingCallWatcher::finished, this, &BlueDevilDaemon::monolithicQuit);
}
void BlueDevilDaemon::onlineMode()
{
- qCDebug(BLUEDAEMON);
if (d->m_status == Private::Online) {
qCDebug(BLUEDAEMON) << "Already in onlineMode";
return;
}
d->m_bluezAgent = new BluezAgent(new QObject());
- connect(d->m_bluezAgent, SIGNAL(agentReleased()), this, SLOT(agentReleased()));
-
- connect(d->m_adapter, SIGNAL(deviceFound(Device*)), this, SLOT(deviceFound(Device*)));
- connect(&d->m_timer, SIGNAL(timeout()), d->m_adapter, SLOT(stopDiscovery()));
+ connect(d->m_bluezAgent, &BluezAgent::agentReleased, this, &BlueDevilDaemon::agentReleased);
+ connect(d->m_adapter, &Adapter::deviceFound, this, &BlueDevilDaemon::deviceFound);
FileReceiverSettings::self()->load();
if (!d->m_fileReceiver && FileReceiverSettings::self()->enabled()) {
d->m_fileReceiver = new FileReceiver(this);
}
+
if (d->m_fileReceiver && !FileReceiverSettings::self()->enabled()) {
qCDebug(BLUEDAEMON) << "Stoppping server";
delete d->m_fileReceiver;
@@ -221,7 +255,7 @@ void BlueDevilDaemon::onlineMode()
d->m_placesModel = new KFilePlacesModel();
}
- //Just in case kded was killed or crashed
+ // Just in case kded was killed or crashed
QModelIndex index = d->m_placesModel->closestItem(QUrl(QStringLiteral("bluetooth:/")));
while (index.row() != -1) {
d->m_placesModel->removePlace(index);
@@ -237,8 +271,6 @@ void BlueDevilDaemon::onlineMode()
void BlueDevilDaemon::monolithicFinished(const QString &)
{
- qCDebug(BLUEDAEMON);
-
if (d->m_status == Private::Online) {
executeMonolithic();
}
@@ -247,6 +279,7 @@ void BlueDevilDaemon::monolithicFinished(const QString &)
void BlueDevilDaemon::offlineMode()
{
qCDebug(BLUEDAEMON) << "Offline mode";
+
if (d->m_status == Private::Offline) {
qCDebug(BLUEDAEMON) << "Already in offlineMode";
return;
@@ -255,7 +288,7 @@ void BlueDevilDaemon::offlineMode()
d->m_adapter = 0;
if (d->m_bluezAgent) {
- delete d->m_bluezAgent->parent(); // we meed to delete the parent for not leaking it
+ delete d->m_bluezAgent->parent(); // we need to delete the parent for not leaking it
d->m_bluezAgent = 0;
}
@@ -265,15 +298,12 @@ void BlueDevilDaemon::offlineMode()
d->m_fileReceiver = 0;
}
- //Just to be sure that online was called
+ // Just to be sure that online was called
if (d->m_placesModel) {
QModelIndex index = d->m_placesModel->closestItem(QUrl(QStringLiteral("bluetooth:/")));
d->m_placesModel->removePlace(index);
}
- if (BlueDevil::Manager::self()->adapters().isEmpty()) {
- killMonolithic();
- }
d->m_status = Private::Offline;
}
@@ -301,31 +331,84 @@ void BlueDevilDaemon::usableAdapterChanged(Adapter *adapter)
}
}
+void BlueDevilDaemon::adapterAdded(Adapter *adapter)
+{
+ restoreAdapterState(adapter);
+}
+
+void BlueDevilDaemon::adapterRemoved(Adapter *adapter)
+{
+ Q_UNUSED(adapter)
+
+ if (BlueDevil::Manager::self()->adapters().isEmpty()) {
+ killMonolithic();
+ }
+}
+
void BlueDevilDaemon::deviceFound(Device *device)
{
qCDebug(BLUEDAEMON) << "DeviceFound: " << device->name();
- d->m_discovered.append(deviceToInfo(device));
org::kde::KDirNotify::emitFilesAdded(QUrl(QStringLiteral("bluetooth:/")));
}
-void BlueDevilDaemon::monolithicQuit(QDBusPendingCallWatcher* watcher)
+void BlueDevilDaemon::monolithicQuit(QDBusPendingCallWatcher *watcher)
{
- qCDebug(BLUEDAEMON);
QDBusPendingReply<void> reply = *watcher;
if (reply.isError()) {
- qDebug() << "Error response: " << reply.error().message();
- killMonolithic();
+ qCDebug(BLUEDAEMON) << "Error response: " << reply.error().message();
+ }
+}
+
+void BlueDevilDaemon::saveAdaptersState()
+{
+ Manager *manager = Manager::self();
+ if (!manager) {
+ return;
+ }
+
+ KConfigGroup adaptersGroup = d->m_config->group("Adapters");
+
+ Q_FOREACH (Adapter *adapter, manager->adapters()) {
+ const QString key = QString(QStringLiteral("%1_powered")).arg(adapter->address());
+ adaptersGroup.writeEntry<bool>(key, adapter->isPowered());
+ }
+
+ d->m_config->sync();
+}
+
+// New adapters are automatically powered on
+void BlueDevilDaemon::restoreAdaptersState()
+{
+ Manager *manager = Manager::self();
+ if (!manager) {
+ return;
+ }
+
+ KConfigGroup adaptersGroup = d->m_config->group("Adapters");
+
+ Q_FOREACH (Adapter *adapter, manager->adapters()) {
+ const QString key = QString(QStringLiteral("%1_powered")).arg(adapter->address());
+ adapter->setPowered(adaptersGroup.readEntry<bool>(key, true));
}
}
+void BlueDevilDaemon::restoreAdapterState(Adapter *adapter)
+{
+ KConfigGroup adaptersGroup = d->m_config->group("Adapters");
+
+ const QString key = QString(QStringLiteral("%1_powered")).arg(adapter->address());
+ adapter->setPowered(adaptersGroup.readEntry<bool>(key, true));
+}
+
DeviceInfo BlueDevilDaemon::deviceToInfo(Device *const device) const
{
DeviceInfo info;
+
info[QStringLiteral("name")] = device->friendlyName();
info[QStringLiteral("icon")] = device->icon();
info[QStringLiteral("address")] = device->address();
- info[QStringLiteral("discovered")] = QStringLiteral("true");
- info[QStringLiteral("UUIDs")] = device->UUIDs().join(QStringLiteral(","));
+ info[QStringLiteral("UBI")] = device->UBI();
+ info[QStringLiteral("UUIDs")] = device->UUIDs().join(QLatin1Char(','));
return info;
}
diff --git a/src/daemon/kded/BlueDevilDaemon.h b/src/daemon/kded/BlueDevilDaemon.h
index a8688ae18871454e34a586f76aa10693180f5cbe..a4a396b576294593d0cf886369a833d059d91ab3 100644
--- a/src/daemon/kded/BlueDevilDaemon.h
+++ b/src/daemon/kded/BlueDevilDaemon.h
@@ -22,43 +22,59 @@
#ifndef BLUEDEVILDAEMON_H
#define BLUEDEVILDAEMON_H
-#include <kdedmodule.h>
+#include <KDEDModule>
#include <QLoggingCategory>
-typedef QMap <QString, QString> DeviceInfo;
+typedef QMap<QString, QString> DeviceInfo;
typedef QMap<QString, DeviceInfo > QMapDeviceInfo;
class QDBusPendingCallWatcher;
-namespace BlueDevil {
+
+namespace BlueDevil
+{
class Adapter;
class Device;
}
+
using namespace BlueDevil;
-class Q_DECL_EXPORT BlueDevilDaemon
- : public KDEDModule
+class Q_DECL_EXPORT BlueDevilDaemon : public KDEDModule
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.BlueDevil")
public:
/**
- * Stablish basics connections with libbluedevil signals and calls online if interfaces are availables
+ * Establish basics connections with libbluedevil signals and calls online if interfaces are availables
*/
BlueDevilDaemon(QObject *parent, const QList<QVariant>&);
- virtual ~BlueDevilDaemon();
+ ~BlueDevilDaemon();
public Q_SLOTS:
+ /**
+ * Returns whether the daemon is in online mode (eg. Bluez services are
+ * running and we have usable adapter)
+ */
Q_SCRIPTABLE bool isOnline();
/**
- * This slot will return a list of devices made of: configured and discovered devices.
- * Going deeper, the first time that this slot is called a discovery of X seconds will start
- * Then if this slot is consulted again it will return configured and discovered device. Once
- * the discovery ends it won't start a new discovery until N seconds pass.
+ * Returns QMap<Address, DeviceInfo> with all known devices
+ */
+ Q_SCRIPTABLE QMapDeviceInfo allDevices();
+
+ /**
+ * Returns DeviceInfo for one device.
*/
- Q_SCRIPTABLE QMapDeviceInfo knownDevices();
+ Q_SCRIPTABLE DeviceInfo device(const QString &address);
+ /**
+ * Starts discovery for timeout miliseconds (0 = forever)
+ */
+ Q_SCRIPTABLE void startDiscovering(quint32 timeout);
+
+ /**
+ * Stops discovery (if it was previously started)
+ */
Q_SCRIPTABLE void stopDiscovering();
private:
@@ -81,20 +97,29 @@ private Q_SLOTS:
*/
void usableAdapterChanged(Adapter *adapter);
+ void adapterAdded(Adapter *adapter);
+ void adapterRemoved(Adapter *adapter);
+
/**
* When the agent is released this is called to unload it
*/
void agentReleased();
- void deviceFound(Device*);
- void monolithicQuit(QDBusPendingCallWatcher* watcher);
+ void login1PrepareForSleep(bool active);
+
+ void deviceFound(Device *device);
+ void monolithicQuit(QDBusPendingCallWatcher *watcher);
void monolithicFinished(const QString &);
private:
void executeMonolithic();
void killMonolithic();
- DeviceInfo deviceToInfo (Device *const device) const;
+ void saveAdaptersState();
+ void restoreAdaptersState();
+ void restoreAdapterState(Adapter *adapter);
+
+ DeviceInfo deviceToInfo(Device *const device) const;
private:
struct Private;
diff --git a/src/daemon/kded/CMakeLists.txt b/src/daemon/kded/CMakeLists.txt
index 3a8ddb75db866034dcc2a0b80b93e460f164fba4..651e68dd47f4919061713d223c4395e2e8a0f231 100644
--- a/src/daemon/kded/CMakeLists.txt
+++ b/src/daemon/kded/CMakeLists.txt
@@ -26,7 +26,7 @@ kconfig_add_kcfg_files(kded_bluedevil_SRCS ../../settings/filereceiversettings.k
add_library(kded_bluedevil MODULE ${kded_bluedevil_SRCS})
-kservice_desktop_to_json(kded_bluedevil bluedevil.desktop)
+kcoreaddons_desktop_to_json(kded_bluedevil bluedevil.desktop)
target_link_libraries(kded_bluedevil
Qt5::Gui
diff --git a/src/daemon/kded/bluezagent.h b/src/daemon/kded/bluezagent.h
index aedfc90876e6bdee5d0335ad9b72c577d508f3cc..d5f4db7684fd032702a5268946c0840a395a2911 100644
--- a/src/daemon/kded/bluezagent.h
+++ b/src/daemon/kded/bluezagent.h
@@ -19,7 +19,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-
#ifndef BLUEZAGENT_H
#define BLUEZAGENT_H
@@ -28,7 +27,9 @@
#include <QDBusAbstractAdaptor>
class QProcess;
-namespace BlueDevil {
+
+namespace BlueDevil
+{
class Adapter;
}
@@ -41,8 +42,7 @@ namespace BlueDevil {
* @ref AgentListenerWorker
* @since 1.0
*/
-class BluezAgent
- : public QDBusAbstractAdaptor
+class BluezAgent : public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.bluez.Agent1")
@@ -51,7 +51,7 @@ public:
/**
* Register the path and initialize the m_adapter
*/
- BluezAgent(QObject *parent);
+ explicit BluezAgent(QObject *parent);
public Q_SLOTS:
/**
@@ -62,12 +62,12 @@ public Q_SLOTS:
/**
* Called by bluez to ask for a device authoritation
*/
- void AuthorizeService(const QDBusObjectPath &device, const QString& uuid, const QDBusMessage &msg);
+ void AuthorizeService(const QDBusObjectPath &device, const QString &uuid, const QDBusMessage &msg);
/**
* Called by bluez to ask for a PIN
*/
- QString RequestPinCode(const QDBusObjectPath& device, const QDBusMessage& msg);
+ QString RequestPinCode(const QDBusObjectPath &device, const QDBusMessage &msg);
/**
* Called by bluez to ask for a passkey, currently is a aslias of RequestPinCode
@@ -112,6 +112,7 @@ public Q_SLOTS:
* This slot gets called when the RequestPasskey helper ends
*/
void processClosedPasskey(int exitCode);
+
Q_SIGNALS:
/**
* Emited to propagate the release call (so BlueDevil can decide what to do)
@@ -131,7 +132,7 @@ private:
* @param helper Name of the helper
* @param msg The msg got from bluez
*/
- void sendBluezError(const QString& helper, const QDBusMessage &msg);
+ void sendBluezError(const QString &helper, const QDBusMessage &msg);
/**
* Returns the name of the device if it is registered on the bus
@@ -142,8 +143,9 @@ private:
QString deviceName(const QString &UBI);
private:
- QProcess *m_process;
- QDBusMessage m_msg;
- QString m_currentHelper;
+ QProcess *m_process;
+ QDBusMessage m_msg;
+ QString m_currentHelper;
};
-#endif
+
+#endif // BLUEZAGENT_H
diff --git a/src/daemon/kded/filereceiver/filereceiver.cpp b/src/daemon/kded/filereceiver/filereceiver.cpp
index 00405b1f254cb60aaeb5b3b7ecf292a2ef7044c4..91d20051b2e3100a73261af0f70c9a3a75e0739e 100644
--- a/src/daemon/kded/filereceiver/filereceiver.cpp
+++ b/src/daemon/kded/filereceiver/filereceiver.cpp
@@ -19,40 +19,46 @@
#include "filereceiver.h"
#include "../BlueDevilDaemon.h"
#include "obexagent.h"
-#include "obex_agent_manager.h"
#include <QDBusConnection>
#include <QDBusPendingCall>
#include <QDBusPendingCallWatcher>
+#include <QDBusServiceWatcher>
-FileReceiver::FileReceiver(QObject* parent)
+FileReceiver::FileReceiver(QObject *parent)
: QObject(parent)
{
- qCDebug(BLUEDAEMON);
qDBusRegisterMetaType<QVariantMap>();
new ObexAgent(this);
- org::bluez::obex::AgentManager1 *agent = new org::bluez::obex::AgentManager1(QStringLiteral("org.bluez.obex"),
- QStringLiteral("/org/bluez/obex"),
- QDBusConnection::sessionBus(),
- this);
+ m_agentManager = new org::bluez::obex::AgentManager1(QStringLiteral("org.bluez.obex"),
+ QStringLiteral("/org/bluez/obex"),
+ QDBusConnection::sessionBus(),
+ this);
- QDBusPendingReply <void > r = agent->RegisterAgent(QDBusObjectPath(QStringLiteral("/BlueDevil_receiveAgent")));
- QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(r, this);
- connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(agentRegistered(QDBusPendingCallWatcher*)));
+ registerAgent();
+
+ // obexd should be set to auto-start by D-Bus (D-Bus activation), so this should restart it in case of crash
+ QDBusServiceWatcher *serviceWatcher = new QDBusServiceWatcher(QStringLiteral("org.bluez.obex"), QDBusConnection::sessionBus(),
+ QDBusServiceWatcher::WatchForUnregistration, this);
+ connect(serviceWatcher, &QDBusServiceWatcher::serviceUnregistered, this, &FileReceiver::registerAgent);
}
-FileReceiver::~FileReceiver()
+void FileReceiver::registerAgent()
{
-
+ QDBusPendingReply<void> r = m_agentManager->RegisterAgent(QDBusObjectPath(QStringLiteral("/BlueDevil_receiveAgent")));
+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(r, this);
+ connect(watcher, &QDBusPendingCallWatcher::finished, this, &FileReceiver::agentRegistered);
}
-void FileReceiver::agentRegistered(QDBusPendingCallWatcher* call)
+void FileReceiver::agentRegistered(QDBusPendingCallWatcher *call)
{
- QDBusPendingReply <void > r = *call;
- qCDebug(BLUEDAEMON) << "Error: " << r.isError();
+ QDBusPendingReply<void> r = *call;
+
if (r.isError()) {
- qCDebug(BLUEDAEMON) << r.error().message();
+ qCWarning(BLUEDAEMON) << "Error registering agent" << r.error().message();
+ } else {
+ qCDebug(BLUEDAEMON) << "Agent registered";
}
call->deleteLater();
diff --git a/src/daemon/kded/filereceiver/filereceiver.h b/src/daemon/kded/filereceiver/filereceiver.h
index e6dc6fb075923a33a90b69773f5eeaf46d48ad64..7011f4a4d00e13ca44684498d9bf1539e1b133a0 100644
--- a/src/daemon/kded/filereceiver/filereceiver.h
+++ b/src/daemon/kded/filereceiver/filereceiver.h
@@ -21,16 +21,23 @@
#include <QObject>
+#include "obex_agent_manager.h"
+
class QDBusPendingCallWatcher;
+
class FileReceiver : public QObject
{
Q_OBJECT
- public:
- explicit FileReceiver(QObject* parent = 0);
- virtual ~FileReceiver();
- private Q_SLOTS:
- void agentRegistered(QDBusPendingCallWatcher* call);
+public:
+ explicit FileReceiver(QObject *parent = 0);
+
+private Q_SLOTS:
+ void registerAgent();
+ void agentRegistered(QDBusPendingCallWatcher *call);
+
+private:
+ org::bluez::obex::AgentManager1 *m_agentManager;
};
-#endif //FILE_RECEIVER_H
+#endif // FILE_RECEIVER_H
diff --git a/src/daemon/kded/filereceiver/obexagent.cpp b/src/daemon/kded/filereceiver/obexagent.cpp
index 7fc7bca4c201905c3f2ba23b85085a6cc6984b86..5af1400671b5a9f0dd20ac44f3751ef7f5e80cc9 100644
--- a/src/daemon/kded/filereceiver/obexagent.cpp
+++ b/src/daemon/kded/filereceiver/obexagent.cpp
@@ -24,24 +24,17 @@
#include <QDebug>
#include <QDBusConnection>
-ObexAgent::ObexAgent(QObject* parent)
+ObexAgent::ObexAgent(QObject *parent)
: QDBusAbstractAdaptor(parent)
{
- qCDebug(BLUEDAEMON);
if (!QDBusConnection::sessionBus().registerObject(QStringLiteral("/BlueDevil_receiveAgent"), parent)) {
- qDebug() << "The dbus object can't be registered";
- return;
+ qCWarning(BLUEDAEMON) << "The DBus object can't be registered";
}
}
-ObexAgent::~ObexAgent()
-{
-
-}
-
QString ObexAgent::AuthorizePush(const QDBusObjectPath& path, const QDBusMessage &msg)
{
- qCDebug(BLUEDAEMON);
+ qCDebug(BLUEDAEMON) << "AuthorizePush" << path.path();
msg.setDelayedReply(true);
@@ -53,11 +46,10 @@ QString ObexAgent::AuthorizePush(const QDBusObjectPath& path, const QDBusMessage
void ObexAgent::Cancel()
{
- qCDebug(BLUEDAEMON);
+ qCDebug(BLUEDAEMON) << "Cancel";
}
-
void ObexAgent::Release()
{
- qCDebug(BLUEDAEMON);
+ qCDebug(BLUEDAEMON) << "Release";
}
diff --git a/src/daemon/kded/filereceiver/obexagent.h b/src/daemon/kded/filereceiver/obexagent.h
index 72c322028886039580d11d90569b6bd9812f8646..2300fe3176fad594899be25eca5040d3f5b939d5 100644
--- a/src/daemon/kded/filereceiver/obexagent.h
+++ b/src/daemon/kded/filereceiver/obexagent.h
@@ -24,20 +24,19 @@
#include <QDBusObjectPath>
class QDBusMessage;
+
class ObexAgent : public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.bluez.obex.Agent1")
- public:
- explicit ObexAgent(QObject* parent);
- virtual ~ObexAgent();
-
- public Q_SLOTS:
- QString AuthorizePush(const QDBusObjectPath &path, const QDBusMessage &msg);
+public:
+ explicit ObexAgent(QObject *parent);
- void Release();
- void Cancel();
+public Q_SLOTS:
+ QString AuthorizePush(const QDBusObjectPath &path, const QDBusMessage &msg);
+ void Release();
+ void Cancel();
};
-#endif //OBEX_AGENT_H
+#endif // OBEX_AGENT_H
diff --git a/src/daemon/kded/filereceiver/receivefilejob.cpp b/src/daemon/kded/filereceiver/receivefilejob.cpp
index 5b9a8f4918ddea5e2be3c65d10195aaa04d301b5..f6342fd6bac721afd1b72df97fd085c1d5be7ff4 100644
--- a/src/daemon/kded/filereceiver/receivefilejob.cpp
+++ b/src/daemon/kded/filereceiver/receivefilejob.cpp
@@ -42,7 +42,7 @@
using namespace BlueDevil;
-ReceiveFileJob::ReceiveFileJob(const QDBusMessage& msg, const QString &path, QObject* parent)
+ReceiveFileJob::ReceiveFileJob(const QDBusMessage &msg, const QString &path, QObject *parent)
: KJob(parent)
, m_speedBytes(0)
, m_path(path)
@@ -51,11 +51,6 @@ ReceiveFileJob::ReceiveFileJob(const QDBusMessage& msg, const QString &path, QOb
setCapabilities(Killable);
}
-ReceiveFileJob::~ReceiveFileJob()
-{
-
-}
-
void ReceiveFileJob::start()
{
QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection);
@@ -63,7 +58,6 @@ void ReceiveFileJob::start()
bool ReceiveFileJob::doKill()
{
- qCDebug(BLUEDAEMON);
m_transfer->Cancel();
return true;
}
@@ -85,28 +79,40 @@ void ReceiveFileJob::init()
m_path,
QDBusConnection::sessionBus(),
this);
- connect(m_transferProps,
- SIGNAL(PropertiesChanged(QString,QVariantMap,QStringList)),
- SLOT(transferPropertiesChanged(QString,QVariantMap,QStringList)));
+ connect(m_transferProps, &org::freedesktop::DBus::Properties::PropertiesChanged,
+ this, &ReceiveFileJob::transferPropertiesChanged);
m_session = new org::bluez::obex::Session1(QStringLiteral("org.bluez.obex"),
m_transfer->session().path(),
QDBusConnection::sessionBus(),
this);
+
qCDebug(BLUEDAEMON) << m_session->destination();
- Device* device = Manager::self()->usableAdapter()->deviceForAddress(m_session->destination());
+ Device *device = 0;
+ bool isDeviceTrusted = false;
+
+ Q_FOREACH (Adapter *adapter, Manager::self()->adapters()) {
+ if (adapter->address() == m_session->source()) {
+ device = adapter->deviceForAddress(m_session->destination());
+ break;
+ }
+ }
+
qCDebug(BLUEDAEMON) << device;
m_deviceName = m_session->destination();
+
if (device) {
qCDebug(BLUEDAEMON) << device->name();
m_deviceName = device->name();
+ isDeviceTrusted = device->isTrusted();
}
FileReceiverSettings::self()->load();
qCDebug(BLUEDAEMON) << "Auto Accept: " << FileReceiverSettings::self()->autoAccept();
- if (FileReceiverSettings::self()->autoAccept() == 1 && device->isTrusted()) {
+
+ if (FileReceiverSettings::self()->autoAccept() == 1 && isDeviceTrusted) {
slotAccept();
return;
} else if (FileReceiverSettings::self()->autoAccept() == 2) {
@@ -133,9 +139,9 @@ void ReceiveFileJob::showNotification()
m_notification->setActions(actions);
- connect(m_notification, SIGNAL(action1Activated()), SLOT(slotAccept()));
- connect(m_notification, SIGNAL(action2Activated()), SLOT(slotCancel()));
- connect(m_notification, SIGNAL(closed()), SLOT(slotCancel()));
+ connect(m_notification, &KNotification::action1Activated, this, &ReceiveFileJob::slotAccept);
+ connect(m_notification, &KNotification::action2Activated, this, &ReceiveFileJob::slotCancel);
+ connect(m_notification, &KNotification::closed, this, &ReceiveFileJob::slotCancel);
int size = IconSize(KIconLoader::Desktop);
m_notification->setPixmap(QIcon::fromTheme(QStringLiteral("preferences-system-bluetooth")).pixmap(size, size));
@@ -145,12 +151,13 @@ void ReceiveFileJob::showNotification()
void ReceiveFileJob::slotAccept()
{
- qCDebug(BLUEDAEMON);
KIO::getJobTracker()->registerJob(this);
m_originalFileName = m_transfer->name();
m_tempPath = createTempPath(m_transfer->name());
+
qCDebug(BLUEDAEMON) << m_tempPath;
+
QDBusMessage msg = m_msg.createReply(m_tempPath);
QDBusConnection::sessionBus().send(msg);
}
@@ -166,13 +173,12 @@ void ReceiveFileJob::slotSaveAs()
void ReceiveFileJob::slotCancel()
{
- qCDebug(BLUEDAEMON);
QDBusMessage msg = m_msg.createErrorReply(QStringLiteral("org.bluez.obex.Error.Rejected"),
QStringLiteral("org.bluez.obex.Error.Rejected"));
QDBusConnection::sessionBus().send(msg);
}
-void ReceiveFileJob::transferPropertiesChanged(const QString& interface, const QVariantMap& properties, const QStringList& invalidatedProperties)
+void ReceiveFileJob::transferPropertiesChanged(const QString &interface, const QVariantMap &properties, const QStringList &invalidatedProperties)
{
qCDebug(BLUEDAEMON) << interface;
qCDebug(BLUEDAEMON) << properties;
@@ -188,9 +194,10 @@ void ReceiveFileJob::transferPropertiesChanged(const QString& interface, const Q
}
}
-void ReceiveFileJob::statusChanged(const QVariant& value)
+void ReceiveFileJob::statusChanged(const QVariant &value)
{
qCDebug(BLUEDAEMON) << value;
+
QString status = value.toString();
FileReceiverSettings::self()->load();
@@ -210,7 +217,7 @@ void ReceiveFileJob::statusChanged(const QVariant& value)
} else if (status == QLatin1String("complete")) {
KIO::CopyJob* job = KIO::move(QUrl::fromLocalFile(m_tempPath), savePath, KIO::HideProgressInfo);
job->setUiDelegate(0);
- connect(job, SIGNAL(finished(KJob*)), SLOT(moveFinished(KJob*)));
+ connect(job, &KIO::CopyJob::finished, this, &ReceiveFileJob::moveFinished);
return;
} else if (status == QLatin1String("error")) {
setError(KJob::UserDefinedError);
@@ -224,6 +231,7 @@ void ReceiveFileJob::statusChanged(const QVariant& value)
void ReceiveFileJob::transferChanged(const QVariant& value)
{
qCDebug(BLUEDAEMON) << value;
+
bool ok = false;
qulonglong bytes = value.toULongLong(&ok);
if (!ok) {
@@ -231,7 +239,7 @@ void ReceiveFileJob::transferChanged(const QVariant& value)
return;
}
- //If a least 1 second has passed since last update
+ // If a least 1 second has passed since last update
int secondsSinceLastTime = m_time.secsTo(QTime::currentTime());
if (secondsSinceLastTime > 0) {
float speed = (bytes - m_speedBytes) / secondsSinceLastTime;
@@ -260,13 +268,13 @@ QString ReceiveFileJob::createTempPath(const QString &fileName) const
{
QString xdgCacheHome = QFile::decodeName(qgetenv("XDG_CACHE_HOME"));
if (xdgCacheHome.isEmpty()) {
- xdgCacheHome = QDir::homePath() + QLatin1String("/.cache");
+ xdgCacheHome = QDir::homePath() + QLatin1String("/.cache");
}
xdgCacheHome.append(QLatin1String("/obexd/"));
- QString path = xdgCacheHome + fileName;
- int i = 0;
+ QString path = xdgCacheHome + fileName;
+ int i = 0;
while (QFile::exists(path)) {
path = xdgCacheHome + fileName + QString::number(i);
i++;
diff --git a/src/daemon/kded/filereceiver/receivefilejob.h b/src/daemon/kded/filereceiver/receivefilejob.h
index 13c69134a569b4a62ae1f82da34b7f5dbd8307d6..68a88feab782bcb9d93c9deb01fa32af51e0b722 100644
--- a/src/daemon/kded/filereceiver/receivefilejob.h
+++ b/src/daemon/kded/filereceiver/receivefilejob.h
@@ -16,7 +16,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
-
#ifndef RECEIVE_FILE_JOB_H
#define RECEIVE_FILE_JOB_H
@@ -28,42 +27,44 @@
class OrgBluezObexSession1Interface;
class OrgBluezObexTransfer1Interface;
class OrgFreedesktopDBusPropertiesInterface;
+
class ReceiveFileJob : public KJob
{
Q_OBJECT
- public:
- explicit ReceiveFileJob(const QDBusMessage &msg, const QString &path, QObject* parent = 0);
- virtual ~ReceiveFileJob();
- virtual void start();
- protected:
- virtual bool doKill();
+public:
+ explicit ReceiveFileJob(const QDBusMessage &msg, const QString &path, QObject *parent = 0);
+
+ void start() Q_DECL_OVERRIDE;
+
+protected:
+ bool doKill() Q_DECL_OVERRIDE;
- private Q_SLOTS:
- void init();
- void showNotification();
- void slotCancel();
- void slotAccept();
- void slotSaveAs();
- void transferPropertiesChanged(const QString &interface, const QVariantMap &properties, const QStringList &invalidatedProperties);
- void moveFinished(KJob* job);
+private Q_SLOTS:
+ void init();
+ void showNotification();
+ void slotCancel();
+ void slotAccept();
+ void slotSaveAs();
+ void transferPropertiesChanged(const QString &interface, const QVariantMap &properties, const QStringList &invalidatedProperties);
+ void moveFinished(KJob *job);
- private:
- void transferChanged(const QVariant &value);
- void statusChanged(const QVariant &value);
- QString createTempPath(const QString &fileName) const;
+private:
+ void transferChanged(const QVariant &value);
+ void statusChanged(const QVariant &value);
+ QString createTempPath(const QString &fileName) const;
- QTime m_time;
- qulonglong m_speedBytes;
- QString m_path;
- QString m_tempPath;
- QString m_originalFileName;
- QString m_deviceName;
- QDBusMessage m_msg;
- OrgBluezObexSession1Interface *m_session;
- OrgBluezObexTransfer1Interface *m_transfer;
- OrgFreedesktopDBusPropertiesInterface *m_transferProps;
+ QTime m_time;
+ qulonglong m_speedBytes;
+ QString m_path;
+ QString m_tempPath;
+ QString m_originalFileName;
+ QString m_deviceName;
+ QDBusMessage m_msg;
+ OrgBluezObexSession1Interface *m_session;
+ OrgBluezObexTransfer1Interface *m_transfer;
+ OrgFreedesktopDBusPropertiesInterface *m_transferProps;
};
-#endif //RECEIVE_FILE_JOB_H
+#endif // RECEIVE_FILE_JOB_H
diff --git a/src/fileitemactionplugin/CMakeLists.txt b/src/fileitemactionplugin/CMakeLists.txt
index 3737c683922efc0d21222281a55e56bc9a70748f..39d6e33e58b8d7309a145a61fe2a3911d77433d3 100644
--- a/src/fileitemactionplugin/CMakeLists.txt
+++ b/src/fileitemactionplugin/CMakeLists.txt
@@ -1,9 +1,17 @@
-add_library(bluetoothfileitemaction MODULE sendfileitemaction.cpp)
-kservice_desktop_to_json(bluetoothfileitemaction bluedevilsendfile.desktop)
+set(fileitemactionplugin_SRCS
+ sendfileitemaction.cpp)
+
+set(kded_bluedevil.xml ${CMAKE_CURRENT_SOURCE_DIR}/kded_bluedevil.xml)
+set_source_files_properties(${kded_bluedevil.xml} PROPERTIES INCLUDE "types.h")
+qt5_add_dbus_interface(fileitemactionplugin_SRCS ${kded_bluedevil.xml} kded_bluedevil)
+
+add_library(bluetoothfileitemaction MODULE ${fileitemactionplugin_SRCS})
+kcoreaddons_desktop_to_json(bluetoothfileitemaction bluedevilsendfile.desktop)
target_link_libraries(bluetoothfileitemaction
Qt5::Widgets
KF5::I18n
KF5::KIOFileWidgets
${LibBlueDevil_LIBRARIES})
+
install(TARGETS bluetoothfileitemaction DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES bluedevilsendfile.desktop DESTINATION ${SERVICES_INSTALL_DIR})
diff --git a/src/fileitemactionplugin/kded_bluedevil.xml b/src/fileitemactionplugin/kded_bluedevil.xml
new file mode 100644
index 0000000000000000000000000000000000000000..e4478975fd84d080888138513dd73c985117a894
--- /dev/null
+++ b/src/fileitemactionplugin/kded_bluedevil.xml
@@ -0,0 +1,23 @@
+<!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.BlueDevil">
+ <method name="isOnline">
+ <arg type="b" direction="out"/>
+ </method>
+ <method name="allDevices">
+ <arg type="aa{ss}" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QMapDeviceInfo"/>
+ </method>
+ <method name="device">
+ <arg name="address" type="s" direction="in"/>
+ <arg type="a{ss}" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="DeviceInfo"/>
+ </method>
+ <method name="startDiscovering">
+ <arg name="timeout" type="u" direction="in"/>
+ </method>
+ <method name="stopDiscovering">
+ </method>
+ </interface>
+</node>
diff --git a/src/fileitemactionplugin/sendfileitemaction.cpp b/src/fileitemactionplugin/sendfileitemaction.cpp
index c750bc4f3319ee93151b3c9b88b040993330285e..ba9d1fde43ed7c1fce90f9a30d377b968fffadef 100644
--- a/src/fileitemactionplugin/sendfileitemaction.cpp
+++ b/src/fileitemactionplugin/sendfileitemaction.cpp
@@ -33,57 +33,56 @@
#include <KProcess>
#include <KLocalizedString>
-#include <bluedevil/bluedevil.h>
-
-using namespace BlueDevil;
-
K_PLUGIN_FACTORY_WITH_JSON(SendFileItemActionFactory,
"bluedevilsendfile.json",
registerPlugin<SendFileItemAction>();)
-SendFileItemAction::SendFileItemAction(QObject* parent, const QVariantList& args)
+SendFileItemAction::SendFileItemAction(QObject *parent, const QVariantList &args)
: KAbstractFileItemActionPlugin(parent)
{
Q_UNUSED(args)
+
+ qDBusRegisterMetaType<DeviceInfo>();
+ qDBusRegisterMetaType<QMapDeviceInfo>();
+
+ m_kded = new org::kde::BlueDevil(QStringLiteral("org.kde.kded5"), QStringLiteral("/modules/bluedevil"),
+ QDBusConnection::sessionBus(), this);
}
-QList< QAction* > SendFileItemAction::actions(const KFileItemListProperties& fileItemInfos, QWidget* parentWidget)
+QList<QAction*> SendFileItemAction::actions(const KFileItemListProperties &infos, QWidget *parent)
{
- Q_UNUSED(parentWidget)
- QList< QAction* > list;
+ Q_UNUSED(parent)
- m_fileItemInfos = fileItemInfos;
+ QList<QAction*> list;
- //If there is no adaptor, there is no bluetooth
- if (!Manager::self()->usableAdapter()) {
+ // Don't show the action for files that we can't send or when Bluetooth is offline.
+ if (!infos.isLocal() || !m_kded->isOnline()) {
return list;
}
- Adapter *adapter = Manager::self()->usableAdapter();
+
+ m_infos = infos;
QAction *menuAction = new QAction(QIcon::fromTheme(QStringLiteral("preferences-system-bluetooth")), i18n("Send via Bluetooth"), this);
QMenu *menu = new QMenu();
- //If we have configured devices, put them first
- QList< Device * > devices = adapter->devices();
- if (!devices.isEmpty()) {
- Q_FOREACH(Device *device, devices) {
- if (device->UUIDs().contains(QLatin1String("00001105-0000-1000-8000-00805F9B34FB"), Qt::CaseInsensitive)) {
- QAction *action = new QAction(QIcon::fromTheme(device->icon()), device->name(), this);
- connect(action, SIGNAL(triggered(bool)), this, SLOT(deviceTriggered()));
- action->setData(device->UBI());
- menu->addAction(action);
- }
+ const QMapDeviceInfo &devices = m_kded->allDevices().value();
+ Q_FOREACH (const DeviceInfo &device, devices) {
+ if (device.value(QStringLiteral("UUIDs")).contains(QLatin1String("00001105-0000-1000-8000-00805F9B34FB"))) {
+ QAction *action = new QAction(QIcon::fromTheme(device[QStringLiteral("icon")]), device.value(QStringLiteral("name")), this);
+ connect(action, &QAction::triggered, this, &SendFileItemAction::deviceTriggered);
+ action->setData(device.value(QStringLiteral("UBI")));
+ menu->addAction(action);
}
}
QAction *otherAction = new QAction(this);
- connect(otherAction, SIGNAL(triggered(bool)), this, SLOT(otherTriggered()));
if (menu->actions().isEmpty()) {
otherAction->setText(i18nc("Find Bluetooth device", "Find Device..."));
} else {
menu->addSeparator();
otherAction->setText(i18nc("Other Bluetooth device", "Other..."));
}
+ connect(otherAction, &QAction::triggered, this, &SendFileItemAction::otherTriggered);
menu->addAction(otherAction);
menuAction->setMenu(menu);
@@ -94,13 +93,13 @@ QList< QAction* > SendFileItemAction::actions(const KFileItemListProperties& fil
void SendFileItemAction::deviceTriggered()
{
QStringList args;
- args.append(QLatin1String("-u") % static_cast<QAction *>(sender())->data().toString());
+ args.append(QStringLiteral("-u") % static_cast<QAction*>(sender())->data().toString());
- const QList<QUrl> &fileList = m_fileItemInfos.urlList();
- Q_FOREACH(const QUrl &url, fileList) {
- args.append(QLatin1String("-f") % url.path());
+ const QList<QUrl> &fileList = m_infos.urlList();
+ Q_FOREACH (const QUrl &url, fileList) {
+ args.append(QStringLiteral("-f") % url.path());
}
- qDebug() << args;
+
KProcess process;
process.setProgram(QStringLiteral("bluedevil-sendfile"), args);
process.startDetached();
@@ -108,12 +107,11 @@ void SendFileItemAction::deviceTriggered()
void SendFileItemAction::otherTriggered()
{
- qDebug();
QStringList args;
- const QList<QUrl> &fileList = m_fileItemInfos.urlList();
- Q_FOREACH(const QUrl &url, fileList) {
- args.append(QLatin1String("-f") % url.path());
+ const QList<QUrl> &fileList = m_infos.urlList();
+ Q_FOREACH (const QUrl &url, fileList) {
+ args.append(QStringLiteral("-f") % url.path());
}
KProcess process;
diff --git a/src/fileitemactionplugin/sendfileitemaction.h b/src/fileitemactionplugin/sendfileitemaction.h
index f9eecc3a524c418330b706b666324eb76b731b6b..a1948319f4501710a6cbd1eb57b1202da726ac88 100644
--- a/src/fileitemactionplugin/sendfileitemaction.h
+++ b/src/fileitemactionplugin/sendfileitemaction.h
@@ -24,22 +24,26 @@
#include <KAbstractFileItemActionPlugin>
#include <KFileItemListProperties>
+#include "kded_bluedevil.h"
+
class QAction;
class QWidget;
class SendFileItemAction : public KAbstractFileItemActionPlugin
{
-Q_OBJECT
+ Q_OBJECT
+
public:
- SendFileItemAction(QObject* parent, const QVariantList &args);
- virtual QList< QAction* > actions(const KFileItemListProperties& fileItemInfos, QWidget* parentWidget);
+ SendFileItemAction(QObject *parent, const QVariantList &args);
+ QList<QAction*> actions(const KFileItemListProperties &infos, QWidget *parent) Q_DECL_OVERRIDE;
private Q_SLOTS:
void deviceTriggered();
void otherTriggered();
private:
- KFileItemListProperties m_fileItemInfos;
+ org::kde::BlueDevil *m_kded;
+ KFileItemListProperties m_infos;
};
#endif // SENDFILEITEMACTION_H
diff --git a/src/fileitemactionplugin/types.h b/src/fileitemactionplugin/types.h
new file mode 100644
index 0000000000000000000000000000000000000000..53f2e4a9db60946e70ca50b630f77fa90942ffec
--- /dev/null
+++ b/src/fileitemactionplugin/types.h
@@ -0,0 +1,11 @@
+#ifndef FILEITEMACTIONPLUGINTYPES
+#define FILEITEMACTIONPLUGINTYPES
+
+#include <QMetaType>
+
+typedef QMap<QString, QString> DeviceInfo;
+typedef QMap<QString, DeviceInfo> QMapDeviceInfo;
+Q_DECLARE_METATYPE(DeviceInfo)
+Q_DECLARE_METATYPE(QMapDeviceInfo)
+
+#endif
diff --git a/src/kcmodule/CMakeLists.txt b/src/kcmodule/CMakeLists.txt
index 64e6050abd87c098659c13cf25d12933ed111616..4145c1bc814c84e4a84220d7b2da7243491d16ac 100644
--- a/src/kcmodule/CMakeLists.txt
+++ b/src/kcmodule/CMakeLists.txt
@@ -24,9 +24,9 @@ add_library(kcm_bluedevildevices MODULE ${kcm_bluedevildevices_PART_SRCS})
add_library(kcm_bluedeviladapters MODULE ${kcm_bluedeviladapters_PART_SRCS})
add_library(kcm_bluedeviltransfer MODULE ${kcm_bluedeviltransfer_PART_SRCS} ${kcm_bluedeviltransfer_PART_SRCS_UI})
-kservice_desktop_to_json(kcm_bluedevildevices bluedevildevices.desktop)
-kservice_desktop_to_json(kcm_bluedeviladapters bluedeviladapters.desktop)
-kservice_desktop_to_json(kcm_bluedeviltransfer bluedeviltransfer.desktop)
+kcoreaddons_desktop_to_json(kcm_bluedevildevices bluedevildevices.desktop)
+kcoreaddons_desktop_to_json(kcm_bluedeviladapters bluedeviladapters.desktop)
+kcoreaddons_desktop_to_json(kcm_bluedeviltransfer bluedeviltransfer.desktop)
target_link_libraries(kcm_bluedevildevices
Qt5::Widgets
diff --git a/src/kcmodule/bluedeviladapters.cpp b/src/kcmodule/bluedeviladapters.cpp
index 9185552f02bb3406b8448cd0e64eb818a6fbe117..13504c9a12a33c6deefd9f51ce6f54d9cb90c02a 100644
--- a/src/kcmodule/bluedeviladapters.cpp
+++ b/src/kcmodule/bluedeviladapters.cpp
@@ -62,8 +62,8 @@ AdapterSettings::AdapterSettings(Adapter *adapter, KCModule *parent)
buttonGroup->addButton(m_alwaysVisible);
buttonGroup->addButton(m_temporaryVisible);
- m_name->setText(adapter->alias());
- m_nameOrig = adapter->alias();
+ m_name->setText(adapter->name());
+ m_nameOrig = adapter->name();
m_hiddenOrig = false;
m_alwaysVisibleOrig = false;
m_temporaryVisibleOrig = false;
@@ -119,9 +119,9 @@ AdapterSettings::AdapterSettings(Adapter *adapter, KCModule *parent)
connect(m_powered, SIGNAL(stateChanged(int)), this, SLOT(slotSettingsChanged()));
if (BlueDevil::Manager::self()->usableAdapter() == adapter) {
- setTitle(i18n("Default adapter: %1 (%2)", adapter->alias(), adapter->address()));
+ setTitle(i18n("Default adapter: %1 (%2)", adapter->name(), adapter->address()));
} else {
- setTitle(i18n("Adapter: %1 (%2)", adapter->alias(), adapter->address()));
+ setTitle(i18n("Adapter: %1 (%2)", adapter->name(), adapter->address()));
}
}
@@ -188,7 +188,7 @@ void AdapterSettings::readChanges()
{
blockSignals(true);
- m_nameOrig = m_adapter->alias();
+ m_nameOrig = m_adapter->name();
m_hiddenOrig = !m_adapter->isDiscoverable();
m_alwaysVisibleOrig = m_adapter->isDiscoverable() && !m_adapter->discoverableTimeout();
m_temporaryVisibleOrig = m_adapter->isDiscoverable() && m_adapter->discoverableTimeout();
@@ -204,9 +204,9 @@ void AdapterSettings::readChanges()
m_discoverTimeLabel->setText(i18np("1 minute", "%1 minutes", m_discoverTime->value()));
if (BlueDevil::Manager::self()->usableAdapter() == m_adapter) {
- setTitle(i18n("Default adapter: %1 (%2)", m_adapter->alias(), m_adapter->address()));
+ setTitle(i18n("Default adapter: %1 (%2)", m_adapter->name(), m_adapter->address()));
} else {
- setTitle(i18n("Adapter: %1 (%2)", m_adapter->alias(), m_adapter->address()));
+ setTitle(i18n("Adapter: %1 (%2)", m_adapter->name(), m_adapter->address()));
}
blockSignals(false);
@@ -320,7 +320,7 @@ void KCMBlueDevilAdapters::generateNoAdaptersMessage()
QGridLayout *layout = new QGridLayout;
m_noAdaptersMessage = new QWidget(this);
QLabel *label = new QLabel(m_noAdaptersMessage);
- label->setPixmap(QIcon::fromTheme(QStringLiteral("dialog-information")).pixmap(128, 128));
+ label->setPixmap(QIcon::fromTheme(QStringLiteral("dialog-information")).pixmap(128));
layout->addWidget(label, 0, 1, Qt::AlignHCenter);
layout->addWidget(new QLabel(i18n("No adapters found. Please connect one."), m_noAdaptersMessage),
1, 1, Qt::AlignHCenter);
diff --git a/src/kcmodule/bluedeviladapters.desktop b/src/kcmodule/bluedeviladapters.desktop
index 1c08977f52ffaeb5349e13c85d01d9221d67d95f..b4befcc61e2379a392701cccb822c5c874c8228e 100644
--- a/src/kcmodule/bluedeviladapters.desktop
+++ b/src/kcmodule/bluedeviladapters.desktop
@@ -80,6 +80,7 @@ X-KDE-Keywords[fr]=Réseau, connectivité, Bluetooth
X-KDE-Keywords[it]=Rete,Connettività,Bluetooth
X-KDE-Keywords[nb]=Nettverk,sammenkobling,blåtann
X-KDE-Keywords[nl]=Netwerkverbinding,connectiviteit,bluetooth
+X-KDE-Keywords[pa]=ਨੈਟਵਰਕ,ਕਨੈਕਟਵਿਟੀ,ਬਲਿਊਟੁੱਥ
X-KDE-Keywords[pl]=Sieć,Łączność,Bluetooth
X-KDE-Keywords[pt]=Rede,Conectividade,Bluetooth
X-KDE-Keywords[pt_BR]=Rede,Conectividade,Bluetooth
diff --git a/src/kcmodule/bluedeviladapters.h b/src/kcmodule/bluedeviladapters.h
index 5a775bd2667ee2d2f97bb15d47953884ff57fa3f..7ecbeb84c5188f4321d4105a3568e7e7f36711de 100644
--- a/src/kcmodule/bluedeviladapters.h
+++ b/src/kcmodule/bluedeviladapters.h
@@ -36,7 +36,8 @@ class QLineEdit;
class SystemCheck;
class AdapterSettings;
-namespace BlueDevil {
+namespace BlueDevil
+{
class Adapter;
}
diff --git a/src/kcmodule/bluedevildevices.cpp b/src/kcmodule/bluedevildevices.cpp
index 1135d6f35e36165743428331ef5af9003bcbd78a..9474e93f096a9a5d55071262e2d06ecd9565f5f9 100644
--- a/src/kcmodule/bluedevildevices.cpp
+++ b/src/kcmodule/bluedevildevices.cpp
@@ -226,11 +226,11 @@ BluetoothDevicesDelegate::BluetoothDevicesDelegate(QObject *parent)
: QStyledItemDelegate(parent)
, smallIconSize(IconSize(KIconLoader::Toolbar))
{
- m_blockedPixmap = QIcon::fromTheme(QStringLiteral("dialog-cancel")).pixmap(smallIconSize, smallIconSize);
- m_trustedPixmap = QIcon::fromTheme(QStringLiteral("security-high")).pixmap(smallIconSize, smallIconSize);
- m_untrustedPixmap = QIcon::fromTheme(QStringLiteral("security-low")).pixmap(smallIconSize, smallIconSize);
- m_connectedPixmap = QIcon::fromTheme(QStringLiteral("user-online")).pixmap(smallIconSize, smallIconSize);
- m_disconnectedPixmap = QIcon::fromTheme(QStringLiteral("user-offline")).pixmap(smallIconSize, smallIconSize);
+ m_blockedPixmap = QIcon::fromTheme(QStringLiteral("dialog-cancel")).pixmap(smallIconSize);
+ m_trustedPixmap = QIcon::fromTheme(QStringLiteral("security-high")).pixmap(smallIconSize);
+ m_untrustedPixmap = QIcon::fromTheme(QStringLiteral("security-low")).pixmap(smallIconSize);
+ m_connectedPixmap = QIcon::fromTheme(QStringLiteral("user-online")).pixmap(smallIconSize);
+ m_disconnectedPixmap = QIcon::fromTheme(QStringLiteral("user-offline")).pixmap(smallIconSize);
}
BluetoothDevicesDelegate::~BluetoothDevicesDelegate()
@@ -518,7 +518,11 @@ void KCMBlueDevilDevices::usableAdapterChanged(Adapter *adapter)
if (adapter) {
connect(adapter, SIGNAL(discoverableChanged(bool)),
this, SLOT(adapterDiscoverableChanged()));
- connect(adapter, SIGNAL(devicesChanged(QList<Device*>)),
+ connect(adapter, SIGNAL(deviceChanged(Device*)),
+ this, SLOT(adapterDevicesChanged()));
+ connect(adapter, SIGNAL(deviceRemoved(Device*)),
+ this, SLOT(adapterDevicesChanged()));
+ connect(adapter, SIGNAL(deviceFound(Device*)),
this, SLOT(adapterDevicesChanged()));
}
fillRemoteDevicesModelInformation();
@@ -547,7 +551,7 @@ void KCMBlueDevilDevices::generateNoDevicesMessage()
m_noDevicesMessage->setBackgroundRole(QPalette::Base);
m_noDevicesMessage->setAutoFillBackground(true);
QLabel *label = new QLabel(m_noDevicesMessage);
- label->setPixmap(QIcon::fromTheme(QStringLiteral("dialog-information")).pixmap(128, 128));
+ label->setPixmap(QIcon::fromTheme(QStringLiteral("dialog-information")).pixmap(128));
layout->addWidget(label, 0, 1, Qt::AlignHCenter);
layout->addWidget(new QLabel(i18n("No remote devices have been added"), m_noDevicesMessage),
1, 1, Qt::AlignHCenter);
diff --git a/src/kcmodule/bluedevildevices.desktop b/src/kcmodule/bluedevildevices.desktop
index ba05bfc4789feb36ca9dd2ef0de7376ec2495e30..7e7235a4e1645673425b6c17030310d87a4471f2 100644
--- a/src/kcmodule/bluedevildevices.desktop
+++ b/src/kcmodule/bluedevildevices.desktop
@@ -81,6 +81,7 @@ X-KDE-Keywords[fr]=Réseau, connectivité, Bluetooth
X-KDE-Keywords[it]=Rete,Connettività,Bluetooth
X-KDE-Keywords[nb]=Nettverk,sammenkobling,blåtann
X-KDE-Keywords[nl]=Netwerkverbinding,connectiviteit,bluetooth
+X-KDE-Keywords[pa]=ਨੈਟਵਰਕ,ਕਨੈਕਟਵਿਟੀ,ਬਲਿਊਟੁੱਥ
X-KDE-Keywords[pl]=Sieć,Łączność,Bluetooth
X-KDE-Keywords[pt]=Rede,Conectividade,Bluetooth
X-KDE-Keywords[pt_BR]=Rede,Conectividade,Bluetooth
diff --git a/src/kcmodule/bluedevildevices.h b/src/kcmodule/bluedevildevices.h
index e47b43e91f6f89a449e806daeec531a3fe32be72..db28629dee426f89bb3ed7cb6b250d0615fa2c55 100644
--- a/src/kcmodule/bluedevildevices.h
+++ b/src/kcmodule/bluedevildevices.h
@@ -32,7 +32,8 @@ class QCheckBox;
class QPushButton;
class QItemSelection;
-namespace BlueDevil {
+namespace BlueDevil
+{
class Adapter;
class Device;
}
diff --git a/src/kcmodule/bluedeviltransfer.cpp b/src/kcmodule/bluedeviltransfer.cpp
index fd1b1200bf036dc5300c9a2acd8080f737e14faf..fa0d55f929bb0ff203a113745a929ec8d58d7b98 100644
--- a/src/kcmodule/bluedeviltransfer.cpp
+++ b/src/kcmodule/bluedeviltransfer.cpp
@@ -40,6 +40,8 @@ K_PLUGIN_FACTORY_WITH_JSON(BlueDevilFactory,
"bluedeviltransfer.json",
registerPlugin<KCMBlueDevilTransfer>();)
+using namespace BlueDevil;
+
////////////////////////////////////////////////////////////////////////////////////////////////////
KCMBlueDevilTransfer::KCMBlueDevilTransfer(QWidget *parent, const QVariantList&)
@@ -78,8 +80,7 @@ KCMBlueDevilTransfer::KCMBlueDevilTransfer(QWidget *parent, const QVariantList&)
addConfig(FileReceiverSettings::self(), transfer);
- connect(BlueDevil::Manager::self(), SIGNAL(usableAdapterChanged(Adapter*)),
- this, SLOT(usableAdapterChanged(Adapter*)));
+ connect(BlueDevil::Manager::self(), &Manager::usableAdapterChanged, this, &KCMBlueDevilTransfer::usableAdapterChanged);
BlueDevil::Adapter *const usableAdapter = BlueDevil::Manager::self()->usableAdapter();
if (usableAdapter) {
@@ -90,10 +91,6 @@ KCMBlueDevilTransfer::KCMBlueDevilTransfer(QWidget *parent, const QVariantList&)
updateInformationState();
}
-KCMBlueDevilTransfer::~KCMBlueDevilTransfer()
-{
-}
-
void KCMBlueDevilTransfer::save()
{
if (!m_restartNeeded) {
diff --git a/src/kcmodule/bluedeviltransfer.desktop b/src/kcmodule/bluedeviltransfer.desktop
index 526e04799a5ec442c1902e54cc087802855807c5..6dc96e7744fb55d3b5b536cdd9e6d7ec22c02dad 100644
--- a/src/kcmodule/bluedeviltransfer.desktop
+++ b/src/kcmodule/bluedeviltransfer.desktop
@@ -79,6 +79,7 @@ X-KDE-Keywords[fr]=Réseau, connectivité, Bluetooth
X-KDE-Keywords[it]=Rete,Connettività,Bluetooth
X-KDE-Keywords[nb]=Nettverk,sammenkobling,blåtann
X-KDE-Keywords[nl]=Netwerkverbinding,connectiviteit,bluetooth
+X-KDE-Keywords[pa]=ਨੈਟਵਰਕ,ਕਨੈਕਟਵਿਟੀ,ਬਲਿਊਟੁੱਥ
X-KDE-Keywords[pl]=Sieć,Łączność,Bluetooth
X-KDE-Keywords[pt]=Rede,Conectividade,Bluetooth
X-KDE-Keywords[pt_BR]=Rede,Conectividade,Bluetooth
diff --git a/src/kcmodule/bluedeviltransfer.h b/src/kcmodule/bluedeviltransfer.h
index 5be3ae345beca5aa192a39118718ff427bc17393..ace854222bb036b2533aec23ef5dada4beeff923 100644
--- a/src/kcmodule/bluedeviltransfer.h
+++ b/src/kcmodule/bluedeviltransfer.h
@@ -24,26 +24,28 @@
#include <kcmodule.h>
class SystemCheck;
-namespace Ui {
+
+namespace Ui
+{
class Transfer;
}
-namespace BlueDevil {
+
+namespace BlueDevil
+{
class Adapter;
}
-typedef BlueDevil::Adapter Adapter;
-
class KCMBlueDevilTransfer : public KCModule
{
Q_OBJECT
public:
KCMBlueDevilTransfer(QWidget *parent, const QVariantList&);
- virtual ~KCMBlueDevilTransfer();
- virtual void save();
+ void save() Q_DECL_OVERRIDE;
+
private Q_SLOTS:
- void usableAdapterChanged(Adapter *adapter);
+ void usableAdapterChanged(BlueDevil::Adapter *adapter);
void adapterDiscoverableChanged();
void updateInformationState();
void changed(bool);
@@ -54,4 +56,4 @@ private:
bool m_restartNeeded;
};
-#endif
+#endif // _BLUEDEVILTRANSFER_H
diff --git a/src/kcmodule/devicedetails.h b/src/kcmodule/devicedetails.h
index b612587b996e0ef24077d7e0f146d9d71730a972..37326da8c0fb398d0a97fc36b87968fbb4b3ec8c 100644
--- a/src/kcmodule/devicedetails.h
+++ b/src/kcmodule/devicedetails.h
@@ -28,7 +28,8 @@ class QLineEdit;
class QAbstractButton;
class QDialogButtonBox;
-namespace BlueDevil {
+namespace BlueDevil
+{
class Device;
}
diff --git a/src/kcmodule/systemcheck.cpp b/src/kcmodule/systemcheck.cpp
index 122021b98adc57c1b979a757005709ec76e404b7..43cd86450e3453bd7acf27aebc938d8381160d19 100644
--- a/src/kcmodule/systemcheck.cpp
+++ b/src/kcmodule/systemcheck.cpp
@@ -41,6 +41,7 @@ SystemCheck::SystemCheck(QWidget *parent)
, m_kded(new KDED(QStringLiteral("org.kde.kded5"), QStringLiteral("/kded"), QDBusConnection::sessionBus()))
, m_parent(parent)
, m_noAdaptersError(0)
+ , m_noUsableAdapterError(0)
, m_notDiscoverableAdapterError(0)
, m_disabledNotificationsError(0)
{
@@ -48,9 +49,6 @@ SystemCheck::SystemCheck(QWidget *parent)
SystemCheck::~SystemCheck()
{
- m_noAdaptersError = 0;
- m_notDiscoverableAdapterError = 0;
- m_disabledNotificationsError = 0;
delete m_kded;
}
@@ -66,6 +64,16 @@ void SystemCheck::createWarnings(QVBoxLayout *layout)
m_noAdaptersError->setText(i18n("No Bluetooth adapters have been found."));
layout->addWidget(m_noAdaptersError);
+ m_noUsableAdapterError = new KMessageWidget(m_parent);
+ m_noUsableAdapterError->setMessageType(KMessageWidget::Warning);
+ m_noUsableAdapterError->setCloseButtonVisible(false);
+ m_noUsableAdapterError->setText(i18n("Your Bluetooth adapter is powered off."));
+
+ QAction *fixNoUsableAdapter = new QAction(QIcon::fromTheme(QStringLiteral("dialog-ok-apply")), i18nc("Action to fix a problem", "Fix it"), m_noUsableAdapterError);
+ connect(fixNoUsableAdapter, SIGNAL(triggered(bool)), this, SLOT(fixNoUsableAdapterError()));
+ m_noUsableAdapterError->addAction(fixNoUsableAdapter);
+ layout->addWidget(m_noUsableAdapterError);
+
m_notDiscoverableAdapterError = new KMessageWidget(m_parent);
m_notDiscoverableAdapterError->setMessageType(KMessageWidget::Warning);
m_notDiscoverableAdapterError->setCloseButtonVisible(false);
@@ -142,6 +150,7 @@ void SystemCheck::updateInformationState()
{
m_noAdaptersError->setEnabled(true);
m_noAdaptersError->setVisible(false);
+ m_noUsableAdapterError->setVisible(false);
m_notDiscoverableAdapterError->setVisible(false);
m_disabledNotificationsError->setVisible(false);
m_noKDEDRunning->setVisible(false);
@@ -151,9 +160,14 @@ void SystemCheck::updateInformationState()
return;
}
+ if (BlueDevil::Manager::self()->adapters().isEmpty()) {
+ m_noAdaptersError->setVisible(true);
+ return;
+ }
+
BlueDevil::Adapter *const usableAdapter = BlueDevil::Manager::self()->usableAdapter();
if (!usableAdapter) {
- m_noAdaptersError->setVisible(true);
+ m_noUsableAdapterError->setVisible(true);
return;
}
if (!usableAdapter->isDiscoverable()) {
@@ -176,6 +190,12 @@ void SystemCheck::fixNoKDEDRunning()
m_kded->loadModule(QStringLiteral("bluedevil"));
}
+void SystemCheck::fixNoUsableAdapterError()
+{
+ m_noUsableAdapterError->setVisible(false);
+ BlueDevil::Manager::self()->adapters().first()->setPowered(true);
+}
+
void SystemCheck::fixNotDiscoverableAdapterError()
{
m_notDiscoverableAdapterError->setVisible(false);
diff --git a/src/kcmodule/systemcheck.h b/src/kcmodule/systemcheck.h
index 74f9128b08eecbcb7770ab3c5b3f5b1ebd9b10be..cccf899a7bebd164086c23a6174bff56a35a3231 100644
--- a/src/kcmodule/systemcheck.h
+++ b/src/kcmodule/systemcheck.h
@@ -36,17 +36,6 @@ public:
SystemCheck(QWidget *parent);
virtual ~SystemCheck();
- struct SystemCheckResult {
- enum Result {
- NoWarnings = 0,
- BluetoothDisabled,
- NoAdapters,
- NotificationsDisabled,
- DefaultAdapterHidden
- } result;
- QWidget *warningWidget;
- };
-
void createWarnings(QVBoxLayout *layout);
bool checkKDEDModuleLoaded();
@@ -61,6 +50,7 @@ public Q_SLOTS:
private Q_SLOTS:
void fixNoKDEDRunning();
+ void fixNoUsableAdapterError();
void fixNotDiscoverableAdapterError();
void fixDisabledNotificationsError();
@@ -68,6 +58,7 @@ private:
KDED *m_kded;
QWidget *m_parent;
KMessageWidget *m_noAdaptersError;
+ KMessageWidget *m_noUsableAdapterError;
KMessageWidget *m_noKDEDRunning;
KMessageWidget *m_notDiscoverableAdapterError;
KMessageWidget *m_disabledNotificationsError;
diff --git a/src/kio/bluetooth/kded_bluedevil.xml b/src/kio/bluetooth/kded_bluedevil.xml
index cb4d6fdd3aeb8d5546833a8ee5de796c5e007537..e4478975fd84d080888138513dd73c985117a894 100644
--- a/src/kio/bluetooth/kded_bluedevil.xml
+++ b/src/kio/bluetooth/kded_bluedevil.xml
@@ -5,11 +5,19 @@
<method name="isOnline">
<arg type="b" direction="out"/>
</method>
- <method name="knownDevices">
+ <method name="allDevices">
<arg type="aa{ss}" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QMapDeviceInfo"/>
</method>
+ <method name="device">
+ <arg name="address" type="s" direction="in"/>
+ <arg type="a{ss}" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="DeviceInfo"/>
+ </method>
+ <method name="startDiscovering">
+ <arg name="timeout" type="u" direction="in"/>
+ </method>
<method name="stopDiscovering">
</method>
</interface>
-</node>
\ No newline at end of file
+</node>
diff --git a/src/kio/bluetooth/kiobluetooth.cpp b/src/kio/bluetooth/kiobluetooth.cpp
index e7b128983e77e865c11d095b5222caff7e8a3f33..7d529e6093097f32fb6fe86a3fe7037b3b21f553 100644
--- a/src/kio/bluetooth/kiobluetooth.cpp
+++ b/src/kio/bluetooth/kiobluetooth.cpp
@@ -30,10 +30,6 @@
#include <KProcess>
#include <KLocalizedString>
-#include <bluedevil/bluedevil.h>
-
-using namespace BlueDevil;
-
extern "C" int Q_DECL_EXPORT kdemain(int argc, char **argv)
{
QCoreApplication app(argc, argv);
@@ -61,27 +57,30 @@ KioBluetooth::KioBluetooth(const QByteArray &pool, const QByteArray &app)
s.icon = QStringLiteral("edit-copy");
s.mimetype = QStringLiteral("application/vnd.kde.bluedevil-sendfile");
s.uuid = QStringLiteral("00001105-0000-1000-8000-00805F9B34FB");
- m_supportedServices.insert(QStringLiteral("00001105-0000-1000-8000-00805F9B34FB"), s);
+ m_supportedServices.insert(s.uuid, s);
+
s.name = i18n("Browse Files");
s.icon = QStringLiteral("edit-find");
s.mimetype = QString();
s.uuid = QStringLiteral("00001106-0000-1000-8000-00805F9B34FB");
- m_supportedServices.insert(QStringLiteral("00001106-0000-1000-8000-00805F9B34FB"), s);
+ m_supportedServices.insert(s.uuid, s);
- if (!Manager::self()->usableAdapter()) {
- qCDebug(BLUETOOTH) << "No available interface";
+ qCDebug(BLUETOOTH) << "Kio Bluetooth instanced!";
+
+ m_kded = new org::kde::BlueDevil(QStringLiteral("org.kde.kded5"), QStringLiteral("/modules/bluedevil"),
+ QDBusConnection::sessionBus());
+
+ if (!m_kded->isOnline()) {
+ qCDebug(BLUETOOTH) << "Bluetooth is offline";
infoMessage(i18n("No Bluetooth adapters have been found."));
return;
}
-
- qCDebug(BLUETOOTH) << "Kio Bluetooth instanced!";
- m_kded = new org::kde::BlueDevil(QStringLiteral("org.kde.kded5"), QStringLiteral("/modules/bluedevil"),
- QDBusConnection::sessionBus(), 0);
}
QList<KioBluetooth::Service> KioBluetooth::getSupportedServices(const QStringList &uuids)
{
qCDebug(BLUETOOTH) << "supported services: " << uuids;
+
QList<Service> retValue;
Q_FOREACH (const QString &uuid, uuids) {
if (m_supportedServices.contains(uuid)) {
@@ -93,14 +92,22 @@ QList<KioBluetooth::Service> KioBluetooth::getSupportedServices(const QStringLis
void KioBluetooth::listRemoteDeviceServices()
{
- m_kded->stopDiscovering();
infoMessage(i18n("Retrieving services..."));
qCDebug(BLUETOOTH) << "Listing remote devices";
- m_currentHost = Manager::self()->usableAdapter()->deviceForAddress(m_currentHostname.replace('-', ':').toUpper());
- m_currentHostServices = getSupportedServices(m_currentHost->UUIDs());
+
+ const DeviceInfo &info = m_kded->device(m_currentHostAddress).value();
+ if (info.isEmpty()) {
+ qCDebug(BLUETOOTH) << "Invalid hostname!";
+ infoMessage(i18n("This address is unavailable."));
+ finished();
+ return;
+ }
+
+ m_currentHostServices = getSupportedServices(info.value(QStringLiteral("UUIDs")).split(QLatin1Char(',')));
qCDebug(BLUETOOTH) << "Num of supported services: " << m_currentHostServices.size();
+
totalSize(m_currentHostServices.count());
int i = 1;
Q_FOREACH (const Service &service, m_currentHostServices) {
@@ -109,7 +116,7 @@ void KioBluetooth::listRemoteDeviceServices()
entry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, service.name);
entry.insert(KIO::UDSEntry::UDS_ICON_NAME, service.icon);
- //If it is browse files, act as a folder
+ // If it is browse files, act as a folder
if (service.uuid == QLatin1String("00001106-0000-1000-8000-00805F9B34FB")) {
QUrl obexUrl;
obexUrl.setScheme(QStringLiteral("obexftp"));
@@ -137,11 +144,15 @@ void KioBluetooth::listRemoteDeviceServices()
void KioBluetooth::listDevices()
{
qCDebug(BLUETOOTH) << "Asking kded for devices";
- QMapDeviceInfo devices = m_kded->knownDevices().value();
+ const QMapDeviceInfo &devices = m_kded->allDevices().value();
qCDebug(BLUETOOTH) << devices.keys();
+
Q_FOREACH(const DeviceInfo device, devices) {
listDevice(device);
}
+
+ m_kded->startDiscovering(10 * 1000);
+
infoMessage(i18n("Scanning for new devices..."));
finished();
}
@@ -173,8 +184,8 @@ void KioBluetooth::listDir(const QUrl &url)
{
qCDebug(BLUETOOTH) << "Listing..." << url;
- /// Url is not used here becuase all we could care about the url is the host, and that's already
- /// handled in @p setHost
+ // Url is not used here becuase all we could care about the url is the host, and that's already
+ // handled in @p setHost
Q_UNUSED(url);
// If we are not online (ie. there's no working bluetooth adapter), list an empty dir
@@ -207,24 +218,24 @@ void KioBluetooth::get(const QUrl &url)
finished();
}
-void KioBluetooth::setHost(const QString &constHostname, quint16 port, const QString &user,
- const QString &pass)
+void KioBluetooth::setHost(const QString &hostname, quint16 port, const QString &user, const QString &pass)
{
- qCDebug(BLUETOOTH) << "Setting host: " << constHostname;
+ qCDebug(BLUETOOTH) << "Setting host: " << hostname;
// In this kio only the hostname (constHostname) is used
Q_UNUSED(port)
Q_UNUSED(user)
Q_UNUSED(pass)
- QString hostname = constHostname;
- hostname = hostname.replace(QLatin1Char('-'), QLatin1Char(':')).toUpper();
if (hostname.isEmpty()) {
m_hasCurrentHost = false;
} else {
m_hasCurrentHost = true;
- m_currentHostname = constHostname;
m_currentHostServices.clear();
+
+ m_currentHostname = hostname;
+ m_currentHostAddress = hostname.toUpper();
+ m_currentHostAddress.replace(QLatin1Char('-'), QLatin1Char(':'));
}
}
diff --git a/src/kio/bluetooth/kiobluetooth.h b/src/kio/bluetooth/kiobluetooth.h
index a353ca9473c70d77baf596f112b8894844e66fe5..756bf9246a6a69da90bd7633162e92f092c34cf8 100644
--- a/src/kio/bluetooth/kiobluetooth.h
+++ b/src/kio/bluetooth/kiobluetooth.h
@@ -36,13 +36,6 @@
*/
class KioBluetoothPrivate;
-namespace BlueDevil {
- class Device;
- class Adapter;
-}
-
-using namespace BlueDevil;
-
class KioBluetooth : public QObject, public KIO::SlaveBase
{
Q_OBJECT
@@ -62,7 +55,7 @@ public:
* get function shall not do much other than setting a mimetype and returning some data that
* could be useful for the mimetype handler.
*/
- void get(const QUrl &url);
+ void get(const QUrl &url) Q_DECL_OVERRIDE;
/**
* List current directory. There are two types of current directories in this kio:
@@ -72,16 +65,16 @@ public:
* 2. Remote device directory (something like bluetoth:/00_12_34_56_6d_34). This directory lists
* the services provided by the given remote device.
*/
- void listDir(const QUrl &url);
+ void listDir(const QUrl &url) Q_DECL_OVERRIDE;
- void stat(const QUrl &url);
+ void stat(const QUrl &url) Q_DECL_OVERRIDE;
/**
* As at the momento we don't handle more than one level url paths, @p setHost has not much
* difference with @p listDir
*
*/
- void setHost(const QString &constHostname, quint16 port, const QString &user, const QString &pass);
+ void setHost(const QString &hostname, quint16 port, const QString &user, const QString &pass) Q_DECL_OVERRIDE;
/**
* Returns a list of supported service names corresponding to the given uuids list. If an uuid is
@@ -104,7 +97,6 @@ public Q_SLOTS:
void listDevice(const DeviceInfo device);
private:
-
/**
* This is set to true when @p setHost is called to list a given remote device, like for example
* 00:2a:5E:8e:6e:f5. If listing the remote devices (bluetooth:/ uri), it's set back to false.
@@ -120,10 +112,9 @@ private:
QString m_currentHostname;
/**
- * Represents the current host when @p hasCurrentHost is set to true. This is set in
- * @p listRemoteDeviceServices function.
+ * Uppercase colon separated address (ex. 00:2A:5E:8E:6E:F5)
*/
- Device *m_currentHost;
+ QString m_currentHostAddress;
/**
* When @p hasCurrentHost to true, this list holds the list of service names provided by the
@@ -133,12 +124,6 @@ private:
/**
* This is an array containing as key the uuid and as value the name of the service that the
- * given uuid represents.
- */
- QMap<QString, QString> m_serviceNames;
-
- /**
- * This is an array containing as key the uuid and as value the name of the service that the
* given uuid represents, and a representative icon. It only contains the supported service names.
*/
QMap<QString, Service> m_supportedServices;
diff --git a/src/kio/obexftp/CMakeLists.txt b/src/kio/obexftp/CMakeLists.txt
index d50825bd2b5c0e299e34a7bd5029f409c92bc2ed..a7702382f2b4837a4dd3c87b84eb9e0bdd57640a 100644
--- a/src/kio/obexftp/CMakeLists.txt
+++ b/src/kio/obexftp/CMakeLists.txt
@@ -1,5 +1,3 @@
-project(kio_obexftp)
-
add_subdirectory(daemon)
set(kio_obexftp_SRCS
diff --git a/src/kio/obexftp/daemon/CMakeLists.txt b/src/kio/obexftp/daemon/CMakeLists.txt
index b7ad5d215523faaed7393f8d1edb537ccb609b63..8a4ff87f3a04af3c504fba740d6e87231b5f8d3b 100644
--- a/src/kio/obexftp/daemon/CMakeLists.txt
+++ b/src/kio/obexftp/daemon/CMakeLists.txt
@@ -12,7 +12,7 @@ qt5_add_dbus_interface(kded_obexftp_SRCS org.freedesktop.DBus.ObjectManager.xml
add_library(kded_obexftpdaemon MODULE ${kded_obexftp_SRCS})
-kservice_desktop_to_json(kded_obexftpdaemon obexftpdaemon.desktop)
+kcoreaddons_desktop_to_json(kded_obexftpdaemon obexftpdaemon.desktop)
target_link_libraries(kded_obexftpdaemon
Qt5::Core
diff --git a/src/kio/obexftp/daemon/ObexFtpDaemon.cpp b/src/kio/obexftp/daemon/ObexFtpDaemon.cpp
index af66c7ce4f47ddbb8581e39a89f0ef50ef5a4078..4170193ea42ab01fae7151ae6952acdec9a292f3 100644
--- a/src/kio/obexftp/daemon/ObexFtpDaemon.cpp
+++ b/src/kio/obexftp/daemon/ObexFtpDaemon.cpp
@@ -29,10 +29,6 @@
#include <KPluginFactory>
#include <KLocalizedString>
-#include <bluedevil/bluedevilmanager.h>
-#include <bluedevil/bluedeviladapter.h>
-
-using namespace BlueDevil;
K_PLUGIN_FACTORY_WITH_JSON(ObexFtpFactory,
"obexftpdaemon.json",
registerPlugin<ObexFtpDaemon>();)
@@ -58,8 +54,6 @@ ObexFtpDaemon::ObexFtpDaemon(QObject *parent, const QList<QVariant>&)
qDBusRegisterMetaType<DBusManagerStruct>();
qDBusRegisterMetaType<QVariantMapMap>();
- d->m_status = Private::Offline;
-
KAboutData aboutData(QStringLiteral("obexftpdaemon"),
i18n("ObexFtp Daemon"),
bluedevil_version,
@@ -70,13 +64,10 @@ ObexFtpDaemon::ObexFtpDaemon(QObject *parent, const QList<QVariant>&)
aboutData.addAuthor(i18n("Alejandro Fiestas Olivares"), i18n("Maintainer"),
QStringLiteral("afiestas@kde.org"), QStringLiteral("http://www.afiestas.org"));
- connect(Manager::self(), SIGNAL(usableAdapterChanged(Adapter*)),
- SLOT(usableAdapterChanged(Adapter*)));
-
+ d->m_status = Private::Offline;
d->m_interface = new OrgFreedesktopDBusObjectManagerInterface(QStringLiteral("org.bluez.obex"),
QStringLiteral("/"),
QDBusConnection::sessionBus(), this);
-
connect(d->m_interface, SIGNAL(InterfacesRemoved(QDBusObjectPath,QStringList)),
SLOT(interfaceRemoved(QDBusObjectPath,QStringList)));
@@ -84,11 +75,13 @@ ObexFtpDaemon::ObexFtpDaemon(QObject *parent, const QList<QVariant>&)
QDBusConnection::sessionBus(),
QDBusServiceWatcher::WatchForUnregistration, this);
- connect(d->m_serviceWatcher, SIGNAL(serviceUnregistered(QString)), SLOT(serviceUnregistered(QString)));
+ connect(d->m_serviceWatcher, SIGNAL(serviceRegistered(QString)), SLOT(serviceRegistered()));
+ connect(d->m_serviceWatcher, SIGNAL(serviceUnregistered(QString)), SLOT(serviceUnregistered()));
- //WARNING this blocks if org.bluez in system bus is dead
- if (Manager::self()->usableAdapter()) {
+ if (QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.bluez.obex"))) {
onlineMode();
+ } else {
+ offlineMode();
}
}
@@ -114,6 +107,7 @@ void ObexFtpDaemon::onlineMode()
void ObexFtpDaemon::offlineMode()
{
qCDebug(OBEXDAEMON) << "Offline mode";
+
if (d->m_status == Private::Offline) {
qCDebug(OBEXDAEMON) << "Already in offlineMode";
return;
@@ -125,33 +119,28 @@ void ObexFtpDaemon::offlineMode()
d->m_status = Private::Offline;
}
-void ObexFtpDaemon::usableAdapterChanged(Adapter *adapter)
+bool ObexFtpDaemon::isOnline()
{
- if (!adapter) {
- offlineMode();
- return;
- }
-
- onlineMode();
+ return d->m_status == Private::Online;
}
-QString ObexFtpDaemon::session(QString address, const QDBusMessage& msg)
+QString ObexFtpDaemon::session(const QString &address, const QString &target, const QDBusMessage& msg)
{
- qCDebug(OBEXDAEMON) << address;
- address.replace(QLatin1Char('-'), QLatin1Char(':'));
-
if (d->m_sessionMap.contains(address)) {
return d->m_sessionMap[address];
}
- //At this point we always want delayed reply
+ qCDebug(OBEXDAEMON) << "Creating session for" << address << "target" << target;
+
+ // At this point we always want delayed reply
msg.setDelayedReply(true);
+
if (d->m_wipSessions.contains(address)) {
d->m_wipSessions[address]->addMessage(msg);
return QString();
}
- CreateSessionJob *job = new CreateSessionJob(address, msg);
+ CreateSessionJob *job = new CreateSessionJob(address, target, msg);
connect(job, SIGNAL(finished(KJob*)), SLOT(sessionCreated(KJob*)));
job->start();
@@ -159,30 +148,46 @@ QString ObexFtpDaemon::session(QString address, const QDBusMessage& msg)
return QString();
}
+bool ObexFtpDaemon::cancelTransfer(const QString &transfer)
+{
+ // We need this function because kio_obexftp is not owner of the transfer,
+ // and thus cannot cancel it.
+
+ QDBusMessage call = QDBusMessage::createMethodCall(QStringLiteral("org.bluez.obex"),
+ transfer,
+ QStringLiteral("org.bluez.obex.Transfer1"),
+ QStringLiteral("Cancel"));
+
+ QDBusReply<void> reply = QDBusConnection::sessionBus().call(call);
+ return reply.isValid();
+}
+
void ObexFtpDaemon::sessionCreated(KJob* job)
{
CreateSessionJob* cJob = qobject_cast<CreateSessionJob*>(job);
qCDebug(OBEXDAEMON) << cJob->path();
d->m_wipSessions.remove(cJob->address());
- d->m_sessionMap.insert(cJob->address(), cJob->path());
- d->m_reverseSessionMap.insert(cJob->path(), cJob->address());
- const QList<QDBusMessage> messages = cJob->messages();
- Q_FOREACH(const QDBusMessage &msg, messages) {
+ Q_FOREACH (const QDBusMessage &msg, cJob->messages()) {
QDBusMessage reply = msg.createReply(cJob->path());
- QDBusConnection::sessionBus().asyncCall(reply);
+ QDBusConnection::sessionBus().send(reply);
+ }
+
+ if (!cJob->error()) {
+ d->m_sessionMap.insert(cJob->address(), cJob->path());
+ d->m_reverseSessionMap.insert(cJob->path(), cJob->address());
}
}
-void ObexFtpDaemon::serviceUnregistered(const QString& service)
+void ObexFtpDaemon::serviceRegistered()
{
- if (service != QLatin1String("org.bluez.obex")) {
- return;
- }
+ onlineMode();
+}
- d->m_sessionMap.clear();
- d->m_reverseSessionMap.clear();
+void ObexFtpDaemon::serviceUnregistered()
+{
+ offlineMode();
}
void ObexFtpDaemon::interfaceRemoved(const QDBusObjectPath &dbusPath, const QStringList& interfaces)
diff --git a/src/kio/obexftp/daemon/ObexFtpDaemon.h b/src/kio/obexftp/daemon/ObexFtpDaemon.h
index d56b73da04cef4ba21fdcae9b332257c94c8df0f..28c34abb8a6e84ba68752289b8870b63ff4fd9ad 100644
--- a/src/kio/obexftp/daemon/ObexFtpDaemon.h
+++ b/src/kio/obexftp/daemon/ObexFtpDaemon.h
@@ -30,44 +30,28 @@ class QDBusMessage;
class QDBusObjectPath;
class QDBusPendingCallWatcher;
-namespace BlueDevil {
- class Adapter;
-};
-using namespace BlueDevil;
-
-class Q_DECL_EXPORT ObexFtpDaemon
- : public KDEDModule
+class Q_DECL_EXPORT ObexFtpDaemon : public KDEDModule
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.ObexFtp")
public:
- /**
- * Connects to usableAdapterChanged
- */
ObexFtpDaemon(QObject *parent, const QList<QVariant>&);
virtual ~ObexFtpDaemon();
public Q_SLOTS:
- Q_SCRIPTABLE QString session(QString address, const QDBusMessage &msg);
+ Q_SCRIPTABLE bool isOnline();
+ Q_SCRIPTABLE QString session(const QString &address, const QString &target, const QDBusMessage &msg);
+ Q_SCRIPTABLE bool cancelTransfer(const QString &transfer);
private Q_SLOTS:
- void usableAdapterChanged(Adapter* adapter);
void sessionCreated(KJob* job);
- void serviceUnregistered(const QString &service);
+ void serviceRegistered();
+ void serviceUnregistered();
void interfaceRemoved(const QDBusObjectPath &path, const QStringList &interfaces);
private:
- /**
- * Called by constructor or eventually by adapterAdded initialize all the helpers
- * @see helpers
- */
- void onlineMode();
-
- /**
- * Called eventually adapterRemoved shutdown all the helpers
- * @see helpers
- */
+ void onlineMode();
void offlineMode();
struct Private;
diff --git a/src/kio/obexftp/daemon/createsessionjob.cpp b/src/kio/obexftp/daemon/createsessionjob.cpp
index 2eba3566a0cd971ba88eba27d11db3f6d5d2bb95..c0191563d99d2a071a823666be00d3ef6c8981eb 100644
--- a/src/kio/obexftp/daemon/createsessionjob.cpp
+++ b/src/kio/obexftp/daemon/createsessionjob.cpp
@@ -24,9 +24,10 @@
#include <QDebug>
// class
-CreateSessionJob::CreateSessionJob(const QString& address, const QDBusMessage& msg, QObject* parent)
+CreateSessionJob::CreateSessionJob(const QString &address, const QString &target, const QDBusMessage &msg, QObject *parent)
: KJob(parent)
, m_address(address)
+ , m_target(target)
, m_client(0)
{
m_messages.append(msg);
@@ -52,7 +53,7 @@ void CreateSessionJob::addMessage(const QDBusMessage& msg)
m_messages.append(msg);
}
-const QList< QDBusMessage > CreateSessionJob::messages() const
+const QList<QDBusMessage> CreateSessionJob::messages() const
{
return m_messages;
}
@@ -61,8 +62,7 @@ void CreateSessionJob::createSession()
{
qCDebug(OBEXDAEMON);
QVariantMap args;
- args[QStringLiteral("Target")] = QStringLiteral("ftp");
-// args["Source"] = "00:02:72:D6:8F:2C";
+ args[QStringLiteral("Target")] = m_target;
m_client = new OrgBluezObexClient1Interface(QStringLiteral("org.bluez.obex"),
QStringLiteral("/org/bluez/obex"),
QDBusConnection::sessionBus(), this);
@@ -70,7 +70,6 @@ void CreateSessionJob::createSession()
QDBusPendingReply <QDBusObjectPath > reply = m_client->CreateSession(m_address, args);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply);
- qCDebug(OBEXDAEMON) << "DROGUES";
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(sessionCreated(QDBusPendingCallWatcher*)));
}
@@ -83,12 +82,7 @@ void CreateSessionJob::sessionCreated(QDBusPendingCallWatcher* watcher)
qCDebug(OBEXDAEMON) << "Error:";
qCDebug(OBEXDAEMON) << reply.error().name();
qCDebug(OBEXDAEMON) << reply.error().message();
-// Q_FOREACH(const QDBusMessage &msg, m_msgs) {
-// qCDebug(OBEXDAEMON) << msg.service() << msg.path();
-// QDBusMessage errorMsg = msg.createErrorReply("org.kde.kded.Error", i18n("Can't stablish connection"));
-// QDBusConnection::sessionBus().send(errorMsg);
-// }C
-// m_status = Error;
+
setError(reply.error().type());
setErrorText(reply.error().message());
emitResult();
diff --git a/src/kio/obexftp/daemon/createsessionjob.h b/src/kio/obexftp/daemon/createsessionjob.h
index a457b0288993ac0ec4fa310e9350fb13f9bd2a85..667384bcc1602ecf2f2228e88318b3a03a517849 100644
--- a/src/kio/obexftp/daemon/createsessionjob.h
+++ b/src/kio/obexftp/daemon/createsessionjob.h
@@ -29,7 +29,7 @@ class CreateSessionJob : public KJob
{
Q_OBJECT
public:
- explicit CreateSessionJob(const QString &address, const QDBusMessage &msg, QObject* parent = 0);
+ explicit CreateSessionJob(const QString &address, const QString &target, const QDBusMessage &msg, QObject *parent = 0);
virtual void start();
QString path();
@@ -44,9 +44,10 @@ private Q_SLOTS:
private:
QString m_path;
QString m_address;
+ QString m_target;
QList<QDBusMessage> m_messages;
OrgBluezObexClient1Interface* m_client;
};
-#endif //CREATE_SESSION_JOB_H
\ No newline at end of file
+#endif //CREATE_SESSION_JOB_H
diff --git a/src/kio/obexftp/kded_obexftp.xml b/src/kio/obexftp/kded_obexftp.xml
index 24c6c5cc196574c7a9f3d42290d5d48af43178c3..06e3b1442ee48c8cda816867b0749ab58413e832 100644
--- a/src/kio/obexftp/kded_obexftp.xml
+++ b/src/kio/obexftp/kded_obexftp.xml
@@ -3,9 +3,17 @@
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.kde.ObexFtp">
+ <method name="isOnline">
+ <arg name="online" type="b" direction="out"/>
+ </method>
<method name="session">
<arg name="address" type="s" direction="in"/>
+ <arg name="target" type="s" direction="in"/>
<arg name="sessionPath" type="s" direction="out"/>
</method>
+ <method name="cancelTransfer">
+ <arg name="transfer" type="s" direction="in"/>
+ <arg name="success" type="b" direction="out"/>
+ </method>
</interface>
-</node>
\ No newline at end of file
+</node>
diff --git a/src/kio/obexftp/kio_obexftp.cpp b/src/kio/obexftp/kio_obexftp.cpp
index b5b93d81e3a563af3aff2fedac37babaa420108e..17eefec61bba3998bf5f159f468cb2f34f586561 100644
--- a/src/kio/obexftp/kio_obexftp.cpp
+++ b/src/kio/obexftp/kio_obexftp.cpp
@@ -61,16 +61,21 @@ static QString urlFileName(const QUrl &url)
return u.fileName();
}
+static bool urlIsRoot(const QUrl &url)
+{
+ const QString &directory = urlDirectory(url);
+ return (directory.isEmpty() || directory == QLatin1String("/")) && urlFileName(url).isEmpty();
+}
+
KioFtp::KioFtp(const QByteArray &pool, const QByteArray &app)
: SlaveBase(QByteArrayLiteral("obexftp"), pool, app)
- , m_settingHost(false)
, m_transfer(0)
{
- qDBusRegisterMetaType<QVariantMapList>();
-
m_timer = new QTimer();
m_timer->setInterval(100);
+ qDBusRegisterMetaType<DeviceInfo>();
+ qDBusRegisterMetaType<QVariantMapList>();
m_kded = new org::kde::ObexFtp(QStringLiteral("org.kde.kded5"), QStringLiteral("/modules/obexftpdaemon"),
QDBusConnection::sessionBus(), 0);
}
@@ -88,6 +93,63 @@ void KioFtp::launchProgressBar()
m_timer->start();
}
+void KioFtp::connectToHost()
+{
+ // Prefer pcsuite target on S60 devices
+ if (m_uuids.contains(QLatin1String("00005005-0000-1000-8000-0002EE000001"))) {
+ if (createSession("pcsuite")) {
+ return;
+ }
+ // Fallback to ftp
+ }
+
+ createSession("ftp");
+}
+
+bool KioFtp::testConnection()
+{
+ if (!m_kded->isOnline().value()) {
+ error(KIO::ERR_SLAVE_DEFINED, i18n("Obexd service is not running."));
+ return false;
+ }
+
+ connectToHost();
+
+ if (!m_transfer) {
+ error(KIO::ERR_COULD_NOT_CONNECT, m_host);
+ return false;
+ }
+ return true;
+}
+
+bool KioFtp::createSession(const QString &target)
+{
+ QDBusPendingReply<QString> reply = m_kded->session(m_host, target);
+ reply.waitForFinished();
+
+ const QString &sessionPath = reply.value();
+
+ if (reply.isError() || sessionPath.isEmpty()) {
+ qCDebug(OBEXFTP) << reply.error().message();
+ qCDebug(OBEXFTP) << reply.error().name();
+
+ delete m_transfer;
+ m_transfer = 0;
+ m_sessionPath.clear();
+ return false;
+ }
+
+ if (m_sessionPath != sessionPath) {
+ m_statMap.clear();
+ delete m_transfer;
+ m_transfer = new org::bluez::obex::FileTransfer1(QStringLiteral("org.bluez.obex"), sessionPath, QDBusConnection::sessionBus());
+ m_sessionPath = sessionPath;
+ }
+
+ return true;
+}
+
+
void KioFtp::updateProcess()
{
if (m_counter == 49) {
@@ -102,34 +164,27 @@ void KioFtp::updateProcess()
void KioFtp::listDir(const QUrl &url)
{
+ if (!testConnection()) {
+ return;
+ }
+
qCDebug(OBEXFTP) << "listdir: " << url;
infoMessage(i18n("Retrieving information from remote device..."));
- qCDebug(OBEXFTP) << "Asking for listFolder";
-
- //TODO: Check if changeFolder fails
- m_transfer->ChangeFolder(url.path()).waitForFinished();
+ qCDebug(OBEXFTP) << "Asking for listFolder" << url.path();
- QDBusPendingReply <QVariantMapList > reply = m_transfer->ListFolder();
- reply.waitForFinished();
-
- if (reply.isError()) {
- qCDebug(OBEXFTP) << reply.error().message();
- error(KIO::ERR_SLAVE_DEFINED, i18n("Bluetooth is not enabled"));
+ if (!changeFolder(url.path())) {
return;
}
- QVariantMapList folderList = reply.value();
- Q_FOREACH(const QVariantMap folder, folderList) {
- KIO::UDSEntry entry = entryFromInfo(folder);
- QUrl statUrl = url.adjusted(QUrl::RemoveFilename);
- statUrl.setPath(statUrl.path() + folder[QStringLiteral("Name")].toString());
- if (!m_statMap.contains(statUrl.toDisplayString())) {
- qCDebug(OBEXFTP) << "Stat: " << statUrl.toDisplayString() << entry.numberValue(KIO::UDSEntry::UDS_SIZE);
- m_statMap.insert(statUrl.toDisplayString(), entry);
- }
+ bool ok;
+ const QList<KIO::UDSEntry> &list = listFolder(url, &ok);
+ if (!ok) {
+ return;
+ }
+ Q_FOREACH (const KIO::UDSEntry &entry, list) {
listEntry(entry);
}
@@ -141,10 +196,13 @@ void KioFtp::copy(const QUrl &src, const QUrl &dest, int permissions, KIO::JobFl
Q_UNUSED(permissions)
Q_UNUSED(flags)
+ if (!testConnection()) {
+ return;
+ }
+
qCDebug(OBEXFTP) << "copy: " << src.url() << " to " << dest.url();
copyHelper(src, dest);
-
finished();
}
@@ -154,11 +212,15 @@ void KioFtp::rename(const QUrl& src, const QUrl& dest, KIO::JobFlags flags)
Q_UNUSED(dest)
Q_UNUSED(flags)
- error(KIO::ERR_UNSUPPORTED_ACTION, src.toDisplayString());
+ error(KIO::ERR_UNSUPPORTED_ACTION, QString());
}
void KioFtp::get(const QUrl& url)
{
+ if (!testConnection()) {
+ return;
+ }
+
QTemporaryFile tempFile(QString(QStringLiteral("%1/kioftp_XXXXXX.%2")).arg(QDir::tempPath(), urlFileName(url)));
tempFile.open();//Create the file
qCDebug(OBEXFTP) << tempFile.fileName();
@@ -180,6 +242,10 @@ void KioFtp::get(const QUrl& url)
finished();
}
+bool KioFtp::cancelTransfer(const QString &transfer)
+{
+ return m_kded->cancelTransfer(transfer);
+}
void KioFtp::setHost(const QString &host, quint16 port, const QString &user, const QString &pass)
{
@@ -187,35 +253,38 @@ void KioFtp::setHost(const QString &host, quint16 port, const QString &user, con
Q_UNUSED(user)
Q_UNUSED(pass)
- infoMessage(i18n("Connecting to the device"));
+ m_host = host;
+ m_host = m_host.replace(QLatin1Char('-'), QLatin1Char(':')).toUpper();
- qCDebug(OBEXFTP) << "setHost: " << host;
+ QDBusMessage call = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kded5"),
+ QStringLiteral("/modules/bluedevil"),
+ QStringLiteral("org.kde.BlueDevil"),
+ QStringLiteral("device"));
+ call << m_host;
+ QDBusReply<DeviceInfo> reply = QDBusConnection::sessionBus().call(call);
+ DeviceInfo info = reply.value();
- qCDebug(OBEXFTP) << "Waiting to stablish the connection 2";
- QDBusPendingReply <QString > reply = m_kded->session(host);
- reply.waitForFinished();
+ m_uuids = info[QStringLiteral("UUIDs")];
- qCDebug(OBEXFTP) << "AFTER" << reply.isError();
- if (reply.isError()) {
- qCDebug(OBEXFTP) << reply.error().message();
- qCDebug(OBEXFTP) << reply.error().name();
- }
-
- qCDebug(OBEXFTP) << "Got a path" << reply.value();
+ infoMessage(i18n("Connecting to the device"));
- m_address = host;
- m_sessionPath = reply.value();
- m_transfer = new org::bluez::obex::FileTransfer1("org.bluez.obex", m_sessionPath, QDBusConnection::sessionBus());
- m_statMap.clear();
+ connectToHost();
}
void KioFtp::del(const QUrl& url, bool isfile)
{
Q_UNUSED(isfile)
- qCDebug(OBEXFTP) << "Del: " << url.url();
- m_transfer->ChangeFolder(urlDirectory(url)).waitForFinished();
- m_transfer->Delete(urlFileName(url)).waitForFinished();
+ if (!testConnection()) {
+ return;
+ }
+ if (!changeFolder(urlDirectory(url))) {
+ return;
+ }
+ if (!deleteFile(urlFileName(url))) {
+ return;
+ }
+
finished();
}
@@ -223,14 +292,28 @@ void KioFtp::mkdir(const QUrl& url, int permissions)
{
Q_UNUSED(permissions)
+ if (!testConnection()) {
+ return;
+ }
+
qCDebug(OBEXFTP) << "MkDir: " << url.url();
- m_transfer->ChangeFolder(urlDirectory(url)).waitForFinished();
- m_transfer->CreateFolder(urlFileName(url)).waitForFinished();
+
+ if (!changeFolder(urlDirectory(url))) {
+ return;
+ }
+ if (!createFolder(urlFileName(url))) {
+ return;
+ }
+
finished();
}
void KioFtp::stat(const QUrl &url)
{
+ if (!testConnection()) {
+ return;
+ }
+
qCDebug(OBEXFTP) << "Stat: " << url.url();
qCDebug(OBEXFTP) << "Stat Dir: " << urlDirectory(url);
qCDebug(OBEXFTP) << "Stat File: " << urlFileName(url);
@@ -245,8 +328,7 @@ void KioFtp::stat(const QUrl &url)
void KioFtp::copyHelper(const QUrl& src, const QUrl& dest)
{
if (src.scheme() == QLatin1String("obexftp") && dest.scheme() == QLatin1String("obexftp")) {
- error(KIO::ERR_UNSUPPORTED_ACTION, src.toDisplayString());
- //TODO: with obexd this seems possible, we should at least try
+ copyWithinObexftp(src, dest);
return;
}
@@ -261,55 +343,49 @@ void KioFtp::copyHelper(const QUrl& src, const QUrl& dest)
}
qCDebug(OBEXFTP) << "This shouldn't happen...";
- finished();
}
-void KioFtp::copyFromObexftp(const QUrl& src, const QUrl& dest)
+void KioFtp::copyWithinObexftp(const QUrl &src, const QUrl &dest)
{
qCDebug(OBEXFTP) << "Source: " << src << "Dest:" << dest;
- //Just in case the url is not in the stat, some times happens...
- if (!m_statMap.contains(src.toDisplayString())) {
- qCDebug(OBEXFTP) << "The url is not in the cache, stating it";
- statHelper(src);
- }
+ copyFile(src.path(), dest.path());
+}
+
+void KioFtp::copyFromObexftp(const QUrl& src, const QUrl& dest)
+{
+ qCDebug(OBEXFTP) << "Source: " << src << "Dest:" << dest;
- if (m_statMap.value(src.toDisplayString()).isDir()) {
- qCDebug(OBEXFTP) << "Skipping to copy: " << src.toDisplayString();
- //TODO: Check if dir copying works with obexd
- error(KIO::ERR_IS_DIRECTORY, src.toDisplayString());
+ if (!changeFolder(urlDirectory(src))) {
return;
}
- qCDebug(OBEXFTP) << "Changing dir:" << urlDirectory(src);
- m_transfer->ChangeFolder(urlDirectory(src)).waitForFinished();
-
- QString dbusPath = m_transfer->GetFile(dest.path(), urlFileName(src)).value().path();
+ const QString &dbusPath = m_transfer->GetFile(dest.path(), urlFileName(src)).value().path();
qCDebug(OBEXFTP) << "Path from GetFile:" << dbusPath;
int size = m_statMap[src.toDisplayString()].numberValue(KIO::UDSEntry::UDS_SIZE);
+ totalSize(size);
+
TransferFileJob *getFile = new TransferFileJob(dbusPath, this);
- getFile->setSize(size);
getFile->exec();
-
- finished();
}
void KioFtp::copyToObexftp(const QUrl& src, const QUrl& dest)
{
qCDebug(OBEXFTP) << "Source:" << src << "Dest:" << dest;
- qCDebug(OBEXFTP) << "Changing folder: " << urlDirectory(dest);
- m_transfer->ChangeFolder(urlDirectory(dest));
- QString dbusPath = m_transfer->PutFile(src.path(), urlFileName(dest)).value().path();
+ if (!changeFolder(urlDirectory(dest))) {
+ return;
+ }
+
+ const QString &dbusPath = m_transfer->PutFile(src.path(), urlFileName(dest)).value().path();
qCDebug(OBEXFTP) << "Path from PutFile: " << dbusPath;
- QFile file(src.path());
+ int size = QFile(src.path()).size();
+ totalSize(size);
+
TransferFileJob *putFile = new TransferFileJob(dbusPath, this);
- putFile->setSize(file.size());
putFile->exec();
-
- finished();
}
void KioFtp::statHelper(const QUrl& url)
@@ -322,10 +398,10 @@ void KioFtp::statHelper(const QUrl& url)
return;
}
- if ((urlDirectory(url) == QLatin1String("/") || urlDirectory(url).isEmpty()) && urlFileName(url).isEmpty()) {
+ if (urlIsRoot(url)) {
qCDebug(OBEXFTP) << "Url is root";
KIO::UDSEntry entry;
- entry.insert(KIO::UDSEntry::UDS_NAME, QString::fromLatin1("/"));
+ entry.insert(KIO::UDSEntry::UDS_NAME, QStringLiteral("/"));
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0700);
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory"));
@@ -333,53 +409,145 @@ void KioFtp::statHelper(const QUrl& url)
qCDebug(OBEXFTP) << "Adding stat cached: " << url.toDisplayString();
m_statMap[url.toDisplayString()] = entry;
statEntry(entry);
-
return;
}
qCDebug(OBEXFTP) << "statMap does NOT contains the url";
- //TODO: Check if changeFolder fails
- m_transfer->ChangeFolder(urlDirectory(url)).waitForFinished();
- QVariantMapList folderList = m_transfer->ListFolder().value();
- qCDebug(OBEXFTP) << urlDirectory(url) << folderList.count();
- Q_FOREACH(const QVariantMap folder, folderList) {
- KIO::UDSEntry entry = entryFromInfo(folder);
-
- QString fileName = folder[QStringLiteral("Name")].toString();
- if (urlFileName(url) == fileName) {
- statEntry(entry);
+
+ if (!changeFolder(urlDirectory(url))) {
+ return;
+ }
+
+ bool ok;
+ const QList<KIO::UDSEntry> &list = listFolder(url, &ok);
+ if (!ok) {
+ return;
+ }
+
+ Q_FOREACH (const KIO::UDSEntry &entry, list) {
+ statEntry(entry);
+ }
+
+ qCDebug(OBEXFTP) << "Finished";
+}
+
+QList<KIO::UDSEntry> KioFtp::listFolder(const QUrl &url, bool *ok)
+{
+ QList<KIO::UDSEntry> list;
+
+ QDBusPendingReply<QVariantMapList> reply = m_transfer->ListFolder();
+ reply.waitForFinished();
+
+ if (reply.isError()) {
+ error(KIO::ERR_CANNOT_OPEN_FOR_READING, urlDirectory(url));
+ *ok = false;
+ return list;
+ }
+
+ Q_FOREACH (const QVariantMap &item, reply.value()) {
+ KIO::UDSEntry entry;
+ entry.insert(KIO::UDSEntry::UDS_NAME, item[QStringLiteral("Name")].toString());
+ entry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, item[QStringLiteral("Label")].toString());
+ entry.insert(KIO::UDSEntry::UDS_ACCESS, 0700);
+ entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, QDateTime::fromString(item[QStringLiteral("Modified")].toString(), "yyyyMMddThhmmssZ").toTime_t());
+ entry.insert(KIO::UDSEntry::UDS_SIZE, item[QStringLiteral("Size")].toLongLong());
+ if (item[QStringLiteral("Type")] == QLatin1String("folder")) {
+ entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
+ entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory"));
+ } else {
+ entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
+ }
+ if (urlIsRoot(url)) {
+ updateRootEntryIcon(entry, item[QStringLiteral("Mem-type")].toString());
}
+ list.append(entry);
//Most probably the client of the kio will stat each file
//so since we are on it, let's cache all of them.
QUrl statUrl = url.adjusted(QUrl::RemoveFilename);
- statUrl.setPath(statUrl.path() + fileName);
+ statUrl.setPath(statUrl.path() + item[QStringLiteral("Name")].toString());
if (!m_statMap.contains(statUrl.toDisplayString())) {
qCDebug(OBEXFTP) << "Stat: " << statUrl.toDisplayString() << entry.stringValue(KIO::UDSEntry::UDS_NAME) << entry.numberValue(KIO::UDSEntry::UDS_SIZE);
m_statMap.insert(statUrl.toDisplayString(), entry);
}
}
- qCDebug(OBEXFTP) << "Finished";
+ *ok = true;
+ return list;
}
-KIO::UDSEntry KioFtp::entryFromInfo(const QVariantMap& info)
+bool KioFtp::changeFolder(const QString &folder)
{
- qCDebug(OBEXFTP) << info;
+ QDBusPendingReply<> reply = m_transfer->ChangeFolder(folder);
+ reply.waitForFinished();
+
+ if (reply.isError()) {
+ error(KIO::ERR_CANNOT_ENTER_DIRECTORY, folder);
+ return false;
+ }
+ return true;
+}
- KIO::UDSEntry entry;
- entry.insert(KIO::UDSEntry::UDS_NAME, info[QStringLiteral("Name")].toString());
- entry.insert(KIO::UDSEntry::UDS_CREATION_TIME, info[QStringLiteral("Created")].toString());
- entry.insert(KIO::UDSEntry::UDS_ACCESS, 0700);
- entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, info[QStringLiteral("Modified")].toString());
+bool KioFtp::createFolder(const QString &folder)
+{
+ QDBusPendingReply<> reply = m_transfer->CreateFolder(folder);
+ reply.waitForFinished();
- if (info[QStringLiteral("Type")].toString() == QLatin1String("folder")) {
- entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
- entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory"));
- } else {
- entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
- entry.insert(KIO::UDSEntry::UDS_SIZE, info[QStringLiteral("Size")].toLongLong());
+ if (reply.isError()) {
+ error(KIO::ERR_COULD_NOT_MKDIR, folder);
+ return false;
}
+ return true;
+}
- return entry;
+bool KioFtp::copyFile(const QString &src, const QString &dest)
+{
+ QDBusPendingReply<> reply = m_transfer->CopyFile(src, dest);
+ reply.waitForFinished();
+
+ if (reply.isError()) {
+ qCDebug(OBEXFTP) << reply.error().message();
+ // Copying files within obexftp is currently not implemented in obexd
+ if (reply.error().message() == QLatin1String("Not Implemented")) {
+ error(KIO::ERR_UNSUPPORTED_ACTION, src);
+ } else {
+ error(KIO::ERR_COULD_NOT_WRITE, src);
+ }
+ return false;
+ }
+ return true;
+}
+
+bool KioFtp::deleteFile(const QString &file)
+{
+ QDBusPendingReply<> reply = m_transfer->Delete(file);
+ reply.waitForFinished();
+
+ if (reply.isError()) {
+ error(KIO::ERR_CANNOT_DELETE, file);
+ return false;
+ }
+ return true;
+}
+
+void KioFtp::updateRootEntryIcon(KIO::UDSEntry &entry, const QString &memoryType)
+{
+ const QString &path = entry.stringValue(KIO::UDSEntry::UDS_NAME);
+
+ // Nokia (mount-points are C: D: E: ...)
+ if (path.size() == 2 && path.at(1) == QLatin1Char(':')) {
+ if (memoryType.startsWith(QLatin1String("DEV"))) {
+ entry.insert(KIO::UDSEntry::UDS_ICON_NAME, QStringLiteral("drive-removable-media"));
+ } else if (memoryType == QLatin1String("MMC")) {
+ entry.insert(KIO::UDSEntry::UDS_ICON_NAME, QStringLiteral("media-flash-sd-mmc"));
+ }
+ }
+ // Android
+ if (entry.stringValue(KIO::UDSEntry::UDS_NAME) == QLatin1String("PHONE_MEMORY")) {
+ entry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, i18n("Phone memory"));
+ entry.insert(KIO::UDSEntry::UDS_ICON_NAME, QStringLiteral("smartphone"));
+ } else if (entry.stringValue(KIO::UDSEntry::UDS_NAME) == QLatin1String("EXTERNAL_MEMORY")) {
+ entry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, i18n("External memory"));
+ entry.insert(KIO::UDSEntry::UDS_ICON_NAME, QStringLiteral("media-flash-sd-mmc"));
+ }
}
diff --git a/src/kio/obexftp/kio_obexftp.h b/src/kio/obexftp/kio_obexftp.h
index 3215fda218c83527ada97d489d00437fedb5e5c1..eefda10852a14475490d6e9cad416d8195bd1d49 100644
--- a/src/kio/obexftp/kio_obexftp.h
+++ b/src/kio/obexftp/kio_obexftp.h
@@ -29,6 +29,8 @@
#include <kio/slavebase.h>
+typedef QMap<QString, QString> DeviceInfo;
+
class OrgBluezObexFileTransfer1Interface;
class KioFtp
: public QObject
@@ -49,26 +51,39 @@ public:
virtual void rename(const QUrl& src, const QUrl& dest, KIO::JobFlags flags);
virtual void get(const QUrl& url);
+ bool cancelTransfer(const QString &transfer);
+
private Q_SLOTS:
void updateProcess();
- KIO::UDSEntry entryFromInfo(const QVariantMap &info);
+private:
void copyHelper(const QUrl &src, const QUrl &dest);
+ void copyWithinObexftp(const QUrl &src, const QUrl &dest);
void copyFromObexftp(const QUrl &src, const QUrl &dest);
void copyToObexftp(const QUrl &src, const QUrl &dest);
void statHelper(const QUrl &url);
+
+ QList<KIO::UDSEntry> listFolder(const QUrl &url, bool *ok);
+ bool changeFolder(const QString &folder);
+ bool createFolder(const QString &folder);
+ bool copyFile(const QString &src, const QString &dest);
+ bool deleteFile(const QString &file);
+
+ void updateRootEntryIcon(KIO::UDSEntry &entry, const QString &memoryType);
void launchProgressBar();
+ void connectToHost();
+ bool testConnection();
+ bool createSession(const QString &target);
private:
- int m_counter;
- bool m_settingHost;
+ int m_counter;
QMap<QString, KIO::UDSEntry> m_statMap;
- QString m_address;
- QString m_sessionPath;
- QTimer *m_timer;
- org::kde::ObexFtp *m_kded;
+ QString m_host;
+ QString m_uuids;
+ QString m_sessionPath;
+ QTimer *m_timer;
+ org::kde::ObexFtp *m_kded;
OrgBluezObexFileTransfer1Interface *m_transfer;
-
};
#endif // KIO_OBEXFTP_H
diff --git a/src/kio/obexftp/transferfilejob.cpp b/src/kio/obexftp/transferfilejob.cpp
index b6267e38fb47336e400fa378019e99aad93c4547..9a0653490766e94031e319115d30d9601967c00f 100644
--- a/src/kio/obexftp/transferfilejob.cpp
+++ b/src/kio/obexftp/transferfilejob.cpp
@@ -35,7 +35,6 @@ TransferFileJob::TransferFileJob(const QString& path, KioFtp* parent)
, m_speedBytes(0)
, m_parent(parent)
{
-
}
TransferFileJob::~TransferFileJob()
@@ -51,16 +50,7 @@ void TransferFileJob::start()
bool TransferFileJob::doKill()
{
- QDBusPendingReply <void > reply = m_transfer->Cancel();
- reply.waitForFinished();
-
- return !reply.isError();
-}
-
-void TransferFileJob::setSize(int size)
-{
- qCDebug(OBEXFTP) << size;
- m_parent->totalSize(size);
+ return m_parent->cancelTransfer(m_path);
}
void TransferFileJob::createObjects()
@@ -98,7 +88,6 @@ void TransferFileJob::statusChanged(const QVariant& value)
m_time = QTime::currentTime();
return;
} else if (status == QLatin1String("complete")) {
- m_parent->finished();
emitResult();
return;
} else if (status == QLatin1String("error")) {
@@ -115,7 +104,7 @@ void TransferFileJob::transferChanged(const QVariant& value)
qCDebug(OBEXFTP) << "Transferred: " << value;
if (m_parent->wasKilled()) {
qCDebug(OBEXFTP) << "Kio was killed, aborting task";
- m_transfer->Cancel().waitForFinished();
+ doKill();
emitResult();
return;
}
diff --git a/src/kio/obexftp/transferfilejob.h b/src/kio/obexftp/transferfilejob.h
index d82cd307a5d7a81a2f2a05092d69e3583be48516..d594359544e0139ae51852a288edf98c2708a9a6 100644
--- a/src/kio/obexftp/transferfilejob.h
+++ b/src/kio/obexftp/transferfilejob.h
@@ -39,7 +39,6 @@ public:
virtual ~TransferFileJob();
- void setSize(int size);
private Q_SLOTS:
void createObjects();
void propertiesChanged(const QString &interface , const QVariantMap &properties , const QStringList &invalidProps);
@@ -56,4 +55,4 @@ private:
};
-#endif //KIO_GET_FILE_JOB_H
\ No newline at end of file
+#endif //KIO_GET_FILE_JOB_H
diff --git a/src/monolithic/CMakeLists.txt b/src/monolithic/CMakeLists.txt
index f39964ea5c3c9b69af93a6ff9e1557069ad017c2..685e30f6ae0e11ae95c2285f119e540ecb45185f 100644
--- a/src/monolithic/CMakeLists.txt
+++ b/src/monolithic/CMakeLists.txt
@@ -17,4 +17,4 @@ target_link_libraries(bluedevil-monolithic
${LibBlueDevil_LIBRARIES})
install(TARGETS bluedevil-monolithic ${INSTALL_TARGETS_DEFAULT_ARGS})
-install(FILES bluedevil-monolithic.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
+install(FILES org.kde.bluedevilmonolithic.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
diff --git a/src/monolithic/main.cpp b/src/monolithic/main.cpp
index ae560a7c7f8c741c1bb01112782e787da3af3b1d..13ae42eebe10c322e4dbcbd2d1b4be6589c65910 100644
--- a/src/monolithic/main.cpp
+++ b/src/monolithic/main.cpp
@@ -42,11 +42,11 @@ int main(int argc, char *argv[])
QStringLiteral("ereslibre@kde.org"), QStringLiteral("http://www.ereslibre.es/"));
QApplication app(argc, argv);
- app.setApplicationName(QStringLiteral("bluedevilmonolithic"));
- app.setApplicationVersion(bluedevil_version);
- app.setOrganizationDomain(QStringLiteral("kde.org"));
app.setQuitOnLastWindowClosed(false);
+ KAboutData::setApplicationData(aboutData);
+ KDBusService service(KDBusService::Unique);
+
QCommandLineParser parser;
parser.setApplicationDescription(i18n("Bluetooth"));
parser.addVersionOption();
@@ -54,7 +54,6 @@ int main(int argc, char *argv[])
parser.process(app);
- KDBusService service(KDBusService::Unique);
Monolithic monolithic;
return app.exec();
diff --git a/src/monolithic/monolithic.cpp b/src/monolithic/monolithic.cpp
index 548075235e6a82ac6dc349b26866d17bcc0e41e3..fb6a23cbd5fcd0f3aa339a69e0151be1c0f92db9 100644
--- a/src/monolithic/monolithic.cpp
+++ b/src/monolithic/monolithic.cpp
@@ -47,7 +47,7 @@ Monolithic::Monolithic(QObject* parent)
offlineMode();
- if (!Manager::self()->adapters().isEmpty()) {
+ if (Manager::self()->usableAdapter()) {
onlineMode();
}
@@ -58,7 +58,6 @@ Monolithic::Monolithic(QObject* parent)
setStandardActionsEnabled(false);
setAssociatedWidget(contextMenu());
- setStatus(KStatusNotifierItem::Active);
poweredChanged();
}
@@ -175,9 +174,11 @@ void Monolithic::regenerateDeviceEntries()
//Shortcut configuration actions, mainly checkables for discovering and powering
menu->addSeparator();
+ Adapter *usableAdapter = Manager::self()->usableAdapter();
+
QAction *discoverable = new QAction(i18n("Discoverable"), menu);
discoverable->setCheckable(true);
- discoverable->setChecked(Manager::self()->usableAdapter()->isDiscoverable());
+ discoverable->setChecked(usableAdapter && usableAdapter->isDiscoverable());
connect(discoverable, SIGNAL(toggled(bool)), this, SLOT(activeDiscoverable(bool)));
menu->addAction(discoverable);
@@ -219,6 +220,8 @@ void Monolithic::setupDevice(Device *device)
void Monolithic::onlineMode()
{
+ setStatus(Active);
+
QList<Adapter*> adapters = Manager::self()->adapters();
Q_FOREACH(Adapter *adapter, adapters) {
connect(adapter, SIGNAL(deviceFound(Device*)), SLOT(deviceCreated(Device*)));
@@ -350,6 +353,7 @@ void Monolithic::deviceCreated(Device *device)
void Monolithic::offlineMode()
{
+ setStatus(Passive);
setTooltipTitleStatus(false);
QMenu *const menu = contextMenu();
diff --git a/src/monolithic/monolithic.h b/src/monolithic/monolithic.h
index 00baf1bbafea44953439727f561e9cec23c1d1a4..cb13cadb4b6a8763e088c01af393b16fa0fcf6ee 100644
--- a/src/monolithic/monolithic.h
+++ b/src/monolithic/monolithic.h
@@ -22,7 +22,8 @@
#include <kstatusnotifieritem.h>
-namespace BlueDevil {
+namespace BlueDevil
+{
class Adapter;
class Device;
}
@@ -31,8 +32,7 @@ class QAction;
using namespace BlueDevil;
-class Monolithic
- : public KStatusNotifierItem
+class Monolithic : public KStatusNotifierItem
{
Q_OBJECT
diff --git a/src/monolithic/org.kde.bluedevilmonolithic.desktop b/src/monolithic/org.kde.bluedevilmonolithic.desktop
new file mode 100644
index 0000000000000000000000000000000000000000..f4572ef1765b0bf262c545505d2a6e98fd3c3a6f
--- /dev/null
+++ b/src/monolithic/org.kde.bluedevilmonolithic.desktop
@@ -0,0 +1,98 @@
+[Desktop Entry]
+Name=BlueDevil
+Name[bs]=BlueDevil
+Name[ca]=BlueDevil
+Name[cs]=BlueDevil
+Name[de]=BlueDevil
+Name[el]=BlueDevil
+Name[en_GB]=BlueDevil
+Name[es]=BlueDevil
+Name[fi]=BlueDevil
+Name[fr]=BlueDevil
+Name[it]=BlueDevil
+Name[ja]=BlueDevil
+Name[nb]=BlueDevil
+Name[nl]=BlueDevil
+Name[pl]=BlueDevil
+Name[pt]=BlueDevil
+Name[pt_BR]=BlueDevil
+Name[sk]=BlueDevil
+Name[sl]=BlueDevil
+Name[sr]=Блудевил
+Name[sr@ijekavian]=Блудевил
+Name[sr@ijekavianlatin]=BlueDevil
+Name[sr@latin]=BlueDevil
+Name[sv]=Blådjävul
+Name[tr]=BlueDevil
+Name[uk]=BlueDevil
+Name[x-test]=xxBlueDevilxx
+Name[zh_CN]=BlueDevil
+Name[zh_TW]=BlueDevil
+GenericName=BlueDevil
+GenericName[bs]=BlueDevil
+GenericName[ca]=BlueDevil
+GenericName[cs]=BlueDevil
+GenericName[de]=BlueDevil
+GenericName[el]=BlueDevil
+GenericName[en_GB]=BlueDevil
+GenericName[es]=BlueDevil
+GenericName[fi]=BlueDevil
+GenericName[fr]=BlueDevil
+GenericName[it]=BlueDevil
+GenericName[ja]=BlueDevil
+GenericName[nb]=BlueDevil
+GenericName[nl]=BlueDevil
+GenericName[pa]=BlueDevil
+GenericName[pl]=BlueDevil
+GenericName[pt]=BlueDevil
+GenericName[pt_BR]=BlueDevil
+GenericName[sk]=BlueDevil
+GenericName[sl]=BlueDevil
+GenericName[sr]=Блудевил
+GenericName[sr@ijekavian]=Блудевил
+GenericName[sr@ijekavianlatin]=BlueDevil
+GenericName[sr@latin]=BlueDevil
+GenericName[sv]=Blådjävul
+GenericName[tr]=BlueDevil
+GenericName[uk]=BlueDevil
+GenericName[x-test]=xxBlueDevilxx
+GenericName[zh_CN]=BlueDevil
+GenericName[zh_TW]=BlueDevil
+Comment=KDE Bluetooth support
+Comment[bs]=Podrška blututa u KDEu
+Comment[ca]=Implementació Bluetooth del KDE
+Comment[cs]=Podpora Bluetooth v KDE
+Comment[de]=KDE-Bluetooth-Unterstützung
+Comment[el]=Υποστήριξη Bluetooth στο KDE
+Comment[en_GB]=KDE Bluetooth support
+Comment[es]=Implementación Bluetooth para KDE
+Comment[fi]=KDE:n Bluetooth-tuki
+Comment[fr]=Prise en charge de Bluetooth pour KDE
+Comment[it]=Supporto Bluetooth per KDE
+Comment[ja]=KDE Bluetooth サポート
+Comment[nb]=KDE Blåtann-støtte
+Comment[nl]=KDE Bluetooth ondersteuning
+Comment[pa]=KDE ਬਲਿਊਟੁੱਥ ਸਹਿਯੋਗ
+Comment[pl]=Obsługa Bluetooth w KDE
+Comment[pt]=Suporte para Bluetooth no KDE
+Comment[pt_BR]=Suporte para Bluetooth do KDE
+Comment[sk]=Podpora Bluetooth KDE
+Comment[sl]=KDE-jeva podpora za Bluetooth
+Comment[sr]=Подршка блутута у КДЕ‑у
+Comment[sr@ijekavian]=Подршка блутута у КДЕ‑у
+Comment[sr@ijekavianlatin]=Podrška Bluetootha u KDEu
+Comment[sr@latin]=Podrška Bluetootha u KDEu
+Comment[sv]=KDE:s Blåtandstöd
+Comment[tr]=KDE Bluetooth desteği
+Comment[uk]=Підтримка Bluetooth у KDE
+Comment[x-test]=xxKDE Bluetooth supportxx
+Comment[zh_CN]=KDE 蓝牙支持
+Comment[zh_TW]=KDE 藍牙支援
+
+Type=Application
+Exec=bluedevil-monolithic
+Icon=preferences-system-bluetooth
+Terminal=false
+Categories=Qt;KDE;X-Bluetooth;Network;
+X-DBUS-StartupType=Unique
+X-DBUS-ServiceName=org.kde.bluedevilmonolithic
diff --git a/src/sendfile/CMakeLists.txt b/src/sendfile/CMakeLists.txt
index 9004cbe2b7d7828711a8d70c13fc99de5efa3693..c0ea4c72544a998ca06ba6b32e600b749ca3b069 100644
--- a/src/sendfile/CMakeLists.txt
+++ b/src/sendfile/CMakeLists.txt
@@ -32,10 +32,11 @@ target_link_libraries(bluedevil-sendfile
Qt5::DBus
KF5::I18n
KF5::CoreAddons
+ KF5::DBusAddons
KF5::IconThemes
KF5::KIOFileWidgets
${LibBlueDevil_LIBRARIES}
)
install(TARGETS bluedevil-sendfile DESTINATION ${INSTALL_TARGETS_DEFAULT_ARGS})
-install(FILES bluedevil-sendfile.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
+install(FILES org.kde.bluedevilsendfile.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
diff --git a/src/sendfile/discoverwidget.cpp b/src/sendfile/discoverwidget.cpp
index 903da161c7c9e76e02bfa44628c532c41686d3ad..4cb5af9471e7fae5688818700153deb10489847a 100644
--- a/src/sendfile/discoverwidget.cpp
+++ b/src/sendfile/discoverwidget.cpp
@@ -20,9 +20,9 @@
* Boston, MA 02110-1301, USA. *
*****************************************************************************/
-
#include "discoverwidget.h"
#include "ui_discover.h"
+#include "debug_p.h"
#include <QListWidgetItem>
#include <QListView>
@@ -35,28 +35,23 @@
using namespace BlueDevil;
-DiscoverWidget::DiscoverWidget(QWidget* parent) : QWidget(parent)
+DiscoverWidget::DiscoverWidget(QWidget* parent)
+ : QWidget(parent)
{
setupUi(this);
- connect(deviceList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this,
- SLOT(itemSelected(QListWidgetItem*)));
- connect(Manager::self()->usableAdapter(), SIGNAL(deviceFound(Device*)), this,
- SLOT(deviceFound(Device*)));
+ connect(deviceList, &QListWidget::currentItemChanged, this, &DiscoverWidget::itemSelected);
+ connect(Manager::self()->usableAdapter(), &Adapter::deviceFound, this, &DiscoverWidget::deviceFound);
startScan();
}
-DiscoverWidget::~DiscoverWidget()
-{
-}
-
void DiscoverWidget::startScan()
{
deviceList->clear();
stopScan();
- QList <Device *> knownDevices = Manager::self()->usableAdapter()->devices();
+ QList<Device*> knownDevices = Manager::self()->usableAdapter()->devices();
Q_FOREACH(Device *device, knownDevices) {
if (device->UUIDs().contains(QLatin1String("00001105-0000-1000-8000-00805F9B34FB"), Qt::CaseInsensitive)) {
deviceFound(device);
@@ -72,27 +67,19 @@ void DiscoverWidget::stopScan()
}
}
-void DiscoverWidget::deviceFound(const QVariantMap& deviceInfo)
-{
- deviceFoundGeneric(deviceInfo[QStringLiteral("Address")].toString(),
- deviceInfo[QStringLiteral("Name")].toString(),
- deviceInfo[QStringLiteral("Icon")].toString(),
- deviceInfo[QStringLiteral("Alias")].toString());
-}
-
-void DiscoverWidget::deviceFound(Device* device)
+void DiscoverWidget::deviceFound(Device *device)
{
deviceFoundGeneric(device->address(), device->name(), device->icon(), device->alias());
}
void DiscoverWidget::deviceFoundGeneric(QString address, QString name, QString icon, QString alias)
{
- qDebug() << "========================";
- qDebug() << "Address: " << address;
- qDebug() << "Name: " << name;
- qDebug() << "Alias: " << alias;
- qDebug() << "Icon: " << icon;
- qDebug() << "\n";
+ qCDebug(SENDFILE) << "========================";
+ qCDebug(SENDFILE) << "Address: " << address;
+ qCDebug(SENDFILE) << "Name: " << name;
+ qCDebug(SENDFILE) << "Alias: " << alias;
+ qCDebug(SENDFILE) << "Icon: " << icon;
+ qCDebug(SENDFILE) << "\n";
bool origName = false;
@@ -101,7 +88,7 @@ void DiscoverWidget::deviceFoundGeneric(QString address, QString name, QString i
}
if (!alias.isEmpty() && alias != name && !name.isEmpty()) {
- name = QString("%1 (%2)").arg(alias).arg(name);
+ name = QString(QStringLiteral("%1 (%2)")).arg(alias).arg(name);
}
if (name.isEmpty()) {
@@ -131,7 +118,7 @@ void DiscoverWidget::deviceFoundGeneric(QString address, QString name, QString i
m_itemRelation.insert(address, item);
}
-void DiscoverWidget::itemSelected(QListWidgetItem* item)
+void DiscoverWidget::itemSelected(QListWidgetItem *item)
{
emit deviceSelected(Manager::self()->usableAdapter()->deviceForAddress(item->data(Qt::UserRole).toString()));
}
diff --git a/src/sendfile/discoverwidget.h b/src/sendfile/discoverwidget.h
index d1cc03bb6decf90df8754c4c8d8f9e062aca3311..3516c61901b09652d49c67776dc3ffb8c0811cdb 100644
--- a/src/sendfile/discoverwidget.h
+++ b/src/sendfile/discoverwidget.h
@@ -20,7 +20,6 @@
* Boston, MA 02110-1301, USA. *
*****************************************************************************/
-
#ifndef DISCOVERWIDGET_H
#define DISCOVERWIDGET_H
@@ -31,28 +30,26 @@
class QTimer;
class BlueWizard;
-namespace BlueDevil {
+namespace BlueDevil
+{
class Device;
}
-using namespace BlueDevil;
-class DiscoverWidget : public QWidget
-, public Ui::Discover
+class DiscoverWidget : public QWidget, public Ui::Discover
{
-Q_OBJECT
+ Q_OBJECT
public:
- DiscoverWidget(QWidget* parent = 0);
- virtual ~DiscoverWidget();
+ explicit DiscoverWidget(QWidget *parent = 0);
+
void stopScan();
public Q_SLOTS:
void startScan();
private Q_SLOTS:
- void deviceFound(const QVariantMap &deviceInfo);
- void deviceFound(Device* device);
- void itemSelected(QListWidgetItem* item);
+ void deviceFound(BlueDevil::Device *device);
+ void itemSelected(QListWidgetItem *item);
private:
void deviceFoundGeneric(QString address, QString name, QString icon, QString alias);
@@ -62,7 +59,7 @@ private:
BlueWizard *m_wizard;
Q_SIGNALS:
- void deviceSelected(Device *device);
+ void deviceSelected(BlueDevil::Device *device);
};
#endif // DISCOVERWIDGET_H
diff --git a/src/sendfile/main.cpp b/src/sendfile/main.cpp
index 1b1bb8bdd8b709ecf4478769d2c6e2f175fbfa57..4f593d37e728b563c668a7cdd0ea72a4d9fdfd98 100644
--- a/src/sendfile/main.cpp
+++ b/src/sendfile/main.cpp
@@ -25,6 +25,7 @@
#include <QCommandLineOption>
#include <KAboutData>
+#include <KDBusService>
#include <KLocalizedString>
#include <bluedevil/bluedevil.h>
@@ -44,13 +45,12 @@ int main(int argc, char *argv[])
QStringLiteral("afiestas@kde.org"), QStringLiteral("http://www.afiestas.org/"));
QApplication app(argc, argv);
- app.setApplicationName(QStringLiteral("bluedevilsendfile"));
- app.setApplicationVersion(bluedevil_version);
- app.setApplicationDisplayName(i18n("Bluetooth Send File Helper"));
- app.setOrganizationDomain(QStringLiteral("kde.org"));
app.setWindowIcon(QIcon::fromTheme(QStringLiteral("preferences-system-bluetooth")));
app.setQuitOnLastWindowClosed(false);
+ KAboutData::setApplicationData(aboutData);
+ KDBusService service;
+
QCommandLineOption kioOption({QLatin1String("kio"), QLatin1String("k")}, i18n("Device UUID where the files will be sent"));
kioOption.setValueName(QStringLiteral("bluetooth://mac"));
@@ -75,8 +75,12 @@ int main(int argc, char *argv[])
deviceInfo = parser.value(kioOption);
}
- SendFileWizard *sendFileWizard = new SendFileWizard(deviceInfo, parser.values(filesOption));
- sendFileWizard->show();
+ SendFileWizard *wizard = new SendFileWizard(deviceInfo, parser.values(filesOption));
+ wizard->show();
+
+ QObject::connect(&service, &KDBusService::activateRequested, wizard, [wizard]() {
+ wizard->setWindowState((wizard->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
+ });
return app.exec();
}
diff --git a/src/sendfile/org.kde.bluedevilsendfile.desktop b/src/sendfile/org.kde.bluedevilsendfile.desktop
new file mode 100644
index 0000000000000000000000000000000000000000..d976633fa00c3439184bc71a5ba57dfb71911f57
--- /dev/null
+++ b/src/sendfile/org.kde.bluedevilsendfile.desktop
@@ -0,0 +1,94 @@
+[Desktop Entry]
+Name=BlueDevil Send File
+Name[bs]=Bludevilovo slanje datoteke
+Name[ca]=Envia fitxer amb BlueDevil
+Name[cs]=Posílání souborů BlueDevil
+Name[de]=BlueDevil-Dateiversand
+Name[el]=Αποστολή αρχείου μέσω BlueDevil
+Name[en_GB]=BlueDevil Send File
+Name[es]=Enviar archivo con BlueDevil
+Name[fi]=BlueDevil-tiedostonlähetys
+Name[fr]=Envoi de fichiers par BlueDevil
+Name[it]=Invio file di BlueDevil
+Name[nb]=BlueDevil send fil
+Name[nl]=BlueDevil bestand verzenden
+Name[pl]=Wysłanie pliku BlueDevil
+Name[pt]=Envio de Ficheiro do Bluetooth
+Name[pt_BR]=Envio de arquivo do BlueDevil
+Name[sk]=Posielanie súborov BlueDevil
+Name[sl]=BlueDevil pošiljanje datotek
+Name[sr]=Блудевилово слање фајла
+Name[sr@ijekavian]=Блудевилово слање фајла
+Name[sr@ijekavianlatin]=BlueDevilovo slanje fajla
+Name[sr@latin]=BlueDevilovo slanje fajla
+Name[sv]=Blådjävul skicka fil
+Name[tr]=BlueDevil Dosya Gönder
+Name[uk]=Надсилання файла BlueDevil
+Name[x-test]=xxBlueDevil Send Filexx
+Name[zh_CN]=BlueDevil 发送文件
+Name[zh_TW]=BlueDevil 傳送檔案
+GenericName=BlueDevil Send File
+GenericName[bs]=Bludevilovo slanje datoteke
+GenericName[ca]=Envia fitxers amb BlueDevil
+GenericName[cs]=Posílání souborů BlueDevil
+GenericName[de]=BlueDevil-Dateiversand
+GenericName[el]=Αποστολή αρχείου μέσω BlueDevil
+GenericName[en_GB]=BlueDevil Send File
+GenericName[es]=Enviar archivo con BlueDevil
+GenericName[fi]=BlueDevil-tiedostonlähetys
+GenericName[fr]=Envoi de fichiers par BlueDevil
+GenericName[it]=Invio file di BlueDevil
+GenericName[nb]=BlueDevil send fil
+GenericName[nl]=BlueDevil bestand verzenden
+GenericName[pl]=Wysłanie pliku BlueDevil
+GenericName[pt]=Envio de Ficheiro do Bluetooth
+GenericName[pt_BR]=Envio de arquivo do BlueDevil
+GenericName[sk]=Posielanie súborov BlueDevil
+GenericName[sl]=BlueDevil pošiljanje datotek
+GenericName[sr]=Блудевилово слање фајла
+GenericName[sr@ijekavian]=Блудевилово слање фајла
+GenericName[sr@ijekavianlatin]=BlueDevilovo slanje fajla
+GenericName[sr@latin]=BlueDevilovo slanje fajla
+GenericName[sv]=Blådjävul skicka fil
+GenericName[tr]=BlueDevil Dosya Gönder
+GenericName[uk]=Надсилання файла BlueDevil
+GenericName[x-test]=xxBlueDevil Send Filexx
+GenericName[zh_CN]=BlueDevil 发送文件
+GenericName[zh_TW]=BlueDevil 傳送檔案
+Comment=BlueDevil Send File
+Comment[bs]=Bludevilovo slanje datoteke
+Comment[ca]=Envia fitxers amb BlueDevil
+Comment[cs]=Posílání souborů BlueDevil
+Comment[de]=BlueDevil-Dateiversand
+Comment[el]=Αποστολή αρχείου μέσω BlueDevil
+Comment[en_GB]=BlueDevil Send File
+Comment[es]=Enviar archivo con BlueDevil
+Comment[fi]=BlueDevil-tiedostonlähetys
+Comment[fr]=Envoi de fichiers par BlueDevil
+Comment[it]=Invio file di BlueDevil
+Comment[nb]=BlueDevil send fil
+Comment[nl]=BlueDevil bestand verzenden
+Comment[pl]=Wysłanie pliku BlueDevil
+Comment[pt]=Envio de Ficheiro do Bluetooth
+Comment[pt_BR]=Envio de arquivo do BlueDevil
+Comment[sk]=Posielanie súborov BlueDevil
+Comment[sl]=BlueDevil pošiljanje datotek
+Comment[sr]=Блудевилово слање фајла
+Comment[sr@ijekavian]=Блудевилово слање фајла
+Comment[sr@ijekavianlatin]=BlueDevilovo slanje fajla
+Comment[sr@latin]=BlueDevilovo slanje fajla
+Comment[sv]=Blådjävul skicka fil
+Comment[tr]=BlueDevil Dosya Gönder
+Comment[uk]=Надсилання файла BlueDevil
+Comment[x-test]=xxBlueDevil Send Filexx
+Comment[zh_CN]=BlueDevil 发送文件
+Comment[zh_TW]=BlueDevil 傳送檔案
+
+Type=Application
+MimeType=application/vnd.kde.bluedevil-sendfile;
+Exec=bluedevil-sendfile -k%U
+Icon=preferences-system-bluetooth
+Terminal=false
+NoDisplay=true
+Categories=Qt;KDE;X-Bluetooth;Network;
+X-DBUS-ServiceName=org.kde.bluedevilsendfile
diff --git a/src/sendfile/pages/connecting.ui b/src/sendfile/pages/connecting.ui
index 10d9d7ea41d62efdd50146d715508f3cc6c6be34..fc2bf06b3c33b0604f2479b2bec85e7034daafa4 100644
--- a/src/sendfile/pages/connecting.ui
+++ b/src/sendfile/pages/connecting.ui
@@ -12,11 +12,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
- <widget class="QLabel" name="connLabel">
- <property name="text">
- <string>Connecting to: %1</string>
- </property>
- </widget>
+ <widget class="QLabel" name="connLabel"/>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
diff --git a/src/sendfile/pages/connectingpage.cpp b/src/sendfile/pages/connectingpage.cpp
index 8d18c3dfecd5f513f088dd53d2f1d2eeddeb2dfd..1c34ed5f555951c190fe2683ae5f7f579573ca55 100644
--- a/src/sendfile/pages/connectingpage.cpp
+++ b/src/sendfile/pages/connectingpage.cpp
@@ -29,7 +29,8 @@
using namespace BlueDevil;
-ConnectingPage::ConnectingPage(QWidget* parent): QWizardPage(parent)
+ConnectingPage::ConnectingPage(QWidget *parent)
+ : QWizardPage(parent)
{
setupUi(this);
}
diff --git a/src/sendfile/pages/connectingpage.h b/src/sendfile/pages/connectingpage.h
index 935b394bd40cfef8ecbd6687d8c2f76cb23237ca..2834cfafc4626171d4ca569c9f9d5321b548e26b 100644
--- a/src/sendfile/pages/connectingpage.h
+++ b/src/sendfile/pages/connectingpage.h
@@ -27,15 +27,14 @@
#include <QWizardPage>
-class ConnectingPage : public QWizardPage,
-public Ui::Connecting
+class ConnectingPage : public QWizardPage, public Ui::Connecting
{
-Q_OBJECT
+ Q_OBJECT
public:
- ConnectingPage(QWidget* parent = 0);
+ explicit ConnectingPage(QWidget *parent = 0);
- virtual void initializePage();
- virtual bool isComplete() const;
+ void initializePage() Q_DECL_OVERRIDE;
+ bool isComplete() const Q_DECL_OVERRIDE;
};
#endif // CONNECTINGPAGE_H
diff --git a/src/sendfile/pages/selectdeviceandfilespage.cpp b/src/sendfile/pages/selectdeviceandfilespage.cpp
index 0c8d07976dbee6beff8aba7f23be698d4da0a4b3..b22d90729225f99296a142894ebb4decc865f63a 100644
--- a/src/sendfile/pages/selectdeviceandfilespage.cpp
+++ b/src/sendfile/pages/selectdeviceandfilespage.cpp
@@ -39,7 +39,10 @@
#include <bluedevil/bluedevil.h>
using namespace BlueDevil;
-SelectDeviceAndFilesPage::SelectDeviceAndFilesPage(QWidget* parent): QWizardPage(parent), m_dialog(0)
+
+SelectDeviceAndFilesPage::SelectDeviceAndFilesPage(QWidget *parent)
+ : QWizardPage(parent)
+ , m_dialog(0)
{
setupUi(this);
@@ -56,24 +59,22 @@ SelectDeviceAndFilesPage::SelectDeviceAndFilesPage(QWidget* parent): QWizardPage
selectBtn->setFixedSize(buttonSize, buttonSize);
selectBtn->setIcon(QIcon::fromTheme(QStringLiteral("document-open")));
- connect(widget, SIGNAL(deviceSelected(Device*)), this, SLOT(deviceSelected(Device*)));
- connect(selectBtn, SIGNAL(clicked(bool)), this, SLOT(openFileDialog()));
+ connect(widget, &DiscoverWidget::deviceSelected, this, &SelectDeviceAndFilesPage::deviceSelected);
+ connect(selectBtn, &QPushButton::clicked, this, &SelectDeviceAndFilesPage::openFileDialog);
}
-
-void SelectDeviceAndFilesPage::deviceSelected(Device* device)
+void SelectDeviceAndFilesPage::deviceSelected(Device *device)
{
if (!device->name().isEmpty()) {
- static_cast<SendFileWizard* >(wizard())->setDevice(device);
+ static_cast<SendFileWizard*>(wizard())->setDevice(device);
} else {
- static_cast<SendFileWizard* >(wizard())->setDevice(0);
+ static_cast<SendFileWizard*>(wizard())->setDevice(0);
}
emit completeChanged();
}
void SelectDeviceAndFilesPage::openFileDialog()
{
- //Don't worry MLaurent, I'm not going to check the pointer before delete it :)
delete m_dialog;
m_dialog = new QFileDialog(this, i18n("Open file..."),
@@ -99,7 +100,7 @@ void SelectDeviceAndFilesPage::selectionChanged()
bool SelectDeviceAndFilesPage::isComplete() const
{
- if (!static_cast<SendFileWizard* >(wizard())->device()) {
+ if (!static_cast<SendFileWizard*>(wizard())->device()) {
return false;
}
diff --git a/src/sendfile/pages/selectdeviceandfilespage.h b/src/sendfile/pages/selectdeviceandfilespage.h
index 19a718b684bf7239cce19f7ef3fa1a0ea90ea53d..f5b50fccbfce8c64996dccdfcee6f7451dc6da47 100644
--- a/src/sendfile/pages/selectdeviceandfilespage.h
+++ b/src/sendfile/pages/selectdeviceandfilespage.h
@@ -31,22 +31,22 @@ class KUrl;
class QWizard;
class QFileDialog;
-namespace BlueDevil {
+namespace BlueDevil
+{
class Device;
}
-using namespace BlueDevil;
-class SelectDeviceAndFilesPage : public QWizardPage ,
- public Ui::SelectFileDiscover
+class SelectDeviceAndFilesPage : public QWizardPage, public Ui::SelectFileDiscover
{
-Q_OBJECT
+ Q_OBJECT
+
public:
- SelectDeviceAndFilesPage(QWidget* parent = 0);
+ explicit SelectDeviceAndFilesPage(QWidget *parent = 0);
- virtual bool isComplete() const;
+ bool isComplete() const Q_DECL_OVERRIDE;
private Q_SLOTS:
- void deviceSelected(Device*);
+ void deviceSelected(BlueDevil::Device *device);
void openFileDialog();
void selectionChanged();
diff --git a/src/sendfile/pages/selectdevicepage.cpp b/src/sendfile/pages/selectdevicepage.cpp
index 01423ddbae316d07c1f8d13292aa71a771141bd4..69a2c84f9d7f800894c15f99378ac1d9901ec9a1 100644
--- a/src/sendfile/pages/selectdevicepage.cpp
+++ b/src/sendfile/pages/selectdevicepage.cpp
@@ -36,7 +36,10 @@
#include <bluedevil/bluedevil.h>
using namespace BlueDevil;
-SelectDevicePage::SelectDevicePage(QWidget* parent): QWizardPage(parent), m_dialog(0)
+
+SelectDevicePage::SelectDevicePage(QWidget *parent) :
+ QWizardPage(parent),
+ m_dialog(0)
{
setupUi(this);
@@ -51,22 +54,22 @@ SelectDevicePage::SelectDevicePage(QWidget* parent): QWizardPage(parent), m_dial
selectBtn->setHidden(true);
selectLbl->setHidden(true);
- connect(widget, SIGNAL(deviceSelected(Device*)), this, SLOT(deviceSelected(Device*)));
+ connect(widget, &DiscoverWidget::deviceSelected, this, &SelectDevicePage::deviceSelected);
}
-void SelectDevicePage::deviceSelected(Device* device)
+void SelectDevicePage::deviceSelected(Device *device)
{
if (!device->name().isEmpty()) {
- static_cast<SendFileWizard* >(wizard())->setDevice(device);
+ static_cast<SendFileWizard*>(wizard())->setDevice(device);
} else {
- static_cast<SendFileWizard* >(wizard())->setDevice(0);
+ static_cast<SendFileWizard*>(wizard())->setDevice(0);
}
emit completeChanged();
}
bool SelectDevicePage::isComplete() const
{
- if (!static_cast<SendFileWizard* >(wizard())->device()) {
+ if (!static_cast<SendFileWizard*>(wizard())->device()) {
return false;
}
diff --git a/src/sendfile/pages/selectdevicepage.h b/src/sendfile/pages/selectdevicepage.h
index 8c4b494a2515118d95954f14feeb437fcd9204e1..18d2cc7ba7bba95e6878fb2e5bcabe8ee7b57fd7 100644
--- a/src/sendfile/pages/selectdevicepage.h
+++ b/src/sendfile/pages/selectdevicepage.h
@@ -30,22 +30,23 @@
class KUrl;
class QWizard;
class KFileDialog;
-namespace BlueDevil {
+
+namespace BlueDevil
+{
class Device;
}
-using namespace BlueDevil;
-class SelectDevicePage : public QWizardPage ,
- public Ui::SelectFileDiscover
+class SelectDevicePage : public QWizardPage, public Ui::SelectFileDiscover
{
-Q_OBJECT
+ Q_OBJECT
+
public:
- SelectDevicePage(QWidget* parent = 0);
+ explicit SelectDevicePage(QWidget *parent = 0);
- virtual bool isComplete() const;
+ bool isComplete() const Q_DECL_OVERRIDE;
private Q_SLOTS:
- void deviceSelected(Device*);
+ void deviceSelected(BlueDevil::Device *device);
private:
KFileDialog *m_dialog;
diff --git a/src/sendfile/pages/selectfilespage.cpp b/src/sendfile/pages/selectfilespage.cpp
index 7362eef89f8125209c6a16342434989d18e91bbd..56ba9afdede07fb74379b63433a66b17eb1eb9f4 100644
--- a/src/sendfile/pages/selectfilespage.cpp
+++ b/src/sendfile/pages/selectfilespage.cpp
@@ -31,14 +31,15 @@
#include <QVBoxLayout>
#include <QLabel>
-SelectFilesPage::SelectFilesPage(QWidget* parent): QWizardPage(parent)
+SelectFilesPage::SelectFilesPage(QWidget *parent)
+ : QWizardPage(parent)
{
m_files = new KFileWidget(QUrl(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)), this);
m_files->setMode(KFile::Files);
m_files->setContentsMargins(0, 0, 0, 0);
setContentsMargins(0, 0, 0, 0);
- connect(m_files, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
+ connect(m_files, &KFileWidget::selectionChanged, this, &SelectFilesPage::selectionChanged);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(m_files);
@@ -48,10 +49,12 @@ void SelectFilesPage::selectionChanged()
{
QStringList fileList;
KFileItemList itemList = m_files->dirOperator()->selectedItems();
- Q_FOREACH(const KFileItem &file, itemList) {
+
+ Q_FOREACH (const KFileItem &file, itemList) {
fileList << file.localPath();
}
- static_cast<SendFileWizard* >(wizard())->setFiles(fileList);
+
+ static_cast<SendFileWizard*>(wizard())->setFiles(fileList);
emit completeChanged();
}
diff --git a/src/sendfile/pages/selectfilespage.h b/src/sendfile/pages/selectfilespage.h
index a8022706dad98b01362e0eec903946fcd4407587..623a21648446516b6816a843597dc6d285bc5cdb 100644
--- a/src/sendfile/pages/selectfilespage.h
+++ b/src/sendfile/pages/selectfilespage.h
@@ -30,11 +30,12 @@ class KFileWidget;
class SelectFilesPage : public QWizardPage
{
-Q_OBJECT
+ Q_OBJECT
+
public:
- SelectFilesPage(QWidget* parent = 0);
+ explicit SelectFilesPage(QWidget *parent = 0);
- virtual bool isComplete() const;
+ bool isComplete() const Q_DECL_OVERRIDE;
private Q_SLOTS:
void selectionChanged();
diff --git a/src/sendfile/sendfilesjob.cpp b/src/sendfile/sendfilesjob.cpp
index 554616b35a63ac8806b0193f0eaf0d38d823b8ec..c943ef0d14880d733160de3ea0f673a89b9f99bc 100644
--- a/src/sendfile/sendfilesjob.cpp
+++ b/src/sendfile/sendfilesjob.cpp
@@ -31,7 +31,8 @@
#include <bluedevil/bluedevil.h>
using namespace BlueDevil;
-SendFilesJob::SendFilesJob(const QStringList& files, Device* device, QObject* parent)
+
+SendFilesJob::SendFilesJob(const QStringList &files, Device *device, QObject *parent)
: KJob(parent)
, m_progress(0)
, m_totalSize(0)
@@ -41,6 +42,7 @@ SendFilesJob::SendFilesJob(const QStringList& files, Device* device, QObject* pa
, m_currentFileProgress(0)
{
qCDebug(SENDFILE) << files;
+
m_filesToSend = files;
Q_FOREACH(const QString &filePath, files) {
@@ -64,14 +66,15 @@ void SendFilesJob::start()
void SendFilesJob::doStart()
{
- qCDebug(SENDFILE);
QVariantMap map;
- map["Target"] = "opp";
+ map[QStringLiteral("Target")] = QStringLiteral("opp");
setTotalAmount(Bytes, m_totalSize);
setProcessedAmount(Bytes, 0);
- emit description(this, i18n("Sending file over Bluetooth"), QPair<QString, QString>(i18nc("File transfer origin", "From"), m_filesToSend.first()), QPair<QString, QString>(i18nc("File transfer destination", "To"), m_device->name()));
+ emit description(this, i18n("Sending file over Bluetooth"),
+ QPair<QString, QString>(i18nc("File transfer origin", "From"), m_filesToSend.first()),
+ QPair<QString, QString>(i18nc("File transfer destination", "To"), m_device->name()));
m_client = new OrgBluezObexClient1Interface(QStringLiteral("org.bluez.obex"),
QStringLiteral("/org/bluez/obex"),
@@ -80,7 +83,7 @@ void SendFilesJob::doStart()
QDBusPendingReply <QDBusObjectPath > reply = m_client->CreateSession(m_device->address(), map);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply);
- connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(createSessionSlot(QDBusPendingCallWatcher*)));
+ connect(watcher, &QDBusPendingCallWatcher::finished, this, &SendFilesJob::createSessionSlot);
}
void SendFilesJob::createSessionSlot(QDBusPendingCallWatcher *call)
@@ -102,14 +105,14 @@ void SendFilesJob::createSessionSlot(QDBusPendingCallWatcher *call)
nextJob();
}
-void SendFilesJob::sendFileSlot(QDBusPendingCallWatcher* watcher)
+void SendFilesJob::sendFileSlot(QDBusPendingCallWatcher *watcher)
{
const QDBusPendingReply<QDBusObjectPath> reply = *watcher;
watcher->deleteLater();
QString path = reply.value().path();
m_props = new OrgFreedesktopDBusPropertiesInterface(QStringLiteral("org.bluez.obex"), path, QDBusConnection::sessionBus(), this);
- connect(m_props, SIGNAL(PropertiesChanged(QString,QVariantMap,QStringList)), SLOT(propertiesChangedSlot(QString,QVariantMap,QStringList)));
+ connect(m_props, &OrgFreedesktopDBusPropertiesInterface::PropertiesChanged, this, &SendFilesJob::propertiesChangedSlot);
}
void SendFilesJob::propertiesChangedSlot(const QString& interface, const QVariantMap& props, const QStringList& invalidProps)
@@ -131,7 +134,8 @@ void SendFilesJob::propertiesChangedSlot(const QString& interface, const QVarian
void SendFilesJob::statusChanged(const QVariant& value)
{
qCDebug(SENDFILE) << value;
- QString status = value.toString();
+
+ const QString &status = value.toString();
if (status == QLatin1String("active")) {
m_time = QTime::currentTime();
@@ -151,6 +155,7 @@ void SendFilesJob::statusChanged(const QVariant& value)
void SendFilesJob::transferChanged(const QVariant& value)
{
qCDebug(SENDFILE) << value;
+
bool ok = false;
qulonglong bytes = value.toULongLong(&ok);
if (!ok) {
@@ -158,7 +163,7 @@ void SendFilesJob::transferChanged(const QVariant& value)
return;
}
- //If a least 1 second has passed since last update
+ // If a least 1 second has passed since last update
int secondsSinceLastTime = m_time.secsTo(QTime::currentTime());
if (secondsSinceLastTime > 0) {
float speed = (bytes - m_speedBytes) / secondsSinceLastTime;
@@ -177,17 +182,18 @@ void SendFilesJob::nextJob()
m_currentFile = m_filesToSend.takeFirst();
m_currentFileSize = m_filesToSendSize.takeFirst();
- emit description(this, i18n("Sending file over Bluetooth"), QPair<QString, QString>(i18nc("File transfer origin", "From"), m_currentFile), QPair<QString, QString>(i18nc("File transfer destination", "To"), m_device->name()));
+ emit description(this, i18n("Sending file over Bluetooth"),
+ QPair<QString, QString>(i18nc("File transfer origin", "From"), m_currentFile),
+ QPair<QString, QString>(i18nc("File transfer destination", "To"), m_device->name()));
QDBusPendingReply<QDBusObjectPath, QVariantMap> fileReply = m_push->SendFile(m_currentFile);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(fileReply);
- connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(sendFileSlot(QDBusPendingCallWatcher*)));
+ connect(watcher, &QDBusPendingCallWatcher::finished, this, &SendFilesJob::sendFileSlot);
}
void SendFilesJob::jobDone()
{
- qCDebug(SENDFILE);
m_speedBytes = 0;
m_currentFileSize = 0;
m_currentFileProgress = 0;
@@ -202,8 +208,6 @@ void SendFilesJob::jobDone()
void SendFilesJob::progress(quint64 transferBytes)
{
- qCDebug(SENDFILE);
-
quint64 toAdd = transferBytes - m_currentFileProgress;
m_currentFileProgress = transferBytes;
m_progress += toAdd;
@@ -213,9 +217,10 @@ void SendFilesJob::progress(quint64 transferBytes)
void SendFilesJob::error(const QDBusObjectPath& transfer, const QString& error)
{
Q_UNUSED(transfer)
+
qCDebug(SENDFILE) << error;
- //if this is the last file, just emit error
+ // If this is the last file, just emit error
if (m_filesToSend.isEmpty()) {
setError(KJob::UserDefinedError);
return;
@@ -225,5 +230,4 @@ void SendFilesJob::error(const QDBusObjectPath& transfer, const QString& error)
m_progress += toAdd;
setProcessedAmount(Bytes, m_progress);
nextJob();
-
}
diff --git a/src/sendfile/sendfilesjob.h b/src/sendfile/sendfilesjob.h
index 28e8ac249d1e94c0f8af22473a23435cfb204733..68580c092790576afcec540c2d242c9fad34a755 100644
--- a/src/sendfile/sendfilesjob.h
+++ b/src/sendfile/sendfilesjob.h
@@ -40,15 +40,14 @@ class OrgBluezObexClient1Interface;
class OrgBluezObexObjectPush1Interface;
class OrgFreedesktopDBusPropertiesInterface;
-using namespace BlueDevil;
class SendFilesJob : public KJob
{
-Q_OBJECT
+ Q_OBJECT
public:
- SendFilesJob(const QStringList &files, BlueDevil::Device* device, QObject* parent = 0);
+ explicit SendFilesJob(const QStringList &files, BlueDevil::Device *device, QObject *parent = 0);
- virtual void start();
- virtual bool doKill();
+ void start() Q_DECL_OVERRIDE;
+ bool doKill() Q_DECL_OVERRIDE;
private Q_SLOTS:
void doStart();
@@ -56,26 +55,25 @@ private Q_SLOTS:
void nextJob();
void jobDone();
void progress(quint64 transferBytes);
- void error(const QDBusObjectPath& transfer, const QString& error);
- void propertiesChangedSlot(const QString& interface, const QVariantMap &props, const QStringList &invalidProps);
- void sendFileSlot(QDBusPendingCallWatcher* watcher);
+ void error(const QDBusObjectPath &transfer, const QString &error);
+ void propertiesChangedSlot(const QString &interface, const QVariantMap &props, const QStringList &invalidProps);
+ void sendFileSlot(QDBusPendingCallWatcher *watcher);
private:
void transferChanged(const QVariant &value);
void statusChanged(const QVariant &value);
QTime m_time;
- QStringList m_filesToSend;
+ QStringList m_filesToSend;
QList <quint64> m_filesToSendSize;
- QString m_currentFile;
+ QString m_currentFile;
QDBusObjectPath m_currentFileDBusPath;
- quint64 m_progress;
- quint64 m_totalSize;
+ quint64 m_progress;
+ quint64 m_totalSize;
qulonglong m_speedBytes;
- Device *m_device;
- quint64 m_currentFileSize;
- quint64 m_currentFileProgress;
-
+ BlueDevil::Device *m_device;
+ quint64 m_currentFileSize;
+ quint64 m_currentFileProgress;
OrgBluezObexClient1Interface *m_client;
OrgBluezObexObjectPush1Interface *m_push;
diff --git a/src/sendfile/sendfilewizard.cpp b/src/sendfile/sendfilewizard.cpp
index 655798965a60dbd26def72f6cf5f35f1f1354308..71b01ea4a8abc9112ac0026b63df788b95ded415 100644
--- a/src/sendfile/sendfilewizard.cpp
+++ b/src/sendfile/sendfilewizard.cpp
@@ -41,7 +41,7 @@
using namespace BlueDevil;
-SendFileWizard::SendFileWizard(const QString& deviceInfo, const QStringList& files)
+SendFileWizard::SendFileWizard(const QString &deviceInfo, const QStringList &files)
: QWizard()
, m_device(0)
, m_job(0)
@@ -52,7 +52,7 @@ SendFileWizard::SendFileWizard(const QString& deviceInfo, const QStringList& fil
return;
}
- qCDebug(SENDFILE) << "DeviceUbi: " << deviceInfo;
+ qCDebug(SENDFILE) << "DeviceUbi:" << deviceInfo;
qCDebug(SENDFILE) << "Files";
qCDebug(SENDFILE) << files;
@@ -106,13 +106,13 @@ void SendFileWizard::done(int result)
}
}
-void SendFileWizard::setFiles(const QStringList& files)
+void SendFileWizard::setFiles(const QStringList &files)
{
qCDebug(SENDFILE) << files;
m_files = files;
}
-void SendFileWizard::setDevice(Device* device)
+void SendFileWizard::setDevice(Device *device)
{
qCDebug(SENDFILE) << device;
m_device = device;
@@ -136,7 +136,7 @@ void SendFileWizard::setDevice(QString deviceUrl)
m_device = device;
}
-Device* SendFileWizard::device()
+Device *SendFileWizard::device()
{
return m_device;
}
@@ -157,11 +157,10 @@ void SendFileWizard::startTransfer()
}
m_job = new SendFilesJob(m_files, m_device);
- connect(m_job, SIGNAL(destroyed(QObject*)), qApp, SLOT(quit()));
+ connect(m_job, &SendFilesJob::destroyed, qApp, &QCoreApplication::quit);
KIO::getJobTracker()->registerJob(m_job);
m_job->start();
- QTimer::singleShot(2000, this, SLOT(wizardDone()));
+ QTimer::singleShot(2000, this, &SendFileWizard::wizardDone);
}
-
diff --git a/src/sendfile/sendfilewizard.h b/src/sendfile/sendfilewizard.h
index 9b425e2d6b6d7c773f72eeb7020346bd358965e1..1dae831e2a18455259207d733d60ad38fc1465b7 100644
--- a/src/sendfile/sendfilewizard.h
+++ b/src/sendfile/sendfilewizard.h
@@ -31,26 +31,27 @@
class WizardAgent;
class QStringList;
class SendFilesJob;
-namespace BlueDevil {
+
+namespace BlueDevil
+{
class Device;
}
-using namespace BlueDevil;
class SendFileWizard : public QWizard
{
-Q_OBJECT
+ Q_OBJECT
public:
- SendFileWizard(const QString &deviceUBI, const QStringList &files);
- virtual ~SendFileWizard();
+ explicit SendFileWizard(const QString &deviceUBI, const QStringList &files);
+ ~SendFileWizard();
- virtual void done(int result);
+ void done(int result) Q_DECL_OVERRIDE;
void setFiles(const QStringList &files);
- void setDevice(Device *device);
+ void setDevice(BlueDevil::Device *device);
void setDevice(QString deviceUrl);
- Device* device();
+ BlueDevil::Device *device();
void startTransfer();
@@ -58,9 +59,8 @@ private Q_SLOTS:
void wizardDone();
private:
- QStringList m_files;
-
- Device *m_device;
+ QStringList m_files;
+ BlueDevil::Device *m_device;
SendFilesJob *m_job;
};
diff --git a/src/settings/filereceiver.kcfg b/src/settings/filereceiver.kcfg
index 5740f9a04c944820a85610b249a52ccf9b51b08d..a2e6521563e4a74cb4ed7fbdaa629ef177b54f1d 100644
--- a/src/settings/filereceiver.kcfg
+++ b/src/settings/filereceiver.kcfg
@@ -3,14 +3,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
- <!-- Includes -->
<kcfgfile name="bluedevilreceiverrc"/>
- <include>QFile</include>
- <include>QDir</include>
- <include>QStandardPaths</include>
- <include>KIO/Global</include>
-<!-- File Receiving -->
+ <!-- File Receiving -->
<group name="General">
<entry name="enabled" type="bool" key="enabled">
<label>Enable or disable receiving files</label>
@@ -18,7 +13,7 @@ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
</entry>
<entry name="saveUrl" type="Url" key="saveUrl">
<label>Save received files to:</label>
- <default code="true">QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation))</default>
+ <default code="true">QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation))</default>
</entry>
<entry name="autoAccept" type="int" key="autoAccept">
<label>Whether allow to modify shared files</label>
diff --git a/src/wizard/CMakeLists.txt b/src/wizard/CMakeLists.txt
index d615f3db4c854da479ac936971d7760f560ae80b..e096ad1df3eaf04c1c775c099df7484f67808d33 100644
--- a/src/wizard/CMakeLists.txt
+++ b/src/wizard/CMakeLists.txt
@@ -11,6 +11,7 @@ set(wizard_SRCS
pages/keyboardpairing.cpp
pages/ssppairing.cpp
pages/fail.cpp
+ pages/success.cpp
)
ki18n_wrap_ui(wizard_SRCS
@@ -20,6 +21,7 @@ ki18n_wrap_ui(wizard_SRCS
pages/keyboardpairing.ui
pages/ssppairing.ui
pages/fail.ui
+ pages/success.ui
)
add_executable(bluedevil-wizard ${wizard_SRCS})
@@ -35,5 +37,5 @@ target_link_libraries(bluedevil-wizard
${LibBlueDevil_LIBRARIES})
install(TARGETS bluedevil-wizard ${INSTALL_TARGETS_DEFAULT_ARGS})
-install(FILES bluedevil-wizard.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
+install(FILES org.kde.bluedevilwizard.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
install(FILES pin-code-database.xml DESTINATION ${DATA_INSTALL_DIR}/bluedevilwizard)
diff --git a/src/wizard/bluewizard.cpp b/src/wizard/bluewizard.cpp
index 02f54b7f141d852cb51057521b6d3896aadf1f49..2f1e62a0e84e46fd35be409175f22c1b36eb90c7 100644
--- a/src/wizard/bluewizard.cpp
+++ b/src/wizard/bluewizard.cpp
@@ -23,6 +23,7 @@
#include "pages/legacypairingdatabase.h"
#include "pages/keyboardpairing.h"
#include "pages/ssppairing.h"
+#include "pages/success.h"
#include "pages/fail.h"
#include "debug_p.h"
@@ -47,11 +48,11 @@ BlueWizard::BlueWizard(const QUrl &url)
setOption(QWizard::IndependentPages, true);
if (url.host().length() == 17) {
- setPreselectedAddress(url.host().replace(QLatin1Char('-'), QLatin1Char(':')).toLatin1());
+ setPreselectedAddress(url.host().replace(QLatin1Char('-'), QLatin1Char(':')));
}
if (url.fileName().length() == 36) {
- setPreselectedUuid(url.fileName().toLatin1());
+ setPreselectedUuid(url.fileName());
}
setPage(Discover, new DiscoverPage(this));
@@ -61,6 +62,7 @@ BlueWizard::BlueWizard(const QUrl &url)
setPage(LegacyPairingDatabase, new LegacyPairingPageDatabase(this));
setPage(KeyboardPairing, new KeyboardPairingPage(this));
setPage(SSPPairing, new SSPPairingPage(this));
+ setPage(Success, new SuccessPage(this));
setPage(Fail, new FailPage(this));
QPushButton *backButton = new QPushButton(this);
@@ -94,10 +96,6 @@ BlueWizard::BlueWizard(const QUrl &url)
m_agent = new WizardAgent(qApp);
}
-BlueWizard::~BlueWizard()
-{
-}
-
void BlueWizard::done(int result)
{
qCDebug(WIZARD) << "Wizard done: " << result;
@@ -111,9 +109,10 @@ Device* BlueWizard::device() const
return m_device;
}
-void BlueWizard::setDeviceAddress(const QByteArray& address)
+void BlueWizard::setDeviceAddress(const QString &address)
{
qCDebug(WIZARD) << "Device Address: " << address;
+
if (!Manager::self()->usableAdapter()) {
qCDebug(WIZARD) << "No usable adapter available";
return;
@@ -123,7 +122,7 @@ void BlueWizard::setDeviceAddress(const QByteArray& address)
m_device = Manager::self()->usableAdapter()->deviceForAddress(m_deviceAddress);
}
-QByteArray BlueWizard::deviceAddress() const
+QString BlueWizard::deviceAddress() const
{
return m_deviceAddress;
}
@@ -137,45 +136,43 @@ void BlueWizard::restartWizard()
qApp->quit();
}
-void BlueWizard::setPin(const QByteArray& pinNum)
+void BlueWizard::setPin(const QString &pin)
{
- qCDebug(WIZARD) << "Setting pin: :" << pinNum;
- m_pin = pinNum;
-}
+ qCDebug(WIZARD) << "Setting pin:" << pin;
-void BlueWizard::setPin(const QString& pin)
-{
- setPin(pin.toUtf8());
+ m_pin = pin;
}
-QByteArray BlueWizard::pin() const
+QString BlueWizard::pin() const
{
return m_pin;
}
-void BlueWizard::setPreselectedUuid(const QByteArray& uuid)
+void BlueWizard::setPreselectedUuid(const QString &uuid)
{
qCDebug(WIZARD) << "Preselect UUID: " << uuid;
+
m_preselectedUuid = uuid;
}
-QByteArray BlueWizard::preselectedUuid() const
+QString BlueWizard::preselectedUuid() const
{
return m_preselectedUuid;
}
-void BlueWizard::setPreselectedAddress(const QByteArray& address)
+void BlueWizard::setPreselectedAddress(const QString &address)
{
qCDebug(WIZARD) << "Preselected Address: " << address;
+
m_preselectedAddress = address;
}
-QByteArray BlueWizard::preselectedAddress() const
+QString BlueWizard::preselectedAddress() const
{
return m_preselectedAddress;
}
-WizardAgent* BlueWizard::agent() const
+WizardAgent *BlueWizard::agent() const
{
return m_agent;
}
diff --git a/src/wizard/bluewizard.h b/src/wizard/bluewizard.h
index ce817d164609ce2fc1b54cc0eb0a2a18e90dd51f..e930916919ad222eba5030a0d18ff27a1e35f926 100644
--- a/src/wizard/bluewizard.h
+++ b/src/wizard/bluewizard.h
@@ -15,57 +15,66 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
#ifndef BLUEWIZARD_H
#define BLUEWIZARD_H
#include <QObject>
#include <QWizard>
-namespace BlueDevil {
+namespace BlueDevil
+{
class Device;
}
class WizardAgent;
+
class BlueWizard : public QWizard
{
-Q_OBJECT
+ Q_OBJECT
public:
- BlueWizard(const QUrl& url);
- virtual ~BlueWizard();
+ explicit BlueWizard(const QUrl &url);
- QByteArray deviceAddress() const;
- void setDeviceAddress(const QByteArray& address);
+ QString deviceAddress() const;
+ void setDeviceAddress(const QString &address);
BlueDevil::Device *device() const;
- QByteArray pin() const;
- void setPin(const QByteArray& pin);
+ QString pin() const;
+ void setPin(const QString &pin);
- QByteArray preselectedUuid() const;
- void setPreselectedUuid(const QByteArray &uuid);
+ QString preselectedUuid() const;
+ void setPreselectedUuid(const QString &uuid);
- QByteArray preselectedAddress() const;
- void setPreselectedAddress(const QByteArray &uuid);
+ QString preselectedAddress() const;
+ void setPreselectedAddress(const QString &uuid);
- WizardAgent* agent() const;
+ WizardAgent *agent() const;
- enum {Discover, NoPairing, LegacyPairing, LegacyPairingDatabase, KeyboardPairing, SSPPairing, Fail, Connect};
+ enum {
+ Discover,
+ NoPairing,
+ LegacyPairing,
+ LegacyPairingDatabase,
+ KeyboardPairing,
+ SSPPairing,
+ Success,
+ Fail,
+ Connect
+ };
public Q_SLOTS:
void restartWizard();
- void setPin(const QString& pin);
- virtual void done(int result);
+ void done(int result) Q_DECL_OVERRIDE;
private:
- QByteArray m_deviceAddress;
- BlueDevil::Device * m_device;
- QByteArray m_pin;
- QByteArray m_preselectedUuid;
- QByteArray m_preselectedAddress;
+ BlueDevil::Device *m_device;
WizardAgent *m_agent;
+ QString m_pin;
+ QString m_deviceAddress;
+ QString m_preselectedUuid;
+ QString m_preselectedAddress;
bool m_manualPin;
};
diff --git a/src/wizard/main.cpp b/src/wizard/main.cpp
index ee9edf80f8916dfaaffe98724d99ccf4aa2320f1..80e260b0cc650328520bcfcd2076b4adbcdbf3e7 100644
--- a/src/wizard/main.cpp
+++ b/src/wizard/main.cpp
@@ -28,6 +28,7 @@
#include <QCommandLineOption>
#include <KAboutData>
+#include <KDBusService>
#include <KLocalizedString>
int main(int argc, char *argv[])
@@ -43,13 +44,12 @@ int main(int argc, char *argv[])
QStringLiteral("afiestas@kde.org"), QStringLiteral("http://www.afiestas.org/"));
QApplication app(argc, argv);
- app.setApplicationName(QStringLiteral("bluedevilwizard"));
- app.setApplicationVersion(bluedevil_version);
- app.setApplicationDisplayName(i18n("Bluetooth Wizard"));
- app.setOrganizationDomain(QStringLiteral("kde.org"));
app.setWindowIcon(QIcon::fromTheme(QStringLiteral("preferences-system-bluetooth")));
app.setQuitOnLastWindowClosed(false);
+ KAboutData::setApplicationData(aboutData);
+ KDBusService service(KDBusService::Unique);
+
QCommandLineParser parser;
parser.setApplicationDescription(i18n("Bluetooth Wizard"));
parser.addVersionOption();
@@ -59,12 +59,13 @@ int main(int argc, char *argv[])
parser.process(app);
const QStringList &args = parser.positionalArguments();
- QUrl url;
- if (!args.isEmpty()) {
- url = args.first();
- }
+ const QUrl &url = !args.isEmpty() ? args.first() : QUrl();
+
+ BlueWizard *wizard = new BlueWizard(url);
- new BlueWizard(url);
+ QObject::connect(&service, &KDBusService::activateRequested, wizard, [wizard]() {
+ wizard->setWindowState((wizard->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
+ });
return app.exec();
}
diff --git a/src/wizard/org.kde.bluedevilwizard.desktop b/src/wizard/org.kde.bluedevilwizard.desktop
new file mode 100644
index 0000000000000000000000000000000000000000..8e89f302bbd2c1a4a9b6efb5d7e36a63272482bf
--- /dev/null
+++ b/src/wizard/org.kde.bluedevilwizard.desktop
@@ -0,0 +1,99 @@
+[Desktop Entry]
+Name=BlueDevil Wizard
+Name[bs]=Bludevilov čarobnjak
+Name[ca]=Assistent del BlueDevil
+Name[cs]=Průvodce Bluedevil
+Name[de]=BlueDevil-Assistent
+Name[el]=Οδηγός BlueDevil
+Name[en_GB]=BlueDevil Wizard
+Name[es]=Asistente de BlueDevil
+Name[fi]=Opastettu BlueDevil-toiminto
+Name[fr]=Assistant pour BlueDevil
+Name[it]=Procedura guidata di BlueDevil
+Name[ja]=BlueDevil ウィザード
+Name[nb]=BlueDevil veiviser
+Name[nl]=BlueDevil assistent
+Name[pl]=Pomocnik BlueDevil
+Name[pt]=Assistente BlueDevil
+Name[pt_BR]=Assistente BlueDevil
+Name[sk]=Sprievodca BlueDevil
+Name[sl]=BlueDevil čarovnik
+Name[sr]=Блудевилов чаробњак
+Name[sr@ijekavian]=Блудевилов чаробњак
+Name[sr@ijekavianlatin]=BlueDevilov čarobnjak
+Name[sr@latin]=BlueDevilov čarobnjak
+Name[sv]=Blådjävul guide
+Name[tr]=BlueDevil Sihirbazı
+Name[uk]=Майстер BlueDevil
+Name[x-test]=xxBlueDevil Wizardxx
+Name[zh_CN]=BlueDevil 向导
+Name[zh_TW]=BlueDevil 精靈
+GenericName=BlueDevil Wizard
+GenericName[bs]=Bludevilov čarobnjak
+GenericName[ca]=Assistent del BlueDevil
+GenericName[cs]=Průvodce Bluedevil
+GenericName[de]=BlueDevil-Assistent
+GenericName[el]=Οδηγός BlueDevil
+GenericName[en_GB]=BlueDevil Wizard
+GenericName[es]=Asistente de BlueDevil
+GenericName[fi]=Opastettu BlueDevil-toiminto
+GenericName[fr]=Assistant pour BlueDevil
+GenericName[it]=Procedura guidata di BlueDevil
+GenericName[ja]=BlueDevil ウィザード
+GenericName[nb]=BlueDevil veiviser
+GenericName[nl]=BlueDevil assistent
+GenericName[pa]=BlueDevil ਸਹਾਇਕ
+GenericName[pl]=Pomocnik BlueDevil
+GenericName[pt]=Assistente BlueDevil
+GenericName[pt_BR]=Assistente BlueDevil
+GenericName[sk]=Sprievodca BlueDevil
+GenericName[sl]=BlueDevil čarovnik
+GenericName[sr]=Блудевилов чаробњак
+GenericName[sr@ijekavian]=Блудевилов чаробњак
+GenericName[sr@ijekavianlatin]=BlueDevilov čarobnjak
+GenericName[sr@latin]=BlueDevilov čarobnjak
+GenericName[sv]=Blådjävul guide
+GenericName[tr]=BlueDevil Sihirbazı
+GenericName[uk]=Майстер BlueDevil
+GenericName[x-test]=xxBlueDevil Wizardxx
+GenericName[zh_CN]=BlueDevil 向导
+GenericName[zh_TW]=BlueDevil 精靈
+Comment=BlueDevil Wizard
+Comment[bs]=Bludevilov čarobnjak
+Comment[ca]=Assistent del BlueDevil
+Comment[cs]=BlueDevil
+Comment[de]=BlueDevil-Assistent
+Comment[el]=Οδηγός BlueDevil
+Comment[en_GB]=BlueDevil Wizard
+Comment[es]=Asistente de BlueDevil
+Comment[fi]=Opastettu BlueDevil-toiminto
+Comment[fr]=Assistant pour BlueDevil
+Comment[it]=Procedura guidata di BlueDevil
+Comment[ja]=BlueDevil ウィザード
+Comment[nb]=BlueDevil veiviser
+Comment[nl]=BlueDevil assistent
+Comment[pa]=BlueDevil ਸਹਾਇਕ
+Comment[pl]=Pomocnik BlueDevil
+Comment[pt]=Assistente BlueDevil
+Comment[pt_BR]=Assistente BlueDevil
+Comment[sk]=Sprievodca BlueDevil
+Comment[sl]=BlueDevil čarovnik
+Comment[sr]=Блудевилов чаробњак
+Comment[sr@ijekavian]=Блудевилов чаробњак
+Comment[sr@ijekavianlatin]=BlueDevilov čarobnjak
+Comment[sr@latin]=BlueDevilov čarobnjak
+Comment[sv]=Blådjävul guide
+Comment[tr]=BlueDevil Sihirbazı
+Comment[uk]=Майстер BlueDevil
+Comment[x-test]=xxBlueDevil Wizardxx
+Comment[zh_CN]=BlueDevil 向导
+Comment[zh_TW]=BlueDevil 精靈
+
+Type=Application
+Exec=bluedevil-wizard %U
+Icon=preferences-system-bluetooth
+Terminal=false
+NoDisplay=true
+Categories=Qt;KDE;X-Bluetooth;Network;
+X-DBUS-StartupType=Unique
+X-DBUS-ServiceName=org.kde.bluedevilwizard
diff --git a/src/wizard/pages/discover.ui b/src/wizard/pages/discover.ui
index c43f080e49649130f01911141bf9e03509496cb4..aec410db9fbcc8e84273cba0ab95de85b4133b4d 100644
--- a/src/wizard/pages/discover.ui
+++ b/src/wizard/pages/discover.ui
@@ -114,9 +114,6 @@
<height>40</height>
</size>
</property>
- <property name="inputMask">
- <string>999999999; </string>
- </property>
<property name="readOnly">
<bool>false</bool>
</property>
diff --git a/src/wizard/pages/discoverpage.cpp b/src/wizard/pages/discoverpage.cpp
index de3f10e4e77c5f051182274a923576d3e380b54e..e52c885d4dcbcac102d7cb1e7c68e72732f52697 100644
--- a/src/wizard/pages/discoverpage.cpp
+++ b/src/wizard/pages/discoverpage.cpp
@@ -26,6 +26,7 @@
#include <QListView>
#include <QLabel>
#include <QTimer>
+#include <QRegExpValidator>
#include <KLocalizedString>
#include <kiconloader.h>
@@ -36,7 +37,9 @@
using namespace BlueDevil;
-DiscoverPage::DiscoverPage(BlueWizard* parent): QWizardPage(parent), m_wizard(parent)
+DiscoverPage::DiscoverPage(BlueWizard *parent)
+ : QWizardPage(parent)
+ , m_wizard(parent)
{
setTitle(i18n("Select a device"));
setupUi(this);
@@ -46,12 +49,7 @@ DiscoverPage::DiscoverPage(BlueWizard* parent): QWizardPage(parent), m_wizard(pa
workingPainter->setWidget(working);
workingPainter->start();
- connect(deviceList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this,
- SLOT(itemSelected(QListWidgetItem*)));
-}
-
-DiscoverPage::~DiscoverPage()
-{
+ connect(deviceList, &QListWidget::currentItemChanged, this, &DiscoverPage::itemSelected);
}
void DiscoverPage::initializePage()
@@ -64,19 +62,22 @@ void DiscoverPage::initializePage()
list << QWizard::CancelButton;
m_wizard->setButtonLayout(list);
- connect(Manager::self()->usableAdapter(), SIGNAL(unpairedDeviceFound(Device*)), this,
- SLOT(deviceFound(Device*)));
- connect(manualPin, SIGNAL(toggled(bool)), pinText, SLOT(setEnabled(bool)));
- connect(manualPin, SIGNAL(toggled(bool)), this, SIGNAL(completeChanged()));
- connect(pinText, SIGNAL(textChanged(QString)), m_wizard, SLOT(setPin(QString)));
- connect(pinText, SIGNAL(textChanged(QString)), this, SIGNAL(completeChanged()));
+ QRegExp rx(QStringLiteral("[0-9]{0,9}"));
+ QRegExpValidator *validator = new QRegExpValidator(rx);
+ pinText->setValidator(validator);
+
+ connect(Manager::self()->usableAdapter(), &Adapter::unpairedDeviceFound, this, &DiscoverPage::deviceFound);
+ connect(manualPin, &QCheckBox::toggled, pinText, &QLineEdit::setEnabled);
+ connect(manualPin, &QCheckBox::toggled, this, &DiscoverPage::completeChanged);
+ connect(pinText, &QLineEdit::textChanged, m_wizard, &BlueWizard::setPin);
+ connect(pinText, &QLineEdit::textChanged, this, &DiscoverPage::completeChanged);
QMetaObject::invokeMethod(this, "startScan", Qt::QueuedConnection);
}
bool DiscoverPage::isComplete() const
{
- if (m_wizard->deviceAddress().isEmpty()) {
+ if (m_wizard->deviceAddress().isEmpty() || !m_wizard->device()) {
return false;
}
if (manualPin->isChecked() && pinText->text().isEmpty()) {
@@ -106,7 +107,7 @@ void DiscoverPage::stopScan()
}
}
-void DiscoverPage::deviceFound(Device* device)
+void DiscoverPage::deviceFound(Device *device)
{
QString address = device->address();
QString name = device->name();
@@ -136,14 +137,14 @@ void DiscoverPage::deviceFound(Device* device)
m_itemRelation[address]->setIcon(QIcon::fromTheme(icon));
m_itemRelation[address]->setData(Qt::UserRole + 1, origName);
- //If the device was selected but it didn't had a name, select it again
+ // If the device was selected but it didn't had a name, select it again
if (deviceList->currentItem() == m_itemRelation[address]) {
itemSelected(m_itemRelation[address]);
}
return;
}
- connect(device, SIGNAL(propertyChanged(QString,QVariant)), SLOT(devicePropertyChanged()));
+ connect(device, &Device::propertyChanged, this, &DiscoverPage::devicePropertyChanged);
QListWidgetItem *item = new QListWidgetItem(QIcon::fromTheme(icon), name, deviceList);
@@ -156,20 +157,20 @@ void DiscoverPage::deviceFound(Device* device)
deviceList->setCurrentItem(m_itemRelation[address]);
}
- //If the device has been preselected via arguments, select it
+ // If the device has been preselected via arguments, select it
if (m_wizard->preselectedAddress() == address.toLower()) {
deviceList->setCurrentItem(m_itemRelation[address]);
}
}
-void DiscoverPage::itemSelected(QListWidgetItem* item)
+void DiscoverPage::itemSelected(QListWidgetItem *item)
{
bool origName = item->data(Qt::UserRole+1).toBool();
if (origName) {
QString address = item->data(Qt::UserRole).toString();
- m_wizard->setDeviceAddress(address.toUtf8());
+ m_wizard->setDeviceAddress(address);
} else {
- m_wizard->setDeviceAddress(QByteArray());
+ m_wizard->setDeviceAddress(QString());
}
emit completeChanged();
}
@@ -184,7 +185,6 @@ void DiscoverPage::devicePropertyChanged()
int DiscoverPage::nextId() const
{
- qCDebug(WIZARD);
if (!isComplete()) {
return BlueWizard::Discover;
}
@@ -193,7 +193,7 @@ int DiscoverPage::nextId() const
return BlueWizard::Discover;
}
- if (m_wizard->deviceAddress().isEmpty()) {
+ if (m_wizard->deviceAddress().isEmpty() || !m_wizard->device()) {
return BlueWizard::Discover;
}
@@ -223,20 +223,20 @@ int DiscoverPage::nextId() const
qCDebug(WIZARD) << "From DB: " << m_wizard->agent()->isFromDatabase();
qCDebug(WIZARD) << "PIN: " << m_wizard->agent()->pin();
- //If keyboard no matter what, we go to the keyboard page.
+ // If keyboard no matter what, we go to the keyboard page.
if (classToType(device->deviceClass()) == BLUETOOTH_TYPE_KEYBOARD) {
qCDebug(WIZARD) << "Keyboard Pairing";
return BlueWizard::KeyboardPairing;
}
- //If pin == NULL means that not pairing is required
+ // If pin == NULL means that not pairing is required
if (!device->hasLegacyPairing() && !m_wizard->agent()->isFromDatabase()) {
qCDebug(WIZARD) << "Secure Pairing";
return BlueWizard::SSPPairing;
}
if (pin == QLatin1String("NULL")) {
- qCDebug(WIZARD) << "NO Pairing";
+ qCDebug(WIZARD) << "No Pairing";
return BlueWizard::NoPairing;
}
diff --git a/src/wizard/pages/discoverpage.h b/src/wizard/pages/discoverpage.h
index 86afbea7429e4f0a9da440c3ced66c415b24f9f2..5d310e7832dbd4dd1c0edecfdbd46d65d53e97a9 100644
--- a/src/wizard/pages/discoverpage.h
+++ b/src/wizard/pages/discoverpage.h
@@ -23,33 +23,34 @@
class BlueWizard;
-namespace BlueDevil {
+namespace BlueDevil
+{
class Device;
}
-using namespace BlueDevil;
class DiscoverPage : public QWizardPage, public Ui::Discover
{
-Q_OBJECT
+ Q_OBJECT
public:
- DiscoverPage(BlueWizard* parent = 0);
- virtual ~DiscoverPage();
+ explicit DiscoverPage(BlueWizard *parent = 0);
+
+ void initializePage() Q_DECL_OVERRIDE;
+ bool isComplete() const Q_DECL_OVERRIDE;
+ int nextId() const Q_DECL_OVERRIDE;
- virtual void initializePage();
- virtual bool isComplete() const;
- virtual int nextId() const;
private Q_SLOTS:
void startScan();
- void deviceFound(Device * device);
- void itemSelected(QListWidgetItem* item);
+ void deviceFound(BlueDevil::Device *device);
+ void itemSelected(QListWidgetItem *item);
void devicePropertyChanged();
+
private:
void stopScan();
private:
QMap<QString, QListWidgetItem*> m_itemRelation;
- Device *m_selectedDevice;
+ BlueDevil::Device *m_selectedDevice;
BlueWizard *m_wizard;
};
diff --git a/src/wizard/pages/fail.cpp b/src/wizard/pages/fail.cpp
index 422920f7f57d0b8e399796c70af0b52bf74c99f6..6abbeeb8b85b55aa8e90e69d196cb85f11ccb55b 100644
--- a/src/wizard/pages/fail.cpp
+++ b/src/wizard/pages/fail.cpp
@@ -35,20 +35,21 @@
using namespace BlueDevil;
-FailPage::FailPage(BlueWizard* parent)
+FailPage::FailPage(BlueWizard *parent)
: QWizardPage(parent)
, m_wizard(parent)
{
setupUi(this);
+
+ failIcon->setPixmap(QIcon::fromTheme(QStringLiteral("task-reject")).pixmap(48));
}
void FailPage::initializePage()
{
- qCDebug(WIZARD);
QPushButton *reset = new QPushButton(this);
KGuiItem::assign(reset, KStandardGuiItem::reset());
reset->setText(i18nc("Button offered when the wizard fail. This button will restart the wizard", "Restart the wizard"));
- connect(reset, SIGNAL(clicked(bool)), m_wizard, SLOT(restartWizard()));
+ connect(reset, &QPushButton::clicked, m_wizard, &BlueWizard::restartWizard);
m_wizard->setButton(QWizard::CustomButton3, reset);
m_wizard->setButtonText(QWizard::CancelButton, i18nc("Button that closes the wizard", "Close"));
@@ -60,11 +61,10 @@ void FailPage::initializePage()
m_wizard->setButtonLayout(list);
- QString deviceName = m_wizard->device()->name();
+ const QString &deviceName = m_wizard->device()->name();
if (deviceName.isEmpty()) {
failLbl->setText(i18nc("This string is shown when the wizard fail","The setup of the device has failed"));
} else {
failLbl->setText(i18n("The setup of %1 has failed", deviceName));
}
-
}
diff --git a/src/wizard/pages/fail.h b/src/wizard/pages/fail.h
index 4b734c4e92121503b722e91d41ab9168bb6e0ad5..fa6378ffb2d82db5a1a0f9fd5f6ac7b534e9291b 100644
--- a/src/wizard/pages/fail.h
+++ b/src/wizard/pages/fail.h
@@ -29,7 +29,8 @@
class BlueWizard;
class KPixmapSequenceOverlayPainter;
-namespace BlueDevil {
+namespace BlueDevil
+{
class Device;
class Adapter;
}
@@ -38,12 +39,12 @@ using namespace BlueDevil;
class FailPage : public QWizardPage, Ui::Fail
{
-Q_OBJECT
+ Q_OBJECT
public:
- FailPage(BlueWizard* parent = 0);
+ explicit FailPage(BlueWizard *parent = 0);
- virtual void initializePage();
+ void initializePage() Q_DECL_OVERRIDE;
private:
BlueWizard *m_wizard;
diff --git a/src/wizard/pages/fail.ui b/src/wizard/pages/fail.ui
index 0470e8f44b3ba7aa77791ec42c6c7b111dc75832..375a4fb344dc3572d3a87bd3a7fc57a3084f799a 100644
--- a/src/wizard/pages/fail.ui
+++ b/src/wizard/pages/fail.ui
@@ -30,6 +30,16 @@
</spacer>
</item>
<item>
+ <widget class="QLabel" name="failIcon">
+ <property name="maximumSize">
+ <size>
+ <width>48</width>
+ <height>48</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QLabel" name="failLbl">
<property name="text">
<string/>
diff --git a/src/wizard/pages/keyboardpairing.cpp b/src/wizard/pages/keyboardpairing.cpp
index 67c7f276534cae5da0888e9160b675611bdc54d0..4b552ba05ad81f31a648572cce93f625c7ba6967 100644
--- a/src/wizard/pages/keyboardpairing.cpp
+++ b/src/wizard/pages/keyboardpairing.cpp
@@ -35,11 +35,12 @@
using namespace BlueDevil;
-KeyboardPairingPage::KeyboardPairingPage(BlueWizard* parent)
+KeyboardPairingPage::KeyboardPairingPage(BlueWizard *parent)
: QWizardPage(parent)
, m_wizard(parent)
{
setupUi(this);
+
m_working = new KPixmapSequenceOverlayPainter(this);
m_working->setSequence(KIconLoader::global()->loadPixmapSequence(QStringLiteral("process-working"), 22));
m_working->setWidget(pinNumber);
@@ -53,13 +54,12 @@ KeyboardPairingPage::KeyboardPairingPage(BlueWizard* parent)
void KeyboardPairingPage::initializePage()
{
- qCDebug(WIZARD);
m_wizard->setButtonLayout(wizardButtonsLayout());
- connect(m_wizard->agent(), SIGNAL(pinRequested(QString)), this, SLOT(pinRequested(QString)));
+ connect(m_wizard->agent(), &WizardAgent::pinRequested, this, &KeyboardPairingPage::pinRequested);
Device *device = m_wizard->device();
- connect(device, SIGNAL(pairedChanged(bool)), this, SLOT(pairedChanged(bool)));
+ connect(device, &Device::pairedChanged, this, &KeyboardPairingPage::pairedChanged);
device->pair();
}
@@ -72,6 +72,7 @@ void KeyboardPairingPage::pinRequested(const QString& pin)
void KeyboardPairingPage::pairedChanged(bool paired)
{
qCDebug(WIZARD) << paired;
+
m_wizard->next();
}
@@ -90,6 +91,5 @@ QList<QWizard::WizardButton> KeyboardPairingPage::wizardButtonsLayout() const
QList <QWizard::WizardButton> list;
list << QWizard::Stretch;
list << QWizard::CancelButton;
-
return list;
}
diff --git a/src/wizard/pages/keyboardpairing.h b/src/wizard/pages/keyboardpairing.h
index 14818f605103fbf76cce2f402313d97e912c1526..871295b052ebb39a2f2488f93df0ebd748ac28bf 100644
--- a/src/wizard/pages/keyboardpairing.h
+++ b/src/wizard/pages/keyboardpairing.h
@@ -29,7 +29,8 @@
class BlueWizard;
class KPixmapSequenceOverlayPainter;
-namespace BlueDevil {
+namespace BlueDevil
+{
class Device;
class Adapter;
}
@@ -38,24 +39,24 @@ using namespace BlueDevil;
class KeyboardPairingPage : public QWizardPage, Ui::KeyboardPairing
{
-Q_OBJECT
+ Q_OBJECT
public:
- KeyboardPairingPage(BlueWizard* parent = 0);
+ explicit KeyboardPairingPage(BlueWizard *parent = 0);
- virtual void initializePage();
- virtual bool validatePage();
- virtual int nextId() const;
+ void initializePage() Q_DECL_OVERRIDE;
+ bool validatePage() Q_DECL_OVERRIDE;
+ int nextId() const Q_DECL_OVERRIDE;
public Q_SLOTS:
void pinRequested(const QString &pin);
void pairedChanged(bool paired);
protected:
- QList <QWizard::WizardButton> wizardButtonsLayout() const;
+ QList<QWizard::WizardButton> wizardButtonsLayout() const;
private:
- BlueWizard *m_wizard;
+ BlueWizard *m_wizard;
KPixmapSequenceOverlayPainter *m_working;
};
diff --git a/src/wizard/pages/legacypairing.cpp b/src/wizard/pages/legacypairing.cpp
index 898c6992baa7fdab3d95a6f0d301fc0f921ae515..943a107cef01b21ea0d489fde4abab0657d8094b 100644
--- a/src/wizard/pages/legacypairing.cpp
+++ b/src/wizard/pages/legacypairing.cpp
@@ -35,11 +35,12 @@
using namespace BlueDevil;
-LegacyPairingPage::LegacyPairingPage(BlueWizard* parent)
+LegacyPairingPage::LegacyPairingPage(BlueWizard *parent)
: QWizardPage(parent)
, m_wizard(parent)
{
setupUi(this);
+
m_working = new KPixmapSequenceOverlayPainter(this);
m_working->setSequence(KIconLoader::global()->loadPixmapSequence(QStringLiteral("process-working"), 22));
m_working->setWidget(pinNumber);
@@ -53,17 +54,16 @@ LegacyPairingPage::LegacyPairingPage(BlueWizard* parent)
void LegacyPairingPage::initializePage()
{
- qCDebug(WIZARD);
m_wizard->setButtonLayout(wizardButtonsLayout());
Device *device = m_wizard->device();
- connect(m_wizard->agent(), SIGNAL(pinRequested(QString)), this, SLOT(pinRequested(QString)));
- connect(device, SIGNAL(pairedChanged(bool)), this, SLOT(pairedChanged(bool)));
+ connect(m_wizard->agent(), &WizardAgent::pinRequested, this, &LegacyPairingPage::pinRequested);
+ connect(device, &Device::pairedChanged, this, &LegacyPairingPage::pairedChanged);
device->pair();
}
-void LegacyPairingPage::pinRequested(const QString& pin)
+void LegacyPairingPage::pinRequested(const QString &pin)
{
m_working->stop();
pinNumber->setText(pin);
@@ -72,6 +72,7 @@ void LegacyPairingPage::pinRequested(const QString& pin)
void LegacyPairingPage::pairedChanged(bool paired)
{
qCDebug(WIZARD) << paired;
+
m_wizard->next();
}
@@ -90,6 +91,5 @@ QList<QWizard::WizardButton> LegacyPairingPage::wizardButtonsLayout() const
QList <QWizard::WizardButton> list;
list << QWizard::Stretch;
list << QWizard::CancelButton;
-
return list;
}
diff --git a/src/wizard/pages/legacypairing.h b/src/wizard/pages/legacypairing.h
index f9ec3d40b96954f411e0802ef15742a2d8dd6226..671743b6f63fb3e2484567b98534de489e1832e1 100644
--- a/src/wizard/pages/legacypairing.h
+++ b/src/wizard/pages/legacypairing.h
@@ -29,23 +29,22 @@
class BlueWizard;
class KPixmapSequenceOverlayPainter;
-namespace BlueDevil {
+namespace BlueDevil
+{
class Device;
class Adapter;
}
-using namespace BlueDevil;
-
class LegacyPairingPage : public QWizardPage, Ui::LegacyPairing
{
-Q_OBJECT
+ Q_OBJECT
public:
- LegacyPairingPage(BlueWizard* parent = 0);
+ explicit LegacyPairingPage(BlueWizard *parent = 0);
- virtual void initializePage();
- virtual bool validatePage();
- virtual int nextId() const;
+ void initializePage() Q_DECL_OVERRIDE;
+ bool validatePage() Q_DECL_OVERRIDE;
+ int nextId() const Q_DECL_OVERRIDE;
public Q_SLOTS:
void pinRequested(const QString &pin);
@@ -55,7 +54,7 @@ protected:
QList <QWizard::WizardButton> wizardButtonsLayout() const;
private:
- BlueWizard *m_wizard;
+ BlueWizard *m_wizard;
KPixmapSequenceOverlayPainter *m_working;
};
diff --git a/src/wizard/pages/legacypairingdatabase.cpp b/src/wizard/pages/legacypairingdatabase.cpp
index a31657c5d19fe5276b7eb09597de4187c6de51bb..61dcde0d20afb95644ab25501433d22f8b18caea 100644
--- a/src/wizard/pages/legacypairingdatabase.cpp
+++ b/src/wizard/pages/legacypairingdatabase.cpp
@@ -36,11 +36,12 @@
using namespace BlueDevil;
-LegacyPairingPageDatabase::LegacyPairingPageDatabase(BlueWizard* parent)
+LegacyPairingPageDatabase::LegacyPairingPageDatabase(BlueWizard *parent)
: QWizardPage(parent)
, m_wizard(parent)
{
setupUi(this);
+
m_working = new KPixmapSequenceOverlayPainter(this);
m_working->setSequence(KIconLoader::global()->loadPixmapSequence(QStringLiteral("process-working"), 22));
m_working->setWidget(working);
@@ -54,13 +55,14 @@ void LegacyPairingPageDatabase::initializePage()
Device *device = m_wizard->device();
connecting->setText(i18n("Connecting to %1...", device->name()));
- connect(device, SIGNAL(pairedChanged(bool)), this, SLOT(pairedChanged(bool)));
+ connect(device, &Device::pairedChanged, this, &LegacyPairingPageDatabase::pairedChanged);
device->pair();
}
void LegacyPairingPageDatabase::pairedChanged(bool paired)
{
qCDebug(WIZARD) << paired;
+
m_wizard->next();
}
@@ -79,6 +81,5 @@ QList< QWizard::WizardButton > LegacyPairingPageDatabase::wizardButtonsLayout()
QList <QWizard::WizardButton> list;
list << QWizard::Stretch;
list << QWizard::CancelButton;
-
return list;
}
diff --git a/src/wizard/pages/legacypairingdatabase.h b/src/wizard/pages/legacypairingdatabase.h
index 00c9d16e849bdfd073be64f3d11a518ebc81b795..637c82ee9fa86f0eef8f68dcefd9487a47e191de 100644
--- a/src/wizard/pages/legacypairingdatabase.h
+++ b/src/wizard/pages/legacypairingdatabase.h
@@ -29,32 +29,31 @@
class BlueWizard;
class KPixmapSequenceOverlayPainter;
-namespace BlueDevil {
+namespace BlueDevil
+{
class Device;
class Adapter;
}
-using namespace BlueDevil;
-
class LegacyPairingPageDatabase : public QWizardPage, Ui::NoPairing
{
-Q_OBJECT
+ Q_OBJECT
public:
- LegacyPairingPageDatabase(BlueWizard* parent = 0);
+ explicit LegacyPairingPageDatabase(BlueWizard *parent = 0);
- virtual void initializePage();
- virtual bool validatePage();
- virtual int nextId() const;
+ void initializePage() Q_DECL_OVERRIDE;
+ bool validatePage() Q_DECL_OVERRIDE;
+ int nextId() const Q_DECL_OVERRIDE;
public Q_SLOTS:
void pairedChanged(bool paired);
protected:
- QList <QWizard::WizardButton> wizardButtonsLayout() const;
+ QList<QWizard::WizardButton> wizardButtonsLayout() const;
private:
- BlueWizard *m_wizard;
+ BlueWizard *m_wizard;
KPixmapSequenceOverlayPainter *m_working;
};
diff --git a/src/wizard/pages/nopairing.cpp b/src/wizard/pages/nopairing.cpp
index c0410e13f6c606c3c1415d97ce3a9ff71a36bd31..d4f1e45ff726508349e4fa401e7c9c47f3ac2c20 100644
--- a/src/wizard/pages/nopairing.cpp
+++ b/src/wizard/pages/nopairing.cpp
@@ -35,59 +35,52 @@
using namespace BlueDevil;
-NoPairingPage::NoPairingPage(BlueWizard* parent) : QWizardPage(parent)
-, m_validPage(false)
-, m_wizard(parent)
+NoPairingPage::NoPairingPage(BlueWizard *parent)
+ : QWizardPage(parent)
+ , m_success(false)
+ , m_wizard(parent)
{
setupUi(this);
+
m_working = new KPixmapSequenceOverlayPainter(this);
m_working->setSequence(KIconLoader::global()->loadPixmapSequence(QStringLiteral("process-working"), 22));
m_working->setWidget(working);
m_working->start();
}
+int NoPairingPage::nextId() const
+{
+ if (m_success) {
+ return BlueWizard::Success;
+ }
+ return BlueWizard::Fail;
+}
+
void NoPairingPage::initializePage()
{
- qCDebug(WIZARD);
m_wizard->setButtonLayout(wizardButtonsLayout());
connecting->setText(connecting->text().append(m_wizard->device()->name()));
- //It can happen that the device is technically connected and trusted but we are not connected
- //to the profile. We have no way to know if the profile was activated or not so we have to relay
- //on a timeout (10s)
- QTimer::singleShot(10000, this, SLOT(timeout()));
- connect(m_wizard->device(), SIGNAL(connectedChanged(bool)), SLOT(connectedChanged(bool)));
- connect(m_wizard->device(), SIGNAL(trustedChanged(bool)), SLOT(connectedChanged(bool)));
+ connect(m_wizard->device(), &Device::connectedChanged, this, &NoPairingPage::connectedChanged);
+ connect(m_wizard->device(), &Device::trustedChanged, this, &NoPairingPage::connectedChanged);
m_wizard->device()->connectDevice();
m_wizard->device()->setTrusted(true);
-}
-void NoPairingPage::timeout()
-{
- connectedChanged(true);
+ QTimer::singleShot(10 * 1000, this, [this]() {
+ connectedChanged(true);
+ });
}
void NoPairingPage::connectedChanged(bool connected)
{
- qCDebug(WIZARD);
+ qCDebug(WIZARD) << "Connect finished" << connected;
- m_validPage = connected;
- if (m_validPage) {
- qCDebug(WIZARD) << "Done";
- m_wizard->done(0);
- }
-}
-
-bool NoPairingPage::validatePage()
-{
- return m_validPage;
-}
-
-int NoPairingPage::nextId() const
-{
- return -1;
+ // Connect may fail but that doesn't really mean the device was setup incorrectly
+ // Device::connectDevice will fail eg. when A2DP profile could not be connected due to missing pulseaudio plugin
+ m_success = true;
+ QTimer::singleShot(500, m_wizard, &BlueWizard::next);
}
QList<QWizard::WizardButton> NoPairingPage::wizardButtonsLayout() const
@@ -95,6 +88,5 @@ QList<QWizard::WizardButton> NoPairingPage::wizardButtonsLayout() const
QList <QWizard::WizardButton> list;
list << QWizard::Stretch;
list << QWizard::CancelButton;
-
return list;
}
diff --git a/src/wizard/pages/nopairing.h b/src/wizard/pages/nopairing.h
index 26f1441d27da9a6eb017b946a2bbc31d694b9967..1f0a8ab13f426eda0061126d79fcb2ecb5499511 100644
--- a/src/wizard/pages/nopairing.h
+++ b/src/wizard/pages/nopairing.h
@@ -30,34 +30,31 @@
class BlueWizard;
class KPixmapSequenceOverlayPainter;
-namespace BlueDevil {
+namespace BlueDevil
+{
class Device;
class Adapter;
}
-using namespace BlueDevil;
-
class NoPairingPage : public QWizardPage, Ui::NoPairing
{
-Q_OBJECT
+ Q_OBJECT
public:
- NoPairingPage(BlueWizard* parent = 0);
+ explicit NoPairingPage(BlueWizard *parent = 0);
- virtual void initializePage();
- virtual bool validatePage();
- virtual int nextId() const;
+ int nextId() const Q_DECL_OVERRIDE;
+ void initializePage() Q_DECL_OVERRIDE;
protected:
- QList <QWizard::WizardButton> wizardButtonsLayout() const;
+ QList<QWizard::WizardButton> wizardButtonsLayout() const;
private Q_SLOTS:
- void timeout();
void connectedChanged(bool connected);
private:
- bool m_validPage;
- BlueWizard *m_wizard;
+ bool m_success;
+ BlueWizard *m_wizard;
KPixmapSequenceOverlayPainter *m_working;
};
diff --git a/src/wizard/pages/ssppairing.cpp b/src/wizard/pages/ssppairing.cpp
index 963bdaa7be58df1b0ae2988312766537890055a8..d9e2b0a0c5185caead8f97fb0b76751ddb1557fe 100644
--- a/src/wizard/pages/ssppairing.cpp
+++ b/src/wizard/pages/ssppairing.cpp
@@ -38,12 +38,13 @@
using namespace BlueDevil;
-SSPPairingPage::SSPPairingPage(BlueWizard* parent)
+SSPPairingPage::SSPPairingPage(BlueWizard *parent)
: QWizardPage(parent)
, m_buttonClicked(QWizard::NoButton)
, m_wizard(parent)
{
setupUi(this);
+
m_working = new KPixmapSequenceOverlayPainter(this);
m_working->setSequence(KIconLoader::global()->loadPixmapSequence(QStringLiteral("process-working"), 22));
m_working->setWidget(pinNumber);
@@ -57,7 +58,6 @@ SSPPairingPage::SSPPairingPage(BlueWizard* parent)
void SSPPairingPage::initializePage()
{
- qCDebug(WIZARD);
QList <QWizard::WizardButton> list;
list << QWizard::Stretch;
list << QWizard::CancelButton;
@@ -66,17 +66,17 @@ void SSPPairingPage::initializePage()
Device *device = m_wizard->device();
confirmLbl->setText(i18n("Connecting to %1...", device->name()));
- connect(device, SIGNAL(pairedChanged(bool)), this, SLOT(pairedChanged(bool)));
- connect(m_wizard->agent(), SIGNAL(confirmationRequested(quint32,QDBusMessage)),
- this, SLOT(confirmationRequested(quint32,QDBusMessage)));
- connect(m_wizard->agent(), SIGNAL(pinRequested(QString)), SLOT(pinRequested(QString)));
+ connect(device, &Device::pairedChanged, this, &SSPPairingPage::pairedChanged);
+ connect(m_wizard->agent(), &WizardAgent::confirmationRequested, this, &SSPPairingPage::confirmationRequested);
+ connect(m_wizard->agent(), &WizardAgent::pinRequested, this, &SSPPairingPage::pinRequested);
device->pair();
}
-void SSPPairingPage::confirmationRequested(quint32 passkey, const QDBusMessage& msg)
+void SSPPairingPage::confirmationRequested(quint32 passkey, const QDBusMessage &msg)
{
m_msg = msg;
+ m_msg.setDelayedReply(true);
QPushButton *matches = new QPushButton(this);
KGuiItem::assign(matches, KStandardGuiItem::apply());
@@ -86,8 +86,8 @@ void SSPPairingPage::confirmationRequested(quint32 passkey, const QDBusMessage&
KGuiItem::assign(notMatch, KStandardGuiItem::cancel());
notMatch->setText(i18n("Does not match"));
- connect(matches, SIGNAL(clicked(bool)), this, SLOT(matchesClicked()));
- connect(notMatch, SIGNAL(clicked(bool)), this, SLOT(notMatchClicked()));
+ connect(matches, &QPushButton::clicked, this, &SSPPairingPage::matchesClicked);
+ connect(notMatch, &QPushButton::clicked, this, &SSPPairingPage::notMatchClicked);
wizard()->setButton(QWizard::CustomButton1, matches);
wizard()->setButton(QWizard::CustomButton2, notMatch);
@@ -101,7 +101,7 @@ void SSPPairingPage::confirmationRequested(quint32 passkey, const QDBusMessage&
}
-void SSPPairingPage::pinRequested(const QString& pin)
+void SSPPairingPage::pinRequested(const QString &pin)
{
m_working->stop();
pinNumber->setText(pin);
@@ -129,6 +129,7 @@ void SSPPairingPage::matchesClicked()
void SSPPairingPage::notMatchClicked()
{
m_buttonClicked = QWizard::CustomButton2;
+ QDBusConnection::systemBus().send(m_msg.createErrorReply(QStringLiteral("org.bluez.Rejected"), QStringLiteral("Rejected")));
wizard()->next();
}
@@ -163,6 +164,5 @@ QList<QWizard::WizardButton> SSPPairingPage::wizardButtonsLayout() const
list << QWizard::Stretch;
list << QWizard::CustomButton2;
list << QWizard::CustomButton1;
-
return list;
}
diff --git a/src/wizard/pages/ssppairing.h b/src/wizard/pages/ssppairing.h
index 9b7066d190397697abfcfe59dc6b1193240d1d04..1cd2aa8b398330b95f8204070d98ff52096414de 100644
--- a/src/wizard/pages/ssppairing.h
+++ b/src/wizard/pages/ssppairing.h
@@ -30,23 +30,22 @@
class BlueWizard;
class KPixmapSequenceOverlayPainter;
-namespace BlueDevil {
+namespace BlueDevil
+{
class Device;
class Adapter;
}
-using namespace BlueDevil;
-
class SSPPairingPage : public QWizardPage, Ui::SSPPairing
{
-Q_OBJECT
+ Q_OBJECT
public:
- SSPPairingPage(BlueWizard* parent = 0);
+ explicit SSPPairingPage(BlueWizard *parent = 0);
- virtual void initializePage();
- virtual int nextId() const;
- virtual bool validatePage();
+ void initializePage() Q_DECL_OVERRIDE;
+ int nextId() const Q_DECL_OVERRIDE;
+ bool validatePage() Q_DECL_OVERRIDE;
public Q_SLOTS:
void confirmationRequested(quint32 passkey, const QDBusMessage &msg);
@@ -56,12 +55,12 @@ public Q_SLOTS:
void pinRequested(const QString &pin);
protected:
- QList <QWizard::WizardButton> wizardButtonsLayout() const;
+ QList<QWizard::WizardButton> wizardButtonsLayout() const;
private:
- QDBusMessage m_msg;
- QWizard::WizardButton m_buttonClicked;
- BlueWizard *m_wizard;
+ QDBusMessage m_msg;
+ QWizard::WizardButton m_buttonClicked;
+ BlueWizard *m_wizard;
KPixmapSequenceOverlayPainter *m_working;
};
diff --git a/src/wizard/pages/success.cpp b/src/wizard/pages/success.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f49bb7fab2871d4807ce3396cddc3f053787736d
--- /dev/null
+++ b/src/wizard/pages/success.cpp
@@ -0,0 +1,66 @@
+/*****************************************************************************
+ * This file is part of the KDE project *
+ * *
+ * Copyright (C) 2010 Alejandro Fiestas Olivares <afiestas@kde.org> *
+ * Copyright (C) 2010-2011 UFO Coders <info@ufocoders.com> *
+ * Copyright (C) 2014 David Rosca <nowrep@gmail.com> *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library 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 "success.h"
+#include "bluewizard.h"
+#include "debug_p.h"
+
+#include <QIcon>
+
+#include <KLocalizedString>
+
+#include <bluedevil/bluedevildevice.h>
+
+SuccessPage::SuccessPage(BlueWizard *parent)
+ : QWizardPage(parent)
+ , m_wizard(parent)
+{
+ setupUi(this);
+
+ successIcon->setPixmap(QIcon::fromTheme(QStringLiteral("task-complete")).pixmap(48));
+}
+
+void SuccessPage::initializePage()
+{
+ qCDebug(WIZARD) << "Initialize Success Page";
+
+ QList<QWizard::WizardButton> list;
+ list << QWizard::Stretch;
+ list << QWizard::FinishButton;
+
+ m_wizard->setButtonLayout(list);
+
+ setFinalPage(true);
+
+ QString deviceName = m_wizard->device()->name();
+ if (deviceName.isEmpty()) {
+ successLbl->setText(i18nc("This string is shown when the wizard succeeds", "The setup of the device has succeeded"));
+ } else {
+ successLbl->setText(i18n("The setup of %1 has succeeded", deviceName));
+ }
+}
+
+int SuccessPage::nextId() const
+{
+ return -1;
+}
diff --git a/src/wizard/pages/success.h b/src/wizard/pages/success.h
new file mode 100644
index 0000000000000000000000000000000000000000..ba0d73c35301fcbb17643c36ce7ebe4576fba8f1
--- /dev/null
+++ b/src/wizard/pages/success.h
@@ -0,0 +1,46 @@
+/*****************************************************************************
+ * This file is part of the KDE project *
+ * *
+ * Copyright (C) 2010 Alejandro Fiestas Olivares <afiestas@kde.org> *
+ * Copyright (C) 2010-2011 UFO Coders <info@ufocoders.com> *
+ * Copyright (C) 2014 David Rosca <nowrep@gmail.com> *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library 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 SUCCESS_H
+#define SUCCESS_H
+
+#include "ui_success.h"
+#include <QWizardPage>
+
+class BlueWizard;
+
+class SuccessPage : public QWizardPage, Ui::Success
+{
+ Q_OBJECT
+
+public:
+ explicit SuccessPage(BlueWizard *parent = 0);
+
+ void initializePage() Q_DECL_OVERRIDE;
+ int nextId() const Q_DECL_OVERRIDE;
+
+private:
+ BlueWizard *m_wizard;
+};
+
+#endif // SUCCESS_H
diff --git a/src/wizard/pages/success.ui b/src/wizard/pages/success.ui
new file mode 100644
index 0000000000000000000000000000000000000000..3630db34a89ecaf7c6a6405113458c068dbe61be
--- /dev/null
+++ b/src/wizard/pages/success.ui
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Success</class>
+ <widget class="QWidget" name="Success">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>10</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="successIcon">
+ <property name="maximumSize">
+ <size>
+ <width>48</width>
+ <height>48</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="successLbl">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/wizard/pin-code-database.xml b/src/wizard/pin-code-database.xml
index 8239aa98a94ec27185c6c93f9fa8022dfc590caa..5e99392705936a96f3974c0f68b047f728dcb2c5 100644
--- a/src/wizard/pin-code-database.xml
+++ b/src/wizard/pin-code-database.xml
@@ -52,9 +52,9 @@
<device type="keyboard" oui="00:13:6C:" name="TomTom Remote" pin="0000"/>
<!-- Sony PlayStation 3 Remote Control -->
- <device oui="00:19:C1:" name="BD Remote Control" pin="NULL"/>
- <device oui="00:1E:3D:" name="BD Remote Control" pin="NULL"/>
- <device oui="00:06:F5:" name="BD Remote Control" pin="NULL"/>
+ <device oui="00:19:C1:" name="PLAYSTATION(R)3 Controller" pin="NULL"/>
+ <device oui="00:1E:3D:" name="PLAYSTATION(R)3 Controller" pin="NULL"/>
+ <device oui="00:06:F5:" name="PLAYSTATION(R)3 Controller" pin="NULL"/>
<!-- Apple Wireless and Mighty Mouse
Note: Apple doesn't follow the specs, and requires their mice
diff --git a/src/wizard/wizardagent.h b/src/wizard/wizardagent.h
index 5a9ea2c5749431a7e723d9b95a356725e7b1cdc1..332139742e1ed754cd23650df6c1773e79ab79d2 100644
--- a/src/wizard/wizardagent.h
+++ b/src/wizard/wizardagent.h
@@ -26,7 +26,8 @@
#include <QApplication>
#include <QXmlStreamReader>
-namespace BlueDevil {
+namespace BlueDevil
+{
class Device;
}