diff --git a/src/kcmodule/devices/devicedetails.ui b/src/kcmodule/devices/devicedetails.ui index 651b29e3..d75d975d 100644 --- a/src/kcmodule/devices/devicedetails.ui +++ b/src/kcmodule/devices/devicedetails.ui @@ -1,249 +1,252 @@ DeviceDetails 0 0 341 468 Qt::Horizontal 20 20 128 128 16777215 128 Qt::AlignCenter Qt::Horizontal 40 20 Qt::Horizontal 40 20 Qt::Vertical QSizePolicy::Fixed 20 10 + + Qt::PlainText + Qt::AlignCenter true Type: Address: Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse Name: true Trusted: Blocked: Actions: Send File Setup NAP Network... Setup DUN Network... Adapter: Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse Qt::Vertical 20 0 Qt::Horizontal 20 20 diff --git a/src/kded/helpers/requestauthorization.cpp b/src/kded/helpers/requestauthorization.cpp index 7d0e9788..4596deaa 100644 --- a/src/kded/helpers/requestauthorization.cpp +++ b/src/kded/helpers/requestauthorization.cpp @@ -1,83 +1,83 @@ /*************************************************************************** * Copyright (C) 2010 Alejandro Fiestas Olivares * * Copyright (C) 2010 Eduardo Robles Elvira * * Copyright (C) 2010 UFO Coders * * Copyright (C) 2014-2015 David Rosca * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "requestauthorization.h" #include "debug_p.h" #include #include #include RequestAuthorization::RequestAuthorization(BluezQt::DevicePtr device, QObject *parent) : QObject(parent) , m_device(device) { KNotification *notification = new KNotification(QStringLiteral("Authorize"), KNotification::Persistent, this); notification->setComponentName(QStringLiteral("bluedevil")); - notification->setTitle(QStringLiteral("%1 (%2)").arg(m_device->name(), m_device->address())); + notification->setTitle(QStringLiteral("%1 (%2)").arg(m_device->name().toHtmlEscaped(), m_device->address().toHtmlEscaped())); 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", m_device->name())); + "%1 is requesting access to this computer", m_device->name().toHtmlEscaped())); QStringList actions; actions.append(i18nc("Button to trust a bluetooth remote device and authorize it to connect", "Trust && Authorize")); 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, &KNotification::action1Activated, this, &RequestAuthorization::authorizeAndTrust); connect(notification, &KNotification::action2Activated, this, &RequestAuthorization::authorize); connect(notification, &KNotification::action3Activated, this, &RequestAuthorization::deny); connect(notification, &KNotification::closed, this, &RequestAuthorization::deny); connect(notification, &KNotification::ignored, this, &RequestAuthorization::deny); notification->sendEvent(); } void RequestAuthorization::authorizeAndTrust() { qCDebug(BLUEDAEMON) << "Authorization accepted and trusted:" << m_device->name() << m_device->address(); deleteLater(); Q_EMIT done(AcceptAndTrust); } void RequestAuthorization::authorize() { qCDebug(BLUEDAEMON) << "Authorization accepted:" << m_device->name() << m_device->address(); deleteLater(); Q_EMIT done(Accept); } void RequestAuthorization::deny() { qCDebug(BLUEDAEMON) << "Authorization denied:" << m_device->name() << m_device->address(); deleteLater(); Q_EMIT done(Deny); } diff --git a/src/kded/helpers/requestconfirmation.cpp b/src/kded/helpers/requestconfirmation.cpp index eb491f92..37ea090c 100644 --- a/src/kded/helpers/requestconfirmation.cpp +++ b/src/kded/helpers/requestconfirmation.cpp @@ -1,71 +1,71 @@ /*************************************************************************** * Copyright (C) 2010 Alejandro Fiestas Olivares * * Copyright (C) 2010 Eduardo Robles Elvira * * Copyright (C) 2010 UFO Coders * * Copyright (C) 2014-2015 David Rosca * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "requestconfirmation.h" #include "debug_p.h" #include #include RequestConfirmation::RequestConfirmation(BluezQt::DevicePtr device, const QString &pin, QObject *parent) : QObject(parent) , m_device(device) , m_pin(pin) { KNotification *notification = new KNotification(QStringLiteral("RequestConfirmation"), KNotification::Persistent, this); notification->setComponentName(QStringLiteral("bluedevil")); - notification->setTitle(QStringLiteral("%1 (%2)").arg(m_device->name(), m_device->address())); + notification->setTitle(QStringLiteral("%1 (%2)").arg(m_device->name().toHtmlEscaped(), m_device->address())); 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", m_device->name(), m_pin)); + "%1 is asking if the PIN is correct: %2", m_device->name().toHtmlEscaped(), m_pin)); QStringList actions; actions.append(i18nc("Notification button to know if the pin is correct or not", "PIN correct")); actions.append(i18nc("Notification button to say that the PIN is wrong", "PIN incorrect")); notification->setActions(actions); 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); notification->sendEvent(); } void RequestConfirmation::pinCorrect() { qCDebug(BLUEDAEMON) << "PIN correct:" << m_device->name() << m_device->address(); deleteLater(); Q_EMIT done(Accept); } void RequestConfirmation::pinWrong() { qCDebug(BLUEDAEMON) << "PIN wrong:" << m_device->name() << m_device->address(); deleteLater(); Q_EMIT done(Deny); } diff --git a/src/kded/helpers/requestpin.cpp b/src/kded/helpers/requestpin.cpp index c394d5c9..cfb90e08 100644 --- a/src/kded/helpers/requestpin.cpp +++ b/src/kded/helpers/requestpin.cpp @@ -1,133 +1,133 @@ /*************************************************************************** * Copyright (C) 2010 Alejandro Fiestas Olivares * * Copyright (C) 2010 Eduardo Robles Elvira * * Copyright (C) 2010 UFO Coders * * Copyright (C) 2014-2015 David Rosca * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "requestpin.h" #include "ui_requestpin.h" #include "debug_p.h" #include #include #include #include #include #include #include RequestPin::RequestPin(BluezQt::DevicePtr device, bool numeric, QObject *parent) : QObject(parent) , m_dialogWidget(0) , m_device(device) , m_numeric(numeric) { m_notification = new KNotification(QStringLiteral("RequestPin"), KNotification::Persistent, this); m_notification->setComponentName(QStringLiteral("bluedevil")); - m_notification->setTitle(QStringLiteral("%1 (%2)").arg(m_device->name(), m_device->address())); + m_notification->setTitle(QStringLiteral("%1 (%2)").arg(m_device->name().toHtmlEscaped(), m_device->address().toHtmlEscaped())); 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", m_device->name())); + "PIN needed to pair with %1", m_device->name().toHtmlEscaped())); QStringList actions; actions.append(i18nc("Notification button which once clicked, a dialog to introduce the PIN will be shown", "Introduce PIN")); m_notification->setActions(actions); connect(m_notification, &KNotification::action1Activated,this, &RequestPin::introducePin); connect(m_notification, &KNotification::closed, this, &RequestPin::quit); connect(m_notification, &KNotification::ignored, this, &RequestPin::quit); m_notification->sendEvent(); } void RequestPin::introducePin() { m_notification->disconnect(); m_notification->close(); m_notification->deleteLater(); QDialog *dialog = new QDialog; dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->setWindowIcon(QIcon::fromTheme(QStringLiteral("preferences-system-bluetooth"))); dialog->setWindowTitle(i18nc("Shown in the caption of a dialog where the user introduce the PIN", "Introduce PIN")); m_dialogWidget = new Ui::DialogWidget; m_dialogWidget->setupUi(dialog); 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.", m_device->name())); m_dialogWidget->pixmap->setPixmap(QIcon::fromTheme(QStringLiteral("preferences-system-bluetooth")).pixmap(64)); m_dialogWidget->pin->setFocus(Qt::ActiveWindowFocusReason); if (m_numeric) { QRegularExpression rx(QStringLiteral("[0-9]{1,6}")); m_dialogWidget->pin->setValidator(new QRegularExpressionValidator(rx, this)); } else { QRegularExpression rx(QStringLiteral("[A-Za-z0-9]{1,16}")); m_dialogWidget->pin->setValidator(new QRegularExpressionValidator(rx, this)); } m_dialogWidget->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); dialog->setFixedSize(dialog->sizeHint()); connect(dialog, &QDialog::finished, this, &RequestPin::dialogFinished); connect(m_dialogWidget->pin, &QLineEdit::textChanged, this, &RequestPin::checkPin); connect(m_dialogWidget->buttonBox, &QDialogButtonBox::accepted, dialog, &QDialog::accept); connect(m_dialogWidget->buttonBox, &QDialogButtonBox::rejected, dialog, &QDialog::reject); dialog->show(); KWindowSystem::setState(dialog->winId(), NET::KeepAbove); KWindowSystem::forceActiveWindow(dialog->winId()); } void RequestPin::checkPin(const QString &pin) { m_dialogWidget->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!pin.isEmpty()); } void RequestPin::dialogFinished(int result) { deleteLater(); if (!result) { qCDebug(BLUEDAEMON) << "PIN dialog rejected:" << m_device->name() << m_device->address(); Q_EMIT done(QString()); return; } qCDebug(BLUEDAEMON) << "PIN dialog accepted:" << m_device->name() << m_device->address(); Q_EMIT done(m_dialogWidget->pin->text().toLatin1().constData()); } void RequestPin::quit() { qCDebug(BLUEDAEMON) << "Rejected to introduce PIN:" << m_device->name() << m_device->address(); deleteLater(); Q_EMIT done(QString()); } diff --git a/src/kded/receivefilejob.cpp b/src/kded/receivefilejob.cpp index 1c68d892..0bd7ecc0 100644 --- a/src/kded/receivefilejob.cpp +++ b/src/kded/receivefilejob.cpp @@ -1,280 +1,280 @@ /************************************************************************************* * Copyright (C) 2013 by Alejandro Fiestas Fiestas * * Copyright (C) 2014-2015 David Rosca * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation; either version 2 * * of the License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * *************************************************************************************/ #include "receivefilejob.h" #include "filereceiversettings.h" #include "obexagent.h" #include "debug_p.h" #include #include #include #include #include #include #include #include #include #include #include #include ReceiveFileJob::ReceiveFileJob(const BluezQt::Request &req, BluezQt::ObexTransferPtr transfer, BluezQt::ObexSessionPtr session, ObexAgent *parent) : KJob(parent) , m_speedBytes(0) , m_agent(parent) , m_transfer(transfer) , m_session(session) , m_request(req) , m_accepted(false) { setCapabilities(Killable); } QString ReceiveFileJob::deviceAddress() const { return m_deviceAddress; } void ReceiveFileJob::start() { QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection); } bool ReceiveFileJob::doKill() { qCDebug(BLUEDAEMON) << "ReceiveFileJob-Kill"; m_transfer->cancel(); return true; } void ReceiveFileJob::init() { qCDebug(BLUEDAEMON) << "ReceiveFileJob:"; qCDebug(BLUEDAEMON) << "\tName:" << m_transfer->name(); qCDebug(BLUEDAEMON) << "\tFilename:" << m_transfer->fileName(); qCDebug(BLUEDAEMON) << "\tStatus:" << m_transfer->status(); qCDebug(BLUEDAEMON) << "\tType:" << m_transfer->type(); qCDebug(BLUEDAEMON) << "\tSize:" << m_transfer->size(); qCDebug(BLUEDAEMON) << "\tTransferred:" << m_transfer->transferred(); qCDebug(BLUEDAEMON) << "ObexSession:"; qCDebug(BLUEDAEMON) << "\tSource:" << m_session->source(); qCDebug(BLUEDAEMON) << "\tDestination:" << m_session->destination(); connect(m_transfer.data(), &BluezQt::ObexTransfer::statusChanged, this, &ReceiveFileJob::statusChanged); connect(m_transfer.data(), &BluezQt::ObexTransfer::transferredChanged, this, &ReceiveFileJob::transferredChanged); m_deviceName = m_session->destination(); BluezQt::AdapterPtr adapter = m_agent->manager()->adapterForAddress(m_session->source()); if (!adapter) { qCDebug(BLUEDAEMON) << "No adapter for" << m_session->source(); showNotification(); return; } BluezQt::DevicePtr device = adapter->deviceForAddress(m_session->destination()); if (!device) { qCDebug(BLUEDAEMON) << "No device for" << m_session->destination(); showNotification(); return; } m_deviceName = device->name(); m_deviceAddress = device->address(); if (m_agent->shouldAutoAcceptTransfer(m_deviceAddress)) { slotAccept(); return; } FileReceiverSettings::self()->load(); switch (FileReceiverSettings::self()->autoAccept()) { case 0: // Never auto-accept transfers showNotification(); break; case 1: // Auto-accept only from trusted devices if (device->isTrusted()) { qCDebug(BLUEDAEMON) << "Auto-accepting transfer for trusted device"; slotAccept(); } else { showNotification(); } break; case 2: // Auto-accept all transfers qCDebug(BLUEDAEMON) << "Auto-accepting transfers for all devices"; slotAccept(); break; default: // Unknown showNotification(); break; } } void ReceiveFileJob::showNotification() { KNotification *notification = new KNotification(QStringLiteral("IncomingFile"), KNotification::Persistent, this); - notification->setTitle(QStringLiteral("%1 (%2)").arg(m_deviceName, m_deviceAddress)); + notification->setTitle(QStringLiteral("%1 (%2)").arg(m_deviceName.toHtmlEscaped(), m_deviceAddress)); notification->setText(i18nc( "Show a notification asking to authorize or deny an incoming file transfer to this computer from a Bluetooth device.", - "%1 is sending you the file %2", m_deviceName, m_transfer->name())); + "%1 is sending you the file %2", m_deviceName.toHtmlEscaped(), m_transfer->name())); QStringList actions; actions.append(i18nc("Button to accept the incoming file transfer and download it in the default download directory", "Accept")); actions.append(i18nc("Deny the incoming file transfer", "Cancel")); notification->setActions(actions); connect(notification, &KNotification::action1Activated, this, &ReceiveFileJob::slotAccept); connect(notification, &KNotification::action2Activated, this, &ReceiveFileJob::slotCancel); connect(notification, &KNotification::closed, this, &ReceiveFileJob::slotCancel); notification->setComponentName(QStringLiteral("bluedevil")); notification->sendEvent(); } void ReceiveFileJob::slotAccept() { qCDebug(BLUEDAEMON) << "ReceiveFileJob-Accept"; KIO::getJobTracker()->registerJob(this); FileReceiverSettings::self()->load(); m_targetPath = FileReceiverSettings::self()->saveUrl().adjusted(QUrl::StripTrailingSlash); m_targetPath.setPath(m_targetPath.path() + QLatin1Char('/') + m_transfer->name()); Q_EMIT description(this, i18n("Receiving file over Bluetooth"), QPair(i18nc("File transfer origin", "From"), m_deviceName), QPair(i18nc("File transfer destination", "To"), m_targetPath.toDisplayString())); m_tempPath = createTempPath(m_transfer->name()); qCDebug(BLUEDAEMON) << "TempPath" << m_tempPath; m_accepted = true; m_request.accept(m_tempPath); } void ReceiveFileJob::slotCancel() { if (!m_accepted && m_transfer->status() == BluezQt::ObexTransfer::Queued) { qCDebug(BLUEDAEMON) << "Cancel Push"; m_request.reject(); setError(KJob::UserDefinedError); emitResult(); } } void ReceiveFileJob::moveFinished(KJob *job) { if (job->error()) { qCDebug(BLUEDAEMON) << job->error(); qCDebug(BLUEDAEMON) << job->errorText(); setError(job->error()); setErrorText(i18n("Saving file failed")); QFile::remove(m_tempPath); } // Delay emitResult to make sure notification is displayed even // for very small files that are received instantly QTimer::singleShot(500, this, [this]() { emitResult(); }); } void ReceiveFileJob::statusChanged(BluezQt::ObexTransfer::Status status) { switch (status) { case BluezQt::ObexTransfer::Active: qCDebug(BLUEDAEMON) << "ReceiveFileJob-Transfer Active"; setTotalAmount(Bytes, m_transfer->size()); setProcessedAmount(Bytes, 0); m_time = QTime::currentTime(); break; case BluezQt::ObexTransfer::Complete: { qCDebug(BLUEDAEMON) << "ReceiveFileJob-Transfer Complete"; KIO::CopyJob *job = KIO::move(QUrl::fromLocalFile(m_tempPath), m_targetPath, KIO::HideProgressInfo); job->setUiDelegate(0); connect(job, &KIO::CopyJob::finished, this, &ReceiveFileJob::moveFinished); break; } case BluezQt::ObexTransfer::Error: qCDebug(BLUEDAEMON) << "ReceiveFileJob-Transfer Error"; setError(KJob::UserDefinedError); setErrorText(i18n("Bluetooth transfer failed")); // Delay emitResult to make sure notification is displayed even // when transfer errors right after accepting it QTimer::singleShot(500, this, [this]() { emitResult(); }); break; default: qCDebug(BLUEDAEMON) << "Not implemented status: " << status; break; } } void ReceiveFileJob::transferredChanged(quint64 transferred) { // qCDebug(BLUEDAEMON) << "ReceiveFileJob-Transferred" << transferred; // If at least 1 second has passed since last update int secondsSinceLastTime = m_time.secsTo(QTime::currentTime()); if (secondsSinceLastTime > 0) { unsigned long speed = (transferred - m_speedBytes) / secondsSinceLastTime; emitSpeed(speed); m_time = QTime::currentTime(); m_speedBytes = transferred; } setProcessedAmount(Bytes, transferred); } QString ReceiveFileJob::createTempPath(const QString &fileName) const { QString xdgCacheHome = QFile::decodeName(qgetenv("XDG_CACHE_HOME")); if (xdgCacheHome.isEmpty()) { xdgCacheHome = QDir::homePath() + QStringLiteral("/.cache"); } xdgCacheHome.append(QLatin1String("/obexd/")); QString path = xdgCacheHome + fileName; int i = 0; while (QFile::exists(path)) { path = xdgCacheHome + fileName + QString::number(i); i++; } return path; } diff --git a/src/sendfile/pages/connecting.ui b/src/sendfile/pages/connecting.ui index 1f2bff7b..199411d9 100644 --- a/src/sendfile/pages/connecting.ui +++ b/src/sendfile/pages/connecting.ui @@ -1,28 +1,32 @@ Connecting 0 0 400 299 - + + + Qt::PlainText + + 0 diff --git a/src/sendfile/pages/failpage.ui b/src/sendfile/pages/failpage.ui index abc8064f..d76a75d9 100644 --- a/src/sendfile/pages/failpage.ui +++ b/src/sendfile/pages/failpage.ui @@ -1,68 +1,71 @@ FailPage 0 0 400 300 Qt::Horizontal QSizePolicy::Fixed 10 20 48 48 + + Qt::PlainText + Qt::Vertical 20 40 diff --git a/src/wizard/pages/fail.ui b/src/wizard/pages/fail.ui index d8b731b5..672e84fe 100644 --- a/src/wizard/pages/fail.ui +++ b/src/wizard/pages/fail.ui @@ -1,71 +1,74 @@ Fail 0 0 400 300 10 Qt::Horizontal QSizePolicy::Fixed 10 20 48 48 + + Qt::PlainText + Qt::Vertical 20 40 diff --git a/src/wizard/pages/pairing.ui b/src/wizard/pages/pairing.ui index 7790b7ce..0c771c95 100644 --- a/src/wizard/pages/pairing.ui +++ b/src/wizard/pages/pairing.ui @@ -1,169 +1,173 @@ Pairing 0 0 400 300 - + + + Qt::PlainText + + 0 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 QSizePolicy::Fixed 50 20 true Qt::AlignCenter true Qt::Horizontal QSizePolicy::Fixed 50 20 Qt::Vertical 20 40 diff --git a/src/wizard/pages/success.ui b/src/wizard/pages/success.ui index 7019ebd7..33f14d69 100644 --- a/src/wizard/pages/success.ui +++ b/src/wizard/pages/success.ui @@ -1,71 +1,74 @@ Success 0 0 400 300 10 Qt::Horizontal QSizePolicy::Fixed 10 20 48 48 + + Qt::PlainText + Qt::Vertical 20 40