Page MenuHomePhorge

kazv-io.hpp
No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None

kazv-io.hpp

/*
* This file is part of kazv.
* SPDX-FileCopyrightText: 2022 nannanko <nannanko@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#pragma once
#include "kazv-io-manager.hpp"
#include <KIO/Job>
#include <QObject>
#include <QUrl>
#include <QtQml>
#include <memory>
struct KazvIOPrivate;
class KazvIO : public QObject {
Q_OBJECT
QML_ELEMENT
/**
* Global manager for kazvIO.
*/
Q_PROPERTY(KazvIOManager *manager READ manager WRITE setManager NOTIFY managerChanged)
Q_PROPERTY(QString roomId READ roomId WRITE setRoomId NOTIFY roomIdChanged)
Q_PROPERTY(QString eventId READ roomId WRITE setEventId NOTIFY eventIdChanged)
Q_PROPERTY(QUrl localFileUrl READ localFileUrl WRITE setLocalFileUrl NOTIFY localFileUrlChanged)
Q_PROPERTY(QString serverUrl READ serverUrl WRITE setServerUrl NOTIFY serverUrlChanged)
Q_PROPERTY(QString token READ token WRITE setToken NOTIFY tokenChanged)
Q_PROPERTY(QString mxcUri READ mxcUri NOTIFY mxcUriChanged)
/**
* From zero to one
*/
Q_PROPERTY(float progress READ progress NOTIFY progressChanged)
Q_PROPERTY(KIO::TransferJob *job READ job WRITE setJob NOTIFY jobChanged)
private:
std::unique_ptr<KazvIOPrivate> m_d;
void connectJob(QPointer<KJob> job);
public:
explicit KazvIO(QObject *parent = 0);
~KazvIO() override;
/**
* QML should call this function to initiate a download.
*/
Q_INVOKABLE void download();
/**
* Upload file to server
*/
Q_INVOKABLE void upload();
/**
* Pause the job.
*/
Q_INVOKABLE void suspend();
/**
* Resume the job.
*/
Q_INVOKABLE void resume();
/**
* Cancel the job.
*/
Q_INVOKABLE void cancel();
KazvIOManager *manager();
void setManager(KazvIOManager *manager);
QString roomId();
void setRoomId(QString roomId);
QString eventId();
void setEventId(QString eventId);
QUrl localFileUrl();
void setLocalFileUrl(QUrl localFileUrl);
QString serverUrl();
void setServerUrl(QString serverUrl);
QString token();
void setToken(QString token);
QString mxcUri();
float progress();
KIO::TransferJob *job();
void setJob(KIO::TransferJob *job);
Q_SIGNALS:
/**
* Sending this signal means that the job has been destroyed and the download or upload task has ended.
* This signal is always emitted once, whether it is a normal exit or an error.
*/
void result();
void success();
void failure();
/**
* When KazvIO is created, it will check if the url it manages is being downloaded or uploading,
* and if it is, then it will send this signal.
*/
void processing();
/**
* This signal is emitted if the upload or download tasks it manages have been paused when KazvIO was created
*/
void suspended();
void managerChanged();
void roomIdChanged();
void eventIdChanged();
void localFileUrlChanged();
void serverUrlChanged();
void tokenChanged();
void mxcUriChanged();
void progressChanged();
void jobChanged();
private Q_SLOTS:
void updateProgress(KJob *job, unsigned long percent);
void checkResult(KJob *job);
void clearPercent();
void setMxcUri(KJob *job);
/**
* Check if a download/upload task is in progress
*/
void checkJob();
};

File Metadata

Mime Type
text/x-c++
Expires
Thu, Oct 2, 4:50 AM (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
486289
Default Alt Text
kazv-io.hpp (3 KB)

Event Timeline