Merge lp:~yofel/kubuntu-packaging/kde-runtime-active-4.7 into lp:~kubuntu-packagers/kubuntu-packaging/kde-runtime

Proposed by Philip Muškovac
Status: Merged
Merged at revision: 223
Proposed branch: lp:~yofel/kubuntu-packaging/kde-runtime-active-4.7
Merge into: lp:~kubuntu-packagers/kubuntu-packaging/kde-runtime
Diff against target: 6168 lines (+6094/-0)
10 files modified
debian/changelog (+7/-0)
debian/kde-runtime-data.install (+4/-0)
debian/kde-runtime.install (+3/-0)
debian/patches/kubuntu_mobile_crash-move-after-first-call-to-applet.diff (+54/-0)
debian/patches/kubuntu_mobile_insert-a-catalog-named-as-the-plugin-name.diff (+38/-0)
debian/patches/kubuntu_mobile_ported-the-new-activity-manager.diff (+2237/-0)
debian/patches/kubuntu_mobile_ported-the-new-plugin-system-to-active-development-4.diff (+3622/-0)
debian/patches/kubuntu_mobile_registering-events-for-activity-switching.diff (+97/-0)
debian/patches/kubuntu_mobile_wrong-cr-info.diff (+26/-0)
debian/patches/series (+6/-0)
To merge this branch: bzr merge lp:~yofel/kubuntu-packaging/kde-runtime-active-4.7
Reviewer Review Type Date Requested Status
Michał Zając Approve
Review via email: mp+71557@code.launchpad.net

Description of the change

2nd batch of the mobile patches from rbelem.

To post a comment you must log in.
Revision history for this message
Michał Zając (quintasan) wrote :

Hey, the patches are missing!

224. By Philip Muškovac

Actually add the patches

Revision history for this message
Michał Zając (quintasan) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2011-07-27 17:40:54 +0000
+++ debian/changelog 2011-08-18 09:25:23 +0000
@@ -1,3 +1,10 @@
1kde-runtime (4:4.7.0a-0ubuntu2) UNRELEASED; urgency=low
2
3 * Added plasma-active patches
4 * Added activitymanager files to install files
5
6 -- Rodrigo Belem <rclbelem@gmail.com> Sun, 07 Aug 2011 09:50:51 -0400
7
1kde-runtime (4:4.7.0a-0ubuntu1) oneiric; urgency=low8kde-runtime (4:4.7.0a-0ubuntu1) oneiric; urgency=low
29
3 [ Romain Perier ]10 [ Romain Perier ]
411
=== modified file 'debian/kde-runtime-data.install'
--- debian/kde-runtime-data.install 2011-06-25 20:12:29 +0000
+++ debian/kde-runtime-data.install 2011-08-18 09:25:23 +0000
@@ -449,6 +449,9 @@
449usr/share/kde4/config/kshorturifilterrc449usr/share/kde4/config/kshorturifilterrc
450usr/share/kde4/config.kcfg/jpegcreatorsettings.kcfg450usr/share/kde4/config.kcfg/jpegcreatorsettings.kcfg
451usr/share/kde4/services/about.protocol451usr/share/kde4/services/about.protocol
452usr/share/kde4/services/activitymanager-plugin-dummy.desktop
453usr/share/kde4/services/activitymanager-plugin-nepomuk.desktop
454usr/share/kde4/services/activitymanager-plugin-slc.desktop
452usr/share/kde4/services/applications.protocol455usr/share/kde4/services/applications.protocol
453usr/share/kde4/services/ar.protocol456usr/share/kde4/services/ar.protocol
454usr/share/kde4/services/bookmarks.protocol457usr/share/kde4/services/bookmarks.protocol
@@ -668,6 +671,7 @@
668usr/share/kde4/services/windowsimagethumbnail.desktop671usr/share/kde4/services/windowsimagethumbnail.desktop
669usr/share/kde4/services/xz.protocol672usr/share/kde4/services/xz.protocol
670usr/share/kde4/services/zip.protocol673usr/share/kde4/services/zip.protocol
674usr/share/kde4/servicetypes/activitymanager-plugin.desktop
671usr/share/kde4/servicetypes/knotifynotifymethod.desktop675usr/share/kde4/servicetypes/knotifynotifymethod.desktop
672usr/share/kde4/servicetypes/nepomukservice.desktop676usr/share/kde4/servicetypes/nepomukservice.desktop
673usr/share/kde4/servicetypes/phononbackend.desktop677usr/share/kde4/servicetypes/phononbackend.desktop
674678
=== modified file 'debian/kde-runtime.install'
--- debian/kde-runtime.install 2011-06-25 20:12:29 +0000
+++ debian/kde-runtime.install 2011-08-18 09:25:23 +0000
@@ -35,6 +35,9 @@
35usr/lib/attica_kde.so35usr/lib/attica_kde.so
36usr/lib/kconf_update_bin/phonon_devicepreference_update36usr/lib/kconf_update_bin/phonon_devicepreference_update
37usr/lib/kconf_update_bin/phonon_deviceuids_update37usr/lib/kconf_update_bin/phonon_deviceuids_update
38usr/lib/kde4/activitymanager_plugin_dummy.so
39usr/lib/kde4/activitymanager_plugin_nepomuk.so
40usr/lib/kde4/activitymanager_plugin_slc.so
38usr/lib/kde4/comicbookthumbnail.so41usr/lib/kde4/comicbookthumbnail.so
39usr/lib/kde4/cursorthumbnail.so42usr/lib/kde4/cursorthumbnail.so
40usr/lib/kde4/djvuthumbnail.so43usr/lib/kde4/djvuthumbnail.so
4144
=== added file 'debian/patches/kubuntu_mobile_crash-move-after-first-call-to-applet.diff'
--- debian/patches/kubuntu_mobile_crash-move-after-first-call-to-applet.diff 1970-01-01 00:00:00 +0000
+++ debian/patches/kubuntu_mobile_crash-move-after-first-call-to-applet.diff 2011-08-18 09:25:23 +0000
@@ -0,0 +1,54 @@
1From 6568d05788b8f019b12c33a195b70489c5ea29ed Mon Sep 17 00:00:00 2001
2From: Marco Martin <notmart@gmail.com>
3Date: Mon, 11 Jul 2011 22:44:05 +0200
4Subject: [PATCH 3/6] crash-- move after first call to applet()
5
6---
7 .../plasmoid/declarativeappletscript.cpp | 2 +-
8 .../javascript/plasmoid/simplejavascriptapplet.cpp | 3 +--
9 2 files changed, 2 insertions(+), 3 deletions(-)
10
11diff --git a/plasma/scriptengines/javascript/plasmoid/declarativeappletscript.cpp b/plasma/scriptengines/javascript/plasmoid/declarativeappletscript.cpp
12index 5bd0b98..6f5cc95 100644
13--- a/plasma/scriptengines/javascript/plasmoid/declarativeappletscript.cpp
14+++ b/plasma/scriptengines/javascript/plasmoid/declarativeappletscript.cpp
15@@ -70,7 +70,6 @@ DeclarativeAppletScript::DeclarativeAppletScript(QObject *parent, const QVariant
16 m_env(0),
17 m_auth(this)
18 {
19- KGlobal::locale()->insertCatalog(description().pluginName());
20 Q_UNUSED(args);
21 }
22
23@@ -82,6 +81,7 @@ bool DeclarativeAppletScript::init()
24 {
25 m_declarativeWidget = new Plasma::DeclarativeWidget(applet());
26 m_declarativeWidget->setInitializationDelayed(true);
27+ KGlobal::locale()->insertCatalog(description().pluginName());
28
29 //make possible to import extensions from the package
30 //FIXME: probably to be removed, would make possible to use native code from within the package :/
31diff --git a/plasma/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp b/plasma/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp
32index b0b13e5..dba71f2 100644
33--- a/plasma/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp
34+++ b/plasma/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp
35@@ -105,8 +105,6 @@ SimpleJavaScriptApplet::SimpleJavaScriptApplet(QObject *parent, const QVariantLi
36 Q_UNUSED(args);
37 // kDebug() << "Script applet launched, args" << applet()->startupArguments();
38
39- KGlobal::locale()->insertCatalog(description().pluginName());
40-
41 // TODO this will be set to the engine we get from QML
42 m_engine = new QScriptEngine(this);
43 m_env = new ScriptEnv(this, m_engine);
44@@ -311,6 +309,7 @@ bool SimpleJavaScriptApplet::init()
45 this, SLOT(extenderItemRestored(Plasma::ExtenderItem*)));
46 connect(applet(), SIGNAL(activate()),
47 this, SLOT(activate()));
48+ KGlobal::locale()->insertCatalog(description().pluginName());
49 setupObjects();
50
51 AppletAuthorization auth(this);
52--
531.7.5.4
54
055
=== added file 'debian/patches/kubuntu_mobile_insert-a-catalog-named-as-the-plugin-name.diff'
--- debian/patches/kubuntu_mobile_insert-a-catalog-named-as-the-plugin-name.diff 1970-01-01 00:00:00 +0000
+++ debian/patches/kubuntu_mobile_insert-a-catalog-named-as-the-plugin-name.diff 2011-08-18 09:25:23 +0000
@@ -0,0 +1,38 @@
1From 56b7574767ebaa1dcf667c663e1d98a2ee299a94 Mon Sep 17 00:00:00 2001
2From: Marco Martin <notmart@gmail.com>
3Date: Mon, 11 Jul 2011 21:23:32 +0200
4Subject: [PATCH 2/6] insert a catalog named as the plugin name
5
6---
7 .../plasmoid/declarativeappletscript.cpp | 1 +
8 .../javascript/plasmoid/simplejavascriptapplet.cpp | 2 ++
9 2 files changed, 3 insertions(+), 0 deletions(-)
10
11diff --git a/plasma/scriptengines/javascript/plasmoid/declarativeappletscript.cpp b/plasma/scriptengines/javascript/plasmoid/declarativeappletscript.cpp
12index 08d53fa..5bd0b98 100644
13--- a/plasma/scriptengines/javascript/plasmoid/declarativeappletscript.cpp
14+++ b/plasma/scriptengines/javascript/plasmoid/declarativeappletscript.cpp
15@@ -70,6 +70,7 @@ DeclarativeAppletScript::DeclarativeAppletScript(QObject *parent, const QVariant
16 m_env(0),
17 m_auth(this)
18 {
19+ KGlobal::locale()->insertCatalog(description().pluginName());
20 Q_UNUSED(args);
21 }
22
23diff --git a/plasma/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp b/plasma/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp
24index 0076cd8..b0b13e5 100644
25--- a/plasma/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp
26+++ b/plasma/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp
27@@ -105,6 +105,8 @@ SimpleJavaScriptApplet::SimpleJavaScriptApplet(QObject *parent, const QVariantLi
28 Q_UNUSED(args);
29 // kDebug() << "Script applet launched, args" << applet()->startupArguments();
30
31+ KGlobal::locale()->insertCatalog(description().pluginName());
32+
33 // TODO this will be set to the engine we get from QML
34 m_engine = new QScriptEngine(this);
35 m_env = new ScriptEnv(this, m_engine);
36--
371.7.5.4
38
039
=== added file 'debian/patches/kubuntu_mobile_ported-the-new-activity-manager.diff'
--- debian/patches/kubuntu_mobile_ported-the-new-activity-manager.diff 1970-01-01 00:00:00 +0000
+++ debian/patches/kubuntu_mobile_ported-the-new-activity-manager.diff 2011-08-18 09:25:23 +0000
@@ -0,0 +1,2237 @@
1From 7bbbc379de69eab6164a6c7a33670e231b734768 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Ivan=20=C4=8Cuki=C4=87?= <ivan.cukic@kde.org>
3Date: Fri, 8 Jul 2011 17:22:59 +0200
4Subject: [PATCH 1/6] Ported the new activity manager
5
6---
7 activitymanager/ActivityManager.cpp | 87 +++++---
8 activitymanager/ActivityManager.h | 83 ++-----
9 activitymanager/ActivityManager_p.h | 16 +-
10 activitymanager/CMakeLists.txt | 44 ++++-
11 activitymanager/Event.cpp | 6 +-
12 activitymanager/Event.h | 29 ++-
13 activitymanager/EventBackend.cpp | 12 +
14 activitymanager/EventBackend.h | 3 +-
15 activitymanager/EventProcessor.cpp | 26 ++-
16 activitymanager/EventProcessor.h | 4 +-
17 activitymanager/NepomukCommon.h | 63 ++++++
18 activitymanager/NepomukEventBackend.cpp | 235 ++++++++++++++------
19 activitymanager/NepomukResourceScoreCache.cpp | 214 ++++++++++++++++++
20 activitymanager/NepomukResourceScoreCache.h | 42 ++++
21 activitymanager/NepomukResourceScoreMaintainer.cpp | 145 ++++++++++++
22 activitymanager/NepomukResourceScoreMaintainer.h | 47 ++++
23 activitymanager/SharedInfo.cpp | 51 +++++
24 activitymanager/SharedInfo.h | 63 ++++++
25 activitymanager/SlcEventBackend.cpp | 127 +++++++++++
26 activitymanager/SlcEventBackend.h | 59 +++++
27 activitymanager/ZeitgeistEventBackend.cpp | 44 ++--
28 activitymanager/main.cpp | 2 -
29 activitymanager/ontologies/CMakeLists.txt | 8 +
30 activitymanager/ontologies/kamdrso.ontology.in | 8 +
31 activitymanager/ontologies/kamdrso.trig | 112 ++++++++++
32 activitymanager/org.kde.ActivityManager.SLC.xml | 15 ++
33 activitymanager/org.kde.ActivityManager.xml | 37 +---
34 activitymanager/queries.sparql | 43 ++++
35 activitymanager/scripts/delete-stats.sh | 4 +
36 nepomuk/ontologies/kext.trig | 41 +++-
37 30 files changed, 1413 insertions(+), 257 deletions(-)
38 create mode 100644 activitymanager/NepomukCommon.h
39 create mode 100644 activitymanager/NepomukResourceScoreCache.cpp
40 create mode 100644 activitymanager/NepomukResourceScoreCache.h
41 create mode 100644 activitymanager/NepomukResourceScoreMaintainer.cpp
42 create mode 100644 activitymanager/NepomukResourceScoreMaintainer.h
43 create mode 100644 activitymanager/SharedInfo.cpp
44 create mode 100644 activitymanager/SharedInfo.h
45 create mode 100644 activitymanager/SlcEventBackend.cpp
46 create mode 100644 activitymanager/SlcEventBackend.h
47 create mode 100644 activitymanager/ontologies/CMakeLists.txt
48 create mode 100644 activitymanager/ontologies/kamdrso.ontology.in
49 create mode 100644 activitymanager/ontologies/kamdrso.trig
50 create mode 100644 activitymanager/org.kde.ActivityManager.SLC.xml
51 create mode 100644 activitymanager/queries.sparql
52 create mode 100755 activitymanager/scripts/delete-stats.sh
53
54diff --git a/activitymanager/ActivityManager.cpp b/activitymanager/ActivityManager.cpp
55index ea95232..e821c92 100644
56--- a/activitymanager/ActivityManager.cpp
57+++ b/activitymanager/ActivityManager.cpp
58@@ -66,9 +66,14 @@ __inline int toInt(WId wid)
59
60 // Private
61
62-ActivityManagerPrivate::ActivityManagerPrivate(ActivityManager * parent)
63+ActivityManagerPrivate::ActivityManagerPrivate(ActivityManager * parent,
64+ QHash < WId, SharedInfo::WindowData > & _windows,
65+ QHash < KUrl, SharedInfo::ResourceData > & _resources
66+ )
67 : haveSessions(false),
68 config("activitymanagerrc"),
69+ windows(_windows),
70+ resources(_resources),
71 #ifdef HAVE_NEPOMUK
72 m_nepomukInitCalled(false),
73 #endif
74@@ -99,6 +104,8 @@ ActivityManagerPrivate::ActivityManagerPrivate(ActivityManager * parent)
75
76 connect(KWindowSystem::self(), SIGNAL(windowRemoved(WId)),
77 this, SLOT(windowClosed(WId)));
78+ connect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)),
79+ this, SLOT(activeWindowChanged(WId)));
80
81 //listen to ksmserver for starting/stopping
82 ksmserverInterface = new QDBusInterface("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
83@@ -126,15 +133,26 @@ ActivityManagerPrivate::~ActivityManagerPrivate()
84
85 void ActivityManagerPrivate::windowClosed(WId windowId)
86 {
87- if (!resourcesForWindow.contains(windowId)) {
88+ // kDebug() << "Window closed..." << windowId
89+ // << "one of ours?" << windows.contains(windowId);
90+
91+ if (!windows.contains(windowId)) {
92 return;
93 }
94
95- foreach(const KUrl & uri, resourcesForWindow[windowId]) {
96- q->NotifyResourceClosed(toInt(windowId), uri.url());
97+ foreach (const KUrl & uri, windows[windowId].resources) {
98+ q->RegisterResourceEvent(windows[windowId].application,
99+ toInt(windowId), uri.url(), Event::Closed, resources[uri].reason);
100 }
101 }
102
103+void ActivityManagerPrivate::activeWindowChanged(WId windowId)
104+{
105+ // kDebug() << "Window focussed..." << windowId
106+ // << "one of ours?" << windows.contains(windowId);
107+
108+}
109+
110 void ActivityManagerPrivate::setActivityState(const QString & id, ActivityManager::State state)
111 {
112 if (activities[id] == state) return;
113@@ -285,7 +303,9 @@ void ActivityManagerPrivate::backstoreAvailable()
114 // Main
115
116 ActivityManager::ActivityManager()
117- : d(new ActivityManagerPrivate(this))
118+ : d(new ActivityManagerPrivate(this,
119+ SharedInfo::self()->m_windows,
120+ SharedInfo::self()->m_resources))
121 {
122
123 QDBusConnection dbus = QDBusConnection::sessionBus();
124@@ -298,6 +318,8 @@ ActivityManager::ActivityManager()
125 // ensureCurrentActivityIsRunning();
126
127 KCrash::setFlags(KCrash::AutoRestart);
128+
129+ EventProcessor::self();
130 }
131
132 ActivityManager::~ActivityManager()
133@@ -656,49 +678,44 @@ void ActivityManager::SetActivityIcon(const QString & id, const QString & icon)
134
135
136 // Resource related mothods
137-
138-void ActivityManager::NotifyResourceAccessed(const QString & application, const QString & uri)
139+void ActivityManager::RegisterResourceEvent(const QString & application, uint _windowId,
140+ const QString & uri, uint event, uint reason)
141 {
142- EventProcessor::self()->addEvent(application, uri, Event::Accessed);
143-}
144+ if (event > Event::LastEventType || reason > Event::LastEventReason)
145+ return;
146
147-void ActivityManager::NotifyResourceClosed(uint _windowId, const QString & uri)
148-{
149- WId windowId = (WId)_windowId;
150- d->resourcesForWindow[windowId].remove(KUrl(uri));
151+ WId windowId = (WId) _windowId;
152
153- EventProcessor::self()->addEvent(d->applicationForWindow[windowId], uri, Event::Closed);
154+ kDebug() << "New event on the horizon" << application << _windowId << windowId << event << Event::Opened;
155+ if (event == Event::Opened) {
156
157- if (d->resourcesForWindow[windowId].size() == 0) {
158- d->resourcesForWindow.remove(windowId);
159- d->applicationForWindow.remove(windowId);
160- }
161-}
162+ KUrl kuri(uri);
163
164-void ActivityManager::NotifyResourceModified(uint windowId, const QString & uri)
165-{
166- EventProcessor::self()->addEvent(d->applicationForWindow[(WId)windowId], uri, Event::Modified);
167-}
168+ kDebug() << "Saving the open event for the window" << windowId;
169+
170+ d->windows[windowId].resources << kuri;
171+ d->resources[kuri].activities << CurrentActivity();
172+
173+ kDebug() << d->windows.keys();
174+
175+ } else if (event == Event::Closed) {
176+
177+ // TODO: Remove from d->resources if needed
178+ d->windows.remove(windowId);
179
180-void ActivityManager::NotifyResourceOpened(const QString & application, uint _windowId, const QString & uri)
181-{
182- WId windowId = (WId)_windowId;
183- if (!d->applicationForWindow.contains(windowId)) {
184- d->applicationForWindow[windowId] = application;
185 }
186
187- KUrl kuri(uri);
188- d->resourcesForWindow[windowId] << kuri;
189- d->activitiesForUrl[kuri] << CurrentActivity();
190+ EventProcessor::self()->addEvent(application, windowId,
191+ uri, (Event::Type) event, (Event::Reason) reason);
192
193- EventProcessor::self()->addEvent(application, uri, Event::Opened);
194 }
195
196-QStringList ActivityManager::ActivitiesForResource(const QString & uri) const
197+void ActivityManager::RegisterResourceMimeType(const QString & uri, const QString & mimetype)
198 {
199- return d->activitiesForUrl.value(uri).toList();
200-}
201+ KUrl kuri(uri);
202
203+ d->resources[kuri].mimetype = mimetype;
204+}
205
206 // static
207 ActivityManager * ActivityManager::self()
208diff --git a/activitymanager/ActivityManager.h b/activitymanager/ActivityManager.h
209index 6bc9ea5..79e66b4 100644
210--- a/activitymanager/ActivityManager.h
211+++ b/activitymanager/ActivityManager.h
212@@ -51,6 +51,18 @@ public:
213 };
214
215 /**
216+ * The event type
217+ */
218+ enum EventType {
219+ Accessed = 1,
220+ Opened = 2,
221+ Modified = 3,
222+ Closed = 4,
223+ FocussedIn = 5,
224+ FocussedOut = 6
225+ };
226+
227+ /**
228 * Creates new ActivityManager
229 */
230 ActivityManager();
231@@ -222,70 +234,25 @@ Q_SIGNALS:
232
233 // Resource related mothods
234 public Q_SLOTS:
235- /**
236- * Should be called when the client application accesses
237- * the file but is not interested in registering more advanced
238- * events like open/modify/close.
239- * @param application unformatted name of the application
240- * @param uri uri of the resource
241- */
242- void NotifyResourceAccessed(const QString & application, const QString & uri);
243-
244- /**
245- * Should be called when the client application
246- * opens a new resource identifiable by an uri.
247- * @param application unformatted name of the application
248- * @param windowId ID of the window that registers the resource
249- * @param uri uri of the resource
250- */
251- void NotifyResourceOpened(const QString & application, uint windowId, const QString & uri);
252-
253- /**
254- * Should be called when the client application
255- * modifies a resource already registered with NotifyResourceOpened
256- * @param windowId ID of the window that registers the resource
257- * @param uri uri of the resource
258- */
259- void NotifyResourceModified(uint windowId, const QString & uri);
260-
261- /**
262- * Should be called when the client application
263- * closes a resource previously registered with
264- * NotifyResourceOpened.
265- * @param ID of the window that unregisters the resource
266- * @param uri uri of the resource
267- */
268- void NotifyResourceClosed(uint windowId, const QString & uri);
269
270 /**
271- * @returns the list of activities that are associated with
272- * the specified resource
273- * @param uri uri of the resource
274+ * Registers a new event
275+ * @param application the name of application that sent the event. Ignored if the event is not of type Opened
276+ * @param windowId ID of the window that displays the resource. Ignored if the event is of type Accessed
277+ * @param uri URI of the resource on which the event happened
278+ * @param event type of the event
279+ * @param reason reason for opening the resource
280 */
281- QStringList ActivitiesForResource(const QString & uri) const;
282+ void RegisterResourceEvent(const QString & application, uint windowId, const QString & uri, uint event, uint reason);
283
284-Q_SIGNALS:
285 /**
286- * @see NotifyResourceAccessed
287+ * Registers resource's mimetype. If not manually specified, it will
288+ * be retrieved if needed from Nepomuk
289+ *
290+ * Note that this will be forgotten when the resource in question is closed.
291+ * @param uri URI of the resource
292 */
293- void ResourceAccessed(const QString & application, const QString & uri);
294-
295- /**
296- * @see NotifyResourceOpened
297- */
298- void ResourceOpened(const QString & application, uint windowId, const QString & uri);
299-
300- /**
301- * @see NotifyResourceModified
302- */
303- void ResourceModified(uint windowId, const QString & uri);
304-
305- /**
306- * @see NotifyResourceClosed
307- */
308- void ResourceClosed(uint windowId, const QString & uri);
309-
310-
311+ void RegisterResourceMimeType(const QString & uri, const QString & mimetype);
312
313 private:
314 friend class ActivityManagerPrivate;
315diff --git a/activitymanager/ActivityManager_p.h b/activitymanager/ActivityManager_p.h
316index 3d9ec39..f68cb18 100644
317--- a/activitymanager/ActivityManager_p.h
318+++ b/activitymanager/ActivityManager_p.h
319@@ -29,6 +29,8 @@
320 #include <KUrl>
321
322 #include "ActivityManager.h"
323+#include "Event.h"
324+#include "SharedInfo.h"
325 #include "config-features.h"
326
327 #ifdef HAVE_NEPOMUK
328@@ -46,7 +48,10 @@ class ActivityManagerPrivate: public QObject {
329 Q_OBJECT
330
331 public:
332- ActivityManagerPrivate(ActivityManager * parent);
333+ ActivityManagerPrivate(ActivityManager * parent,
334+ QHash < WId, SharedInfo::WindowData > & _windows,
335+ QHash < KUrl, SharedInfo::ResourceData > & _resources
336+ );
337 ~ActivityManagerPrivate();
338
339 void addRunningActivity(const QString & id);
340@@ -55,11 +60,6 @@ public:
341 void ensureCurrentActivityIsRunning();
342 bool setCurrentActivity(const QString & id);
343
344- // URIs and WIDs for open resources
345- QHash < WId, QSet < KUrl > > resourcesForWindow;
346- QHash < WId, QString > applicationForWindow;
347- QHash < KUrl, QSet < QString > > activitiesForUrl;
348-
349 void setActivityState(const QString & id, ActivityManager::State state);
350 QHash < QString, ActivityManager::State > activities;
351
352@@ -74,6 +74,9 @@ public:
353 QTimer configSyncTimer;
354 KConfig config;
355
356+ QHash < WId, SharedInfo::WindowData > & windows;
357+ QHash < KUrl, SharedInfo::ResourceData > & resources;
358+
359 public:
360 void initConifg();
361
362@@ -91,6 +94,7 @@ public Q_SLOTS:
363 void scheduleConfigSync();
364 void configSync();
365 void windowClosed(WId windowId);
366+ void activeWindowChanged(WId windowId);
367
368 void startCompleted();
369 void stopCompleted();
370diff --git a/activitymanager/CMakeLists.txt b/activitymanager/CMakeLists.txt
371index 23dddae..726fcce 100644
372--- a/activitymanager/CMakeLists.txt
373+++ b/activitymanager/CMakeLists.txt
374@@ -3,6 +3,7 @@ project(ActivityManager)
375 set (ADDITIONAL_LINK_LIBS)
376
377 add_subdirectory(kded)
378+add_subdirectory(ontologies)
379
380 # Checking for Nepomuk
381 macro_optional_find_package(Nepomuk)
382@@ -56,23 +57,58 @@ include_directories(
383 set(activity_manager_SRCS
384 ActivityManager.cpp
385 EventProcessor.cpp
386- ZeitgeistEventBackend.cpp
387- NepomukEventBackend.cpp
388 EventBackend.cpp
389 Event.cpp
390+ SharedInfo.cpp
391 main.cpp
392 )
393
394+set(activity_manager_backends_SRCS
395+ NepomukEventBackend.cpp
396+ NepomukResourceScoreMaintainer.cpp
397+ NepomukResourceScoreCache.cpp
398+ ZeitgeistEventBackend.cpp
399+ SlcEventBackend.cpp
400+ )
401+
402 qt4_add_dbus_adaptor(
403 activity_manager_SRCS org.kde.ActivityManager.xml
404 ActivityManager.h ActivityManager
405 )
406
407+qt4_add_dbus_adaptor(
408+ activity_manager_SRCS org.kde.ActivityManager.SLC.xml
409+ SlcEventBackend.h SlcEventBackend
410+ )
411+
412 if(Nepomuk_FOUND)
413- soprano_add_ontology(activity_manager_SRCS ${CMAKE_SOURCE_DIR}/nepomuk/ontologies/kext.trig "KExt" "Nepomuk::Vocabulary" "trig")
414+ soprano_add_ontology(activity_manager_SRCS
415+ ${CMAKE_SOURCE_DIR}/nepomuk/ontologies/kext.trig
416+ "KExt" "Nepomuk::Vocabulary" "trig"
417+ )
418+
419+ # soprano_add_ontology(activity_manager_SRCS
420+ # ${CMAKE_CURRENT_SOURCE_DIR}/ontologies/kamdrso.trig
421+ # "RSO" "Nepomuk::Vocabulary" "trig"
422+ # )
423+
424+ soprano_add_ontology(activity_manager_SRCS
425+ ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nie/nie.trig
426+ "NIE" "Nepomuk::Vocabulary" "trig"
427+ )
428+
429+ soprano_add_ontology(activity_manager_SRCS
430+ ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nepomuk/nao.trig
431+ "NAO" "Nepomuk::Vocabulary" "trig"
432+ )
433+
434+ soprano_add_ontology(activity_manager_SRCS
435+ ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nepomuk/nuao.trig
436+ "NUAO" "Nepomuk::Vocabulary" "trig"
437+ )
438 endif()
439
440-kde4_add_executable(activity-manager ${activity_manager_SRCS})
441+kde4_add_executable(activity-manager ${activity_manager_SRCS} ${activity_manager_backends_SRCS})
442
443 target_link_libraries(
444 activity-manager
445diff --git a/activitymanager/Event.cpp b/activitymanager/Event.cpp
446index ceabaf5..f8a964f 100644
447--- a/activitymanager/Event.cpp
448+++ b/activitymanager/Event.cpp
449@@ -19,8 +19,9 @@
450
451 #include "Event.h"
452
453-Event::Event(const QString & vApplication, const QString & vUri, Type vType, Reason vReason)
454- : application(vApplication), uri(vUri), type(vType), reason(vReason), timestamp(QDateTime::currentDateTime())
455+
456+Event::Event(const QString & vApplication, WId vWid, const QString & vUri, Type vType, Reason vReason)
457+ : application(vApplication), wid(vWid), uri(vUri), type(vType), reason(vReason), timestamp(QDateTime::currentDateTime())
458 {
459 }
460
461@@ -28,6 +29,7 @@ bool Event::operator == (const Event & other) const
462 {
463 return
464 application == other.application &&
465+ wid == other.wid &&
466 uri == other.uri &&
467 type == other.type &&
468 reason == other.reason;
469diff --git a/activitymanager/Event.h b/activitymanager/Event.h
470index 5a05b7a..19b8187 100644
471--- a/activitymanager/Event.h
472+++ b/activitymanager/Event.h
473@@ -21,6 +21,7 @@
474 #define EVENT_H_
475
476 #include <QString>
477+#include <QWidget>
478 #include <QtCore/QDateTime>
479
480 /**
481@@ -29,26 +30,34 @@
482 class Event {
483 public:
484 enum Type {
485- Accessed, ///< resource was accessed, but we don't know for how long it will be open/used
486- Opened, ///< resource was opened
487- Modified, ///< previously opened resource was modified
488- Closed ///< previously opened resource was closed
489+ Accessed = 0, ///< resource was accessed, but we don't know for how long it will be open/used
490+ Opened = 1, ///< resource was opened
491+ Modified = 2, ///< previously opened resource was modified
492+ Closed = 3, ///< previously opened resource was closed
493+ FocussedIn = 4, ///< resource get the keyboard focus
494+ FocussedOut = 5, ///< resource lost the focus
495+
496+ LastEventType = 5
497+
498 };
499
500 enum Reason {
501- User,
502- Scheduled,
503- Heuristic,
504- System,
505- World
506+ User = 0,
507+ Scheduled = 1,
508+ Heuristic = 2,
509+ System = 3,
510+ World = 4,
511+
512+ LastEventReason = 4
513 };
514
515- Event(const QString & application, const QString & uri, Type type = Accessed, Reason reason = User);
516+ Event(const QString & application, WId wid, const QString & uri, Type type = Accessed, Reason reason = User);
517
518 bool operator == (const Event & other) const;
519
520 public:
521 QString application;
522+ WId wid;
523 QString uri;
524 Type type;
525 Reason reason;
526diff --git a/activitymanager/EventBackend.cpp b/activitymanager/EventBackend.cpp
527index e06c25d..2650dbf 100644
528--- a/activitymanager/EventBackend.cpp
529+++ b/activitymanager/EventBackend.cpp
530@@ -26,3 +26,15 @@ EventBackend::EventBackend()
531 EventBackend::~EventBackend()
532 {
533 }
534+
535+void EventBackend::addEvents(const EventList & events)
536+{
537+ Q_UNUSED(events)
538+}
539+
540+void EventBackend::setResourceMimeType(const QString & uri, const QString & mimetype)
541+{
542+ Q_UNUSED(uri)
543+ Q_UNUSED(mimetype)
544+}
545+
546diff --git a/activitymanager/EventBackend.h b/activitymanager/EventBackend.h
547index 26bb925..bd7cbf9 100644
548--- a/activitymanager/EventBackend.h
549+++ b/activitymanager/EventBackend.h
550@@ -31,7 +31,8 @@ public:
551 EventBackend();
552 virtual ~EventBackend();
553
554- virtual void addEvents(const EventList & events) = 0;
555+ virtual void addEvents(const EventList & events);
556+ virtual void setResourceMimeType(const QString & uri, const QString & mimetype);
557
558 };
559
560diff --git a/activitymanager/EventProcessor.cpp b/activitymanager/EventProcessor.cpp
561index 6e38bf2..48bb405 100644
562--- a/activitymanager/EventProcessor.cpp
563+++ b/activitymanager/EventProcessor.cpp
564@@ -31,6 +31,8 @@
565 #include "NepomukEventBackend.h"
566 #endif
567
568+#include "SlcEventBackend.h"
569+
570 #include <QDateTime>
571 #include <QList>
572 #include <QMutex>
573@@ -41,7 +43,9 @@
574
575 class EventProcessorPrivate: public QThread {
576 public:
577- QList < EventBackend * > backends;
578+ QList < EventBackend * > lazyBackends;
579+ QList < EventBackend * > syncBackends;
580+
581 QList < Event > events;
582 QMutex events_mutex;
583
584@@ -75,7 +79,7 @@ void EventProcessorPrivate::run()
585
586 EventProcessorPrivate::events_mutex.unlock();
587
588- foreach (EventBackend * backend, backends) {
589+ foreach (EventBackend * backend, lazyBackends) {
590 backend->addEvents(currentEvents);
591 }
592 }
593@@ -94,23 +98,29 @@ EventProcessor::EventProcessor()
594 : d(new EventProcessorPrivate())
595 {
596 #ifdef HAVE_QZEITGEIST
597- d->backends.append(new ZeitgeistEventBackend());
598+ d->lazyBackends.append(new ZeitgeistEventBackend());
599 #endif
600 #ifdef HAVE_NEPOMUK
601- d->backends.append(new NepomukEventBackend());
602+ d->lazyBackends.append(new NepomukEventBackend());
603 #endif
604+ d->syncBackends.append(new SlcEventBackend());
605 }
606
607 EventProcessor::~EventProcessor()
608 {
609- qDeleteAll(d->backends);
610+ qDeleteAll(d->lazyBackends);
611+ qDeleteAll(d->syncBackends);
612 delete d;
613 }
614
615-void EventProcessor::addEvent(const QString & application, const QString & uri,
616- Event::Type type, Event::Reason reason)
617+void EventProcessor::addEvent(const QString & application, WId wid, const QString & uri,
618+ Event::Type type, Event::Reason reason)
619 {
620- Event newEvent(application, uri, type, reason);
621+ Event newEvent(application, wid, uri, type, reason);
622+
623+ foreach (EventBackend * backend, d->syncBackends) {
624+ backend->addEvents(QList < Event > () << newEvent);
625+ }
626
627 d->events_mutex.lock();
628
629diff --git a/activitymanager/EventProcessor.h b/activitymanager/EventProcessor.h
630index 59cdbad..64eeeb3 100644
631--- a/activitymanager/EventProcessor.h
632+++ b/activitymanager/EventProcessor.h
633@@ -30,13 +30,13 @@ class EventProcessorPrivate;
634 /**
635 * Thread to process desktop/usage events
636 */
637-class EventProcessor: public QThread {
638+class EventProcessor {
639 public:
640 static EventProcessor * self();
641
642 virtual ~EventProcessor();
643
644- void addEvent(const QString & application, const QString & uri,
645+ void addEvent(const QString & application, WId wid, const QString & uri,
646 Event::Type type = Event::Accessed, Event::Reason reason = Event::User);
647
648 private:
649diff --git a/activitymanager/NepomukCommon.h b/activitymanager/NepomukCommon.h
650new file mode 100644
651index 0000000..9df5a62
652--- /dev/null
653+++ b/activitymanager/NepomukCommon.h
654@@ -0,0 +1,63 @@
655+/*
656+ * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
657+ *
658+ * This program is free software; you can redistribute it and/or modify
659+ * it under the terms of the GNU General Public License version 2,
660+ * or (at your option) any later version, as published by the Free
661+ * Software Foundation
662+ *
663+ * This program is distributed in the hope that it will be useful,
664+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
665+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
666+ * GNU General Public License for more details
667+ *
668+ * You should have received a copy of the GNU General Public
669+ * License along with this program; if not, write to the
670+ * Free Software Foundation, Inc.,
671+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
672+ */
673+
674+#ifndef NEPOMUK_COMMON_H_
675+#define NEPOMUK_COMMON_H_
676+
677+#include "nie.h"
678+
679+#define NUAO_targettedResource KUrl(NUAO::nuaoNamespace().toString() + QLatin1String("targettedResource"))
680+#define NUAO_initiatingAgent KUrl(NUAO::nuaoNamespace().toString() + QLatin1String("initiatingAgent"))
681+// #define NUAO_involvesActivity KUrl(NUAO::nuaoNamespace().toString() + QLatin1String("involvesActivity"))
682+
683+#define activityResource(ID) Nepomuk::Resource(ID, KExt::Activity())
684+#define agentResource(ID) Nepomuk::Resource(ID, NAO::Agent())
685+#define currentActivityRes activityResource(ActivityManager::self()->CurrentActivity())
686+
687+// #define anyResource(ID) Nepomuk::Resource(KUrl(ID))
688+
689+inline Nepomuk::Resource anyResource(const QUrl & uri)
690+{
691+ Nepomuk::Resource result(uri);
692+
693+ kDebug() << "setting the URI" << result.isFile() << result.isValid();
694+ result.setProperty(Nepomuk::Vocabulary::NIE::url(), uri);
695+ kDebug() << "set the URI" << result.isFile() << result.isValid();
696+
697+ return result;
698+}
699+
700+inline Nepomuk::Resource anyResource(const QString & uri)
701+{
702+ return anyResource(KUrl(uri));
703+}
704+
705+#define litN3(A) Soprano::Node::literalToN3(A)
706+
707+inline QString resN3(const QUrl & uri)
708+{
709+ return Soprano::Node::resourceToN3(uri);
710+}
711+
712+inline QString resN3(const Nepomuk::Resource & resource)
713+{
714+ return Soprano::Node::resourceToN3(resource.resourceUri());
715+}
716+
717+#endif // NEPOMUK_COMMON_H_
718diff --git a/activitymanager/NepomukEventBackend.cpp b/activitymanager/NepomukEventBackend.cpp
719index 4fe3584..65c398c 100644
720--- a/activitymanager/NepomukEventBackend.cpp
721+++ b/activitymanager/NepomukEventBackend.cpp
722@@ -31,6 +31,8 @@
723 #else // HAVE_NEPOMUK
724
725 #include "NepomukEventBackend.h"
726+#include "NepomukResourceScoreMaintainer.h"
727+
728 #include "Event.h"
729 #include "ActivityManager.h"
730 #include "kext.h"
731@@ -54,9 +56,11 @@
732
733 #include <kdebug.h>
734
735+#include "NepomukCommon.h"
736+
737+using namespace Soprano::Vocabulary;
738 using namespace Nepomuk::Vocabulary;
739 using namespace Nepomuk::Query;
740-using namespace Soprano::Vocabulary;
741
742 NepomukEventBackend::NepomukEventBackend()
743 {
744@@ -64,21 +68,88 @@ NepomukEventBackend::NepomukEventBackend()
745
746 void NepomukEventBackend::addEvents(const EventList & events)
747 {
748- foreach(const Event& event, events) {
749- if(event.type == Event::Accessed) {
750- // one-shot event
751- Nepomuk::Resource eventRes = createDesktopEvent(event.uri, event.timestamp, event.application);
752- eventRes.addType(NUAO::UsageEvent());
753- eventRes.addProperty(NUAO::end(), event.timestamp);
754- }
755- else if(event.type == Event::Opened) {
756- // create a new event
757- createDesktopEvent(event.uri, event.timestamp, event.application);
758+ foreach (const Event& event, events) {
759+ kDebug() << "We are processing event" << event.type << event.uri;
760+ kDebug() << "for agent" << event.application << agentResource(event.application).resourceUri();
761+
762+ switch (event.type) {
763+ case Event::Accessed:
764+ {
765+ // one-shot event
766+
767+ Nepomuk::Resource eventRes = createDesktopEvent(event.uri, event.timestamp, event.application);
768+ eventRes.addType(NUAO::UsageEvent());
769+ eventRes.setProperty(NUAO::start(), event.timestamp);
770+ eventRes.setProperty(NUAO::end(), event.timestamp);
771+
772+ kDebug() << "Created one-shot Accessed event" << eventRes;
773+
774+ NepomukResourceScoreMaintainer::self()->processResource(event.uri, event.application);
775+
776+ break;
777+ }
778+
779+ case Event::Opened:
780+ // create a new event
781+ createDesktopEvent(event.uri, event.timestamp, event.application);
782+
783+ break;
784+
785+ case Event::Closed:
786+ {
787+ // We should find and close the last open event
788+ // TODO: This can have a problem if an app closes a document
789+ // while not in the current activity
790+ const QString query
791+ = QString::fromLatin1(
792+ "select ?r where { "
793+ "?r a nuao:DesktopEvent . "
794+ "?r %1 %2 . "
795+ "?r %3 %4 . "
796+ "?r %5 %6 . "
797+ "?r nuao:start ?start . "
798+ "OPTIONAL { ?r nuao:end ?d . } . "
799+ "FILTER(!BOUND(?d)) . "
800+ "}"
801+ "ORDER BY DESC (?start) LIMIT 1"
802+ ).arg(
803+ /* %1 */ resN3(NUAO_targettedResource),
804+ /* %2 */ resN3(anyResource(KUrl(event.uri))),
805+ /* %3 */ resN3(NUAO_initiatingAgent),
806+ /* %4 */ resN3(agentResource(event.application)),
807+ /* %5 */ resN3(KExt::usedActivity()),
808+ /* %6 */ resN3(currentActivityRes)
809+ );
810+ kDebug() << query;
811+
812+ Soprano::QueryResultIterator it
813+ = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(query, Soprano::Query::QueryLanguageSparql);
814+
815+ if (it.next()) {
816+ kDebug() << "Closing the event";
817+
818+ Nepomuk::Resource eventRes(it[0].uri());
819+ it.close();
820+
821+ eventRes.addProperty(NUAO::end(), event.timestamp);
822+
823+ NepomukResourceScoreMaintainer::self()->processResource(event.uri, event.application);
824+ }
825+
826+ break;
827+ }
828+
829+ default:
830+ // Nothing yet
831+ // TODO: Add focus and modification
832+ break;
833 }
834- else {
835- // find the corresponding event
836- // FIXME: enable this once the range of nao:identifier has been fixed and is no longer assumed to be rdfs:Resource
837- // resulting in a wrong query.
838+
839+
840+// } else {
841+// // find the corresponding event
842+// // FIXME: enable this once the range of nao:identifier has been fixed and is no longer assumed to be rdfs:Resource
843+// // resulting in a wrong query.
844 // Query query(ResourceTypeTerm(NUAO::DesktopEvent())
845 // && ComparisonTerm(NUAO::involves(),
846 // ResourceTerm(Nepomuk::Resource(KUrl(event.uri))), ComparisonTerm::Equal)
847@@ -88,77 +159,103 @@ void NepomukEventBackend::addEvents(const EventList & events)
848 // && !ComparisonTerm(NUAO::end(), Term()));
849 // query.setLimit(1);
850 // query.setQueryFlags(Query::NoResultRestrictions);
851-// const QString queryS = query.toSparqlQuery();
852- const QString queryS
853- = QString::fromLatin1("select ?r where { "
854- "?r a nuao:DesktopEvent . "
855- "?r nuao:involves %1 . "
856- "?r nuao:involves ?a . "
857- "?a a nao:Agent . "
858- "?a nao:identifier %2 . "
859- "OPTIONAL { ?r nuao:end ?d . } . "
860- "FILTER(!BOUND(?d)) . } "
861- "LIMIT 1")
862- .arg(Soprano::Node::resourceToN3(Nepomuk::Resource(KUrl(event.uri)).resourceUri()),
863- Soprano::Node::literalToN3(event.application));
864- kDebug() << queryS;
865- Soprano::QueryResultIterator it
866- = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(queryS, Soprano::Query::QueryLanguageSparql);
867- if(it.next()) {
868- Nepomuk::Resource eventRes(it[0].uri());
869- it.close();
870-
871- eventRes.addProperty(NUAO::end(), event.timestamp);
872- if(event.type == Event::Modified) {
873- eventRes.addType(NUAO::ModificationEvent());
874- }
875- else {
876- eventRes.addType(NUAO::UsageEvent());
877- }
878-
879- // In case of a modification event we create a new event which will
880- // be completed by the final Closed event since this one resource
881- // modification is done now. It ended with saving the resource.
882- if(event.type == Event::Modified) {
883- // create a new event
884- createDesktopEvent(event.uri, event.timestamp, event.application);
885- }
886- }
887- else {
888- kDebug() << "Failed to find matching Open event for resource" << event.uri << "and application" << event.application;
889- }
890- }
891+// const QString query = query.toSparqlQuery();
892+//
893+// // TODO: Something strange is going on here - this should check for
894+// // the activity as well
895+// const QString query
896+// = QString::fromLatin1("select ?r where { "
897+// "?r a nuao:DesktopEvent . "
898+// "?r %1 %2 . "
899+// "?r %3 %4 . "
900+// "OPTIONAL { ?r nuao:end ?d . } . "
901+// "FILTER(!BOUND(?d)) . } "
902+// "LIMIT 1")
903+// .arg(
904+// /* %1 */ resN3(NUAO_targettedResource),
905+// /* %2 */ resN3(anyResource(KUrl(event.uri))),
906+// /* %3 */ resN3(NUAO_initiatingAgent),
907+// /* %4 */ resN3(agentResource(event.application))
908+// );
909+//
910+// kDebug() << query;
911+//
912+// Soprano::QueryResultIterator it
913+// = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(query, Soprano::Query::QueryLanguageSparql);
914+//
915+// if (it.next()) {
916+// Nepomuk::Resource eventRes(it[0].uri());
917+// it.close();
918+//
919+// eventRes.addProperty(NUAO::end(), event.timestamp);
920+// if (event.type == Event::Modified) {
921+// eventRes.addType(NUAO::ModificationEvent());
922+// } else {
923+// eventRes.addType(NUAO::UsageEvent());
924+// }
925+//
926+// // TODO: We are not creating separate events for modifications
927+// // // In case of a modification event we create a new event which will
928+// // // be completed by the final Closed event since this one resource
929+// // // modification is done now. It ended with saving the resource.
930+// // if (event.type == Event::Modified) {
931+// // // create a new event
932+// // createDesktopEvent(event.uri, event.timestamp, event.application);
933+// // }
934+//
935+// } else {
936+// kDebug() << "Failed to find matching Open event for resource" << event.uri << "and application" << event.application;
937+// }
938+//
939+// if (event.type == Event::Closed) {
940+// NepomukResourceScoreMaintainer::self()->processResource(event.uri, event.application);
941+// }
942+// }
943 }
944 }
945
946 Nepomuk::Resource NepomukEventBackend::createDesktopEvent(const KUrl& uri, const QDateTime& startTime, const QString& app)
947 {
948+ kDebug() << "Creating a new desktop event" << uri << startTime << app;
949+
950 // one-shot event
951 Nepomuk::Resource eventRes(QUrl(), NUAO::DesktopEvent());
952- eventRes.addProperty(NUAO::involves(), Nepomuk::Resource(uri));
953+ eventRes.addProperty(NUAO_targettedResource, anyResource(uri));
954 eventRes.addProperty(NUAO::start(), startTime);
955
956+ kDebug() << "Created event" << eventRes.resourceUri()
957+ << "for resource" << ((Nepomuk::Resource(uri)).resourceUri());
958+
959 // the app
960 Nepomuk::Resource appRes(app, NAO::Agent());
961- eventRes.addProperty(NUAO::involves(), appRes);
962+ eventRes.addProperty(NUAO_initiatingAgent, appRes);
963
964 // the activity
965- if(!m_currentActivity.isValid()
966+ if (!m_currentActivity.isValid()
967 || m_currentActivity.identifiers().isEmpty()
968 || m_currentActivity.identifiers().first() != ActivityManager::self()->CurrentActivity()) {
969 // update the current activity resource
970- Soprano::QueryResultIterator it
971- = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(QString::fromLatin1("select ?r where { ?r a %1 . ?r %2 %3 . } LIMIT 1")
972- .arg(Soprano::Node::resourceToN3(KExt::Activity()),
973- Soprano::Node::resourceToN3(KExt::activityIdentifier()),
974- Soprano::Node::literalToN3(ActivityManager::self()->CurrentActivity())),
975- Soprano::Query::QueryLanguageSparql);
976- if(it.next()) {
977+
978+ kDebug() << "Assigning the activity to the event";
979+
980+ const QString query = QString::fromLatin1("select ?r where { "
981+ " ?r a %1 . "
982+ " ?r %2 %3 . "
983+ "} LIMIT 1"
984+ ).arg(
985+ /* %1 */ resN3(KExt::Activity()),
986+ /* %2 */ resN3(KExt::activityIdentifier()),
987+ /* %3 */ resN3(currentActivityRes)
988+ );
989+
990+ Soprano::QueryResultIterator it = Nepomuk::ResourceManager::instance()->mainModel()
991+ ->executeQuery(query, Soprano::Query::QueryLanguageSparql);
992+
993+ if (it.next()) {
994 m_currentActivity = it[0].uri();
995- }
996- else {
997- m_currentActivity = Nepomuk::Resource(ActivityManager::self()->CurrentActivity(), Nepomuk::Vocabulary::KExt::Activity());
998- m_currentActivity.setProperty(Nepomuk::Vocabulary::KExt::activityIdentifier(), ActivityManager::self()->CurrentActivity());
999+ } else {
1000+ m_currentActivity = currentActivityRes;
1001+ m_currentActivity.setProperty(KExt::activityIdentifier(), ActivityManager::self()->CurrentActivity());
1002 }
1003 }
1004
1005diff --git a/activitymanager/NepomukResourceScoreCache.cpp b/activitymanager/NepomukResourceScoreCache.cpp
1006new file mode 100644
1007index 0000000..8d1b66b
1008--- /dev/null
1009+++ b/activitymanager/NepomukResourceScoreCache.cpp
1010@@ -0,0 +1,214 @@
1011+/*
1012+ * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
1013+ *
1014+ * This program is free software; you can redistribute it and/or modify
1015+ * it under the terms of the GNU General Public License version 2,
1016+ * or (at your option) any later version, as published by the Free
1017+ * Software Foundation
1018+ *
1019+ * This program is distributed in the hope that it will be useful,
1020+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1021+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1022+ * GNU General Public License for more details
1023+ *
1024+ * You should have received a copy of the GNU General Public
1025+ * License along with this program; if not, write to the
1026+ * Free Software Foundation, Inc.,
1027+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1028+ */
1029+
1030+#include "NepomukResourceScoreCache.h"
1031+
1032+#include <cmath>
1033+
1034+#include <Soprano/Model>
1035+#include <Soprano/QueryResultIterator>
1036+
1037+#include <Nepomuk/Resource>
1038+#include <Nepomuk/ResourceManager>
1039+#include <Nepomuk/Variant>
1040+
1041+#include <KDebug>
1042+
1043+#include "kext.h"
1044+#include "nao.h"
1045+#include "nuao.h"
1046+
1047+#include "ActivityManager.h"
1048+
1049+using namespace Nepomuk::Vocabulary;
1050+
1051+#include "NepomukCommon.h"
1052+
1053+/**
1054+ *
1055+ */
1056+class NepomukResourceScoreCachePrivate {
1057+public:
1058+ Nepomuk::Resource self;
1059+ QString activity;
1060+ QString application;
1061+ QUrl resource;
1062+
1063+ qreal timeFactor(int days) const
1064+ {
1065+ // Exp is falling rather quickly, we are slowing it 32 times
1066+ return ::exp(- days / 32.0);
1067+ }
1068+
1069+ qreal timeFactor(QDateTime fromTime, QDateTime toTime = QDateTime::currentDateTime()) const
1070+ {
1071+ return timeFactor(fromTime.daysTo(toTime));
1072+ }
1073+
1074+};
1075+
1076+NepomukResourceScoreCache::NepomukResourceScoreCache(const QString & activity, const QString & application, const QUrl & resource)
1077+ : d(new NepomukResourceScoreCachePrivate())
1078+{
1079+ kDebug() << "Cache for" << activity << application << resource << anyResource(resource).resourceUri();
1080+
1081+ d->activity = activity;
1082+ d->application = application;
1083+ d->resource = resource;
1084+
1085+ const QString query
1086+ = QString::fromLatin1("select ?r where { "
1087+ "?r a %1 . "
1088+ "?r kext:usedActivity %2 . "
1089+ "?r kext:initiatingAgent %3 . "
1090+ "?r kext:targettedResource %4 . "
1091+ "} LIMIT 1"
1092+ ).arg(
1093+ /* %1 */ resN3(KExt::ResourceScoreCache()),
1094+ /* %2 */ resN3(currentActivityRes),
1095+ /* %3 */ resN3(agentResource(application)),
1096+ /* %4 */ resN3(anyResource(resource))
1097+ );
1098+
1099+ kDebug() << query;
1100+
1101+ Soprano::QueryResultIterator it
1102+ = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(query, Soprano::Query::QueryLanguageSparql);
1103+
1104+ if (it.next()) {
1105+ Nepomuk::Resource result(it[0].uri());
1106+ it.close();
1107+
1108+ d->self = result;
1109+
1110+ kDebug() << "Found an old cache" << d->self.resourceUri() << d->self.resourceType()
1111+ << "With a score of" << d->self.property(KExt::cachedScore()) << d->self.property(NAO::score());
1112+
1113+ } else {
1114+ Nepomuk::Resource result(QUrl(), KExt::ResourceScoreCache());
1115+
1116+ result.setProperty(
1117+ KExt::targettedResource(),
1118+ Nepomuk::Resource(resource)
1119+ );
1120+ result.setProperty(
1121+ KExt::initiatingAgent(), agentResource(application)
1122+ );
1123+ result.setProperty(
1124+ KExt::usedActivity(), activityResource(activity)
1125+ );
1126+ result.setProperty(KExt::cachedScore(), 0);
1127+
1128+ d->self = result;
1129+
1130+ kDebug() << "Created a new cache resource" << d->self.resourceUri() << d->self.resourceType();
1131+
1132+ }
1133+}
1134+
1135+NepomukResourceScoreCache::~NepomukResourceScoreCache()
1136+{
1137+ delete d;
1138+}
1139+
1140+void NepomukResourceScoreCache::updateScore()
1141+{
1142+ kDebug() << "Updating the score for " << d->resource;
1143+ kDebug() << "Last modified as string" << d->self.property(NAO::lastModified());
1144+
1145+ QDateTime lastModified = d->self.property(NAO::lastModified()).toDateTime();
1146+
1147+ qreal score = d->self.property(KExt::cachedScore()).toDouble();
1148+
1149+ if (lastModified.isValid()) {
1150+ // Adjusting the score depending on the time that passed since the
1151+ // last update
1152+
1153+ kDebug() << "Previous score:" << score;
1154+ score *= d->timeFactor(lastModified);
1155+ kDebug() << "Adjusted score:" << score;
1156+
1157+ } else {
1158+ // If we haven't had previous calculation, set the score to 0
1159+ score = 0;
1160+
1161+ }
1162+
1163+ kDebug() << "Last modified timestamp is" << lastModified << lastModified.isValid();
1164+
1165+ const QString query
1166+ = QString::fromLatin1("select distinct ?r where { "
1167+ "?r a nuao:DesktopEvent . "
1168+ "?r %1 %2 . "
1169+ "?r %3 %4 . "
1170+ "?r %5 %6 . "
1171+ "?r nuao:end ?end . "
1172+ "FILTER(?end >= %7) ."
1173+ " } "
1174+ ).arg(
1175+ /* %1 */ resN3(KExt::usedActivity()),
1176+ /* %2 */ resN3(activityResource(d->activity)),
1177+ /* %3 */ resN3(NUAO_targettedResource),
1178+ /* %4 */ resN3(anyResource(d->resource)),
1179+ /* %5 */ resN3(NUAO_initiatingAgent),
1180+ /* %6 */ resN3(agentResource(d->application)),
1181+ /* %7 */ litN3(lastModified.isValid() ? lastModified : QDateTime::fromMSecsSinceEpoch(0))
1182+ );
1183+
1184+ kDebug() << query;
1185+
1186+ Soprano::QueryResultIterator it
1187+ = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(query, Soprano::Query::QueryLanguageSparql);
1188+
1189+ d->self.setProperty(NAO::lastModified(), QDateTime::currentDateTime());
1190+
1191+ while (it.next()) {
1192+ Nepomuk::Resource result(it[0].uri());
1193+ QDateTime eventStart = result.property(NUAO::start()).toDateTime();
1194+ QDateTime eventEnd = result.property(NUAO::end()).toDateTime();
1195+
1196+ if (!eventStart.isValid()) continue;
1197+
1198+ if (!eventEnd.isValid()) {
1199+ // If the end was not saved, we are treating it as a simple
1200+ // Accessed event
1201+ eventEnd = eventStart;
1202+ }
1203+
1204+ int intervalLength = eventStart.secsTo(eventEnd);
1205+
1206+ if (intervalLength == 0) {
1207+ // We have an Accessed event - otherwise, this wouldn't be 0
1208+
1209+ score += d->timeFactor(eventEnd); // like it is open for 1 minute
1210+
1211+ } else if (intervalLength >= 4) {
1212+ // Ignoring stuff that was open for less than 4 seconds
1213+
1214+ score += d->timeFactor(eventEnd) * intervalLength / 60.0;
1215+ }
1216+
1217+ kDebug() << result.resourceUri() << eventStart << eventEnd << intervalLength;
1218+
1219+ }
1220+
1221+ kDebug() << "New calculated score:" << score << d->self.isValid();
1222+ d->self.setProperty(KExt::cachedScore(), score);
1223+ d->self.setProperty(NAO::score(), score);
1224+}
1225diff --git a/activitymanager/NepomukResourceScoreCache.h b/activitymanager/NepomukResourceScoreCache.h
1226new file mode 100644
1227index 0000000..a26b5a2
1228--- /dev/null
1229+++ b/activitymanager/NepomukResourceScoreCache.h
1230@@ -0,0 +1,42 @@
1231+/*
1232+ * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
1233+ *
1234+ * This program is free software; you can redistribute it and/or modify
1235+ * it under the terms of the GNU General Public License version 2,
1236+ * or (at your option) any later version, as published by the Free
1237+ * Software Foundation
1238+ *
1239+ * This program is distributed in the hope that it will be useful,
1240+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1241+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1242+ * GNU General Public License for more details
1243+ *
1244+ * You should have received a copy of the GNU General Public
1245+ * License along with this program; if not, write to the
1246+ * Free Software Foundation, Inc.,
1247+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1248+ */
1249+
1250+#ifndef NEPOMUK_RESOURCE_SCORE_CACHE_H_
1251+#define NEPOMUK_RESOURCE_SCORE_CACHE_H_
1252+
1253+#include <QString>
1254+#include <QUrl>
1255+
1256+class NepomukResourceScoreCachePrivate;
1257+
1258+/**
1259+ *
1260+ */
1261+class NepomukResourceScoreCache {
1262+public:
1263+ NepomukResourceScoreCache(const QString & activity, const QString & application, const QUrl & resource);
1264+ virtual ~NepomukResourceScoreCache();
1265+
1266+ void updateScore();
1267+
1268+private:
1269+ class NepomukResourceScoreCachePrivate * const d;
1270+};
1271+
1272+#endif // NEPOMUK_RESOURCE_SCORE_CACHE_H_
1273diff --git a/activitymanager/NepomukResourceScoreMaintainer.cpp b/activitymanager/NepomukResourceScoreMaintainer.cpp
1274new file mode 100644
1275index 0000000..f5e4d3c
1276--- /dev/null
1277+++ b/activitymanager/NepomukResourceScoreMaintainer.cpp
1278@@ -0,0 +1,145 @@
1279+/*
1280+ * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
1281+ *
1282+ * This program is free software; you can redistribute it and/or modify
1283+ * it under the terms of the GNU General Public License version 2,
1284+ * or (at your option) any later version, as published by the Free
1285+ * Software Foundation
1286+ *
1287+ * This program is distributed in the hope that it will be useful,
1288+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1289+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1290+ * GNU General Public License for more details
1291+ *
1292+ * You should have received a copy of the GNU General Public
1293+ * License along with this program; if not, write to the
1294+ * Free Software Foundation, Inc.,
1295+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1296+ */
1297+
1298+#include "NepomukResourceScoreMaintainer.h"
1299+
1300+#include <QList>
1301+#include <QMutex>
1302+#include <QThread>
1303+
1304+#include <KDebug>
1305+
1306+#include <Nepomuk/Resource>
1307+
1308+#include <time.h>
1309+#include "kext.h"
1310+
1311+#include "ActivityManager.h"
1312+#include "NepomukResourceScoreCache.h"
1313+
1314+class NepomukResourceScoreMaintainerPrivate: public QThread {
1315+public:
1316+ typedef QString ApplicationName;
1317+ typedef QString ActivityID;
1318+ typedef QList < QUrl > ResourceList;
1319+
1320+ typedef QMap < ApplicationName, ResourceList > Applications;
1321+ typedef QMap < ActivityID, Applications > ResourceTree;
1322+
1323+ ResourceTree openResources;
1324+ QMutex openResources_mutex;
1325+
1326+ void run();
1327+ void processActivity(const ActivityID & activity, const Applications & applications);
1328+
1329+ static NepomukResourceScoreMaintainer * s_instance;
1330+
1331+};
1332+
1333+NepomukResourceScoreMaintainer * NepomukResourceScoreMaintainerPrivate::s_instance = NULL;
1334+
1335+void NepomukResourceScoreMaintainerPrivate::run()
1336+{
1337+ forever {
1338+ // initial delay before processing the resources
1339+ sleep(5);
1340+
1341+ NepomukResourceScoreMaintainerPrivate::openResources_mutex.lock();
1342+ ResourceTree resources = openResources;
1343+ openResources.clear();
1344+ NepomukResourceScoreMaintainerPrivate::openResources_mutex.unlock();
1345+
1346+ const QString & activity = ActivityManager::self()->CurrentActivity();
1347+
1348+ // Let us first process the events related to the current
1349+ // activity so that the stats are available quicker
1350+
1351+ if (resources.contains(activity)) {
1352+ kDebug() << "Processing current activity events";
1353+
1354+ processActivity(activity, resources[activity]);
1355+ resources.remove(activity);
1356+ }
1357+
1358+ foreach (const ActivityID & activity, resources.keys()) {
1359+ kDebug() << "Processing activity" << activity;
1360+
1361+ processActivity(activity, resources[activity]);
1362+ }
1363+ }
1364+}
1365+
1366+void NepomukResourceScoreMaintainerPrivate::processActivity(const ActivityID & activity, const Applications & applications)
1367+{
1368+ foreach (const ApplicationName & application, applications.keys()) {
1369+ // Processing resources for the pair (activity, application)
1370+ kDebug() << " Processing application" << application;
1371+
1372+ foreach (const QUrl & resource, applications[application]) {
1373+ kDebug() << " Updating score for" << activity, application, resource;
1374+ NepomukResourceScoreCache(activity, application, resource).updateScore();
1375+
1376+ }
1377+ }
1378+}
1379+
1380+NepomukResourceScoreMaintainer * NepomukResourceScoreMaintainer::self()
1381+{
1382+ if (!NepomukResourceScoreMaintainerPrivate::s_instance) {
1383+ NepomukResourceScoreMaintainerPrivate::s_instance = new NepomukResourceScoreMaintainer();
1384+ }
1385+
1386+ return NepomukResourceScoreMaintainerPrivate::s_instance;
1387+}
1388+
1389+NepomukResourceScoreMaintainer::NepomukResourceScoreMaintainer()
1390+ : d(new NepomukResourceScoreMaintainerPrivate())
1391+{
1392+}
1393+
1394+NepomukResourceScoreMaintainer::~NepomukResourceScoreMaintainer()
1395+{
1396+ delete d;
1397+}
1398+
1399+void NepomukResourceScoreMaintainer::processResource(const KUrl & resource, const QString & application)
1400+{
1401+ d->openResources_mutex.lock();
1402+
1403+ // Checking whether the item is already scheduled for
1404+ // processing
1405+
1406+ kDebug() << "Adding" << resource << application << "to the queue";
1407+
1408+ const QString & activity = ActivityManager::self()->CurrentActivity();
1409+
1410+ if (d->openResources.contains(activity) &&
1411+ d->openResources[activity].contains(application) &&
1412+ d->openResources[activity][application].contains(resource)) {
1413+ return;
1414+ }
1415+
1416+ d->openResources[activity][application] << resource;
1417+
1418+ d->openResources_mutex.unlock();
1419+
1420+ d->start();
1421+}
1422+
1423+
1424diff --git a/activitymanager/NepomukResourceScoreMaintainer.h b/activitymanager/NepomukResourceScoreMaintainer.h
1425new file mode 100644
1426index 0000000..cbef9f9
1427--- /dev/null
1428+++ b/activitymanager/NepomukResourceScoreMaintainer.h
1429@@ -0,0 +1,47 @@
1430+/*
1431+ * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
1432+ *
1433+ * This program is free software; you can redistribute it and/or modify
1434+ * it under the terms of the GNU General Public License version 2,
1435+ * or (at your option) any later version, as published by the Free
1436+ * Software Foundation
1437+ *
1438+ * This program is distributed in the hope that it will be useful,
1439+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1440+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1441+ * GNU General Public License for more details
1442+ *
1443+ * You should have received a copy of the GNU General Public
1444+ * License along with this program; if not, write to the
1445+ * Free Software Foundation, Inc.,
1446+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1447+ */
1448+
1449+#ifndef NEPOMUK_RESOURCE_SCORE_MAINTAINER_H_
1450+#define NEPOMUK_RESOURCE_SCORE_MAINTAINER_H_
1451+
1452+#include <QThread>
1453+#include <Nepomuk/Resource>
1454+
1455+#include "Event.h"
1456+
1457+class NepomukResourceScoreMaintainerPrivate;
1458+
1459+/**
1460+ * Thread to process desktop/usage events
1461+ */
1462+class NepomukResourceScoreMaintainer {
1463+public:
1464+ static NepomukResourceScoreMaintainer * self();
1465+
1466+ virtual ~NepomukResourceScoreMaintainer();
1467+
1468+ void processResource(const KUrl & resource, const QString & application);
1469+
1470+private:
1471+ NepomukResourceScoreMaintainer();
1472+
1473+ class NepomukResourceScoreMaintainerPrivate * const d;
1474+};
1475+
1476+#endif // NEPOMUK_RESOURCE_SCORE_MAINTAINER_H_
1477diff --git a/activitymanager/SharedInfo.cpp b/activitymanager/SharedInfo.cpp
1478new file mode 100644
1479index 0000000..8c71c34
1480--- /dev/null
1481+++ b/activitymanager/SharedInfo.cpp
1482@@ -0,0 +1,51 @@
1483+/*
1484+ * Copyright (C) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
1485+ *
1486+ * This program is free software; you can redistribute it and/or modify
1487+ * it under the terms of the GNU General Public License version 2,
1488+ * or (at your option) any later version, as published by the Free
1489+ * Software Foundation
1490+ *
1491+ * This program is distributed in the hope that it will be useful,
1492+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1493+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1494+ * GNU General Public License for more details
1495+ *
1496+ * You should have received a copy of the GNU General Public
1497+ * License along with this program; if not, write to the
1498+ * Free Software Foundation, Inc.,
1499+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1500+ */
1501+
1502+#include "SharedInfo.h"
1503+
1504+SharedInfo * SharedInfo::s_instance = NULL;
1505+
1506+SharedInfo * SharedInfo::self()
1507+{
1508+ if (!s_instance) {
1509+ s_instance = new SharedInfo();
1510+ }
1511+
1512+ return s_instance;
1513+}
1514+
1515+SharedInfo::SharedInfo()
1516+{
1517+}
1518+
1519+SharedInfo::~SharedInfo()
1520+{
1521+}
1522+
1523+QHash < WId, SharedInfo::WindowData > const & SharedInfo::windows() const
1524+{
1525+ return m_windows;
1526+}
1527+
1528+QHash < KUrl, SharedInfo::ResourceData > const & SharedInfo::resources() const
1529+{
1530+ return m_resources;
1531+}
1532+
1533+
1534diff --git a/activitymanager/SharedInfo.h b/activitymanager/SharedInfo.h
1535new file mode 100644
1536index 0000000..6e60612
1537--- /dev/null
1538+++ b/activitymanager/SharedInfo.h
1539@@ -0,0 +1,63 @@
1540+/*
1541+ * Copyright (C) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
1542+ *
1543+ * This program is free software; you can redistribute it and/or modify
1544+ * it under the terms of the GNU General Public License version 2,
1545+ * or (at your option) any later version, as published by the Free
1546+ * Software Foundation
1547+ *
1548+ * This program is distributed in the hope that it will be useful,
1549+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1550+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1551+ * GNU General Public License for more details
1552+ *
1553+ * You should have received a copy of the GNU General Public
1554+ * License along with this program; if not, write to the
1555+ * Free Software Foundation, Inc.,
1556+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1557+ */
1558+
1559+#ifndef SHARED_INFO_H_
1560+#define SHARED_INFO_H_
1561+
1562+#include <KUrl>
1563+#include <QSet>
1564+#include <QString>
1565+#include <QHash>
1566+
1567+#include "Event.h"
1568+
1569+/**
1570+ *
1571+ */
1572+class SharedInfo {
1573+public:
1574+ static SharedInfo * self();
1575+
1576+ virtual ~SharedInfo();
1577+
1578+ struct WindowData {
1579+ QSet < KUrl > resources;
1580+ QString application;
1581+ };
1582+
1583+ struct ResourceData {
1584+ Event::Reason reason;
1585+ QSet < QString > activities;
1586+ QString mimetype;
1587+ };
1588+
1589+ QHash < WId, WindowData > const & windows() const;
1590+ QHash < KUrl, ResourceData > const & resources() const;
1591+
1592+private:
1593+ QHash < WId, WindowData > m_windows;
1594+ QHash < KUrl, ResourceData > m_resources;
1595+
1596+ static SharedInfo * s_instance;
1597+ SharedInfo();
1598+
1599+ friend class ActivityManager;
1600+};
1601+
1602+#endif // SHARED_INFO_H_
1603diff --git a/activitymanager/SlcEventBackend.cpp b/activitymanager/SlcEventBackend.cpp
1604new file mode 100644
1605index 0000000..fe8f01d
1606--- /dev/null
1607+++ b/activitymanager/SlcEventBackend.cpp
1608@@ -0,0 +1,127 @@
1609+/*
1610+ * Copyright (C) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
1611+ *
1612+ * This program is free software; you can redistribute it and/or modify
1613+ * it under the terms of the GNU General Public License version 2,
1614+ * or (at your option) any later version, as published by the Free
1615+ * Software Foundation
1616+ *
1617+ * This program is distributed in the hope that it will be useful,
1618+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1619+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1620+ * GNU General Public License for more details
1621+ *
1622+ * You should have received a copy of the GNU General Public
1623+ * License along with this program; if not, write to the
1624+ * Free Software Foundation, Inc.,
1625+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1626+ */
1627+
1628+#include "SlcEventBackend.h"
1629+#include "slcadaptor.h"
1630+
1631+#include <QDBusConnection>
1632+#include <KDebug>
1633+#include <KWindowSystem>
1634+#include <KUrl>
1635+
1636+#include "SharedInfo.h"
1637+
1638+SlcEventBackend::SlcEventBackend()
1639+ : focussedWindow(0)
1640+{
1641+ QDBusConnection dbus = QDBusConnection::sessionBus();
1642+ new SLCAdaptor(this);
1643+ dbus.registerObject("/SLC", this);
1644+
1645+ connect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)),
1646+ this, SLOT(activeWindowChanged(WId)));
1647+}
1648+
1649+void SlcEventBackend::addEvents(const EventList & events)
1650+{
1651+ foreach (const Event & event, events) {
1652+ switch (event.type) {
1653+ case Event::FocussedIn:
1654+ case Event::Opened:
1655+ // kDebug() << "Event::FocussedIn" << focussedWindow << event.wid << event.uri;
1656+
1657+ lastFocussedResource[event.wid] = event.uri;
1658+
1659+ if (event.wid == focussedWindow) {
1660+ updateFocus(focussedWindow);
1661+ }
1662+
1663+ break;
1664+
1665+ case Event::FocussedOut:
1666+ case Event::Closed:
1667+ // kDebug() << "Event::FocussedOut" << focussedWindow << event.wid << event.uri;
1668+
1669+ if (lastFocussedResource[event.wid] == event.uri) {
1670+ lastFocussedResource[event.wid] = KUrl();
1671+ }
1672+
1673+ if (event.wid == focussedWindow) {
1674+ updateFocus();
1675+ }
1676+
1677+ break;
1678+
1679+ default:
1680+ // nothing
1681+ break;
1682+ }
1683+ }
1684+}
1685+
1686+KUrl SlcEventBackend::_focussedResourceURI()
1687+{
1688+ KUrl kuri;
1689+
1690+ if (lastFocussedResource.contains(focussedWindow)) {
1691+ kuri = lastFocussedResource[focussedWindow];
1692+ } else {
1693+ foreach (const KUrl & uri, SharedInfo::self()->windows()[focussedWindow].resources) {
1694+ kuri = uri;
1695+ break;
1696+ }
1697+ }
1698+
1699+ return kuri;
1700+}
1701+
1702+QString SlcEventBackend::focussedResourceURI()
1703+{
1704+ return _focussedResourceURI().url();
1705+}
1706+
1707+QString SlcEventBackend::focussedResourceMimetype()
1708+{
1709+ return SharedInfo::self()->resources().contains(_focussedResourceURI()) ?
1710+ SharedInfo::self()->resources()[_focussedResourceURI()].mimetype : QString();
1711+}
1712+
1713+void SlcEventBackend::activeWindowChanged(WId wid)
1714+{
1715+ if (wid == focussedWindow) return;
1716+
1717+ focussedWindow = wid;
1718+
1719+ updateFocus(wid);
1720+}
1721+
1722+void SlcEventBackend::updateFocus(WId wid)
1723+{
1724+ // kDebug() << "Updating focus for " << wid;
1725+
1726+ if (wid == 0 || !SharedInfo::self()->windows().contains(wid)) {
1727+ // kDebug() << "Clearing focus";
1728+ emit focusChanged(QString(), QString());
1729+
1730+ } else if (wid == focussedWindow) {
1731+ // kDebug() << "It is the currently focussed window";
1732+ emit focusChanged(focussedResourceURI(), SharedInfo::self()->resources()[_focussedResourceURI()].mimetype);
1733+
1734+ }
1735+}
1736diff --git a/activitymanager/SlcEventBackend.h b/activitymanager/SlcEventBackend.h
1737new file mode 100644
1738index 0000000..3c79792
1739--- /dev/null
1740+++ b/activitymanager/SlcEventBackend.h
1741@@ -0,0 +1,59 @@
1742+/*
1743+ * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
1744+ *
1745+ * This program is free software; you can redistribute it and/or modify
1746+ * it under the terms of the GNU General Public License version 2,
1747+ * or (at your option) any later version, as published by the Free
1748+ * Software Foundation
1749+ *
1750+ * This program is distributed in the hope that it will be useful,
1751+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1752+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1753+ * GNU General Public License for more details
1754+ *
1755+ * You should have received a copy of the GNU General Public
1756+ * License along with this program; if not, write to the
1757+ * Free Software Foundation, Inc.,
1758+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1759+ */
1760+
1761+#ifndef SLC_EVENT_BACKEND_H_
1762+#define SLC_EVENT_BACKEND_H_
1763+
1764+#include "EventBackend.h"
1765+
1766+#include <QObject>
1767+#include <KUrl>
1768+
1769+/**
1770+ *
1771+ */
1772+class SlcEventBackend: public QObject, public EventBackend {
1773+ Q_OBJECT
1774+ Q_CLASSINFO("D-Bus Interface", "org.kde.ActivityManager.SLC")
1775+
1776+public:
1777+ SlcEventBackend();
1778+
1779+ virtual void addEvents(const EventList & events);
1780+
1781+private Q_SLOTS:
1782+ void activeWindowChanged(WId windowId);
1783+
1784+public Q_SLOTS:
1785+ QString focussedResourceURI();
1786+ QString focussedResourceMimetype();
1787+
1788+Q_SIGNALS:
1789+ void focusChanged(const QString & uri, const QString & mimetype);
1790+
1791+private:
1792+ void updateFocus(WId wid = 0);
1793+
1794+ WId focussedWindow;
1795+ KUrl _focussedResourceURI();
1796+ QHash < WId, KUrl > lastFocussedResource;
1797+};
1798+
1799+#endif // SLC_EVENT_BACKEND_H_
1800+
1801diff --git a/activitymanager/ZeitgeistEventBackend.cpp b/activitymanager/ZeitgeistEventBackend.cpp
1802index 6ae0cf0..1bbd050 100644
1803--- a/activitymanager/ZeitgeistEventBackend.cpp
1804+++ b/activitymanager/ZeitgeistEventBackend.cpp
1805@@ -34,20 +34,20 @@
1806
1807 static QString eventInterpretation(Event::Type type)
1808 {
1809- switch (type) {
1810- case Event::Accessed:
1811- return QtZeitgeist::Interpretation::Event::ZGAccessEvent;
1812+ // switch (type) {
1813+ // case Event::Accessed:
1814+ // return QtZeitgeist::Interpretation::Event::ZGAccessEvent;
1815
1816- case Event::Opened:
1817- return QtZeitgeist::Interpretation::Event::ZGAccessEvent;
1818+ // case Event::Opened:
1819+ // return QtZeitgeist::Interpretation::Event::ZGAccessEvent;
1820
1821- case Event::Modified:
1822- return QtZeitgeist::Interpretation::Event::ZGModifyEvent;
1823+ // case Event::Modified:
1824+ // return QtZeitgeist::Interpretation::Event::ZGModifyEvent;
1825
1826- case Event::Closed:
1827- return QtZeitgeist::Interpretation::Event::ZGLeaveEvent;
1828+ // case Event::Closed:
1829+ // return QtZeitgeist::Interpretation::Event::ZGLeaveEvent;
1830
1831- }
1832+ // }
1833
1834 // shut up GCC
1835 return QString();
1836@@ -55,22 +55,22 @@ static QString eventInterpretation(Event::Type type)
1837
1838 static QString eventManifestation(Event::Reason reason)
1839 {
1840- switch (reason) {
1841- case Event::User:
1842- return QtZeitgeist::Manifestation::Event::ZGUserActivity;
1843+ // switch (reason) {
1844+ // case Event::User:
1845+ // return QtZeitgeist::Manifestation::Event::ZGUserActivity;
1846
1847- case Event::Heuristic:
1848- return QtZeitgeist::Manifestation::Event::ZGHeuristicActivity;
1849+ // case Event::Heuristic:
1850+ // return QtZeitgeist::Manifestation::Event::ZGHeuristicActivity;
1851
1852- case Event::Scheduled:
1853- return QtZeitgeist::Manifestation::Event::ZGScheduledActivity;
1854+ // case Event::Scheduled:
1855+ // return QtZeitgeist::Manifestation::Event::ZGScheduledActivity;
1856
1857- case Event::System:
1858- return QtZeitgeist::Manifestation::Event::ZGSystemNotification;
1859+ // case Event::System:
1860+ // return QtZeitgeist::Manifestation::Event::ZGSystemNotification;
1861
1862- case Event::World:
1863- return QtZeitgeist::Manifestation::Event::ZGWorldActivity;
1864- }
1865+ // case Event::World:
1866+ // return QtZeitgeist::Manifestation::Event::ZGWorldActivity;
1867+ // }
1868
1869 // shut up GCC
1870 return QtZeitgeist::Manifestation::Event::ZGUserActivity;
1871diff --git a/activitymanager/main.cpp b/activitymanager/main.cpp
1872index cfaed00..2ce18ed 100644
1873--- a/activitymanager/main.cpp
1874+++ b/activitymanager/main.cpp
1875@@ -19,8 +19,6 @@
1876
1877 #include <ActivityManager.h>
1878
1879-#include <KDebug>
1880-
1881 #include <KAboutData>
1882 #include <KCmdLineArgs>
1883
1884diff --git a/activitymanager/ontologies/CMakeLists.txt b/activitymanager/ontologies/CMakeLists.txt
1885new file mode 100644
1886index 0000000..838b1f4
1887--- /dev/null
1888+++ b/activitymanager/ontologies/CMakeLists.txt
1889@@ -0,0 +1,8 @@
1890+project(nepomuk_ontologies)
1891+
1892+configure_file(kamdrso.ontology.in ${CMAKE_CURRENT_BINARY_DIR}/kamdrso.ontology)
1893+
1894+install(FILES
1895+ kamdrso.trig
1896+ ${CMAKE_CURRENT_BINARY_DIR}/kamdrso.ontology
1897+DESTINATION ${CMAKE_INSTALL_PREFIX}/share/ontology/kde)
1898diff --git a/activitymanager/ontologies/kamdrso.ontology.in b/activitymanager/ontologies/kamdrso.ontology.in
1899new file mode 100644
1900index 0000000..032dac0
1901--- /dev/null
1902+++ b/activitymanager/ontologies/kamdrso.ontology.in
1903@@ -0,0 +1,8 @@
1904+[Ontology]
1905+Version=1.0
1906+Name=KDE Activity Manager Daemon - Resource Scoring Ontology
1907+Comment=The KDE Resource Scoring Ontology contains classes related to KAMD's scoring mechanisms
1908+Namespace=http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso#" ;
1909+Path=${CMAKE_INSTALL_PREFIX}/share/ontology/kde/kamdrso.trig
1910+MimeType=application/x-trig
1911+Type=Data
1912diff --git a/activitymanager/ontologies/kamdrso.trig b/activitymanager/ontologies/kamdrso.trig
1913new file mode 100644
1914index 0000000..b968231
1915--- /dev/null
1916+++ b/activitymanager/ontologies/kamdrso.trig
1917@@ -0,0 +1,112 @@
1918+#
1919+# Copyright (c) 2011 Ivan Cukic <ivan.cukic@kde.org>
1920+# All rights reserved, licensed under either CC-BY or BSD.
1921+#
1922+# You are free:
1923+# * to Share - to copy, distribute and transmit the work
1924+# * to Remix - to adapt the work
1925+# Under the following conditions:
1926+# * Attribution - You must attribute the work in the manner specified by the author
1927+# or licensor (but not in any way that suggests that they endorse you or your use
1928+# of the work).
1929+#
1930+# Redistribution and use in source and binary forms, with or without modification,
1931+# are permitted provided that the following conditions are met:
1932+# * Redistributions of source code must retain the above copyright notice, this
1933+# list of conditions and the following disclaimer.
1934+# * Redistributions in binary form must reproduce the above copyright notice, this
1935+# list of conditions and the following disclaimer in the documentation and/or
1936+# other materials provided with the distribution.
1937+# * Neither the names of the authors nor the names of contributors may
1938+# be used to endorse or promote products derived from this ontology without
1939+# specific prior written permission.
1940+#
1941+# THIS ONTOLOGY IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1942+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1943+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1944+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1945+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1946+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1947+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1948+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1949+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
1950+# THIS ONTOLOGY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1951+#
1952+
1953+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
1954+@prefix nao: <http://www.semanticdesktop.org/ontologies/2007/08/15/nao#> .
1955+@prefix nrl: <http://www.semanticdesktop.org/ontologies/2007/08/15/nrl#> .
1956+@prefix nie: <http://www.semanticdesktop.org/ontologies/2007/01/19/nie#> .
1957+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
1958+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
1959+@prefix kamdrso: <http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso#> .
1960+@prefix nfo: <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#> .
1961+
1962+kamdrso: {
1963+ kamdrso:unixFileMode
1964+ a rdf:Property ;
1965+ rdfs:label "Unix file mode" ;
1966+ rdfs:comment "The file mode value as seen on unix file systems." ;
1967+ rdfs:domain nfo:FileDataObject ;
1968+ rdfs:range xsd:integer ;
1969+ nao:userVisible false .
1970+
1971+ kamdrso:unixFileOwner
1972+ a rdf:Property ;
1973+ rdfs:label "Unix file owner" ;
1974+ rdfs:comment "The owner of the file as seen on unix file systems. This is intended as the low-level counterpart to nfo:owner." ;
1975+ rdfs:domain nfo:FileDataObject ;
1976+ rdfs:range xsd:string ;
1977+ nao:userVisible false .
1978+
1979+ kamdrso:unixFileGroup
1980+ a rdf:Property ;
1981+ rdfs:label "Unix file group" ;
1982+ rdfs:comment "The group of the file as seen on unix file systems." ;
1983+ rdfs:domain nfo:FileDataObject ;
1984+ rdfs:range xsd:string ;
1985+ nao:userVisible false .
1986+
1987+ kamdrso:Activity
1988+ a rdfs:Class ;
1989+ rdfs:subClassOf rdfs:Resource ;
1990+ rdfs:label "activity" ;
1991+ rdfs:comment "A Plasma activity." .
1992+
1993+ kamdrso:usedActivity
1994+ a rdf:Property ;
1995+ rdfs:label "used activity" ;
1996+ rdfs:comment "The activity that was active when resource was created. This is mostly used for graphs or desktop events." ;
1997+ rdfs:domain rdfs:Resource ;
1998+ rdfs:range kamdrso:Activity ;
1999+ nao:userVisible false .
2000+
2001+ kamdrso:activityIdentifier
2002+ a rdf:Property ;
2003+ rdfs:subPropertyOf nao:identifier ;
2004+ rdfs:label "activity identifier" ;
2005+ rdfs:comment "The unique ID of the activity as used outside of Nepomuk. Typically this is a UUID." ;
2006+ rdfs:domain kamdrso:Activity ;
2007+ rdfs:range xsd:string ;
2008+ nao:userVisible false .
2009+
2010+}
2011+
2012+<http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso/metadata> {
2013+ <http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso/metadata>
2014+ a nrl:GraphMetadata ;
2015+ nrl:coreGraphMetadataFor kamdrso: .
2016+
2017+
2018+ kamdrso:
2019+ a nrl:Ontology , nrl:DocumentGraph ;
2020+ nao:prefLabel "KDE Extensions Ontology" ;
2021+ nao:hasDefaultNamespace "http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso#" ;
2022+ nao:hasDefaultNamespaceAbbreviation "kamdrso" ;
2023+ nao:lastModified "2011-06-02T12:31:43Z" ;
2024+ nao:serializationLanguage "TriG" ;
2025+ nao:status "Unstable" ;
2026+ nrl:updatable "0" ;
2027+ nao:version "2" .
2028+}
2029+
2030diff --git a/activitymanager/org.kde.ActivityManager.SLC.xml b/activitymanager/org.kde.ActivityManager.SLC.xml
2031new file mode 100644
2032index 0000000..b9df419
2033--- /dev/null
2034+++ b/activitymanager/org.kde.ActivityManager.SLC.xml
2035@@ -0,0 +1,15 @@
2036+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
2037+<node>
2038+ <interface name="org.kde.ActivityManager.SLC">
2039+ <signal name="focusChanged">
2040+ <arg name="uri" type="s" direction="out"/>
2041+ <arg name="mimetype" type="s" direction="out"/>
2042+ </signal>
2043+ <method name="focussedResourceURI">
2044+ <arg type="s" direction="out"/>
2045+ </method>
2046+ <method name="focussedResourceMimetype">
2047+ <arg type="s" direction="out"/>
2048+ </method>
2049+ </interface>
2050+</node>
2051diff --git a/activitymanager/org.kde.ActivityManager.xml b/activitymanager/org.kde.ActivityManager.xml
2052index b03e826..a09252b 100644
2053--- a/activitymanager/org.kde.ActivityManager.xml
2054+++ b/activitymanager/org.kde.ActivityManager.xml
2055@@ -23,23 +23,6 @@
2056 <arg name="id" type="s" direction="out"/>
2057 <arg name="state" type="i" direction="out"/>
2058 </signal>
2059- <signal name="ResourceAccessed">
2060- <arg name="application" type="s" direction="out"/>
2061- <arg name="uri" type="s" direction="out"/>
2062- </signal>
2063- <signal name="ResourceOpened">
2064- <arg name="application" type="s" direction="out"/>
2065- <arg name="windowId" type="u" direction="out"/>
2066- <arg name="uri" type="s" direction="out"/>
2067- </signal>
2068- <signal name="ResourceModified">
2069- <arg name="windowId" type="u" direction="out"/>
2070- <arg name="uri" type="s" direction="out"/>
2071- </signal>
2072- <signal name="ResourceClosed">
2073- <arg name="windowId" type="u" direction="out"/>
2074- <arg name="uri" type="s" direction="out"/>
2075- </signal>
2076 <method name="Start">
2077 </method>
2078 <method name="Stop">
2079@@ -102,26 +85,16 @@
2080 <method name="IsBackstoreAvailable">
2081 <arg type="b" direction="out"/>
2082 </method>
2083- <method name="NotifyResourceAccessed">
2084- <arg name="application" type="s" direction="in"/>
2085- <arg name="uri" type="s" direction="in"/>
2086- </method>
2087- <method name="NotifyResourceOpened">
2088+ <method name="RegisterResourceEvent">
2089 <arg name="application" type="s" direction="in"/>
2090 <arg name="windowId" type="u" direction="in"/>
2091 <arg name="uri" type="s" direction="in"/>
2092+ <arg name="event" type="u" direction="in"/>
2093+ <arg name="reason" type="u" direction="in"/>
2094 </method>
2095- <method name="NotifyResourceModified">
2096- <arg name="windowId" type="u" direction="in"/>
2097- <arg name="uri" type="s" direction="in"/>
2098- </method>
2099- <method name="NotifyResourceClosed">
2100- <arg name="windowId" type="u" direction="in"/>
2101- <arg name="uri" type="s" direction="in"/>
2102- </method>
2103- <method name="ActivitiesForResource">
2104- <arg type="as" direction="out"/>
2105+ <method name="RegisterResourceMimeType">
2106 <arg name="uri" type="s" direction="in"/>
2107+ <arg name="mimetype" type="s" direction="in"/>
2108 </method>
2109 </interface>
2110 </node>
2111diff --git a/activitymanager/queries.sparql b/activitymanager/queries.sparql
2112new file mode 100644
2113index 0000000..680eef5
2114--- /dev/null
2115+++ b/activitymanager/queries.sparql
2116@@ -0,0 +1,43 @@
2117+// Getting the highest scored caches for (application/agent, activity)
2118+
2119+select distinct ?resource,
2120+ (
2121+ (
2122+ ?lastScore * bif:exp(-
2123+ bif:datediff('day', ?lastUpdate, ##CURRENT_DATETIME##)
2124+ )
2125+ )
2126+ as ?score) where {
2127+ ?cache kext:targettedResource ?resource .
2128+ ?cache a kext:ResourceScoreCache .
2129+ ?cache nao:lastModified ?lastUpdate .
2130+ ?cache kext:cachedScore ?lastScore .
2131+ ?cache kext:usedActivity ##ACTIVITY## .
2132+ ?cache kext:initiatingAgent ##AGENT## .
2133+ OPTIONAL { ?resource nie:url ?uri . } .
2134+}
2135+ORDER BY DESC (?score)
2136+LIMIT 10
2137+
2138+// Getting the highest scored caches for (activity)
2139+
2140+select distinct ?resource,
2141+ (
2142+ (
2143+ SUM (
2144+ ?lastScore * bif:exp(
2145+ - bif:datediff('day', ?lastUpdate, ##CURRENT_DATETIME##)
2146+ )
2147+ )
2148+ )
2149+ as ?score
2150+ ) where {
2151+ ?cache kext:targettedResource ?resource .
2152+ ?cache a kext:ResourceScoreCache .
2153+ ?cache nao:lastModified ?lastUpdate .
2154+ ?cache kext:cachedScore ?lastScore .
2155+ ?cache kext:usedActivity ##ACTIVITY## .
2156+ }
2157+ GROUP BY (?resource)
2158+ ORDER BY DESC (?score)
2159+ LIMIT 10
2160diff --git a/activitymanager/scripts/delete-stats.sh b/activitymanager/scripts/delete-stats.sh
2161new file mode 100755
2162index 0000000..a237c38
2163--- /dev/null
2164+++ b/activitymanager/scripts/delete-stats.sh
2165@@ -0,0 +1,4 @@
2166+#!/bin/zsh
2167+alias nepomukcmd="sopranocmd --socket `kde4-config --path socket`nepomuk-socket --model main --nrl"
2168+for res in `nepomukcmd --foo query 'select ?r { ?r a kext:ResourceScoreCache . }'`; nepomukcmd rm $res
2169+for res in `nepomukcmd --foo query 'select ?r { ?r a nuao:DesktopEvent . }'`; nepomukcmd rm $res
2170diff --git a/nepomuk/ontologies/kext.trig b/nepomuk/ontologies/kext.trig
2171index be5d041..b743638 100644
2172--- a/nepomuk/ontologies/kext.trig
2173+++ b/nepomuk/ontologies/kext.trig
2174@@ -7,18 +7,18 @@
2175 # * to Remix - to adapt the work
2176 # Under the following conditions:
2177 # * Attribution - You must attribute the work in the manner specified by the author
2178-# or licensor (but not in any way that suggests that they endorse you or your use
2179+# or licensor (but not in any way that suggests that they endorse you or your use
2180 # of the work).
2181 #
2182-# Redistribution and use in source and binary forms, with or without modification,
2183+# Redistribution and use in source and binary forms, with or without modification,
2184 # are permitted provided that the following conditions are met:
2185-# * Redistributions of source code must retain the above copyright notice, this
2186+# * Redistributions of source code must retain the above copyright notice, this
2187 # list of conditions and the following disclaimer.
2188-# * Redistributions in binary form must reproduce the above copyright notice, this
2189-# list of conditions and the following disclaimer in the documentation and/or
2190+# * Redistributions in binary form must reproduce the above copyright notice, this
2191+# list of conditions and the following disclaimer in the documentation and/or
2192 # other materials provided with the distribution.
2193 # * Neither the names of the authors nor the names of contributors may
2194-# be used to endorse or promote products derived from this ontology without
2195+# be used to endorse or promote products derived from this ontology without
2196 # specific prior written permission.
2197 #
2198 # THIS ONTOLOGY IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2199@@ -94,6 +94,35 @@ kext: {
2200 rdfs:range xsd:string ;
2201 nrl:cardinality 1 ;
2202 nao:userVisible false .
2203+
2204+ kext:ResourceScoreCache
2205+ a rdfs:Class ;
2206+ rdfs:subClassOf rdfs:Resource ;
2207+ rdfs:label "Resource score cache" ;
2208+ rdfs:comment "For storing the automatically calculated score based on the usage statistics" ;
2209+ nao:userVisible false .
2210+
2211+ kext:targettedResource
2212+ a rdf:Property ;
2213+ rdfs:comment "Resource for which the score is calculated." ;
2214+ rdfs:domain kext:ResourceScoreCache ;
2215+ rdfs:label "resource" ;
2216+ rdfs:range rdfs:Resource .
2217+
2218+ kext:initiatingAgent
2219+ a rdf:Property ;
2220+ rdfs:comment "Relates the score to the agent initiating the events." ;
2221+ rdfs:domain kext:ResourceScoreCache ;
2222+ rdfs:label "involved agent" ;
2223+ rdfs:range nao:Agent .
2224+
2225+ kext:cachedScore
2226+ a rdf:Property ;
2227+ rdfs:subPropertyOf nao:score ;
2228+ rdfs:comment "The automatically calculated score" ;
2229+ rdfs:domain kext:ResourceScoreCache ;
2230+ rdfs:label "calculated score" ;
2231+ rdfs:range xsd:float .
2232 }
2233
2234 <http://nepomuk.kde.org/ontologies/2010/11/29/kext/metadata> {
2235--
22361.7.5.4
2237
02238
=== added file 'debian/patches/kubuntu_mobile_ported-the-new-plugin-system-to-active-development-4.diff'
--- debian/patches/kubuntu_mobile_ported-the-new-plugin-system-to-active-development-4.diff 1970-01-01 00:00:00 +0000
+++ debian/patches/kubuntu_mobile_ported-the-new-plugin-system-to-active-development-4.diff 2011-08-18 09:25:23 +0000
@@ -0,0 +1,3622 @@
1From 6f809ee3c098c9a89af74f3f3e731e9d4ddda1bd Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Ivan=20=C4=8Cuki=C4=87?= <ivan.cukic@kde.org>
3Date: Thu, 14 Jul 2011 18:21:12 +0200
4Subject: [PATCH 4/6] Ported the new plugin system to active-development/4.7
5
6---
7 activitymanager/ActivityManager.cpp | 3 +-
8 activitymanager/CMakeLists.txt | 76 +-----
9 activitymanager/EventBackend.cpp | 40 ---
10 activitymanager/EventBackend.h | 40 ---
11 activitymanager/EventProcessor.cpp | 85 +++++--
12 activitymanager/EventProcessor.h | 5 +-
13 activitymanager/NepomukCommon.h | 63 -----
14 activitymanager/NepomukEventBackend.cpp | 267 --------------------
15 activitymanager/NepomukEventBackend.h | 47 ----
16 activitymanager/NepomukResourceScoreCache.cpp | 214 ----------------
17 activitymanager/NepomukResourceScoreCache.h | 42 ---
18 activitymanager/NepomukResourceScoreMaintainer.cpp | 145 -----------
19 activitymanager/NepomukResourceScoreMaintainer.h | 47 ----
20 activitymanager/Plugin.cpp | 56 ++++
21 activitymanager/Plugin.h | 59 +++++
22 activitymanager/SharedInfo.cpp | 20 ++
23 activitymanager/SharedInfo.h | 17 ++-
24 activitymanager/SlcEventBackend.cpp | 127 ----------
25 activitymanager/SlcEventBackend.h | 59 -----
26 activitymanager/ZeitgeistEventBackend.cpp | 95 -------
27 activitymanager/ZeitgeistEventBackend.h | 39 ---
28 activitymanager/activitymanager-plugin.desktop | 12 +
29 activitymanager/krso.trig | 100 ++++++++
30 activitymanager/ontologies/CMakeLists.txt | 8 -
31 activitymanager/ontologies/kamdrso.ontology.in | 8 -
32 activitymanager/ontologies/kamdrso.trig | 112 --------
33 activitymanager/org.kde.ActivityManager.SLC.xml | 15 --
34 activitymanager/plugins/CMakeLists.txt | 3 +
35 activitymanager/plugins/dummy/CMakeLists.txt | 30 +++
36 .../dummy/activitymanager-plugin-dummy.desktop | 19 ++
37 activitymanager/plugins/dummy/dummy.cpp | 34 +++
38 activitymanager/plugins/dummy/dummy.h | 35 +++
39 activitymanager/plugins/nepomuk/CMakeLists.txt | 61 +++++
40 activitymanager/plugins/nepomuk/NepomukCommon.h | 67 +++++
41 activitymanager/plugins/nepomuk/NepomukPlugin.cpp | 264 +++++++++++++++++++
42 activitymanager/plugins/nepomuk/NepomukPlugin.h | 47 ++++
43 .../plugins/nepomuk/NepomukResourceScoreCache.cpp | 215 ++++++++++++++++
44 .../plugins/nepomuk/NepomukResourceScoreCache.h | 42 +++
45 .../nepomuk/NepomukResourceScoreMaintainer.cpp | 145 +++++++++++
46 .../nepomuk/NepomukResourceScoreMaintainer.h | 47 ++++
47 .../nepomuk/activitymanager-plugin-nepomuk.desktop | 20 ++
48 activitymanager/plugins/slc/CMakeLists.txt | 37 +++
49 .../plugins/slc/activitymanager-plugin-slc.desktop | 19 ++
50 .../plugins/slc/org.kde.ActivityManager.SLC.xml | 15 ++
51 activitymanager/plugins/slc/slc.cpp | 132 ++++++++++
52 activitymanager/plugins/slc/slc.h | 58 +++++
53 46 files changed, 1634 insertions(+), 1457 deletions(-)
54 delete mode 100644 activitymanager/EventBackend.cpp
55 delete mode 100644 activitymanager/EventBackend.h
56 delete mode 100644 activitymanager/NepomukCommon.h
57 delete mode 100644 activitymanager/NepomukEventBackend.cpp
58 delete mode 100644 activitymanager/NepomukEventBackend.h
59 delete mode 100644 activitymanager/NepomukResourceScoreCache.cpp
60 delete mode 100644 activitymanager/NepomukResourceScoreCache.h
61 delete mode 100644 activitymanager/NepomukResourceScoreMaintainer.cpp
62 delete mode 100644 activitymanager/NepomukResourceScoreMaintainer.h
63 create mode 100644 activitymanager/Plugin.cpp
64 create mode 100644 activitymanager/Plugin.h
65 delete mode 100644 activitymanager/SlcEventBackend.cpp
66 delete mode 100644 activitymanager/SlcEventBackend.h
67 delete mode 100644 activitymanager/ZeitgeistEventBackend.cpp
68 delete mode 100644 activitymanager/ZeitgeistEventBackend.h
69 create mode 100644 activitymanager/activitymanager-plugin.desktop
70 create mode 100644 activitymanager/krso.trig
71 delete mode 100644 activitymanager/ontologies/CMakeLists.txt
72 delete mode 100644 activitymanager/ontologies/kamdrso.ontology.in
73 delete mode 100644 activitymanager/ontologies/kamdrso.trig
74 delete mode 100644 activitymanager/org.kde.ActivityManager.SLC.xml
75 create mode 100644 activitymanager/plugins/CMakeLists.txt
76 create mode 100644 activitymanager/plugins/dummy/CMakeLists.txt
77 create mode 100644 activitymanager/plugins/dummy/activitymanager-plugin-dummy.desktop
78 create mode 100644 activitymanager/plugins/dummy/dummy.cpp
79 create mode 100644 activitymanager/plugins/dummy/dummy.h
80 create mode 100644 activitymanager/plugins/nepomuk/CMakeLists.txt
81 create mode 100644 activitymanager/plugins/nepomuk/NepomukCommon.h
82 create mode 100644 activitymanager/plugins/nepomuk/NepomukPlugin.cpp
83 create mode 100644 activitymanager/plugins/nepomuk/NepomukPlugin.h
84 create mode 100644 activitymanager/plugins/nepomuk/NepomukResourceScoreCache.cpp
85 create mode 100644 activitymanager/plugins/nepomuk/NepomukResourceScoreCache.h
86 create mode 100644 activitymanager/plugins/nepomuk/NepomukResourceScoreMaintainer.cpp
87 create mode 100644 activitymanager/plugins/nepomuk/NepomukResourceScoreMaintainer.h
88 create mode 100644 activitymanager/plugins/nepomuk/activitymanager-plugin-nepomuk.desktop
89 create mode 100644 activitymanager/plugins/slc/CMakeLists.txt
90 create mode 100644 activitymanager/plugins/slc/activitymanager-plugin-slc.desktop
91 create mode 100644 activitymanager/plugins/slc/org.kde.ActivityManager.SLC.xml
92 create mode 100644 activitymanager/plugins/slc/slc.cpp
93 create mode 100644 activitymanager/plugins/slc/slc.h
94
95diff --git a/activitymanager/ActivityManager.cpp b/activitymanager/ActivityManager.cpp
96index e821c92..0e06cf5 100644
97--- a/activitymanager/ActivityManager.cpp
98+++ b/activitymanager/ActivityManager.cpp
99@@ -123,7 +123,6 @@ ActivityManagerPrivate::ActivityManagerPrivate(ActivityManager * parent,
100 ksmserverInterface->deleteLater();
101 ksmserverInterface = 0;
102 }
103-
104 }
105
106 ActivityManagerPrivate::~ActivityManagerPrivate()
107@@ -148,6 +147,7 @@ void ActivityManagerPrivate::windowClosed(WId windowId)
108
109 void ActivityManagerPrivate::activeWindowChanged(WId windowId)
110 {
111+ Q_UNUSED(windowId)
112 // kDebug() << "Window focussed..." << windowId
113 // << "one of ours?" << windows.contains(windowId);
114
115@@ -234,6 +234,7 @@ bool ActivityManagerPrivate::setCurrentActivity(const QString & id)
116 scheduleConfigSync();
117 }
118
119+ SharedInfo::self()->setCurrentActivity(id);
120 emit q->CurrentActivityChanged(id);
121 return true;
122 }
123diff --git a/activitymanager/CMakeLists.txt b/activitymanager/CMakeLists.txt
124index 726fcce..3e1ab10 100644
125--- a/activitymanager/CMakeLists.txt
126+++ b/activitymanager/CMakeLists.txt
127@@ -1,9 +1,11 @@
128 project(ActivityManager)
129
130-set (ADDITIONAL_LINK_LIBS)
131+set(ADDITIONAL_LINK_LIBS)
132
133 add_subdirectory(kded)
134-add_subdirectory(ontologies)
135+# add_subdirectory(ontologies)
136+
137+add_subdirectory(plugins)
138
139 # Checking for Nepomuk
140 macro_optional_find_package(Nepomuk)
141@@ -22,26 +24,6 @@ if(Nepomuk_FOUND)
142 )
143 endif(Nepomuk_FOUND)
144
145-# Checking for QtZeitgeist
146-macro_optional_find_package(QZeitgeist)
147-
148-if (QZEITGEIST_INCLUDE_DIR)
149- set(QZeitgeist_FOUND TRUE)
150-endif(QZEITGEIST_INCLUDE_DIR)
151-
152-macro_log_feature(
153- QZeitgeist_FOUND
154- "QtZeitgeist" "Qt bindings for Zeitgeist" "http://gitorious.org/kde-zeitgeist/libqzeitgeist/" FALSE ""
155- "RECOMMENDED: Zeitgeist and QtZeitgeist is needed for resource tracking")
156-if (QZeitgeist_FOUND)
157- set(HAVE_QZEITGEIST 1)
158- include_directories(${QZEITGEIST_INCLUDE_DIR})
159- set(ADDITIONAL_LINK_LIBS
160- ${ADDITIONAL_LINK_LIBS}
161- ${QZEITGEIST_LIBRARY}
162- )
163-endif(QZeitgeist_FOUND)
164-
165 # config file
166 configure_file(config-features.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-features.h )
167
168@@ -57,58 +39,18 @@ include_directories(
169 set(activity_manager_SRCS
170 ActivityManager.cpp
171 EventProcessor.cpp
172- EventBackend.cpp
173+ Plugin.cpp
174 Event.cpp
175 SharedInfo.cpp
176 main.cpp
177 )
178
179-set(activity_manager_backends_SRCS
180- NepomukEventBackend.cpp
181- NepomukResourceScoreMaintainer.cpp
182- NepomukResourceScoreCache.cpp
183- ZeitgeistEventBackend.cpp
184- SlcEventBackend.cpp
185- )
186-
187 qt4_add_dbus_adaptor(
188 activity_manager_SRCS org.kde.ActivityManager.xml
189 ActivityManager.h ActivityManager
190 )
191
192-qt4_add_dbus_adaptor(
193- activity_manager_SRCS org.kde.ActivityManager.SLC.xml
194- SlcEventBackend.h SlcEventBackend
195- )
196-
197-if(Nepomuk_FOUND)
198- soprano_add_ontology(activity_manager_SRCS
199- ${CMAKE_SOURCE_DIR}/nepomuk/ontologies/kext.trig
200- "KExt" "Nepomuk::Vocabulary" "trig"
201- )
202-
203- # soprano_add_ontology(activity_manager_SRCS
204- # ${CMAKE_CURRENT_SOURCE_DIR}/ontologies/kamdrso.trig
205- # "RSO" "Nepomuk::Vocabulary" "trig"
206- # )
207-
208- soprano_add_ontology(activity_manager_SRCS
209- ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nie/nie.trig
210- "NIE" "Nepomuk::Vocabulary" "trig"
211- )
212-
213- soprano_add_ontology(activity_manager_SRCS
214- ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nepomuk/nao.trig
215- "NAO" "Nepomuk::Vocabulary" "trig"
216- )
217-
218- soprano_add_ontology(activity_manager_SRCS
219- ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nepomuk/nuao.trig
220- "NUAO" "Nepomuk::Vocabulary" "trig"
221- )
222-endif()
223-
224-kde4_add_executable(activity-manager ${activity_manager_SRCS} ${activity_manager_backends_SRCS})
225+kde4_add_executable(activity-manager ${activity_manager_SRCS})
226
227 target_link_libraries(
228 activity-manager
229@@ -129,3 +71,9 @@ install(
230 TARGETS activity-manager ${INSTALL_TARGETS_DEFAULT_ARGS}
231 )
232
233+install(FILES
234+ activitymanager-plugin.desktop
235+ DESTINATION ${SERVICETYPES_INSTALL_DIR}
236+ )
237+
238+
239diff --git a/activitymanager/EventBackend.cpp b/activitymanager/EventBackend.cpp
240deleted file mode 100644
241index 2650dbf..0000000
242--- a/activitymanager/EventBackend.cpp
243+++ /dev/null
244@@ -1,40 +0,0 @@
245-/*
246- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
247- *
248- * This program is free software; you can redistribute it and/or modify
249- * it under the terms of the GNU General Public License version 2,
250- * or (at your option) any later version, as published by the Free
251- * Software Foundation
252- *
253- * This program is distributed in the hope that it will be useful,
254- * but WITHOUT ANY WARRANTY; without even the implied warranty of
255- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
256- * GNU General Public License for more details
257- *
258- * You should have received a copy of the GNU General Public
259- * License along with this program; if not, write to the
260- * Free Software Foundation, Inc.,
261- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
262- */
263-
264-#include "EventBackend.h"
265-
266-EventBackend::EventBackend()
267-{
268-}
269-
270-EventBackend::~EventBackend()
271-{
272-}
273-
274-void EventBackend::addEvents(const EventList & events)
275-{
276- Q_UNUSED(events)
277-}
278-
279-void EventBackend::setResourceMimeType(const QString & uri, const QString & mimetype)
280-{
281- Q_UNUSED(uri)
282- Q_UNUSED(mimetype)
283-}
284-
285diff --git a/activitymanager/EventBackend.h b/activitymanager/EventBackend.h
286deleted file mode 100644
287index bd7cbf9..0000000
288--- a/activitymanager/EventBackend.h
289+++ /dev/null
290@@ -1,40 +0,0 @@
291-/*
292- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
293- *
294- * This program is free software; you can redistribute it and/or modify
295- * it under the terms of the GNU General Public License version 2,
296- * or (at your option) any later version, as published by the Free
297- * Software Foundation
298- *
299- * This program is distributed in the hope that it will be useful,
300- * but WITHOUT ANY WARRANTY; without even the implied warranty of
301- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
302- * GNU General Public License for more details
303- *
304- * You should have received a copy of the GNU General Public
305- * License along with this program; if not, write to the
306- * Free Software Foundation, Inc.,
307- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
308- */
309-
310-#ifndef EVENT_BACKEND_H_
311-#define EVENT_BACKEND_H_
312-
313-#include <EventProcessor.h>
314-#include "Event.h"
315-
316-/**
317- *
318- */
319-class EventBackend {
320-public:
321- EventBackend();
322- virtual ~EventBackend();
323-
324- virtual void addEvents(const EventList & events);
325- virtual void setResourceMimeType(const QString & uri, const QString & mimetype);
326-
327-};
328-
329-#endif // EVENT_BACKEND_H_
330-
331diff --git a/activitymanager/EventProcessor.cpp b/activitymanager/EventProcessor.cpp
332index 48bb405..a6c9d2e 100644
333--- a/activitymanager/EventProcessor.cpp
334+++ b/activitymanager/EventProcessor.cpp
335@@ -19,32 +19,27 @@
336 */
337
338 #include "EventProcessor.h"
339-#include "EventBackend.h"
340+#include "Plugin.h"
341
342 #include "config-features.h"
343
344-#ifdef HAVE_QZEITGEIST
345-#include "ZeitgeistEventBackend.h"
346-#endif
347+#include "Plugin.h"
348
349-#ifdef HAVE_NEPOMUK
350-#include "NepomukEventBackend.h"
351-#endif
352-
353-#include "SlcEventBackend.h"
354+#include <KDebug>
355
356 #include <QDateTime>
357 #include <QList>
358 #include <QMutex>
359
360 #include <KDebug>
361+#include <KServiceTypeTrader>
362
363 #include <time.h>
364
365 class EventProcessorPrivate: public QThread {
366 public:
367- QList < EventBackend * > lazyBackends;
368- QList < EventBackend * > syncBackends;
369+ QList < Plugin * > lazyBackends;
370+ QList < Plugin * > syncBackends;
371
372 QList < Event > events;
373 QMutex events_mutex;
374@@ -79,7 +74,7 @@ void EventProcessorPrivate::run()
375
376 EventProcessorPrivate::events_mutex.unlock();
377
378- foreach (EventBackend * backend, lazyBackends) {
379+ foreach (Plugin * backend, lazyBackends) {
380 backend->addEvents(currentEvents);
381 }
382 }
383@@ -97,13 +92,63 @@ EventProcessor * EventProcessor::self()
384 EventProcessor::EventProcessor()
385 : d(new EventProcessorPrivate())
386 {
387-#ifdef HAVE_QZEITGEIST
388- d->lazyBackends.append(new ZeitgeistEventBackend());
389-#endif
390-#ifdef HAVE_NEPOMUK
391- d->lazyBackends.append(new NepomukEventBackend());
392-#endif
393- d->syncBackends.append(new SlcEventBackend());
394+ // Plugin loading
395+
396+ kDebug() << "Loading plugins...";
397+
398+ KService::List offers = KServiceTypeTrader::self()->query("ActivityManager/Plugin");
399+
400+ QStringList disabledPlugins = SharedInfo::self()->pluginConfig("Global").readEntry("disabledPlugins", QStringList());
401+ kDebug() << disabledPlugins << "disabled due to the configuration in activitymanager-pluginsrc";
402+
403+ foreach(const KService::Ptr & service, offers) {
404+ if (!disabledPlugins.contains(service->library())) {
405+ disabledPlugins.append(
406+ service->property("X-ActivityManager-PluginOverrides", QVariant::StringList).toStringList()
407+ );
408+ kDebug() << service->name() << "disables" <<
409+ service->property("X-ActivityManager-PluginOverrides", QVariant::StringList);
410+
411+ }
412+ }
413+
414+ foreach(const KService::Ptr & service, offers) {
415+ if (disabledPlugins.contains(service->library())) {
416+ continue;
417+ }
418+
419+ kDebug() << "Loading plugin:"
420+ << service->name() << service->storageId() << service->library()
421+ << service->property("X-ActivityManager-PluginType", QVariant::String);
422+
423+ KPluginFactory * factory = KPluginLoader(service->library()).factory();
424+
425+ if (!factory) {
426+ kDebug() << "Failed to load plugin:" << service->name();
427+ continue;
428+ }
429+
430+ Plugin * plugin = factory->create < Plugin > (this);
431+ plugin->setSharedInfo(SharedInfo::self());
432+
433+ if (plugin) {
434+ const QString & type = service->property("X-ActivityManager-PluginType", QVariant::String).toString();
435+
436+ if (type == "lazyeventhandler") {
437+ d->lazyBackends << plugin;
438+ kDebug() << "Added to lazy plugins";
439+
440+ } else if (type == "synceventhandler"){
441+ d->syncBackends << plugin;
442+ kDebug() << "Added to sync plugins";
443+
444+ }
445+
446+ } else {
447+ kDebug() << "Failed to load plugin:" << service->name();
448+ }
449+
450+ }
451 }
452
453 EventProcessor::~EventProcessor()
454@@ -118,7 +163,7 @@ void EventProcessor::addEvent(const QString & application, WId wid, const QStrin
455 {
456 Event newEvent(application, wid, uri, type, reason);
457
458- foreach (EventBackend * backend, d->syncBackends) {
459+ foreach (Plugin * backend, d->syncBackends) {
460 backend->addEvents(QList < Event > () << newEvent);
461 }
462
463diff --git a/activitymanager/EventProcessor.h b/activitymanager/EventProcessor.h
464index 64eeeb3..061e07c 100644
465--- a/activitymanager/EventProcessor.h
466+++ b/activitymanager/EventProcessor.h
467@@ -20,17 +20,18 @@
468 #ifndef EVENT_PROCESSOR_H
469 #define EVENT_PROCESSOR_H
470
471+#include <QObject>
472 #include <QThread>
473
474 #include "Event.h"
475
476-class EventBackend;
477+class Plugin;
478 class EventProcessorPrivate;
479
480 /**
481 * Thread to process desktop/usage events
482 */
483-class EventProcessor {
484+class EventProcessor: public QObject {
485 public:
486 static EventProcessor * self();
487
488diff --git a/activitymanager/NepomukCommon.h b/activitymanager/NepomukCommon.h
489deleted file mode 100644
490index 9df5a62..0000000
491--- a/activitymanager/NepomukCommon.h
492+++ /dev/null
493@@ -1,63 +0,0 @@
494-/*
495- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
496- *
497- * This program is free software; you can redistribute it and/or modify
498- * it under the terms of the GNU General Public License version 2,
499- * or (at your option) any later version, as published by the Free
500- * Software Foundation
501- *
502- * This program is distributed in the hope that it will be useful,
503- * but WITHOUT ANY WARRANTY; without even the implied warranty of
504- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
505- * GNU General Public License for more details
506- *
507- * You should have received a copy of the GNU General Public
508- * License along with this program; if not, write to the
509- * Free Software Foundation, Inc.,
510- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
511- */
512-
513-#ifndef NEPOMUK_COMMON_H_
514-#define NEPOMUK_COMMON_H_
515-
516-#include "nie.h"
517-
518-#define NUAO_targettedResource KUrl(NUAO::nuaoNamespace().toString() + QLatin1String("targettedResource"))
519-#define NUAO_initiatingAgent KUrl(NUAO::nuaoNamespace().toString() + QLatin1String("initiatingAgent"))
520-// #define NUAO_involvesActivity KUrl(NUAO::nuaoNamespace().toString() + QLatin1String("involvesActivity"))
521-
522-#define activityResource(ID) Nepomuk::Resource(ID, KExt::Activity())
523-#define agentResource(ID) Nepomuk::Resource(ID, NAO::Agent())
524-#define currentActivityRes activityResource(ActivityManager::self()->CurrentActivity())
525-
526-// #define anyResource(ID) Nepomuk::Resource(KUrl(ID))
527-
528-inline Nepomuk::Resource anyResource(const QUrl & uri)
529-{
530- Nepomuk::Resource result(uri);
531-
532- kDebug() << "setting the URI" << result.isFile() << result.isValid();
533- result.setProperty(Nepomuk::Vocabulary::NIE::url(), uri);
534- kDebug() << "set the URI" << result.isFile() << result.isValid();
535-
536- return result;
537-}
538-
539-inline Nepomuk::Resource anyResource(const QString & uri)
540-{
541- return anyResource(KUrl(uri));
542-}
543-
544-#define litN3(A) Soprano::Node::literalToN3(A)
545-
546-inline QString resN3(const QUrl & uri)
547-{
548- return Soprano::Node::resourceToN3(uri);
549-}
550-
551-inline QString resN3(const Nepomuk::Resource & resource)
552-{
553- return Soprano::Node::resourceToN3(resource.resourceUri());
554-}
555-
556-#endif // NEPOMUK_COMMON_H_
557diff --git a/activitymanager/NepomukEventBackend.cpp b/activitymanager/NepomukEventBackend.cpp
558deleted file mode 100644
559index 65c398c..0000000
560--- a/activitymanager/NepomukEventBackend.cpp
561+++ /dev/null
562@@ -1,267 +0,0 @@
563-/*
564- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
565- * Copyright (c) 2011 Sebastian Trueg <trueg@kde.org>
566- *
567- * This program is free software; you can redistribute it and/or modify
568- * it under the terms of the GNU General Public License version 2,
569- * or (at your option) any later version, as published by the Free
570- * Software Foundation
571- *
572- * This program is distributed in the hope that it will be useful,
573- * but WITHOUT ANY WARRANTY; without even the implied warranty of
574- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
575- * GNU General Public License for more details
576- *
577- * You should have received a copy of the GNU General Public
578- * License along with this program; if not, write to the
579- * Free Software Foundation, Inc.,
580- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
581- */
582-
583-#include "config-features.h"
584-
585-#ifndef HAVE_NEPOMUK
586-#ifdef _MSC_VER
587-#pragma warning()
588-#pragma message("No Nepomuk, disabling desktop events processing")
589-#else
590- #warning "No Nepomuk, disabling desktop events processing"
591-#endif
592-
593-#else // HAVE_NEPOMUK
594-
595-#include "NepomukEventBackend.h"
596-#include "NepomukResourceScoreMaintainer.h"
597-
598-#include "Event.h"
599-#include "ActivityManager.h"
600-#include "kext.h"
601-
602-#include <nepomuk/resource.h>
603-#include <nepomuk/nuao.h>
604-#include <nepomuk/resourcemanager.h>
605-#include <nepomuk/variant.h>
606-
607-#include <Nepomuk/Query/Query>
608-#include <Nepomuk/Query/ResourceTerm>
609-#include <Nepomuk/Query/ResourceTypeTerm>
610-#include <Nepomuk/Query/ComparisonTerm>
611-#include <Nepomuk/Query/LiteralTerm>
612-#include <Nepomuk/Query/NegationTerm>
613-
614-#include <Soprano/Vocabulary/NAO>
615-#include <Soprano/QueryResultIterator>
616-#include <Soprano/Node>
617-#include <Soprano/Model>
618-
619-#include <kdebug.h>
620-
621-#include "NepomukCommon.h"
622-
623-using namespace Soprano::Vocabulary;
624-using namespace Nepomuk::Vocabulary;
625-using namespace Nepomuk::Query;
626-
627-NepomukEventBackend::NepomukEventBackend()
628-{
629-}
630-
631-void NepomukEventBackend::addEvents(const EventList & events)
632-{
633- foreach (const Event& event, events) {
634- kDebug() << "We are processing event" << event.type << event.uri;
635- kDebug() << "for agent" << event.application << agentResource(event.application).resourceUri();
636-
637- switch (event.type) {
638- case Event::Accessed:
639- {
640- // one-shot event
641-
642- Nepomuk::Resource eventRes = createDesktopEvent(event.uri, event.timestamp, event.application);
643- eventRes.addType(NUAO::UsageEvent());
644- eventRes.setProperty(NUAO::start(), event.timestamp);
645- eventRes.setProperty(NUAO::end(), event.timestamp);
646-
647- kDebug() << "Created one-shot Accessed event" << eventRes;
648-
649- NepomukResourceScoreMaintainer::self()->processResource(event.uri, event.application);
650-
651- break;
652- }
653-
654- case Event::Opened:
655- // create a new event
656- createDesktopEvent(event.uri, event.timestamp, event.application);
657-
658- break;
659-
660- case Event::Closed:
661- {
662- // We should find and close the last open event
663- // TODO: This can have a problem if an app closes a document
664- // while not in the current activity
665- const QString query
666- = QString::fromLatin1(
667- "select ?r where { "
668- "?r a nuao:DesktopEvent . "
669- "?r %1 %2 . "
670- "?r %3 %4 . "
671- "?r %5 %6 . "
672- "?r nuao:start ?start . "
673- "OPTIONAL { ?r nuao:end ?d . } . "
674- "FILTER(!BOUND(?d)) . "
675- "}"
676- "ORDER BY DESC (?start) LIMIT 1"
677- ).arg(
678- /* %1 */ resN3(NUAO_targettedResource),
679- /* %2 */ resN3(anyResource(KUrl(event.uri))),
680- /* %3 */ resN3(NUAO_initiatingAgent),
681- /* %4 */ resN3(agentResource(event.application)),
682- /* %5 */ resN3(KExt::usedActivity()),
683- /* %6 */ resN3(currentActivityRes)
684- );
685- kDebug() << query;
686-
687- Soprano::QueryResultIterator it
688- = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(query, Soprano::Query::QueryLanguageSparql);
689-
690- if (it.next()) {
691- kDebug() << "Closing the event";
692-
693- Nepomuk::Resource eventRes(it[0].uri());
694- it.close();
695-
696- eventRes.addProperty(NUAO::end(), event.timestamp);
697-
698- NepomukResourceScoreMaintainer::self()->processResource(event.uri, event.application);
699- }
700-
701- break;
702- }
703-
704- default:
705- // Nothing yet
706- // TODO: Add focus and modification
707- break;
708- }
709-
710-
711-// } else {
712-// // find the corresponding event
713-// // FIXME: enable this once the range of nao:identifier has been fixed and is no longer assumed to be rdfs:Resource
714-// // resulting in a wrong query.
715-// Query query(ResourceTypeTerm(NUAO::DesktopEvent())
716-// && ComparisonTerm(NUAO::involves(),
717-// ResourceTerm(Nepomuk::Resource(KUrl(event.uri))), ComparisonTerm::Equal)
718-// && ComparisonTerm(NUAO::involves(),
719-// ResourceTypeTerm(NAO::Agent())
720-// && ComparisonTerm(NAO::identifier(), LiteralTerm(event.application), ComparisonTerm::Equal))
721-// && !ComparisonTerm(NUAO::end(), Term()));
722-// query.setLimit(1);
723-// query.setQueryFlags(Query::NoResultRestrictions);
724-// const QString query = query.toSparqlQuery();
725-//
726-// // TODO: Something strange is going on here - this should check for
727-// // the activity as well
728-// const QString query
729-// = QString::fromLatin1("select ?r where { "
730-// "?r a nuao:DesktopEvent . "
731-// "?r %1 %2 . "
732-// "?r %3 %4 . "
733-// "OPTIONAL { ?r nuao:end ?d . } . "
734-// "FILTER(!BOUND(?d)) . } "
735-// "LIMIT 1")
736-// .arg(
737-// /* %1 */ resN3(NUAO_targettedResource),
738-// /* %2 */ resN3(anyResource(KUrl(event.uri))),
739-// /* %3 */ resN3(NUAO_initiatingAgent),
740-// /* %4 */ resN3(agentResource(event.application))
741-// );
742-//
743-// kDebug() << query;
744-//
745-// Soprano::QueryResultIterator it
746-// = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(query, Soprano::Query::QueryLanguageSparql);
747-//
748-// if (it.next()) {
749-// Nepomuk::Resource eventRes(it[0].uri());
750-// it.close();
751-//
752-// eventRes.addProperty(NUAO::end(), event.timestamp);
753-// if (event.type == Event::Modified) {
754-// eventRes.addType(NUAO::ModificationEvent());
755-// } else {
756-// eventRes.addType(NUAO::UsageEvent());
757-// }
758-//
759-// // TODO: We are not creating separate events for modifications
760-// // // In case of a modification event we create a new event which will
761-// // // be completed by the final Closed event since this one resource
762-// // // modification is done now. It ended with saving the resource.
763-// // if (event.type == Event::Modified) {
764-// // // create a new event
765-// // createDesktopEvent(event.uri, event.timestamp, event.application);
766-// // }
767-//
768-// } else {
769-// kDebug() << "Failed to find matching Open event for resource" << event.uri << "and application" << event.application;
770-// }
771-//
772-// if (event.type == Event::Closed) {
773-// NepomukResourceScoreMaintainer::self()->processResource(event.uri, event.application);
774-// }
775-// }
776- }
777-}
778-
779-Nepomuk::Resource NepomukEventBackend::createDesktopEvent(const KUrl& uri, const QDateTime& startTime, const QString& app)
780-{
781- kDebug() << "Creating a new desktop event" << uri << startTime << app;
782-
783- // one-shot event
784- Nepomuk::Resource eventRes(QUrl(), NUAO::DesktopEvent());
785- eventRes.addProperty(NUAO_targettedResource, anyResource(uri));
786- eventRes.addProperty(NUAO::start(), startTime);
787-
788- kDebug() << "Created event" << eventRes.resourceUri()
789- << "for resource" << ((Nepomuk::Resource(uri)).resourceUri());
790-
791- // the app
792- Nepomuk::Resource appRes(app, NAO::Agent());
793- eventRes.addProperty(NUAO_initiatingAgent, appRes);
794-
795- // the activity
796- if (!m_currentActivity.isValid()
797- || m_currentActivity.identifiers().isEmpty()
798- || m_currentActivity.identifiers().first() != ActivityManager::self()->CurrentActivity()) {
799- // update the current activity resource
800-
801- kDebug() << "Assigning the activity to the event";
802-
803- const QString query = QString::fromLatin1("select ?r where { "
804- " ?r a %1 . "
805- " ?r %2 %3 . "
806- "} LIMIT 1"
807- ).arg(
808- /* %1 */ resN3(KExt::Activity()),
809- /* %2 */ resN3(KExt::activityIdentifier()),
810- /* %3 */ resN3(currentActivityRes)
811- );
812-
813- Soprano::QueryResultIterator it = Nepomuk::ResourceManager::instance()->mainModel()
814- ->executeQuery(query, Soprano::Query::QueryLanguageSparql);
815-
816- if (it.next()) {
817- m_currentActivity = it[0].uri();
818- } else {
819- m_currentActivity = currentActivityRes;
820- m_currentActivity.setProperty(KExt::activityIdentifier(), ActivityManager::self()->CurrentActivity());
821- }
822- }
823-
824- eventRes.setProperty(KExt::usedActivity(), m_currentActivity);
825-
826- return eventRes;
827-}
828-
829-#endif // HAVE_NEPOMUK
830diff --git a/activitymanager/NepomukEventBackend.h b/activitymanager/NepomukEventBackend.h
831deleted file mode 100644
832index a8cbc0f..0000000
833--- a/activitymanager/NepomukEventBackend.h
834+++ /dev/null
835@@ -1,47 +0,0 @@
836-/*
837- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
838- * Copyright (c) 2011 Sebastian Trueg <trueg@kde.org>
839- *
840- * This program is free software; you can redistribute it and/or modify
841- * it under the terms of the GNU General Public License version 2,
842- * or (at your option) any later version, as published by the Free
843- * Software Foundation
844- *
845- * This program is distributed in the hope that it will be useful,
846- * but WITHOUT ANY WARRANTY; without even the implied warranty of
847- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
848- * GNU General Public License for more details
849- *
850- * You should have received a copy of the GNU General Public
851- * License along with this program; if not, write to the
852- * Free Software Foundation, Inc.,
853- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
854- */
855-
856-#ifndef NEPOMUK_EVENT_BACKEND_H_
857-#define NEPOMUK_EVENT_BACKEND_H_
858-
859-#include "EventBackend.h"
860-
861-#include <Nepomuk/Resource>
862-
863-class KUrl;
864-class QDateTime;
865-
866-/**
867- *
868- */
869-class NepomukEventBackend: public EventBackend {
870-public:
871- NepomukEventBackend();
872-
873- virtual void addEvents(const EventList & events);
874-
875-private:
876- Nepomuk::Resource createDesktopEvent(const KUrl& uri, const QDateTime& startTime, const QString& app);
877-
878- Nepomuk::Resource m_currentActivity;
879-};
880-
881-#endif // NEPOMUK_EVENT_BACKEND_H_
882-
883diff --git a/activitymanager/NepomukResourceScoreCache.cpp b/activitymanager/NepomukResourceScoreCache.cpp
884deleted file mode 100644
885index 8d1b66b..0000000
886--- a/activitymanager/NepomukResourceScoreCache.cpp
887+++ /dev/null
888@@ -1,214 +0,0 @@
889-/*
890- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
891- *
892- * This program is free software; you can redistribute it and/or modify
893- * it under the terms of the GNU General Public License version 2,
894- * or (at your option) any later version, as published by the Free
895- * Software Foundation
896- *
897- * This program is distributed in the hope that it will be useful,
898- * but WITHOUT ANY WARRANTY; without even the implied warranty of
899- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
900- * GNU General Public License for more details
901- *
902- * You should have received a copy of the GNU General Public
903- * License along with this program; if not, write to the
904- * Free Software Foundation, Inc.,
905- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
906- */
907-
908-#include "NepomukResourceScoreCache.h"
909-
910-#include <cmath>
911-
912-#include <Soprano/Model>
913-#include <Soprano/QueryResultIterator>
914-
915-#include <Nepomuk/Resource>
916-#include <Nepomuk/ResourceManager>
917-#include <Nepomuk/Variant>
918-
919-#include <KDebug>
920-
921-#include "kext.h"
922-#include "nao.h"
923-#include "nuao.h"
924-
925-#include "ActivityManager.h"
926-
927-using namespace Nepomuk::Vocabulary;
928-
929-#include "NepomukCommon.h"
930-
931-/**
932- *
933- */
934-class NepomukResourceScoreCachePrivate {
935-public:
936- Nepomuk::Resource self;
937- QString activity;
938- QString application;
939- QUrl resource;
940-
941- qreal timeFactor(int days) const
942- {
943- // Exp is falling rather quickly, we are slowing it 32 times
944- return ::exp(- days / 32.0);
945- }
946-
947- qreal timeFactor(QDateTime fromTime, QDateTime toTime = QDateTime::currentDateTime()) const
948- {
949- return timeFactor(fromTime.daysTo(toTime));
950- }
951-
952-};
953-
954-NepomukResourceScoreCache::NepomukResourceScoreCache(const QString & activity, const QString & application, const QUrl & resource)
955- : d(new NepomukResourceScoreCachePrivate())
956-{
957- kDebug() << "Cache for" << activity << application << resource << anyResource(resource).resourceUri();
958-
959- d->activity = activity;
960- d->application = application;
961- d->resource = resource;
962-
963- const QString query
964- = QString::fromLatin1("select ?r where { "
965- "?r a %1 . "
966- "?r kext:usedActivity %2 . "
967- "?r kext:initiatingAgent %3 . "
968- "?r kext:targettedResource %4 . "
969- "} LIMIT 1"
970- ).arg(
971- /* %1 */ resN3(KExt::ResourceScoreCache()),
972- /* %2 */ resN3(currentActivityRes),
973- /* %3 */ resN3(agentResource(application)),
974- /* %4 */ resN3(anyResource(resource))
975- );
976-
977- kDebug() << query;
978-
979- Soprano::QueryResultIterator it
980- = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(query, Soprano::Query::QueryLanguageSparql);
981-
982- if (it.next()) {
983- Nepomuk::Resource result(it[0].uri());
984- it.close();
985-
986- d->self = result;
987-
988- kDebug() << "Found an old cache" << d->self.resourceUri() << d->self.resourceType()
989- << "With a score of" << d->self.property(KExt::cachedScore()) << d->self.property(NAO::score());
990-
991- } else {
992- Nepomuk::Resource result(QUrl(), KExt::ResourceScoreCache());
993-
994- result.setProperty(
995- KExt::targettedResource(),
996- Nepomuk::Resource(resource)
997- );
998- result.setProperty(
999- KExt::initiatingAgent(), agentResource(application)
1000- );
1001- result.setProperty(
1002- KExt::usedActivity(), activityResource(activity)
1003- );
1004- result.setProperty(KExt::cachedScore(), 0);
1005-
1006- d->self = result;
1007-
1008- kDebug() << "Created a new cache resource" << d->self.resourceUri() << d->self.resourceType();
1009-
1010- }
1011-}
1012-
1013-NepomukResourceScoreCache::~NepomukResourceScoreCache()
1014-{
1015- delete d;
1016-}
1017-
1018-void NepomukResourceScoreCache::updateScore()
1019-{
1020- kDebug() << "Updating the score for " << d->resource;
1021- kDebug() << "Last modified as string" << d->self.property(NAO::lastModified());
1022-
1023- QDateTime lastModified = d->self.property(NAO::lastModified()).toDateTime();
1024-
1025- qreal score = d->self.property(KExt::cachedScore()).toDouble();
1026-
1027- if (lastModified.isValid()) {
1028- // Adjusting the score depending on the time that passed since the
1029- // last update
1030-
1031- kDebug() << "Previous score:" << score;
1032- score *= d->timeFactor(lastModified);
1033- kDebug() << "Adjusted score:" << score;
1034-
1035- } else {
1036- // If we haven't had previous calculation, set the score to 0
1037- score = 0;
1038-
1039- }
1040-
1041- kDebug() << "Last modified timestamp is" << lastModified << lastModified.isValid();
1042-
1043- const QString query
1044- = QString::fromLatin1("select distinct ?r where { "
1045- "?r a nuao:DesktopEvent . "
1046- "?r %1 %2 . "
1047- "?r %3 %4 . "
1048- "?r %5 %6 . "
1049- "?r nuao:end ?end . "
1050- "FILTER(?end >= %7) ."
1051- " } "
1052- ).arg(
1053- /* %1 */ resN3(KExt::usedActivity()),
1054- /* %2 */ resN3(activityResource(d->activity)),
1055- /* %3 */ resN3(NUAO_targettedResource),
1056- /* %4 */ resN3(anyResource(d->resource)),
1057- /* %5 */ resN3(NUAO_initiatingAgent),
1058- /* %6 */ resN3(agentResource(d->application)),
1059- /* %7 */ litN3(lastModified.isValid() ? lastModified : QDateTime::fromMSecsSinceEpoch(0))
1060- );
1061-
1062- kDebug() << query;
1063-
1064- Soprano::QueryResultIterator it
1065- = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(query, Soprano::Query::QueryLanguageSparql);
1066-
1067- d->self.setProperty(NAO::lastModified(), QDateTime::currentDateTime());
1068-
1069- while (it.next()) {
1070- Nepomuk::Resource result(it[0].uri());
1071- QDateTime eventStart = result.property(NUAO::start()).toDateTime();
1072- QDateTime eventEnd = result.property(NUAO::end()).toDateTime();
1073-
1074- if (!eventStart.isValid()) continue;
1075-
1076- if (!eventEnd.isValid()) {
1077- // If the end was not saved, we are treating it as a simple
1078- // Accessed event
1079- eventEnd = eventStart;
1080- }
1081-
1082- int intervalLength = eventStart.secsTo(eventEnd);
1083-
1084- if (intervalLength == 0) {
1085- // We have an Accessed event - otherwise, this wouldn't be 0
1086-
1087- score += d->timeFactor(eventEnd); // like it is open for 1 minute
1088-
1089- } else if (intervalLength >= 4) {
1090- // Ignoring stuff that was open for less than 4 seconds
1091-
1092- score += d->timeFactor(eventEnd) * intervalLength / 60.0;
1093- }
1094-
1095- kDebug() << result.resourceUri() << eventStart << eventEnd << intervalLength;
1096-
1097- }
1098-
1099- kDebug() << "New calculated score:" << score << d->self.isValid();
1100- d->self.setProperty(KExt::cachedScore(), score);
1101- d->self.setProperty(NAO::score(), score);
1102-}
1103diff --git a/activitymanager/NepomukResourceScoreCache.h b/activitymanager/NepomukResourceScoreCache.h
1104deleted file mode 100644
1105index a26b5a2..0000000
1106--- a/activitymanager/NepomukResourceScoreCache.h
1107+++ /dev/null
1108@@ -1,42 +0,0 @@
1109-/*
1110- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
1111- *
1112- * This program is free software; you can redistribute it and/or modify
1113- * it under the terms of the GNU General Public License version 2,
1114- * or (at your option) any later version, as published by the Free
1115- * Software Foundation
1116- *
1117- * This program is distributed in the hope that it will be useful,
1118- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1119- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1120- * GNU General Public License for more details
1121- *
1122- * You should have received a copy of the GNU General Public
1123- * License along with this program; if not, write to the
1124- * Free Software Foundation, Inc.,
1125- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1126- */
1127-
1128-#ifndef NEPOMUK_RESOURCE_SCORE_CACHE_H_
1129-#define NEPOMUK_RESOURCE_SCORE_CACHE_H_
1130-
1131-#include <QString>
1132-#include <QUrl>
1133-
1134-class NepomukResourceScoreCachePrivate;
1135-
1136-/**
1137- *
1138- */
1139-class NepomukResourceScoreCache {
1140-public:
1141- NepomukResourceScoreCache(const QString & activity, const QString & application, const QUrl & resource);
1142- virtual ~NepomukResourceScoreCache();
1143-
1144- void updateScore();
1145-
1146-private:
1147- class NepomukResourceScoreCachePrivate * const d;
1148-};
1149-
1150-#endif // NEPOMUK_RESOURCE_SCORE_CACHE_H_
1151diff --git a/activitymanager/NepomukResourceScoreMaintainer.cpp b/activitymanager/NepomukResourceScoreMaintainer.cpp
1152deleted file mode 100644
1153index f5e4d3c..0000000
1154--- a/activitymanager/NepomukResourceScoreMaintainer.cpp
1155+++ /dev/null
1156@@ -1,145 +0,0 @@
1157-/*
1158- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
1159- *
1160- * This program is free software; you can redistribute it and/or modify
1161- * it under the terms of the GNU General Public License version 2,
1162- * or (at your option) any later version, as published by the Free
1163- * Software Foundation
1164- *
1165- * This program is distributed in the hope that it will be useful,
1166- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1167- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1168- * GNU General Public License for more details
1169- *
1170- * You should have received a copy of the GNU General Public
1171- * License along with this program; if not, write to the
1172- * Free Software Foundation, Inc.,
1173- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1174- */
1175-
1176-#include "NepomukResourceScoreMaintainer.h"
1177-
1178-#include <QList>
1179-#include <QMutex>
1180-#include <QThread>
1181-
1182-#include <KDebug>
1183-
1184-#include <Nepomuk/Resource>
1185-
1186-#include <time.h>
1187-#include "kext.h"
1188-
1189-#include "ActivityManager.h"
1190-#include "NepomukResourceScoreCache.h"
1191-
1192-class NepomukResourceScoreMaintainerPrivate: public QThread {
1193-public:
1194- typedef QString ApplicationName;
1195- typedef QString ActivityID;
1196- typedef QList < QUrl > ResourceList;
1197-
1198- typedef QMap < ApplicationName, ResourceList > Applications;
1199- typedef QMap < ActivityID, Applications > ResourceTree;
1200-
1201- ResourceTree openResources;
1202- QMutex openResources_mutex;
1203-
1204- void run();
1205- void processActivity(const ActivityID & activity, const Applications & applications);
1206-
1207- static NepomukResourceScoreMaintainer * s_instance;
1208-
1209-};
1210-
1211-NepomukResourceScoreMaintainer * NepomukResourceScoreMaintainerPrivate::s_instance = NULL;
1212-
1213-void NepomukResourceScoreMaintainerPrivate::run()
1214-{
1215- forever {
1216- // initial delay before processing the resources
1217- sleep(5);
1218-
1219- NepomukResourceScoreMaintainerPrivate::openResources_mutex.lock();
1220- ResourceTree resources = openResources;
1221- openResources.clear();
1222- NepomukResourceScoreMaintainerPrivate::openResources_mutex.unlock();
1223-
1224- const QString & activity = ActivityManager::self()->CurrentActivity();
1225-
1226- // Let us first process the events related to the current
1227- // activity so that the stats are available quicker
1228-
1229- if (resources.contains(activity)) {
1230- kDebug() << "Processing current activity events";
1231-
1232- processActivity(activity, resources[activity]);
1233- resources.remove(activity);
1234- }
1235-
1236- foreach (const ActivityID & activity, resources.keys()) {
1237- kDebug() << "Processing activity" << activity;
1238-
1239- processActivity(activity, resources[activity]);
1240- }
1241- }
1242-}
1243-
1244-void NepomukResourceScoreMaintainerPrivate::processActivity(const ActivityID & activity, const Applications & applications)
1245-{
1246- foreach (const ApplicationName & application, applications.keys()) {
1247- // Processing resources for the pair (activity, application)
1248- kDebug() << " Processing application" << application;
1249-
1250- foreach (const QUrl & resource, applications[application]) {
1251- kDebug() << " Updating score for" << activity, application, resource;
1252- NepomukResourceScoreCache(activity, application, resource).updateScore();
1253-
1254- }
1255- }
1256-}
1257-
1258-NepomukResourceScoreMaintainer * NepomukResourceScoreMaintainer::self()
1259-{
1260- if (!NepomukResourceScoreMaintainerPrivate::s_instance) {
1261- NepomukResourceScoreMaintainerPrivate::s_instance = new NepomukResourceScoreMaintainer();
1262- }
1263-
1264- return NepomukResourceScoreMaintainerPrivate::s_instance;
1265-}
1266-
1267-NepomukResourceScoreMaintainer::NepomukResourceScoreMaintainer()
1268- : d(new NepomukResourceScoreMaintainerPrivate())
1269-{
1270-}
1271-
1272-NepomukResourceScoreMaintainer::~NepomukResourceScoreMaintainer()
1273-{
1274- delete d;
1275-}
1276-
1277-void NepomukResourceScoreMaintainer::processResource(const KUrl & resource, const QString & application)
1278-{
1279- d->openResources_mutex.lock();
1280-
1281- // Checking whether the item is already scheduled for
1282- // processing
1283-
1284- kDebug() << "Adding" << resource << application << "to the queue";
1285-
1286- const QString & activity = ActivityManager::self()->CurrentActivity();
1287-
1288- if (d->openResources.contains(activity) &&
1289- d->openResources[activity].contains(application) &&
1290- d->openResources[activity][application].contains(resource)) {
1291- return;
1292- }
1293-
1294- d->openResources[activity][application] << resource;
1295-
1296- d->openResources_mutex.unlock();
1297-
1298- d->start();
1299-}
1300-
1301-
1302diff --git a/activitymanager/NepomukResourceScoreMaintainer.h b/activitymanager/NepomukResourceScoreMaintainer.h
1303deleted file mode 100644
1304index cbef9f9..0000000
1305--- a/activitymanager/NepomukResourceScoreMaintainer.h
1306+++ /dev/null
1307@@ -1,47 +0,0 @@
1308-/*
1309- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
1310- *
1311- * This program is free software; you can redistribute it and/or modify
1312- * it under the terms of the GNU General Public License version 2,
1313- * or (at your option) any later version, as published by the Free
1314- * Software Foundation
1315- *
1316- * This program is distributed in the hope that it will be useful,
1317- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1318- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1319- * GNU General Public License for more details
1320- *
1321- * You should have received a copy of the GNU General Public
1322- * License along with this program; if not, write to the
1323- * Free Software Foundation, Inc.,
1324- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1325- */
1326-
1327-#ifndef NEPOMUK_RESOURCE_SCORE_MAINTAINER_H_
1328-#define NEPOMUK_RESOURCE_SCORE_MAINTAINER_H_
1329-
1330-#include <QThread>
1331-#include <Nepomuk/Resource>
1332-
1333-#include "Event.h"
1334-
1335-class NepomukResourceScoreMaintainerPrivate;
1336-
1337-/**
1338- * Thread to process desktop/usage events
1339- */
1340-class NepomukResourceScoreMaintainer {
1341-public:
1342- static NepomukResourceScoreMaintainer * self();
1343-
1344- virtual ~NepomukResourceScoreMaintainer();
1345-
1346- void processResource(const KUrl & resource, const QString & application);
1347-
1348-private:
1349- NepomukResourceScoreMaintainer();
1350-
1351- class NepomukResourceScoreMaintainerPrivate * const d;
1352-};
1353-
1354-#endif // NEPOMUK_RESOURCE_SCORE_MAINTAINER_H_
1355diff --git a/activitymanager/Plugin.cpp b/activitymanager/Plugin.cpp
1356new file mode 100644
1357index 0000000..e1f9bc9
1358--- /dev/null
1359+++ b/activitymanager/Plugin.cpp
1360@@ -0,0 +1,56 @@
1361+/*
1362+ * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
1363+ *
1364+ * This program is free software; you can redistribute it and/or modify
1365+ * it under the terms of the GNU General Public License version 2,
1366+ * or (at your option) any later version, as published by the Free
1367+ * Software Foundation
1368+ *
1369+ * This program is distributed in the hope that it will be useful,
1370+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1371+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1372+ * GNU General Public License for more details
1373+ *
1374+ * You should have received a copy of the GNU General Public
1375+ * License along with this program; if not, write to the
1376+ * Free Software Foundation, Inc.,
1377+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1378+ */
1379+
1380+#include "Plugin.h"
1381+
1382+class Plugin::Private {
1383+public:
1384+ SharedInfo * sharedInfo;
1385+};
1386+
1387+Plugin::Plugin(QObject * parent)
1388+ : QObject(parent), d(new Private())
1389+{
1390+}
1391+
1392+Plugin::~Plugin()
1393+{
1394+ delete d;
1395+}
1396+
1397+void Plugin::addEvents(const EventList & events)
1398+{
1399+ Q_UNUSED(events)
1400+}
1401+
1402+void Plugin::setResourceMimeType(const QString & uri, const QString & mimetype)
1403+{
1404+ Q_UNUSED(uri)
1405+ Q_UNUSED(mimetype)
1406+}
1407+
1408+void Plugin::setSharedInfo(SharedInfo * sharedInfo)
1409+{
1410+ d->sharedInfo = sharedInfo;
1411+}
1412+
1413+SharedInfo * Plugin::sharedInfo() const
1414+{
1415+ return d->sharedInfo;
1416+}
1417diff --git a/activitymanager/Plugin.h b/activitymanager/Plugin.h
1418new file mode 100644
1419index 0000000..cdf8b7f
1420--- /dev/null
1421+++ b/activitymanager/Plugin.h
1422@@ -0,0 +1,59 @@
1423+/*
1424+ * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
1425+ *
1426+ * This program is free software; you can redistribute it and/or modify
1427+ * it under the terms of the GNU General Public License version 2,
1428+ * or (at your option) any later version, as published by the Free
1429+ * Software Foundation
1430+ *
1431+ * This program is distributed in the hope that it will be useful,
1432+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1433+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1434+ * GNU General Public License for more details
1435+ *
1436+ * You should have received a copy of the GNU General Public
1437+ * License along with this program; if not, write to the
1438+ * Free Software Foundation, Inc.,
1439+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1440+ */
1441+
1442+#ifndef EVENT_BACKEND_H_
1443+#define EVENT_BACKEND_H_
1444+
1445+#include <EventProcessor.h>
1446+
1447+#include <kdemacros.h>
1448+#include <KPluginFactory>
1449+#include <KPluginLoader>
1450+
1451+#include "Event.h"
1452+#include "SharedInfo.h"
1453+
1454+#define KAMD_EXPORT_PLUGIN(ClassName, AboutData) \
1455+ K_PLUGIN_FACTORY(ClassName##Factory, registerPlugin<ClassName>();) \
1456+ K_EXPORT_PLUGIN(ClassName##Factory("AboutData"))
1457+
1458+
1459+/**
1460+ *
1461+ */
1462+class KDE_EXPORT Plugin: public QObject {
1463+ Q_OBJECT
1464+
1465+public:
1466+ Plugin(QObject * parent);
1467+ virtual ~Plugin();
1468+
1469+ virtual void addEvents(const EventList & events);
1470+ virtual void setResourceMimeType(const QString & uri, const QString & mimetype);
1471+
1472+ virtual void setSharedInfo(SharedInfo * sharedInfo);
1473+ SharedInfo * sharedInfo() const;
1474+
1475+private:
1476+ class Private;
1477+ Private * const d;
1478+};
1479+
1480+#endif // EVENT_BACKEND_H_
1481+
1482diff --git a/activitymanager/SharedInfo.cpp b/activitymanager/SharedInfo.cpp
1483index 8c71c34..1948075 100644
1484--- a/activitymanager/SharedInfo.cpp
1485+++ b/activitymanager/SharedInfo.cpp
1486@@ -18,6 +18,9 @@
1487 */
1488
1489 #include "SharedInfo.h"
1490+#include "ActivityManager.h"
1491+
1492+#include <KDebug>
1493
1494 SharedInfo * SharedInfo::s_instance = NULL;
1495
1496@@ -25,12 +28,15 @@ SharedInfo * SharedInfo::self()
1497 {
1498 if (!s_instance) {
1499 s_instance = new SharedInfo();
1500+
1501+ kDebug() << "SHARED INFO" << (void*) s_instance;
1502 }
1503
1504 return s_instance;
1505 }
1506
1507 SharedInfo::SharedInfo()
1508+ : m_config("activitymanager-pluginsrc")
1509 {
1510 }
1511
1512@@ -48,4 +54,18 @@ QHash < KUrl, SharedInfo::ResourceData > const & SharedInfo::resources() const
1513 return m_resources;
1514 }
1515
1516+QString SharedInfo::currentActivity() const
1517+{
1518+ return m_currentActivity;
1519+}
1520+
1521+void SharedInfo::setCurrentActivity(const QString & activity)
1522+{
1523+ m_currentActivity = activity;
1524+}
1525+
1526+KConfigGroup SharedInfo::pluginConfig(const QString & pluginName) const
1527+{
1528+ return KConfigGroup(&m_config, pluginName);
1529+}
1530
1531diff --git a/activitymanager/SharedInfo.h b/activitymanager/SharedInfo.h
1532index 6e60612..77f5683 100644
1533--- a/activitymanager/SharedInfo.h
1534+++ b/activitymanager/SharedInfo.h
1535@@ -25,6 +25,9 @@
1536 #include <QString>
1537 #include <QHash>
1538
1539+#include <KConfigGroup>
1540+#include <KConfig>
1541+
1542 #include "Event.h"
1543
1544 /**
1545@@ -32,8 +35,6 @@
1546 */
1547 class SharedInfo {
1548 public:
1549- static SharedInfo * self();
1550-
1551 virtual ~SharedInfo();
1552
1553 struct WindowData {
1554@@ -50,14 +51,26 @@ public:
1555 QHash < WId, WindowData > const & windows() const;
1556 QHash < KUrl, ResourceData > const & resources() const;
1557
1558+ QString currentActivity() const;
1559+
1560+ KConfigGroup pluginConfig(const QString & pluginName) const;
1561+
1562 private:
1563+ static SharedInfo * self();
1564+
1565+ void setCurrentActivity(const QString & activity);
1566+
1567 QHash < WId, WindowData > m_windows;
1568 QHash < KUrl, ResourceData > m_resources;
1569+ QString m_currentActivity;
1570+ KConfig m_config;
1571
1572 static SharedInfo * s_instance;
1573 SharedInfo();
1574
1575 friend class ActivityManager;
1576+ friend class ActivityManagerPrivate;
1577+ friend class EventProcessor;
1578 };
1579
1580 #endif // SHARED_INFO_H_
1581diff --git a/activitymanager/SlcEventBackend.cpp b/activitymanager/SlcEventBackend.cpp
1582deleted file mode 100644
1583index fe8f01d..0000000
1584--- a/activitymanager/SlcEventBackend.cpp
1585+++ /dev/null
1586@@ -1,127 +0,0 @@
1587-/*
1588- * Copyright (C) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
1589- *
1590- * This program is free software; you can redistribute it and/or modify
1591- * it under the terms of the GNU General Public License version 2,
1592- * or (at your option) any later version, as published by the Free
1593- * Software Foundation
1594- *
1595- * This program is distributed in the hope that it will be useful,
1596- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1597- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1598- * GNU General Public License for more details
1599- *
1600- * You should have received a copy of the GNU General Public
1601- * License along with this program; if not, write to the
1602- * Free Software Foundation, Inc.,
1603- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1604- */
1605-
1606-#include "SlcEventBackend.h"
1607-#include "slcadaptor.h"
1608-
1609-#include <QDBusConnection>
1610-#include <KDebug>
1611-#include <KWindowSystem>
1612-#include <KUrl>
1613-
1614-#include "SharedInfo.h"
1615-
1616-SlcEventBackend::SlcEventBackend()
1617- : focussedWindow(0)
1618-{
1619- QDBusConnection dbus = QDBusConnection::sessionBus();
1620- new SLCAdaptor(this);
1621- dbus.registerObject("/SLC", this);
1622-
1623- connect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)),
1624- this, SLOT(activeWindowChanged(WId)));
1625-}
1626-
1627-void SlcEventBackend::addEvents(const EventList & events)
1628-{
1629- foreach (const Event & event, events) {
1630- switch (event.type) {
1631- case Event::FocussedIn:
1632- case Event::Opened:
1633- // kDebug() << "Event::FocussedIn" << focussedWindow << event.wid << event.uri;
1634-
1635- lastFocussedResource[event.wid] = event.uri;
1636-
1637- if (event.wid == focussedWindow) {
1638- updateFocus(focussedWindow);
1639- }
1640-
1641- break;
1642-
1643- case Event::FocussedOut:
1644- case Event::Closed:
1645- // kDebug() << "Event::FocussedOut" << focussedWindow << event.wid << event.uri;
1646-
1647- if (lastFocussedResource[event.wid] == event.uri) {
1648- lastFocussedResource[event.wid] = KUrl();
1649- }
1650-
1651- if (event.wid == focussedWindow) {
1652- updateFocus();
1653- }
1654-
1655- break;
1656-
1657- default:
1658- // nothing
1659- break;
1660- }
1661- }
1662-}
1663-
1664-KUrl SlcEventBackend::_focussedResourceURI()
1665-{
1666- KUrl kuri;
1667-
1668- if (lastFocussedResource.contains(focussedWindow)) {
1669- kuri = lastFocussedResource[focussedWindow];
1670- } else {
1671- foreach (const KUrl & uri, SharedInfo::self()->windows()[focussedWindow].resources) {
1672- kuri = uri;
1673- break;
1674- }
1675- }
1676-
1677- return kuri;
1678-}
1679-
1680-QString SlcEventBackend::focussedResourceURI()
1681-{
1682- return _focussedResourceURI().url();
1683-}
1684-
1685-QString SlcEventBackend::focussedResourceMimetype()
1686-{
1687- return SharedInfo::self()->resources().contains(_focussedResourceURI()) ?
1688- SharedInfo::self()->resources()[_focussedResourceURI()].mimetype : QString();
1689-}
1690-
1691-void SlcEventBackend::activeWindowChanged(WId wid)
1692-{
1693- if (wid == focussedWindow) return;
1694-
1695- focussedWindow = wid;
1696-
1697- updateFocus(wid);
1698-}
1699-
1700-void SlcEventBackend::updateFocus(WId wid)
1701-{
1702- // kDebug() << "Updating focus for " << wid;
1703-
1704- if (wid == 0 || !SharedInfo::self()->windows().contains(wid)) {
1705- // kDebug() << "Clearing focus";
1706- emit focusChanged(QString(), QString());
1707-
1708- } else if (wid == focussedWindow) {
1709- // kDebug() << "It is the currently focussed window";
1710- emit focusChanged(focussedResourceURI(), SharedInfo::self()->resources()[_focussedResourceURI()].mimetype);
1711-
1712- }
1713-}
1714diff --git a/activitymanager/SlcEventBackend.h b/activitymanager/SlcEventBackend.h
1715deleted file mode 100644
1716index 3c79792..0000000
1717--- a/activitymanager/SlcEventBackend.h
1718+++ /dev/null
1719@@ -1,59 +0,0 @@
1720-/*
1721- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
1722- *
1723- * This program is free software; you can redistribute it and/or modify
1724- * it under the terms of the GNU General Public License version 2,
1725- * or (at your option) any later version, as published by the Free
1726- * Software Foundation
1727- *
1728- * This program is distributed in the hope that it will be useful,
1729- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1730- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1731- * GNU General Public License for more details
1732- *
1733- * You should have received a copy of the GNU General Public
1734- * License along with this program; if not, write to the
1735- * Free Software Foundation, Inc.,
1736- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1737- */
1738-
1739-#ifndef SLC_EVENT_BACKEND_H_
1740-#define SLC_EVENT_BACKEND_H_
1741-
1742-#include "EventBackend.h"
1743-
1744-#include <QObject>
1745-#include <KUrl>
1746-
1747-/**
1748- *
1749- */
1750-class SlcEventBackend: public QObject, public EventBackend {
1751- Q_OBJECT
1752- Q_CLASSINFO("D-Bus Interface", "org.kde.ActivityManager.SLC")
1753-
1754-public:
1755- SlcEventBackend();
1756-
1757- virtual void addEvents(const EventList & events);
1758-
1759-private Q_SLOTS:
1760- void activeWindowChanged(WId windowId);
1761-
1762-public Q_SLOTS:
1763- QString focussedResourceURI();
1764- QString focussedResourceMimetype();
1765-
1766-Q_SIGNALS:
1767- void focusChanged(const QString & uri, const QString & mimetype);
1768-
1769-private:
1770- void updateFocus(WId wid = 0);
1771-
1772- WId focussedWindow;
1773- KUrl _focussedResourceURI();
1774- QHash < WId, KUrl > lastFocussedResource;
1775-};
1776-
1777-#endif // SLC_EVENT_BACKEND_H_
1778-
1779diff --git a/activitymanager/ZeitgeistEventBackend.cpp b/activitymanager/ZeitgeistEventBackend.cpp
1780deleted file mode 100644
1781index 1bbd050..0000000
1782--- a/activitymanager/ZeitgeistEventBackend.cpp
1783+++ /dev/null
1784@@ -1,95 +0,0 @@
1785-/*
1786- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
1787- *
1788- * This program is free software; you can redistribute it and/or modify
1789- * it under the terms of the GNU General Public License version 2,
1790- * or (at your option) any later version, as published by the Free
1791- * Software Foundation
1792- *
1793- * This program is distributed in the hope that it will be useful,
1794- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1795- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1796- * GNU General Public License for more details
1797- *
1798- * You should have received a copy of the GNU General Public
1799- * License along with this program; if not, write to the
1800- * Free Software Foundation, Inc.,
1801- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1802- */
1803-
1804-#include "config-features.h"
1805-
1806-#ifndef HAVE_QZEITGEIST
1807-#ifdef __GNUC__
1808- #warning "No QtZeitgeist, disabling desktop events processing"
1809-#endif
1810-
1811-#else // HAVE_QZEITGEIST
1812-
1813-#include "ZeitgeistEventBackend.h"
1814-
1815-#include <QtZeitgeist/QtZeitgeist>
1816-#include <QtZeitgeist/Interpretation>
1817-#include <QtZeitgeist/Manifestation>
1818-
1819-static QString eventInterpretation(Event::Type type)
1820-{
1821- // switch (type) {
1822- // case Event::Accessed:
1823- // return QtZeitgeist::Interpretation::Event::ZGAccessEvent;
1824-
1825- // case Event::Opened:
1826- // return QtZeitgeist::Interpretation::Event::ZGAccessEvent;
1827-
1828- // case Event::Modified:
1829- // return QtZeitgeist::Interpretation::Event::ZGModifyEvent;
1830-
1831- // case Event::Closed:
1832- // return QtZeitgeist::Interpretation::Event::ZGLeaveEvent;
1833-
1834- // }
1835-
1836- // shut up GCC
1837- return QString();
1838-}
1839-
1840-static QString eventManifestation(Event::Reason reason)
1841-{
1842- // switch (reason) {
1843- // case Event::User:
1844- // return QtZeitgeist::Manifestation::Event::ZGUserActivity;
1845-
1846- // case Event::Heuristic:
1847- // return QtZeitgeist::Manifestation::Event::ZGHeuristicActivity;
1848-
1849- // case Event::Scheduled:
1850- // return QtZeitgeist::Manifestation::Event::ZGScheduledActivity;
1851-
1852- // case Event::System:
1853- // return QtZeitgeist::Manifestation::Event::ZGSystemNotification;
1854-
1855- // case Event::World:
1856- // return QtZeitgeist::Manifestation::Event::ZGWorldActivity;
1857- // }
1858-
1859- // shut up GCC
1860- return QtZeitgeist::Manifestation::Event::ZGUserActivity;
1861-}
1862-
1863-static QString applicationUri(const QString & application)
1864-{
1865- // TODO: Make this correct
1866- return "app://" + application + ".desktop";
1867-}
1868-
1869-ZeitgeistEventBackend::ZeitgeistEventBackend()
1870-{
1871- QtZeitgeist::init();
1872-}
1873-
1874-void ZeitgeistEventBackend::addEvents(const EventList & events)
1875-{
1876-
1877-}
1878-
1879-#endif // HAVE_QZEITGEIST
1880diff --git a/activitymanager/ZeitgeistEventBackend.h b/activitymanager/ZeitgeistEventBackend.h
1881deleted file mode 100644
1882index 1b5fab7..0000000
1883--- a/activitymanager/ZeitgeistEventBackend.h
1884+++ /dev/null
1885@@ -1,39 +0,0 @@
1886-/*
1887- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
1888- *
1889- * This program is free software; you can redistribute it and/or modify
1890- * it under the terms of the GNU General Public License version 2,
1891- * or (at your option) any later version, as published by the Free
1892- * Software Foundation
1893- *
1894- * This program is distributed in the hope that it will be useful,
1895- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1896- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1897- * GNU General Public License for more details
1898- *
1899- * You should have received a copy of the GNU General Public
1900- * License along with this program; if not, write to the
1901- * Free Software Foundation, Inc.,
1902- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1903- */
1904-
1905-#ifndef ZEITGEIST_EVENT_BACKEND_H_
1906-#define ZEITGEIST_EVENT_BACKEND_H_
1907-
1908-#include "EventBackend.h"
1909-
1910-/**
1911- *
1912- */
1913-class ZeitgeistEventBackend: public EventBackend {
1914-public:
1915- ZeitgeistEventBackend();
1916-
1917- virtual void addEvents(const EventList & events);
1918-
1919-private:
1920- /* data */
1921-};
1922-
1923-#endif // ZEITGEIST_EVENT_BACKEND_H_
1924-
1925diff --git a/activitymanager/activitymanager-plugin.desktop b/activitymanager/activitymanager-plugin.desktop
1926new file mode 100644
1927index 0000000..f7a068f
1928--- /dev/null
1929+++ b/activitymanager/activitymanager-plugin.desktop
1930@@ -0,0 +1,12 @@
1931+[Desktop Entry]
1932+Type=ServiceType
1933+X-KDE-ServiceType=ActivityManager/Plugin
1934+
1935+Comment=Activity manager plugin
1936+
1937+[PropertyDef::X-ActivityManager-PluginType]
1938+Type=QString
1939+
1940+[PropertyDef::X-ActivityManager-PluginOverrides]
1941+Type=QString
1942+
1943diff --git a/activitymanager/krso.trig b/activitymanager/krso.trig
1944new file mode 100644
1945index 0000000..a74aa69
1946--- /dev/null
1947+++ b/activitymanager/krso.trig
1948@@ -0,0 +1,100 @@
1949+#
1950+# Copyright (c) 2011 Ivan Cukic <ivan.cukic@kde.org>
1951+# All rights reserved, licensed under either CC-BY or BSD.
1952+#
1953+# You are free:
1954+# * to Share - to copy, distribute and transmit the work
1955+# * to Remix - to adapt the work
1956+# Under the following conditions:
1957+# * Attribution - You must attribute the work in the manner specified by the author
1958+# or licensor (but not in any way that suggests that they endorse you or your use
1959+# of the work).
1960+#
1961+# Redistribution and use in source and binary forms, with or without modification,
1962+# are permitted provided that the following conditions are met:
1963+# * Redistributions of source code must retain the above copyright notice, this
1964+# list of conditions and the following disclaimer.
1965+# * Redistributions in binary form must reproduce the above copyright notice, this
1966+# list of conditions and the following disclaimer in the documentation and/or
1967+# other materials provided with the distribution.
1968+# * Neither the names of the authors nor the names of contributors may
1969+# be used to endorse or promote products derived from this ontology without
1970+# specific prior written permission.
1971+#
1972+# THIS ONTOLOGY IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1973+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1974+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1975+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1976+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1977+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1978+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1979+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1980+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
1981+# THIS ONTOLOGY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1982+#
1983+
1984+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
1985+@prefix nao: <http://www.semanticdesktop.org/ontologies/2007/08/15/nao#> .
1986+@prefix nrl: <http://www.semanticdesktop.org/ontologies/2007/08/15/nrl#> .
1987+@prefix nie: <http://www.semanticdesktop.org/ontologies/2007/01/19/nie#> .
1988+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
1989+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
1990+@prefix krso: <http://nepomuk.kde.org/ontologies/2011/06/17/krso#> .
1991+@prefix nfo: <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#> .
1992+
1993+krso: {
1994+ krso:ResourceScoreCache
1995+ a rdfs:Class ;
1996+ rdfs:subClassOf rdfs:Resource ;
1997+ rdfs:label "Resource score cache" ;
1998+ rdfs:comment "For storing the automatically calculated score based on the usage statistics" ;
1999+ nao:userVisible false .
2000+
2001+ krso:targettedResource
2002+ a rdf:Property ;
2003+ rdfs:comment "Resource for which the score is calculated." ;
2004+ rdfs:domain krso:ResourceScoreCache ;
2005+ rdfs:label "resource" ;
2006+ rdfs:range rdfs:Resource .
2007+
2008+ krso:initiatingAgent
2009+ a rdf:Property ;
2010+ rdfs:comment "Relates the score to the agent initiating the events." ;
2011+ rdfs:domain krso:ResourceScoreCache ;
2012+ rdfs:label "involved agent" ;
2013+ rdfs:range nao:Agent .
2014+
2015+ krso:involvesActivity
2016+ a rdf:Property ;
2017+ rdfs:comment "Relates the score to the activity in which the events happened." ;
2018+ rdfs:domain krso:ResourceScoreCache ;
2019+ rdfs:label "involved activity" ;
2020+ rdfs:range krso:Activity .
2021+
2022+ krso:cachedScore
2023+ a rdf:Property ;
2024+ rdfs:subPropertyOf nao:score ;
2025+ rdfs:comment "The automatically calculated score" ;
2026+ rdfs:domain krso:ResourceScoreCache ;
2027+ rdfs:label "calculated score" ;
2028+ rdfs:range xsd:float .
2029+}
2030+
2031+<http://nepomuk.kde.org/ontologies/2011/06/17/krso/metadata> {
2032+ <http://nepomuk.kde.org/ontologies/2011/06/17/krso/metadata>
2033+ a nrl:GraphMetadata ;
2034+ nrl:coreGraphMetadataFor krso: .
2035+
2036+
2037+ krso:
2038+ a nrl:Ontology , nrl:DocumentGraph ;
2039+ nao:prefLabel "KDE Resource Scoring Ontology" ;
2040+ nao:hasDefaultNamespace "http://nepomuk.kde.org/ontologies/2011/06/17/krso#" ;
2041+ nao:hasDefaultNamespaceAbbreviation "krso" ;
2042+ nao:lastModified "2011-06-17T11:00:43Z" ;
2043+ nao:serializationLanguage "TriG" ;
2044+ nao:status "Unstable" ;
2045+ nrl:updatable "0" ;
2046+ nao:version "2" .
2047+}
2048+
2049diff --git a/activitymanager/ontologies/CMakeLists.txt b/activitymanager/ontologies/CMakeLists.txt
2050deleted file mode 100644
2051index 838b1f4..0000000
2052--- a/activitymanager/ontologies/CMakeLists.txt
2053+++ /dev/null
2054@@ -1,8 +0,0 @@
2055-project(nepomuk_ontologies)
2056-
2057-configure_file(kamdrso.ontology.in ${CMAKE_CURRENT_BINARY_DIR}/kamdrso.ontology)
2058-
2059-install(FILES
2060- kamdrso.trig
2061- ${CMAKE_CURRENT_BINARY_DIR}/kamdrso.ontology
2062-DESTINATION ${CMAKE_INSTALL_PREFIX}/share/ontology/kde)
2063diff --git a/activitymanager/ontologies/kamdrso.ontology.in b/activitymanager/ontologies/kamdrso.ontology.in
2064deleted file mode 100644
2065index 032dac0..0000000
2066--- a/activitymanager/ontologies/kamdrso.ontology.in
2067+++ /dev/null
2068@@ -1,8 +0,0 @@
2069-[Ontology]
2070-Version=1.0
2071-Name=KDE Activity Manager Daemon - Resource Scoring Ontology
2072-Comment=The KDE Resource Scoring Ontology contains classes related to KAMD's scoring mechanisms
2073-Namespace=http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso#" ;
2074-Path=${CMAKE_INSTALL_PREFIX}/share/ontology/kde/kamdrso.trig
2075-MimeType=application/x-trig
2076-Type=Data
2077diff --git a/activitymanager/ontologies/kamdrso.trig b/activitymanager/ontologies/kamdrso.trig
2078deleted file mode 100644
2079index b968231..0000000
2080--- a/activitymanager/ontologies/kamdrso.trig
2081+++ /dev/null
2082@@ -1,112 +0,0 @@
2083-#
2084-# Copyright (c) 2011 Ivan Cukic <ivan.cukic@kde.org>
2085-# All rights reserved, licensed under either CC-BY or BSD.
2086-#
2087-# You are free:
2088-# * to Share - to copy, distribute and transmit the work
2089-# * to Remix - to adapt the work
2090-# Under the following conditions:
2091-# * Attribution - You must attribute the work in the manner specified by the author
2092-# or licensor (but not in any way that suggests that they endorse you or your use
2093-# of the work).
2094-#
2095-# Redistribution and use in source and binary forms, with or without modification,
2096-# are permitted provided that the following conditions are met:
2097-# * Redistributions of source code must retain the above copyright notice, this
2098-# list of conditions and the following disclaimer.
2099-# * Redistributions in binary form must reproduce the above copyright notice, this
2100-# list of conditions and the following disclaimer in the documentation and/or
2101-# other materials provided with the distribution.
2102-# * Neither the names of the authors nor the names of contributors may
2103-# be used to endorse or promote products derived from this ontology without
2104-# specific prior written permission.
2105-#
2106-# THIS ONTOLOGY IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2107-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2108-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2109-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2110-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2111-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2112-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2113-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2114-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2115-# THIS ONTOLOGY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2116-#
2117-
2118-@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
2119-@prefix nao: <http://www.semanticdesktop.org/ontologies/2007/08/15/nao#> .
2120-@prefix nrl: <http://www.semanticdesktop.org/ontologies/2007/08/15/nrl#> .
2121-@prefix nie: <http://www.semanticdesktop.org/ontologies/2007/01/19/nie#> .
2122-@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
2123-@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
2124-@prefix kamdrso: <http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso#> .
2125-@prefix nfo: <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#> .
2126-
2127-kamdrso: {
2128- kamdrso:unixFileMode
2129- a rdf:Property ;
2130- rdfs:label "Unix file mode" ;
2131- rdfs:comment "The file mode value as seen on unix file systems." ;
2132- rdfs:domain nfo:FileDataObject ;
2133- rdfs:range xsd:integer ;
2134- nao:userVisible false .
2135-
2136- kamdrso:unixFileOwner
2137- a rdf:Property ;
2138- rdfs:label "Unix file owner" ;
2139- rdfs:comment "The owner of the file as seen on unix file systems. This is intended as the low-level counterpart to nfo:owner." ;
2140- rdfs:domain nfo:FileDataObject ;
2141- rdfs:range xsd:string ;
2142- nao:userVisible false .
2143-
2144- kamdrso:unixFileGroup
2145- a rdf:Property ;
2146- rdfs:label "Unix file group" ;
2147- rdfs:comment "The group of the file as seen on unix file systems." ;
2148- rdfs:domain nfo:FileDataObject ;
2149- rdfs:range xsd:string ;
2150- nao:userVisible false .
2151-
2152- kamdrso:Activity
2153- a rdfs:Class ;
2154- rdfs:subClassOf rdfs:Resource ;
2155- rdfs:label "activity" ;
2156- rdfs:comment "A Plasma activity." .
2157-
2158- kamdrso:usedActivity
2159- a rdf:Property ;
2160- rdfs:label "used activity" ;
2161- rdfs:comment "The activity that was active when resource was created. This is mostly used for graphs or desktop events." ;
2162- rdfs:domain rdfs:Resource ;
2163- rdfs:range kamdrso:Activity ;
2164- nao:userVisible false .
2165-
2166- kamdrso:activityIdentifier
2167- a rdf:Property ;
2168- rdfs:subPropertyOf nao:identifier ;
2169- rdfs:label "activity identifier" ;
2170- rdfs:comment "The unique ID of the activity as used outside of Nepomuk. Typically this is a UUID." ;
2171- rdfs:domain kamdrso:Activity ;
2172- rdfs:range xsd:string ;
2173- nao:userVisible false .
2174-
2175-}
2176-
2177-<http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso/metadata> {
2178- <http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso/metadata>
2179- a nrl:GraphMetadata ;
2180- nrl:coreGraphMetadataFor kamdrso: .
2181-
2182-
2183- kamdrso:
2184- a nrl:Ontology , nrl:DocumentGraph ;
2185- nao:prefLabel "KDE Extensions Ontology" ;
2186- nao:hasDefaultNamespace "http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso#" ;
2187- nao:hasDefaultNamespaceAbbreviation "kamdrso" ;
2188- nao:lastModified "2011-06-02T12:31:43Z" ;
2189- nao:serializationLanguage "TriG" ;
2190- nao:status "Unstable" ;
2191- nrl:updatable "0" ;
2192- nao:version "2" .
2193-}
2194-
2195diff --git a/activitymanager/org.kde.ActivityManager.SLC.xml b/activitymanager/org.kde.ActivityManager.SLC.xml
2196deleted file mode 100644
2197index b9df419..0000000
2198--- a/activitymanager/org.kde.ActivityManager.SLC.xml
2199+++ /dev/null
2200@@ -1,15 +0,0 @@
2201-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
2202-<node>
2203- <interface name="org.kde.ActivityManager.SLC">
2204- <signal name="focusChanged">
2205- <arg name="uri" type="s" direction="out"/>
2206- <arg name="mimetype" type="s" direction="out"/>
2207- </signal>
2208- <method name="focussedResourceURI">
2209- <arg type="s" direction="out"/>
2210- </method>
2211- <method name="focussedResourceMimetype">
2212- <arg type="s" direction="out"/>
2213- </method>
2214- </interface>
2215-</node>
2216diff --git a/activitymanager/plugins/CMakeLists.txt b/activitymanager/plugins/CMakeLists.txt
2217new file mode 100644
2218index 0000000..6acca9e
2219--- /dev/null
2220+++ b/activitymanager/plugins/CMakeLists.txt
2221@@ -0,0 +1,3 @@
2222+macro_optional_add_subdirectory(dummy)
2223+macro_optional_add_subdirectory(slc)
2224+macro_optional_add_subdirectory(nepomuk)
2225diff --git a/activitymanager/plugins/dummy/CMakeLists.txt b/activitymanager/plugins/dummy/CMakeLists.txt
2226new file mode 100644
2227index 0000000..7cced75
2228--- /dev/null
2229+++ b/activitymanager/plugins/dummy/CMakeLists.txt
2230@@ -0,0 +1,30 @@
2231+project(activitymanager-dummy)
2232+
2233+include_directories(
2234+ ${CMAKE_SOURCE_DIR}
2235+ ${CMAKE_BINARY_DIR}
2236+ ${CMAKE_CURRENT_SOURCE_DIR}
2237+ ${CMAKE_CURRENT_SOURCE_DIR}/../..
2238+ ${CMAKE_CURRENT_BINARY_DIR}
2239+ ${KDE4_INCLUDES}
2240+ )
2241+
2242+set(
2243+ dummy_SRCS
2244+ dummy.cpp
2245+ ../../Plugin.cpp
2246+ )
2247+
2248+kde4_add_plugin(
2249+ activitymanager_plugin_dummy
2250+ ${dummy_SRCS}
2251+ )
2252+
2253+target_link_libraries(
2254+ activitymanager_plugin_dummy
2255+ ${KDE4_KDECORE_LIBS}
2256+)
2257+
2258+install(TARGETS activitymanager_plugin_dummy DESTINATION ${PLUGIN_INSTALL_DIR})
2259+install(FILES activitymanager-plugin-dummy.desktop DESTINATION ${SERVICES_INSTALL_DIR})
2260+
2261diff --git a/activitymanager/plugins/dummy/activitymanager-plugin-dummy.desktop b/activitymanager/plugins/dummy/activitymanager-plugin-dummy.desktop
2262new file mode 100644
2263index 0000000..34ec150
2264--- /dev/null
2265+++ b/activitymanager/plugins/dummy/activitymanager-plugin-dummy.desktop
2266@@ -0,0 +1,19 @@
2267+[Desktop Entry]
2268+Name=Dummy plugin
2269+Comment=Just testing
2270+Type=Service
2271+Icon=
2272+
2273+X-KDE-ServiceTypes=ActivityManager/Plugin
2274+X-KDE-Library=activitymanager_plugin_dummy
2275+X-KDE-PluginInfo-Author=Ivan Cukic
2276+X-KDE-PluginInfo-Email=ivan.cukic@kde.org
2277+X-KDE-PluginInfo-Name=org.kde.kactivitymanager.dummy
2278+X-KDE-PluginInfo-Version=1.0
2279+X-KDE-PluginInfo-Website=http://plasma.kde.org/
2280+X-KDE-PluginInfo-Category=Language
2281+X-KDE-PluginInfo-Depends=
2282+X-KDE-PluginInfo-License=GPL
2283+X-KDE-PluginInfo-EnabledByDefault=true
2284+
2285+X-ActivityManager-PluginType=normal
2286diff --git a/activitymanager/plugins/dummy/dummy.cpp b/activitymanager/plugins/dummy/dummy.cpp
2287new file mode 100644
2288index 0000000..e20fb2b
2289--- /dev/null
2290+++ b/activitymanager/plugins/dummy/dummy.cpp
2291@@ -0,0 +1,34 @@
2292+/*
2293+ * Copyright (C) 2011 Ivan Cukic ivan.cukic(at)kde.org
2294+ *
2295+ * This program is free software; you can redistribute it and/or
2296+ * modify it under the terms of the GNU General Public License as
2297+ * published by the Free Software Foundation; either version 2 of
2298+ * the License, or (at your option) any later version.
2299+ *
2300+ * This program is distributed in the hope that it will be useful,
2301+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2302+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2303+ * GNU General Public License for more details.
2304+ *
2305+ * You should have received a copy of the GNU General Public License
2306+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2307+ */
2308+
2309+#include "dummy.h"
2310+
2311+#include <KDebug>
2312+#include "ActivityManager.h"
2313+
2314+DummyPlugin::DummyPlugin(QObject * parent, const QVariantList & args)
2315+ : Plugin(parent)
2316+{
2317+ Q_UNUSED(args)
2318+ kDebug() << "We are in the DummyPlugin";
2319+}
2320+
2321+DummyPlugin::~DummyPlugin()
2322+{
2323+}
2324+
2325+KAMD_EXPORT_PLUGIN(DummyPlugin, "activitymanger_plugin_dummy")
2326diff --git a/activitymanager/plugins/dummy/dummy.h b/activitymanager/plugins/dummy/dummy.h
2327new file mode 100644
2328index 0000000..e059a5e
2329--- /dev/null
2330+++ b/activitymanager/plugins/dummy/dummy.h
2331@@ -0,0 +1,35 @@
2332+/*
2333+ * Copyright (C) 2008 Nick Shaforostoff <shaforostoff@kde.ru>
2334+ *
2335+ * based on work by:
2336+ * Copyright (C) 2007 Thomas Georgiou <TAGeorgiou@gmail.com> and Jeff Cooper <weirdsox11@gmail.com>
2337+ *
2338+ * This program is free software; you can redistribute it and/or
2339+ * modify it under the terms of the GNU General Public License as
2340+ * published by the Free Software Foundation; either version 2 of
2341+ * the License, or (at your option) any later version.
2342+ *
2343+ * This program is distributed in the hope that it will be useful,
2344+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2345+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2346+ * GNU General Public License for more details.
2347+ *
2348+ * You should have received a copy of the GNU General Public License
2349+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2350+ */
2351+
2352+#ifndef Dummy_H
2353+#define Dummy_H
2354+
2355+#include "../../Plugin.h"
2356+
2357+class DummyPlugin: public Plugin
2358+{
2359+ Q_OBJECT
2360+
2361+public:
2362+ DummyPlugin(QObject *parent, const QVariantList & args);
2363+ ~DummyPlugin();
2364+};
2365+
2366+#endif
2367diff --git a/activitymanager/plugins/nepomuk/CMakeLists.txt b/activitymanager/plugins/nepomuk/CMakeLists.txt
2368new file mode 100644
2369index 0000000..7900519
2370--- /dev/null
2371+++ b/activitymanager/plugins/nepomuk/CMakeLists.txt
2372@@ -0,0 +1,61 @@
2373+project(activitymanager-plugin-nepomuk)
2374+
2375+# Checking for Nepomuk
2376+find_package(Nepomuk REQUIRED)
2377+
2378+set(
2379+ nepomuk_SRCS
2380+ NepomukPlugin.cpp
2381+ NepomukResourceScoreCache.cpp
2382+ NepomukResourceScoreMaintainer.cpp
2383+ ../../Plugin.cpp
2384+ ../../SharedInfo.cpp
2385+ )
2386+
2387+soprano_add_ontology(nepomuk_SRCS
2388+ ${CMAKE_SOURCE_DIR}/nepomuk/ontologies/kext.trig
2389+ "KExt" "Nepomuk::Vocabulary" "trig"
2390+ )
2391+
2392+soprano_add_ontology(nepomuk_SRCS
2393+ ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nie/nie.trig
2394+ "NIE" "Nepomuk::Vocabulary" "trig"
2395+ )
2396+
2397+soprano_add_ontology(nepomuk_SRCS
2398+ ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nepomuk/nao.trig
2399+ "NAO" "Nepomuk::Vocabulary" "trig"
2400+ )
2401+
2402+soprano_add_ontology(nepomuk_SRCS
2403+ ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nepomuk/nuao.trig
2404+ "NUAO" "Nepomuk::Vocabulary" "trig"
2405+ )
2406+
2407+include_directories(
2408+ ${CMAKE_SOURCE_DIR}
2409+ ${CMAKE_BINARY_DIR}
2410+ ${CMAKE_CURRENT_SOURCE_DIR}
2411+ ${CMAKE_CURRENT_SOURCE_DIR}/../..
2412+ ${CMAKE_CURRENT_BINARY_DIR}
2413+ ${CMAKE_CURRENT_BINARY_DIR}/../..
2414+ ${KDE4_INCLUDES}
2415+ )
2416+
2417+kde4_add_plugin(
2418+ activitymanager_plugin_nepomuk
2419+ ${nepomuk_SRCS}
2420+ )
2421+
2422+target_link_libraries(
2423+ activitymanager_plugin_nepomuk
2424+ ${KDE4_KDECORE_LIBS}
2425+ ${KDE4_KDEUI_LIBS}
2426+ ${NEPOMUK_LIBRARIES}
2427+ ${NEPOMUK_QUERY_LIBRARIES}
2428+ ${SOPRANO_LIBRARIES}
2429+ )
2430+
2431+install(TARGETS activitymanager_plugin_nepomuk DESTINATION ${PLUGIN_INSTALL_DIR})
2432+install(FILES activitymanager-plugin-nepomuk.desktop DESTINATION ${SERVICES_INSTALL_DIR})
2433+
2434diff --git a/activitymanager/plugins/nepomuk/NepomukCommon.h b/activitymanager/plugins/nepomuk/NepomukCommon.h
2435new file mode 100644
2436index 0000000..222c9c0
2437--- /dev/null
2438+++ b/activitymanager/plugins/nepomuk/NepomukCommon.h
2439@@ -0,0 +1,67 @@
2440+/*
2441+ * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
2442+ *
2443+ * This program is free software; you can redistribute it and/or modify
2444+ * it under the terms of the GNU General Public License version 2,
2445+ * or (at your option) any later version, as published by the Free
2446+ * Software Foundation
2447+ *
2448+ * This program is distributed in the hope that it will be useful,
2449+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2450+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2451+ * GNU General Public License for more details
2452+ *
2453+ * You should have received a copy of the GNU General Public
2454+ * License along with this program; if not, write to the
2455+ * Free Software Foundation, Inc.,
2456+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2457+ */
2458+
2459+#ifndef NEPOMUK_COMMON_H_
2460+#define NEPOMUK_COMMON_H_
2461+
2462+#include "nie.h"
2463+#include "NepomukPlugin.h"
2464+
2465+#include <Nepomuk/Variant>
2466+
2467+#define NUAO_targettedResource KUrl(NUAO::nuaoNamespace().toString() + QLatin1String("targettedResource"))
2468+#define NUAO_initiatingAgent KUrl(NUAO::nuaoNamespace().toString() + QLatin1String("initiatingAgent"))
2469+// #define NUAO_involvesActivity KUrl(NUAO::nuaoNamespace().toString() + QLatin1String("involvesActivity"))
2470+
2471+#define activityResource(ID) Nepomuk::Resource(ID, KExt::Activity())
2472+#define agentResource(ID) Nepomuk::Resource(ID, NAO::Agent())
2473+#define currentActivityId NepomukPlugin::self()->sharedInfo()->currentActivity()
2474+#define currentActivityRes activityResource(currentActivityId)
2475+
2476+// #define anyResource(ID) Nepomuk::Resource(KUrl(ID))
2477+
2478+inline Nepomuk::Resource anyResource(const QUrl & uri)
2479+{
2480+ Nepomuk::Resource result(uri);
2481+
2482+ kDebug() << "setting the URI" << result.isFile() << result.isValid();
2483+ result.setProperty(Nepomuk::Vocabulary::NIE::url(), uri);
2484+ kDebug() << "set the URI" << result.isFile() << result.isValid();
2485+
2486+ return result;
2487+}
2488+
2489+inline Nepomuk::Resource anyResource(const QString & uri)
2490+{
2491+ return anyResource(KUrl(uri));
2492+}
2493+
2494+#define litN3(A) Soprano::Node::literalToN3(A)
2495+
2496+inline QString resN3(const QUrl & uri)
2497+{
2498+ return Soprano::Node::resourceToN3(uri);
2499+}
2500+
2501+inline QString resN3(const Nepomuk::Resource & resource)
2502+{
2503+ return Soprano::Node::resourceToN3(resource.resourceUri());
2504+}
2505+
2506+#endif // NEPOMUK_COMMON_H_
2507diff --git a/activitymanager/plugins/nepomuk/NepomukPlugin.cpp b/activitymanager/plugins/nepomuk/NepomukPlugin.cpp
2508new file mode 100644
2509index 0000000..9cbcda7
2510--- /dev/null
2511+++ b/activitymanager/plugins/nepomuk/NepomukPlugin.cpp
2512@@ -0,0 +1,264 @@
2513+/*
2514+ * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
2515+ * Copyright (c) 2011 Sebastian Trueg <trueg@kde.org>
2516+ *
2517+ * This program is free software; you can redistribute it and/or modify
2518+ * it under the terms of the GNU General Public License version 2,
2519+ * or (at your option) any later version, as published by the Free
2520+ * Software Foundation
2521+ *
2522+ * This program is distributed in the hope that it will be useful,
2523+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2524+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2525+ * GNU General Public License for more details
2526+ *
2527+ * You should have received a copy of the GNU General Public
2528+ * License along with this program; if not, write to the
2529+ * Free Software Foundation, Inc.,
2530+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2531+ */
2532+
2533+#include "NepomukPlugin.h"
2534+#include "NepomukResourceScoreMaintainer.h"
2535+
2536+#include "../../Event.h"
2537+#include "kext.h"
2538+
2539+#include <nepomuk/resource.h>
2540+#include <nepomuk/nuao.h>
2541+#include <nepomuk/resourcemanager.h>
2542+#include <nepomuk/variant.h>
2543+
2544+#include <Nepomuk/Query/Query>
2545+#include <Nepomuk/Query/ResourceTerm>
2546+#include <Nepomuk/Query/ResourceTypeTerm>
2547+#include <Nepomuk/Query/ComparisonTerm>
2548+#include <Nepomuk/Query/LiteralTerm>
2549+#include <Nepomuk/Query/NegationTerm>
2550+
2551+#include <Soprano/Vocabulary/NAO>
2552+#include <Soprano/QueryResultIterator>
2553+#include <Soprano/Node>
2554+#include <Soprano/Model>
2555+
2556+#include <kdebug.h>
2557+
2558+#include "NepomukCommon.h"
2559+
2560+using namespace Soprano::Vocabulary;
2561+using namespace Nepomuk::Vocabulary;
2562+using namespace Nepomuk::Query;
2563+
2564+NepomukPlugin * NepomukPlugin::s_instance = NULL;
2565+
2566+NepomukPlugin::NepomukPlugin(QObject *parent, const QVariantList & args)
2567+ : Plugin(parent)
2568+{
2569+ Q_UNUSED(args)
2570+ s_instance = this;
2571+}
2572+
2573+NepomukPlugin * NepomukPlugin::self()
2574+{
2575+ return s_instance;
2576+}
2577+
2578+void NepomukPlugin::addEvents(const EventList & events)
2579+{
2580+ foreach (const Event& event, events) {
2581+ kDebug() << "We are processing event" << event.type << event.uri;
2582+ kDebug() << "for agent" << event.application << agentResource(event.application).resourceUri();
2583+
2584+ switch (event.type) {
2585+ case Event::Accessed:
2586+ {
2587+ // one-shot event
2588+
2589+ Nepomuk::Resource eventRes = createDesktopEvent(event.uri, event.timestamp, event.application);
2590+ eventRes.addType(NUAO::UsageEvent());
2591+ eventRes.setProperty(NUAO::start(), event.timestamp);
2592+ eventRes.setProperty(NUAO::end(), event.timestamp);
2593+
2594+ kDebug() << "Created one-shot Accessed event" << eventRes;
2595+
2596+ NepomukResourceScoreMaintainer::self()->processResource(event.uri, event.application);
2597+
2598+ break;
2599+ }
2600+
2601+ case Event::Opened:
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: