diff --git a/src/service/Activities_p.h b/src/service/Activities_p.h index fd01970..dae44f4 100644 --- a/src/service/Activities_p.h +++ b/src/service/Activities_p.h @@ -1,129 +1,128 @@ /* * Copyright (C) 2010 - 2016 by Ivan Cukic * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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, see . */ #ifndef ACTIVITIES_P_H #define ACTIVITIES_P_H // Self #include "Activities.h" // Qt #include #include #include // KDE #include #include class KSMServer; -class QDBusInterface; class Activities::Private : public QObject { Q_OBJECT public: Private(Activities *parent); ~Private() override; // Loads the last activity // the user has used void loadLastActivity(); // If the current activity is not running, // make some other activity current void ensureCurrentActivityIsRunning(); public Q_SLOTS: bool setCurrentActivity(const QString &activity); public: void setActivityState(const QString &activity, Activities::State state); // Configuration class KDE4ConfigurationTransitionChecker { public: KDE4ConfigurationTransitionChecker(); } kde4ConfigurationTransitionChecker; QTimer configSyncTimer; KConfig config; // Interface to the session management KSMServer *ksmserver; QHash activities; QReadWriteLock activitiesLock; QString currentActivity; public: inline KConfigGroup activityNameConfig() { return KConfigGroup(&config, "activities"); } inline KConfigGroup activityDescriptionConfig() { return KConfigGroup(&config, "activities-descriptions"); } inline KConfigGroup activityIconConfig() { return KConfigGroup(&config, "activities-icons"); } inline KConfigGroup mainConfig() { return KConfigGroup(&config, "main"); } inline QString activityName(const QString &activity) { return activityNameConfig().readEntry(activity, QString()); } inline QString activityDescription(const QString &activity) { return activityDescriptionConfig().readEntry(activity, QString()); } inline QString activityIcon(const QString &activity) { return activityIconConfig().readEntry(activity, QString()); } public Q_SLOTS: // Schedules config syncing to be done after // a predefined time interval void scheduleConfigSync(); // Immediately syncs the configuration file void configSync(); QString addActivity(const QString &name); void removeActivity(const QString &activity); void activitySessionStateChanged(const QString &activity, int state); private: Activities *const q; }; #endif // ACTIVITIES_P_H diff --git a/src/service/plugins/activitytemplates/TemplatesPlugin.h b/src/service/plugins/activitytemplates/TemplatesPlugin.h index a5ec966..2c648be 100644 --- a/src/service/plugins/activitytemplates/TemplatesPlugin.h +++ b/src/service/plugins/activitytemplates/TemplatesPlugin.h @@ -1,50 +1,48 @@ /* * Copyright (C) 2012, 2013, 2014 Ivan Cukic * * 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, see . */ #ifndef PLUGINS_GLOBAL_TEMPLATES_H #define PLUGINS_GLOBAL_TEMPLATES_H #include -class QSignalMapper; -class KActionCollection; class TemplatesPlugin : public Plugin { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.ActivityManager.Templates") public: explicit TemplatesPlugin(QObject *parent = nullptr, const QVariantList &args = QVariantList()); ~TemplatesPlugin() override; bool init(QHash &modules) override; QDBusVariant featureValue(const QStringList &property) const override; void setFeatureValue(const QStringList &property, const QDBusVariant &value) override; public Q_SLOTS: void createActivity(const QDBusVariant &values); private: QObject *m_activities; }; #endif // PLUGINS_GLOBAL_TEMPLATES_ diff --git a/src/service/plugins/sqlite/Database.h b/src/service/plugins/sqlite/Database.h index 6bcaa5d..c026c73 100644 --- a/src/service/plugins/sqlite/Database.h +++ b/src/service/plugins/sqlite/Database.h @@ -1,64 +1,63 @@ /* * Copyright (C) 2011, 2012 Ivan Cukic * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * or (at your option) any later version, 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 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 PLUGINS_SQLITE_RESOURCESDATABASE_H #define PLUGINS_SQLITE_RESOURCESDATABASE_H // Qt #include #include #include #include #include #include // Utils #include // Local #include class QDateTime; -class QSqlDatabase; class QSqlError; namespace Common { class Database; } // namespace Common class ResourcesDatabaseMigrator : public QObject { Q_OBJECT public: // static Database *self(); private: ResourcesDatabaseMigrator(); ~ResourcesDatabaseMigrator() override; void migrateDatabase(const QString &newDatabaseFile) const; D_PTR; friend Common::Database::Ptr resourcesDatabase(); }; Common::Database::Ptr resourcesDatabase(); #endif // PLUGINS_SQLITE_RESOURCESDATABASE_H diff --git a/src/service/plugins/sqlite/ResourceLinking.h b/src/service/plugins/sqlite/ResourceLinking.h index 2c68be9..671c3bb 100644 --- a/src/service/plugins/sqlite/ResourceLinking.h +++ b/src/service/plugins/sqlite/ResourceLinking.h @@ -1,97 +1,96 @@ /* * Copyright (C) 2011, 2012, 2013, 2014, 2015 Ivan Cukic * * 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, see . */ #ifndef PLUGINS_SQLITE_RESOURCE_LINKING_H #define PLUGINS_SQLITE_RESOURCE_LINKING_H // Qt #include // Boost and STL #include #include // Local #include class QSqlQuery; -class QFileSystemWatcher; /** * Communication with the outer world. * * - Handles configuration * - Filters the events based on the user's configuration. */ class ResourceLinking : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.ActivityManager.Resources.Linking") public: explicit ResourceLinking(QObject *parent); void init(); public Q_SLOTS: /** * Links the resource to the activity * @param initiatingAgent application that requests the linking. Leave * empty if the resource should be linked to the activity regardless * of which application asks for it. * @param targettedResource resource to link to the activity. Can be a file * or any other kind of URI. If it is not a globally recognizable URI, * you should set the initiatingAgent to a specific application. * @param usedActivity Activity to link to. Leave empty to link to all * activities. */ void LinkResourceToActivity(QString initiatingAgent, QString targettedResource, QString usedActivity = QString()); void UnlinkResourceFromActivity(QString initiatingAgent, QString targettedResource, QString usedActivity = QString()); bool IsResourceLinkedToActivity(QString initiatingAgent, QString targettedResource, QString usedActivity = QString()); Q_SIGNALS: void ResourceLinkedToActivity(const QString &initiatingAgent, const QString &targettedResource, const QString &usedActivity); void ResourceUnlinkedFromActivity(const QString &initiatingAgent, const QString &targettedResource, const QString &usedActivity); private Q_SLOTS: void onActivityAdded(const QString &activity); void onActivityRemoved(const QString &activity); void onCurrentActivityChanged(const QString &activity); private: bool validateArguments(QString &initiatingAgent, QString &targettedResource, QString &usedActivity); QString currentActivity() const; std::unique_ptr linkResourceToActivityQuery; std::unique_ptr unlinkResourceFromAllActivitiesQuery; std::unique_ptr unlinkResourceFromActivityQuery; std::unique_ptr isResourceLinkedToActivityQuery; }; #endif // PLUGINS_SQLITE_RESOURCE_LINKING_H diff --git a/src/service/plugins/sqlite/StatsPlugin.h b/src/service/plugins/sqlite/StatsPlugin.h index 98c2ff9..c5476e9 100644 --- a/src/service/plugins/sqlite/StatsPlugin.h +++ b/src/service/plugins/sqlite/StatsPlugin.h @@ -1,159 +1,158 @@ /* * Copyright (C) 2011, 2012, 2013, 2014 Ivan Cukic * * 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, see . */ #ifndef PLUGINS_SQLITE_STATS_PLUGIN_H #define PLUGINS_SQLITE_STATS_PLUGIN_H // Qt #include #include // Boost and STL #include #include // Local #include class QSqlQuery; -class QFileSystemWatcher; class ResourceLinking; /** * Communication with the outer world. * * - Handles configuration * - Filters the events based on the user's configuration. */ class StatsPlugin : public Plugin { Q_OBJECT // Q_CLASSINFO("D-Bus Interface", "org.kde.ActivityManager.Resources.Scoring") // Q_PLUGIN_METADATA(IID "org.kde.ActivityManager.plugins.sqlite") public: explicit StatsPlugin(QObject *parent = nullptr, const QVariantList &args = QVariantList()); static StatsPlugin *self(); bool init(QHash &modules) override; QString currentActivity() const; QStringList listActivities() const; inline QObject *activitiesInterface() const { return m_activities; } bool isFeatureOperational(const QStringList &feature) const override; QStringList listFeatures(const QStringList &feature) const override; QDBusVariant featureValue(const QStringList &property) const override; void setFeatureValue(const QStringList &property, const QDBusVariant &value) override; // // D-BUS Interface methods // public Q_SLOTS: void DeleteRecentStats(const QString &activity, int count, const QString &what); void DeleteEarlierStats(const QString &activity, int months); void DeleteStatsForResource(const QString &activity, const QString &client, const QString &resource); Q_SIGNALS: void ResourceScoreUpdated(const QString &activity, const QString &client, const QString &resource, double score, uint lastUpdate, uint firstUpdate); void ResourceScoreDeleted(const QString &activity, const QString &client, const QString &resource); void RecentStatsDeleted(const QString &activity, int count, const QString &what); void EarlierStatsDeleted(const QString &activity, int months); // // End D-BUS Interface methods // private Q_SLOTS: void addEvents(const EventList &events); void loadConfiguration(); void openResourceEvent(const QString &usedActivity, const QString &initiatingAgent, const QString &targettedResource, const QDateTime &start, const QDateTime &end = QDateTime()); void closeResourceEvent(const QString &usedActivity, const QString &initiatingAgent, const QString &targettedResource, const QDateTime &end); void saveResourceTitle(const QString &uri, const QString &title, bool autoTitle = false); void saveResourceMimetype(const QString &uri, const QString &mimetype, bool autoMimetype = false); bool insertResourceInfo(const QString &uri); void detectResourceInfo(const QString &uri); void deleteOldEvents(); private: inline bool acceptedEvent(const Event &event); inline Event validateEvent(Event event); enum WhatToRemember { AllApplications = 0, SpecificApplications = 1, NoApplications = 2 }; QObject *m_activities; QObject *m_resources; boost::container::flat_set m_apps; QList m_urlFilters; QStringList m_otrActivities; std::unique_ptr openResourceEventQuery; std::unique_ptr closeResourceEventQuery; std::unique_ptr insertResourceInfoQuery; std::unique_ptr getResourceInfoQuery; std::unique_ptr saveResourceTitleQuery; std::unique_ptr saveResourceMimetypeQuery; QTimer m_deleteOldEventsTimer; bool m_blockedByDefault : 1; bool m_blockAll : 1; WhatToRemember m_whatToRemember : 2; ResourceLinking *m_resourceLinking; static StatsPlugin *s_instance; }; #endif // PLUGINS_SQLITE_STATS_PLUGIN_H