[OpenDocString] kdeconnect-kde (cpp)
photoplugin.cpp
PhotoPlugin::PhotoPlugin(QObject *parent, const QVariantList &args)
    : KdeConnectPlugin(parent, args)
{
}
Constructs a photo plugin object and assigns it to its parent object.
PhotoPlugin::~PhotoPlugin()
{
}
This removes the photo plugin from the list of plugins.
bool PhotoPlugin::receivePacket(const NetworkPacket &np)
{
    if (np.get(QStringLiteral("cancel"))) {
        requestedFiles.takeFirst();
    }

    if (requestedFiles.isEmpty() || !np.hasPayload()) {
        return true;
    }

    const QString url = requestedFiles.takeFirst();
    FileTransferJob *job = np.createPayloadTransferJob(QUrl(url));
    connect(job, &FileTransferJob::result, this, [this, url] {
        Q_EMIT photoReceived(url);
    });
    job->start();
    return true;
}
This creates a FileTransferJob object and connects it to the network packet. It returns true if the packet should be cancelled, or the packet is already in progress.
void PhotoPlugin::requestPhoto(const QString &url)
{
    requestedFiles.append(url);
    NetworkPacket np(PACKET_TYPE_PHOTO_REQUEST);
    sendPacket(np);
}
This requests a photo from the given url. It adds it to the list of requested files, and sends a network packet.
QString PhotoPlugin::dbusPath() const
{
    return QStringLiteral("/modules/kdeconnect/devices/") + device()->id() + QStringLiteral("/photo");
}
Returns the dbus path as a QString.