From kde-commits Sat Jun 30 21:04:40 2012 From: =?utf-8?b?SXZhbiDEjHVracSH?= Date: Sat, 30 Jun 2012 21:04:40 +0000 To: kde-commits Subject: [kactivities/ivan/plugin-refactor] /: Features object Message-Id: <20120630210440.65086A60C6 () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=134109050825130 Git commit 4c321b6c1e47c7c120512c34ca5732d46bd20f9c by Ivan =C4=8Cuki=C4=87. Committed on 29/06/2012 at 10:07. Pushed by ivan into branch 'ivan/plugin-refactor'. Features object M +7 -0 lib/CMakeLists.txt M +2 -3 lib/info.cpp M +12 -0 lib/manager_p.cpp M +4 -1 lib/manager_p.h M +19 -5 service/Application.cpp M +10 -5 service/Application.h M +6 -0 service/CMakeLists.txt A +67 -0 service/Features.cpp [License: GPL (v2)] M +9 -0 service/Features.h M +0 -1 service/Resources.cpp http://commits.kde.org/kactivities/4c321b6c1e47c7c120512c34ca5732d46bd20f9c diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index a7c0514..e064b8b 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -86,6 +86,13 @@ qt4_add_dbus_interface( resources_interface ) = +qt4_add_dbus_interface( + kactivities_LIB_SRCS + + ../common/dbus/org.kde.ActivityManager.Features.xml + features_interface + ) + kde4_add_library( kactivities SHARED ${kactivities_LIB_SRCS} diff --git a/lib/info.cpp b/lib/info.cpp index dd315bc..9cafb72 100644 --- a/lib/info.cpp +++ b/lib/info.cpp @@ -170,10 +170,9 @@ Info::Availability Info::availability() const if (Manager::activities()->ListActivities().value().contains(d->id)) { result =3D BasicInfo; = - // TODO: - // if (Manager::self()->IsFeatureOperational("activity/resource-li= nking")) { + if (Manager::features()->IsFeatureOperational("resource-linking"))= { result =3D Everything; - // } + } } = return result; diff --git a/lib/manager_p.cpp b/lib/manager_p.cpp index 307a449..f3e35d8 100644 --- a/lib/manager_p.cpp +++ b/lib/manager_p.cpp @@ -46,6 +46,13 @@ Manager::Manager() ACTIVITY_MANAGER_DBUS_OBJECT "/Resources", QDBusConnection::sessionBus(), this + )), + m_features( + new org::kde::ActivityManager::Features( + ACTIVITY_MANAGER_DBUS_PATH, + ACTIVITY_MANAGER_DBUS_OBJECT "/Features", + QDBusConnection::sessionBus(), + this )) { connect(&m_watcher, SIGNAL(serviceOwnerChanged(const QString &, const = QString &, const QString &)), @@ -104,5 +111,10 @@ Service::Resources * Manager::resources() return self()->m_resources; } = +Service::Features * Manager::features() +{ + return self()->m_features; +} + } // namespace KActivities = diff --git a/lib/manager_p.h b/lib/manager_p.h index 2e482e4..16f329c 100644 --- a/lib/manager_p.h +++ b/lib/manager_p.h @@ -22,6 +22,7 @@ = #include "activities_interface.h" #include "resources_interface.h" +#include "features_interface.h" = #include = @@ -39,6 +40,7 @@ public: = static Service::Activities * activities(); static Service::Resources * resources(); + static Service::Features * features(); = public Q_SLOTS: void serviceOwnerChanged(const QString & serviceName, const QString & = oldOwner, const QString & newOwner); @@ -54,7 +56,8 @@ private: static Manager * s_instance; = Service::Activities * const m_activities; - Service::Resources * const m_resources; + Service::Resources * const m_resources; + Service::Features * const m_features; }; = } // namespace KActivities diff --git a/service/Application.cpp b/service/Application.cpp index 816da64..7604228 100644 --- a/service/Application.cpp +++ b/service/Application.cpp @@ -29,6 +29,7 @@ = #include #include +#include = #include #include @@ -38,6 +39,8 @@ #include #include = +static QList < QThread * > s_moduleThreads; + template T * runInQThread() { @@ -45,8 +48,8 @@ T * runInQThread() = class Thread: public QThread { public: - Thread(T * ptr) - : QThread(ptr), object(ptr) + Thread(T * ptr =3D nullptr) + : QThread(), object(ptr) { } = @@ -55,6 +58,8 @@ T * runInQThread() qDebug() << "This is the current thread id for" << T::staticMetaObject.className() << QThread::currentThreadI= d() << QThread::currentThread(); exec(); + + delete object; } = private: @@ -62,6 +67,8 @@ T * runInQThread() = } * thread =3D new Thread(object); = + s_moduleThreads << thread; + object->moveToThread(thread); thread->start(); = @@ -71,9 +78,10 @@ T * runInQThread() } = Application::Application() - : KApplication(), - m_resources (runInQThread()), - m_activities(runInQThread()) + : KUniqueApplication(), + m_resources (runInQThread ()), + m_activities (runInQThread ()), + m_features (runInQThread ()) { // TODO: We should move away from any GUI code setQuitOnLastWindowClosed(false); @@ -94,6 +102,12 @@ Application::Application() = Application::~Application() { + foreach (QThread * thread, s_moduleThreads) { + thread->quit(); + thread->wait(); + + delete thread; + } } = Activities & Application::activities() const diff --git a/service/Application.h b/service/Application.h index 4bde757..e7077d2 100644 --- a/service/Application.h +++ b/service/Application.h @@ -20,16 +20,17 @@ #ifndef APPLICATION_H #define APPLICATION_H = -#include +#include #include = class Resources; class Activities; +class Features; = /** * Application */ -class Application: public KApplication { +class Application: public KUniqueApplication { public: Application(); virtual ~Application(); @@ -38,11 +39,15 @@ public: = Resources & resources() const; Activities & activities() const; - // Features & features() const; + Features & features() const; = private: - const std::unique_ptr < Resources > m_resources; - const std::unique_ptr < Activities > m_activities; + Resources * m_resources; + Activities * m_activities; + Features * m_features; + // const std::unique_ptr < Resources > m_resources; + // const std::unique_ptr < Activities > m_activities; + // const std::unique_ptr < Features > m_features; }; = #endif // APPLICATION_H diff --git a/service/CMakeLists.txt b/service/CMakeLists.txt index e34c2f2..e934c31 100644 --- a/service/CMakeLists.txt +++ b/service/CMakeLists.txt @@ -80,6 +80,7 @@ set (activity_manager_SRCS = Activities.cpp Resources.cpp + Features.cpp = NepomukActivityManager.cpp = @@ -143,6 +144,11 @@ qt4_add_dbus_adaptor (activity_manager_SRCS Resources.h Resources ) = +qt4_add_dbus_adaptor (activity_manager_SRCS + ../common/dbus/org.kde.ActivityManager.Features.xml + Features.h Features + ) + kde4_add_executable (activity-manager ${activity_manager_SRCS}) = target_link_libraries (activity-manager diff --git a/service/Features.cpp b/service/Features.cpp new file mode 100644 index 0000000..d7f41d0 --- /dev/null +++ b/service/Features.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (C) 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. + */ + +#include +#include "featuresadaptor.h" + +#include + +#include "common.h" +#include "jobs/encryption/all.h" + +#include + +class Features::Private { + +}; + +Features::Features(QObject * parent) + : QObject(parent), d() +{ + new FeaturesAdaptor(this); + QDBusConnection::sessionBus().registerObject( + ACTIVITY_MANAGER_OBJECT_PATH(Features), this); +} + +Features::~Features() +{ +} + +bool Features::IsFeatureEnabled(const QString & activity, const QString & = feature) const +{ + return true; +} + +bool Features::IsFeatureOperational(const QString & feature) const +{ + if (feature =3D=3D "resource-linking") { + return NEPOMUK_PRESENT; + } + + if (feature =3D=3D "encryption") { + return Jobs::Encryption::Common::isEnabled(); + } + + return false; +} + +void Features::SetFeatureEnabled(const QString & activity, const QString &= feature, bool value) +{ +} + diff --git a/service/Features.h b/service/Features.h index efdc5ae..47a9df5 100644 --- a/service/Features.h +++ b/service/Features.h @@ -37,6 +37,15 @@ class Features: public QObject { Q_CLASSINFO("D-Bus Interface", "org.kde.ActivityManager.Features") = public: + Features(QObject * parent =3D nullptr); + virtual ~Features(); + +public Q_SLOTS: + bool IsFeatureOperational(const QString & feature) const; + + bool IsFeatureEnabled(const QString & activity, const QString & featur= e) const; + + void SetFeatureEnabled(const QString & activity, const QString & featu= re, bool value); = = private: diff --git a/service/Resources.cpp b/service/Resources.cpp index 6b808a5..0401857 100644 --- a/service/Resources.cpp +++ b/service/Resources.cpp @@ -44,7 +44,6 @@ // TODO static QString CurrentActivity() { - qDebug() << Application::self().activities().CurrentActivity(); return Application::self().activities().CurrentActivity(); } =