bluetoothdownloadjob.cpp 1.73 KB
Newer Older
1 2
/*
 * Copyright 2016 Saikrishna Arcot <saiarcot895@gmail.com>
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
 *
 * 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) version 3 or any later version
 * accepted by the membership of KDE e.V. (or its successor approved
 * by the membership of KDE e.V.), which shall act as a proxy
 * defined in Section 14 of version 3 of the license.
 *
 * 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
18
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19 20
 */

21
#include "bluetoothdownloadjob.h"
22

23
BluetoothDownloadJob::BluetoothDownloadJob(const QBluetoothAddress& remoteAddress, const QVariantMap& transferInfo, QObject* parent)
24 25
    : QObject(parent)
    , mRemoteAddress(remoteAddress)
26
    , mTransferUuid(QBluetoothUuid(transferInfo.value(QStringLiteral("uuid")).toString()))
27
    , mSocket(new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol))
28
{
29
}
30

31 32 33 34
QSharedPointer<QIODevice> BluetoothDownloadJob::payload() const
{
    return mSocket.staticCast<QIODevice>();
}
35

36 37
void BluetoothDownloadJob::start()
{
38 39
    connect(mSocket.data(), &QBluetoothSocket::disconnected, mSocket.data(), &QBluetoothSocket::readyRead);
    connect(mSocket.data(), &QBluetoothSocket::disconnected, mSocket.data(), &QBluetoothSocket::readChannelFinished);
40 41
    mSocket->connectToService(mRemoteAddress, mTransferUuid, QIODevice::ReadOnly);
}