diff --git a/dataengines/statusnotifieritem/CMakeLists.txt b/dataengines/statusnotifieritem/CMakeLists.txt index 6a6fc9aa4..158861e40 100644 --- a/dataengines/statusnotifieritem/CMakeLists.txt +++ b/dataengines/statusnotifieritem/CMakeLists.txt @@ -1,39 +1,45 @@ include_directories(${plasma-workspace_SOURCE_DIR}/statusnotifierwatcher) # We add our source code here set(statusnotifieritem_engine_SRCS statusnotifieritem_engine.cpp statusnotifieritemsource.cpp statusnotifieritemservice.cpp statusnotifieritemjob.cpp systemtraytypes.cpp ) set(statusnotifierwatcher_xml ${KNOTIFICATIONS_DBUS_INTERFACES_DIR}/kf5_org.kde.StatusNotifierWatcher.xml) qt5_add_dbus_interface(statusnotifieritem_engine_SRCS ${statusnotifierwatcher_xml} statusnotifierwatcher_interface) qt5_add_dbus_interface(statusnotifieritem_engine_SRCS ../mpris2/org.freedesktop.DBus.Properties.xml dbusproperties) set(statusnotifieritem_xml ${KNOTIFICATIONS_DBUS_INTERFACES_DIR}/kf5_org.kde.StatusNotifierItem.xml) set_source_files_properties(${statusnotifieritem_xml} PROPERTIES NO_NAMESPACE false INCLUDE "systemtraytypes.h" CLASSNAME OrgKdeStatusNotifierItem ) qt5_add_dbus_interface(statusnotifieritem_engine_SRCS ${statusnotifieritem_xml} statusnotifieritem_interface) add_library(plasma_engine_statusnotifieritem MODULE ${statusnotifieritem_engine_SRCS}) target_link_libraries(plasma_engine_statusnotifieritem Qt5::DBus KF5::Service KF5::Plasma KF5::IconThemes dbusmenuqt ) +ecm_qt_declare_logging_category(statusnotifieritem_engine_SRCS HEADER debug.h + IDENTIFIER DATAENGINE_SNI + CATEGORY_NAME kde.dataengine.sni + DEFAULT_SEVERITY Info) + + kcoreaddons_desktop_to_json(plasma_engine_statusnotifieritem plasma-dataengine-statusnotifieritem.desktop) install(TARGETS plasma_engine_statusnotifieritem DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/dataengine) install(FILES plasma-dataengine-statusnotifieritem.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) install(FILES statusnotifieritem.operations DESTINATION ${PLASMA_DATA_INSTALL_DIR}/services) diff --git a/dataengines/statusnotifieritem/statusnotifieritem_engine.cpp b/dataengines/statusnotifieritem/statusnotifieritem_engine.cpp index 71e5c9cd3..8cf9c9ce0 100644 --- a/dataengines/statusnotifieritem/statusnotifieritem_engine.cpp +++ b/dataengines/statusnotifieritem/statusnotifieritem_engine.cpp @@ -1,157 +1,157 @@ /*************************************************************************** * * * Copyright (C) 2009 Marco Martin * * Copyright (C) 2009 Matthieu Gallien * * * * 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) any later version. * * * * 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 * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #include "statusnotifieritem_engine.h" #include #include "statusnotifieritemsource.h" #include "dbusproperties.h" -#include +#include "debug.h" #include static const QString s_watcherServiceName(QStringLiteral("org.kde.StatusNotifierWatcher")); StatusNotifierItemEngine::StatusNotifierItemEngine(QObject *parent, const QVariantList& args) : Plasma::DataEngine(parent, args), m_statusNotifierWatcher(nullptr) { Q_UNUSED(args); init(); } StatusNotifierItemEngine::~StatusNotifierItemEngine() { QDBusConnection::sessionBus().unregisterService(m_serviceName); } Plasma::Service* StatusNotifierItemEngine::serviceForSource(const QString &name) { StatusNotifierItemSource *source = dynamic_cast(containerForSource(name)); // if source does not exist, return null service if (!source) { return Plasma::DataEngine::serviceForSource(name); } Plasma::Service *service = source->createService(); service->setParent(this); return service; } void StatusNotifierItemEngine::init() { if (QDBusConnection::sessionBus().isConnected()) { m_serviceName = "org.kde.StatusNotifierHost-" + QString::number(QCoreApplication::applicationPid()); QDBusConnection::sessionBus().registerService(m_serviceName); QDBusServiceWatcher *watcher = new QDBusServiceWatcher(s_watcherServiceName, QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this); connect(watcher, &QDBusServiceWatcher::serviceOwnerChanged, this, &StatusNotifierItemEngine::serviceChange); registerWatcher(s_watcherServiceName); } } void StatusNotifierItemEngine::serviceChange(const QString& name, const QString& oldOwner, const QString& newOwner) { - qDebug()<< "Service" << name << "status change, old owner:" << oldOwner << "new:" << newOwner; + qCDebug(DATAENGINE_SNI)<< "Service" << name << "status change, old owner:" << oldOwner << "new:" << newOwner; if (newOwner.isEmpty()) { //unregistered unregisterWatcher(name); } else if (oldOwner.isEmpty()) { //registered registerWatcher(name); } } void StatusNotifierItemEngine::registerWatcher(const QString& service) { - //qDebug()<<"service appeared"<isValid()) { m_statusNotifierWatcher->call(QDBus::NoBlock, QStringLiteral("RegisterStatusNotifierHost"), m_serviceName); OrgFreedesktopDBusPropertiesInterface propetriesIface(m_statusNotifierWatcher->service(), m_statusNotifierWatcher->path(), m_statusNotifierWatcher->connection()); QDBusPendingReply pendingItems = propetriesIface.Get(m_statusNotifierWatcher->interface(), "RegisteredStatusNotifierItems"); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingItems, this); connect(watcher, &QDBusPendingCallWatcher::finished, this, [=]() { watcher->deleteLater(); QDBusReply reply = *watcher; QStringList registeredItems = reply.value().variant().toStringList(); foreach (const QString &service, registeredItems) { newItem(service); } }); connect(m_statusNotifierWatcher, &OrgKdeStatusNotifierWatcherInterface::StatusNotifierItemRegistered, this, &StatusNotifierItemEngine::serviceRegistered); connect(m_statusNotifierWatcher, &OrgKdeStatusNotifierWatcherInterface::StatusNotifierItemUnregistered, this, &StatusNotifierItemEngine::serviceUnregistered); } else { delete m_statusNotifierWatcher; m_statusNotifierWatcher = nullptr; - qDebug()<<"System tray daemon not reachable"; + qCDebug(DATAENGINE_SNI)<<"System tray daemon not reachable"; } } } void StatusNotifierItemEngine::unregisterWatcher(const QString& service) { if (service == s_watcherServiceName) { - qDebug()<< s_watcherServiceName << "disappeared"; + qCDebug(DATAENGINE_SNI)<< s_watcherServiceName << "disappeared"; disconnect(m_statusNotifierWatcher, &OrgKdeStatusNotifierWatcherInterface::StatusNotifierItemRegistered, this, &StatusNotifierItemEngine::serviceRegistered); disconnect(m_statusNotifierWatcher, &OrgKdeStatusNotifierWatcherInterface::StatusNotifierItemUnregistered, this, &StatusNotifierItemEngine::serviceUnregistered); removeAllSources(); delete m_statusNotifierWatcher; m_statusNotifierWatcher = nullptr; } } void StatusNotifierItemEngine::serviceRegistered(const QString &service) { - qDebug() << "Registering"< * * * * 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) any later version. * * * * 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 * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #include "systemtraytypes.h" // Marshall the ImageStruct data into a D-BUS argument const QDBusArgument &operator<<(QDBusArgument &argument, const KDbusImageStruct &icon) { argument.beginStructure(); argument << icon.width; argument << icon.height; argument << icon.data; argument.endStructure(); return argument; } #include // Retrieve the ImageStruct data from the D-BUS argument const QDBusArgument &operator>>(const QDBusArgument &argument, KDbusImageStruct &icon) { qint32 width = 0; qint32 height = 0; QByteArray data; if (argument.currentType() == QDBusArgument::StructureType) { argument.beginStructure(); - //qDebug() << "begun structure"; + //qCDebug(DATAENGINE_SNI)() << "begun structure"; argument >> width; - //qDebug() << width; + //qCDebug(DATAENGINE_SNI)() << width; argument >> height; - //qDebug() << height; + //qCDebug(DATAENGINE_SNI)() << height; argument >> data; - //qDebug() << data.size(); + //qCDebug(DATAENGINE_SNI)() << data.size(); argument.endStructure(); } icon.width = width; icon.height = height; icon.data = data; return argument; } // Marshall the ImageVector data into a D-BUS argument const QDBusArgument &operator<<(QDBusArgument &argument, const KDbusImageVector &iconVector) { argument.beginArray(qMetaTypeId()); for (int i=0; i>(const QDBusArgument &argument, KDbusImageVector &iconVector) { iconVector.clear(); if (argument.currentType() == QDBusArgument::ArrayType) { argument.beginArray(); while (!argument.atEnd()) { KDbusImageStruct element; argument >> element; iconVector.append(element); } argument.endArray(); } return argument; } // Marshall the ToolTipStruct data into a D-BUS argument const QDBusArgument &operator<<(QDBusArgument &argument, const KDbusToolTipStruct &toolTip) { argument.beginStructure(); argument << toolTip.icon; argument << toolTip.image; argument << toolTip.title; argument << toolTip.subTitle; argument.endStructure(); return argument; } // Retrieve the ToolTipStruct data from the D-BUS argument const QDBusArgument &operator>>(const QDBusArgument &argument, KDbusToolTipStruct &toolTip) { QString icon; KDbusImageVector image; QString title; QString subTitle; if (argument.currentType() == QDBusArgument::StructureType) { argument.beginStructure(); argument >> icon; argument >> image; argument >> title; argument >> subTitle; argument.endStructure(); } toolTip.icon = icon; toolTip.image = image; toolTip.title = title; toolTip.subTitle = subTitle; return argument; } diff --git a/dataengines/time/CMakeLists.txt b/dataengines/time/CMakeLists.txt index 5d802fa24..d8ba700cb 100644 --- a/dataengines/time/CMakeLists.txt +++ b/dataengines/time/CMakeLists.txt @@ -1,22 +1,27 @@ add_definitions(-DTRANSLATION_DOMAIN=\"plasma_engine_time\") set(time_engine_SRCS timeengine.cpp timesource.cpp solarsystem.cpp ) +ecm_qt_declare_logging_category(time_engine_SRCS HEADER debug.h + IDENTIFIER DATAENGINE_TIME + CATEGORY_NAME kde.dataengine.time + DEFAULT_SEVERITY Info) + add_library(plasma_engine_time MODULE ${time_engine_SRCS}) target_link_libraries(plasma_engine_time Qt5::DBus KF5::Solid KF5::Plasma KF5::I18n KF5::Service ) kcoreaddons_desktop_to_json(plasma_engine_time plasma-dataengine-time.desktop) install(TARGETS plasma_engine_time DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/dataengine) install(FILES plasma-dataengine-time.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) diff --git a/dataengines/time/timeengine.cpp b/dataengines/time/timeengine.cpp index 813ff1a5b..0adb8ca0d 100644 --- a/dataengines/time/timeengine.cpp +++ b/dataengines/time/timeengine.cpp @@ -1,147 +1,148 @@ /* * Copyright 2007 Aaron Seigo * Copyright 2008 Alex Merry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 or * (at your option) any later version. * * 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. */ #include "timeengine.h" #include #include #include #include #include #ifdef Q_OS_LINUX #include #include #include #endif #include "timesource.h" +#include "debug.h" //timezone is defined in msvc #ifdef timezone #undef timezone #endif TimeEngine::TimeEngine(QObject *parent, const QVariantList &args) : Plasma::DataEngine(parent, args) { Q_UNUSED(args) setMinimumPollingInterval(333); // To have translated timezone names // (effectively a noop if the catalog is already present). ////KF5 port: remove this line and define TRANSLATION_DOMAIN in CMakeLists.txt instead //KLocale::global()->insertCatalog("timezones4"); QTimer::singleShot(0, this, &TimeEngine::init); } TimeEngine::~TimeEngine() { } void TimeEngine::init() { QDBusConnection dbus = QDBusConnection::sessionBus(); dbus.connect(QString(), QString(), QStringLiteral("org.kde.KTimeZoned"), QStringLiteral("timeZoneChanged"), this, SLOT(tzConfigChanged())); #ifdef Q_OS_LINUX //monitor for the system clock being changed auto timeChangedFd = timerfd_create(CLOCK_REALTIME, O_CLOEXEC | O_NONBLOCK); itimerspec timespec; memset(×pec, 0, sizeof(timespec)); //set all timers to 0 seconds, which creates a timer that won't do anything int err = timerfd_settime(timeChangedFd, 3, ×pec, nullptr); //monitor for the time changing //(flags == TFD_TIMER_ABSTIME | TFD_TIMER_CANCEL_ON_SET). However these are not exposed in glibc so value is hardcoded if (err) { - qWarning() << "Could not create timer with TFD_TIMER_CANCEL_ON_SET. Clock skews will not be detected. Error:" << qPrintable(strerror(err)); + qCWarning(DATAENGINE_TIME) << "Could not create timer with TFD_TIMER_CANCEL_ON_SET. Clock skews will not be detected. Error:" << qPrintable(strerror(err)); } connect(this, &QObject::destroyed, [timeChangedFd]() { close(timeChangedFd); }); auto notifier = new QSocketNotifier(timeChangedFd, QSocketNotifier::Read, this); connect(notifier, &QSocketNotifier::activated, this, [this](int fd) { uint64_t c; read(fd, &c, 8); clockSkewed(); }); #else dbus.connect(QString(), "/org/kde/kcmshell_clock", "org.kde.kcmshell_clock", "clockUpdated", this, SLOT(clockSkewed())); dbus.connect(QStringLiteral("org.kde.Solid.PowerManagement"), QStringLiteral("/org/kde/Solid/PowerManagement/Actions/SuspendSession"), QStringLiteral("org.kde.Solid.PowerManagement.Actions.SuspendSession"), QStringLiteral("resumingFromSuspend"), this, SLOT(clockSkewed())); #endif } void TimeEngine::clockSkewed() { - qDebug() << "Time engine Clock skew signaled"; + qCDebug(DATAENGINE_TIME) << "Time engine Clock skew signaled"; updateAllSources(); forceImmediateUpdateOfAllVisualizations(); } void TimeEngine::tzConfigChanged() { - qDebug() << "Local timezone changed signaled"; + qCDebug(DATAENGINE_TIME) << "Local timezone changed signaled"; TimeSource *s = qobject_cast(containerForSource(QStringLiteral("Local"))); if (s) { s->setTimeZone(QStringLiteral("Local")); } updateAllSources(); forceImmediateUpdateOfAllVisualizations(); } QStringList TimeEngine::sources() const { QStringList sources; Q_FOREACH(const QByteArray &tz, QTimeZone::availableTimeZoneIds()) { sources << QString(tz.constData()); } sources << QStringLiteral("Local"); return sources; } bool TimeEngine::sourceRequestEvent(const QString &name) { addSource(new TimeSource(name, this)); return true; } bool TimeEngine::updateSourceEvent(const QString &tz) { TimeSource *s = qobject_cast(containerForSource(tz)); if (s) { s->updateTime(); return true; } return false; } K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(time, TimeEngine, "plasma-dataengine-time.json") #include "timeengine.moc"