aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Seigo <aseigo@kde.org>2011-11-04 22:24:14 (GMT)
committerAaron Seigo <aseigo@kde.org>2011-11-04 22:24:14 (GMT)
commitc35999173fba6f50b66385ec281b47f5c2bb33f2 (patch)
treea910459341cc1eb760cbeac827de4a1c92a0b2e1
parent38df01aaeb5717e16c19cdf1e9ebd57f9a585528 (diff)
remove the classes the duplicate functionality in libkactivitiesrefs/backups/branch-libkactivities-1323850121
-rw-r--r--libs/kworkspace/CMakeLists.txt13
-rw-r--r--libs/kworkspace/kactivityconsumer.cpp127
-rw-r--r--libs/kworkspace/kactivityconsumer.h159
-rw-r--r--libs/kworkspace/kactivityconsumer_p.h27
-rw-r--r--libs/kworkspace/kactivitycontroller.cpp116
-rw-r--r--libs/kworkspace/kactivitycontroller.h144
-rw-r--r--libs/kworkspace/kactivityinfo.cpp252
-rw-r--r--libs/kworkspace/kactivityinfo.h226
-rw-r--r--libs/kworkspace/kactivityinfo_p.h43
-rw-r--r--libs/kworkspace/kactivitymanager_p.cpp83
-rw-r--r--libs/kworkspace/kactivitymanager_p.h49
11 files changed, 0 insertions, 1239 deletions
diff --git a/libs/kworkspace/CMakeLists.txt b/libs/kworkspace/CMakeLists.txt
index 32cd11d..5ba7e97 100644
--- a/libs/kworkspace/CMakeLists.txt
+++ b/libs/kworkspace/CMakeLists.txt
@@ -3,10 +3,6 @@ set(kworkspace_LIB_SRCS kdisplaymanager.cpp
kwindowlistmenu.cpp
screenpreviewwidget.cpp
kworkspace.cpp
- kactivityconsumer.cpp
- kactivitycontroller.cpp
- kactivityinfo.cpp
- kactivitymanager_p.cpp
)
if(SOPRANO_PLUGIN_RAPTORPARSER_FOUND AND SHAREDDESKTOPONTOLOGIES_ROOT_DIR)
@@ -50,12 +46,6 @@ set_source_files_properties(${kwin_xml} PROPERTIES INCLUDE "interface_util.h")
qt4_add_dbus_interface( kworkspace_LIB_SRCS ${kwin_xml} kwin_interface )
-qt4_add_dbus_interface(
- kworkspace_LIB_SRCS
- org.kde.ActivityManager.xml
- activitymanager_interface
-)
-
if(WIN32)
set (LIB_MODE)
else(WIN32)
@@ -72,7 +62,4 @@ install(TARGETS kworkspace EXPORT kdeworkspaceLibraryTargets ${INSTALL_TARGETS_D
install( FILES kdisplaymanager.h
kwindowlistmenu.h
kworkspace.h
- kactivityconsumer.h
- kactivitycontroller.h
- kactivityinfo.h
DESTINATION ${INCLUDE_INSTALL_DIR}/kworkspace COMPONENT Devel )
diff --git a/libs/kworkspace/kactivityconsumer.cpp b/libs/kworkspace/kactivityconsumer.cpp
deleted file mode 100644
index 8275124..0000000
--- a/libs/kworkspace/kactivityconsumer.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (c) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License version 2 as published by the Free Software Foundation.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "kactivityconsumer.h"
-#include "kactivityconsumer_p.h"
-#include "kactivitymanager_p.h"
-
-#include <KDebug>
-
-KActivityConsumer::KActivityConsumer(QObject * parent)
- : QObject(parent), d(new KActivityConsumerPrivate())
-{
- connect(
- KActivityManager::self(), SIGNAL(CurrentActivityChanged(QString)),
- this, SIGNAL(currentActivityChanged(QString))
- );
-}
-
-KActivityConsumer::~KActivityConsumer()
-{
- delete d;
-}
-
-// macro defines a shorthand for validating and returning a d-bus result
-// @param TYPE type of the result
-// @param METHOD invocation of the d-bus method
-// @param DEFAULT value to be used if the reply was not valid
-#define KACTIVITYCONSUMER_DBUS_RETURN(TYPE, METHOD, DEFAULT) \
- QDBusReply < TYPE > dbusReply = METHOD; \
- if (dbusReply.isValid()) { \
- return dbusReply.value(); \
- } else { \
- kDebug() << "d-bus reply was invalid" \
- << dbusReply.value() \
- << dbusReply.error(); \
- return DEFAULT; \
- }
-
-QString KActivityConsumer::currentActivity() const
-{
- KACTIVITYCONSUMER_DBUS_RETURN(
- QString, KActivityManager::self()->CurrentActivity(), QString() );
-}
-
-QStringList KActivityConsumer::listActivities(KActivityInfo::State state) const
-{
- KACTIVITYCONSUMER_DBUS_RETURN(
- QStringList, KActivityManager::self()->ListActivities(state), QStringList() );
-}
-
-QStringList KActivityConsumer::listActivities() const
-{
- KACTIVITYCONSUMER_DBUS_RETURN(
- QStringList, KActivityManager::self()->ListActivities(), QStringList() );
-}
-
-QStringList KActivityConsumer::activitiesForResource(const KUrl & uri)
-{
- KACTIVITYCONSUMER_DBUS_RETURN(
- QStringList, KActivityManager::self()->ActivitiesForResource(uri.url()), QStringList() );
-}
-
-#undef KACTIVITYCONSUMER_DBUS_RETURN
-
-void KActivityConsumer::resourceAccessed(const KUrl & uri)
-{
- KActivityManager::self()->NotifyResourceAccessed(
- QCoreApplication::instance()->applicationName(),
- uri.url()
- );
-}
-
-void KActivityConsumer::resourceAccessed(WId wid, const KUrl & uri, ResourceAction action)
-{
- switch (action) {
- case Opened:
- KActivityManager::self()->NotifyResourceOpened(
- QCoreApplication::instance()->applicationName(),
- (quintptr)wid,
- uri.url()
- );
- break;
-
- case Modified:
- KActivityManager::self()->NotifyResourceModified(
- (quintptr)wid,
- uri.url()
- );
- break;
-
- case Closed:
- KActivityManager::self()->NotifyResourceClosed(
- (quintptr)wid,
- uri.url()
- );
- break;
- }
-}
-
-KActivityConsumer::ServiceStatus KActivityConsumer::serviceStatus()
-{
- if (!KActivityManager::isActivityServiceRunning()) {
- return NotRunning;
- }
-
- if (!KActivityManager::self()->IsBackstoreAvailable()) {
- return BareFunctionality;
- }
-
- return FullFunctionality;
-}
-
diff --git a/libs/kworkspace/kactivityconsumer.h b/libs/kworkspace/kactivityconsumer.h
deleted file mode 100644
index 901aac1..0000000
--- a/libs/kworkspace/kactivityconsumer.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (c) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License version 2 as published by the Free Software Foundation.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef ACTIVITY_CONSUMER_H
-#define ACTIVITY_CONSUMER_H
-
-#include <QObject>
-#include <QWidget>
-#include <QString>
-#include <KUrl>
-#include <QStringList>
-
-#include "kactivityinfo.h"
-#include <kdemacros.h>
-
-class KActivityConsumerPrivate;
-/**
- * Contextual information can be, from the user's point of view, divided
- * into three aspects - "who am I?", "where am I?" (what are my surroundings?)
- * and "what am I doing?".
- *
- * Activities deal with the last one - "what am I doing?". The current activity
- * refers to what the user is doing at the moment, while the other activities represent
- * things that he/she was doing before, and probably will be doing again.
- *
- * Activity is an abstract concept whose meaning can differ from one user to another.
- * Typical examples of activities are "developing a KDE project", "studying the
- * 19th century art", "composing music", "lazing on a Sunday afternoon" etc.
- *
- * Every activity can have applications, documents, or other types of resources
- * assigned to it.
- *
- * KActivityConsumer provides an entry-level API for supporting activities in an
- * application - to react to the changes to the current activity as well as
- * registering the resources with its windows.
- *
- * Resource can be anything that is identifiable by an URI (for example,
- * a local file or a web page)
- *
- * @since 4.5
- */
-class KDE_EXPORT KActivityConsumer: public QObject {
- Q_OBJECT
-
- Q_PROPERTY(QString currentActivity READ currentActivity)
- Q_PROPERTY(QStringList activities READ listActivities)
-
-public:
- /**
- * Enum holds different actions regarding accessing some resource
- */
- enum ResourceAction {
- Opened,
- Modified,
- Closed
- };
-
- /**
- * Different states of the activities service
- */
- enum ServiceStatus {
- NotRunning, ///< Service is not running
- BareFunctionality, ///< Service is running without nepomuk backend
- FullFunctionality ///< Service is running, and nepomuk is available
- };
-
- explicit KActivityConsumer(QObject * parent = 0);
-
- ~KActivityConsumer();
-
- /**
- * @returns the id of the current activity
- */
- QString currentActivity() const;
-
- /**
- * @returns the list of activities filtered by state
- * @param state state of the activity
- */
- QStringList listActivities(KActivityInfo::State state) const;
-
- /**
- * @returns the list of all existing activities
- */
- QStringList listActivities() const;
-
- /**
- * Returns the list of activities of a currently
- * registered resource. If back storage (Nepomuk)
- * doesn't exist, the result will contain only
- * the activities that were associated with the
- * specified resource in the current session.
- * @param uri uri of the resource
- */
- QStringList activitiesForResource(const KUrl & uri);
-
- /**
- * @returns status of the activities service
- */
- static ServiceStatus serviceStatus();
-
-Q_SIGNALS:
- /**
- * This signal is emitted when the global
- * activity is changed
- * @param id id of the new current activity
- */
- void currentActivityChanged(const QString & id);
-
- /**
- * This signal is emitted when the activity service
- * goes online or offline
- * @param status new status of the service
- */
- void serviceStatusChanged(KActivityConsumer::ServiceStatus status);
-
-public Q_SLOTS:
- /**
- * Should be called when the client application accesses an URI which
- * is important to remember, but it doesn't want to register open,
- * modify and close events for it.
- * @param uri uri of the resource
- */
- void resourceAccessed(const KUrl & uri);
-
- /**
- * Should be called when the client application opens, modifies or
- * closes a resource.
- * @param wid ID of the window that accesses the resource
- * @param uri uri of the resource
- * @param action is the resource being opened, modified or closed
- * @note You need to call this method with action == Opened before
- * calling it with any other action
- * @note When the window that has registered any resources is destroyed,
- * it will automatically call this method with action == Closed
- * for all opened resources
- */
- void resourceAccessed(WId wid, const KUrl & uri, ResourceAction action);
-
-private:
- KActivityConsumerPrivate * const d;
-};
-
-#endif // ACTIVITY_CONSUMER_H
diff --git a/libs/kworkspace/kactivityconsumer_p.h b/libs/kworkspace/kactivityconsumer_p.h
deleted file mode 100644
index 3e78120..0000000
--- a/libs/kworkspace/kactivityconsumer_p.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License version 2 as published by the Free Software Foundation.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef ACTIVITYCONSUMER_P_H
-#define ACTIVITYCONSUMER_P_H
-
-#include "activitymanager_interface.h"
-
-class KActivityConsumerPrivate {
-};
-
-#endif // ACTIVITY_CONSUMER_H
diff --git a/libs/kworkspace/kactivitycontroller.cpp b/libs/kworkspace/kactivitycontroller.cpp
deleted file mode 100644
index 5501921..0000000
--- a/libs/kworkspace/kactivitycontroller.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License version 2 as published by the Free Software Foundation.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "kactivitycontroller.h"
-#include "kactivityconsumer_p.h"
-#include "kactivitymanager_p.h"
-
-#include <QObject>
-#include <KDebug>
-
-class KActivityController::Private: public QObject {
-public:
- Private(KActivityController * parent)
- : q(parent)
- {
- }
-
-public Q_SLOTS:
- void resourceAccessed(const QString & application, const QString & uri) {
- q->resourceAccessed(application, uri);
- }
-
- void resourceOpened(const QString & application, uint wid, const QString & uri) {
- q->resourceAccessed(application, wid, uri, KActivityController::Opened);
- }
-
- void resourceModified(uint wid, const QString & uri) {
- q->resourceAccessed(QString(), wid, uri, KActivityController::Modified);
- }
-
- void resourceClosed(uint wid, const QString & uri) {
- q->resourceAccessed(QString(), wid, uri, KActivityController::Closed);
- }
-
-private:
- KActivityController * const q;
-};
-
-KActivityController::KActivityController(QObject * parent)
- : KActivityConsumer(parent), d(new Private(this))
-{
- connect(KActivityManager::self(), SIGNAL(ActivityAdded(QString)),
- this, SIGNAL(activityAdded(QString)));
-
- connect(KActivityManager::self(), SIGNAL(ActivityRemoved(QString)),
- this, SIGNAL(activityRemoved(QString)));
-
- connect(KActivityManager::self(), SIGNAL(ResourceAccessed(QString,QString)),
- this, SLOT(resourceAccessed(QString,QString)));
-
- connect(KActivityManager::self(), SIGNAL(ResourceOpened(QString,uint,QString)),
- this, SLOT(resourceOpened(QString,uint,QString)));
-
- connect(KActivityManager::self(), SIGNAL(ResourceModified(uint,QString)),
- this, SLOT(resourceModified(uint,QString)));
-
- connect(KActivityManager::self(), SIGNAL(ResourceClosed(uint,QString)),
- this, SLOT(resourceClosed(uint,QString)));
-}
-
-KActivityController::~KActivityController()
-{
- delete d;
-}
-
-void KActivityController::setActivityName(const QString & id, const QString & name)
-{
- KActivityManager::self()->SetActivityName(id, name);
-}
-
-void KActivityController::setActivityIcon(const QString & id, const QString & icon)
-{
- KActivityManager::self()->SetActivityIcon(id, icon);
-}
-
-bool KActivityController::setCurrentActivity(const QString & id)
-{
- return KActivityManager::self()->SetCurrentActivity(id);
-}
-
-QString KActivityController::addActivity(const QString & name)
-{
- return KActivityManager::self()->AddActivity(name);
-}
-
-void KActivityController::removeActivity(const QString & id)
-{
- KActivityManager::self()->RemoveActivity(id);
-}
-
-void KActivityController::stopActivity(const QString & id)
-{
- KActivityManager::self()->StopActivity(id);
-}
-
-void KActivityController::startActivity(const QString & id)
-{
- KActivityManager::self()->StartActivity(id);
-}
-
-#include "kactivitycontroller.moc"
diff --git a/libs/kworkspace/kactivitycontroller.h b/libs/kworkspace/kactivitycontroller.h
deleted file mode 100644
index 3a02825..0000000
--- a/libs/kworkspace/kactivitycontroller.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (c) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License version 2 as published by the Free Software Foundation.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef ACTIVITY_CONTROLLER_H
-#define ACTIVITY_CONTROLLER_H
-
-#include <QObject>
-#include <QWidget>
-#include <QString>
-#include <QStringList>
-
-#include <KUrl>
-
-#include <kworkspace/kactivityconsumer.h>
-
-#include <kdemacros.h>
-
-/**
- * This class provides methods for controlling and managing
- * the activities.
- *
- * @see KActivityConsumer for info about activities
- *
- * @since 4.5
- */
-class KDE_EXPORT KActivityController: public KActivityConsumer
-{
- Q_OBJECT
-
- Q_PROPERTY(QString currentActivity READ currentActivity WRITE setCurrentActivity)
-
-public:
- explicit KActivityController(QObject * parent = 0);
-
- ~KActivityController();
-
- /**
- * Sets the name of the specified activity
- * @param id id of the activity
- * @param name name to be set
- */
- void setActivityName(const QString & id, const QString & name);
-
- /**
- * Sets the icon of the specified activity
- * @param id id of the activity
- * @param icon icon to be set - freedesktop.org name or file path
- */
- void setActivityIcon(const QString & id, const QString & icon);
-
- /**
- * Sets the current activity
- * @param id id of the activity to make current
- * @returns true if successful
- */
- bool setCurrentActivity(const QString & id);
-
- /**
- * Adds a new activity
- * @param name name of the activity
- * @returns id of the newly created activity
- */
- QString addActivity(const QString & name);
-
- /**
- * Removes the specified activity
- * @param id id of the activity to delete
- */
- void removeActivity(const QString & id);
-
- /**
- * Stops the activity
- * @param id id of the activity to stop
- */
- void stopActivity(const QString & id);
-
- /**
- * Starts the activity
- * @param id id of the activity to start
- */
- void startActivity(const QString & id);
-
-Q_SIGNALS:
- /**
- * This signal is emitted when the global
- * activity is changed
- * @param id id of the new current activity
- */
- void activityAdded(const QString & id);
-
- /**
- * This signal is emitted when the activity
- * is removed
- * @param id id of the removed activity
- */
- void activityRemoved(const QString & id);
-
- /**
- * Emitted when the client application accesses
- * the file but is not interested in registering more advanced
- * events like open/modify/close.
- * @param application unformatted name of the application
- * @param uri uri of the resource
- */
- void resourceAccessed(const QString & application, const KUrl & uri);
-
- /**
- * Emitted when the client application
- * opens a new resource identifiable by an uri.
- * @param application unformatted name of the application
- * @param windowId ID of the window that registers the resource
- * @param uri uri of the resource
- * @param action performed action
- *
- * @note application parameter is only specified on action == Opened
- */
- void resourceAccessed(const QString & application, uint windowId, const KUrl & uri, ResourceAction action);
-
-private:
- class Private;
- Private * const d;
-
- Q_PRIVATE_SLOT(d, void resourceAccessed(const QString &, const QString &))
- Q_PRIVATE_SLOT(d, void resourceOpened(const QString &, uint, const QString &))
- Q_PRIVATE_SLOT(d, void resourceModified(uint, const QString &))
- Q_PRIVATE_SLOT(d, void resourceClosed(uint, const QString &))
-};
-
-#endif // ACTIVITY_CONTROLLER_H
diff --git a/libs/kworkspace/kactivityinfo.cpp b/libs/kworkspace/kactivityinfo.cpp
deleted file mode 100644
index 2b3c2fb..0000000
--- a/libs/kworkspace/kactivityinfo.cpp
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (c) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License version 2 as published by the Free Software Foundation.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include <KDebug>
-
-#include "kactivityinfo.h"
-#include "kactivityinfo_p.h"
-#include "kactivitymanager_p.h"
-
-#ifdef HAVE_SOPRANO_PLUGIN_RAPTORPARSER
-#include "nfo.h"
-#include "nco.h"
-#include "pimo.h"
-#endif
-
-// Private
-
-KActivityInfo::Private::Private(KActivityInfo *info, const QString &activityId)
- : q(info),
- state(KActivityInfo::Invalid),
- id(activityId)
-{
- KActivityManager::self();
-}
-
-KUrl KActivityInfo::Private::urlForType(KActivityInfo::ResourceType resourceType) const
-{
- switch (resourceType) {
-#ifdef HAVE_SOPRANO_PLUGIN_RAPTORPARSER
- case KActivityInfo::DocumentResource:
- return Ontologies::nfo::Document();
-
- case KActivityInfo::FolderResource:
- return Ontologies::nfo::Folder();
-
- case KActivityInfo::ApplicationResource:
- return Ontologies::nfo::Application();
-
- case KActivityInfo::ContactResource:
- return Ontologies::nco::Contact();
-
- case KActivityInfo::LocationResource:
- return Ontologies::pimo::Location();
-#endif
- default:
- return KUrl(QString());
- }
-}
-
-#define IMPLEMENT_SIGNAL_HANDLER(ORIGINAL,INTERNAL) \
- void KActivityInfo::Private::INTERNAL(const QString & _id) const \
- { \
- if (id == _id) emit q->INTERNAL(); \
- }
-
-IMPLEMENT_SIGNAL_HANDLER(ActivityAdded,added)
-IMPLEMENT_SIGNAL_HANDLER(ActivityRemoved,removed)
-IMPLEMENT_SIGNAL_HANDLER(ActivityStarted,started)
-IMPLEMENT_SIGNAL_HANDLER(ActivityStopped,stopped)
-IMPLEMENT_SIGNAL_HANDLER(ActivityChanged,infoChanged)
-
-#undef IMPLEMENT_SIGNAL_HANDLER
-
-void KActivityInfo::Private::activityStateChanged(const QString & idChanged, int newState)
-{
- if (idChanged == id) {
- state = static_cast<KActivityInfo::State>(newState);
- emit q->stateChanged(state);
- }
-}
-
-// KActivityInfo
-KActivityInfo::KActivityInfo(const QString &activityId, QObject *parent)
- : QObject(parent),
- d(new Private(this, activityId))
-{
- d->id = activityId;
- connect(KActivityManager::self(), SIGNAL(ActivityStateChanged(QString,int)),
- this, SLOT(activityStateChanged(QString,int)));
-
- connect(KActivityManager::self(), SIGNAL(ActivityChanged(QString)),
- this, SLOT(infoChanged(QString)));
-
- connect(KActivityManager::self(), SIGNAL(ActivityAdded(QString)),
- this, SLOT(added(QString)));
-
- connect(KActivityManager::self(), SIGNAL(ActivityRemoved(QString)),
- this, SLOT(removed(QString)));
-
- connect(KActivityManager::self(), SIGNAL(ActivityStarted(QString)),
- this, SLOT(started(QString)));
-
- connect(KActivityManager::self(), SIGNAL(ActivityStopped(QString)),
- this, SLOT(stopped(QString)));
-}
-
-KActivityInfo::~KActivityInfo()
-{
- delete d;
-}
-
-bool KActivityInfo::isValid() const
-{
- return (state() != Invalid);
-}
-
-void KActivityInfo::associateResource(const KUrl & resource, ResourceType resourceType)
-{
- associateResource(resource, d->urlForType(resourceType));
-}
-
-void KActivityInfo::associateResource(const KUrl & resource, const KUrl & resourceType)
-{
- // TODO:
- // Private::s_store
- // ->associateResource(d->id, resource.url(), resourceType.url());
-}
-
-void KActivityInfo::disassociateResource(const KUrl & resource)
-{
- // TODO:
- // Private::s_store
- // ->disassociateResource(d->id, resource.url());
-}
-
-QList < KUrl > KActivityInfo::associatedResources(ResourceType resourceType) const
-{
- return associatedResources(d->urlForType(resourceType));
-}
-
-QList < KUrl > KActivityInfo::associatedResources(const KUrl & resourceType) const
-{
- QList < KUrl > result;
-
- // TODO:
- // QDBusReply < QStringList > reply = Private::s_store
- // ->associatedResources(d->id, resourceType.url());
-
- // if (reply.isValid()) {
- // QStringList associatedResources = reply.value();
-
- // foreach (const QString & uri, associatedResources) {
- // result << KUrl(uri);
- // }
- // }
-
- return result;
-}
-
-// macro defines a shorthand for validating and returning a d-bus result
-// @param REPLY_TYPE type of the d-bus result
-// @param CAST_TYPE type to which to cast the result
-// @param METHOD invocation of the d-bus method
-#define KACTIVITYINFO_DBUS_CAST_RETURN(REPLY_TYPE, CAST_TYPE, METHOD) \
- QDBusReply < REPLY_TYPE > dbusReply = METHOD; \
- if (dbusReply.isValid()) { \
- return (CAST_TYPE)(dbusReply.value()); \
- } else { \
- return CAST_TYPE(); \
- }
-
-
-KUrl KActivityInfo::uri() const
-{
- // TODO:
- return KUrl();
- // KACTIVITYINFO_DBUS_CAST_RETURN(
- // QString, KUrl, Private::s_store->uri(d->id));
-}
-
-KUrl KActivityInfo::resourceUri() const
-{
- // TODO:
- return KUrl();
- // KACTIVITYINFO_DBUS_CAST_RETURN(
- // QString, KUrl, Private::s_store->resourceUri(d->id));
-}
-
-QString KActivityInfo::id() const
-{
- return d->id;
-}
-
-QString KActivityInfo::name() const
-{
- KACTIVITYINFO_DBUS_CAST_RETURN(
- QString, QString, KActivityManager::self()->ActivityName(d->id));
-}
-
-QString KActivityInfo::icon() const
-{
- KACTIVITYINFO_DBUS_CAST_RETURN(
- QString, QString, KActivityManager::self()->ActivityIcon(d->id));
-}
-
-KActivityInfo::State KActivityInfo::state() const
-{
- if (d->state == Invalid) {
- QDBusReply < int > dbusReply = KActivityManager::self()->ActivityState(d->id);
-
- if (dbusReply.isValid()) {
- d->state = (State)(dbusReply.value());
- }
- }
-
- return d->state;
-}
-
-QString KActivityInfo::name(const QString & id)
-{
- KACTIVITYINFO_DBUS_CAST_RETURN(
- QString, QString, KActivityManager::self()->ActivityName(id));
-}
-
-#undef KACTIVITYINFO_DBUS_CAST_RETURN
-
-KActivityInfo::Availability KActivityInfo::availability() const
-{
- Availability result = Nothing;
-
- if (!KActivityManager::isActivityServiceRunning()) {
- return result;
- }
-
- if (KActivityManager::self()->ListActivities().value().contains(d->id)) {
- result = BasicInfo;
-
- if (KActivityManager::self()->IsBackstoreAvailable()) {
- result = Everything;
- }
- }
-
- return result;
-}
-
-#include "kactivityinfo.moc"
-
diff --git a/libs/kworkspace/kactivityinfo.h b/libs/kworkspace/kactivityinfo.h
deleted file mode 100644
index 3e271de..0000000
--- a/libs/kworkspace/kactivityinfo.h
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright (c) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License version 2 as published by the Free Software Foundation.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef ACTIVITY_INFO_H
-#define ACTIVITY_INFO_H
-
-#include <QObject>
-#include <QWidget>
-#include <QString>
-#include <QStringList>
-
-#include <KUrl>
-#include <kdemacros.h>
-
-/**
- * This class provides info about an activity. Most methods in it
- * require a Nepomuk backend running.
- *
- * @see KActivityConsumer for info about activities
- *
- * @since 4.5
- */
-class KDE_EXPORT KActivityInfo: public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(KUrl uri READ uri)
- Q_PROPERTY(KUrl resourceUri READ resourceUri)
- Q_PROPERTY(QString id READ id)
- Q_PROPERTY(QString name READ name)
-
-public:
- explicit KActivityInfo(const QString & activityId, QObject *parent=0);
- ~KActivityInfo();
-
- /**
- * @return true if the activity represented by this object exists and is valid
- */
- bool isValid() const;
-
- /**
- * Set of predefined resource types provided for convenience
- */
- enum ResourceType {
- UnspecifiedResource = 0,
- DocumentResource = 1, ///< @see nfo:Document
- FolderResource = 2, ///< @see nfo:Folder
- ApplicationResource = 3, ///< @see nfo:Application
- ContactResource = 4, ///< @see nco:Contact
- LocationResource = 5 ///< @see pimo:Location
-
- };
-
- /**
- * Specifies which parts of this class are functional
- */
- enum Availability {
- Nothing = 0, ///< No activity info provided (isValid is false)
- BasicInfo = 1, ///< Basic info is provided
- Everything = 2 ///< Everything is available
- };
-
- /**
- * State of the activity
- */
- enum State {
- Invalid = 0,
- Running = 2,
- Starting = 3,
- Stopped = 4,
- Stopping = 5
- };
-
- /**
- * @returns what info is provided by this instance of KActivityInfo
- */
- Availability availability() const;
-
- /**
- * Associates the resource with the activity represented by this
- * KActivityInfo object.
- * @param resourceUrl url of the resource
- * @param resourceType type of the resource
- * @note Functional only when availability is Everything
- */
- void associateResource(const KUrl & resourceUrl, ResourceType resourceType = UnspecifiedResource);
-
- /**
- * Associates the resource with the activity represented by this
- * KActivityInfo object.
- * @param resourceUrl url of the resource
- * @param resourceType type of the resource
- * @note Functional only when availability is Everything
- */
- void associateResource(const KUrl & resourceUrl, const KUrl & resourceType);
-
- /**
- * Removes the association of this activity and the specified
- * resource.
- * @param resourceUrl url of the resource
- * @note Functional only when availability is Everything
- */
- void disassociateResource(const KUrl & resourceUrl);
-
- /**
- * @param resourceType type of the resource
- * @returns a list of resources of the specified type that are
- * associated with this activity. If the type is not specified,
- * all associated resources are returned,
- * @note Functional only when availability is Everything
- */
- QList < KUrl > associatedResources(ResourceType resourceType = UnspecifiedResource) const;
-
- /**
- * @param resourceType type of the resource
- * @returns a list of resources of the specified type that are
- * associated with this activity. If the type is not specified,
- * all associated resources are returned,
- * @note Functional only when availability is Everything
- */
- QList < KUrl > associatedResources(const KUrl & resourceType) const;
-
- /**
- * @returns the URI of this activity. The same URI is used by
- * activities KIO slave.
- * @note Functional only when availability is Everything
- */
- KUrl uri() const;
-
- /**
- * @returns the Nepomuk resource URI of this activity
- * @note Functional only when availability is Everything
- */
- KUrl resourceUri() const;
-
- /**
- * @returns the id of the activity
- */
- QString id() const;
-
- /**
- * @returns the name of the activity
- * @note Functional when availability is BasicInfo or Everything
- */
- QString name() const;
-
- /**
- * @returns the icon of the activity. Icon can be a
- * freedesktop.org name or a file path. Or empty if
- * no icon is set.
- * @note Functional only when availability is Everything
- */
- QString icon() const;
-
- /**
- * @returns the state of the activity
- */
- State state() const;
-
- /**
- * This function is provided for convenience.
- * @returns the name of the specified activity
- * @param id id of the activity
- */
- static QString name(const QString & id);
-
-Q_SIGNALS:
- /**
- * Emitted when the activity's name, icon or description is changed
- */
- void infoChanged();
-
- /**
- * Emitted when the activity is added
- */
- void added();
-
- /**
- * Emitted when the activity is removed
- */
- void removed();
-
- /**
- * Emitted when the activity is started
- */
- void started();
-
- /**
- * Emitted when the activity is stopped
- */
- void stopped();
-
- /**
- * Emitted when the activity changes state
- * @param state new state of the activity
- */
- void stateChanged(KActivityInfo::State state);
-
-private:
- class Private;
- Private * const d;
-
- Q_PRIVATE_SLOT(d, void activityStateChanged(const QString &, int))
- Q_PRIVATE_SLOT(d, void added(const QString &))
- Q_PRIVATE_SLOT(d, void removed(const QString &))
- Q_PRIVATE_SLOT(d, void started(const QString &))
- Q_PRIVATE_SLOT(d, void stopped(const QString &))
- Q_PRIVATE_SLOT(d, void infoChanged(const QString &))
-};
-
-#endif // ACTIVITY_INFO_H
diff --git a/libs/kworkspace/kactivityinfo_p.h b/libs/kworkspace/kactivityinfo_p.h
deleted file mode 100644
index 79f675b..0000000
--- a/libs/kworkspace/kactivityinfo_p.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License version 2 as published by the Free Software Foundation.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef ACTIVITY_INFO_PH
-#define ACTIVITY_INFO_PH
-
-#include "activitymanager_interface.h"
-#include "kactivityinfo.h"
-
-class KActivityInfo::Private {
-public:
- Private(KActivityInfo *info, const QString &activityId);
-
- KUrl urlForType(KActivityInfo::ResourceType resourceType) const;
- void activityStateChanged(const QString &, int);
-
- void added(const QString &) const;
- void removed(const QString &) const;
- void started(const QString &) const;
- void stopped(const QString &) const;
- void infoChanged(const QString &) const;
-
- KActivityInfo *q;
- KActivityInfo::State state;
- QString id;
-};
-
-#endif // ACTIVITY_INFO_PH
diff --git a/libs/kworkspace/kactivitymanager_p.cpp b/libs/kworkspace/kactivitymanager_p.cpp
deleted file mode 100644
index 893f066..0000000
--- a/libs/kworkspace/kactivitymanager_p.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
- *
- * 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 "kactivitymanager_p.h"
-
-#include <QDBusConnection>
-
-#include <KToolInvocation>
-#include <KDebug>
-
-KActivityManager * KActivityManager::s_instance = NULL;
-
-// #define ACTIVITY_MANAGER_DBUS_PATH "org.kde.ActivityManager"
-#define ACTIVITY_MANAGER_DBUS_PATH "org.kde.kactivitymanagerd"
-#define ACTIVITY_MANAGER_DBUS_OBJECT "/ActivityManager"
-
-KActivityManager::KActivityManager()
- : org::kde::ActivityManager(
- ACTIVITY_MANAGER_DBUS_PATH,
- ACTIVITY_MANAGER_DBUS_OBJECT,
- QDBusConnection::sessionBus()
- )
-{
- connect(&m_watcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)),
- this, SLOT(serviceOwnerChanged(QString,QString,QString)));
-}
-
-KActivityManager * KActivityManager::self()
-{
- if (!s_instance) {
- // check if the activity manager is already running
- if (!isActivityServiceRunning()) {
-
- // not running, trying to launch it
- QString error;
-
- int ret = KToolInvocation::startServiceByDesktopPath("kactivitymanagerd.desktop", QStringList(), &error);
- if (ret > 0) {
- kDebug() << "Activity: Couldn't start kactivitymanagerd: " << error << endl;
- }
-
- if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(ACTIVITY_MANAGER_DBUS_PATH)) {
- kDebug() << "Activity: The kactivitymanagerd service is still not registered";
- } else {
- kDebug() << "Activity: The kactivitymanagerd service has been registered";
- }
- }
-
- // creating a new instance of the class
- s_instance = new KActivityManager();
- }
-
- return s_instance;
-}
-
-bool KActivityManager::isActivityServiceRunning()
-{
- return QDBusConnection::sessionBus().interface()->isServiceRegistered(ACTIVITY_MANAGER_DBUS_PATH);
-}
-
-void KActivityManager::serviceOwnerChanged(const QString & serviceName, const QString & oldOwner, const QString & newOwner)
-{
- if (serviceName == ACTIVITY_MANAGER_DBUS_PATH) {
- emit presenceChanged(!newOwner.isEmpty());
- }
-}
-
diff --git a/libs/kworkspace/kactivitymanager_p.h b/libs/kworkspace/kactivitymanager_p.h
deleted file mode 100644
index 8c24ae7..0000000
--- a/libs/kworkspace/kactivitymanager_p.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
- *
- * 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 ACTIVITY_MANAGER_P_
-#define ACTIVITY_MANAGER_P_
-
-#include "activitymanager_interface.h"
-
-#include <QDBusServiceWatcher>
-
-class KActivityManager: public org::kde::ActivityManager {
- Q_OBJECT
-public:
- static KActivityManager * self();
-
- static bool isActivityServiceRunning();
-
-public Q_SLOTS:
- void serviceOwnerChanged(const QString & serviceName, const QString & oldOwner, const QString & newOwner);
-
-Q_SIGNALS:
- void presenceChanged(bool present);
-
-private:
- KActivityManager();
-
- QDBusServiceWatcher m_watcher;
-
- static KActivityManager * s_instance;
-};
-
-
-#endif // ACTIVITY_MANAGER_P_