From kde-commits Thu Apr 30 20:59:26 2015 From: David Rosca Date: Thu, 30 Apr 2015 20:59:26 +0000 To: kde-commits Subject: [bluedevil] src/wizard: wizard: Merge all pairing pages to single page Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=143042757814705 Git commit 63d1c901ab9047c0c637cbfbc3ad352727b2d9e5 by David Rosca. Committed on 30/04/2015 at 18:02. Pushed by drosca into branch 'master'. wizard: Merge all pairing pages to single page It is not needed to have special pages for each device type when the only thing that really changes is the info text that is displayed to user. Also fix incorrect PIN handling when restarting wizard. M +2 -7 src/wizard/CMakeLists.txt M +2 -22 src/wizard/bluewizard.cpp M +1 -8 src/wizard/bluewizard.h M +2 -2 src/wizard/main.cpp M +17 -32 src/wizard/pages/discover.cpp M +1 -11 src/wizard/pages/discover.ui M +1 -1 src/wizard/pages/fail.cpp D +0 -105 src/wizard/pages/keyboardpairing.cpp D +0 -62 src/wizard/pages/keyboardpairing.h D +0 -147 src/wizard/pages/keyboardpairing.ui D +0 -105 src/wizard/pages/legacypairing.cpp D +0 -61 src/wizard/pages/legacypairing.h D +0 -147 src/wizard/pages/legacypairing.ui D +0 -88 src/wizard/pages/legacypairingdatabase.cpp D +0 -59 src/wizard/pages/legacypairingdatabase.h R +60 -59 src/wizard/pages/pairing.cpp [from: src/wizard/pages/ssppair= ing.cpp - 058% similarity] R +10 -17 src/wizard/pages/pairing.h [from: src/wizard/pages/ssppairin= g.h - 080% similarity] R +23 -10 src/wizard/pages/pairing.ui [from: src/wizard/pages/ssppairi= ng.ui - 085% similarity] M +2 -9 src/wizard/wizardagent.cpp M +0 -2 src/wizard/wizardagent.h http://commits.kde.org/bluedevil/63d1c901ab9047c0c637cbfbc3ad352727b2d9e5 diff --git a/src/wizard/CMakeLists.txt b/src/wizard/CMakeLists.txt index d52cde1..50e47aa 100644 --- a/src/wizard/CMakeLists.txt +++ b/src/wizard/CMakeLists.txt @@ -6,10 +6,7 @@ set(wizard_SRCS = pages/discover.cpp pages/connect.cpp - pages/legacypairing.cpp - pages/legacypairingdatabase.cpp - pages/keyboardpairing.cpp - pages/ssppairing.cpp + pages/pairing.cpp pages/fail.cpp pages/success.cpp ) @@ -17,9 +14,7 @@ set(wizard_SRCS ki18n_wrap_ui(wizard_SRCS pages/discover.ui pages/connect.ui - pages/legacypairing.ui - pages/keyboardpairing.ui - pages/ssppairing.ui + pages/pairing.ui pages/fail.ui pages/success.ui ) diff --git a/src/wizard/bluewizard.cpp b/src/wizard/bluewizard.cpp index 8d53d16..058a6e7 100644 --- a/src/wizard/bluewizard.cpp +++ b/src/wizard/bluewizard.cpp @@ -19,10 +19,7 @@ #include "wizardagent.h" #include "pages/discover.h" #include "pages/connect.h" -#include "pages/legacypairing.h" -#include "pages/legacypairingdatabase.h" -#include "pages/keyboardpairing.h" -#include "pages/ssppairing.h" +#include "pages/pairing.h" #include "pages/success.h" #include "pages/fail.h" #include "debug_p.h" @@ -42,16 +39,11 @@ BlueWizard::BlueWizard() : QWizard() , m_agent(new WizardAgent(this)) { - setWindowTitle(i18n("Bluetooth Device Wizard")); - setOption(QWizard::IndependentPages, true); = setPage(Discover, new DiscoverPage(this)); setPage(Connect, new ConnectPage(this)); - setPage(LegacyPairing, new LegacyPairingPage(this)); - setPage(LegacyPairingDatabase, new LegacyPairingPageDatabase(this)); - setPage(KeyboardPairing, new KeyboardPairingPage(this)); - setPage(SSPPairing, new SSPPairingPage(this)); + setPage(Pairing, new PairingPage(this)); setPage(Success, new SuccessPage(this)); setPage(Fail, new FailPage(this)); = @@ -93,18 +85,6 @@ void BlueWizard::setDevice(BluezQt::DevicePtr device) m_device =3D device; } = -void BlueWizard::setPin(const QString &pin) -{ - qCDebug(WIZARD) << "Setting pin:" << pin; - - m_pin =3D pin; -} - -QString BlueWizard::pin() const -{ - return m_pin; -} - WizardAgent *BlueWizard::agent() const { return m_agent; diff --git a/src/wizard/bluewizard.h b/src/wizard/bluewizard.h index c54a1d5..7143262 100644 --- a/src/wizard/bluewizard.h +++ b/src/wizard/bluewizard.h @@ -35,18 +35,12 @@ public: BluezQt::DevicePtr device() const; void setDevice(BluezQt::DevicePtr device); = - QString pin() const; - void setPin(const QString &pin); - WizardAgent *agent() const; BluezQt::Manager *manager() const; = enum { Discover, - LegacyPairing, - LegacyPairingDatabase, - KeyboardPairing, - SSPPairing, + Pairing, Success, Fail, Connect @@ -63,7 +57,6 @@ private: WizardAgent *m_agent; = BluezQt::DevicePtr m_device; - QString m_pin; }; = #endif // BLUEWIZARD_H diff --git a/src/wizard/main.cpp b/src/wizard/main.cpp index 44345ac..857ace1 100644 --- a/src/wizard/main.cpp +++ b/src/wizard/main.cpp @@ -33,9 +33,9 @@ int main(int argc, char *argv[]) { KAboutData aboutData(QStringLiteral("bluedevilwizard"), - i18n("Bluetooth Wizard"), + i18n("Bluetooth Device Wizard"), BLUEDEVIL_VERSION, - i18n("Bluetooth Wizard"), + i18n("Bluetooth Device Wizard"), KAboutLicense::GPL, i18n("(c) 2010, UFO Coders")); = diff --git a/src/wizard/pages/discover.cpp b/src/wizard/pages/discover.cpp index b53b0e5..c9f90b1 100644 --- a/src/wizard/pages/discover.cpp +++ b/src/wizard/pages/discover.cpp @@ -142,7 +142,6 @@ void DiscoverPage::initializePage() = connect(manualPin, &QCheckBox::toggled, pinText, &QLineEdit::setEnable= d); connect(manualPin, &QCheckBox::toggled, this, &DiscoverPage::completeC= hanged); - connect(pinText, &QLineEdit::textChanged, m_wizard, &BlueWizard::setPi= n); connect(pinText, &QLineEdit::textChanged, this, &DiscoverPage::complet= eChanged); = m_manager =3D m_wizard->manager(); @@ -157,8 +156,9 @@ void DiscoverPage::initializePage() m_model->setDevicesModel(new BluezQt::DevicesModel(m_manager, this= )); } = - // Reset selected device deviceView->setCurrentIndex(QModelIndex()); + manualPin->setChecked(false); + pinText->clear(); = checkAdapters(); connect(m_manager, &BluezQt::Manager::adapterAdded, this, &DiscoverPag= e::checkAdapters); @@ -169,7 +169,7 @@ void DiscoverPage::initializePage() = bool DiscoverPage::isComplete() const { - if (!m_wizard->device()) { + if (!m_wizard->device() || m_wizard->device()->isPaired()) { return false; } = @@ -196,56 +196,41 @@ int DiscoverPage::nextId() const = BluezQt::DevicePtr device =3D m_wizard->device(); = + if (device->isPaired()) { + return BlueWizard::Discover; + } + if (m_adapter && m_adapter->isDiscovering()) { qCDebug(WIZARD) << "Stopping scanning"; m_adapter->stopDiscovery(); } = - if (device->isPaired()) { - qCDebug(WIZARD) << "Device is paired, skipping to connect"; - return BlueWizard::Connect; - } + QString pin =3D m_wizard->agent()->getPin(device); = - QString pin; if (manualPin->isChecked()) { - pin =3D m_wizard->pin(); + pin =3D pinText->text(); m_wizard->agent()->setPin(pin); - } else { - pin =3D m_wizard->agent()->getPin(device); } = - qCDebug(WIZARD) << "Class: " << device->deviceType(); + qCDebug(WIZARD) << "Device type: " << BluezQt::Device::typeToString(de= vice->deviceType()); qCDebug(WIZARD) << "Legacy: " << device->hasLegacyPairing(); qCDebug(WIZARD) << "From DB: " << m_wizard->agent()->isFromDatabase(); - qCDebug(WIZARD) << "PIN: " << m_wizard->agent()->pin(); + qCDebug(WIZARD) << "PIN: " << pin; = - // If keyboard no matter what, we go to the keyboard page - if (device->deviceType() =3D=3D BluezQt::Device::Keyboard) { - qCDebug(WIZARD) << "Keyboard Pairing"; - return BlueWizard::KeyboardPairing; - } - - // No legacy pairing and no database pin means secure pairing - if (!device->hasLegacyPairing() && !m_wizard->agent()->isFromDatabase(= )) { - qCDebug(WIZARD) << "Secure Pairing"; - return BlueWizard::SSPPairing; - } - - // NULL pin means that no pairing is required + // NULL pin means that we should only connect to device if (pin =3D=3D QLatin1String("NULL")) { - qCDebug(WIZARD) << "No Pairing"; return BlueWizard::Connect; } = - if (m_wizard->agent()->isFromDatabase()) { - return BlueWizard::LegacyPairingDatabase; - } else { - return BlueWizard::LegacyPairing; - } + return BlueWizard::Pairing; } = void DiscoverPage::indexSelected(const QModelIndex &index) { + if (m_wizard->currentId() !=3D BlueWizard::Discover) { + return; + } + BluezQt::DevicePtr device =3D m_model->device(index); m_wizard->setDevice(device); = diff --git a/src/wizard/pages/discover.ui b/src/wizard/pages/discover.ui index 5faa988..4683632 100644 --- a/src/wizard/pages/discover.ui +++ b/src/wizard/pages/discover.ui @@ -81,19 +81,9 @@ - - - Manual PIN: - - - manualPin - - - - - + Manual PIN: false diff --git a/src/wizard/pages/fail.cpp b/src/wizard/pages/fail.cpp index 63faf8e..61c3119 100644 --- a/src/wizard/pages/fail.cpp +++ b/src/wizard/pages/fail.cpp @@ -63,7 +63,7 @@ void FailPage::initializePage() BluezQt::DevicePtr device =3D m_wizard->device(); = if (device->name().isEmpty()) { - failLbl->setText(i18nc("This string is shown when the wizard fail"= ,"The setup of the device has failed")); + 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", device->name()= )); } diff --git a/src/wizard/pages/keyboardpairing.cpp b/src/wizard/pages/keyboa= rdpairing.cpp deleted file mode 100644 index 8d5558a..0000000 --- a/src/wizard/pages/keyboardpairing.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/*************************************************************************= **** - * This file is part of the KDE project = * - * = * - * Copyright (C) 2010 Alejandro Fiestas Olivares = * - * Copyright (C) 2010-2011 UFO Coders = * - * = * - * 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 Licen= se * - * 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 "keyboardpairing.h" -#include "wizardagent.h" -#include "../bluewizard.h" -#include "debug_p.h" - -#include -#include -#include - -#include -#include -#include - -KeyboardPairingPage::KeyboardPairingPage(BlueWizard *parent) - : QWizardPage(parent) - , m_wizard(parent) - , m_success(false) -{ - setupUi(this); - - m_working =3D new KPixmapSequenceOverlayPainter(this); - m_working->setSequence(KIconLoader::global()->loadPixmapSequence(QStri= ngLiteral("process-working"), 22)); - m_working->setWidget(pinNumber); - m_working->start(); - - QFont font(pinNumber->font()); - font.setPointSize(42); - font.setBold(true); - pinNumber->setFont(font); -} - -int KeyboardPairingPage::nextId() const -{ - if (m_success) { - return BlueWizard::Connect; - } - return BlueWizard::Fail; -} - -void KeyboardPairingPage::initializePage() -{ - qCDebug(WIZARD) << "Initialize Keyboard Pairing Page"; - - m_wizard->setButtonLayout(wizardButtonsLayout()); - - connect(m_wizard->agent(), &WizardAgent::pinRequested, this, &Keyboard= PairingPage::pinRequested); - - // Adapter must be pairable, otherwise pairing would fail - BluezQt::PendingCall *call =3D m_wizard->device()->adapter()->setPaira= ble(true); - connect(call, &BluezQt::PendingCall::finished, this, &KeyboardPairingP= age::setPairableFinished); -} - -void KeyboardPairingPage::setPairableFinished(BluezQt::PendingCall *call) -{ - Q_UNUSED(call) - - BluezQt::PendingCall *pairCall =3D m_wizard->device()->pair(); - connect(pairCall, &BluezQt::PendingCall::finished, this, &KeyboardPair= ingPage::pairingFinished); -} - -void KeyboardPairingPage::pairingFinished(BluezQt::PendingCall *call) -{ - qCDebug(WIZARD) << "Keyboard Pairing finished:"; - qCDebug(WIZARD) << "\t error : " << (bool) call->error(); - qCDebug(WIZARD) << "\t errorText : " << call->errorText(); - - m_success =3D !call->error(); - wizard()->next(); -} - -void KeyboardPairingPage::pinRequested(const QString& pin) -{ - m_working->stop(); - pinNumber->setText(pin); -} - -QList KeyboardPairingPage::wizardButtonsLayout() co= nst -{ - QList list; - list << QWizard::Stretch; - list << QWizard::CancelButton; - return list; -} diff --git a/src/wizard/pages/keyboardpairing.h b/src/wizard/pages/keyboard= pairing.h deleted file mode 100644 index 03ead07..0000000 --- a/src/wizard/pages/keyboardpairing.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************= **** - * This file is part of the KDE project = * - * = * - * Copyright (C) 2010 Alejandro Fiestas Olivares = * - * Copyright (C) 2010-2011 UFO Coders = * - * = * - * 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 Licen= se * - * 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 KEYBOARDPAIRING_H -#define KEYBOARDPAIRING_H - -#include "ui_keyboardpairing.h" - -#include - -namespace BluezQt -{ - class PendingCall; -} - -class BlueWizard; -class KPixmapSequenceOverlayPainter; - -class KeyboardPairingPage : public QWizardPage, Ui::KeyboardPairing -{ - Q_OBJECT - -public: - explicit KeyboardPairingPage(BlueWizard *parent =3D 0); - - int nextId() const Q_DECL_OVERRIDE; - void initializePage() Q_DECL_OVERRIDE; - -private Q_SLOTS: - void setPairableFinished(BluezQt::PendingCall *call); - void pairingFinished(BluezQt::PendingCall *call); - void pinRequested(const QString &pin); - -protected: - QList wizardButtonsLayout() const; - -private: - BlueWizard *m_wizard; - KPixmapSequenceOverlayPainter *m_working; - bool m_success; -}; - -#endif // KEYBOARDPAIRING_H diff --git a/src/wizard/pages/keyboardpairing.ui b/src/wizard/pages/keyboar= dpairing.ui deleted file mode 100644 index 1c8ad92..0000000 --- a/src/wizard/pages/keyboardpairing.ui +++ /dev/null @@ -1,147 +0,0 @@ - - - KeyboardPairing - - - - 0 - 0 - 400 - 300 - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 22 - 22 - - - - QFrame::NoFrame - - - QFrame::Raised - - - 0 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Please introduce the PIN in your keyboard when it appears = and press Enter - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - diff --git a/src/wizard/pages/legacypairing.cpp b/src/wizard/pages/legacypa= iring.cpp deleted file mode 100644 index d755b12..0000000 --- a/src/wizard/pages/legacypairing.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/*************************************************************************= **** - * This file is part of the KDE project = * - * = * - * Copyright (C) 2010 Alejandro Fiestas Olivares = * - * Copyright (C) 2010-2011 UFO Coders = * - * = * - * 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 Licen= se * - * 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 "legacypairing.h" -#include "../bluewizard.h" -#include "../wizardagent.h" -#include "debug_p.h" - -#include -#include -#include - -#include -#include -#include - -LegacyPairingPage::LegacyPairingPage(BlueWizard *parent) - : QWizardPage(parent) - , m_wizard(parent) - , m_success(false) -{ - setupUi(this); - - m_working =3D new KPixmapSequenceOverlayPainter(this); - m_working->setSequence(KIconLoader::global()->loadPixmapSequence(QStri= ngLiteral("process-working"), 22)); - m_working->setWidget(pinNumber); - m_working->start(); - - QFont font(pinNumber->font()); - font.setPointSize(42); - font.setBold(true); - pinNumber->setFont(font); -} - -int LegacyPairingPage::nextId() const -{ - if (m_success) { - return BlueWizard::Connect; - } - return BlueWizard::Fail; -} - -void LegacyPairingPage::initializePage() -{ - qCDebug(WIZARD) << "Initialize Legacy Pairing Page"; - - m_wizard->setButtonLayout(wizardButtonsLayout()); - - connect(m_wizard->agent(), &WizardAgent::pinRequested, this, &LegacyPa= iringPage::pinRequested); - - // Adapter must be pairable, otherwise pairing would fail - BluezQt::PendingCall *call =3D m_wizard->device()->adapter()->setPaira= ble(true); - connect(call, &BluezQt::PendingCall::finished, this, &LegacyPairingPag= e::setPairableFinished); -} - -void LegacyPairingPage::setPairableFinished(BluezQt::PendingCall *call) -{ - Q_UNUSED(call) - - BluezQt::PendingCall *pairCall =3D m_wizard->device()->pair(); - connect(pairCall, &BluezQt::PendingCall::finished, this, &LegacyPairin= gPage::pairingFinished); -} - -void LegacyPairingPage::pairingFinished(BluezQt::PendingCall *call) -{ - qCDebug(WIZARD) << "Legacy Pairing finished:"; - qCDebug(WIZARD) << "\t error : " << (bool) call->error(); - qCDebug(WIZARD) << "\t errorText : " << call->errorText(); - - m_success =3D !call->error(); - wizard()->next(); -} - -void LegacyPairingPage::pinRequested(const QString &pin) -{ - m_working->stop(); - pinNumber->setText(pin); -} - -QList LegacyPairingPage::wizardButtonsLayout() const -{ - QList list; - list << QWizard::Stretch; - list << QWizard::CancelButton; - return list; -} diff --git a/src/wizard/pages/legacypairing.h b/src/wizard/pages/legacypair= ing.h deleted file mode 100644 index 730257c..0000000 --- a/src/wizard/pages/legacypairing.h +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************= **** - * This file is part of the KDE project = * - * = * - * Copyright (C) 2010 Alejandro Fiestas Olivares = * - * Copyright (C) 2010-2011 UFO Coders = * - * = * - * 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 Licen= se * - * 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 LEGACYPAIRING_H -#define LEGACYPAIRING_H - -#include "ui_legacypairing.h" - -#include - -namespace BluezQt -{ - class PendingCall; -} - -class BlueWizard; -class KPixmapSequenceOverlayPainter; - -class LegacyPairingPage : public QWizardPage, Ui::LegacyPairing -{ - Q_OBJECT - -public: - explicit LegacyPairingPage(BlueWizard *parent =3D 0); - - int nextId() const Q_DECL_OVERRIDE; - void initializePage() Q_DECL_OVERRIDE; - -public Q_SLOTS: - void setPairableFinished(BluezQt::PendingCall *call); - void pairingFinished(BluezQt::PendingCall *call); - void pinRequested(const QString &pin); - -private: - QList wizardButtonsLayout() const; - - BlueWizard *m_wizard; - KPixmapSequenceOverlayPainter *m_working; - bool m_success; -}; - -#endif // LEGACYPAIRING_H diff --git a/src/wizard/pages/legacypairing.ui b/src/wizard/pages/legacypai= ring.ui deleted file mode 100644 index 4d909e5..0000000 --- a/src/wizard/pages/legacypairing.ui +++ /dev/null @@ -1,147 +0,0 @@ - - - LegacyPairing - - - - 0 - 0 - 400 - 300 - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 22 - 22 - - - - QFrame::NoFrame - - - QFrame::Raised - - - 0 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Please introduce the PIN in your device when it appears - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - diff --git a/src/wizard/pages/legacypairingdatabase.cpp b/src/wizard/pages/= legacypairingdatabase.cpp deleted file mode 100644 index 76780b3..0000000 --- a/src/wizard/pages/legacypairingdatabase.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/*************************************************************************= **** - * This file is part of the KDE project = * - * = * - * Copyright (C) 2010 Alejandro Fiestas Olivares = * - * Copyright (C) 2010-2011 UFO Coders = * - * = * - * 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 Licen= se * - * 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 "legacypairingdatabase.h" -#include "../bluewizard.h" -#include "../wizardagent.h" -#include "debug_p.h" - -#include - -#include -#include -#include - -LegacyPairingPageDatabase::LegacyPairingPageDatabase(BlueWizard *parent) - : QWizardPage(parent) - , m_wizard(parent) - , m_success(false) -{ - setupUi(this); -} - -int LegacyPairingPageDatabase::nextId() const -{ - if (m_success) { - return BlueWizard::Connect; - } - return BlueWizard::Fail; -} - -void LegacyPairingPageDatabase::initializePage() -{ - qCDebug(WIZARD) << "Initialize Legacy Database Pairing Page"; - - m_wizard->setButtonLayout(wizardButtonsLayout()); - - BluezQt::DevicePtr device =3D m_wizard->device(); - connecting->setText(i18nc("Connecting to a Bluetooth device", "Connect= ing to %1...", device->name())); - - // Adapter must be pairable, otherwise pairing would fail - BluezQt::PendingCall *call =3D device->adapter()->setPairable(true); - connect(call, &BluezQt::PendingCall::finished, this, &LegacyPairingPag= eDatabase::setPairableFinished); -} - -void LegacyPairingPageDatabase::setPairableFinished(BluezQt::PendingCall *= call) -{ - Q_UNUSED(call) - - BluezQt::PendingCall *pairCall =3D m_wizard->device()->pair(); - connect(pairCall, &BluezQt::PendingCall::finished, this, &LegacyPairin= gPageDatabase::pairingFinished); -} - -void LegacyPairingPageDatabase::pairingFinished(BluezQt::PendingCall *call) -{ - qCDebug(WIZARD) << "Legacy Database Pairing finished:"; - qCDebug(WIZARD) << "\t error : " << (bool) call->error(); - qCDebug(WIZARD) << "\t errorText : " << call->errorText(); - - m_success =3D !call->error(); - wizard()->next(); -} - -QList< QWizard::WizardButton > LegacyPairingPageDatabase::wizardButtonsLay= out() const -{ - QList list; - list << QWizard::Stretch; - list << QWizard::CancelButton; - return list; -} diff --git a/src/wizard/pages/legacypairingdatabase.h b/src/wizard/pages/le= gacypairingdatabase.h deleted file mode 100644 index 4b73c2f..0000000 --- a/src/wizard/pages/legacypairingdatabase.h +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************= **** - * This file is part of the KDE project = * - * = * - * Copyright (C) 2010 Alejandro Fiestas Olivares = * - * Copyright (C) 2010-2011 UFO Coders = * - * = * - * 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 Licen= se * - * 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 LEGACYPAIRINGDATABASE_H -#define LEGACYPAIRINGDATABASE_H - -#include "ui_connect.h" - -#include - -namespace BluezQt -{ - class PendingCall; -} - -class BlueWizard; - -class LegacyPairingPageDatabase : public QWizardPage, Ui::Connect -{ - Q_OBJECT - -public: - explicit LegacyPairingPageDatabase(BlueWizard *parent =3D 0); - - int nextId() const Q_DECL_OVERRIDE; - void initializePage() Q_DECL_OVERRIDE; - -public Q_SLOTS: - void setPairableFinished(BluezQt::PendingCall *call); - void pairingFinished(BluezQt::PendingCall *call); - -protected: - QList wizardButtonsLayout() const; - -private: - BlueWizard *m_wizard; - bool m_success; -}; - -#endif // LEGACYPAIRINGDATABASE_H diff --git a/src/wizard/pages/ssppairing.cpp b/src/wizard/pages/pairing.cpp similarity index 58% rename from src/wizard/pages/ssppairing.cpp rename to src/wizard/pages/pairing.cpp index f710c49..6b8622e 100644 --- a/src/wizard/pages/ssppairing.cpp +++ b/src/wizard/pages/pairing.cpp @@ -1,8 +1,7 @@ /*************************************************************************= **** * This file is part of the KDE project = * * = * - * Copyright (C) 2010 Alejandro Fiestas Olivares = * - * Copyright (C) 2010-2011 UFO Coders = * + * Copyright (C) 2015 David Rosca = * * = * * This library is free software; you can redistribute it and/or = * * modify it under the terms of the GNU Library General Public = * @@ -20,7 +19,7 @@ * Boston, MA 02110-1301, USA. = * *************************************************************************= ****/ = -#include "ssppairing.h" +#include "pairing.h" #include "../bluewizard.h" #include "../wizardagent.h" #include "debug_p.h" @@ -30,32 +29,25 @@ #include #include #include -#include -#include = #include #include #include = -SSPPairingPage::SSPPairingPage(BlueWizard *parent) +PairingPage::PairingPage(BlueWizard *parent) : QWizardPage(parent) , m_wizard(parent) , m_success(false) { setupUi(this); = - m_working =3D new KPixmapSequenceOverlayPainter(this); - m_working->setSequence(KIconLoader::global()->loadPixmapSequence(QStri= ngLiteral("process-working"), 22)); - m_working->setWidget(pinNumber); - m_working->start(); - QFont font(pinNumber->font()); font.setPointSize(42); font.setBold(true); pinNumber->setFont(font); } = -int SSPPairingPage::nextId() const +int PairingPage::nextId() const { if (m_success) { return BlueWizard::Connect; @@ -63,54 +55,69 @@ int SSPPairingPage::nextId() const return BlueWizard::Fail; } = -void SSPPairingPage::initializePage() +void PairingPage::initializePage() { - qCDebug(WIZARD) << "Initialize Secure Simple Pairing Page"; + qCDebug(WIZARD) << "Initialize Pairing Page"; = - QList list; - list << QWizard::Stretch; - list << QWizard::CustomButton1; - m_wizard->setButtonLayout(list); + m_device =3D m_wizard->device(); + m_wizard->setButtonLayout(wizardButtonsLayout()); = QPushButton *cancel =3D new QPushButton(this); KGuiItem::assign(cancel, KStandardGuiItem::cancel()); - - connect(cancel, &QPushButton::clicked, this, &SSPPairingPage::cancelCl= icked); + connect(cancel, &QPushButton::clicked, this, &PairingPage::cancelClick= ed); wizard()->setButton(QWizard::CustomButton1, cancel); = - BluezQt::DevicePtr device =3D m_wizard->device(); - confirmLbl->setText(i18n("Connecting to %1...", device->name())); + frame->hide(); + progressBar->show(); + connectingLbl->show(); + confirmLbl->clear(); = - connect(m_wizard->agent(), &WizardAgent::confirmationRequested, this, = &SSPPairingPage::confirmationRequested); - connect(m_wizard->agent(), &WizardAgent::pinRequested, this, &SSPPairi= ngPage::pinRequested); + connectingLbl->setText(i18n("Connecting to %1...", m_device->name())); = - // Adapter must be pairable, otherwise pairing would fail - BluezQt::PendingCall *call =3D device->adapter()->setPairable(true); - connect(call, &BluezQt::PendingCall::finished, this, &SSPPairingPage::= setPairableFinished); -} + connect(m_wizard->agent(), &WizardAgent::pinRequested, this, &PairingP= age::pinRequested); + connect(m_wizard->agent(), &WizardAgent::confirmationRequested, this, = &PairingPage::confirmationRequested); = -void SSPPairingPage::setPairableFinished(BluezQt::PendingCall *call) -{ - Q_UNUSED(call) - - BluezQt::PendingCall *pairCall =3D m_wizard->device()->pair(); - connect(pairCall, &BluezQt::PendingCall::finished, this, &SSPPairingPa= ge::pairingFinished); + BluezQt::PendingCall *pairCall =3D m_device->pair(); + connect(pairCall, &BluezQt::PendingCall::finished, this, &PairingPage:= :pairingFinished); } = -void SSPPairingPage::pairingFinished(BluezQt::PendingCall *call) +void PairingPage::pairingFinished(BluezQt::PendingCall *call) { - qCDebug(WIZARD) << "Secure Pairing finished:"; + qCDebug(WIZARD) << "Pairing finished:"; qCDebug(WIZARD) << "\t error : " << (bool) call->error(); qCDebug(WIZARD) << "\t errorText : " << call->errorText(); = m_success =3D !call->error(); - wizard()->next(); + m_wizard->next(); } = -void SSPPairingPage::confirmationRequested(const QString &passkey, const B= luezQt::Request<> &req) +void PairingPage::pinRequested(const QString &pin) +{ + // Don't ask user to introduce the PIN if it was used from database + if (m_wizard->agent()->isFromDatabase()) { + return; + } + + frame->show(); + connectingLbl->hide(); + progressBar->hide(); + + if (m_device->deviceType() =3D=3D BluezQt::Device::Keyboard) { + confirmLbl->setText(i18n("Please introduce the PIN in your keyboar= d when it appears and press Enter")); + } else { + confirmLbl->setText(i18n("Please introduce the PIN in your device = when it appears")); + } + pinNumber->setText(pin); +} + +void PairingPage::confirmationRequested(const QString &passkey, const Blue= zQt::Request<> &req) { m_req =3D req; = + frame->show(); + connectingLbl->hide(); + progressBar->hide(); + QPushButton *matches =3D new QPushButton(this); KGuiItem::assign(matches, KStandardGuiItem::apply()); matches->setText(i18n("Matches")); @@ -119,28 +126,23 @@ void SSPPairingPage::confirmationRequested(const QStr= ing &passkey, const BluezQt KGuiItem::assign(notMatch, KStandardGuiItem::cancel()); notMatch->setText(i18n("Does not match")); = - connect(matches, &QPushButton::clicked, this, &SSPPairingPage::matches= Clicked); - connect(notMatch, &QPushButton::clicked, this, &SSPPairingPage::notMat= chClicked); + connect(matches, &QPushButton::clicked, this, &PairingPage::matchesCli= cked); + connect(notMatch, &QPushButton::clicked, this, &PairingPage::notMatchC= licked); = - wizard()->setButton(QWizard::CustomButton1, matches); - wizard()->setButton(QWizard::CustomButton2, notMatch); + m_wizard->setButton(QWizard::CustomButton1, matches); + m_wizard->setButton(QWizard::CustomButton2, notMatch); = - wizard()->setButtonLayout(wizardButtonsLayout()); + QList list; + list << QWizard::Stretch; + list << QWizard::CustomButton1; + list << QWizard::CustomButton2; + m_wizard->setButtonLayout(list); = - m_working->stop(); pinNumber->setText(passkey); - - confirmLbl->setText(i18n("Please, confirm that the PIN displayed on \"= %1\" matches the wizard one.", m_wizard->device()->name())); + confirmLbl->setText(i18n("Please, confirm that the PIN displayed on %1= matches the wizard one.", m_wizard->device()->name())); } = -void SSPPairingPage::pinRequested(const QString& pin) -{ - m_working->stop(); - pinNumber->setText(pin); - confirmLbl->setText(i18n("Please introduce the PIN in your device when= it appears")); -} - -void SSPPairingPage::matchesClicked() +void PairingPage::matchesClicked() { wizard()->button(QWizard::CustomButton1)->setEnabled(false); wizard()->button(QWizard::CustomButton2)->setEnabled(false); @@ -148,21 +150,20 @@ void SSPPairingPage::matchesClicked() m_req.accept(); } = -void SSPPairingPage::notMatchClicked() +void PairingPage::notMatchClicked() { m_req.reject(); } = -void SSPPairingPage::cancelClicked() +void PairingPage::cancelClicked() { - m_wizard->device()->cancelPairing(); + m_device->cancelPairing(); } = -QList SSPPairingPage::wizardButtonsLayout() const +QList PairingPage::wizardButtonsLayout() const { QList list; list << QWizard::Stretch; list << QWizard::CustomButton1; - list << QWizard::CustomButton2; return list; } diff --git a/src/wizard/pages/ssppairing.h b/src/wizard/pages/pairing.h similarity index 80% rename from src/wizard/pages/ssppairing.h rename to src/wizard/pages/pairing.h index 0efe2a0..f573821 100644 --- a/src/wizard/pages/ssppairing.h +++ b/src/wizard/pages/pairing.h @@ -1,8 +1,7 @@ /*************************************************************************= **** * This file is part of the KDE project = * * = * - * Copyright (C) 2010 Alejandro Fiestas Olivares = * - * Copyright (C) 2010-2011 UFO Coders = * + * Copyright (C) 2015 David Rosca = * * = * * This library is free software; you can redistribute it and/or = * * modify it under the terms of the GNU Library General Public = * @@ -20,38 +19,32 @@ * Boston, MA 02110-1301, USA. = * *************************************************************************= ****/ = -#ifndef SSPPAIRINGPAGE_H -#define SSPPAIRINGPAGE_H +#ifndef PAIRINGPAGE_H +#define PAIRINGPAGE_H = -#include "ui_ssppairing.h" +#include "ui_pairing.h" = #include = +#include #include = -namespace BluezQt -{ - class PendingCall; -} - class BlueWizard; -class KPixmapSequenceOverlayPainter; = -class SSPPairingPage : public QWizardPage, Ui::SSPPairing +class PairingPage : public QWizardPage, Ui::Pairing { Q_OBJECT = public: - explicit SSPPairingPage(BlueWizard *parent =3D 0); + explicit PairingPage(BlueWizard *parent =3D Q_NULLPTR); = int nextId() const Q_DECL_OVERRIDE; void initializePage() Q_DECL_OVERRIDE; = public Q_SLOTS: - void setPairableFinished(BluezQt::PendingCall *call); void pairingFinished(BluezQt::PendingCall *call); - void confirmationRequested(const QString &passkey, const BluezQt::Requ= est<> &req); void pinRequested(const QString &pin); + void confirmationRequested(const QString &passkey, const BluezQt::Requ= est<> &req); void matchesClicked(); void notMatchClicked(); void cancelClicked(); @@ -60,9 +53,9 @@ private: QList wizardButtonsLayout() const; = BlueWizard *m_wizard; - KPixmapSequenceOverlayPainter *m_working; + BluezQt::DevicePtr m_device; BluezQt::Request<> m_req; bool m_success; }; = -#endif // SSPPAIRINGPAGE_H +#endif // PAIRINGPAGE_H diff --git a/src/wizard/pages/ssppairing.ui b/src/wizard/pages/pairing.ui similarity index 85% rename from src/wizard/pages/ssppairing.ui rename to src/wizard/pages/pairing.ui index 673df77..7790b7c 100644 --- a/src/wizard/pages/ssppairing.ui +++ b/src/wizard/pages/pairing.ui @@ -1,7 +1,7 @@ - SSPPairing - + Pairing + 0 @@ -12,6 +12,16 @@ + + + + + + 0 + + + + QFrame::StyledPanel @@ -94,9 +104,12 @@ Qt::Horizontal + + QSizePolicy::Fixed + - 40 + 50 20 @@ -107,15 +120,12 @@ true - - - 0 - 0 - - + + Qt::AlignCenter + true @@ -126,9 +136,12 @@ Qt::Horizontal + + QSizePolicy::Fixed + - 40 + 50 20 diff --git a/src/wizard/wizardagent.cpp b/src/wizard/wizardagent.cpp index a0b4b04..1737228 100644 --- a/src/wizard/wizardagent.cpp +++ b/src/wizard/wizardagent.cpp @@ -45,6 +45,7 @@ QString WizardAgent::pin() void WizardAgent::setPin(const QString &pin) { m_pin =3D pin; + m_fromDatabase =3D false; } = bool WizardAgent::isFromDatabase() @@ -54,10 +55,7 @@ bool WizardAgent::isFromDatabase() = QString WizardAgent::getPin(BluezQt::DevicePtr device) { - if (!m_pin.isEmpty() || !device) { - return m_pin; - } - + m_fromDatabase =3D false; m_pin =3D QString::number(KRandom::random()); m_pin =3D m_pin.left(6); = @@ -164,8 +162,3 @@ void WizardAgent::requestConfirmation(BluezQt::DevicePt= r device, const QString & = Q_EMIT confirmationRequested(passkey, req); } - -void WizardAgent::release() -{ - Q_EMIT agentReleased(); -} diff --git a/src/wizard/wizardagent.h b/src/wizard/wizardagent.h index 31598ef..831edda 100644 --- a/src/wizard/wizardagent.h +++ b/src/wizard/wizardagent.h @@ -43,12 +43,10 @@ public: void requestPasskey(BluezQt::DevicePtr device, const BluezQt::Request<= quint32> &req) Q_DECL_OVERRIDE; void displayPasskey(BluezQt::DevicePtr device, const QString &passkey,= const QString &entered) Q_DECL_OVERRIDE; void requestConfirmation(BluezQt::DevicePtr device, const QString &pas= skey, const BluezQt::Request<> &req) Q_DECL_OVERRIDE; - void release() Q_DECL_OVERRIDE; = Q_SIGNALS: void pinRequested(const QString &pin); void confirmationRequested(const QString &passkey, const BluezQt::Requ= est<> &req); - void agentReleased(); = private: bool m_fromDatabase;