kde-workspace/plasma/dataengines/applicationjobs/kuiserverengine.h
Ivailo Monev 42bd88d0d2 kuiserver: announce destination URL changes to job clients
to fix the plasma job notification actions (see the previous commit), also
changing the destination URL type to QString because it is such (see
kdelibs/kio/kio/copyjob.cpp and kdelibs/kio/kio/job.cpp) and the
QVariant/QDBusVariant conversion is redundant

requires changes to the job tracker interface in kdelibs aswell.. see
kdelibs/kdeui/jobs/kuiserverjobtracker.cpp

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-06-27 03:26:20 +03:00

146 lines
3.6 KiB
C++

/*
* Copyright © 2008 Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* 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 Library 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.
*/
#ifndef KUISERVERENGINE_H
#define KUISERVERENGINE_H
#include <QtDBus/qdbusextratypes.h>
#include <QBasicTimer>
#include <QTimer>
#include <Plasma/DataContainer>
#include <Plasma/DataEngine>
class JobView;
namespace Plasma
{
class Service;
} // namespace Plasma
class KuiserverEngine : public Plasma::DataEngine
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.JobViewServer")
public:
KuiserverEngine(QObject* parent, const QVariantList& args);
~KuiserverEngine();
void init();
QDBusObjectPath requestView(const QString &appName, const QString &appIconName,
int capabilities);
Plasma::Service* serviceForSource(const QString& source);
private Q_SLOTS:
void processPendingJobs();
private:
QTimer m_pendingJobsTimer;
QList<JobView *> m_pendingJobs;
};
class JobView : public Plasma::DataContainer
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.JobView")
public:
enum State {
UnknownState = -1,
Running = 0,
Suspended = 1,
Stopped = 2
};
JobView(QObject *parent = 0);
~JobView();
uint jobId() const;
JobView::State state();
void setTotalAmount(qlonglong amount, const QString &unit);
QString totalAmountSize() const;
QString totalAmountFiles() const;
void setProcessedAmount(qlonglong amount, const QString &unit);
void setSpeed(qlonglong bytesPerSecond);
QString speedString() const;
void setInfoMessage(const QString &infoMessage);
QString infoMessage() const;
bool setDescriptionField(uint number, const QString &name, const QString &value);
void clearDescriptionField(uint number);
void setAppName(const QString &appName);
void setAppIconName(const QString &appIconName);
void setCapabilities(int capabilities);
void setPercent(uint percent);
void setSuspended(bool suspended);
// vestigal, required to implement this dbus interface
void setDestUrl(const QString &destUrl);
void terminate(const QString &errorMessage);
QDBusObjectPath objectPath() const;
void requestStateChange(State state);
public Q_SLOTS:
void finished();
Q_SIGNALS:
void suspendRequested();
void resumeRequested();
void cancelRequested();
protected:
void timerEvent(QTimerEvent *event);
private:
void scheduleUpdate();
void updateEta();
int unitId(const QString &unit);
QDBusObjectPath m_objectPath;
QBasicTimer m_updateTimer;
uint m_capabilities;
uint m_percent;
uint m_jobId;
// for ETA calculation we cache these values
qlonglong m_speed;
qlonglong m_totalBytes;
qlonglong m_processedBytes;
State m_state;
QString m_destUrl;
QMap<QString, int> m_unitMap;
int m_bytesUnitId;
int m_unitId;
static uint s_jobId;
};
#endif