commit plasma6-activities for openSUSE:Factory
Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package plasma6-activities for openSUSE:Factory checked in at 2024-10-07 21:47:55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/plasma6-activities (Old) and /work/SRC/openSUSE:Factory/.plasma6-activities.new.19354 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "plasma6-activities" Mon Oct 7 21:47:55 2024 rev:12 rq:1205924 version:6.2.0 Changes: -------- --- /work/SRC/openSUSE:Factory/plasma6-activities/plasma6-activities.changes 2024-09-11 16:55:52.887255984 +0200 +++ /work/SRC/openSUSE:Factory/.plasma6-activities.new.19354/plasma6-activities.changes 2024-10-07 21:48:23.992685929 +0200 @@ -1,0 +2,23 @@ +Sat Oct 5 10:44:26 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de> + +- Update to 6.2.0: + * New bugfix release + * For more details see https://kde.org/announcements/plasma/6/6.2.0 +- Changes since 6.1.90: + * update version for new release + * Initialise offline defaults on startup + * Avoid reporting serviceStatus of NotRunning whilst kamd is loading (kde#466193) + +------------------------------------------------------------------- +Tue Sep 17 14:53:55 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de> + +- Update to 6.1.90: + * New feature release + * For more details see https://kde.org/announcements/plasma/6/6.1.90 +- Changes since 6.1.5: + * update version for new release + * Port to declarative type registration + * Drop inactive code + * update version for new release + +------------------------------------------------------------------- Old: ---- plasma-activities-6.1.5.tar.xz plasma-activities-6.1.5.tar.xz.sig New: ---- plasma-activities-6.2.0.tar.xz plasma-activities-6.2.0.tar.xz.sig ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ plasma6-activities.spec ++++++ --- /var/tmp/diff_new_pack.kC0gXK/_old 2024-10-07 21:48:24.852721711 +0200 +++ /var/tmp/diff_new_pack.kC0gXK/_new 2024-10-07 21:48:24.856721878 +0200 @@ -16,20 +16,20 @@ # -%define kf6_version 6.2.0 -%define qt6_version 6.6.0 +%define kf6_version 6.5.0 +%define qt6_version 6.7.0 %define rname plasma-activities %bcond_without released Name: plasma6-activities -Version: 6.1.5 +Version: 6.2.0 Release: 0 Summary: Plasma Activities support License: GPL-2.0-or-later URL: https://www.kde.org -Source: https://download.kde.org/stable/plasma/%{version}/%{rname}-%{version}.tar.xz +Source: %{rname}-%{version}.tar.xz %if %{with released} -Source1: https://download.kde.org/stable/plasma/%{version}/%{rname}-%{version}.tar.xz.sig +Source1: %{rname}-%{version}.tar.xz.sig Source2: plasma.keyring %endif BuildRequires: doxygen ++++++ plasma-activities-6.1.5.tar.xz -> plasma-activities-6.2.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plasma-activities-6.1.5/CMakeLists.txt new/plasma-activities-6.2.0/CMakeLists.txt --- old/plasma-activities-6.1.5/CMakeLists.txt 2024-09-10 10:51:20.000000000 +0200 +++ new/plasma-activities-6.2.0/CMakeLists.txt 2024-10-03 14:37:53.000000000 +0200 @@ -1,12 +1,12 @@ # vim:set softtabstop=3 shiftwidth=3 tabstop=3 expandtab: cmake_minimum_required(VERSION 3.16) -set(PROJECT_VERSION "6.1.5") +set(PROJECT_VERSION "6.2.0") project(PlasmaActivities VERSION ${PROJECT_VERSION}) set(PROJECT_VERSION_MAJOR "6") -set(QT_MIN_VERSION "6.6.0") -set(KF6_MIN_VERSION "6.2.0") +set(QT_MIN_VERSION "6.7.0") +set(KF6_MIN_VERSION "6.5.0") set(KDE_COMPILERSETTINGS_LEVEL "5.82") set(CMAKE_CXX_STANDARD 20) @@ -53,8 +53,8 @@ ) ecm_set_disabled_deprecation_versions( - QT 6.4 - KF 5.102.0 + QT 6.7 + KF 6.4.0 ) add_subdirectory (src) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plasma-activities-6.1.5/src/imports/CMakeLists.txt new/plasma-activities-6.2.0/src/imports/CMakeLists.txt --- old/plasma-activities-6.1.5/src/imports/CMakeLists.txt 2024-09-10 10:51:20.000000000 +0200 +++ new/plasma-activities-6.2.0/src/imports/CMakeLists.txt 2024-10-03 14:37:53.000000000 +0200 @@ -6,16 +6,13 @@ find_package (KF6Config ${KF6_MIN_VERSION} CONFIG REQUIRED) find_package (KF6CoreAddons ${KF6_MIN_VERSION} CONFIG REQUIRED) -ecm_add_qml_module(plasmaactivitiesextensionplugin URI "org.kde.activities" VERSION 0.1) +ecm_add_qml_module(plasmaactivitiesextensionplugin URI "org.kde.activities" VERSION 0.1 GENERATE_PLUGIN_SOURCE DEPENDENCIES QtCore) target_sources(plasmaactivitiesextensionplugin PRIVATE - activitiesextensionplugin.cpp - activitiesextensionplugin.h activitymodel.cpp activitymodel.h activityinfo.cpp activityinfo.h -# resourcemodel.cpp ${PLASMA_ACTIVITIES_CURRENT_ROOT_SOURCE_DIR}/src/utils/dbusfuture_p.cpp ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plasma-activities-6.1.5/src/imports/activitiesextensionplugin.cpp new/plasma-activities-6.2.0/src/imports/activitiesextensionplugin.cpp --- old/plasma-activities-6.1.5/src/imports/activitiesextensionplugin.cpp 2024-09-10 10:51:20.000000000 +0200 +++ new/plasma-activities-6.2.0/src/imports/activitiesextensionplugin.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,42 +0,0 @@ -/* - SPDX-FileCopyrightText: 2012, 2013, 2014, 2015 Ivan Cukic <ivan.cukic(at)kde.org> - - SPDX-License-Identifier: LGPL-2.0-or-later -*/ - -#include "activitiesextensionplugin.h" - -#include "activityinfo.h" -#include "activitymodel.h" -#include "resourceinstance.h" - -#include <QQmlEngine> - -// #include "resourcemodel.h" - -// TODO: Clean up unused classes from the imports module - -// TODO: Since plasma is now dealing with activity model wallpapers, -// replace ActivityModel with the KActivities::ActivitiesModel -// (but keep the name) - -ActivitiesExtensionPlugin::ActivitiesExtensionPlugin(QObject *parent) - : QQmlExtensionPlugin(parent) -{ -} - -void ActivitiesExtensionPlugin::registerTypes(const char *uri) -{ - Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.activities")); - - // Used by applets/activitybar - qmlRegisterType<KActivities::Imports::ActivityModel>(uri, 0, 1, "ActivityModel"); - - qmlRegisterType<KActivities::Imports::ActivityInfo>(uri, 0, 1, "ActivityInfo"); - - // This one is removed in favor of KActivities::Stats::ResultModel. - // Subclass it, and make it do what you want. - // qmlRegisterType<KActivities::Imports::ResourceModel>(uri, 0, 1, "ResourceModel"); -} - -#include "moc_activitiesextensionplugin.cpp" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plasma-activities-6.1.5/src/imports/activitiesextensionplugin.h new/plasma-activities-6.2.0/src/imports/activitiesextensionplugin.h --- old/plasma-activities-6.1.5/src/imports/activitiesextensionplugin.h 2024-09-10 10:51:20.000000000 +0200 +++ new/plasma-activities-6.2.0/src/imports/activitiesextensionplugin.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,22 +0,0 @@ -/* - SPDX-FileCopyrightText: 2011, 2012, 2013, 2014, 2015 Ivan Cukic <ivan.cukic(at)kde.org> - - SPDX-License-Identifier: LGPL-2.0-or-later -*/ - -#ifndef KACTIVITIES_ACTIVITIES_EXTENSION_PLUGIN_H -#define KACTIVITIES_ACTIVITIES_EXTENSION_PLUGIN_H - -#include <QQmlExtensionPlugin> - -class ActivitiesExtensionPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.kde.activities") - -public: - explicit ActivitiesExtensionPlugin(QObject *parent = nullptr); - void registerTypes(const char *uri) override; -}; - -#endif // KACTIVITIES_ACTIVITIES_EXTENSION_PLUGIN_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plasma-activities-6.1.5/src/imports/activityinfo.h new/plasma-activities-6.2.0/src/imports/activityinfo.h --- old/plasma-activities-6.1.5/src/imports/activityinfo.h 2024-09-10 10:51:20.000000000 +0200 +++ new/plasma-activities-6.2.0/src/imports/activityinfo.h 2024-10-03 14:37:53.000000000 +0200 @@ -9,6 +9,7 @@ // Qt #include <QObject> +#include <qqmlregistration.h> // STL #include <memory> @@ -28,6 +29,7 @@ class ActivityInfo : public QObject { Q_OBJECT + QML_ELEMENT /** * Unique identifier of the activity diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plasma-activities-6.1.5/src/imports/activitymodel.h new/plasma-activities-6.2.0/src/imports/activitymodel.h --- old/plasma-activities-6.1.5/src/imports/activitymodel.h 2024-09-10 10:51:20.000000000 +0200 +++ new/plasma-activities-6.2.0/src/imports/activitymodel.h 2024-10-03 14:37:53.000000000 +0200 @@ -12,6 +12,7 @@ #include <QCollator> #include <QJSValue> #include <QObject> +#include <qqmlregistration.h> // STL and Boost #include <boost/container/flat_set.hpp> @@ -36,6 +37,7 @@ class ActivityModel : public QAbstractListModel { Q_OBJECT + QML_ELEMENT Q_PROPERTY(QString shownStates READ shownStates WRITE setShownStates NOTIFY shownStatesChanged) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plasma-activities-6.1.5/src/imports/resourcemodel.cpp new/plasma-activities-6.2.0/src/imports/resourcemodel.cpp --- old/plasma-activities-6.1.5/src/imports/resourcemodel.cpp 2024-09-10 10:51:20.000000000 +0200 +++ new/plasma-activities-6.2.0/src/imports/resourcemodel.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,624 +0,0 @@ -/* - SPDX-FileCopyrightText: 2012, 2013, 2014 Ivan Cukic <ivan.cukic(at)kde.org> - - SPDX-License-Identifier: GPL-2.0-or-later -*/ - -// Self -#include "resourcemodel.h" - -// Qt -#include <QByteArray> -#include <QCoreApplication> -#include <QDebug> -#include <QModelIndex> -#include <QSqlQuery> -#include <QUuid> - -// KDE -#include <KConfig> -#include <KDesktopFile> -#include <KFileItem> -#include <ksharedconfig.h> - -// STL and Boost -#include <boost/algorithm/string/join.hpp> -#include <boost/range/adaptor/filtered.hpp> -#include <boost/range/adaptor/transformed.hpp> -#include <boost/range/algorithm/find_if.hpp> -#include <boost/range/numeric.hpp> -#include <mutex> - -// Local -#include "common/dbus/common.h" -#include "utils/dbusfuture_p.h" -#include "utils/range.h" - -#define ENABLE_QJSVALUE_CONTINUATION -#include "utils/continue_with.h" - -#define ACTIVITY_COLUMN 0 -#define AGENT_COLUMN 1 -#define RESOURCE_COLUMN 2 -#define UNKNOWN_COLUMN 3 - -using kamd::utils::continue_with; - -namespace KActivities -{ -namespace Imports -{ -class ResourceModel::LinkerService : public QDBusInterface -{ -private: - LinkerService() - : KAMD_DBUS_INTERFACE("Resources/Linking", ResourcesLinking, nullptr) - { - } - -public: - static std::shared_ptr<LinkerService> self() - { - static std::weak_ptr<LinkerService> s_instance; - static std::mutex singleton; - - std::lock_guard<std::mutex> singleton_lock(singleton); - - auto result = s_instance.lock(); - - if (s_instance.expired()) { - result.reset(new LinkerService()); - s_instance = result; - } - - return result; - } -}; - -ResourceModel::ResourceModel(QObject *parent) - : QSortFilterProxyModel(parent) - , m_shownActivities(QStringLiteral(":current")) - , m_shownAgents(QStringLiteral(":current")) - , m_defaultItemsLoaded(false) - , m_linker(LinkerService::self()) - , m_config(KSharedConfig::openConfig("kactivitymanagerd-resourcelinkingrc")->group("Order")) -{ - // NOTE: What to do if the file does not exist? - // Ignoring that case since the daemon creates it on startup. - // Is it plausible that somebody will instantiate the ResourceModel - // before the daemon is started? - - const QString databaseDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/kactivitymanagerd/resources/"); - - m_databaseFile = databaseDir + QStringLiteral("database"); - - loadDatabase(); - - connect(&m_service, &KActivities::Consumer::currentActivityChanged, this, &ResourceModel::onCurrentActivityChanged); - - connect(m_linker.get(), SIGNAL(ResourceLinkedToActivity(QString, QString, QString)), this, SLOT(onResourceLinkedToActivity(QString, QString, QString))); - connect(m_linker.get(), - SIGNAL(ResourceUnlinkedFromActivity(QString, QString, QString)), - this, - SLOT(onResourceUnlinkedFromActivity(QString, QString, QString))); - - setDynamicSortFilter(true); - sort(0); -} - -bool ResourceModel::loadDatabase() -{ - if (m_database.isValid()) - return true; - if (!QFile(m_databaseFile).exists()) - return false; - - // TODO: Database connection naming could be smarter (thread-id-based, - // reusing connections...?) - m_database = QSqlDatabase::addDatabase(QStringLiteral("QSQLITE"), QStringLiteral("kactivities_db_resources_") + QString::number((quintptr)this)); - - // qDebug() << "Database file is: " << m_databaseFile; - m_database.setDatabaseName(m_databaseFile); - - m_database.open(); - - m_databaseModel = new QSqlTableModel(this, m_database); - m_databaseModel->setTable("ResourceLink"); - m_databaseModel->select(); - - setSourceModel(m_databaseModel); - - reloadData(); - - return true; -} - -ResourceModel::~ResourceModel() -{ -} - -QVariant ResourceModel::dataForColumn(const QModelIndex &index, int column) const -{ - if (!m_database.isValid()) - return QVariant(); - - return m_databaseModel->data(index.sibling(index.row(), column), Qt::DisplayRole); -} - -bool ResourceModel::lessThan(const QModelIndex &left, const QModelIndex &right) const -{ - const auto leftResource = dataForColumn(left, RESOURCE_COLUMN).toString(); - const auto rightResource = dataForColumn(right, RESOURCE_COLUMN).toString(); - - const bool hasLeft = m_sorting.contains(leftResource); - const bool hasRight = m_sorting.contains(rightResource); - - return (hasLeft && !hasRight) ? true - : (!hasLeft && hasRight) ? false - : (hasLeft && hasRight) ? m_sorting.indexOf(leftResource) < m_sorting.indexOf(rightResource) - : QString::compare(leftResource, rightResource, Qt::CaseInsensitive) < 0; -} - -QHash<int, QByteArray> ResourceModel::roleNames() const -{ - return {{Qt::DisplayRole, "display"}, - {Qt::DecorationRole, "decoration"}, - {ResourceRole, "uri"}, - {AgentRole, "agent"}, - {ActivityRole, "activity"}, - {DescriptionRole, "subtitle"}}; -} - -template<typename Validator> -inline QStringList validateList(const QString &values, Validator validator) -{ - using boost::adaptors::filtered; - using kamd::utils::as_collection; - - auto result = as_collection<QStringList>(values.split(',') | filtered(validator)); - - if (result.isEmpty()) { - result.append(QStringLiteral(":current")); - } - - return result; -} - -void ResourceModel::setShownActivities(const QString &activities) -{ - m_shownActivities = validateList(activities, [&](const QString &activity) { - return activity == ":current" || activity == ":any" || activity == ":global" || !QUuid(activity).isNull(); - }); - - reloadData(); - Q_EMIT shownActivitiesChanged(); -} - -void ResourceModel::setShownAgents(const QString &agents) -{ - m_shownAgents = validateList(agents, [&](const QString &agent) { - return agent == ":current" || agent == ":any" || agent == ":global" || (!agent.isEmpty() && !agent.contains('\'') && !agent.contains('"')); - }); - - loadDefaultsIfNeeded(); - reloadData(); - Q_EMIT shownAgentsChanged(); -} - -QString ResourceModel::shownActivities() const -{ - return m_shownActivities.join(','); -} - -QString ResourceModel::shownAgents() const -{ - return m_shownAgents.join(','); -} - -QString ResourceModel::defaultItemsConfig() const -{ - return m_defaultItemsConfig; -} - -void ResourceModel::setDefaultItemsConfig(const QString &defaultItemsConfig) -{ - m_defaultItemsConfig = defaultItemsConfig; - loadDefaultsIfNeeded(); -} - -QString ResourceModel::activityToWhereClause(const QString &shownActivity) const -{ - return QStringLiteral(" OR usedActivity=") - + (shownActivity == ":current" ? "'" + m_service.currentActivity() + "'" - : shownActivity == ":any" ? "usedActivity" - : shownActivity == ":global" ? "''" - : "'" + shownActivity + "'"); -} - -QString ResourceModel::agentToWhereClause(const QString &shownAgent) const -{ - return QStringLiteral(" OR initiatingAgent=") - + (shownAgent == ":current" ? "'" + QCoreApplication::applicationName() + "'" - : shownAgent == ":any" ? "initiatingAgent" - : shownAgent == ":global" ? "''" - : "'" + shownAgent + "'"); -} - -QString ResourceModel::whereClause(const QStringList &activities, const QStringList &agents) const -{ - using boost::accumulate; - using namespace kamd::utils; - - // qDebug() << "Getting the where clause for: " << activities << " " << agents; - - // Defining the transformation functions for generating the SQL WHERE clause - // from the specified activity/agent. They also resolve the special values - // like :current, :any and :global. - - auto activityToWhereClause = transformed(&ResourceModel::activityToWhereClause, this); - auto agentToWhereClause = transformed(&ResourceModel::agentToWhereClause, this); - - // Generating the SQL WHERE part by concatenating the generated clauses. - // The generated query will be in the form of '0 OR clause1 OR clause2 ...' - - const QString whereActivity = accumulate(activities | activityToWhereClause, QStringLiteral("0")); - - const QString whereAgent = accumulate(agents | agentToWhereClause, QStringLiteral("0")); - - // qDebug() << "This is the filter: " << '(' + whereActivity + ") AND (" + whereAgent + ')'; - - return '(' + whereActivity + ") AND (" + whereAgent + ')'; -} - -void ResourceModel::reloadData() -{ - m_sorting = m_config.readEntry(m_shownAgents.first(), QStringList()); - - if (!m_database.isValid()) - return; - m_databaseModel->setFilter(whereClause(m_shownActivities, m_shownAgents)); -} - -void ResourceModel::onCurrentActivityChanged(const QString &activity) -{ - Q_UNUSED(activity); - - if (m_shownActivities.contains(":current")) { - reloadData(); - } -} - -QVariant ResourceModel::data(const QModelIndex &proxyIndex, int role) const -{ - auto index = mapToSource(proxyIndex); - - if (role == Qt::DisplayRole || role == DescriptionRole || role == Qt::DecorationRole) { - auto uri = dataForColumn(index, RESOURCE_COLUMN).toString(); - - // TODO: Will probably need some more special handling - - // for application:/ and a few more - - if (uri.startsWith('/')) { - uri = QLatin1String("file://") + uri; - } - - KFileItem file(uri); - // clang-format off - if (file.mimetype() == "application/x-desktop") { - KDesktopFile desktop(file.localPath()); - - return role == Qt::DisplayRole ? desktop.readGenericName() : - role == DescriptionRole ? desktop.readName() : - role == Qt::DecorationRole ? desktop.readIcon() : QVariant(); - } - - return role == Qt::DisplayRole ? file.name() : - role == Qt::DecorationRole ? file.iconName() : QVariant(); - } - - return dataForColumn(index, - role == ResourceRole ? RESOURCE_COLUMN : - role == AgentRole ? AGENT_COLUMN : - role == ActivityRole ? ACTIVITY_COLUMN : - UNKNOWN_COLUMN - ); - // clang-format on -} - -void ResourceModel::linkResourceToActivity(const QString &resource, const QJSValue &callback) const -{ - linkResourceToActivity(resource, m_shownActivities.first(), callback); -} - -void ResourceModel::linkResourceToActivity(const QString &resource, const QString &activity, const QJSValue &callback) const -{ - linkResourceToActivity(m_shownAgents.first(), resource, activity, callback); -} - -void ResourceModel::linkResourceToActivity(const QString &agent, const QString &_resource, const QString &activity, const QJSValue &callback) const -{ - if (activity == ":any") { - qWarning() << ":any is not a valid activity specification for linking"; - return; - } - - auto resource = validateResource(_resource); - - // qDebug() << "ResourceModel: Linking resource to activity: --------------------------------------------------\n" - // << "ResourceModel: Resource: " << resource << "\n" - // << "ResourceModel: Agents: " << agent << "\n" - // << "ResourceModel: Activities: " << activity << "\n"; - - kamd::utils::continue_with(DBusFuture::asyncCall<void>(m_linker.get(), - QStringLiteral("LinkResourceToActivity"), - agent, - resource, - activity == ":current" ? m_service.currentActivity() - : activity == ":global" ? "" - : activity), - callback); -} - -void ResourceModel::unlinkResourceFromActivity(const QString &resource, const QJSValue &callback) -{ - unlinkResourceFromActivity(m_shownAgents, resource, m_shownActivities, callback); -} - -void ResourceModel::unlinkResourceFromActivity(const QString &resource, const QString &activity, const QJSValue &callback) -{ - unlinkResourceFromActivity(m_shownAgents, resource, QStringList() << activity, callback); -} - -void ResourceModel::unlinkResourceFromActivity(const QString &agent, const QString &resource, const QString &activity, const QJSValue &callback) -{ - unlinkResourceFromActivity(QStringList() << agent, resource, QStringList() << activity, callback); -} - -void ResourceModel::unlinkResourceFromActivity(const QStringList &agents, const QString &_resource, const QStringList &activities, const QJSValue &callback) -{ - auto resource = validateResource(_resource); - - // qDebug() << "ResourceModel: Unlinking resource from activity: ----------------------------------------------\n" - // << "ResourceModel: Resource: " << resource << "\n" - // << "ResourceModel: Agents: " << agents << "\n" - // << "ResourceModel: Activities: " << activities << "\n"; - - for (const auto &agent : agents) { - for (const auto &activity : activities) { - if (activity == ":any") { - qWarning() << ":any is not a valid activity specification for linking"; - return; - } - - // We might want to compose the continuations into one - // so that the callback gets called only once, - // but we don't care about that at the moment - kamd::utils::continue_with(DBusFuture::asyncCall<void>(m_linker.get(), - QStringLiteral("UnlinkResourceFromActivity"), - agent, - resource, - activity == ":current" ? m_service.currentActivity() - : activity == ":global" ? "" - : activity), - callback); - } - } -} - -bool ResourceModel::isResourceLinkedToActivity(const QString &resource) -{ - return isResourceLinkedToActivity(m_shownAgents, resource, m_shownActivities); -} - -bool ResourceModel::isResourceLinkedToActivity(const QString &resource, const QString &activity) -{ - return isResourceLinkedToActivity(m_shownAgents, resource, QStringList() << activity); -} - -bool ResourceModel::isResourceLinkedToActivity(const QString &agent, const QString &resource, const QString &activity) -{ - return isResourceLinkedToActivity(QStringList() << agent, resource, QStringList() << activity); -} - -bool ResourceModel::isResourceLinkedToActivity(const QStringList &agents, const QString &_resource, const QStringList &activities) -{ - if (!m_database.isValid()) - return false; - - auto resource = validateResource(_resource); - - // qDebug() << "ResourceModel: Testing whether the resource is linked to activity: ----------------------------\n" - // << "ResourceModel: Resource: " << resource << "\n" - // << "ResourceModel: Agents: " << agents << "\n" - // << "ResourceModel: Activities: " << activities << "\n"; - - QSqlQuery query(m_database); - query.prepare( - "SELECT targettedResource " - "FROM ResourceLink " - "WHERE targettedResource=:resource AND " - + whereClause(activities, agents)); - query.bindValue(":resource", resource); - query.exec(); - - auto result = query.next(); - - // qDebug() << "Query: " << query.lastQuery(); - // - // if (query.lastError().isValid()) { - // qDebug() << "Error: " << query.lastError(); - // } - // - // qDebug() << "Result: " << result; - - return result; -} - -void ResourceModel::onResourceLinkedToActivity(const QString &initiatingAgent, const QString &targettedResource, const QString &usedActivity) -{ - Q_UNUSED(targettedResource); - - if (!loadDatabase()) - return; - - auto matchingActivity = boost::find_if(m_shownActivities, [&](const QString &shownActivity) { - return - // If the activity is not important - shownActivity == ":any" || - // or we are listening for the changes for the current activity - (shownActivity == ":current" && usedActivity == m_service.currentActivity()) || - // or we want the globally linked resources - (shownActivity == ":global" && usedActivity.isEmpty()) || - // or we have a specific activity in mind - shownActivity == usedActivity; - }); - - auto matchingAgent = boost::find_if(m_shownAgents, [&](const QString &shownAgent) { - return - // If the agent is not important - shownAgent == ":any" || - // or we are listening for the changes for the current agent - (shownAgent == ":current" && initiatingAgent == QCoreApplication::applicationName()) || - // or for links that are global, and not related to a specific agent - (shownAgent == ":global" && initiatingAgent.isEmpty()) || - // or we have a specific agent to listen for - shownAgent == initiatingAgent; - }); - - if (matchingActivity != m_shownActivities.end() && matchingAgent != m_shownAgents.end()) { - // TODO: This might be smarter possibly, but might collide - // with the SQL model. Implement a custom model with internal - // cache instead of basing it on QSqlModel. - reloadData(); - } -} - -void ResourceModel::onResourceUnlinkedFromActivity(const QString &initiatingAgent, const QString &targettedResource, const QString &usedActivity) -{ - // These are the same at the moment - onResourceLinkedToActivity(initiatingAgent, targettedResource, usedActivity); -} - -void ResourceModel::setOrder(const QStringList &resources) -{ - m_sorting = resources; - m_config.writeEntry(m_shownAgents.first(), m_sorting); - m_config.sync(); - invalidate(); -} - -void ResourceModel::move(int sourceItem, int destinationItem) -{ - QStringList resources; - const int rows = rowCount(); - - for (int row = 0; row < rows; row++) { - resources << resourceAt(row); - } - - if (sourceItem < 0 || sourceItem >= rows || destinationItem < 0 || destinationItem >= rows) { - return; - } - - // Moving one item from the source item's location to the location - // after the destination item - std::rotate(resources.begin() + sourceItem, resources.begin() + sourceItem + 1, resources.begin() + destinationItem + 1); - - setOrder(resources); -} - -void ResourceModel::sortItems(Qt::SortOrder sortOrder) -{ - typedef QPair<QString, QString> Resource; - QList<Resource> resources; - const int rows = rowCount(); - - for (int row = 0; row < rows; ++row) { - resources << qMakePair(resourceAt(row), displayAt(row)); - } - - std::sort(resources.begin(), resources.end(), [sortOrder](const Resource &left, const Resource &right) { - return sortOrder == Qt::AscendingOrder ? left.second < right.second : right.second < left.second; - }); - - QStringList result; - - for (const auto &resource : std::as_const(resources)) { - result << resource.first; - } - - setOrder(result); -} - -KConfigGroup ResourceModel::config() const -{ - return KSharedConfig::openConfig("kactivitymanagerd-resourcelinkingrc")->group("Order"); -} - -int ResourceModel::count() const -{ - return QSortFilterProxyModel::rowCount(); -} - -QString ResourceModel::displayAt(int row) const -{ - return data(index(row, 0), Qt::DisplayRole).toString(); -} - -QString ResourceModel::resourceAt(int row) const -{ - return validateResource(data(index(row, 0), ResourceRole).toString()); -} - -void ResourceModel::loadDefaultsIfNeeded() const -{ - // Did we get a request to actually do anything? - if (m_defaultItemsConfig.isEmpty()) - return; - if (m_shownAgents.size() == 0) - return; - - // If we have already loaded the items, just exit - if (m_defaultItemsLoaded) - return; - m_defaultItemsLoaded = true; - - // If there are items in the model, no need to load the defaults - if (count() != 0) - return; - - // Did we already load the defaults for this agent? - QStringList alreadyInitialized = m_config.readEntry("defaultItemsProcessedFor", QStringList()); - if (alreadyInitialized.contains(m_shownAgents.first())) - return; - alreadyInitialized << m_shownAgents.first(); - m_config.writeEntry("defaultItemsProcessedFor", alreadyInitialized); - m_config.sync(); - - QStringList args = m_defaultItemsConfig.split("/"); - QString configField = args.takeLast(); - QString configGroup = args.takeLast(); - QString configFile = args.join("/"); - - // qDebug() << "Config" - // << configFile << " " - // << configGroup << " " - // << configField << " "; - - QStringList items = KSharedConfig::openConfig(configFile)->group(configGroup).readEntry(configField, QStringList()); - - for (const auto &item : items) { - // qDebug() << "Adding: " << item; - linkResourceToActivity(item, ":global", QJSValue()); - } -} - -QString ResourceModel::validateResource(const QString &resource) const -{ - return resource.startsWith(QLatin1String("file://")) ? QUrl(resource).toLocalFile() : resource; -} - -} // namespace Imports -} // namespace KActivities - -#include "moc_resourcemodel.cpp" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plasma-activities-6.1.5/src/imports/resourcemodel.h new/plasma-activities-6.2.0/src/imports/resourcemodel.h --- old/plasma-activities-6.1.5/src/imports/resourcemodel.h 2024-09-10 10:51:20.000000000 +0200 +++ new/plasma-activities-6.2.0/src/imports/resourcemodel.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,170 +0,0 @@ -/* - SPDX-FileCopyrightText: 2012, 2013, 2014 Ivan Cukic <ivan.cukic(at)kde.org> - - SPDX-License-Identifier: GPL-2.0-or-later -*/ - -#ifndef KACTIVITIES_IMPORTS_RESOURCE_MODEL_H -#define KACTIVITIES_IMPORTS_RESOURCE_MODEL_H - -// Qt -#include <QJSValue> -#include <QObject> -#include <QSortFilterProxyModel> -#include <QSqlDatabase> -#include <QSqlTableModel> - -// KDE -#include <KConfigGroup> - -// STL and Boost -#include <memory> - -// Local -#include <lib/consumer.h> -#include <lib/controller.h> -#include <lib/info.h> - -class QModelIndex; -class QDBusPendingCallWatcher; - -namespace KActivities -{ -namespace Imports -{ -/** - * ResourceModel - */ - -class ResourceModel : public QSortFilterProxyModel -{ - Q_OBJECT - - /** - * Sets for which activities should the resources be shown for. - * Coma-separated values. - * Special values are: - * - ":current" for the current activity - * - ":any" show resources that are linked to any activity, including "global" - * - ":global" show resources that are globally linked - */ - Q_PROPERTY(QString shownActivities READ shownActivities WRITE setShownActivities NOTIFY shownActivitiesChanged) - - /** - * Sets for which agents should the resources be shown for. - * Coma-separated values. - * Special values are: - * - ":current" for the current application - * - ":any" show resources that are linked to any agent, including "global" - * - ":global" show resources that are globally linked - */ - Q_PROPERTY(QString shownAgents READ shownAgents WRITE setShownAgents NOTIFY shownAgentsChanged) - - /** - * If the model is empty, use this config file to read the default items. - * The default items are automatically linked globally, not per-activity. - * It needs to have the following format: 'config-namerc/ConfigGroup/ConfigEntry'. - * The config entry needs to be a list of strings. - */ - Q_PROPERTY(QString defaultItemsConfig READ defaultItemsConfig WRITE setDefaultItemsConfig) - -public: - explicit ResourceModel(QObject *parent = nullptr); - ~ResourceModel() override; - - enum Roles { - ResourceRole = Qt::UserRole, - ActivityRole = Qt::UserRole + 1, - AgentRole = Qt::UserRole + 2, - DescriptionRole = Qt::UserRole + 3, - }; - - QHash<int, QByteArray> roleNames() const override; - - virtual QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const override; - -public Q_SLOTS: - // Resource linking control methods - void linkResourceToActivity(const QString &resource, const QJSValue &callback) const; - void linkResourceToActivity(const QString &resource, const QString &activity, const QJSValue &callback) const; - void linkResourceToActivity(const QString &agent, const QString &resource, const QString &activity, const QJSValue &callback) const; - - void unlinkResourceFromActivity(const QString &resource, const QJSValue &callback); - void unlinkResourceFromActivity(const QString &resource, const QString &activity, const QJSValue &callback); - void unlinkResourceFromActivity(const QString &agent, const QString &resource, const QString &activity, const QJSValue &callback); - void unlinkResourceFromActivity(const QStringList &agents, const QString &resource, const QStringList &activities, const QJSValue &callback); - - bool isResourceLinkedToActivity(const QString &resource); - bool isResourceLinkedToActivity(const QString &resource, const QString &activity); - bool isResourceLinkedToActivity(const QString &agent, const QString &resource, const QString &activity); - bool isResourceLinkedToActivity(const QStringList &agents, const QString &resource, const QStringList &activities); - - // Model property getters and setters - void setShownActivities(const QString &activities); - QString shownActivities() const; - - void setShownAgents(const QString &agents); - QString shownAgents() const; - - QString defaultItemsConfig() const; - void setDefaultItemsConfig(const QString &defaultItemsConfig); - - void setOrder(const QStringList &resources); - void move(int sourceItem, int destinationItem); - void sortItems(Qt::SortOrder sortOrder); - - KConfigGroup config() const; - - int count() const; - QString displayAt(int row) const; - QString resourceAt(int row) const; - -protected: - bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; - -Q_SIGNALS: - void shownActivitiesChanged(); - void shownAgentsChanged(); - -private Q_SLOTS: - void onCurrentActivityChanged(const QString &activity); - - void onResourceLinkedToActivity(const QString &initiatingAgent, const QString &targettedResource, const QString &usedActivity); - void onResourceUnlinkedFromActivity(const QString &initiatingAgent, const QString &targettedResource, const QString &usedActivity); - -private: - KActivities::Consumer m_service; - - inline QVariant dataForColumn(const QModelIndex &index, int column) const; - - QString activityToWhereClause(const QString &activity) const; - QString agentToWhereClause(const QString &agent) const; - QString whereClause(const QStringList &activities, const QStringList &agents) const; - - void loadDefaultsIfNeeded() const; - - bool loadDatabase(); - QString m_databaseFile; - QSqlDatabase m_database; - QSqlTableModel *m_databaseModel; - - QStringList m_shownActivities; - QStringList m_shownAgents; - QStringList m_sorting; - - QString m_defaultItemsConfig; - mutable bool m_defaultItemsLoaded; - - void reloadData(); - QString validateResource(const QString &resource) const; - - class LinkerService; - std::shared_ptr<LinkerService> m_linker; - - mutable KConfigGroup m_config; -}; - -} // namespace Imports -} // namespace KActivities - -#endif // KACTIVITIES_IMPORTS_RESOURCE_MODEL_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plasma-activities-6.1.5/src/lib/activitiescache_p.cpp new/plasma-activities-6.2.0/src/lib/activitiescache_p.cpp --- old/plasma-activities-6.1.5/src/lib/activitiescache_p.cpp 2024-09-10 10:51:20.000000000 +0200 +++ new/plasma-activities-6.2.0/src/lib/activitiescache_p.cpp 2024-10-03 14:37:53.000000000 +0200 @@ -62,28 +62,38 @@ // signal void org.kde.ActivityManager.Activities.ActivityStarted(QString activity) // signal void org.kde.ActivityManager.Activities.ActivityStopped(QString activity) - setServiceStatus(Manager::self()->isServiceRunning()); + setServiceStatus(Manager::self()->serviceStatus()); } -void ActivitiesCache::setServiceStatus(bool status) +void ActivitiesCache::setServiceStatus(Manager::ServiceStatus status) { - // qDebug() << "Setting service status to:" << status; loadOfflineDefaults(); - if (status) { + auto oldStatus = m_status; + switch (status) { + case Manager::NotRunning: + m_status = Consumer::NotRunning; + break; + case Manager::Starting: + m_status = Consumer::Unknown; + break; + case Manager::Running: + // will become running once loaded + m_status = Consumer::Unknown; updateAllActivities(); + break; + } + if (m_status != oldStatus) { + Q_EMIT serviceStatusChanged(m_status); } } void ActivitiesCache::loadOfflineDefaults() { - m_status = Consumer::NotRunning; - m_activities.clear(); m_activities << ActivityInfo(nulluuid, QString(), QString(), QString(), Info::Running); m_currentActivity = nulluuid; - Q_EMIT serviceStatusChanged(m_status); Q_EMIT activityListChanged(); } @@ -113,10 +123,6 @@ void ActivitiesCache::updateAllActivities() { - // qDebug() << "Updating all"; - m_status = Consumer::Unknown; - Q_EMIT serviceStatusChanged(m_status); - // Loading the current activity auto call = Manager::self()->activities()->asyncCall(QStringLiteral("CurrentActivity")); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plasma-activities-6.1.5/src/lib/activitiescache_p.h new/plasma-activities-6.2.0/src/lib/activitiescache_p.h --- old/plasma-activities-6.1.5/src/lib/activitiescache_p.h 2024-09-10 10:51:20.000000000 +0200 +++ new/plasma-activities-6.2.0/src/lib/activitiescache_p.h 2024-10-03 14:37:53.000000000 +0200 @@ -16,6 +16,7 @@ #include "activities_interface.h" #include "consumer.h" +#include "manager_p.h" namespace KActivities { @@ -63,7 +64,7 @@ void setAllActivities(const ActivityInfoList &activities); void setCurrentActivity(const QString &activity); - void setServiceStatus(bool status); + void setServiceStatus(Manager::ServiceStatus status); public: template<typename _Result, typename _Functor> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plasma-activities-6.1.5/src/lib/manager_p.cpp new/plasma-activities-6.2.0/src/lib/manager_p.cpp --- old/plasma-activities-6.1.5/src/lib/manager_p.cpp 2024-09-10 10:51:20.000000000 +0200 +++ new/plasma-activities-6.2.0/src/lib/manager_p.cpp 2024-10-03 14:37:53.000000000 +0200 @@ -34,11 +34,11 @@ , m_resources(new KAMD_DBUS_CLASS_INTERFACE("Resources", Resources, this)) , m_resourcesLinking(new KAMD_DBUS_CLASS_INTERFACE("Resources/Linking", ResourcesLinking, this)) , m_features(new KAMD_DBUS_CLASS_INTERFACE("Features", Features, this)) - , m_serviceRunning(false) + , m_serviceStatus(Manager::NotRunning) { connect(&m_watcher, &QDBusServiceWatcher::serviceOwnerChanged, this, &Manager::serviceOwnerChanged); - if (isServiceRunning()) { + if (serviceStatus()) { serviceOwnerChanged(KAMD_DBUS_SERVICE, QString(), KAMD_DBUS_SERVICE); } } @@ -51,7 +51,12 @@ if (!s_instance) { runInMainThread([]() { // check if the activity manager is already running - if (!Manager::isServiceRunning()) { + // creating a new instance of the class + Manager::s_instance = new Manager(); + + if (QDBusConnection::sessionBus().interface()->isServiceRegistered(KAMD_DBUS_SERVICE)) { // already running + s_instance->m_serviceStatus = Running; + } else { // not running bool disableAutolaunch = QCoreApplication::instance()->property("org.kde.KActivities.core.disableAutostart").toBool(); qCDebug(KAMD_CORELIB) << "Should we start the daemon?"; @@ -59,22 +64,29 @@ if (!disableAutolaunch && QDBusConnection::sessionBus().interface()) { qCDebug(KAMD_CORELIB) << "Starting the activity manager daemon"; auto busInterface = QDBusConnection::sessionBus().interface(); - busInterface->asyncCall(QStringLiteral("StartServiceByName"), KAMD_DBUS_SERVICE, uint(0)); + auto pending = busInterface->asyncCall(QStringLiteral("StartServiceByName"), KAMD_DBUS_SERVICE, uint(0)); + s_instance->m_serviceStatus = Manager::Starting; + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pending, s_instance); + connect(watcher, &QDBusPendingCallWatcher::finished, watcher, []() { + const bool isRunning = QDBusConnection::sessionBus().interface()->isServiceRegistered(KAMD_DBUS_SERVICE); + s_instance->m_serviceStatus = isRunning ? Manager::Running : Manager::NotRunning; + Q_EMIT s_instance->serviceStatusChanged(s_instance->m_serviceStatus); + }); } } - - // creating a new instance of the class - Manager::s_instance = new Manager(); }); } - return s_instance; } bool Manager::isServiceRunning() { - return (s_instance ? s_instance->m_serviceRunning : true) && QDBusConnection::sessionBus().interface() - && QDBusConnection::sessionBus().interface()->isServiceRegistered(KAMD_DBUS_SERVICE); + return s_instance && s_instance->m_serviceStatus == Manager::Running; +} + +Manager::ServiceStatus Manager::serviceStatus() +{ + return s_instance ? s_instance->m_serviceStatus : NotRunning; } void Manager::serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner) @@ -82,10 +94,11 @@ Q_UNUSED(oldOwner); if (serviceName == KAMD_DBUS_SERVICE) { - m_serviceRunning = !newOwner.isEmpty(); - Q_EMIT serviceStatusChanged(m_serviceRunning); + const bool isRunning = QDBusConnection::sessionBus().interface()->isServiceRegistered(KAMD_DBUS_SERVICE); + m_serviceStatus = isRunning ? Manager::Running : Manager::NotRunning; + Q_EMIT serviceStatusChanged(m_serviceStatus); - if (m_serviceRunning) { + if (isRunning) { using namespace kamd::utils; continue_with(DBusFuture::fromReply(m_service->serviceVersion()), [this](const std::optional<QString> &serviceVersion) { @@ -94,7 +107,7 @@ if (!serviceVersion.has_value()) { qWarning() << "KActivities: FATAL ERROR: Failed to contact the activity manager daemon"; - m_serviceRunning = false; + m_serviceStatus = NotRunning; return; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plasma-activities-6.1.5/src/lib/manager_p.h new/plasma-activities-6.2.0/src/lib/manager_p.h --- old/plasma-activities-6.1.5/src/lib/manager_p.h 2024-09-10 10:51:20.000000000 +0200 +++ new/plasma-activities-6.2.0/src/lib/manager_p.h 2024-10-03 14:37:53.000000000 +0200 @@ -26,9 +26,16 @@ Q_OBJECT public: + enum ServiceStatus { + NotRunning, + Starting, + Running, + }; + static Manager *self(); static bool isServiceRunning(); + static ServiceStatus serviceStatus(); static Service::Activities *activities(); static Service::Resources *resources(); @@ -39,7 +46,7 @@ void serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner); Q_SIGNALS: - void serviceStatusChanged(bool status); + void serviceStatusChanged(ServiceStatus status); private: Manager(); @@ -53,7 +60,7 @@ Service::Resources *const m_resources; Service::ResourcesLinking *const m_resourcesLinking; Service::Features *const m_features; - bool m_serviceRunning; + ServiceStatus m_serviceStatus; friend class ManagerInstantiator; };
participants (1)
-
Source-Sync