From 00cf2c8af79cb52f32439c4a73e59174dfa2fc90 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sat, 14 May 2022 20:05:52 +0300 Subject: [PATCH] generic: adjust to org.kde.JobView/org.kde.JobViewV2 interface changes Signed-off-by: Ivailo Monev --- kuiserver/CMakeLists.txt | 31 ++++++++-------- kuiserver/jobview.cpp | 25 ++++--------- kuiserver/jobview.h | 21 ++--------- kuiserver/progresslistmodel.cpp | 3 +- .../applicationjobs/CMakeLists.txt | 35 +++++++++++++++---- .../applicationjobs/kuiserverengine.cpp | 2 +- .../applicationjobs/kuiserverengine.h | 2 +- 7 files changed, 59 insertions(+), 60 deletions(-) diff --git a/kuiserver/CMakeLists.txt b/kuiserver/CMakeLists.txt index c1450817..57d2b6de 100644 --- a/kuiserver/CMakeLists.txt +++ b/kuiserver/CMakeLists.txt @@ -2,7 +2,7 @@ if(ENABLE_TESTING) add_subdirectory(tests) endif() -include_directories( ${KDE4_KIO_INCLUDES} ) +include_directories(${KDE4_KIO_INCLUDES}) # for dbus_add_activation_service include(MacroDBusAddActivationService) @@ -25,24 +25,22 @@ set(kuiserver_KDEINIT_PRIVATE # # - set(jobview_xml ${KDE4_DBUS_INTERFACES_INSTALL_DIR}/org.kde.JobViewV2.xml) +set(jobview_xml ${KDE4_DBUS_INTERFACES_INSTALL_DIR}/org.kde.JobView.xml) - qt4_add_dbus_adaptor(kuiserver_SRCS ${jobview_xml} jobview.h JobView jobviewadaptor ) +qt4_add_dbus_adaptor(kuiserver_SRCS ${jobview_xml} jobview.h JobView jobviewadaptor ) - qt4_add_dbus_interface(kuiserver_SRCS ${jobview_xml} jobview_interface ) +qt4_add_dbus_interface(kuiserver_SRCS ${jobview_xml} jobview_interface ) # - # - set(jobviewserver_xml ${KDE4_DBUS_INTERFACES_INSTALL_DIR}/org.kde.JobViewServer.xml) +set(jobviewserver_xml ${KDE4_DBUS_INTERFACES_INSTALL_DIR}/org.kde.JobViewServer.xml) - qt4_add_dbus_adaptor(kuiserver_SRCS ${jobviewserver_xml} progresslistmodel.h ProgressListModel jobviewserveradaptor ) +qt4_add_dbus_adaptor(kuiserver_SRCS ${jobviewserver_xml} progresslistmodel.h ProgressListModel jobviewserveradaptor) - qt4_add_dbus_interface(kuiserver_SRCS ${jobviewserver_xml} jobviewserver_interface ) +qt4_add_dbus_interface(kuiserver_SRCS ${jobviewserver_xml} jobviewserver_interface ) # -qt4_add_dbus_adaptor(kuiserver_SRCS org.kde.kuiserver.xml progresslistmodel.h ProgressListModel kuiserveradaptor ) - +qt4_add_dbus_adaptor(kuiserver_SRCS org.kde.kuiserver.xml progresslistmodel.h ProgressListModel kuiserveradaptor) dbus_add_activation_service(org.kde.kuiserver.service.in) @@ -51,10 +49,15 @@ dbus_add_activation_service(org.kde.kuiserver.service.in) kde4_add_kcfg_files(kuiserver_SRCS kuiserversettings.kcfgc) -add_executable( kuiserver ${kuiserver_SRCS}) +add_executable(kuiserver ${kuiserver_SRCS}) -target_link_libraries(kuiserver ${KDE4_KIO_LIBS} ) +target_link_libraries(kuiserver ${KDE4_KIO_LIBS}) -install(TARGETS kuiserver ${INSTALL_TARGETS_DEFAULT_ARGS} ) +install( + TARGETS kuiserver ${INSTALL_TARGETS_DEFAULT_ARGS} +) -install( FILES kuiserver.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR} ) +install( + FILES kuiserver.desktop + DESTINATION ${KDE4_SERVICES_INSTALL_DIR} +) diff --git a/kuiserver/jobview.cpp b/kuiserver/jobview.cpp index 77a50ab6..b43ffc32 100644 --- a/kuiserver/jobview.cpp +++ b/kuiserver/jobview.cpp @@ -29,6 +29,8 @@ #include +typedef QPair iFacePair; + JobView::JobView(uint jobId, QObject *parent) : QObject(parent), m_capabilities(-1), @@ -40,7 +42,7 @@ JobView::JobView(uint jobId, QObject *parent) m_isTerminated(false), m_currentPendingCalls(0) { - new JobViewV2Adaptor(this); + new JobViewAdaptor(this); m_objectPath.setPath(QString("/JobViewServer/JobView_%1").arg(m_jobId)); QDBusConnection::sessionBus().registerObject(m_objectPath.path(), this); @@ -54,7 +56,6 @@ void JobView::terminate(const QString &errorMessage) { QDBusConnection::sessionBus().unregisterObject(m_objectPath.path(), QDBusConnection::UnregisterTree); - typedef QPair iFacePair; foreach(const iFacePair &pair, m_objectPaths) { kDebug(7024) << "making async call of terminate for: " << pair.first; pair.second->asyncCall(QLatin1String("terminate"), errorMessage); @@ -92,7 +93,6 @@ void JobView::requestCancel() void JobView::setSuspended(bool suspended) { - typedef QPair iFacePair; foreach(const iFacePair &pair, m_objectPaths) { pair.second->asyncCall(QLatin1String("setSuspended"), suspended); } @@ -108,7 +108,6 @@ uint JobView::state() const void JobView::setTotalAmount(qulonglong amount, const QString &unit) { - typedef QPair iFacePair; foreach(const iFacePair &pair, m_objectPaths) { pair.second->asyncCall(QLatin1String("setTotalAmount"), amount, unit); } @@ -136,7 +135,6 @@ QString JobView::sizeTotal() const void JobView::setProcessedAmount(qulonglong amount, const QString &unit) { - typedef QPair iFacePair; foreach(const iFacePair &pair, m_objectPaths) { pair.second->asyncCall(QLatin1String("setProcessedAmount"), amount, unit); } @@ -163,7 +161,6 @@ QString JobView::sizeProcessed() const void JobView::setPercent(uint value) { - typedef QPair iFacePair; foreach(const iFacePair &pair, m_objectPaths) { pair.second->asyncCall(QLatin1String("setPercent"), value); } @@ -179,7 +176,6 @@ uint JobView::percent() const void JobView::setSpeed(qulonglong bytesPerSecond) { - typedef QPair iFacePair; foreach(const iFacePair &pair, m_objectPaths) { pair.second->asyncCall(QLatin1String("setSpeed"), bytesPerSecond); } @@ -195,7 +191,6 @@ QString JobView::speed() const void JobView::setInfoMessage(const QString &infoMessage) { - typedef QPair iFacePair; foreach(const iFacePair &pair, m_objectPaths) { pair.second->asyncCall(QLatin1String("setInfoMessage"), infoMessage); } @@ -211,7 +206,6 @@ QString JobView::infoMessage() const bool JobView::setDescriptionField(uint number, const QString &name, const QString &value) { - typedef QPair iFacePair; foreach(const iFacePair &pair, m_objectPaths) { pair.second->asyncCall(QLatin1String("setDescriptionField"), number, name, value); } @@ -229,7 +223,6 @@ bool JobView::setDescriptionField(uint number, const QString &name, const QStrin void JobView::clearDescriptionField(uint number) { - typedef QPair iFacePair; foreach(const iFacePair &pair, m_objectPaths) { pair.second->asyncCall(QLatin1String("clearDescriptionField"), number); } @@ -242,7 +235,6 @@ void JobView::clearDescriptionField(uint number) void JobView::setAppName(const QString &appName) { - typedef QPair iFacePair; foreach(const iFacePair &pair, m_objectPaths) { pair.second->asyncCall(QLatin1String("setAppName"), appName); } @@ -257,7 +249,6 @@ QString JobView::appName() const void JobView::setAppIconName(const QString &appIconName) { - typedef QPair iFacePair; foreach(const iFacePair &pair, m_objectPaths) { pair.second->asyncCall(QLatin1String("setAppIconName"), appIconName); } @@ -272,7 +263,6 @@ QString JobView::appIconName() const void JobView::setCapabilities(int capabilities) { - typedef QPair iFacePair; foreach(const iFacePair &pair, m_objectPaths) { pair.second->asyncCall(QLatin1String("setCapabilities"), capabilities); } @@ -313,10 +303,9 @@ QVariant JobView::destUrl() const void JobView::addJobContact(const QString& objectPath, const QString& address) { - org::kde::JobViewV2 *client = - new org::kde::JobViewV2(address, objectPath, QDBusConnection::sessionBus()); + org::kde::JobView *client = new org::kde::JobView(address, objectPath, QDBusConnection::sessionBus()); - QPair pair(objectPath, client); + iFacePair pair(objectPath, client); //propagate any request signals from the client's job, up to us, then to the parent KJob //otherwise e.g. the pause button on plasma's tray would be broken. @@ -371,7 +360,7 @@ void JobView::addJobContact(const QString& objectPath, const QString& address) QStringList JobView::jobContacts() { QStringList output; - QHash >::const_iterator it = m_objectPaths.constBegin(); + QHash::const_iterator it = m_objectPaths.constBegin(); for (; it != m_objectPaths.constEnd(); ++it) { //for debug purposes only output.append("service name of the interface: " + it.key() + "; objectPath for the interface: " + it.value().first); @@ -407,7 +396,7 @@ void JobView::pendingCallFinished(RequestViewCallWatcher* watcher) // do basically the same as terminate() except only for service // since this one missed out. - org::kde::JobViewV2 *client = new org::kde::JobViewV2(address, objectPath.path(), QDBusConnection::sessionBus()); + org::kde::JobView *client = new org::kde::JobView(address, objectPath.path(), QDBusConnection::sessionBus()); kDebug(7024) << "making async terminate call to objectPath: " << objectPath.path(); kDebug(7024) << "this was because a pending call was finished, but the job was already terminated before it returned."; diff --git a/kuiserver/jobview.h b/kuiserver/jobview.h index 5cb33644..a703cbf7 100644 --- a/kuiserver/jobview.h +++ b/kuiserver/jobview.h @@ -29,12 +29,12 @@ #include class RequestViewCallWatcher; -class OrgKdeJobViewV2Interface; +class OrgKdeJobViewInterface; class JobView : public QObject { Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "org.kde.JobViewV2") + Q_CLASSINFO("D-Bus Interface", "org.kde.JobView") public: @@ -102,8 +102,6 @@ public: QDBusObjectPath objectPath() const; - - /** * Set the dest Url of the job... * sent from the jobtracker (once upon construction) @@ -129,7 +127,6 @@ public: void requestResume(); void requestCancel(); - /** * Called by the model. * Lets us know that a job at @p objectPath is @@ -182,29 +179,17 @@ private Q_SLOTS: private: int m_capabilities; ///< The capabilities of the job - QString m_applicationName; ///< The application name - QString m_appIconName; ///< The icon name - QString m_sizeTotal; ///< The total size of the operation - QString m_sizeProcessed; ///< The processed size at the moment(amount completed) - QString m_speed; ///< The current speed of the operation (human readable, example, "3Mb/s") - int m_percent; ///< The current percent completed of the job - QString m_infoMessage; ///< The information message to be shown - QString m_error; ///< The error message of the job, set when it's terminated - QString m_totalUnit; ///< The unit used in setTotalAmount - qulonglong m_totalAmount; ///< The amount used in setTotalAmount - QString m_processUnit; ///< The unit used in setProcessedAmount - qulonglong m_processAmount; ///< The processed amount (setProcessedAmount) QHash > m_descFields; @@ -217,7 +202,7 @@ private: * All for the client: *
> */ - QHash > m_objectPaths; + QHash > m_objectPaths; const uint m_jobId; JobState m_state; ///< Current state of this job diff --git a/kuiserver/progresslistmodel.cpp b/kuiserver/progresslistmodel.cpp index ec189158..5faed076 100644 --- a/kuiserver/progresslistmodel.cpp +++ b/kuiserver/progresslistmodel.cpp @@ -278,8 +278,7 @@ void ProgressListModel::registerService(const QString &serviceName, const QStrin //tell this new client to create all of the same jobs that we currently have. //also connect them so that when the method comes back, it will return a - //QDBusObjectPath value, which is where we can contact that job, within "org.kde.JobViewV2" - //TODO: KDE5 remember to replace current org.kde.JobView interface with the V2 one.. (it's named V2 for compat. reasons). + //QDBusObjectPath value, which is where we can contact that job, within "org.kde.JobView" //TODO: this falls victim to what newJob used to be vulnerable to...async calls returning too slowly and a terminate ensuing before that. // it may not be a problem (yet), though. diff --git a/plasma/dataengines/applicationjobs/CMakeLists.txt b/plasma/dataengines/applicationjobs/CMakeLists.txt index c2c1bbad..37ec6b22 100644 --- a/plasma/dataengines/applicationjobs/CMakeLists.txt +++ b/plasma/dataengines/applicationjobs/CMakeLists.txt @@ -9,13 +9,36 @@ set(kuiserver_engine_SRCS jobaction.cpp ) -qt4_add_dbus_adaptor(kuiserver_engine_SRCS ${KDE4_DBUS_INTERFACES_INSTALL_DIR}/org.kde.JobViewV2.xml kuiserverengine.h JobView jobviewadaptor ) -qt4_add_dbus_adaptor(kuiserver_engine_SRCS ${KDE4_DBUS_INTERFACES_INSTALL_DIR}/org.kde.JobViewServer.xml kuiserverengine.h KuiserverEngine jobviewserveradaptor ) +qt4_add_dbus_adaptor(kuiserver_engine_SRCS + ${KDE4_DBUS_INTERFACES_INSTALL_DIR}/org.kde.JobView.xml + kuiserverengine.h + JobView + jobviewadaptor +) +qt4_add_dbus_adaptor(kuiserver_engine_SRCS + ${KDE4_DBUS_INTERFACES_INSTALL_DIR}/org.kde.JobViewServer.xml + kuiserverengine.h + KuiserverEngine + jobviewserveradaptor +) kde4_add_plugin(plasma_engine_applicationjobs ${kuiserver_engine_SRCS}) -target_link_libraries(plasma_engine_applicationjobs ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${KDE4_PLASMA_LIBS}) +target_link_libraries(plasma_engine_applicationjobs + ${KDE4_KDEUI_LIBS} + ${KDE4_KIO_LIBS} + ${KDE4_PLASMA_LIBS} +) -install(TARGETS plasma_engine_applicationjobs DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}) -install(FILES plasma-dataengine-applicationjobs.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR} ) -install(FILES applicationjobs.operations DESTINATION ${KDE4_DATA_INSTALL_DIR}/plasma/services) +install( + TARGETS plasma_engine_applicationjobs + DESTINATION ${KDE4_PLUGIN_INSTALL_DIR} +) +install( + FILES plasma-dataengine-applicationjobs.desktop + DESTINATION ${KDE4_SERVICES_INSTALL_DIR} +) +install( + FILES applicationjobs.operations + DESTINATION ${KDE4_DATA_INSTALL_DIR}/plasma/services +) diff --git a/plasma/dataengines/applicationjobs/kuiserverengine.cpp b/plasma/dataengines/applicationjobs/kuiserverengine.cpp index 7641cbcc..4a74d950 100644 --- a/plasma/dataengines/applicationjobs/kuiserverengine.cpp +++ b/plasma/dataengines/applicationjobs/kuiserverengine.cpp @@ -47,7 +47,7 @@ JobView::JobView(QObject* parent) m_jobId = ++s_jobId; setObjectName(QString("Job %1").arg(s_jobId)); - new JobViewV2Adaptor(this); + new JobViewAdaptor(this); m_objectPath.setPath(QString("/DataEngine/applicationjobs/JobView_%1").arg(m_jobId)); QDBusConnection::sessionBus().registerObject(m_objectPath.path(), this); diff --git a/plasma/dataengines/applicationjobs/kuiserverengine.h b/plasma/dataengines/applicationjobs/kuiserverengine.h index 3b547288..6598878f 100644 --- a/plasma/dataengines/applicationjobs/kuiserverengine.h +++ b/plasma/dataengines/applicationjobs/kuiserverengine.h @@ -59,7 +59,7 @@ private: class JobView : public Plasma::DataContainer { Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "org.kde.JobViewV2") + Q_CLASSINFO("D-Bus Interface", "org.kde.JobView") public: enum State {