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

Proposed by Philip Muškovac on 2011-08-15
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 2011-08-15 Approve on 2011-08-18
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.
Michał Zając (quintasan) wrote :

Hey, the patches are missing!

224. By Philip Muškovac on 2011-08-18

Actually add the patches

Michał Zając (quintasan) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2011-07-27 17:40:54 +0000
3+++ debian/changelog 2011-08-18 09:25:23 +0000
4@@ -1,3 +1,10 @@
5+kde-runtime (4:4.7.0a-0ubuntu2) UNRELEASED; urgency=low
6+
7+ * Added plasma-active patches
8+ * Added activitymanager files to install files
9+
10+ -- Rodrigo Belem <rclbelem@gmail.com> Sun, 07 Aug 2011 09:50:51 -0400
11+
12 kde-runtime (4:4.7.0a-0ubuntu1) oneiric; urgency=low
13
14 [ Romain Perier ]
15
16=== modified file 'debian/kde-runtime-data.install'
17--- debian/kde-runtime-data.install 2011-06-25 20:12:29 +0000
18+++ debian/kde-runtime-data.install 2011-08-18 09:25:23 +0000
19@@ -449,6 +449,9 @@
20 usr/share/kde4/config/kshorturifilterrc
21 usr/share/kde4/config.kcfg/jpegcreatorsettings.kcfg
22 usr/share/kde4/services/about.protocol
23+usr/share/kde4/services/activitymanager-plugin-dummy.desktop
24+usr/share/kde4/services/activitymanager-plugin-nepomuk.desktop
25+usr/share/kde4/services/activitymanager-plugin-slc.desktop
26 usr/share/kde4/services/applications.protocol
27 usr/share/kde4/services/ar.protocol
28 usr/share/kde4/services/bookmarks.protocol
29@@ -668,6 +671,7 @@
30 usr/share/kde4/services/windowsimagethumbnail.desktop
31 usr/share/kde4/services/xz.protocol
32 usr/share/kde4/services/zip.protocol
33+usr/share/kde4/servicetypes/activitymanager-plugin.desktop
34 usr/share/kde4/servicetypes/knotifynotifymethod.desktop
35 usr/share/kde4/servicetypes/nepomukservice.desktop
36 usr/share/kde4/servicetypes/phononbackend.desktop
37
38=== modified file 'debian/kde-runtime.install'
39--- debian/kde-runtime.install 2011-06-25 20:12:29 +0000
40+++ debian/kde-runtime.install 2011-08-18 09:25:23 +0000
41@@ -35,6 +35,9 @@
42 usr/lib/attica_kde.so
43 usr/lib/kconf_update_bin/phonon_devicepreference_update
44 usr/lib/kconf_update_bin/phonon_deviceuids_update
45+usr/lib/kde4/activitymanager_plugin_dummy.so
46+usr/lib/kde4/activitymanager_plugin_nepomuk.so
47+usr/lib/kde4/activitymanager_plugin_slc.so
48 usr/lib/kde4/comicbookthumbnail.so
49 usr/lib/kde4/cursorthumbnail.so
50 usr/lib/kde4/djvuthumbnail.so
51
52=== added file 'debian/patches/kubuntu_mobile_crash-move-after-first-call-to-applet.diff'
53--- debian/patches/kubuntu_mobile_crash-move-after-first-call-to-applet.diff 1970-01-01 00:00:00 +0000
54+++ debian/patches/kubuntu_mobile_crash-move-after-first-call-to-applet.diff 2011-08-18 09:25:23 +0000
55@@ -0,0 +1,54 @@
56+From 6568d05788b8f019b12c33a195b70489c5ea29ed Mon Sep 17 00:00:00 2001
57+From: Marco Martin <notmart@gmail.com>
58+Date: Mon, 11 Jul 2011 22:44:05 +0200
59+Subject: [PATCH 3/6] crash-- move after first call to applet()
60+
61+---
62+ .../plasmoid/declarativeappletscript.cpp | 2 +-
63+ .../javascript/plasmoid/simplejavascriptapplet.cpp | 3 +--
64+ 2 files changed, 2 insertions(+), 3 deletions(-)
65+
66+diff --git a/plasma/scriptengines/javascript/plasmoid/declarativeappletscript.cpp b/plasma/scriptengines/javascript/plasmoid/declarativeappletscript.cpp
67+index 5bd0b98..6f5cc95 100644
68+--- a/plasma/scriptengines/javascript/plasmoid/declarativeappletscript.cpp
69++++ b/plasma/scriptengines/javascript/plasmoid/declarativeappletscript.cpp
70+@@ -70,7 +70,6 @@ DeclarativeAppletScript::DeclarativeAppletScript(QObject *parent, const QVariant
71+ m_env(0),
72+ m_auth(this)
73+ {
74+- KGlobal::locale()->insertCatalog(description().pluginName());
75+ Q_UNUSED(args);
76+ }
77+
78+@@ -82,6 +81,7 @@ bool DeclarativeAppletScript::init()
79+ {
80+ m_declarativeWidget = new Plasma::DeclarativeWidget(applet());
81+ m_declarativeWidget->setInitializationDelayed(true);
82++ KGlobal::locale()->insertCatalog(description().pluginName());
83+
84+ //make possible to import extensions from the package
85+ //FIXME: probably to be removed, would make possible to use native code from within the package :/
86+diff --git a/plasma/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp b/plasma/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp
87+index b0b13e5..dba71f2 100644
88+--- a/plasma/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp
89++++ b/plasma/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp
90+@@ -105,8 +105,6 @@ SimpleJavaScriptApplet::SimpleJavaScriptApplet(QObject *parent, const QVariantLi
91+ Q_UNUSED(args);
92+ // kDebug() << "Script applet launched, args" << applet()->startupArguments();
93+
94+- KGlobal::locale()->insertCatalog(description().pluginName());
95+-
96+ // TODO this will be set to the engine we get from QML
97+ m_engine = new QScriptEngine(this);
98+ m_env = new ScriptEnv(this, m_engine);
99+@@ -311,6 +309,7 @@ bool SimpleJavaScriptApplet::init()
100+ this, SLOT(extenderItemRestored(Plasma::ExtenderItem*)));
101+ connect(applet(), SIGNAL(activate()),
102+ this, SLOT(activate()));
103++ KGlobal::locale()->insertCatalog(description().pluginName());
104+ setupObjects();
105+
106+ AppletAuthorization auth(this);
107+--
108+1.7.5.4
109+
110
111=== added file 'debian/patches/kubuntu_mobile_insert-a-catalog-named-as-the-plugin-name.diff'
112--- debian/patches/kubuntu_mobile_insert-a-catalog-named-as-the-plugin-name.diff 1970-01-01 00:00:00 +0000
113+++ debian/patches/kubuntu_mobile_insert-a-catalog-named-as-the-plugin-name.diff 2011-08-18 09:25:23 +0000
114@@ -0,0 +1,38 @@
115+From 56b7574767ebaa1dcf667c663e1d98a2ee299a94 Mon Sep 17 00:00:00 2001
116+From: Marco Martin <notmart@gmail.com>
117+Date: Mon, 11 Jul 2011 21:23:32 +0200
118+Subject: [PATCH 2/6] insert a catalog named as the plugin name
119+
120+---
121+ .../plasmoid/declarativeappletscript.cpp | 1 +
122+ .../javascript/plasmoid/simplejavascriptapplet.cpp | 2 ++
123+ 2 files changed, 3 insertions(+), 0 deletions(-)
124+
125+diff --git a/plasma/scriptengines/javascript/plasmoid/declarativeappletscript.cpp b/plasma/scriptengines/javascript/plasmoid/declarativeappletscript.cpp
126+index 08d53fa..5bd0b98 100644
127+--- a/plasma/scriptengines/javascript/plasmoid/declarativeappletscript.cpp
128++++ b/plasma/scriptengines/javascript/plasmoid/declarativeappletscript.cpp
129+@@ -70,6 +70,7 @@ DeclarativeAppletScript::DeclarativeAppletScript(QObject *parent, const QVariant
130+ m_env(0),
131+ m_auth(this)
132+ {
133++ KGlobal::locale()->insertCatalog(description().pluginName());
134+ Q_UNUSED(args);
135+ }
136+
137+diff --git a/plasma/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp b/plasma/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp
138+index 0076cd8..b0b13e5 100644
139+--- a/plasma/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp
140++++ b/plasma/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp
141+@@ -105,6 +105,8 @@ SimpleJavaScriptApplet::SimpleJavaScriptApplet(QObject *parent, const QVariantLi
142+ Q_UNUSED(args);
143+ // kDebug() << "Script applet launched, args" << applet()->startupArguments();
144+
145++ KGlobal::locale()->insertCatalog(description().pluginName());
146++
147+ // TODO this will be set to the engine we get from QML
148+ m_engine = new QScriptEngine(this);
149+ m_env = new ScriptEnv(this, m_engine);
150+--
151+1.7.5.4
152+
153
154=== added file 'debian/patches/kubuntu_mobile_ported-the-new-activity-manager.diff'
155--- debian/patches/kubuntu_mobile_ported-the-new-activity-manager.diff 1970-01-01 00:00:00 +0000
156+++ debian/patches/kubuntu_mobile_ported-the-new-activity-manager.diff 2011-08-18 09:25:23 +0000
157@@ -0,0 +1,2237 @@
158+From 7bbbc379de69eab6164a6c7a33670e231b734768 Mon Sep 17 00:00:00 2001
159+From: =?UTF-8?q?Ivan=20=C4=8Cuki=C4=87?= <ivan.cukic@kde.org>
160+Date: Fri, 8 Jul 2011 17:22:59 +0200
161+Subject: [PATCH 1/6] Ported the new activity manager
162+
163+---
164+ activitymanager/ActivityManager.cpp | 87 +++++---
165+ activitymanager/ActivityManager.h | 83 ++-----
166+ activitymanager/ActivityManager_p.h | 16 +-
167+ activitymanager/CMakeLists.txt | 44 ++++-
168+ activitymanager/Event.cpp | 6 +-
169+ activitymanager/Event.h | 29 ++-
170+ activitymanager/EventBackend.cpp | 12 +
171+ activitymanager/EventBackend.h | 3 +-
172+ activitymanager/EventProcessor.cpp | 26 ++-
173+ activitymanager/EventProcessor.h | 4 +-
174+ activitymanager/NepomukCommon.h | 63 ++++++
175+ activitymanager/NepomukEventBackend.cpp | 235 ++++++++++++++------
176+ activitymanager/NepomukResourceScoreCache.cpp | 214 ++++++++++++++++++
177+ activitymanager/NepomukResourceScoreCache.h | 42 ++++
178+ activitymanager/NepomukResourceScoreMaintainer.cpp | 145 ++++++++++++
179+ activitymanager/NepomukResourceScoreMaintainer.h | 47 ++++
180+ activitymanager/SharedInfo.cpp | 51 +++++
181+ activitymanager/SharedInfo.h | 63 ++++++
182+ activitymanager/SlcEventBackend.cpp | 127 +++++++++++
183+ activitymanager/SlcEventBackend.h | 59 +++++
184+ activitymanager/ZeitgeistEventBackend.cpp | 44 ++--
185+ activitymanager/main.cpp | 2 -
186+ activitymanager/ontologies/CMakeLists.txt | 8 +
187+ activitymanager/ontologies/kamdrso.ontology.in | 8 +
188+ activitymanager/ontologies/kamdrso.trig | 112 ++++++++++
189+ activitymanager/org.kde.ActivityManager.SLC.xml | 15 ++
190+ activitymanager/org.kde.ActivityManager.xml | 37 +---
191+ activitymanager/queries.sparql | 43 ++++
192+ activitymanager/scripts/delete-stats.sh | 4 +
193+ nepomuk/ontologies/kext.trig | 41 +++-
194+ 30 files changed, 1413 insertions(+), 257 deletions(-)
195+ create mode 100644 activitymanager/NepomukCommon.h
196+ create mode 100644 activitymanager/NepomukResourceScoreCache.cpp
197+ create mode 100644 activitymanager/NepomukResourceScoreCache.h
198+ create mode 100644 activitymanager/NepomukResourceScoreMaintainer.cpp
199+ create mode 100644 activitymanager/NepomukResourceScoreMaintainer.h
200+ create mode 100644 activitymanager/SharedInfo.cpp
201+ create mode 100644 activitymanager/SharedInfo.h
202+ create mode 100644 activitymanager/SlcEventBackend.cpp
203+ create mode 100644 activitymanager/SlcEventBackend.h
204+ create mode 100644 activitymanager/ontologies/CMakeLists.txt
205+ create mode 100644 activitymanager/ontologies/kamdrso.ontology.in
206+ create mode 100644 activitymanager/ontologies/kamdrso.trig
207+ create mode 100644 activitymanager/org.kde.ActivityManager.SLC.xml
208+ create mode 100644 activitymanager/queries.sparql
209+ create mode 100755 activitymanager/scripts/delete-stats.sh
210+
211+diff --git a/activitymanager/ActivityManager.cpp b/activitymanager/ActivityManager.cpp
212+index ea95232..e821c92 100644
213+--- a/activitymanager/ActivityManager.cpp
214++++ b/activitymanager/ActivityManager.cpp
215+@@ -66,9 +66,14 @@ __inline int toInt(WId wid)
216+
217+ // Private
218+
219+-ActivityManagerPrivate::ActivityManagerPrivate(ActivityManager * parent)
220++ActivityManagerPrivate::ActivityManagerPrivate(ActivityManager * parent,
221++ QHash < WId, SharedInfo::WindowData > & _windows,
222++ QHash < KUrl, SharedInfo::ResourceData > & _resources
223++ )
224+ : haveSessions(false),
225+ config("activitymanagerrc"),
226++ windows(_windows),
227++ resources(_resources),
228+ #ifdef HAVE_NEPOMUK
229+ m_nepomukInitCalled(false),
230+ #endif
231+@@ -99,6 +104,8 @@ ActivityManagerPrivate::ActivityManagerPrivate(ActivityManager * parent)
232+
233+ connect(KWindowSystem::self(), SIGNAL(windowRemoved(WId)),
234+ this, SLOT(windowClosed(WId)));
235++ connect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)),
236++ this, SLOT(activeWindowChanged(WId)));
237+
238+ //listen to ksmserver for starting/stopping
239+ ksmserverInterface = new QDBusInterface("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
240+@@ -126,15 +133,26 @@ ActivityManagerPrivate::~ActivityManagerPrivate()
241+
242+ void ActivityManagerPrivate::windowClosed(WId windowId)
243+ {
244+- if (!resourcesForWindow.contains(windowId)) {
245++ // kDebug() << "Window closed..." << windowId
246++ // << "one of ours?" << windows.contains(windowId);
247++
248++ if (!windows.contains(windowId)) {
249+ return;
250+ }
251+
252+- foreach(const KUrl & uri, resourcesForWindow[windowId]) {
253+- q->NotifyResourceClosed(toInt(windowId), uri.url());
254++ foreach (const KUrl & uri, windows[windowId].resources) {
255++ q->RegisterResourceEvent(windows[windowId].application,
256++ toInt(windowId), uri.url(), Event::Closed, resources[uri].reason);
257+ }
258+ }
259+
260++void ActivityManagerPrivate::activeWindowChanged(WId windowId)
261++{
262++ // kDebug() << "Window focussed..." << windowId
263++ // << "one of ours?" << windows.contains(windowId);
264++
265++}
266++
267+ void ActivityManagerPrivate::setActivityState(const QString & id, ActivityManager::State state)
268+ {
269+ if (activities[id] == state) return;
270+@@ -285,7 +303,9 @@ void ActivityManagerPrivate::backstoreAvailable()
271+ // Main
272+
273+ ActivityManager::ActivityManager()
274+- : d(new ActivityManagerPrivate(this))
275++ : d(new ActivityManagerPrivate(this,
276++ SharedInfo::self()->m_windows,
277++ SharedInfo::self()->m_resources))
278+ {
279+
280+ QDBusConnection dbus = QDBusConnection::sessionBus();
281+@@ -298,6 +318,8 @@ ActivityManager::ActivityManager()
282+ // ensureCurrentActivityIsRunning();
283+
284+ KCrash::setFlags(KCrash::AutoRestart);
285++
286++ EventProcessor::self();
287+ }
288+
289+ ActivityManager::~ActivityManager()
290+@@ -656,49 +678,44 @@ void ActivityManager::SetActivityIcon(const QString & id, const QString & icon)
291+
292+
293+ // Resource related mothods
294+-
295+-void ActivityManager::NotifyResourceAccessed(const QString & application, const QString & uri)
296++void ActivityManager::RegisterResourceEvent(const QString & application, uint _windowId,
297++ const QString & uri, uint event, uint reason)
298+ {
299+- EventProcessor::self()->addEvent(application, uri, Event::Accessed);
300+-}
301++ if (event > Event::LastEventType || reason > Event::LastEventReason)
302++ return;
303+
304+-void ActivityManager::NotifyResourceClosed(uint _windowId, const QString & uri)
305+-{
306+- WId windowId = (WId)_windowId;
307+- d->resourcesForWindow[windowId].remove(KUrl(uri));
308++ WId windowId = (WId) _windowId;
309+
310+- EventProcessor::self()->addEvent(d->applicationForWindow[windowId], uri, Event::Closed);
311++ kDebug() << "New event on the horizon" << application << _windowId << windowId << event << Event::Opened;
312++ if (event == Event::Opened) {
313+
314+- if (d->resourcesForWindow[windowId].size() == 0) {
315+- d->resourcesForWindow.remove(windowId);
316+- d->applicationForWindow.remove(windowId);
317+- }
318+-}
319++ KUrl kuri(uri);
320+
321+-void ActivityManager::NotifyResourceModified(uint windowId, const QString & uri)
322+-{
323+- EventProcessor::self()->addEvent(d->applicationForWindow[(WId)windowId], uri, Event::Modified);
324+-}
325++ kDebug() << "Saving the open event for the window" << windowId;
326++
327++ d->windows[windowId].resources << kuri;
328++ d->resources[kuri].activities << CurrentActivity();
329++
330++ kDebug() << d->windows.keys();
331++
332++ } else if (event == Event::Closed) {
333++
334++ // TODO: Remove from d->resources if needed
335++ d->windows.remove(windowId);
336+
337+-void ActivityManager::NotifyResourceOpened(const QString & application, uint _windowId, const QString & uri)
338+-{
339+- WId windowId = (WId)_windowId;
340+- if (!d->applicationForWindow.contains(windowId)) {
341+- d->applicationForWindow[windowId] = application;
342+ }
343+
344+- KUrl kuri(uri);
345+- d->resourcesForWindow[windowId] << kuri;
346+- d->activitiesForUrl[kuri] << CurrentActivity();
347++ EventProcessor::self()->addEvent(application, windowId,
348++ uri, (Event::Type) event, (Event::Reason) reason);
349+
350+- EventProcessor::self()->addEvent(application, uri, Event::Opened);
351+ }
352+
353+-QStringList ActivityManager::ActivitiesForResource(const QString & uri) const
354++void ActivityManager::RegisterResourceMimeType(const QString & uri, const QString & mimetype)
355+ {
356+- return d->activitiesForUrl.value(uri).toList();
357+-}
358++ KUrl kuri(uri);
359+
360++ d->resources[kuri].mimetype = mimetype;
361++}
362+
363+ // static
364+ ActivityManager * ActivityManager::self()
365+diff --git a/activitymanager/ActivityManager.h b/activitymanager/ActivityManager.h
366+index 6bc9ea5..79e66b4 100644
367+--- a/activitymanager/ActivityManager.h
368++++ b/activitymanager/ActivityManager.h
369+@@ -51,6 +51,18 @@ public:
370+ };
371+
372+ /**
373++ * The event type
374++ */
375++ enum EventType {
376++ Accessed = 1,
377++ Opened = 2,
378++ Modified = 3,
379++ Closed = 4,
380++ FocussedIn = 5,
381++ FocussedOut = 6
382++ };
383++
384++ /**
385+ * Creates new ActivityManager
386+ */
387+ ActivityManager();
388+@@ -222,70 +234,25 @@ Q_SIGNALS:
389+
390+ // Resource related mothods
391+ public Q_SLOTS:
392+- /**
393+- * Should be called when the client application accesses
394+- * the file but is not interested in registering more advanced
395+- * events like open/modify/close.
396+- * @param application unformatted name of the application
397+- * @param uri uri of the resource
398+- */
399+- void NotifyResourceAccessed(const QString & application, const QString & uri);
400+-
401+- /**
402+- * Should be called when the client application
403+- * opens a new resource identifiable by an uri.
404+- * @param application unformatted name of the application
405+- * @param windowId ID of the window that registers the resource
406+- * @param uri uri of the resource
407+- */
408+- void NotifyResourceOpened(const QString & application, uint windowId, const QString & uri);
409+-
410+- /**
411+- * Should be called when the client application
412+- * modifies a resource already registered with NotifyResourceOpened
413+- * @param windowId ID of the window that registers the resource
414+- * @param uri uri of the resource
415+- */
416+- void NotifyResourceModified(uint windowId, const QString & uri);
417+-
418+- /**
419+- * Should be called when the client application
420+- * closes a resource previously registered with
421+- * NotifyResourceOpened.
422+- * @param ID of the window that unregisters the resource
423+- * @param uri uri of the resource
424+- */
425+- void NotifyResourceClosed(uint windowId, const QString & uri);
426+
427+ /**
428+- * @returns the list of activities that are associated with
429+- * the specified resource
430+- * @param uri uri of the resource
431++ * Registers a new event
432++ * @param application the name of application that sent the event. Ignored if the event is not of type Opened
433++ * @param windowId ID of the window that displays the resource. Ignored if the event is of type Accessed
434++ * @param uri URI of the resource on which the event happened
435++ * @param event type of the event
436++ * @param reason reason for opening the resource
437+ */
438+- QStringList ActivitiesForResource(const QString & uri) const;
439++ void RegisterResourceEvent(const QString & application, uint windowId, const QString & uri, uint event, uint reason);
440+
441+-Q_SIGNALS:
442+ /**
443+- * @see NotifyResourceAccessed
444++ * Registers resource's mimetype. If not manually specified, it will
445++ * be retrieved if needed from Nepomuk
446++ *
447++ * Note that this will be forgotten when the resource in question is closed.
448++ * @param uri URI of the resource
449+ */
450+- void ResourceAccessed(const QString & application, const QString & uri);
451+-
452+- /**
453+- * @see NotifyResourceOpened
454+- */
455+- void ResourceOpened(const QString & application, uint windowId, const QString & uri);
456+-
457+- /**
458+- * @see NotifyResourceModified
459+- */
460+- void ResourceModified(uint windowId, const QString & uri);
461+-
462+- /**
463+- * @see NotifyResourceClosed
464+- */
465+- void ResourceClosed(uint windowId, const QString & uri);
466+-
467+-
468++ void RegisterResourceMimeType(const QString & uri, const QString & mimetype);
469+
470+ private:
471+ friend class ActivityManagerPrivate;
472+diff --git a/activitymanager/ActivityManager_p.h b/activitymanager/ActivityManager_p.h
473+index 3d9ec39..f68cb18 100644
474+--- a/activitymanager/ActivityManager_p.h
475++++ b/activitymanager/ActivityManager_p.h
476+@@ -29,6 +29,8 @@
477+ #include <KUrl>
478+
479+ #include "ActivityManager.h"
480++#include "Event.h"
481++#include "SharedInfo.h"
482+ #include "config-features.h"
483+
484+ #ifdef HAVE_NEPOMUK
485+@@ -46,7 +48,10 @@ class ActivityManagerPrivate: public QObject {
486+ Q_OBJECT
487+
488+ public:
489+- ActivityManagerPrivate(ActivityManager * parent);
490++ ActivityManagerPrivate(ActivityManager * parent,
491++ QHash < WId, SharedInfo::WindowData > & _windows,
492++ QHash < KUrl, SharedInfo::ResourceData > & _resources
493++ );
494+ ~ActivityManagerPrivate();
495+
496+ void addRunningActivity(const QString & id);
497+@@ -55,11 +60,6 @@ public:
498+ void ensureCurrentActivityIsRunning();
499+ bool setCurrentActivity(const QString & id);
500+
501+- // URIs and WIDs for open resources
502+- QHash < WId, QSet < KUrl > > resourcesForWindow;
503+- QHash < WId, QString > applicationForWindow;
504+- QHash < KUrl, QSet < QString > > activitiesForUrl;
505+-
506+ void setActivityState(const QString & id, ActivityManager::State state);
507+ QHash < QString, ActivityManager::State > activities;
508+
509+@@ -74,6 +74,9 @@ public:
510+ QTimer configSyncTimer;
511+ KConfig config;
512+
513++ QHash < WId, SharedInfo::WindowData > & windows;
514++ QHash < KUrl, SharedInfo::ResourceData > & resources;
515++
516+ public:
517+ void initConifg();
518+
519+@@ -91,6 +94,7 @@ public Q_SLOTS:
520+ void scheduleConfigSync();
521+ void configSync();
522+ void windowClosed(WId windowId);
523++ void activeWindowChanged(WId windowId);
524+
525+ void startCompleted();
526+ void stopCompleted();
527+diff --git a/activitymanager/CMakeLists.txt b/activitymanager/CMakeLists.txt
528+index 23dddae..726fcce 100644
529+--- a/activitymanager/CMakeLists.txt
530++++ b/activitymanager/CMakeLists.txt
531+@@ -3,6 +3,7 @@ project(ActivityManager)
532+ set (ADDITIONAL_LINK_LIBS)
533+
534+ add_subdirectory(kded)
535++add_subdirectory(ontologies)
536+
537+ # Checking for Nepomuk
538+ macro_optional_find_package(Nepomuk)
539+@@ -56,23 +57,58 @@ include_directories(
540+ set(activity_manager_SRCS
541+ ActivityManager.cpp
542+ EventProcessor.cpp
543+- ZeitgeistEventBackend.cpp
544+- NepomukEventBackend.cpp
545+ EventBackend.cpp
546+ Event.cpp
547++ SharedInfo.cpp
548+ main.cpp
549+ )
550+
551++set(activity_manager_backends_SRCS
552++ NepomukEventBackend.cpp
553++ NepomukResourceScoreMaintainer.cpp
554++ NepomukResourceScoreCache.cpp
555++ ZeitgeistEventBackend.cpp
556++ SlcEventBackend.cpp
557++ )
558++
559+ qt4_add_dbus_adaptor(
560+ activity_manager_SRCS org.kde.ActivityManager.xml
561+ ActivityManager.h ActivityManager
562+ )
563+
564++qt4_add_dbus_adaptor(
565++ activity_manager_SRCS org.kde.ActivityManager.SLC.xml
566++ SlcEventBackend.h SlcEventBackend
567++ )
568++
569+ if(Nepomuk_FOUND)
570+- soprano_add_ontology(activity_manager_SRCS ${CMAKE_SOURCE_DIR}/nepomuk/ontologies/kext.trig "KExt" "Nepomuk::Vocabulary" "trig")
571++ soprano_add_ontology(activity_manager_SRCS
572++ ${CMAKE_SOURCE_DIR}/nepomuk/ontologies/kext.trig
573++ "KExt" "Nepomuk::Vocabulary" "trig"
574++ )
575++
576++ # soprano_add_ontology(activity_manager_SRCS
577++ # ${CMAKE_CURRENT_SOURCE_DIR}/ontologies/kamdrso.trig
578++ # "RSO" "Nepomuk::Vocabulary" "trig"
579++ # )
580++
581++ soprano_add_ontology(activity_manager_SRCS
582++ ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nie/nie.trig
583++ "NIE" "Nepomuk::Vocabulary" "trig"
584++ )
585++
586++ soprano_add_ontology(activity_manager_SRCS
587++ ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nepomuk/nao.trig
588++ "NAO" "Nepomuk::Vocabulary" "trig"
589++ )
590++
591++ soprano_add_ontology(activity_manager_SRCS
592++ ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nepomuk/nuao.trig
593++ "NUAO" "Nepomuk::Vocabulary" "trig"
594++ )
595+ endif()
596+
597+-kde4_add_executable(activity-manager ${activity_manager_SRCS})
598++kde4_add_executable(activity-manager ${activity_manager_SRCS} ${activity_manager_backends_SRCS})
599+
600+ target_link_libraries(
601+ activity-manager
602+diff --git a/activitymanager/Event.cpp b/activitymanager/Event.cpp
603+index ceabaf5..f8a964f 100644
604+--- a/activitymanager/Event.cpp
605++++ b/activitymanager/Event.cpp
606+@@ -19,8 +19,9 @@
607+
608+ #include "Event.h"
609+
610+-Event::Event(const QString & vApplication, const QString & vUri, Type vType, Reason vReason)
611+- : application(vApplication), uri(vUri), type(vType), reason(vReason), timestamp(QDateTime::currentDateTime())
612++
613++Event::Event(const QString & vApplication, WId vWid, const QString & vUri, Type vType, Reason vReason)
614++ : application(vApplication), wid(vWid), uri(vUri), type(vType), reason(vReason), timestamp(QDateTime::currentDateTime())
615+ {
616+ }
617+
618+@@ -28,6 +29,7 @@ bool Event::operator == (const Event & other) const
619+ {
620+ return
621+ application == other.application &&
622++ wid == other.wid &&
623+ uri == other.uri &&
624+ type == other.type &&
625+ reason == other.reason;
626+diff --git a/activitymanager/Event.h b/activitymanager/Event.h
627+index 5a05b7a..19b8187 100644
628+--- a/activitymanager/Event.h
629++++ b/activitymanager/Event.h
630+@@ -21,6 +21,7 @@
631+ #define EVENT_H_
632+
633+ #include <QString>
634++#include <QWidget>
635+ #include <QtCore/QDateTime>
636+
637+ /**
638+@@ -29,26 +30,34 @@
639+ class Event {
640+ public:
641+ enum Type {
642+- Accessed, ///< resource was accessed, but we don't know for how long it will be open/used
643+- Opened, ///< resource was opened
644+- Modified, ///< previously opened resource was modified
645+- Closed ///< previously opened resource was closed
646++ Accessed = 0, ///< resource was accessed, but we don't know for how long it will be open/used
647++ Opened = 1, ///< resource was opened
648++ Modified = 2, ///< previously opened resource was modified
649++ Closed = 3, ///< previously opened resource was closed
650++ FocussedIn = 4, ///< resource get the keyboard focus
651++ FocussedOut = 5, ///< resource lost the focus
652++
653++ LastEventType = 5
654++
655+ };
656+
657+ enum Reason {
658+- User,
659+- Scheduled,
660+- Heuristic,
661+- System,
662+- World
663++ User = 0,
664++ Scheduled = 1,
665++ Heuristic = 2,
666++ System = 3,
667++ World = 4,
668++
669++ LastEventReason = 4
670+ };
671+
672+- Event(const QString & application, const QString & uri, Type type = Accessed, Reason reason = User);
673++ Event(const QString & application, WId wid, const QString & uri, Type type = Accessed, Reason reason = User);
674+
675+ bool operator == (const Event & other) const;
676+
677+ public:
678+ QString application;
679++ WId wid;
680+ QString uri;
681+ Type type;
682+ Reason reason;
683+diff --git a/activitymanager/EventBackend.cpp b/activitymanager/EventBackend.cpp
684+index e06c25d..2650dbf 100644
685+--- a/activitymanager/EventBackend.cpp
686++++ b/activitymanager/EventBackend.cpp
687+@@ -26,3 +26,15 @@ EventBackend::EventBackend()
688+ EventBackend::~EventBackend()
689+ {
690+ }
691++
692++void EventBackend::addEvents(const EventList & events)
693++{
694++ Q_UNUSED(events)
695++}
696++
697++void EventBackend::setResourceMimeType(const QString & uri, const QString & mimetype)
698++{
699++ Q_UNUSED(uri)
700++ Q_UNUSED(mimetype)
701++}
702++
703+diff --git a/activitymanager/EventBackend.h b/activitymanager/EventBackend.h
704+index 26bb925..bd7cbf9 100644
705+--- a/activitymanager/EventBackend.h
706++++ b/activitymanager/EventBackend.h
707+@@ -31,7 +31,8 @@ public:
708+ EventBackend();
709+ virtual ~EventBackend();
710+
711+- virtual void addEvents(const EventList & events) = 0;
712++ virtual void addEvents(const EventList & events);
713++ virtual void setResourceMimeType(const QString & uri, const QString & mimetype);
714+
715+ };
716+
717+diff --git a/activitymanager/EventProcessor.cpp b/activitymanager/EventProcessor.cpp
718+index 6e38bf2..48bb405 100644
719+--- a/activitymanager/EventProcessor.cpp
720++++ b/activitymanager/EventProcessor.cpp
721+@@ -31,6 +31,8 @@
722+ #include "NepomukEventBackend.h"
723+ #endif
724+
725++#include "SlcEventBackend.h"
726++
727+ #include <QDateTime>
728+ #include <QList>
729+ #include <QMutex>
730+@@ -41,7 +43,9 @@
731+
732+ class EventProcessorPrivate: public QThread {
733+ public:
734+- QList < EventBackend * > backends;
735++ QList < EventBackend * > lazyBackends;
736++ QList < EventBackend * > syncBackends;
737++
738+ QList < Event > events;
739+ QMutex events_mutex;
740+
741+@@ -75,7 +79,7 @@ void EventProcessorPrivate::run()
742+
743+ EventProcessorPrivate::events_mutex.unlock();
744+
745+- foreach (EventBackend * backend, backends) {
746++ foreach (EventBackend * backend, lazyBackends) {
747+ backend->addEvents(currentEvents);
748+ }
749+ }
750+@@ -94,23 +98,29 @@ EventProcessor::EventProcessor()
751+ : d(new EventProcessorPrivate())
752+ {
753+ #ifdef HAVE_QZEITGEIST
754+- d->backends.append(new ZeitgeistEventBackend());
755++ d->lazyBackends.append(new ZeitgeistEventBackend());
756+ #endif
757+ #ifdef HAVE_NEPOMUK
758+- d->backends.append(new NepomukEventBackend());
759++ d->lazyBackends.append(new NepomukEventBackend());
760+ #endif
761++ d->syncBackends.append(new SlcEventBackend());
762+ }
763+
764+ EventProcessor::~EventProcessor()
765+ {
766+- qDeleteAll(d->backends);
767++ qDeleteAll(d->lazyBackends);
768++ qDeleteAll(d->syncBackends);
769+ delete d;
770+ }
771+
772+-void EventProcessor::addEvent(const QString & application, const QString & uri,
773+- Event::Type type, Event::Reason reason)
774++void EventProcessor::addEvent(const QString & application, WId wid, const QString & uri,
775++ Event::Type type, Event::Reason reason)
776+ {
777+- Event newEvent(application, uri, type, reason);
778++ Event newEvent(application, wid, uri, type, reason);
779++
780++ foreach (EventBackend * backend, d->syncBackends) {
781++ backend->addEvents(QList < Event > () << newEvent);
782++ }
783+
784+ d->events_mutex.lock();
785+
786+diff --git a/activitymanager/EventProcessor.h b/activitymanager/EventProcessor.h
787+index 59cdbad..64eeeb3 100644
788+--- a/activitymanager/EventProcessor.h
789++++ b/activitymanager/EventProcessor.h
790+@@ -30,13 +30,13 @@ class EventProcessorPrivate;
791+ /**
792+ * Thread to process desktop/usage events
793+ */
794+-class EventProcessor: public QThread {
795++class EventProcessor {
796+ public:
797+ static EventProcessor * self();
798+
799+ virtual ~EventProcessor();
800+
801+- void addEvent(const QString & application, const QString & uri,
802++ void addEvent(const QString & application, WId wid, const QString & uri,
803+ Event::Type type = Event::Accessed, Event::Reason reason = Event::User);
804+
805+ private:
806+diff --git a/activitymanager/NepomukCommon.h b/activitymanager/NepomukCommon.h
807+new file mode 100644
808+index 0000000..9df5a62
809+--- /dev/null
810++++ b/activitymanager/NepomukCommon.h
811+@@ -0,0 +1,63 @@
812++/*
813++ * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
814++ *
815++ * This program is free software; you can redistribute it and/or modify
816++ * it under the terms of the GNU General Public License version 2,
817++ * or (at your option) any later version, as published by the Free
818++ * Software Foundation
819++ *
820++ * This program is distributed in the hope that it will be useful,
821++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
822++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
823++ * GNU General Public License for more details
824++ *
825++ * You should have received a copy of the GNU General Public
826++ * License along with this program; if not, write to the
827++ * Free Software Foundation, Inc.,
828++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
829++ */
830++
831++#ifndef NEPOMUK_COMMON_H_
832++#define NEPOMUK_COMMON_H_
833++
834++#include "nie.h"
835++
836++#define NUAO_targettedResource KUrl(NUAO::nuaoNamespace().toString() + QLatin1String("targettedResource"))
837++#define NUAO_initiatingAgent KUrl(NUAO::nuaoNamespace().toString() + QLatin1String("initiatingAgent"))
838++// #define NUAO_involvesActivity KUrl(NUAO::nuaoNamespace().toString() + QLatin1String("involvesActivity"))
839++
840++#define activityResource(ID) Nepomuk::Resource(ID, KExt::Activity())
841++#define agentResource(ID) Nepomuk::Resource(ID, NAO::Agent())
842++#define currentActivityRes activityResource(ActivityManager::self()->CurrentActivity())
843++
844++// #define anyResource(ID) Nepomuk::Resource(KUrl(ID))
845++
846++inline Nepomuk::Resource anyResource(const QUrl & uri)
847++{
848++ Nepomuk::Resource result(uri);
849++
850++ kDebug() << "setting the URI" << result.isFile() << result.isValid();
851++ result.setProperty(Nepomuk::Vocabulary::NIE::url(), uri);
852++ kDebug() << "set the URI" << result.isFile() << result.isValid();
853++
854++ return result;
855++}
856++
857++inline Nepomuk::Resource anyResource(const QString & uri)
858++{
859++ return anyResource(KUrl(uri));
860++}
861++
862++#define litN3(A) Soprano::Node::literalToN3(A)
863++
864++inline QString resN3(const QUrl & uri)
865++{
866++ return Soprano::Node::resourceToN3(uri);
867++}
868++
869++inline QString resN3(const Nepomuk::Resource & resource)
870++{
871++ return Soprano::Node::resourceToN3(resource.resourceUri());
872++}
873++
874++#endif // NEPOMUK_COMMON_H_
875+diff --git a/activitymanager/NepomukEventBackend.cpp b/activitymanager/NepomukEventBackend.cpp
876+index 4fe3584..65c398c 100644
877+--- a/activitymanager/NepomukEventBackend.cpp
878++++ b/activitymanager/NepomukEventBackend.cpp
879+@@ -31,6 +31,8 @@
880+ #else // HAVE_NEPOMUK
881+
882+ #include "NepomukEventBackend.h"
883++#include "NepomukResourceScoreMaintainer.h"
884++
885+ #include "Event.h"
886+ #include "ActivityManager.h"
887+ #include "kext.h"
888+@@ -54,9 +56,11 @@
889+
890+ #include <kdebug.h>
891+
892++#include "NepomukCommon.h"
893++
894++using namespace Soprano::Vocabulary;
895+ using namespace Nepomuk::Vocabulary;
896+ using namespace Nepomuk::Query;
897+-using namespace Soprano::Vocabulary;
898+
899+ NepomukEventBackend::NepomukEventBackend()
900+ {
901+@@ -64,21 +68,88 @@ NepomukEventBackend::NepomukEventBackend()
902+
903+ void NepomukEventBackend::addEvents(const EventList & events)
904+ {
905+- foreach(const Event& event, events) {
906+- if(event.type == Event::Accessed) {
907+- // one-shot event
908+- Nepomuk::Resource eventRes = createDesktopEvent(event.uri, event.timestamp, event.application);
909+- eventRes.addType(NUAO::UsageEvent());
910+- eventRes.addProperty(NUAO::end(), event.timestamp);
911+- }
912+- else if(event.type == Event::Opened) {
913+- // create a new event
914+- createDesktopEvent(event.uri, event.timestamp, event.application);
915++ foreach (const Event& event, events) {
916++ kDebug() << "We are processing event" << event.type << event.uri;
917++ kDebug() << "for agent" << event.application << agentResource(event.application).resourceUri();
918++
919++ switch (event.type) {
920++ case Event::Accessed:
921++ {
922++ // one-shot event
923++
924++ Nepomuk::Resource eventRes = createDesktopEvent(event.uri, event.timestamp, event.application);
925++ eventRes.addType(NUAO::UsageEvent());
926++ eventRes.setProperty(NUAO::start(), event.timestamp);
927++ eventRes.setProperty(NUAO::end(), event.timestamp);
928++
929++ kDebug() << "Created one-shot Accessed event" << eventRes;
930++
931++ NepomukResourceScoreMaintainer::self()->processResource(event.uri, event.application);
932++
933++ break;
934++ }
935++
936++ case Event::Opened:
937++ // create a new event
938++ createDesktopEvent(event.uri, event.timestamp, event.application);
939++
940++ break;
941++
942++ case Event::Closed:
943++ {
944++ // We should find and close the last open event
945++ // TODO: This can have a problem if an app closes a document
946++ // while not in the current activity
947++ const QString query
948++ = QString::fromLatin1(
949++ "select ?r where { "
950++ "?r a nuao:DesktopEvent . "
951++ "?r %1 %2 . "
952++ "?r %3 %4 . "
953++ "?r %5 %6 . "
954++ "?r nuao:start ?start . "
955++ "OPTIONAL { ?r nuao:end ?d . } . "
956++ "FILTER(!BOUND(?d)) . "
957++ "}"
958++ "ORDER BY DESC (?start) LIMIT 1"
959++ ).arg(
960++ /* %1 */ resN3(NUAO_targettedResource),
961++ /* %2 */ resN3(anyResource(KUrl(event.uri))),
962++ /* %3 */ resN3(NUAO_initiatingAgent),
963++ /* %4 */ resN3(agentResource(event.application)),
964++ /* %5 */ resN3(KExt::usedActivity()),
965++ /* %6 */ resN3(currentActivityRes)
966++ );
967++ kDebug() << query;
968++
969++ Soprano::QueryResultIterator it
970++ = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(query, Soprano::Query::QueryLanguageSparql);
971++
972++ if (it.next()) {
973++ kDebug() << "Closing the event";
974++
975++ Nepomuk::Resource eventRes(it[0].uri());
976++ it.close();
977++
978++ eventRes.addProperty(NUAO::end(), event.timestamp);
979++
980++ NepomukResourceScoreMaintainer::self()->processResource(event.uri, event.application);
981++ }
982++
983++ break;
984++ }
985++
986++ default:
987++ // Nothing yet
988++ // TODO: Add focus and modification
989++ break;
990+ }
991+- else {
992+- // find the corresponding event
993+- // FIXME: enable this once the range of nao:identifier has been fixed and is no longer assumed to be rdfs:Resource
994+- // resulting in a wrong query.
995++
996++
997++// } else {
998++// // find the corresponding event
999++// // FIXME: enable this once the range of nao:identifier has been fixed and is no longer assumed to be rdfs:Resource
1000++// // resulting in a wrong query.
1001+ // Query query(ResourceTypeTerm(NUAO::DesktopEvent())
1002+ // && ComparisonTerm(NUAO::involves(),
1003+ // ResourceTerm(Nepomuk::Resource(KUrl(event.uri))), ComparisonTerm::Equal)
1004+@@ -88,77 +159,103 @@ void NepomukEventBackend::addEvents(const EventList & events)
1005+ // && !ComparisonTerm(NUAO::end(), Term()));
1006+ // query.setLimit(1);
1007+ // query.setQueryFlags(Query::NoResultRestrictions);
1008+-// const QString queryS = query.toSparqlQuery();
1009+- const QString queryS
1010+- = QString::fromLatin1("select ?r where { "
1011+- "?r a nuao:DesktopEvent . "
1012+- "?r nuao:involves %1 . "
1013+- "?r nuao:involves ?a . "
1014+- "?a a nao:Agent . "
1015+- "?a nao:identifier %2 . "
1016+- "OPTIONAL { ?r nuao:end ?d . } . "
1017+- "FILTER(!BOUND(?d)) . } "
1018+- "LIMIT 1")
1019+- .arg(Soprano::Node::resourceToN3(Nepomuk::Resource(KUrl(event.uri)).resourceUri()),
1020+- Soprano::Node::literalToN3(event.application));
1021+- kDebug() << queryS;
1022+- Soprano::QueryResultIterator it
1023+- = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(queryS, Soprano::Query::QueryLanguageSparql);
1024+- if(it.next()) {
1025+- Nepomuk::Resource eventRes(it[0].uri());
1026+- it.close();
1027+-
1028+- eventRes.addProperty(NUAO::end(), event.timestamp);
1029+- if(event.type == Event::Modified) {
1030+- eventRes.addType(NUAO::ModificationEvent());
1031+- }
1032+- else {
1033+- eventRes.addType(NUAO::UsageEvent());
1034+- }
1035+-
1036+- // In case of a modification event we create a new event which will
1037+- // be completed by the final Closed event since this one resource
1038+- // modification is done now. It ended with saving the resource.
1039+- if(event.type == Event::Modified) {
1040+- // create a new event
1041+- createDesktopEvent(event.uri, event.timestamp, event.application);
1042+- }
1043+- }
1044+- else {
1045+- kDebug() << "Failed to find matching Open event for resource" << event.uri << "and application" << event.application;
1046+- }
1047+- }
1048++// const QString query = query.toSparqlQuery();
1049++//
1050++// // TODO: Something strange is going on here - this should check for
1051++// // the activity as well
1052++// const QString query
1053++// = QString::fromLatin1("select ?r where { "
1054++// "?r a nuao:DesktopEvent . "
1055++// "?r %1 %2 . "
1056++// "?r %3 %4 . "
1057++// "OPTIONAL { ?r nuao:end ?d . } . "
1058++// "FILTER(!BOUND(?d)) . } "
1059++// "LIMIT 1")
1060++// .arg(
1061++// /* %1 */ resN3(NUAO_targettedResource),
1062++// /* %2 */ resN3(anyResource(KUrl(event.uri))),
1063++// /* %3 */ resN3(NUAO_initiatingAgent),
1064++// /* %4 */ resN3(agentResource(event.application))
1065++// );
1066++//
1067++// kDebug() << query;
1068++//
1069++// Soprano::QueryResultIterator it
1070++// = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(query, Soprano::Query::QueryLanguageSparql);
1071++//
1072++// if (it.next()) {
1073++// Nepomuk::Resource eventRes(it[0].uri());
1074++// it.close();
1075++//
1076++// eventRes.addProperty(NUAO::end(), event.timestamp);
1077++// if (event.type == Event::Modified) {
1078++// eventRes.addType(NUAO::ModificationEvent());
1079++// } else {
1080++// eventRes.addType(NUAO::UsageEvent());
1081++// }
1082++//
1083++// // TODO: We are not creating separate events for modifications
1084++// // // In case of a modification event we create a new event which will
1085++// // // be completed by the final Closed event since this one resource
1086++// // // modification is done now. It ended with saving the resource.
1087++// // if (event.type == Event::Modified) {
1088++// // // create a new event
1089++// // createDesktopEvent(event.uri, event.timestamp, event.application);
1090++// // }
1091++//
1092++// } else {
1093++// kDebug() << "Failed to find matching Open event for resource" << event.uri << "and application" << event.application;
1094++// }
1095++//
1096++// if (event.type == Event::Closed) {
1097++// NepomukResourceScoreMaintainer::self()->processResource(event.uri, event.application);
1098++// }
1099++// }
1100+ }
1101+ }
1102+
1103+ Nepomuk::Resource NepomukEventBackend::createDesktopEvent(const KUrl& uri, const QDateTime& startTime, const QString& app)
1104+ {
1105++ kDebug() << "Creating a new desktop event" << uri << startTime << app;
1106++
1107+ // one-shot event
1108+ Nepomuk::Resource eventRes(QUrl(), NUAO::DesktopEvent());
1109+- eventRes.addProperty(NUAO::involves(), Nepomuk::Resource(uri));
1110++ eventRes.addProperty(NUAO_targettedResource, anyResource(uri));
1111+ eventRes.addProperty(NUAO::start(), startTime);
1112+
1113++ kDebug() << "Created event" << eventRes.resourceUri()
1114++ << "for resource" << ((Nepomuk::Resource(uri)).resourceUri());
1115++
1116+ // the app
1117+ Nepomuk::Resource appRes(app, NAO::Agent());
1118+- eventRes.addProperty(NUAO::involves(), appRes);
1119++ eventRes.addProperty(NUAO_initiatingAgent, appRes);
1120+
1121+ // the activity
1122+- if(!m_currentActivity.isValid()
1123++ if (!m_currentActivity.isValid()
1124+ || m_currentActivity.identifiers().isEmpty()
1125+ || m_currentActivity.identifiers().first() != ActivityManager::self()->CurrentActivity()) {
1126+ // update the current activity resource
1127+- Soprano::QueryResultIterator it
1128+- = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(QString::fromLatin1("select ?r where { ?r a %1 . ?r %2 %3 . } LIMIT 1")
1129+- .arg(Soprano::Node::resourceToN3(KExt::Activity()),
1130+- Soprano::Node::resourceToN3(KExt::activityIdentifier()),
1131+- Soprano::Node::literalToN3(ActivityManager::self()->CurrentActivity())),
1132+- Soprano::Query::QueryLanguageSparql);
1133+- if(it.next()) {
1134++
1135++ kDebug() << "Assigning the activity to the event";
1136++
1137++ const QString query = QString::fromLatin1("select ?r where { "
1138++ " ?r a %1 . "
1139++ " ?r %2 %3 . "
1140++ "} LIMIT 1"
1141++ ).arg(
1142++ /* %1 */ resN3(KExt::Activity()),
1143++ /* %2 */ resN3(KExt::activityIdentifier()),
1144++ /* %3 */ resN3(currentActivityRes)
1145++ );
1146++
1147++ Soprano::QueryResultIterator it = Nepomuk::ResourceManager::instance()->mainModel()
1148++ ->executeQuery(query, Soprano::Query::QueryLanguageSparql);
1149++
1150++ if (it.next()) {
1151+ m_currentActivity = it[0].uri();
1152+- }
1153+- else {
1154+- m_currentActivity = Nepomuk::Resource(ActivityManager::self()->CurrentActivity(), Nepomuk::Vocabulary::KExt::Activity());
1155+- m_currentActivity.setProperty(Nepomuk::Vocabulary::KExt::activityIdentifier(), ActivityManager::self()->CurrentActivity());
1156++ } else {
1157++ m_currentActivity = currentActivityRes;
1158++ m_currentActivity.setProperty(KExt::activityIdentifier(), ActivityManager::self()->CurrentActivity());
1159+ }
1160+ }
1161+
1162+diff --git a/activitymanager/NepomukResourceScoreCache.cpp b/activitymanager/NepomukResourceScoreCache.cpp
1163+new file mode 100644
1164+index 0000000..8d1b66b
1165+--- /dev/null
1166++++ b/activitymanager/NepomukResourceScoreCache.cpp
1167+@@ -0,0 +1,214 @@
1168++/*
1169++ * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
1170++ *
1171++ * This program is free software; you can redistribute it and/or modify
1172++ * it under the terms of the GNU General Public License version 2,
1173++ * or (at your option) any later version, as published by the Free
1174++ * Software Foundation
1175++ *
1176++ * This program is distributed in the hope that it will be useful,
1177++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1178++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1179++ * GNU General Public License for more details
1180++ *
1181++ * You should have received a copy of the GNU General Public
1182++ * License along with this program; if not, write to the
1183++ * Free Software Foundation, Inc.,
1184++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1185++ */
1186++
1187++#include "NepomukResourceScoreCache.h"
1188++
1189++#include <cmath>
1190++
1191++#include <Soprano/Model>
1192++#include <Soprano/QueryResultIterator>
1193++
1194++#include <Nepomuk/Resource>
1195++#include <Nepomuk/ResourceManager>
1196++#include <Nepomuk/Variant>
1197++
1198++#include <KDebug>
1199++
1200++#include "kext.h"
1201++#include "nao.h"
1202++#include "nuao.h"
1203++
1204++#include "ActivityManager.h"
1205++
1206++using namespace Nepomuk::Vocabulary;
1207++
1208++#include "NepomukCommon.h"
1209++
1210++/**
1211++ *
1212++ */
1213++class NepomukResourceScoreCachePrivate {
1214++public:
1215++ Nepomuk::Resource self;
1216++ QString activity;
1217++ QString application;
1218++ QUrl resource;
1219++
1220++ qreal timeFactor(int days) const
1221++ {
1222++ // Exp is falling rather quickly, we are slowing it 32 times
1223++ return ::exp(- days / 32.0);
1224++ }
1225++
1226++ qreal timeFactor(QDateTime fromTime, QDateTime toTime = QDateTime::currentDateTime()) const
1227++ {
1228++ return timeFactor(fromTime.daysTo(toTime));
1229++ }
1230++
1231++};
1232++
1233++NepomukResourceScoreCache::NepomukResourceScoreCache(const QString & activity, const QString & application, const QUrl & resource)
1234++ : d(new NepomukResourceScoreCachePrivate())
1235++{
1236++ kDebug() << "Cache for" << activity << application << resource << anyResource(resource).resourceUri();
1237++
1238++ d->activity = activity;
1239++ d->application = application;
1240++ d->resource = resource;
1241++
1242++ const QString query
1243++ = QString::fromLatin1("select ?r where { "
1244++ "?r a %1 . "
1245++ "?r kext:usedActivity %2 . "
1246++ "?r kext:initiatingAgent %3 . "
1247++ "?r kext:targettedResource %4 . "
1248++ "} LIMIT 1"
1249++ ).arg(
1250++ /* %1 */ resN3(KExt::ResourceScoreCache()),
1251++ /* %2 */ resN3(currentActivityRes),
1252++ /* %3 */ resN3(agentResource(application)),
1253++ /* %4 */ resN3(anyResource(resource))
1254++ );
1255++
1256++ kDebug() << query;
1257++
1258++ Soprano::QueryResultIterator it
1259++ = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(query, Soprano::Query::QueryLanguageSparql);
1260++
1261++ if (it.next()) {
1262++ Nepomuk::Resource result(it[0].uri());
1263++ it.close();
1264++
1265++ d->self = result;
1266++
1267++ kDebug() << "Found an old cache" << d->self.resourceUri() << d->self.resourceType()
1268++ << "With a score of" << d->self.property(KExt::cachedScore()) << d->self.property(NAO::score());
1269++
1270++ } else {
1271++ Nepomuk::Resource result(QUrl(), KExt::ResourceScoreCache());
1272++
1273++ result.setProperty(
1274++ KExt::targettedResource(),
1275++ Nepomuk::Resource(resource)
1276++ );
1277++ result.setProperty(
1278++ KExt::initiatingAgent(), agentResource(application)
1279++ );
1280++ result.setProperty(
1281++ KExt::usedActivity(), activityResource(activity)
1282++ );
1283++ result.setProperty(KExt::cachedScore(), 0);
1284++
1285++ d->self = result;
1286++
1287++ kDebug() << "Created a new cache resource" << d->self.resourceUri() << d->self.resourceType();
1288++
1289++ }
1290++}
1291++
1292++NepomukResourceScoreCache::~NepomukResourceScoreCache()
1293++{
1294++ delete d;
1295++}
1296++
1297++void NepomukResourceScoreCache::updateScore()
1298++{
1299++ kDebug() << "Updating the score for " << d->resource;
1300++ kDebug() << "Last modified as string" << d->self.property(NAO::lastModified());
1301++
1302++ QDateTime lastModified = d->self.property(NAO::lastModified()).toDateTime();
1303++
1304++ qreal score = d->self.property(KExt::cachedScore()).toDouble();
1305++
1306++ if (lastModified.isValid()) {
1307++ // Adjusting the score depending on the time that passed since the
1308++ // last update
1309++
1310++ kDebug() << "Previous score:" << score;
1311++ score *= d->timeFactor(lastModified);
1312++ kDebug() << "Adjusted score:" << score;
1313++
1314++ } else {
1315++ // If we haven't had previous calculation, set the score to 0
1316++ score = 0;
1317++
1318++ }
1319++
1320++ kDebug() << "Last modified timestamp is" << lastModified << lastModified.isValid();
1321++
1322++ const QString query
1323++ = QString::fromLatin1("select distinct ?r where { "
1324++ "?r a nuao:DesktopEvent . "
1325++ "?r %1 %2 . "
1326++ "?r %3 %4 . "
1327++ "?r %5 %6 . "
1328++ "?r nuao:end ?end . "
1329++ "FILTER(?end >= %7) ."
1330++ " } "
1331++ ).arg(
1332++ /* %1 */ resN3(KExt::usedActivity()),
1333++ /* %2 */ resN3(activityResource(d->activity)),
1334++ /* %3 */ resN3(NUAO_targettedResource),
1335++ /* %4 */ resN3(anyResource(d->resource)),
1336++ /* %5 */ resN3(NUAO_initiatingAgent),
1337++ /* %6 */ resN3(agentResource(d->application)),
1338++ /* %7 */ litN3(lastModified.isValid() ? lastModified : QDateTime::fromMSecsSinceEpoch(0))
1339++ );
1340++
1341++ kDebug() << query;
1342++
1343++ Soprano::QueryResultIterator it
1344++ = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(query, Soprano::Query::QueryLanguageSparql);
1345++
1346++ d->self.setProperty(NAO::lastModified(), QDateTime::currentDateTime());
1347++
1348++ while (it.next()) {
1349++ Nepomuk::Resource result(it[0].uri());
1350++ QDateTime eventStart = result.property(NUAO::start()).toDateTime();
1351++ QDateTime eventEnd = result.property(NUAO::end()).toDateTime();
1352++
1353++ if (!eventStart.isValid()) continue;
1354++
1355++ if (!eventEnd.isValid()) {
1356++ // If the end was not saved, we are treating it as a simple
1357++ // Accessed event
1358++ eventEnd = eventStart;
1359++ }
1360++
1361++ int intervalLength = eventStart.secsTo(eventEnd);
1362++
1363++ if (intervalLength == 0) {
1364++ // We have an Accessed event - otherwise, this wouldn't be 0
1365++
1366++ score += d->timeFactor(eventEnd); // like it is open for 1 minute
1367++
1368++ } else if (intervalLength >= 4) {
1369++ // Ignoring stuff that was open for less than 4 seconds
1370++
1371++ score += d->timeFactor(eventEnd) * intervalLength / 60.0;
1372++ }
1373++
1374++ kDebug() << result.resourceUri() << eventStart << eventEnd << intervalLength;
1375++
1376++ }
1377++
1378++ kDebug() << "New calculated score:" << score << d->self.isValid();
1379++ d->self.setProperty(KExt::cachedScore(), score);
1380++ d->self.setProperty(NAO::score(), score);
1381++}
1382+diff --git a/activitymanager/NepomukResourceScoreCache.h b/activitymanager/NepomukResourceScoreCache.h
1383+new file mode 100644
1384+index 0000000..a26b5a2
1385+--- /dev/null
1386++++ b/activitymanager/NepomukResourceScoreCache.h
1387+@@ -0,0 +1,42 @@
1388++/*
1389++ * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
1390++ *
1391++ * This program is free software; you can redistribute it and/or modify
1392++ * it under the terms of the GNU General Public License version 2,
1393++ * or (at your option) any later version, as published by the Free
1394++ * Software Foundation
1395++ *
1396++ * This program is distributed in the hope that it will be useful,
1397++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1398++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1399++ * GNU General Public License for more details
1400++ *
1401++ * You should have received a copy of the GNU General Public
1402++ * License along with this program; if not, write to the
1403++ * Free Software Foundation, Inc.,
1404++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1405++ */
1406++
1407++#ifndef NEPOMUK_RESOURCE_SCORE_CACHE_H_
1408++#define NEPOMUK_RESOURCE_SCORE_CACHE_H_
1409++
1410++#include <QString>
1411++#include <QUrl>
1412++
1413++class NepomukResourceScoreCachePrivate;
1414++
1415++/**
1416++ *
1417++ */
1418++class NepomukResourceScoreCache {
1419++public:
1420++ NepomukResourceScoreCache(const QString & activity, const QString & application, const QUrl & resource);
1421++ virtual ~NepomukResourceScoreCache();
1422++
1423++ void updateScore();
1424++
1425++private:
1426++ class NepomukResourceScoreCachePrivate * const d;
1427++};
1428++
1429++#endif // NEPOMUK_RESOURCE_SCORE_CACHE_H_
1430+diff --git a/activitymanager/NepomukResourceScoreMaintainer.cpp b/activitymanager/NepomukResourceScoreMaintainer.cpp
1431+new file mode 100644
1432+index 0000000..f5e4d3c
1433+--- /dev/null
1434++++ b/activitymanager/NepomukResourceScoreMaintainer.cpp
1435+@@ -0,0 +1,145 @@
1436++/*
1437++ * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
1438++ *
1439++ * This program is free software; you can redistribute it and/or modify
1440++ * it under the terms of the GNU General Public License version 2,
1441++ * or (at your option) any later version, as published by the Free
1442++ * Software Foundation
1443++ *
1444++ * This program is distributed in the hope that it will be useful,
1445++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1446++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1447++ * GNU General Public License for more details
1448++ *
1449++ * You should have received a copy of the GNU General Public
1450++ * License along with this program; if not, write to the
1451++ * Free Software Foundation, Inc.,
1452++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1453++ */
1454++
1455++#include "NepomukResourceScoreMaintainer.h"
1456++
1457++#include <QList>
1458++#include <QMutex>
1459++#include <QThread>
1460++
1461++#include <KDebug>
1462++
1463++#include <Nepomuk/Resource>
1464++
1465++#include <time.h>
1466++#include "kext.h"
1467++
1468++#include "ActivityManager.h"
1469++#include "NepomukResourceScoreCache.h"
1470++
1471++class NepomukResourceScoreMaintainerPrivate: public QThread {
1472++public:
1473++ typedef QString ApplicationName;
1474++ typedef QString ActivityID;
1475++ typedef QList < QUrl > ResourceList;
1476++
1477++ typedef QMap < ApplicationName, ResourceList > Applications;
1478++ typedef QMap < ActivityID, Applications > ResourceTree;
1479++
1480++ ResourceTree openResources;
1481++ QMutex openResources_mutex;
1482++
1483++ void run();
1484++ void processActivity(const ActivityID & activity, const Applications & applications);
1485++
1486++ static NepomukResourceScoreMaintainer * s_instance;
1487++
1488++};
1489++
1490++NepomukResourceScoreMaintainer * NepomukResourceScoreMaintainerPrivate::s_instance = NULL;
1491++
1492++void NepomukResourceScoreMaintainerPrivate::run()
1493++{
1494++ forever {
1495++ // initial delay before processing the resources
1496++ sleep(5);
1497++
1498++ NepomukResourceScoreMaintainerPrivate::openResources_mutex.lock();
1499++ ResourceTree resources = openResources;
1500++ openResources.clear();
1501++ NepomukResourceScoreMaintainerPrivate::openResources_mutex.unlock();
1502++
1503++ const QString & activity = ActivityManager::self()->CurrentActivity();
1504++
1505++ // Let us first process the events related to the current
1506++ // activity so that the stats are available quicker
1507++
1508++ if (resources.contains(activity)) {
1509++ kDebug() << "Processing current activity events";
1510++
1511++ processActivity(activity, resources[activity]);
1512++ resources.remove(activity);
1513++ }
1514++
1515++ foreach (const ActivityID & activity, resources.keys()) {
1516++ kDebug() << "Processing activity" << activity;
1517++
1518++ processActivity(activity, resources[activity]);
1519++ }
1520++ }
1521++}
1522++
1523++void NepomukResourceScoreMaintainerPrivate::processActivity(const ActivityID & activity, const Applications & applications)
1524++{
1525++ foreach (const ApplicationName & application, applications.keys()) {
1526++ // Processing resources for the pair (activity, application)
1527++ kDebug() << " Processing application" << application;
1528++
1529++ foreach (const QUrl & resource, applications[application]) {
1530++ kDebug() << " Updating score for" << activity, application, resource;
1531++ NepomukResourceScoreCache(activity, application, resource).updateScore();
1532++
1533++ }
1534++ }
1535++}
1536++
1537++NepomukResourceScoreMaintainer * NepomukResourceScoreMaintainer::self()
1538++{
1539++ if (!NepomukResourceScoreMaintainerPrivate::s_instance) {
1540++ NepomukResourceScoreMaintainerPrivate::s_instance = new NepomukResourceScoreMaintainer();
1541++ }
1542++
1543++ return NepomukResourceScoreMaintainerPrivate::s_instance;
1544++}
1545++
1546++NepomukResourceScoreMaintainer::NepomukResourceScoreMaintainer()
1547++ : d(new NepomukResourceScoreMaintainerPrivate())
1548++{
1549++}
1550++
1551++NepomukResourceScoreMaintainer::~NepomukResourceScoreMaintainer()
1552++{
1553++ delete d;
1554++}
1555++
1556++void NepomukResourceScoreMaintainer::processResource(const KUrl & resource, const QString & application)
1557++{
1558++ d->openResources_mutex.lock();
1559++
1560++ // Checking whether the item is already scheduled for
1561++ // processing
1562++
1563++ kDebug() << "Adding" << resource << application << "to the queue";
1564++
1565++ const QString & activity = ActivityManager::self()->CurrentActivity();
1566++
1567++ if (d->openResources.contains(activity) &&
1568++ d->openResources[activity].contains(application) &&
1569++ d->openResources[activity][application].contains(resource)) {
1570++ return;
1571++ }
1572++
1573++ d->openResources[activity][application] << resource;
1574++
1575++ d->openResources_mutex.unlock();
1576++
1577++ d->start();
1578++}
1579++
1580++
1581+diff --git a/activitymanager/NepomukResourceScoreMaintainer.h b/activitymanager/NepomukResourceScoreMaintainer.h
1582+new file mode 100644
1583+index 0000000..cbef9f9
1584+--- /dev/null
1585++++ b/activitymanager/NepomukResourceScoreMaintainer.h
1586+@@ -0,0 +1,47 @@
1587++/*
1588++ * Copyright (C) 2011 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++#ifndef NEPOMUK_RESOURCE_SCORE_MAINTAINER_H_
1607++#define NEPOMUK_RESOURCE_SCORE_MAINTAINER_H_
1608++
1609++#include <QThread>
1610++#include <Nepomuk/Resource>
1611++
1612++#include "Event.h"
1613++
1614++class NepomukResourceScoreMaintainerPrivate;
1615++
1616++/**
1617++ * Thread to process desktop/usage events
1618++ */
1619++class NepomukResourceScoreMaintainer {
1620++public:
1621++ static NepomukResourceScoreMaintainer * self();
1622++
1623++ virtual ~NepomukResourceScoreMaintainer();
1624++
1625++ void processResource(const KUrl & resource, const QString & application);
1626++
1627++private:
1628++ NepomukResourceScoreMaintainer();
1629++
1630++ class NepomukResourceScoreMaintainerPrivate * const d;
1631++};
1632++
1633++#endif // NEPOMUK_RESOURCE_SCORE_MAINTAINER_H_
1634+diff --git a/activitymanager/SharedInfo.cpp b/activitymanager/SharedInfo.cpp
1635+new file mode 100644
1636+index 0000000..8c71c34
1637+--- /dev/null
1638++++ b/activitymanager/SharedInfo.cpp
1639+@@ -0,0 +1,51 @@
1640++/*
1641++ * Copyright (C) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
1642++ *
1643++ * This program is free software; you can redistribute it and/or modify
1644++ * it under the terms of the GNU General Public License version 2,
1645++ * or (at your option) any later version, as published by the Free
1646++ * Software Foundation
1647++ *
1648++ * This program is distributed in the hope that it will be useful,
1649++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1650++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1651++ * GNU General Public License for more details
1652++ *
1653++ * You should have received a copy of the GNU General Public
1654++ * License along with this program; if not, write to the
1655++ * Free Software Foundation, Inc.,
1656++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1657++ */
1658++
1659++#include "SharedInfo.h"
1660++
1661++SharedInfo * SharedInfo::s_instance = NULL;
1662++
1663++SharedInfo * SharedInfo::self()
1664++{
1665++ if (!s_instance) {
1666++ s_instance = new SharedInfo();
1667++ }
1668++
1669++ return s_instance;
1670++}
1671++
1672++SharedInfo::SharedInfo()
1673++{
1674++}
1675++
1676++SharedInfo::~SharedInfo()
1677++{
1678++}
1679++
1680++QHash < WId, SharedInfo::WindowData > const & SharedInfo::windows() const
1681++{
1682++ return m_windows;
1683++}
1684++
1685++QHash < KUrl, SharedInfo::ResourceData > const & SharedInfo::resources() const
1686++{
1687++ return m_resources;
1688++}
1689++
1690++
1691+diff --git a/activitymanager/SharedInfo.h b/activitymanager/SharedInfo.h
1692+new file mode 100644
1693+index 0000000..6e60612
1694+--- /dev/null
1695++++ b/activitymanager/SharedInfo.h
1696+@@ -0,0 +1,63 @@
1697++/*
1698++ * Copyright (C) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
1699++ *
1700++ * This program is free software; you can redistribute it and/or modify
1701++ * it under the terms of the GNU General Public License version 2,
1702++ * or (at your option) any later version, as published by the Free
1703++ * Software Foundation
1704++ *
1705++ * This program is distributed in the hope that it will be useful,
1706++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1707++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1708++ * GNU General Public License for more details
1709++ *
1710++ * You should have received a copy of the GNU General Public
1711++ * License along with this program; if not, write to the
1712++ * Free Software Foundation, Inc.,
1713++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1714++ */
1715++
1716++#ifndef SHARED_INFO_H_
1717++#define SHARED_INFO_H_
1718++
1719++#include <KUrl>
1720++#include <QSet>
1721++#include <QString>
1722++#include <QHash>
1723++
1724++#include "Event.h"
1725++
1726++/**
1727++ *
1728++ */
1729++class SharedInfo {
1730++public:
1731++ static SharedInfo * self();
1732++
1733++ virtual ~SharedInfo();
1734++
1735++ struct WindowData {
1736++ QSet < KUrl > resources;
1737++ QString application;
1738++ };
1739++
1740++ struct ResourceData {
1741++ Event::Reason reason;
1742++ QSet < QString > activities;
1743++ QString mimetype;
1744++ };
1745++
1746++ QHash < WId, WindowData > const & windows() const;
1747++ QHash < KUrl, ResourceData > const & resources() const;
1748++
1749++private:
1750++ QHash < WId, WindowData > m_windows;
1751++ QHash < KUrl, ResourceData > m_resources;
1752++
1753++ static SharedInfo * s_instance;
1754++ SharedInfo();
1755++
1756++ friend class ActivityManager;
1757++};
1758++
1759++#endif // SHARED_INFO_H_
1760+diff --git a/activitymanager/SlcEventBackend.cpp b/activitymanager/SlcEventBackend.cpp
1761+new file mode 100644
1762+index 0000000..fe8f01d
1763+--- /dev/null
1764++++ b/activitymanager/SlcEventBackend.cpp
1765+@@ -0,0 +1,127 @@
1766++/*
1767++ * Copyright (C) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
1768++ *
1769++ * This program is free software; you can redistribute it and/or modify
1770++ * it under the terms of the GNU General Public License version 2,
1771++ * or (at your option) any later version, as published by the Free
1772++ * Software Foundation
1773++ *
1774++ * This program is distributed in the hope that it will be useful,
1775++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1776++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1777++ * GNU General Public License for more details
1778++ *
1779++ * You should have received a copy of the GNU General Public
1780++ * License along with this program; if not, write to the
1781++ * Free Software Foundation, Inc.,
1782++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1783++ */
1784++
1785++#include "SlcEventBackend.h"
1786++#include "slcadaptor.h"
1787++
1788++#include <QDBusConnection>
1789++#include <KDebug>
1790++#include <KWindowSystem>
1791++#include <KUrl>
1792++
1793++#include "SharedInfo.h"
1794++
1795++SlcEventBackend::SlcEventBackend()
1796++ : focussedWindow(0)
1797++{
1798++ QDBusConnection dbus = QDBusConnection::sessionBus();
1799++ new SLCAdaptor(this);
1800++ dbus.registerObject("/SLC", this);
1801++
1802++ connect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)),
1803++ this, SLOT(activeWindowChanged(WId)));
1804++}
1805++
1806++void SlcEventBackend::addEvents(const EventList & events)
1807++{
1808++ foreach (const Event & event, events) {
1809++ switch (event.type) {
1810++ case Event::FocussedIn:
1811++ case Event::Opened:
1812++ // kDebug() << "Event::FocussedIn" << focussedWindow << event.wid << event.uri;
1813++
1814++ lastFocussedResource[event.wid] = event.uri;
1815++
1816++ if (event.wid == focussedWindow) {
1817++ updateFocus(focussedWindow);
1818++ }
1819++
1820++ break;
1821++
1822++ case Event::FocussedOut:
1823++ case Event::Closed:
1824++ // kDebug() << "Event::FocussedOut" << focussedWindow << event.wid << event.uri;
1825++
1826++ if (lastFocussedResource[event.wid] == event.uri) {
1827++ lastFocussedResource[event.wid] = KUrl();
1828++ }
1829++
1830++ if (event.wid == focussedWindow) {
1831++ updateFocus();
1832++ }
1833++
1834++ break;
1835++
1836++ default:
1837++ // nothing
1838++ break;
1839++ }
1840++ }
1841++}
1842++
1843++KUrl SlcEventBackend::_focussedResourceURI()
1844++{
1845++ KUrl kuri;
1846++
1847++ if (lastFocussedResource.contains(focussedWindow)) {
1848++ kuri = lastFocussedResource[focussedWindow];
1849++ } else {
1850++ foreach (const KUrl & uri, SharedInfo::self()->windows()[focussedWindow].resources) {
1851++ kuri = uri;
1852++ break;
1853++ }
1854++ }
1855++
1856++ return kuri;
1857++}
1858++
1859++QString SlcEventBackend::focussedResourceURI()
1860++{
1861++ return _focussedResourceURI().url();
1862++}
1863++
1864++QString SlcEventBackend::focussedResourceMimetype()
1865++{
1866++ return SharedInfo::self()->resources().contains(_focussedResourceURI()) ?
1867++ SharedInfo::self()->resources()[_focussedResourceURI()].mimetype : QString();
1868++}
1869++
1870++void SlcEventBackend::activeWindowChanged(WId wid)
1871++{
1872++ if (wid == focussedWindow) return;
1873++
1874++ focussedWindow = wid;
1875++
1876++ updateFocus(wid);
1877++}
1878++
1879++void SlcEventBackend::updateFocus(WId wid)
1880++{
1881++ // kDebug() << "Updating focus for " << wid;
1882++
1883++ if (wid == 0 || !SharedInfo::self()->windows().contains(wid)) {
1884++ // kDebug() << "Clearing focus";
1885++ emit focusChanged(QString(), QString());
1886++
1887++ } else if (wid == focussedWindow) {
1888++ // kDebug() << "It is the currently focussed window";
1889++ emit focusChanged(focussedResourceURI(), SharedInfo::self()->resources()[_focussedResourceURI()].mimetype);
1890++
1891++ }
1892++}
1893+diff --git a/activitymanager/SlcEventBackend.h b/activitymanager/SlcEventBackend.h
1894+new file mode 100644
1895+index 0000000..3c79792
1896+--- /dev/null
1897++++ b/activitymanager/SlcEventBackend.h
1898+@@ -0,0 +1,59 @@
1899++/*
1900++ * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
1901++ *
1902++ * This program is free software; you can redistribute it and/or modify
1903++ * it under the terms of the GNU General Public License version 2,
1904++ * or (at your option) any later version, as published by the Free
1905++ * Software Foundation
1906++ *
1907++ * This program is distributed in the hope that it will be useful,
1908++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1909++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1910++ * GNU General Public License for more details
1911++ *
1912++ * You should have received a copy of the GNU General Public
1913++ * License along with this program; if not, write to the
1914++ * Free Software Foundation, Inc.,
1915++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1916++ */
1917++
1918++#ifndef SLC_EVENT_BACKEND_H_
1919++#define SLC_EVENT_BACKEND_H_
1920++
1921++#include "EventBackend.h"
1922++
1923++#include <QObject>
1924++#include <KUrl>
1925++
1926++/**
1927++ *
1928++ */
1929++class SlcEventBackend: public QObject, public EventBackend {
1930++ Q_OBJECT
1931++ Q_CLASSINFO("D-Bus Interface", "org.kde.ActivityManager.SLC")
1932++
1933++public:
1934++ SlcEventBackend();
1935++
1936++ virtual void addEvents(const EventList & events);
1937++
1938++private Q_SLOTS:
1939++ void activeWindowChanged(WId windowId);
1940++
1941++public Q_SLOTS:
1942++ QString focussedResourceURI();
1943++ QString focussedResourceMimetype();
1944++
1945++Q_SIGNALS:
1946++ void focusChanged(const QString & uri, const QString & mimetype);
1947++
1948++private:
1949++ void updateFocus(WId wid = 0);
1950++
1951++ WId focussedWindow;
1952++ KUrl _focussedResourceURI();
1953++ QHash < WId, KUrl > lastFocussedResource;
1954++};
1955++
1956++#endif // SLC_EVENT_BACKEND_H_
1957++
1958+diff --git a/activitymanager/ZeitgeistEventBackend.cpp b/activitymanager/ZeitgeistEventBackend.cpp
1959+index 6ae0cf0..1bbd050 100644
1960+--- a/activitymanager/ZeitgeistEventBackend.cpp
1961++++ b/activitymanager/ZeitgeistEventBackend.cpp
1962+@@ -34,20 +34,20 @@
1963+
1964+ static QString eventInterpretation(Event::Type type)
1965+ {
1966+- switch (type) {
1967+- case Event::Accessed:
1968+- return QtZeitgeist::Interpretation::Event::ZGAccessEvent;
1969++ // switch (type) {
1970++ // case Event::Accessed:
1971++ // return QtZeitgeist::Interpretation::Event::ZGAccessEvent;
1972+
1973+- case Event::Opened:
1974+- return QtZeitgeist::Interpretation::Event::ZGAccessEvent;
1975++ // case Event::Opened:
1976++ // return QtZeitgeist::Interpretation::Event::ZGAccessEvent;
1977+
1978+- case Event::Modified:
1979+- return QtZeitgeist::Interpretation::Event::ZGModifyEvent;
1980++ // case Event::Modified:
1981++ // return QtZeitgeist::Interpretation::Event::ZGModifyEvent;
1982+
1983+- case Event::Closed:
1984+- return QtZeitgeist::Interpretation::Event::ZGLeaveEvent;
1985++ // case Event::Closed:
1986++ // return QtZeitgeist::Interpretation::Event::ZGLeaveEvent;
1987+
1988+- }
1989++ // }
1990+
1991+ // shut up GCC
1992+ return QString();
1993+@@ -55,22 +55,22 @@ static QString eventInterpretation(Event::Type type)
1994+
1995+ static QString eventManifestation(Event::Reason reason)
1996+ {
1997+- switch (reason) {
1998+- case Event::User:
1999+- return QtZeitgeist::Manifestation::Event::ZGUserActivity;
2000++ // switch (reason) {
2001++ // case Event::User:
2002++ // return QtZeitgeist::Manifestation::Event::ZGUserActivity;
2003+
2004+- case Event::Heuristic:
2005+- return QtZeitgeist::Manifestation::Event::ZGHeuristicActivity;
2006++ // case Event::Heuristic:
2007++ // return QtZeitgeist::Manifestation::Event::ZGHeuristicActivity;
2008+
2009+- case Event::Scheduled:
2010+- return QtZeitgeist::Manifestation::Event::ZGScheduledActivity;
2011++ // case Event::Scheduled:
2012++ // return QtZeitgeist::Manifestation::Event::ZGScheduledActivity;
2013+
2014+- case Event::System:
2015+- return QtZeitgeist::Manifestation::Event::ZGSystemNotification;
2016++ // case Event::System:
2017++ // return QtZeitgeist::Manifestation::Event::ZGSystemNotification;
2018+
2019+- case Event::World:
2020+- return QtZeitgeist::Manifestation::Event::ZGWorldActivity;
2021+- }
2022++ // case Event::World:
2023++ // return QtZeitgeist::Manifestation::Event::ZGWorldActivity;
2024++ // }
2025+
2026+ // shut up GCC
2027+ return QtZeitgeist::Manifestation::Event::ZGUserActivity;
2028+diff --git a/activitymanager/main.cpp b/activitymanager/main.cpp
2029+index cfaed00..2ce18ed 100644
2030+--- a/activitymanager/main.cpp
2031++++ b/activitymanager/main.cpp
2032+@@ -19,8 +19,6 @@
2033+
2034+ #include <ActivityManager.h>
2035+
2036+-#include <KDebug>
2037+-
2038+ #include <KAboutData>
2039+ #include <KCmdLineArgs>
2040+
2041+diff --git a/activitymanager/ontologies/CMakeLists.txt b/activitymanager/ontologies/CMakeLists.txt
2042+new file mode 100644
2043+index 0000000..838b1f4
2044+--- /dev/null
2045++++ b/activitymanager/ontologies/CMakeLists.txt
2046+@@ -0,0 +1,8 @@
2047++project(nepomuk_ontologies)
2048++
2049++configure_file(kamdrso.ontology.in ${CMAKE_CURRENT_BINARY_DIR}/kamdrso.ontology)
2050++
2051++install(FILES
2052++ kamdrso.trig
2053++ ${CMAKE_CURRENT_BINARY_DIR}/kamdrso.ontology
2054++DESTINATION ${CMAKE_INSTALL_PREFIX}/share/ontology/kde)
2055+diff --git a/activitymanager/ontologies/kamdrso.ontology.in b/activitymanager/ontologies/kamdrso.ontology.in
2056+new file mode 100644
2057+index 0000000..032dac0
2058+--- /dev/null
2059++++ b/activitymanager/ontologies/kamdrso.ontology.in
2060+@@ -0,0 +1,8 @@
2061++[Ontology]
2062++Version=1.0
2063++Name=KDE Activity Manager Daemon - Resource Scoring Ontology
2064++Comment=The KDE Resource Scoring Ontology contains classes related to KAMD's scoring mechanisms
2065++Namespace=http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso#" ;
2066++Path=${CMAKE_INSTALL_PREFIX}/share/ontology/kde/kamdrso.trig
2067++MimeType=application/x-trig
2068++Type=Data
2069+diff --git a/activitymanager/ontologies/kamdrso.trig b/activitymanager/ontologies/kamdrso.trig
2070+new file mode 100644
2071+index 0000000..b968231
2072+--- /dev/null
2073++++ b/activitymanager/ontologies/kamdrso.trig
2074+@@ -0,0 +1,112 @@
2075++#
2076++# Copyright (c) 2011 Ivan Cukic <ivan.cukic@kde.org>
2077++# All rights reserved, licensed under either CC-BY or BSD.
2078++#
2079++# You are free:
2080++# * to Share - to copy, distribute and transmit the work
2081++# * to Remix - to adapt the work
2082++# Under the following conditions:
2083++# * Attribution - You must attribute the work in the manner specified by the author
2084++# or licensor (but not in any way that suggests that they endorse you or your use
2085++# of the work).
2086++#
2087++# Redistribution and use in source and binary forms, with or without modification,
2088++# are permitted provided that the following conditions are met:
2089++# * Redistributions of source code must retain the above copyright notice, this
2090++# list of conditions and the following disclaimer.
2091++# * Redistributions in binary form must reproduce the above copyright notice, this
2092++# list of conditions and the following disclaimer in the documentation and/or
2093++# other materials provided with the distribution.
2094++# * Neither the names of the authors nor the names of contributors may
2095++# be used to endorse or promote products derived from this ontology without
2096++# specific prior written permission.
2097++#
2098++# THIS ONTOLOGY IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2099++# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2100++# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2101++# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2102++# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2103++# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2104++# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2105++# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2106++# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2107++# THIS ONTOLOGY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2108++#
2109++
2110++@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
2111++@prefix nao: <http://www.semanticdesktop.org/ontologies/2007/08/15/nao#> .
2112++@prefix nrl: <http://www.semanticdesktop.org/ontologies/2007/08/15/nrl#> .
2113++@prefix nie: <http://www.semanticdesktop.org/ontologies/2007/01/19/nie#> .
2114++@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
2115++@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
2116++@prefix kamdrso: <http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso#> .
2117++@prefix nfo: <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#> .
2118++
2119++kamdrso: {
2120++ kamdrso:unixFileMode
2121++ a rdf:Property ;
2122++ rdfs:label "Unix file mode" ;
2123++ rdfs:comment "The file mode value as seen on unix file systems." ;
2124++ rdfs:domain nfo:FileDataObject ;
2125++ rdfs:range xsd:integer ;
2126++ nao:userVisible false .
2127++
2128++ kamdrso:unixFileOwner
2129++ a rdf:Property ;
2130++ rdfs:label "Unix file owner" ;
2131++ rdfs:comment "The owner of the file as seen on unix file systems. This is intended as the low-level counterpart to nfo:owner." ;
2132++ rdfs:domain nfo:FileDataObject ;
2133++ rdfs:range xsd:string ;
2134++ nao:userVisible false .
2135++
2136++ kamdrso:unixFileGroup
2137++ a rdf:Property ;
2138++ rdfs:label "Unix file group" ;
2139++ rdfs:comment "The group of the file as seen on unix file systems." ;
2140++ rdfs:domain nfo:FileDataObject ;
2141++ rdfs:range xsd:string ;
2142++ nao:userVisible false .
2143++
2144++ kamdrso:Activity
2145++ a rdfs:Class ;
2146++ rdfs:subClassOf rdfs:Resource ;
2147++ rdfs:label "activity" ;
2148++ rdfs:comment "A Plasma activity." .
2149++
2150++ kamdrso:usedActivity
2151++ a rdf:Property ;
2152++ rdfs:label "used activity" ;
2153++ rdfs:comment "The activity that was active when resource was created. This is mostly used for graphs or desktop events." ;
2154++ rdfs:domain rdfs:Resource ;
2155++ rdfs:range kamdrso:Activity ;
2156++ nao:userVisible false .
2157++
2158++ kamdrso:activityIdentifier
2159++ a rdf:Property ;
2160++ rdfs:subPropertyOf nao:identifier ;
2161++ rdfs:label "activity identifier" ;
2162++ rdfs:comment "The unique ID of the activity as used outside of Nepomuk. Typically this is a UUID." ;
2163++ rdfs:domain kamdrso:Activity ;
2164++ rdfs:range xsd:string ;
2165++ nao:userVisible false .
2166++
2167++}
2168++
2169++<http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso/metadata> {
2170++ <http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso/metadata>
2171++ a nrl:GraphMetadata ;
2172++ nrl:coreGraphMetadataFor kamdrso: .
2173++
2174++
2175++ kamdrso:
2176++ a nrl:Ontology , nrl:DocumentGraph ;
2177++ nao:prefLabel "KDE Extensions Ontology" ;
2178++ nao:hasDefaultNamespace "http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso#" ;
2179++ nao:hasDefaultNamespaceAbbreviation "kamdrso" ;
2180++ nao:lastModified "2011-06-02T12:31:43Z" ;
2181++ nao:serializationLanguage "TriG" ;
2182++ nao:status "Unstable" ;
2183++ nrl:updatable "0" ;
2184++ nao:version "2" .
2185++}
2186++
2187+diff --git a/activitymanager/org.kde.ActivityManager.SLC.xml b/activitymanager/org.kde.ActivityManager.SLC.xml
2188+new file mode 100644
2189+index 0000000..b9df419
2190+--- /dev/null
2191++++ b/activitymanager/org.kde.ActivityManager.SLC.xml
2192+@@ -0,0 +1,15 @@
2193++<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
2194++<node>
2195++ <interface name="org.kde.ActivityManager.SLC">
2196++ <signal name="focusChanged">
2197++ <arg name="uri" type="s" direction="out"/>
2198++ <arg name="mimetype" type="s" direction="out"/>
2199++ </signal>
2200++ <method name="focussedResourceURI">
2201++ <arg type="s" direction="out"/>
2202++ </method>
2203++ <method name="focussedResourceMimetype">
2204++ <arg type="s" direction="out"/>
2205++ </method>
2206++ </interface>
2207++</node>
2208+diff --git a/activitymanager/org.kde.ActivityManager.xml b/activitymanager/org.kde.ActivityManager.xml
2209+index b03e826..a09252b 100644
2210+--- a/activitymanager/org.kde.ActivityManager.xml
2211++++ b/activitymanager/org.kde.ActivityManager.xml
2212+@@ -23,23 +23,6 @@
2213+ <arg name="id" type="s" direction="out"/>
2214+ <arg name="state" type="i" direction="out"/>
2215+ </signal>
2216+- <signal name="ResourceAccessed">
2217+- <arg name="application" type="s" direction="out"/>
2218+- <arg name="uri" type="s" direction="out"/>
2219+- </signal>
2220+- <signal name="ResourceOpened">
2221+- <arg name="application" type="s" direction="out"/>
2222+- <arg name="windowId" type="u" direction="out"/>
2223+- <arg name="uri" type="s" direction="out"/>
2224+- </signal>
2225+- <signal name="ResourceModified">
2226+- <arg name="windowId" type="u" direction="out"/>
2227+- <arg name="uri" type="s" direction="out"/>
2228+- </signal>
2229+- <signal name="ResourceClosed">
2230+- <arg name="windowId" type="u" direction="out"/>
2231+- <arg name="uri" type="s" direction="out"/>
2232+- </signal>
2233+ <method name="Start">
2234+ </method>
2235+ <method name="Stop">
2236+@@ -102,26 +85,16 @@
2237+ <method name="IsBackstoreAvailable">
2238+ <arg type="b" direction="out"/>
2239+ </method>
2240+- <method name="NotifyResourceAccessed">
2241+- <arg name="application" type="s" direction="in"/>
2242+- <arg name="uri" type="s" direction="in"/>
2243+- </method>
2244+- <method name="NotifyResourceOpened">
2245++ <method name="RegisterResourceEvent">
2246+ <arg name="application" type="s" direction="in"/>
2247+ <arg name="windowId" type="u" direction="in"/>
2248+ <arg name="uri" type="s" direction="in"/>
2249++ <arg name="event" type="u" direction="in"/>
2250++ <arg name="reason" type="u" direction="in"/>
2251+ </method>
2252+- <method name="NotifyResourceModified">
2253+- <arg name="windowId" type="u" direction="in"/>
2254+- <arg name="uri" type="s" direction="in"/>
2255+- </method>
2256+- <method name="NotifyResourceClosed">
2257+- <arg name="windowId" type="u" direction="in"/>
2258+- <arg name="uri" type="s" direction="in"/>
2259+- </method>
2260+- <method name="ActivitiesForResource">
2261+- <arg type="as" direction="out"/>
2262++ <method name="RegisterResourceMimeType">
2263+ <arg name="uri" type="s" direction="in"/>
2264++ <arg name="mimetype" type="s" direction="in"/>
2265+ </method>
2266+ </interface>
2267+ </node>
2268+diff --git a/activitymanager/queries.sparql b/activitymanager/queries.sparql
2269+new file mode 100644
2270+index 0000000..680eef5
2271+--- /dev/null
2272++++ b/activitymanager/queries.sparql
2273+@@ -0,0 +1,43 @@
2274++// Getting the highest scored caches for (application/agent, activity)
2275++
2276++select distinct ?resource,
2277++ (
2278++ (
2279++ ?lastScore * bif:exp(-
2280++ bif:datediff('day', ?lastUpdate, ##CURRENT_DATETIME##)
2281++ )
2282++ )
2283++ as ?score) where {
2284++ ?cache kext:targettedResource ?resource .
2285++ ?cache a kext:ResourceScoreCache .
2286++ ?cache nao:lastModified ?lastUpdate .
2287++ ?cache kext:cachedScore ?lastScore .
2288++ ?cache kext:usedActivity ##ACTIVITY## .
2289++ ?cache kext:initiatingAgent ##AGENT## .
2290++ OPTIONAL { ?resource nie:url ?uri . } .
2291++}
2292++ORDER BY DESC (?score)
2293++LIMIT 10
2294++
2295++// Getting the highest scored caches for (activity)
2296++
2297++select distinct ?resource,
2298++ (
2299++ (
2300++ SUM (
2301++ ?lastScore * bif:exp(
2302++ - bif:datediff('day', ?lastUpdate, ##CURRENT_DATETIME##)
2303++ )
2304++ )
2305++ )
2306++ as ?score
2307++ ) where {
2308++ ?cache kext:targettedResource ?resource .
2309++ ?cache a kext:ResourceScoreCache .
2310++ ?cache nao:lastModified ?lastUpdate .
2311++ ?cache kext:cachedScore ?lastScore .
2312++ ?cache kext:usedActivity ##ACTIVITY## .
2313++ }
2314++ GROUP BY (?resource)
2315++ ORDER BY DESC (?score)
2316++ LIMIT 10
2317+diff --git a/activitymanager/scripts/delete-stats.sh b/activitymanager/scripts/delete-stats.sh
2318+new file mode 100755
2319+index 0000000..a237c38
2320+--- /dev/null
2321++++ b/activitymanager/scripts/delete-stats.sh
2322+@@ -0,0 +1,4 @@
2323++#!/bin/zsh
2324++alias nepomukcmd="sopranocmd --socket `kde4-config --path socket`nepomuk-socket --model main --nrl"
2325++for res in `nepomukcmd --foo query 'select ?r { ?r a kext:ResourceScoreCache . }'`; nepomukcmd rm $res
2326++for res in `nepomukcmd --foo query 'select ?r { ?r a nuao:DesktopEvent . }'`; nepomukcmd rm $res
2327+diff --git a/nepomuk/ontologies/kext.trig b/nepomuk/ontologies/kext.trig
2328+index be5d041..b743638 100644
2329+--- a/nepomuk/ontologies/kext.trig
2330++++ b/nepomuk/ontologies/kext.trig
2331+@@ -7,18 +7,18 @@
2332+ # * to Remix - to adapt the work
2333+ # Under the following conditions:
2334+ # * Attribution - You must attribute the work in the manner specified by the author
2335+-# or licensor (but not in any way that suggests that they endorse you or your use
2336++# or licensor (but not in any way that suggests that they endorse you or your use
2337+ # of the work).
2338+ #
2339+-# Redistribution and use in source and binary forms, with or without modification,
2340++# Redistribution and use in source and binary forms, with or without modification,
2341+ # are permitted provided that the following conditions are met:
2342+-# * Redistributions of source code must retain the above copyright notice, this
2343++# * Redistributions of source code must retain the above copyright notice, this
2344+ # list of conditions and the following disclaimer.
2345+-# * Redistributions in binary form must reproduce the above copyright notice, this
2346+-# list of conditions and the following disclaimer in the documentation and/or
2347++# * Redistributions in binary form must reproduce the above copyright notice, this
2348++# list of conditions and the following disclaimer in the documentation and/or
2349+ # other materials provided with the distribution.
2350+ # * Neither the names of the authors nor the names of contributors may
2351+-# be used to endorse or promote products derived from this ontology without
2352++# be used to endorse or promote products derived from this ontology without
2353+ # specific prior written permission.
2354+ #
2355+ # THIS ONTOLOGY IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2356+@@ -94,6 +94,35 @@ kext: {
2357+ rdfs:range xsd:string ;
2358+ nrl:cardinality 1 ;
2359+ nao:userVisible false .
2360++
2361++ kext:ResourceScoreCache
2362++ a rdfs:Class ;
2363++ rdfs:subClassOf rdfs:Resource ;
2364++ rdfs:label "Resource score cache" ;
2365++ rdfs:comment "For storing the automatically calculated score based on the usage statistics" ;
2366++ nao:userVisible false .
2367++
2368++ kext:targettedResource
2369++ a rdf:Property ;
2370++ rdfs:comment "Resource for which the score is calculated." ;
2371++ rdfs:domain kext:ResourceScoreCache ;
2372++ rdfs:label "resource" ;
2373++ rdfs:range rdfs:Resource .
2374++
2375++ kext:initiatingAgent
2376++ a rdf:Property ;
2377++ rdfs:comment "Relates the score to the agent initiating the events." ;
2378++ rdfs:domain kext:ResourceScoreCache ;
2379++ rdfs:label "involved agent" ;
2380++ rdfs:range nao:Agent .
2381++
2382++ kext:cachedScore
2383++ a rdf:Property ;
2384++ rdfs:subPropertyOf nao:score ;
2385++ rdfs:comment "The automatically calculated score" ;
2386++ rdfs:domain kext:ResourceScoreCache ;
2387++ rdfs:label "calculated score" ;
2388++ rdfs:range xsd:float .
2389+ }
2390+
2391+ <http://nepomuk.kde.org/ontologies/2010/11/29/kext/metadata> {
2392+--
2393+1.7.5.4
2394+
2395
2396=== added file 'debian/patches/kubuntu_mobile_ported-the-new-plugin-system-to-active-development-4.diff'
2397--- debian/patches/kubuntu_mobile_ported-the-new-plugin-system-to-active-development-4.diff 1970-01-01 00:00:00 +0000
2398+++ debian/patches/kubuntu_mobile_ported-the-new-plugin-system-to-active-development-4.diff 2011-08-18 09:25:23 +0000
2399@@ -0,0 +1,3622 @@
2400+From 6f809ee3c098c9a89af74f3f3e731e9d4ddda1bd Mon Sep 17 00:00:00 2001
2401+From: =?UTF-8?q?Ivan=20=C4=8Cuki=C4=87?= <ivan.cukic@kde.org>
2402+Date: Thu, 14 Jul 2011 18:21:12 +0200
2403+Subject: [PATCH 4/6] Ported the new plugin system to active-development/4.7
2404+
2405+---
2406+ activitymanager/ActivityManager.cpp | 3 +-
2407+ activitymanager/CMakeLists.txt | 76 +-----
2408+ activitymanager/EventBackend.cpp | 40 ---
2409+ activitymanager/EventBackend.h | 40 ---
2410+ activitymanager/EventProcessor.cpp | 85 +++++--
2411+ activitymanager/EventProcessor.h | 5 +-
2412+ activitymanager/NepomukCommon.h | 63 -----
2413+ activitymanager/NepomukEventBackend.cpp | 267 --------------------
2414+ activitymanager/NepomukEventBackend.h | 47 ----
2415+ activitymanager/NepomukResourceScoreCache.cpp | 214 ----------------
2416+ activitymanager/NepomukResourceScoreCache.h | 42 ---
2417+ activitymanager/NepomukResourceScoreMaintainer.cpp | 145 -----------
2418+ activitymanager/NepomukResourceScoreMaintainer.h | 47 ----
2419+ activitymanager/Plugin.cpp | 56 ++++
2420+ activitymanager/Plugin.h | 59 +++++
2421+ activitymanager/SharedInfo.cpp | 20 ++
2422+ activitymanager/SharedInfo.h | 17 ++-
2423+ activitymanager/SlcEventBackend.cpp | 127 ----------
2424+ activitymanager/SlcEventBackend.h | 59 -----
2425+ activitymanager/ZeitgeistEventBackend.cpp | 95 -------
2426+ activitymanager/ZeitgeistEventBackend.h | 39 ---
2427+ activitymanager/activitymanager-plugin.desktop | 12 +
2428+ activitymanager/krso.trig | 100 ++++++++
2429+ activitymanager/ontologies/CMakeLists.txt | 8 -
2430+ activitymanager/ontologies/kamdrso.ontology.in | 8 -
2431+ activitymanager/ontologies/kamdrso.trig | 112 --------
2432+ activitymanager/org.kde.ActivityManager.SLC.xml | 15 --
2433+ activitymanager/plugins/CMakeLists.txt | 3 +
2434+ activitymanager/plugins/dummy/CMakeLists.txt | 30 +++
2435+ .../dummy/activitymanager-plugin-dummy.desktop | 19 ++
2436+ activitymanager/plugins/dummy/dummy.cpp | 34 +++
2437+ activitymanager/plugins/dummy/dummy.h | 35 +++
2438+ activitymanager/plugins/nepomuk/CMakeLists.txt | 61 +++++
2439+ activitymanager/plugins/nepomuk/NepomukCommon.h | 67 +++++
2440+ activitymanager/plugins/nepomuk/NepomukPlugin.cpp | 264 +++++++++++++++++++
2441+ activitymanager/plugins/nepomuk/NepomukPlugin.h | 47 ++++
2442+ .../plugins/nepomuk/NepomukResourceScoreCache.cpp | 215 ++++++++++++++++
2443+ .../plugins/nepomuk/NepomukResourceScoreCache.h | 42 +++
2444+ .../nepomuk/NepomukResourceScoreMaintainer.cpp | 145 +++++++++++
2445+ .../nepomuk/NepomukResourceScoreMaintainer.h | 47 ++++
2446+ .../nepomuk/activitymanager-plugin-nepomuk.desktop | 20 ++
2447+ activitymanager/plugins/slc/CMakeLists.txt | 37 +++
2448+ .../plugins/slc/activitymanager-plugin-slc.desktop | 19 ++
2449+ .../plugins/slc/org.kde.ActivityManager.SLC.xml | 15 ++
2450+ activitymanager/plugins/slc/slc.cpp | 132 ++++++++++
2451+ activitymanager/plugins/slc/slc.h | 58 +++++
2452+ 46 files changed, 1634 insertions(+), 1457 deletions(-)
2453+ delete mode 100644 activitymanager/EventBackend.cpp
2454+ delete mode 100644 activitymanager/EventBackend.h
2455+ delete mode 100644 activitymanager/NepomukCommon.h
2456+ delete mode 100644 activitymanager/NepomukEventBackend.cpp
2457+ delete mode 100644 activitymanager/NepomukEventBackend.h
2458+ delete mode 100644 activitymanager/NepomukResourceScoreCache.cpp
2459+ delete mode 100644 activitymanager/NepomukResourceScoreCache.h
2460+ delete mode 100644 activitymanager/NepomukResourceScoreMaintainer.cpp
2461+ delete mode 100644 activitymanager/NepomukResourceScoreMaintainer.h
2462+ create mode 100644 activitymanager/Plugin.cpp
2463+ create mode 100644 activitymanager/Plugin.h
2464+ delete mode 100644 activitymanager/SlcEventBackend.cpp
2465+ delete mode 100644 activitymanager/SlcEventBackend.h
2466+ delete mode 100644 activitymanager/ZeitgeistEventBackend.cpp
2467+ delete mode 100644 activitymanager/ZeitgeistEventBackend.h
2468+ create mode 100644 activitymanager/activitymanager-plugin.desktop
2469+ create mode 100644 activitymanager/krso.trig
2470+ delete mode 100644 activitymanager/ontologies/CMakeLists.txt
2471+ delete mode 100644 activitymanager/ontologies/kamdrso.ontology.in
2472+ delete mode 100644 activitymanager/ontologies/kamdrso.trig
2473+ delete mode 100644 activitymanager/org.kde.ActivityManager.SLC.xml
2474+ create mode 100644 activitymanager/plugins/CMakeLists.txt
2475+ create mode 100644 activitymanager/plugins/dummy/CMakeLists.txt
2476+ create mode 100644 activitymanager/plugins/dummy/activitymanager-plugin-dummy.desktop
2477+ create mode 100644 activitymanager/plugins/dummy/dummy.cpp
2478+ create mode 100644 activitymanager/plugins/dummy/dummy.h
2479+ create mode 100644 activitymanager/plugins/nepomuk/CMakeLists.txt
2480+ create mode 100644 activitymanager/plugins/nepomuk/NepomukCommon.h
2481+ create mode 100644 activitymanager/plugins/nepomuk/NepomukPlugin.cpp
2482+ create mode 100644 activitymanager/plugins/nepomuk/NepomukPlugin.h
2483+ create mode 100644 activitymanager/plugins/nepomuk/NepomukResourceScoreCache.cpp
2484+ create mode 100644 activitymanager/plugins/nepomuk/NepomukResourceScoreCache.h
2485+ create mode 100644 activitymanager/plugins/nepomuk/NepomukResourceScoreMaintainer.cpp
2486+ create mode 100644 activitymanager/plugins/nepomuk/NepomukResourceScoreMaintainer.h
2487+ create mode 100644 activitymanager/plugins/nepomuk/activitymanager-plugin-nepomuk.desktop
2488+ create mode 100644 activitymanager/plugins/slc/CMakeLists.txt
2489+ create mode 100644 activitymanager/plugins/slc/activitymanager-plugin-slc.desktop
2490+ create mode 100644 activitymanager/plugins/slc/org.kde.ActivityManager.SLC.xml
2491+ create mode 100644 activitymanager/plugins/slc/slc.cpp
2492+ create mode 100644 activitymanager/plugins/slc/slc.h
2493+
2494+diff --git a/activitymanager/ActivityManager.cpp b/activitymanager/ActivityManager.cpp
2495+index e821c92..0e06cf5 100644
2496+--- a/activitymanager/ActivityManager.cpp
2497++++ b/activitymanager/ActivityManager.cpp
2498+@@ -123,7 +123,6 @@ ActivityManagerPrivate::ActivityManagerPrivate(ActivityManager * parent,
2499+ ksmserverInterface->deleteLater();
2500+ ksmserverInterface = 0;
2501+ }
2502+-
2503+ }
2504+
2505+ ActivityManagerPrivate::~ActivityManagerPrivate()
2506+@@ -148,6 +147,7 @@ void ActivityManagerPrivate::windowClosed(WId windowId)
2507+
2508+ void ActivityManagerPrivate::activeWindowChanged(WId windowId)
2509+ {
2510++ Q_UNUSED(windowId)
2511+ // kDebug() << "Window focussed..." << windowId
2512+ // << "one of ours?" << windows.contains(windowId);
2513+
2514+@@ -234,6 +234,7 @@ bool ActivityManagerPrivate::setCurrentActivity(const QString & id)
2515+ scheduleConfigSync();
2516+ }
2517+
2518++ SharedInfo::self()->setCurrentActivity(id);
2519+ emit q->CurrentActivityChanged(id);
2520+ return true;
2521+ }
2522+diff --git a/activitymanager/CMakeLists.txt b/activitymanager/CMakeLists.txt
2523+index 726fcce..3e1ab10 100644
2524+--- a/activitymanager/CMakeLists.txt
2525++++ b/activitymanager/CMakeLists.txt
2526+@@ -1,9 +1,11 @@
2527+ project(ActivityManager)
2528+
2529+-set (ADDITIONAL_LINK_LIBS)
2530++set(ADDITIONAL_LINK_LIBS)
2531+
2532+ add_subdirectory(kded)
2533+-add_subdirectory(ontologies)
2534++# add_subdirectory(ontologies)
2535++
2536++add_subdirectory(plugins)
2537+
2538+ # Checking for Nepomuk
2539+ macro_optional_find_package(Nepomuk)
2540+@@ -22,26 +24,6 @@ if(Nepomuk_FOUND)
2541+ )
2542+ endif(Nepomuk_FOUND)
2543+
2544+-# Checking for QtZeitgeist
2545+-macro_optional_find_package(QZeitgeist)
2546+-
2547+-if (QZEITGEIST_INCLUDE_DIR)
2548+- set(QZeitgeist_FOUND TRUE)
2549+-endif(QZEITGEIST_INCLUDE_DIR)
2550+-
2551+-macro_log_feature(
2552+- QZeitgeist_FOUND
2553+- "QtZeitgeist" "Qt bindings for Zeitgeist" "http://gitorious.org/kde-zeitgeist/libqzeitgeist/" FALSE ""
2554+- "RECOMMENDED: Zeitgeist and QtZeitgeist is needed for resource tracking")
2555+-if (QZeitgeist_FOUND)
2556+- set(HAVE_QZEITGEIST 1)
2557+- include_directories(${QZEITGEIST_INCLUDE_DIR})
2558+- set(ADDITIONAL_LINK_LIBS
2559+- ${ADDITIONAL_LINK_LIBS}
2560+- ${QZEITGEIST_LIBRARY}
2561+- )
2562+-endif(QZeitgeist_FOUND)
2563+-
2564+ # config file
2565+ configure_file(config-features.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-features.h )
2566+
2567+@@ -57,58 +39,18 @@ include_directories(
2568+ set(activity_manager_SRCS
2569+ ActivityManager.cpp
2570+ EventProcessor.cpp
2571+- EventBackend.cpp
2572++ Plugin.cpp
2573+ Event.cpp
2574+ SharedInfo.cpp
2575+ main.cpp
2576+ )
2577+
2578+-set(activity_manager_backends_SRCS
2579+- NepomukEventBackend.cpp
2580+- NepomukResourceScoreMaintainer.cpp
2581+- NepomukResourceScoreCache.cpp
2582+- ZeitgeistEventBackend.cpp
2583+- SlcEventBackend.cpp
2584+- )
2585+-
2586+ qt4_add_dbus_adaptor(
2587+ activity_manager_SRCS org.kde.ActivityManager.xml
2588+ ActivityManager.h ActivityManager
2589+ )
2590+
2591+-qt4_add_dbus_adaptor(
2592+- activity_manager_SRCS org.kde.ActivityManager.SLC.xml
2593+- SlcEventBackend.h SlcEventBackend
2594+- )
2595+-
2596+-if(Nepomuk_FOUND)
2597+- soprano_add_ontology(activity_manager_SRCS
2598+- ${CMAKE_SOURCE_DIR}/nepomuk/ontologies/kext.trig
2599+- "KExt" "Nepomuk::Vocabulary" "trig"
2600+- )
2601+-
2602+- # soprano_add_ontology(activity_manager_SRCS
2603+- # ${CMAKE_CURRENT_SOURCE_DIR}/ontologies/kamdrso.trig
2604+- # "RSO" "Nepomuk::Vocabulary" "trig"
2605+- # )
2606+-
2607+- soprano_add_ontology(activity_manager_SRCS
2608+- ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nie/nie.trig
2609+- "NIE" "Nepomuk::Vocabulary" "trig"
2610+- )
2611+-
2612+- soprano_add_ontology(activity_manager_SRCS
2613+- ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nepomuk/nao.trig
2614+- "NAO" "Nepomuk::Vocabulary" "trig"
2615+- )
2616+-
2617+- soprano_add_ontology(activity_manager_SRCS
2618+- ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nepomuk/nuao.trig
2619+- "NUAO" "Nepomuk::Vocabulary" "trig"
2620+- )
2621+-endif()
2622+-
2623+-kde4_add_executable(activity-manager ${activity_manager_SRCS} ${activity_manager_backends_SRCS})
2624++kde4_add_executable(activity-manager ${activity_manager_SRCS})
2625+
2626+ target_link_libraries(
2627+ activity-manager
2628+@@ -129,3 +71,9 @@ install(
2629+ TARGETS activity-manager ${INSTALL_TARGETS_DEFAULT_ARGS}
2630+ )
2631+
2632++install(FILES
2633++ activitymanager-plugin.desktop
2634++ DESTINATION ${SERVICETYPES_INSTALL_DIR}
2635++ )
2636++
2637++
2638+diff --git a/activitymanager/EventBackend.cpp b/activitymanager/EventBackend.cpp
2639+deleted file mode 100644
2640+index 2650dbf..0000000
2641+--- a/activitymanager/EventBackend.cpp
2642++++ /dev/null
2643+@@ -1,40 +0,0 @@
2644+-/*
2645+- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
2646+- *
2647+- * This program is free software; you can redistribute it and/or modify
2648+- * it under the terms of the GNU General Public License version 2,
2649+- * or (at your option) any later version, as published by the Free
2650+- * Software Foundation
2651+- *
2652+- * This program is distributed in the hope that it will be useful,
2653+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2654+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2655+- * GNU General Public License for more details
2656+- *
2657+- * You should have received a copy of the GNU General Public
2658+- * License along with this program; if not, write to the
2659+- * Free Software Foundation, Inc.,
2660+- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2661+- */
2662+-
2663+-#include "EventBackend.h"
2664+-
2665+-EventBackend::EventBackend()
2666+-{
2667+-}
2668+-
2669+-EventBackend::~EventBackend()
2670+-{
2671+-}
2672+-
2673+-void EventBackend::addEvents(const EventList & events)
2674+-{
2675+- Q_UNUSED(events)
2676+-}
2677+-
2678+-void EventBackend::setResourceMimeType(const QString & uri, const QString & mimetype)
2679+-{
2680+- Q_UNUSED(uri)
2681+- Q_UNUSED(mimetype)
2682+-}
2683+-
2684+diff --git a/activitymanager/EventBackend.h b/activitymanager/EventBackend.h
2685+deleted file mode 100644
2686+index bd7cbf9..0000000
2687+--- a/activitymanager/EventBackend.h
2688++++ /dev/null
2689+@@ -1,40 +0,0 @@
2690+-/*
2691+- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
2692+- *
2693+- * This program is free software; you can redistribute it and/or modify
2694+- * it under the terms of the GNU General Public License version 2,
2695+- * or (at your option) any later version, as published by the Free
2696+- * Software Foundation
2697+- *
2698+- * This program is distributed in the hope that it will be useful,
2699+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2700+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2701+- * GNU General Public License for more details
2702+- *
2703+- * You should have received a copy of the GNU General Public
2704+- * License along with this program; if not, write to the
2705+- * Free Software Foundation, Inc.,
2706+- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2707+- */
2708+-
2709+-#ifndef EVENT_BACKEND_H_
2710+-#define EVENT_BACKEND_H_
2711+-
2712+-#include <EventProcessor.h>
2713+-#include "Event.h"
2714+-
2715+-/**
2716+- *
2717+- */
2718+-class EventBackend {
2719+-public:
2720+- EventBackend();
2721+- virtual ~EventBackend();
2722+-
2723+- virtual void addEvents(const EventList & events);
2724+- virtual void setResourceMimeType(const QString & uri, const QString & mimetype);
2725+-
2726+-};
2727+-
2728+-#endif // EVENT_BACKEND_H_
2729+-
2730+diff --git a/activitymanager/EventProcessor.cpp b/activitymanager/EventProcessor.cpp
2731+index 48bb405..a6c9d2e 100644
2732+--- a/activitymanager/EventProcessor.cpp
2733++++ b/activitymanager/EventProcessor.cpp
2734+@@ -19,32 +19,27 @@
2735+ */
2736+
2737+ #include "EventProcessor.h"
2738+-#include "EventBackend.h"
2739++#include "Plugin.h"
2740+
2741+ #include "config-features.h"
2742+
2743+-#ifdef HAVE_QZEITGEIST
2744+-#include "ZeitgeistEventBackend.h"
2745+-#endif
2746++#include "Plugin.h"
2747+
2748+-#ifdef HAVE_NEPOMUK
2749+-#include "NepomukEventBackend.h"
2750+-#endif
2751+-
2752+-#include "SlcEventBackend.h"
2753++#include <KDebug>
2754+
2755+ #include <QDateTime>
2756+ #include <QList>
2757+ #include <QMutex>
2758+
2759+ #include <KDebug>
2760++#include <KServiceTypeTrader>
2761+
2762+ #include <time.h>
2763+
2764+ class EventProcessorPrivate: public QThread {
2765+ public:
2766+- QList < EventBackend * > lazyBackends;
2767+- QList < EventBackend * > syncBackends;
2768++ QList < Plugin * > lazyBackends;
2769++ QList < Plugin * > syncBackends;
2770+
2771+ QList < Event > events;
2772+ QMutex events_mutex;
2773+@@ -79,7 +74,7 @@ void EventProcessorPrivate::run()
2774+
2775+ EventProcessorPrivate::events_mutex.unlock();
2776+
2777+- foreach (EventBackend * backend, lazyBackends) {
2778++ foreach (Plugin * backend, lazyBackends) {
2779+ backend->addEvents(currentEvents);
2780+ }
2781+ }
2782+@@ -97,13 +92,63 @@ EventProcessor * EventProcessor::self()
2783+ EventProcessor::EventProcessor()
2784+ : d(new EventProcessorPrivate())
2785+ {
2786+-#ifdef HAVE_QZEITGEIST
2787+- d->lazyBackends.append(new ZeitgeistEventBackend());
2788+-#endif
2789+-#ifdef HAVE_NEPOMUK
2790+- d->lazyBackends.append(new NepomukEventBackend());
2791+-#endif
2792+- d->syncBackends.append(new SlcEventBackend());
2793++ // Plugin loading
2794++
2795++ kDebug() << "Loading plugins...";
2796++
2797++ KService::List offers = KServiceTypeTrader::self()->query("ActivityManager/Plugin");
2798++
2799++ QStringList disabledPlugins = SharedInfo::self()->pluginConfig("Global").readEntry("disabledPlugins", QStringList());
2800++ kDebug() << disabledPlugins << "disabled due to the configuration in activitymanager-pluginsrc";
2801++
2802++ foreach(const KService::Ptr & service, offers) {
2803++ if (!disabledPlugins.contains(service->library())) {
2804++ disabledPlugins.append(
2805++ service->property("X-ActivityManager-PluginOverrides", QVariant::StringList).toStringList()
2806++ );
2807++ kDebug() << service->name() << "disables" <<
2808++ service->property("X-ActivityManager-PluginOverrides", QVariant::StringList);
2809++
2810++ }
2811++ }
2812++
2813++ foreach(const KService::Ptr & service, offers) {
2814++ if (disabledPlugins.contains(service->library())) {
2815++ continue;
2816++ }
2817++
2818++ kDebug() << "Loading plugin:"
2819++ << service->name() << service->storageId() << service->library()
2820++ << service->property("X-ActivityManager-PluginType", QVariant::String);
2821++
2822++ KPluginFactory * factory = KPluginLoader(service->library()).factory();
2823++
2824++ if (!factory) {
2825++ kDebug() << "Failed to load plugin:" << service->name();
2826++ continue;
2827++ }
2828++
2829++ Plugin * plugin = factory->create < Plugin > (this);
2830++ plugin->setSharedInfo(SharedInfo::self());
2831++
2832++ if (plugin) {
2833++ const QString & type = service->property("X-ActivityManager-PluginType", QVariant::String).toString();
2834++
2835++ if (type == "lazyeventhandler") {
2836++ d->lazyBackends << plugin;
2837++ kDebug() << "Added to lazy plugins";
2838++
2839++ } else if (type == "synceventhandler"){
2840++ d->syncBackends << plugin;
2841++ kDebug() << "Added to sync plugins";
2842++
2843++ }
2844++
2845++ } else {
2846++ kDebug() << "Failed to load plugin:" << service->name();
2847++ }
2848++
2849++ }
2850+ }
2851+
2852+ EventProcessor::~EventProcessor()
2853+@@ -118,7 +163,7 @@ void EventProcessor::addEvent(const QString & application, WId wid, const QStrin
2854+ {
2855+ Event newEvent(application, wid, uri, type, reason);
2856+
2857+- foreach (EventBackend * backend, d->syncBackends) {
2858++ foreach (Plugin * backend, d->syncBackends) {
2859+ backend->addEvents(QList < Event > () << newEvent);
2860+ }
2861+
2862+diff --git a/activitymanager/EventProcessor.h b/activitymanager/EventProcessor.h
2863+index 64eeeb3..061e07c 100644
2864+--- a/activitymanager/EventProcessor.h
2865++++ b/activitymanager/EventProcessor.h
2866+@@ -20,17 +20,18 @@
2867+ #ifndef EVENT_PROCESSOR_H
2868+ #define EVENT_PROCESSOR_H
2869+
2870++#include <QObject>
2871+ #include <QThread>
2872+
2873+ #include "Event.h"
2874+
2875+-class EventBackend;
2876++class Plugin;
2877+ class EventProcessorPrivate;
2878+
2879+ /**
2880+ * Thread to process desktop/usage events
2881+ */
2882+-class EventProcessor {
2883++class EventProcessor: public QObject {
2884+ public:
2885+ static EventProcessor * self();
2886+
2887+diff --git a/activitymanager/NepomukCommon.h b/activitymanager/NepomukCommon.h
2888+deleted file mode 100644
2889+index 9df5a62..0000000
2890+--- a/activitymanager/NepomukCommon.h
2891++++ /dev/null
2892+@@ -1,63 +0,0 @@
2893+-/*
2894+- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
2895+- *
2896+- * This program is free software; you can redistribute it and/or modify
2897+- * it under the terms of the GNU General Public License version 2,
2898+- * or (at your option) any later version, as published by the Free
2899+- * Software Foundation
2900+- *
2901+- * This program is distributed in the hope that it will be useful,
2902+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2903+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2904+- * GNU General Public License for more details
2905+- *
2906+- * You should have received a copy of the GNU General Public
2907+- * License along with this program; if not, write to the
2908+- * Free Software Foundation, Inc.,
2909+- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2910+- */
2911+-
2912+-#ifndef NEPOMUK_COMMON_H_
2913+-#define NEPOMUK_COMMON_H_
2914+-
2915+-#include "nie.h"
2916+-
2917+-#define NUAO_targettedResource KUrl(NUAO::nuaoNamespace().toString() + QLatin1String("targettedResource"))
2918+-#define NUAO_initiatingAgent KUrl(NUAO::nuaoNamespace().toString() + QLatin1String("initiatingAgent"))
2919+-// #define NUAO_involvesActivity KUrl(NUAO::nuaoNamespace().toString() + QLatin1String("involvesActivity"))
2920+-
2921+-#define activityResource(ID) Nepomuk::Resource(ID, KExt::Activity())
2922+-#define agentResource(ID) Nepomuk::Resource(ID, NAO::Agent())
2923+-#define currentActivityRes activityResource(ActivityManager::self()->CurrentActivity())
2924+-
2925+-// #define anyResource(ID) Nepomuk::Resource(KUrl(ID))
2926+-
2927+-inline Nepomuk::Resource anyResource(const QUrl & uri)
2928+-{
2929+- Nepomuk::Resource result(uri);
2930+-
2931+- kDebug() << "setting the URI" << result.isFile() << result.isValid();
2932+- result.setProperty(Nepomuk::Vocabulary::NIE::url(), uri);
2933+- kDebug() << "set the URI" << result.isFile() << result.isValid();
2934+-
2935+- return result;
2936+-}
2937+-
2938+-inline Nepomuk::Resource anyResource(const QString & uri)
2939+-{
2940+- return anyResource(KUrl(uri));
2941+-}
2942+-
2943+-#define litN3(A) Soprano::Node::literalToN3(A)
2944+-
2945+-inline QString resN3(const QUrl & uri)
2946+-{
2947+- return Soprano::Node::resourceToN3(uri);
2948+-}
2949+-
2950+-inline QString resN3(const Nepomuk::Resource & resource)
2951+-{
2952+- return Soprano::Node::resourceToN3(resource.resourceUri());
2953+-}
2954+-
2955+-#endif // NEPOMUK_COMMON_H_
2956+diff --git a/activitymanager/NepomukEventBackend.cpp b/activitymanager/NepomukEventBackend.cpp
2957+deleted file mode 100644
2958+index 65c398c..0000000
2959+--- a/activitymanager/NepomukEventBackend.cpp
2960++++ /dev/null
2961+@@ -1,267 +0,0 @@
2962+-/*
2963+- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
2964+- * Copyright (c) 2011 Sebastian Trueg <trueg@kde.org>
2965+- *
2966+- * This program is free software; you can redistribute it and/or modify
2967+- * it under the terms of the GNU General Public License version 2,
2968+- * or (at your option) any later version, as published by the Free
2969+- * Software Foundation
2970+- *
2971+- * This program is distributed in the hope that it will be useful,
2972+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2973+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2974+- * GNU General Public License for more details
2975+- *
2976+- * You should have received a copy of the GNU General Public
2977+- * License along with this program; if not, write to the
2978+- * Free Software Foundation, Inc.,
2979+- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2980+- */
2981+-
2982+-#include "config-features.h"
2983+-
2984+-#ifndef HAVE_NEPOMUK
2985+-#ifdef _MSC_VER
2986+-#pragma warning()
2987+-#pragma message("No Nepomuk, disabling desktop events processing")
2988+-#else
2989+- #warning "No Nepomuk, disabling desktop events processing"
2990+-#endif
2991+-
2992+-#else // HAVE_NEPOMUK
2993+-
2994+-#include "NepomukEventBackend.h"
2995+-#include "NepomukResourceScoreMaintainer.h"
2996+-
2997+-#include "Event.h"
2998+-#include "ActivityManager.h"
2999+-#include "kext.h"
3000+-
3001+-#include <nepomuk/resource.h>
3002+-#include <nepomuk/nuao.h>
3003+-#include <nepomuk/resourcemanager.h>
3004+-#include <nepomuk/variant.h>
3005+-
3006+-#include <Nepomuk/Query/Query>
3007+-#include <Nepomuk/Query/ResourceTerm>
3008+-#include <Nepomuk/Query/ResourceTypeTerm>
3009+-#include <Nepomuk/Query/ComparisonTerm>
3010+-#include <Nepomuk/Query/LiteralTerm>
3011+-#include <Nepomuk/Query/NegationTerm>
3012+-
3013+-#include <Soprano/Vocabulary/NAO>
3014+-#include <Soprano/QueryResultIterator>
3015+-#include <Soprano/Node>
3016+-#include <Soprano/Model>
3017+-
3018+-#include <kdebug.h>
3019+-
3020+-#include "NepomukCommon.h"
3021+-
3022+-using namespace Soprano::Vocabulary;
3023+-using namespace Nepomuk::Vocabulary;
3024+-using namespace Nepomuk::Query;
3025+-
3026+-NepomukEventBackend::NepomukEventBackend()
3027+-{
3028+-}
3029+-
3030+-void NepomukEventBackend::addEvents(const EventList & events)
3031+-{
3032+- foreach (const Event& event, events) {
3033+- kDebug() << "We are processing event" << event.type << event.uri;
3034+- kDebug() << "for agent" << event.application << agentResource(event.application).resourceUri();
3035+-
3036+- switch (event.type) {
3037+- case Event::Accessed:
3038+- {
3039+- // one-shot event
3040+-
3041+- Nepomuk::Resource eventRes = createDesktopEvent(event.uri, event.timestamp, event.application);
3042+- eventRes.addType(NUAO::UsageEvent());
3043+- eventRes.setProperty(NUAO::start(), event.timestamp);
3044+- eventRes.setProperty(NUAO::end(), event.timestamp);
3045+-
3046+- kDebug() << "Created one-shot Accessed event" << eventRes;
3047+-
3048+- NepomukResourceScoreMaintainer::self()->processResource(event.uri, event.application);
3049+-
3050+- break;
3051+- }
3052+-
3053+- case Event::Opened:
3054+- // create a new event
3055+- createDesktopEvent(event.uri, event.timestamp, event.application);
3056+-
3057+- break;
3058+-
3059+- case Event::Closed:
3060+- {
3061+- // We should find and close the last open event
3062+- // TODO: This can have a problem if an app closes a document
3063+- // while not in the current activity
3064+- const QString query
3065+- = QString::fromLatin1(
3066+- "select ?r where { "
3067+- "?r a nuao:DesktopEvent . "
3068+- "?r %1 %2 . "
3069+- "?r %3 %4 . "
3070+- "?r %5 %6 . "
3071+- "?r nuao:start ?start . "
3072+- "OPTIONAL { ?r nuao:end ?d . } . "
3073+- "FILTER(!BOUND(?d)) . "
3074+- "}"
3075+- "ORDER BY DESC (?start) LIMIT 1"
3076+- ).arg(
3077+- /* %1 */ resN3(NUAO_targettedResource),
3078+- /* %2 */ resN3(anyResource(KUrl(event.uri))),
3079+- /* %3 */ resN3(NUAO_initiatingAgent),
3080+- /* %4 */ resN3(agentResource(event.application)),
3081+- /* %5 */ resN3(KExt::usedActivity()),
3082+- /* %6 */ resN3(currentActivityRes)
3083+- );
3084+- kDebug() << query;
3085+-
3086+- Soprano::QueryResultIterator it
3087+- = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(query, Soprano::Query::QueryLanguageSparql);
3088+-
3089+- if (it.next()) {
3090+- kDebug() << "Closing the event";
3091+-
3092+- Nepomuk::Resource eventRes(it[0].uri());
3093+- it.close();
3094+-
3095+- eventRes.addProperty(NUAO::end(), event.timestamp);
3096+-
3097+- NepomukResourceScoreMaintainer::self()->processResource(event.uri, event.application);
3098+- }
3099+-
3100+- break;
3101+- }
3102+-
3103+- default:
3104+- // Nothing yet
3105+- // TODO: Add focus and modification
3106+- break;
3107+- }
3108+-
3109+-
3110+-// } else {
3111+-// // find the corresponding event
3112+-// // FIXME: enable this once the range of nao:identifier has been fixed and is no longer assumed to be rdfs:Resource
3113+-// // resulting in a wrong query.
3114+-// Query query(ResourceTypeTerm(NUAO::DesktopEvent())
3115+-// && ComparisonTerm(NUAO::involves(),
3116+-// ResourceTerm(Nepomuk::Resource(KUrl(event.uri))), ComparisonTerm::Equal)
3117+-// && ComparisonTerm(NUAO::involves(),
3118+-// ResourceTypeTerm(NAO::Agent())
3119+-// && ComparisonTerm(NAO::identifier(), LiteralTerm(event.application), ComparisonTerm::Equal))
3120+-// && !ComparisonTerm(NUAO::end(), Term()));
3121+-// query.setLimit(1);
3122+-// query.setQueryFlags(Query::NoResultRestrictions);
3123+-// const QString query = query.toSparqlQuery();
3124+-//
3125+-// // TODO: Something strange is going on here - this should check for
3126+-// // the activity as well
3127+-// const QString query
3128+-// = QString::fromLatin1("select ?r where { "
3129+-// "?r a nuao:DesktopEvent . "
3130+-// "?r %1 %2 . "
3131+-// "?r %3 %4 . "
3132+-// "OPTIONAL { ?r nuao:end ?d . } . "
3133+-// "FILTER(!BOUND(?d)) . } "
3134+-// "LIMIT 1")
3135+-// .arg(
3136+-// /* %1 */ resN3(NUAO_targettedResource),
3137+-// /* %2 */ resN3(anyResource(KUrl(event.uri))),
3138+-// /* %3 */ resN3(NUAO_initiatingAgent),
3139+-// /* %4 */ resN3(agentResource(event.application))
3140+-// );
3141+-//
3142+-// kDebug() << query;
3143+-//
3144+-// Soprano::QueryResultIterator it
3145+-// = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(query, Soprano::Query::QueryLanguageSparql);
3146+-//
3147+-// if (it.next()) {
3148+-// Nepomuk::Resource eventRes(it[0].uri());
3149+-// it.close();
3150+-//
3151+-// eventRes.addProperty(NUAO::end(), event.timestamp);
3152+-// if (event.type == Event::Modified) {
3153+-// eventRes.addType(NUAO::ModificationEvent());
3154+-// } else {
3155+-// eventRes.addType(NUAO::UsageEvent());
3156+-// }
3157+-//
3158+-// // TODO: We are not creating separate events for modifications
3159+-// // // In case of a modification event we create a new event which will
3160+-// // // be completed by the final Closed event since this one resource
3161+-// // // modification is done now. It ended with saving the resource.
3162+-// // if (event.type == Event::Modified) {
3163+-// // // create a new event
3164+-// // createDesktopEvent(event.uri, event.timestamp, event.application);
3165+-// // }
3166+-//
3167+-// } else {
3168+-// kDebug() << "Failed to find matching Open event for resource" << event.uri << "and application" << event.application;
3169+-// }
3170+-//
3171+-// if (event.type == Event::Closed) {
3172+-// NepomukResourceScoreMaintainer::self()->processResource(event.uri, event.application);
3173+-// }
3174+-// }
3175+- }
3176+-}
3177+-
3178+-Nepomuk::Resource NepomukEventBackend::createDesktopEvent(const KUrl& uri, const QDateTime& startTime, const QString& app)
3179+-{
3180+- kDebug() << "Creating a new desktop event" << uri << startTime << app;
3181+-
3182+- // one-shot event
3183+- Nepomuk::Resource eventRes(QUrl(), NUAO::DesktopEvent());
3184+- eventRes.addProperty(NUAO_targettedResource, anyResource(uri));
3185+- eventRes.addProperty(NUAO::start(), startTime);
3186+-
3187+- kDebug() << "Created event" << eventRes.resourceUri()
3188+- << "for resource" << ((Nepomuk::Resource(uri)).resourceUri());
3189+-
3190+- // the app
3191+- Nepomuk::Resource appRes(app, NAO::Agent());
3192+- eventRes.addProperty(NUAO_initiatingAgent, appRes);
3193+-
3194+- // the activity
3195+- if (!m_currentActivity.isValid()
3196+- || m_currentActivity.identifiers().isEmpty()
3197+- || m_currentActivity.identifiers().first() != ActivityManager::self()->CurrentActivity()) {
3198+- // update the current activity resource
3199+-
3200+- kDebug() << "Assigning the activity to the event";
3201+-
3202+- const QString query = QString::fromLatin1("select ?r where { "
3203+- " ?r a %1 . "
3204+- " ?r %2 %3 . "
3205+- "} LIMIT 1"
3206+- ).arg(
3207+- /* %1 */ resN3(KExt::Activity()),
3208+- /* %2 */ resN3(KExt::activityIdentifier()),
3209+- /* %3 */ resN3(currentActivityRes)
3210+- );
3211+-
3212+- Soprano::QueryResultIterator it = Nepomuk::ResourceManager::instance()->mainModel()
3213+- ->executeQuery(query, Soprano::Query::QueryLanguageSparql);
3214+-
3215+- if (it.next()) {
3216+- m_currentActivity = it[0].uri();
3217+- } else {
3218+- m_currentActivity = currentActivityRes;
3219+- m_currentActivity.setProperty(KExt::activityIdentifier(), ActivityManager::self()->CurrentActivity());
3220+- }
3221+- }
3222+-
3223+- eventRes.setProperty(KExt::usedActivity(), m_currentActivity);
3224+-
3225+- return eventRes;
3226+-}
3227+-
3228+-#endif // HAVE_NEPOMUK
3229+diff --git a/activitymanager/NepomukEventBackend.h b/activitymanager/NepomukEventBackend.h
3230+deleted file mode 100644
3231+index a8cbc0f..0000000
3232+--- a/activitymanager/NepomukEventBackend.h
3233++++ /dev/null
3234+@@ -1,47 +0,0 @@
3235+-/*
3236+- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
3237+- * Copyright (c) 2011 Sebastian Trueg <trueg@kde.org>
3238+- *
3239+- * This program is free software; you can redistribute it and/or modify
3240+- * it under the terms of the GNU General Public License version 2,
3241+- * or (at your option) any later version, as published by the Free
3242+- * Software Foundation
3243+- *
3244+- * This program is distributed in the hope that it will be useful,
3245+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3246+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3247+- * GNU General Public License for more details
3248+- *
3249+- * You should have received a copy of the GNU General Public
3250+- * License along with this program; if not, write to the
3251+- * Free Software Foundation, Inc.,
3252+- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3253+- */
3254+-
3255+-#ifndef NEPOMUK_EVENT_BACKEND_H_
3256+-#define NEPOMUK_EVENT_BACKEND_H_
3257+-
3258+-#include "EventBackend.h"
3259+-
3260+-#include <Nepomuk/Resource>
3261+-
3262+-class KUrl;
3263+-class QDateTime;
3264+-
3265+-/**
3266+- *
3267+- */
3268+-class NepomukEventBackend: public EventBackend {
3269+-public:
3270+- NepomukEventBackend();
3271+-
3272+- virtual void addEvents(const EventList & events);
3273+-
3274+-private:
3275+- Nepomuk::Resource createDesktopEvent(const KUrl& uri, const QDateTime& startTime, const QString& app);
3276+-
3277+- Nepomuk::Resource m_currentActivity;
3278+-};
3279+-
3280+-#endif // NEPOMUK_EVENT_BACKEND_H_
3281+-
3282+diff --git a/activitymanager/NepomukResourceScoreCache.cpp b/activitymanager/NepomukResourceScoreCache.cpp
3283+deleted file mode 100644
3284+index 8d1b66b..0000000
3285+--- a/activitymanager/NepomukResourceScoreCache.cpp
3286++++ /dev/null
3287+@@ -1,214 +0,0 @@
3288+-/*
3289+- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
3290+- *
3291+- * This program is free software; you can redistribute it and/or modify
3292+- * it under the terms of the GNU General Public License version 2,
3293+- * or (at your option) any later version, as published by the Free
3294+- * Software Foundation
3295+- *
3296+- * This program is distributed in the hope that it will be useful,
3297+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3298+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3299+- * GNU General Public License for more details
3300+- *
3301+- * You should have received a copy of the GNU General Public
3302+- * License along with this program; if not, write to the
3303+- * Free Software Foundation, Inc.,
3304+- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3305+- */
3306+-
3307+-#include "NepomukResourceScoreCache.h"
3308+-
3309+-#include <cmath>
3310+-
3311+-#include <Soprano/Model>
3312+-#include <Soprano/QueryResultIterator>
3313+-
3314+-#include <Nepomuk/Resource>
3315+-#include <Nepomuk/ResourceManager>
3316+-#include <Nepomuk/Variant>
3317+-
3318+-#include <KDebug>
3319+-
3320+-#include "kext.h"
3321+-#include "nao.h"
3322+-#include "nuao.h"
3323+-
3324+-#include "ActivityManager.h"
3325+-
3326+-using namespace Nepomuk::Vocabulary;
3327+-
3328+-#include "NepomukCommon.h"
3329+-
3330+-/**
3331+- *
3332+- */
3333+-class NepomukResourceScoreCachePrivate {
3334+-public:
3335+- Nepomuk::Resource self;
3336+- QString activity;
3337+- QString application;
3338+- QUrl resource;
3339+-
3340+- qreal timeFactor(int days) const
3341+- {
3342+- // Exp is falling rather quickly, we are slowing it 32 times
3343+- return ::exp(- days / 32.0);
3344+- }
3345+-
3346+- qreal timeFactor(QDateTime fromTime, QDateTime toTime = QDateTime::currentDateTime()) const
3347+- {
3348+- return timeFactor(fromTime.daysTo(toTime));
3349+- }
3350+-
3351+-};
3352+-
3353+-NepomukResourceScoreCache::NepomukResourceScoreCache(const QString & activity, const QString & application, const QUrl & resource)
3354+- : d(new NepomukResourceScoreCachePrivate())
3355+-{
3356+- kDebug() << "Cache for" << activity << application << resource << anyResource(resource).resourceUri();
3357+-
3358+- d->activity = activity;
3359+- d->application = application;
3360+- d->resource = resource;
3361+-
3362+- const QString query
3363+- = QString::fromLatin1("select ?r where { "
3364+- "?r a %1 . "
3365+- "?r kext:usedActivity %2 . "
3366+- "?r kext:initiatingAgent %3 . "
3367+- "?r kext:targettedResource %4 . "
3368+- "} LIMIT 1"
3369+- ).arg(
3370+- /* %1 */ resN3(KExt::ResourceScoreCache()),
3371+- /* %2 */ resN3(currentActivityRes),
3372+- /* %3 */ resN3(agentResource(application)),
3373+- /* %4 */ resN3(anyResource(resource))
3374+- );
3375+-
3376+- kDebug() << query;
3377+-
3378+- Soprano::QueryResultIterator it
3379+- = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(query, Soprano::Query::QueryLanguageSparql);
3380+-
3381+- if (it.next()) {
3382+- Nepomuk::Resource result(it[0].uri());
3383+- it.close();
3384+-
3385+- d->self = result;
3386+-
3387+- kDebug() << "Found an old cache" << d->self.resourceUri() << d->self.resourceType()
3388+- << "With a score of" << d->self.property(KExt::cachedScore()) << d->self.property(NAO::score());
3389+-
3390+- } else {
3391+- Nepomuk::Resource result(QUrl(), KExt::ResourceScoreCache());
3392+-
3393+- result.setProperty(
3394+- KExt::targettedResource(),
3395+- Nepomuk::Resource(resource)
3396+- );
3397+- result.setProperty(
3398+- KExt::initiatingAgent(), agentResource(application)
3399+- );
3400+- result.setProperty(
3401+- KExt::usedActivity(), activityResource(activity)
3402+- );
3403+- result.setProperty(KExt::cachedScore(), 0);
3404+-
3405+- d->self = result;
3406+-
3407+- kDebug() << "Created a new cache resource" << d->self.resourceUri() << d->self.resourceType();
3408+-
3409+- }
3410+-}
3411+-
3412+-NepomukResourceScoreCache::~NepomukResourceScoreCache()
3413+-{
3414+- delete d;
3415+-}
3416+-
3417+-void NepomukResourceScoreCache::updateScore()
3418+-{
3419+- kDebug() << "Updating the score for " << d->resource;
3420+- kDebug() << "Last modified as string" << d->self.property(NAO::lastModified());
3421+-
3422+- QDateTime lastModified = d->self.property(NAO::lastModified()).toDateTime();
3423+-
3424+- qreal score = d->self.property(KExt::cachedScore()).toDouble();
3425+-
3426+- if (lastModified.isValid()) {
3427+- // Adjusting the score depending on the time that passed since the
3428+- // last update
3429+-
3430+- kDebug() << "Previous score:" << score;
3431+- score *= d->timeFactor(lastModified);
3432+- kDebug() << "Adjusted score:" << score;
3433+-
3434+- } else {
3435+- // If we haven't had previous calculation, set the score to 0
3436+- score = 0;
3437+-
3438+- }
3439+-
3440+- kDebug() << "Last modified timestamp is" << lastModified << lastModified.isValid();
3441+-
3442+- const QString query
3443+- = QString::fromLatin1("select distinct ?r where { "
3444+- "?r a nuao:DesktopEvent . "
3445+- "?r %1 %2 . "
3446+- "?r %3 %4 . "
3447+- "?r %5 %6 . "
3448+- "?r nuao:end ?end . "
3449+- "FILTER(?end >= %7) ."
3450+- " } "
3451+- ).arg(
3452+- /* %1 */ resN3(KExt::usedActivity()),
3453+- /* %2 */ resN3(activityResource(d->activity)),
3454+- /* %3 */ resN3(NUAO_targettedResource),
3455+- /* %4 */ resN3(anyResource(d->resource)),
3456+- /* %5 */ resN3(NUAO_initiatingAgent),
3457+- /* %6 */ resN3(agentResource(d->application)),
3458+- /* %7 */ litN3(lastModified.isValid() ? lastModified : QDateTime::fromMSecsSinceEpoch(0))
3459+- );
3460+-
3461+- kDebug() << query;
3462+-
3463+- Soprano::QueryResultIterator it
3464+- = Nepomuk::ResourceManager::instance()->mainModel()->executeQuery(query, Soprano::Query::QueryLanguageSparql);
3465+-
3466+- d->self.setProperty(NAO::lastModified(), QDateTime::currentDateTime());
3467+-
3468+- while (it.next()) {
3469+- Nepomuk::Resource result(it[0].uri());
3470+- QDateTime eventStart = result.property(NUAO::start()).toDateTime();
3471+- QDateTime eventEnd = result.property(NUAO::end()).toDateTime();
3472+-
3473+- if (!eventStart.isValid()) continue;
3474+-
3475+- if (!eventEnd.isValid()) {
3476+- // If the end was not saved, we are treating it as a simple
3477+- // Accessed event
3478+- eventEnd = eventStart;
3479+- }
3480+-
3481+- int intervalLength = eventStart.secsTo(eventEnd);
3482+-
3483+- if (intervalLength == 0) {
3484+- // We have an Accessed event - otherwise, this wouldn't be 0
3485+-
3486+- score += d->timeFactor(eventEnd); // like it is open for 1 minute
3487+-
3488+- } else if (intervalLength >= 4) {
3489+- // Ignoring stuff that was open for less than 4 seconds
3490+-
3491+- score += d->timeFactor(eventEnd) * intervalLength / 60.0;
3492+- }
3493+-
3494+- kDebug() << result.resourceUri() << eventStart << eventEnd << intervalLength;
3495+-
3496+- }
3497+-
3498+- kDebug() << "New calculated score:" << score << d->self.isValid();
3499+- d->self.setProperty(KExt::cachedScore(), score);
3500+- d->self.setProperty(NAO::score(), score);
3501+-}
3502+diff --git a/activitymanager/NepomukResourceScoreCache.h b/activitymanager/NepomukResourceScoreCache.h
3503+deleted file mode 100644
3504+index a26b5a2..0000000
3505+--- a/activitymanager/NepomukResourceScoreCache.h
3506++++ /dev/null
3507+@@ -1,42 +0,0 @@
3508+-/*
3509+- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
3510+- *
3511+- * This program is free software; you can redistribute it and/or modify
3512+- * it under the terms of the GNU General Public License version 2,
3513+- * or (at your option) any later version, as published by the Free
3514+- * Software Foundation
3515+- *
3516+- * This program is distributed in the hope that it will be useful,
3517+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3518+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3519+- * GNU General Public License for more details
3520+- *
3521+- * You should have received a copy of the GNU General Public
3522+- * License along with this program; if not, write to the
3523+- * Free Software Foundation, Inc.,
3524+- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3525+- */
3526+-
3527+-#ifndef NEPOMUK_RESOURCE_SCORE_CACHE_H_
3528+-#define NEPOMUK_RESOURCE_SCORE_CACHE_H_
3529+-
3530+-#include <QString>
3531+-#include <QUrl>
3532+-
3533+-class NepomukResourceScoreCachePrivate;
3534+-
3535+-/**
3536+- *
3537+- */
3538+-class NepomukResourceScoreCache {
3539+-public:
3540+- NepomukResourceScoreCache(const QString & activity, const QString & application, const QUrl & resource);
3541+- virtual ~NepomukResourceScoreCache();
3542+-
3543+- void updateScore();
3544+-
3545+-private:
3546+- class NepomukResourceScoreCachePrivate * const d;
3547+-};
3548+-
3549+-#endif // NEPOMUK_RESOURCE_SCORE_CACHE_H_
3550+diff --git a/activitymanager/NepomukResourceScoreMaintainer.cpp b/activitymanager/NepomukResourceScoreMaintainer.cpp
3551+deleted file mode 100644
3552+index f5e4d3c..0000000
3553+--- a/activitymanager/NepomukResourceScoreMaintainer.cpp
3554++++ /dev/null
3555+@@ -1,145 +0,0 @@
3556+-/*
3557+- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
3558+- *
3559+- * This program is free software; you can redistribute it and/or modify
3560+- * it under the terms of the GNU General Public License version 2,
3561+- * or (at your option) any later version, as published by the Free
3562+- * Software Foundation
3563+- *
3564+- * This program is distributed in the hope that it will be useful,
3565+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3566+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3567+- * GNU General Public License for more details
3568+- *
3569+- * You should have received a copy of the GNU General Public
3570+- * License along with this program; if not, write to the
3571+- * Free Software Foundation, Inc.,
3572+- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3573+- */
3574+-
3575+-#include "NepomukResourceScoreMaintainer.h"
3576+-
3577+-#include <QList>
3578+-#include <QMutex>
3579+-#include <QThread>
3580+-
3581+-#include <KDebug>
3582+-
3583+-#include <Nepomuk/Resource>
3584+-
3585+-#include <time.h>
3586+-#include "kext.h"
3587+-
3588+-#include "ActivityManager.h"
3589+-#include "NepomukResourceScoreCache.h"
3590+-
3591+-class NepomukResourceScoreMaintainerPrivate: public QThread {
3592+-public:
3593+- typedef QString ApplicationName;
3594+- typedef QString ActivityID;
3595+- typedef QList < QUrl > ResourceList;
3596+-
3597+- typedef QMap < ApplicationName, ResourceList > Applications;
3598+- typedef QMap < ActivityID, Applications > ResourceTree;
3599+-
3600+- ResourceTree openResources;
3601+- QMutex openResources_mutex;
3602+-
3603+- void run();
3604+- void processActivity(const ActivityID & activity, const Applications & applications);
3605+-
3606+- static NepomukResourceScoreMaintainer * s_instance;
3607+-
3608+-};
3609+-
3610+-NepomukResourceScoreMaintainer * NepomukResourceScoreMaintainerPrivate::s_instance = NULL;
3611+-
3612+-void NepomukResourceScoreMaintainerPrivate::run()
3613+-{
3614+- forever {
3615+- // initial delay before processing the resources
3616+- sleep(5);
3617+-
3618+- NepomukResourceScoreMaintainerPrivate::openResources_mutex.lock();
3619+- ResourceTree resources = openResources;
3620+- openResources.clear();
3621+- NepomukResourceScoreMaintainerPrivate::openResources_mutex.unlock();
3622+-
3623+- const QString & activity = ActivityManager::self()->CurrentActivity();
3624+-
3625+- // Let us first process the events related to the current
3626+- // activity so that the stats are available quicker
3627+-
3628+- if (resources.contains(activity)) {
3629+- kDebug() << "Processing current activity events";
3630+-
3631+- processActivity(activity, resources[activity]);
3632+- resources.remove(activity);
3633+- }
3634+-
3635+- foreach (const ActivityID & activity, resources.keys()) {
3636+- kDebug() << "Processing activity" << activity;
3637+-
3638+- processActivity(activity, resources[activity]);
3639+- }
3640+- }
3641+-}
3642+-
3643+-void NepomukResourceScoreMaintainerPrivate::processActivity(const ActivityID & activity, const Applications & applications)
3644+-{
3645+- foreach (const ApplicationName & application, applications.keys()) {
3646+- // Processing resources for the pair (activity, application)
3647+- kDebug() << " Processing application" << application;
3648+-
3649+- foreach (const QUrl & resource, applications[application]) {
3650+- kDebug() << " Updating score for" << activity, application, resource;
3651+- NepomukResourceScoreCache(activity, application, resource).updateScore();
3652+-
3653+- }
3654+- }
3655+-}
3656+-
3657+-NepomukResourceScoreMaintainer * NepomukResourceScoreMaintainer::self()
3658+-{
3659+- if (!NepomukResourceScoreMaintainerPrivate::s_instance) {
3660+- NepomukResourceScoreMaintainerPrivate::s_instance = new NepomukResourceScoreMaintainer();
3661+- }
3662+-
3663+- return NepomukResourceScoreMaintainerPrivate::s_instance;
3664+-}
3665+-
3666+-NepomukResourceScoreMaintainer::NepomukResourceScoreMaintainer()
3667+- : d(new NepomukResourceScoreMaintainerPrivate())
3668+-{
3669+-}
3670+-
3671+-NepomukResourceScoreMaintainer::~NepomukResourceScoreMaintainer()
3672+-{
3673+- delete d;
3674+-}
3675+-
3676+-void NepomukResourceScoreMaintainer::processResource(const KUrl & resource, const QString & application)
3677+-{
3678+- d->openResources_mutex.lock();
3679+-
3680+- // Checking whether the item is already scheduled for
3681+- // processing
3682+-
3683+- kDebug() << "Adding" << resource << application << "to the queue";
3684+-
3685+- const QString & activity = ActivityManager::self()->CurrentActivity();
3686+-
3687+- if (d->openResources.contains(activity) &&
3688+- d->openResources[activity].contains(application) &&
3689+- d->openResources[activity][application].contains(resource)) {
3690+- return;
3691+- }
3692+-
3693+- d->openResources[activity][application] << resource;
3694+-
3695+- d->openResources_mutex.unlock();
3696+-
3697+- d->start();
3698+-}
3699+-
3700+-
3701+diff --git a/activitymanager/NepomukResourceScoreMaintainer.h b/activitymanager/NepomukResourceScoreMaintainer.h
3702+deleted file mode 100644
3703+index cbef9f9..0000000
3704+--- a/activitymanager/NepomukResourceScoreMaintainer.h
3705++++ /dev/null
3706+@@ -1,47 +0,0 @@
3707+-/*
3708+- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
3709+- *
3710+- * This program is free software; you can redistribute it and/or modify
3711+- * it under the terms of the GNU General Public License version 2,
3712+- * or (at your option) any later version, as published by the Free
3713+- * Software Foundation
3714+- *
3715+- * This program is distributed in the hope that it will be useful,
3716+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3717+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3718+- * GNU General Public License for more details
3719+- *
3720+- * You should have received a copy of the GNU General Public
3721+- * License along with this program; if not, write to the
3722+- * Free Software Foundation, Inc.,
3723+- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3724+- */
3725+-
3726+-#ifndef NEPOMUK_RESOURCE_SCORE_MAINTAINER_H_
3727+-#define NEPOMUK_RESOURCE_SCORE_MAINTAINER_H_
3728+-
3729+-#include <QThread>
3730+-#include <Nepomuk/Resource>
3731+-
3732+-#include "Event.h"
3733+-
3734+-class NepomukResourceScoreMaintainerPrivate;
3735+-
3736+-/**
3737+- * Thread to process desktop/usage events
3738+- */
3739+-class NepomukResourceScoreMaintainer {
3740+-public:
3741+- static NepomukResourceScoreMaintainer * self();
3742+-
3743+- virtual ~NepomukResourceScoreMaintainer();
3744+-
3745+- void processResource(const KUrl & resource, const QString & application);
3746+-
3747+-private:
3748+- NepomukResourceScoreMaintainer();
3749+-
3750+- class NepomukResourceScoreMaintainerPrivate * const d;
3751+-};
3752+-
3753+-#endif // NEPOMUK_RESOURCE_SCORE_MAINTAINER_H_
3754+diff --git a/activitymanager/Plugin.cpp b/activitymanager/Plugin.cpp
3755+new file mode 100644
3756+index 0000000..e1f9bc9
3757+--- /dev/null
3758++++ b/activitymanager/Plugin.cpp
3759+@@ -0,0 +1,56 @@
3760++/*
3761++ * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
3762++ *
3763++ * This program is free software; you can redistribute it and/or modify
3764++ * it under the terms of the GNU General Public License version 2,
3765++ * or (at your option) any later version, as published by the Free
3766++ * Software Foundation
3767++ *
3768++ * This program is distributed in the hope that it will be useful,
3769++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3770++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3771++ * GNU General Public License for more details
3772++ *
3773++ * You should have received a copy of the GNU General Public
3774++ * License along with this program; if not, write to the
3775++ * Free Software Foundation, Inc.,
3776++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3777++ */
3778++
3779++#include "Plugin.h"
3780++
3781++class Plugin::Private {
3782++public:
3783++ SharedInfo * sharedInfo;
3784++};
3785++
3786++Plugin::Plugin(QObject * parent)
3787++ : QObject(parent), d(new Private())
3788++{
3789++}
3790++
3791++Plugin::~Plugin()
3792++{
3793++ delete d;
3794++}
3795++
3796++void Plugin::addEvents(const EventList & events)
3797++{
3798++ Q_UNUSED(events)
3799++}
3800++
3801++void Plugin::setResourceMimeType(const QString & uri, const QString & mimetype)
3802++{
3803++ Q_UNUSED(uri)
3804++ Q_UNUSED(mimetype)
3805++}
3806++
3807++void Plugin::setSharedInfo(SharedInfo * sharedInfo)
3808++{
3809++ d->sharedInfo = sharedInfo;
3810++}
3811++
3812++SharedInfo * Plugin::sharedInfo() const
3813++{
3814++ return d->sharedInfo;
3815++}
3816+diff --git a/activitymanager/Plugin.h b/activitymanager/Plugin.h
3817+new file mode 100644
3818+index 0000000..cdf8b7f
3819+--- /dev/null
3820++++ b/activitymanager/Plugin.h
3821+@@ -0,0 +1,59 @@
3822++/*
3823++ * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
3824++ *
3825++ * This program is free software; you can redistribute it and/or modify
3826++ * it under the terms of the GNU General Public License version 2,
3827++ * or (at your option) any later version, as published by the Free
3828++ * Software Foundation
3829++ *
3830++ * This program is distributed in the hope that it will be useful,
3831++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3832++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3833++ * GNU General Public License for more details
3834++ *
3835++ * You should have received a copy of the GNU General Public
3836++ * License along with this program; if not, write to the
3837++ * Free Software Foundation, Inc.,
3838++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3839++ */
3840++
3841++#ifndef EVENT_BACKEND_H_
3842++#define EVENT_BACKEND_H_
3843++
3844++#include <EventProcessor.h>
3845++
3846++#include <kdemacros.h>
3847++#include <KPluginFactory>
3848++#include <KPluginLoader>
3849++
3850++#include "Event.h"
3851++#include "SharedInfo.h"
3852++
3853++#define KAMD_EXPORT_PLUGIN(ClassName, AboutData) \
3854++ K_PLUGIN_FACTORY(ClassName##Factory, registerPlugin<ClassName>();) \
3855++ K_EXPORT_PLUGIN(ClassName##Factory("AboutData"))
3856++
3857++
3858++/**
3859++ *
3860++ */
3861++class KDE_EXPORT Plugin: public QObject {
3862++ Q_OBJECT
3863++
3864++public:
3865++ Plugin(QObject * parent);
3866++ virtual ~Plugin();
3867++
3868++ virtual void addEvents(const EventList & events);
3869++ virtual void setResourceMimeType(const QString & uri, const QString & mimetype);
3870++
3871++ virtual void setSharedInfo(SharedInfo * sharedInfo);
3872++ SharedInfo * sharedInfo() const;
3873++
3874++private:
3875++ class Private;
3876++ Private * const d;
3877++};
3878++
3879++#endif // EVENT_BACKEND_H_
3880++
3881+diff --git a/activitymanager/SharedInfo.cpp b/activitymanager/SharedInfo.cpp
3882+index 8c71c34..1948075 100644
3883+--- a/activitymanager/SharedInfo.cpp
3884++++ b/activitymanager/SharedInfo.cpp
3885+@@ -18,6 +18,9 @@
3886+ */
3887+
3888+ #include "SharedInfo.h"
3889++#include "ActivityManager.h"
3890++
3891++#include <KDebug>
3892+
3893+ SharedInfo * SharedInfo::s_instance = NULL;
3894+
3895+@@ -25,12 +28,15 @@ SharedInfo * SharedInfo::self()
3896+ {
3897+ if (!s_instance) {
3898+ s_instance = new SharedInfo();
3899++
3900++ kDebug() << "SHARED INFO" << (void*) s_instance;
3901+ }
3902+
3903+ return s_instance;
3904+ }
3905+
3906+ SharedInfo::SharedInfo()
3907++ : m_config("activitymanager-pluginsrc")
3908+ {
3909+ }
3910+
3911+@@ -48,4 +54,18 @@ QHash < KUrl, SharedInfo::ResourceData > const & SharedInfo::resources() const
3912+ return m_resources;
3913+ }
3914+
3915++QString SharedInfo::currentActivity() const
3916++{
3917++ return m_currentActivity;
3918++}
3919++
3920++void SharedInfo::setCurrentActivity(const QString & activity)
3921++{
3922++ m_currentActivity = activity;
3923++}
3924++
3925++KConfigGroup SharedInfo::pluginConfig(const QString & pluginName) const
3926++{
3927++ return KConfigGroup(&m_config, pluginName);
3928++}
3929+
3930+diff --git a/activitymanager/SharedInfo.h b/activitymanager/SharedInfo.h
3931+index 6e60612..77f5683 100644
3932+--- a/activitymanager/SharedInfo.h
3933++++ b/activitymanager/SharedInfo.h
3934+@@ -25,6 +25,9 @@
3935+ #include <QString>
3936+ #include <QHash>
3937+
3938++#include <KConfigGroup>
3939++#include <KConfig>
3940++
3941+ #include "Event.h"
3942+
3943+ /**
3944+@@ -32,8 +35,6 @@
3945+ */
3946+ class SharedInfo {
3947+ public:
3948+- static SharedInfo * self();
3949+-
3950+ virtual ~SharedInfo();
3951+
3952+ struct WindowData {
3953+@@ -50,14 +51,26 @@ public:
3954+ QHash < WId, WindowData > const & windows() const;
3955+ QHash < KUrl, ResourceData > const & resources() const;
3956+
3957++ QString currentActivity() const;
3958++
3959++ KConfigGroup pluginConfig(const QString & pluginName) const;
3960++
3961+ private:
3962++ static SharedInfo * self();
3963++
3964++ void setCurrentActivity(const QString & activity);
3965++
3966+ QHash < WId, WindowData > m_windows;
3967+ QHash < KUrl, ResourceData > m_resources;
3968++ QString m_currentActivity;
3969++ KConfig m_config;
3970+
3971+ static SharedInfo * s_instance;
3972+ SharedInfo();
3973+
3974+ friend class ActivityManager;
3975++ friend class ActivityManagerPrivate;
3976++ friend class EventProcessor;
3977+ };
3978+
3979+ #endif // SHARED_INFO_H_
3980+diff --git a/activitymanager/SlcEventBackend.cpp b/activitymanager/SlcEventBackend.cpp
3981+deleted file mode 100644
3982+index fe8f01d..0000000
3983+--- a/activitymanager/SlcEventBackend.cpp
3984++++ /dev/null
3985+@@ -1,127 +0,0 @@
3986+-/*
3987+- * Copyright (C) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
3988+- *
3989+- * This program is free software; you can redistribute it and/or modify
3990+- * it under the terms of the GNU General Public License version 2,
3991+- * or (at your option) any later version, as published by the Free
3992+- * Software Foundation
3993+- *
3994+- * This program is distributed in the hope that it will be useful,
3995+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3996+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3997+- * GNU General Public License for more details
3998+- *
3999+- * You should have received a copy of the GNU General Public
4000+- * License along with this program; if not, write to the
4001+- * Free Software Foundation, Inc.,
4002+- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
4003+- */
4004+-
4005+-#include "SlcEventBackend.h"
4006+-#include "slcadaptor.h"
4007+-
4008+-#include <QDBusConnection>
4009+-#include <KDebug>
4010+-#include <KWindowSystem>
4011+-#include <KUrl>
4012+-
4013+-#include "SharedInfo.h"
4014+-
4015+-SlcEventBackend::SlcEventBackend()
4016+- : focussedWindow(0)
4017+-{
4018+- QDBusConnection dbus = QDBusConnection::sessionBus();
4019+- new SLCAdaptor(this);
4020+- dbus.registerObject("/SLC", this);
4021+-
4022+- connect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)),
4023+- this, SLOT(activeWindowChanged(WId)));
4024+-}
4025+-
4026+-void SlcEventBackend::addEvents(const EventList & events)
4027+-{
4028+- foreach (const Event & event, events) {
4029+- switch (event.type) {
4030+- case Event::FocussedIn:
4031+- case Event::Opened:
4032+- // kDebug() << "Event::FocussedIn" << focussedWindow << event.wid << event.uri;
4033+-
4034+- lastFocussedResource[event.wid] = event.uri;
4035+-
4036+- if (event.wid == focussedWindow) {
4037+- updateFocus(focussedWindow);
4038+- }
4039+-
4040+- break;
4041+-
4042+- case Event::FocussedOut:
4043+- case Event::Closed:
4044+- // kDebug() << "Event::FocussedOut" << focussedWindow << event.wid << event.uri;
4045+-
4046+- if (lastFocussedResource[event.wid] == event.uri) {
4047+- lastFocussedResource[event.wid] = KUrl();
4048+- }
4049+-
4050+- if (event.wid == focussedWindow) {
4051+- updateFocus();
4052+- }
4053+-
4054+- break;
4055+-
4056+- default:
4057+- // nothing
4058+- break;
4059+- }
4060+- }
4061+-}
4062+-
4063+-KUrl SlcEventBackend::_focussedResourceURI()
4064+-{
4065+- KUrl kuri;
4066+-
4067+- if (lastFocussedResource.contains(focussedWindow)) {
4068+- kuri = lastFocussedResource[focussedWindow];
4069+- } else {
4070+- foreach (const KUrl & uri, SharedInfo::self()->windows()[focussedWindow].resources) {
4071+- kuri = uri;
4072+- break;
4073+- }
4074+- }
4075+-
4076+- return kuri;
4077+-}
4078+-
4079+-QString SlcEventBackend::focussedResourceURI()
4080+-{
4081+- return _focussedResourceURI().url();
4082+-}
4083+-
4084+-QString SlcEventBackend::focussedResourceMimetype()
4085+-{
4086+- return SharedInfo::self()->resources().contains(_focussedResourceURI()) ?
4087+- SharedInfo::self()->resources()[_focussedResourceURI()].mimetype : QString();
4088+-}
4089+-
4090+-void SlcEventBackend::activeWindowChanged(WId wid)
4091+-{
4092+- if (wid == focussedWindow) return;
4093+-
4094+- focussedWindow = wid;
4095+-
4096+- updateFocus(wid);
4097+-}
4098+-
4099+-void SlcEventBackend::updateFocus(WId wid)
4100+-{
4101+- // kDebug() << "Updating focus for " << wid;
4102+-
4103+- if (wid == 0 || !SharedInfo::self()->windows().contains(wid)) {
4104+- // kDebug() << "Clearing focus";
4105+- emit focusChanged(QString(), QString());
4106+-
4107+- } else if (wid == focussedWindow) {
4108+- // kDebug() << "It is the currently focussed window";
4109+- emit focusChanged(focussedResourceURI(), SharedInfo::self()->resources()[_focussedResourceURI()].mimetype);
4110+-
4111+- }
4112+-}
4113+diff --git a/activitymanager/SlcEventBackend.h b/activitymanager/SlcEventBackend.h
4114+deleted file mode 100644
4115+index 3c79792..0000000
4116+--- a/activitymanager/SlcEventBackend.h
4117++++ /dev/null
4118+@@ -1,59 +0,0 @@
4119+-/*
4120+- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
4121+- *
4122+- * This program is free software; you can redistribute it and/or modify
4123+- * it under the terms of the GNU General Public License version 2,
4124+- * or (at your option) any later version, as published by the Free
4125+- * Software Foundation
4126+- *
4127+- * This program is distributed in the hope that it will be useful,
4128+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4129+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4130+- * GNU General Public License for more details
4131+- *
4132+- * You should have received a copy of the GNU General Public
4133+- * License along with this program; if not, write to the
4134+- * Free Software Foundation, Inc.,
4135+- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
4136+- */
4137+-
4138+-#ifndef SLC_EVENT_BACKEND_H_
4139+-#define SLC_EVENT_BACKEND_H_
4140+-
4141+-#include "EventBackend.h"
4142+-
4143+-#include <QObject>
4144+-#include <KUrl>
4145+-
4146+-/**
4147+- *
4148+- */
4149+-class SlcEventBackend: public QObject, public EventBackend {
4150+- Q_OBJECT
4151+- Q_CLASSINFO("D-Bus Interface", "org.kde.ActivityManager.SLC")
4152+-
4153+-public:
4154+- SlcEventBackend();
4155+-
4156+- virtual void addEvents(const EventList & events);
4157+-
4158+-private Q_SLOTS:
4159+- void activeWindowChanged(WId windowId);
4160+-
4161+-public Q_SLOTS:
4162+- QString focussedResourceURI();
4163+- QString focussedResourceMimetype();
4164+-
4165+-Q_SIGNALS:
4166+- void focusChanged(const QString & uri, const QString & mimetype);
4167+-
4168+-private:
4169+- void updateFocus(WId wid = 0);
4170+-
4171+- WId focussedWindow;
4172+- KUrl _focussedResourceURI();
4173+- QHash < WId, KUrl > lastFocussedResource;
4174+-};
4175+-
4176+-#endif // SLC_EVENT_BACKEND_H_
4177+-
4178+diff --git a/activitymanager/ZeitgeistEventBackend.cpp b/activitymanager/ZeitgeistEventBackend.cpp
4179+deleted file mode 100644
4180+index 1bbd050..0000000
4181+--- a/activitymanager/ZeitgeistEventBackend.cpp
4182++++ /dev/null
4183+@@ -1,95 +0,0 @@
4184+-/*
4185+- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
4186+- *
4187+- * This program is free software; you can redistribute it and/or modify
4188+- * it under the terms of the GNU General Public License version 2,
4189+- * or (at your option) any later version, as published by the Free
4190+- * Software Foundation
4191+- *
4192+- * This program is distributed in the hope that it will be useful,
4193+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4194+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4195+- * GNU General Public License for more details
4196+- *
4197+- * You should have received a copy of the GNU General Public
4198+- * License along with this program; if not, write to the
4199+- * Free Software Foundation, Inc.,
4200+- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
4201+- */
4202+-
4203+-#include "config-features.h"
4204+-
4205+-#ifndef HAVE_QZEITGEIST
4206+-#ifdef __GNUC__
4207+- #warning "No QtZeitgeist, disabling desktop events processing"
4208+-#endif
4209+-
4210+-#else // HAVE_QZEITGEIST
4211+-
4212+-#include "ZeitgeistEventBackend.h"
4213+-
4214+-#include <QtZeitgeist/QtZeitgeist>
4215+-#include <QtZeitgeist/Interpretation>
4216+-#include <QtZeitgeist/Manifestation>
4217+-
4218+-static QString eventInterpretation(Event::Type type)
4219+-{
4220+- // switch (type) {
4221+- // case Event::Accessed:
4222+- // return QtZeitgeist::Interpretation::Event::ZGAccessEvent;
4223+-
4224+- // case Event::Opened:
4225+- // return QtZeitgeist::Interpretation::Event::ZGAccessEvent;
4226+-
4227+- // case Event::Modified:
4228+- // return QtZeitgeist::Interpretation::Event::ZGModifyEvent;
4229+-
4230+- // case Event::Closed:
4231+- // return QtZeitgeist::Interpretation::Event::ZGLeaveEvent;
4232+-
4233+- // }
4234+-
4235+- // shut up GCC
4236+- return QString();
4237+-}
4238+-
4239+-static QString eventManifestation(Event::Reason reason)
4240+-{
4241+- // switch (reason) {
4242+- // case Event::User:
4243+- // return QtZeitgeist::Manifestation::Event::ZGUserActivity;
4244+-
4245+- // case Event::Heuristic:
4246+- // return QtZeitgeist::Manifestation::Event::ZGHeuristicActivity;
4247+-
4248+- // case Event::Scheduled:
4249+- // return QtZeitgeist::Manifestation::Event::ZGScheduledActivity;
4250+-
4251+- // case Event::System:
4252+- // return QtZeitgeist::Manifestation::Event::ZGSystemNotification;
4253+-
4254+- // case Event::World:
4255+- // return QtZeitgeist::Manifestation::Event::ZGWorldActivity;
4256+- // }
4257+-
4258+- // shut up GCC
4259+- return QtZeitgeist::Manifestation::Event::ZGUserActivity;
4260+-}
4261+-
4262+-static QString applicationUri(const QString & application)
4263+-{
4264+- // TODO: Make this correct
4265+- return "app://" + application + ".desktop";
4266+-}
4267+-
4268+-ZeitgeistEventBackend::ZeitgeistEventBackend()
4269+-{
4270+- QtZeitgeist::init();
4271+-}
4272+-
4273+-void ZeitgeistEventBackend::addEvents(const EventList & events)
4274+-{
4275+-
4276+-}
4277+-
4278+-#endif // HAVE_QZEITGEIST
4279+diff --git a/activitymanager/ZeitgeistEventBackend.h b/activitymanager/ZeitgeistEventBackend.h
4280+deleted file mode 100644
4281+index 1b5fab7..0000000
4282+--- a/activitymanager/ZeitgeistEventBackend.h
4283++++ /dev/null
4284+@@ -1,39 +0,0 @@
4285+-/*
4286+- * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
4287+- *
4288+- * This program is free software; you can redistribute it and/or modify
4289+- * it under the terms of the GNU General Public License version 2,
4290+- * or (at your option) any later version, as published by the Free
4291+- * Software Foundation
4292+- *
4293+- * This program is distributed in the hope that it will be useful,
4294+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4295+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4296+- * GNU General Public License for more details
4297+- *
4298+- * You should have received a copy of the GNU General Public
4299+- * License along with this program; if not, write to the
4300+- * Free Software Foundation, Inc.,
4301+- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
4302+- */
4303+-
4304+-#ifndef ZEITGEIST_EVENT_BACKEND_H_
4305+-#define ZEITGEIST_EVENT_BACKEND_H_
4306+-
4307+-#include "EventBackend.h"
4308+-
4309+-/**
4310+- *
4311+- */
4312+-class ZeitgeistEventBackend: public EventBackend {
4313+-public:
4314+- ZeitgeistEventBackend();
4315+-
4316+- virtual void addEvents(const EventList & events);
4317+-
4318+-private:
4319+- /* data */
4320+-};
4321+-
4322+-#endif // ZEITGEIST_EVENT_BACKEND_H_
4323+-
4324+diff --git a/activitymanager/activitymanager-plugin.desktop b/activitymanager/activitymanager-plugin.desktop
4325+new file mode 100644
4326+index 0000000..f7a068f
4327+--- /dev/null
4328++++ b/activitymanager/activitymanager-plugin.desktop
4329+@@ -0,0 +1,12 @@
4330++[Desktop Entry]
4331++Type=ServiceType
4332++X-KDE-ServiceType=ActivityManager/Plugin
4333++
4334++Comment=Activity manager plugin
4335++
4336++[PropertyDef::X-ActivityManager-PluginType]
4337++Type=QString
4338++
4339++[PropertyDef::X-ActivityManager-PluginOverrides]
4340++Type=QString
4341++
4342+diff --git a/activitymanager/krso.trig b/activitymanager/krso.trig
4343+new file mode 100644
4344+index 0000000..a74aa69
4345+--- /dev/null
4346++++ b/activitymanager/krso.trig
4347+@@ -0,0 +1,100 @@
4348++#
4349++# Copyright (c) 2011 Ivan Cukic <ivan.cukic@kde.org>
4350++# All rights reserved, licensed under either CC-BY or BSD.
4351++#
4352++# You are free:
4353++# * to Share - to copy, distribute and transmit the work
4354++# * to Remix - to adapt the work
4355++# Under the following conditions:
4356++# * Attribution - You must attribute the work in the manner specified by the author
4357++# or licensor (but not in any way that suggests that they endorse you or your use
4358++# of the work).
4359++#
4360++# Redistribution and use in source and binary forms, with or without modification,
4361++# are permitted provided that the following conditions are met:
4362++# * Redistributions of source code must retain the above copyright notice, this
4363++# list of conditions and the following disclaimer.
4364++# * Redistributions in binary form must reproduce the above copyright notice, this
4365++# list of conditions and the following disclaimer in the documentation and/or
4366++# other materials provided with the distribution.
4367++# * Neither the names of the authors nor the names of contributors may
4368++# be used to endorse or promote products derived from this ontology without
4369++# specific prior written permission.
4370++#
4371++# THIS ONTOLOGY IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
4372++# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
4373++# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
4374++# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
4375++# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
4376++# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
4377++# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
4378++# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4379++# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
4380++# THIS ONTOLOGY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4381++#
4382++
4383++@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
4384++@prefix nao: <http://www.semanticdesktop.org/ontologies/2007/08/15/nao#> .
4385++@prefix nrl: <http://www.semanticdesktop.org/ontologies/2007/08/15/nrl#> .
4386++@prefix nie: <http://www.semanticdesktop.org/ontologies/2007/01/19/nie#> .
4387++@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
4388++@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
4389++@prefix krso: <http://nepomuk.kde.org/ontologies/2011/06/17/krso#> .
4390++@prefix nfo: <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#> .
4391++
4392++krso: {
4393++ krso:ResourceScoreCache
4394++ a rdfs:Class ;
4395++ rdfs:subClassOf rdfs:Resource ;
4396++ rdfs:label "Resource score cache" ;
4397++ rdfs:comment "For storing the automatically calculated score based on the usage statistics" ;
4398++ nao:userVisible false .
4399++
4400++ krso:targettedResource
4401++ a rdf:Property ;
4402++ rdfs:comment "Resource for which the score is calculated." ;
4403++ rdfs:domain krso:ResourceScoreCache ;
4404++ rdfs:label "resource" ;
4405++ rdfs:range rdfs:Resource .
4406++
4407++ krso:initiatingAgent
4408++ a rdf:Property ;
4409++ rdfs:comment "Relates the score to the agent initiating the events." ;
4410++ rdfs:domain krso:ResourceScoreCache ;
4411++ rdfs:label "involved agent" ;
4412++ rdfs:range nao:Agent .
4413++
4414++ krso:involvesActivity
4415++ a rdf:Property ;
4416++ rdfs:comment "Relates the score to the activity in which the events happened." ;
4417++ rdfs:domain krso:ResourceScoreCache ;
4418++ rdfs:label "involved activity" ;
4419++ rdfs:range krso:Activity .
4420++
4421++ krso:cachedScore
4422++ a rdf:Property ;
4423++ rdfs:subPropertyOf nao:score ;
4424++ rdfs:comment "The automatically calculated score" ;
4425++ rdfs:domain krso:ResourceScoreCache ;
4426++ rdfs:label "calculated score" ;
4427++ rdfs:range xsd:float .
4428++}
4429++
4430++<http://nepomuk.kde.org/ontologies/2011/06/17/krso/metadata> {
4431++ <http://nepomuk.kde.org/ontologies/2011/06/17/krso/metadata>
4432++ a nrl:GraphMetadata ;
4433++ nrl:coreGraphMetadataFor krso: .
4434++
4435++
4436++ krso:
4437++ a nrl:Ontology , nrl:DocumentGraph ;
4438++ nao:prefLabel "KDE Resource Scoring Ontology" ;
4439++ nao:hasDefaultNamespace "http://nepomuk.kde.org/ontologies/2011/06/17/krso#" ;
4440++ nao:hasDefaultNamespaceAbbreviation "krso" ;
4441++ nao:lastModified "2011-06-17T11:00:43Z" ;
4442++ nao:serializationLanguage "TriG" ;
4443++ nao:status "Unstable" ;
4444++ nrl:updatable "0" ;
4445++ nao:version "2" .
4446++}
4447++
4448+diff --git a/activitymanager/ontologies/CMakeLists.txt b/activitymanager/ontologies/CMakeLists.txt
4449+deleted file mode 100644
4450+index 838b1f4..0000000
4451+--- a/activitymanager/ontologies/CMakeLists.txt
4452++++ /dev/null
4453+@@ -1,8 +0,0 @@
4454+-project(nepomuk_ontologies)
4455+-
4456+-configure_file(kamdrso.ontology.in ${CMAKE_CURRENT_BINARY_DIR}/kamdrso.ontology)
4457+-
4458+-install(FILES
4459+- kamdrso.trig
4460+- ${CMAKE_CURRENT_BINARY_DIR}/kamdrso.ontology
4461+-DESTINATION ${CMAKE_INSTALL_PREFIX}/share/ontology/kde)
4462+diff --git a/activitymanager/ontologies/kamdrso.ontology.in b/activitymanager/ontologies/kamdrso.ontology.in
4463+deleted file mode 100644
4464+index 032dac0..0000000
4465+--- a/activitymanager/ontologies/kamdrso.ontology.in
4466++++ /dev/null
4467+@@ -1,8 +0,0 @@
4468+-[Ontology]
4469+-Version=1.0
4470+-Name=KDE Activity Manager Daemon - Resource Scoring Ontology
4471+-Comment=The KDE Resource Scoring Ontology contains classes related to KAMD's scoring mechanisms
4472+-Namespace=http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso#" ;
4473+-Path=${CMAKE_INSTALL_PREFIX}/share/ontology/kde/kamdrso.trig
4474+-MimeType=application/x-trig
4475+-Type=Data
4476+diff --git a/activitymanager/ontologies/kamdrso.trig b/activitymanager/ontologies/kamdrso.trig
4477+deleted file mode 100644
4478+index b968231..0000000
4479+--- a/activitymanager/ontologies/kamdrso.trig
4480++++ /dev/null
4481+@@ -1,112 +0,0 @@
4482+-#
4483+-# Copyright (c) 2011 Ivan Cukic <ivan.cukic@kde.org>
4484+-# All rights reserved, licensed under either CC-BY or BSD.
4485+-#
4486+-# You are free:
4487+-# * to Share - to copy, distribute and transmit the work
4488+-# * to Remix - to adapt the work
4489+-# Under the following conditions:
4490+-# * Attribution - You must attribute the work in the manner specified by the author
4491+-# or licensor (but not in any way that suggests that they endorse you or your use
4492+-# of the work).
4493+-#
4494+-# Redistribution and use in source and binary forms, with or without modification,
4495+-# are permitted provided that the following conditions are met:
4496+-# * Redistributions of source code must retain the above copyright notice, this
4497+-# list of conditions and the following disclaimer.
4498+-# * Redistributions in binary form must reproduce the above copyright notice, this
4499+-# list of conditions and the following disclaimer in the documentation and/or
4500+-# other materials provided with the distribution.
4501+-# * Neither the names of the authors nor the names of contributors may
4502+-# be used to endorse or promote products derived from this ontology without
4503+-# specific prior written permission.
4504+-#
4505+-# THIS ONTOLOGY IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
4506+-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
4507+-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
4508+-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
4509+-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
4510+-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
4511+-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
4512+-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4513+-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
4514+-# THIS ONTOLOGY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4515+-#
4516+-
4517+-@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
4518+-@prefix nao: <http://www.semanticdesktop.org/ontologies/2007/08/15/nao#> .
4519+-@prefix nrl: <http://www.semanticdesktop.org/ontologies/2007/08/15/nrl#> .
4520+-@prefix nie: <http://www.semanticdesktop.org/ontologies/2007/01/19/nie#> .
4521+-@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
4522+-@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
4523+-@prefix kamdrso: <http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso#> .
4524+-@prefix nfo: <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#> .
4525+-
4526+-kamdrso: {
4527+- kamdrso:unixFileMode
4528+- a rdf:Property ;
4529+- rdfs:label "Unix file mode" ;
4530+- rdfs:comment "The file mode value as seen on unix file systems." ;
4531+- rdfs:domain nfo:FileDataObject ;
4532+- rdfs:range xsd:integer ;
4533+- nao:userVisible false .
4534+-
4535+- kamdrso:unixFileOwner
4536+- a rdf:Property ;
4537+- rdfs:label "Unix file owner" ;
4538+- rdfs:comment "The owner of the file as seen on unix file systems. This is intended as the low-level counterpart to nfo:owner." ;
4539+- rdfs:domain nfo:FileDataObject ;
4540+- rdfs:range xsd:string ;
4541+- nao:userVisible false .
4542+-
4543+- kamdrso:unixFileGroup
4544+- a rdf:Property ;
4545+- rdfs:label "Unix file group" ;
4546+- rdfs:comment "The group of the file as seen on unix file systems." ;
4547+- rdfs:domain nfo:FileDataObject ;
4548+- rdfs:range xsd:string ;
4549+- nao:userVisible false .
4550+-
4551+- kamdrso:Activity
4552+- a rdfs:Class ;
4553+- rdfs:subClassOf rdfs:Resource ;
4554+- rdfs:label "activity" ;
4555+- rdfs:comment "A Plasma activity." .
4556+-
4557+- kamdrso:usedActivity
4558+- a rdf:Property ;
4559+- rdfs:label "used activity" ;
4560+- rdfs:comment "The activity that was active when resource was created. This is mostly used for graphs or desktop events." ;
4561+- rdfs:domain rdfs:Resource ;
4562+- rdfs:range kamdrso:Activity ;
4563+- nao:userVisible false .
4564+-
4565+- kamdrso:activityIdentifier
4566+- a rdf:Property ;
4567+- rdfs:subPropertyOf nao:identifier ;
4568+- rdfs:label "activity identifier" ;
4569+- rdfs:comment "The unique ID of the activity as used outside of Nepomuk. Typically this is a UUID." ;
4570+- rdfs:domain kamdrso:Activity ;
4571+- rdfs:range xsd:string ;
4572+- nao:userVisible false .
4573+-
4574+-}
4575+-
4576+-<http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso/metadata> {
4577+- <http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso/metadata>
4578+- a nrl:GraphMetadata ;
4579+- nrl:coreGraphMetadataFor kamdrso: .
4580+-
4581+-
4582+- kamdrso:
4583+- a nrl:Ontology , nrl:DocumentGraph ;
4584+- nao:prefLabel "KDE Extensions Ontology" ;
4585+- nao:hasDefaultNamespace "http://nepomuk.kde.org/ontologies/2011/06/01/kamdrso#" ;
4586+- nao:hasDefaultNamespaceAbbreviation "kamdrso" ;
4587+- nao:lastModified "2011-06-02T12:31:43Z" ;
4588+- nao:serializationLanguage "TriG" ;
4589+- nao:status "Unstable" ;
4590+- nrl:updatable "0" ;
4591+- nao:version "2" .
4592+-}
4593+-
4594+diff --git a/activitymanager/org.kde.ActivityManager.SLC.xml b/activitymanager/org.kde.ActivityManager.SLC.xml
4595+deleted file mode 100644
4596+index b9df419..0000000
4597+--- a/activitymanager/org.kde.ActivityManager.SLC.xml
4598++++ /dev/null
4599+@@ -1,15 +0,0 @@
4600+-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
4601+-<node>
4602+- <interface name="org.kde.ActivityManager.SLC">
4603+- <signal name="focusChanged">
4604+- <arg name="uri" type="s" direction="out"/>
4605+- <arg name="mimetype" type="s" direction="out"/>
4606+- </signal>
4607+- <method name="focussedResourceURI">
4608+- <arg type="s" direction="out"/>
4609+- </method>
4610+- <method name="focussedResourceMimetype">
4611+- <arg type="s" direction="out"/>
4612+- </method>
4613+- </interface>
4614+-</node>
4615+diff --git a/activitymanager/plugins/CMakeLists.txt b/activitymanager/plugins/CMakeLists.txt
4616+new file mode 100644
4617+index 0000000..6acca9e
4618+--- /dev/null
4619++++ b/activitymanager/plugins/CMakeLists.txt
4620+@@ -0,0 +1,3 @@
4621++macro_optional_add_subdirectory(dummy)
4622++macro_optional_add_subdirectory(slc)
4623++macro_optional_add_subdirectory(nepomuk)
4624+diff --git a/activitymanager/plugins/dummy/CMakeLists.txt b/activitymanager/plugins/dummy/CMakeLists.txt
4625+new file mode 100644
4626+index 0000000..7cced75
4627+--- /dev/null
4628++++ b/activitymanager/plugins/dummy/CMakeLists.txt
4629+@@ -0,0 +1,30 @@
4630++project(activitymanager-dummy)
4631++
4632++include_directories(
4633++ ${CMAKE_SOURCE_DIR}
4634++ ${CMAKE_BINARY_DIR}
4635++ ${CMAKE_CURRENT_SOURCE_DIR}
4636++ ${CMAKE_CURRENT_SOURCE_DIR}/../..
4637++ ${CMAKE_CURRENT_BINARY_DIR}
4638++ ${KDE4_INCLUDES}
4639++ )
4640++
4641++set(
4642++ dummy_SRCS
4643++ dummy.cpp
4644++ ../../Plugin.cpp
4645++ )
4646++
4647++kde4_add_plugin(
4648++ activitymanager_plugin_dummy
4649++ ${dummy_SRCS}
4650++ )
4651++
4652++target_link_libraries(
4653++ activitymanager_plugin_dummy
4654++ ${KDE4_KDECORE_LIBS}
4655++)
4656++
4657++install(TARGETS activitymanager_plugin_dummy DESTINATION ${PLUGIN_INSTALL_DIR})
4658++install(FILES activitymanager-plugin-dummy.desktop DESTINATION ${SERVICES_INSTALL_DIR})
4659++
4660+diff --git a/activitymanager/plugins/dummy/activitymanager-plugin-dummy.desktop b/activitymanager/plugins/dummy/activitymanager-plugin-dummy.desktop
4661+new file mode 100644
4662+index 0000000..34ec150
4663+--- /dev/null
4664++++ b/activitymanager/plugins/dummy/activitymanager-plugin-dummy.desktop
4665+@@ -0,0 +1,19 @@
4666++[Desktop Entry]
4667++Name=Dummy plugin
4668++Comment=Just testing
4669++Type=Service
4670++Icon=
4671++
4672++X-KDE-ServiceTypes=ActivityManager/Plugin
4673++X-KDE-Library=activitymanager_plugin_dummy
4674++X-KDE-PluginInfo-Author=Ivan Cukic
4675++X-KDE-PluginInfo-Email=ivan.cukic@kde.org
4676++X-KDE-PluginInfo-Name=org.kde.kactivitymanager.dummy
4677++X-KDE-PluginInfo-Version=1.0
4678++X-KDE-PluginInfo-Website=http://plasma.kde.org/
4679++X-KDE-PluginInfo-Category=Language
4680++X-KDE-PluginInfo-Depends=
4681++X-KDE-PluginInfo-License=GPL
4682++X-KDE-PluginInfo-EnabledByDefault=true
4683++
4684++X-ActivityManager-PluginType=normal
4685+diff --git a/activitymanager/plugins/dummy/dummy.cpp b/activitymanager/plugins/dummy/dummy.cpp
4686+new file mode 100644
4687+index 0000000..e20fb2b
4688+--- /dev/null
4689++++ b/activitymanager/plugins/dummy/dummy.cpp
4690+@@ -0,0 +1,34 @@
4691++/*
4692++ * Copyright (C) 2011 Ivan Cukic ivan.cukic(at)kde.org
4693++ *
4694++ * This program is free software; you can redistribute it and/or
4695++ * modify it under the terms of the GNU General Public License as
4696++ * published by the Free Software Foundation; either version 2 of
4697++ * the License, or (at your option) any later version.
4698++ *
4699++ * This program is distributed in the hope that it will be useful,
4700++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4701++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4702++ * GNU General Public License for more details.
4703++ *
4704++ * You should have received a copy of the GNU General Public License
4705++ * along with this program. If not, see <http://www.gnu.org/licenses/>.
4706++ */
4707++
4708++#include "dummy.h"
4709++
4710++#include <KDebug>
4711++#include "ActivityManager.h"
4712++
4713++DummyPlugin::DummyPlugin(QObject * parent, const QVariantList & args)
4714++ : Plugin(parent)
4715++{
4716++ Q_UNUSED(args)
4717++ kDebug() << "We are in the DummyPlugin";
4718++}
4719++
4720++DummyPlugin::~DummyPlugin()
4721++{
4722++}
4723++
4724++KAMD_EXPORT_PLUGIN(DummyPlugin, "activitymanger_plugin_dummy")
4725+diff --git a/activitymanager/plugins/dummy/dummy.h b/activitymanager/plugins/dummy/dummy.h
4726+new file mode 100644
4727+index 0000000..e059a5e
4728+--- /dev/null
4729++++ b/activitymanager/plugins/dummy/dummy.h
4730+@@ -0,0 +1,35 @@
4731++/*
4732++ * Copyright (C) 2008 Nick Shaforostoff <shaforostoff@kde.ru>
4733++ *
4734++ * based on work by:
4735++ * Copyright (C) 2007 Thomas Georgiou <TAGeorgiou@gmail.com> and Jeff Cooper <weirdsox11@gmail.com>
4736++ *
4737++ * This program is free software; you can redistribute it and/or
4738++ * modify it under the terms of the GNU General Public License as
4739++ * published by the Free Software Foundation; either version 2 of
4740++ * the License, or (at your option) any later version.
4741++ *
4742++ * This program is distributed in the hope that it will be useful,
4743++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4744++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4745++ * GNU General Public License for more details.
4746++ *
4747++ * You should have received a copy of the GNU General Public License
4748++ * along with this program. If not, see <http://www.gnu.org/licenses/>.
4749++ */
4750++
4751++#ifndef Dummy_H
4752++#define Dummy_H
4753++
4754++#include "../../Plugin.h"
4755++
4756++class DummyPlugin: public Plugin
4757++{
4758++ Q_OBJECT
4759++
4760++public:
4761++ DummyPlugin(QObject *parent, const QVariantList & args);
4762++ ~DummyPlugin();
4763++};
4764++
4765++#endif
4766+diff --git a/activitymanager/plugins/nepomuk/CMakeLists.txt b/activitymanager/plugins/nepomuk/CMakeLists.txt
4767+new file mode 100644
4768+index 0000000..7900519
4769+--- /dev/null
4770++++ b/activitymanager/plugins/nepomuk/CMakeLists.txt
4771+@@ -0,0 +1,61 @@
4772++project(activitymanager-plugin-nepomuk)
4773++
4774++# Checking for Nepomuk
4775++find_package(Nepomuk REQUIRED)
4776++
4777++set(
4778++ nepomuk_SRCS
4779++ NepomukPlugin.cpp
4780++ NepomukResourceScoreCache.cpp
4781++ NepomukResourceScoreMaintainer.cpp
4782++ ../../Plugin.cpp
4783++ ../../SharedInfo.cpp
4784++ )
4785++
4786++soprano_add_ontology(nepomuk_SRCS
4787++ ${CMAKE_SOURCE_DIR}/nepomuk/ontologies/kext.trig
4788++ "KExt" "Nepomuk::Vocabulary" "trig"
4789++ )
4790++
4791++soprano_add_ontology(nepomuk_SRCS
4792++ ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nie/nie.trig
4793++ "NIE" "Nepomuk::Vocabulary" "trig"
4794++ )
4795++
4796++soprano_add_ontology(nepomuk_SRCS
4797++ ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nepomuk/nao.trig
4798++ "NAO" "Nepomuk::Vocabulary" "trig"
4799++ )
4800++
4801++soprano_add_ontology(nepomuk_SRCS
4802++ ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nepomuk/nuao.trig
4803++ "NUAO" "Nepomuk::Vocabulary" "trig"
4804++ )
4805++
4806++include_directories(
4807++ ${CMAKE_SOURCE_DIR}
4808++ ${CMAKE_BINARY_DIR}
4809++ ${CMAKE_CURRENT_SOURCE_DIR}
4810++ ${CMAKE_CURRENT_SOURCE_DIR}/../..
4811++ ${CMAKE_CURRENT_BINARY_DIR}
4812++ ${CMAKE_CURRENT_BINARY_DIR}/../..
4813++ ${KDE4_INCLUDES}
4814++ )
4815++
4816++kde4_add_plugin(
4817++ activitymanager_plugin_nepomuk
4818++ ${nepomuk_SRCS}
4819++ )
4820++
4821++target_link_libraries(
4822++ activitymanager_plugin_nepomuk
4823++ ${KDE4_KDECORE_LIBS}
4824++ ${KDE4_KDEUI_LIBS}
4825++ ${NEPOMUK_LIBRARIES}
4826++ ${NEPOMUK_QUERY_LIBRARIES}
4827++ ${SOPRANO_LIBRARIES}
4828++ )
4829++
4830++install(TARGETS activitymanager_plugin_nepomuk DESTINATION ${PLUGIN_INSTALL_DIR})
4831++install(FILES activitymanager-plugin-nepomuk.desktop DESTINATION ${SERVICES_INSTALL_DIR})
4832++
4833+diff --git a/activitymanager/plugins/nepomuk/NepomukCommon.h b/activitymanager/plugins/nepomuk/NepomukCommon.h
4834+new file mode 100644
4835+index 0000000..222c9c0
4836+--- /dev/null
4837++++ b/activitymanager/plugins/nepomuk/NepomukCommon.h
4838+@@ -0,0 +1,67 @@
4839++/*
4840++ * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
4841++ *
4842++ * This program is free software; you can redistribute it and/or modify
4843++ * it under the terms of the GNU General Public License version 2,
4844++ * or (at your option) any later version, as published by the Free
4845++ * Software Foundation
4846++ *
4847++ * This program is distributed in the hope that it will be useful,
4848++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4849++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4850++ * GNU General Public License for more details
4851++ *
4852++ * You should have received a copy of the GNU General Public
4853++ * License along with this program; if not, write to the
4854++ * Free Software Foundation, Inc.,
4855++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
4856++ */
4857++
4858++#ifndef NEPOMUK_COMMON_H_
4859++#define NEPOMUK_COMMON_H_
4860++
4861++#include "nie.h"
4862++#include "NepomukPlugin.h"
4863++
4864++#include <Nepomuk/Variant>
4865++
4866++#define NUAO_targettedResource KUrl(NUAO::nuaoNamespace().toString() + QLatin1String("targettedResource"))
4867++#define NUAO_initiatingAgent KUrl(NUAO::nuaoNamespace().toString() + QLatin1String("initiatingAgent"))
4868++// #define NUAO_involvesActivity KUrl(NUAO::nuaoNamespace().toString() + QLatin1String("involvesActivity"))
4869++
4870++#define activityResource(ID) Nepomuk::Resource(ID, KExt::Activity())
4871++#define agentResource(ID) Nepomuk::Resource(ID, NAO::Agent())
4872++#define currentActivityId NepomukPlugin::self()->sharedInfo()->currentActivity()
4873++#define currentActivityRes activityResource(currentActivityId)
4874++
4875++// #define anyResource(ID) Nepomuk::Resource(KUrl(ID))
4876++
4877++inline Nepomuk::Resource anyResource(const QUrl & uri)
4878++{
4879++ Nepomuk::Resource result(uri);
4880++
4881++ kDebug() << "setting the URI" << result.isFile() << result.isValid();
4882++ result.setProperty(Nepomuk::Vocabulary::NIE::url(), uri);
4883++ kDebug() << "set the URI" << result.isFile() << result.isValid();
4884++
4885++ return result;
4886++}
4887++
4888++inline Nepomuk::Resource anyResource(const QString & uri)
4889++{
4890++ return anyResource(KUrl(uri));
4891++}
4892++
4893++#define litN3(A) Soprano::Node::literalToN3(A)
4894++
4895++inline QString resN3(const QUrl & uri)
4896++{
4897++ return Soprano::Node::resourceToN3(uri);
4898++}
4899++
4900++inline QString resN3(const Nepomuk::Resource & resource)
4901++{
4902++ return Soprano::Node::resourceToN3(resource.resourceUri());
4903++}
4904++
4905++#endif // NEPOMUK_COMMON_H_
4906+diff --git a/activitymanager/plugins/nepomuk/NepomukPlugin.cpp b/activitymanager/plugins/nepomuk/NepomukPlugin.cpp
4907+new file mode 100644
4908+index 0000000..9cbcda7
4909+--- /dev/null
4910++++ b/activitymanager/plugins/nepomuk/NepomukPlugin.cpp
4911+@@ -0,0 +1,264 @@
4912++/*
4913++ * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
4914++ * Copyright (c) 2011 Sebastian Trueg <trueg@kde.org>
4915++ *
4916++ * This program is free software; you can redistribute it and/or modify
4917++ * it under the terms of the GNU General Public License version 2,
4918++ * or (at your option) any later version, as published by the Free
4919++ * Software Foundation
4920++ *
4921++ * This program is distributed in the hope that it will be useful,
4922++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4923++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4924++ * GNU General Public License for more details
4925++ *
4926++ * You should have received a copy of the GNU General Public
4927++ * License along with this program; if not, write to the
4928++ * Free Software Foundation, Inc.,
4929++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
4930++ */
4931++
4932++#include "NepomukPlugin.h"
4933++#include "NepomukResourceScoreMaintainer.h"
4934++
4935++#include "../../Event.h"
4936++#include "kext.h"
4937++
4938++#include <nepomuk/resource.h>
4939++#include <nepomuk/nuao.h>
4940++#include <nepomuk/resourcemanager.h>
4941++#include <nepomuk/variant.h>
4942++
4943++#include <Nepomuk/Query/Query>
4944++#include <Nepomuk/Query/ResourceTerm>
4945++#include <Nepomuk/Query/ResourceTypeTerm>
4946++#include <Nepomuk/Query/ComparisonTerm>
4947++#include <Nepomuk/Query/LiteralTerm>
4948++#include <Nepomuk/Query/NegationTerm>
4949++
4950++#include <Soprano/Vocabulary/NAO>
4951++#include <Soprano/QueryResultIterator>
4952++#include <Soprano/Node>
4953++#include <Soprano/Model>
4954++
4955++#include <kdebug.h>
4956++
4957++#include "NepomukCommon.h"
4958++
4959++using namespace Soprano::Vocabulary;
4960++using namespace Nepomuk::Vocabulary;
4961++using namespace Nepomuk::Query;
4962++
4963++NepomukPlugin * NepomukPlugin::s_instance = NULL;
4964++
4965++NepomukPlugin::NepomukPlugin(QObject *parent, const QVariantList & args)
4966++ : Plugin(parent)
4967++{
4968++ Q_UNUSED(args)
4969++ s_instance = this;
4970++}
4971++
4972++NepomukPlugin * NepomukPlugin::self()
4973++{
4974++ return s_instance;
4975++}
4976++
4977++void NepomukPlugin::addEvents(const EventList & events)
4978++{
4979++ foreach (const Event& event, events) {
4980++ kDebug() << "We are processing event" << event.type << event.uri;
4981++ kDebug() << "for agent" << event.application << agentResource(event.application).resourceUri();
4982++
4983++ switch (event.type) {
4984++ case Event::Accessed:
4985++ {
4986++ // one-shot event
4987++
4988++ Nepomuk::Resource eventRes = createDesktopEvent(event.uri, event.timestamp, event.application);
4989++ eventRes.addType(NUAO::UsageEvent());
4990++ eventRes.setProperty(NUAO::start(), event.timestamp);
4991++ eventRes.setProperty(NUAO::end(), event.timestamp);
4992++
4993++ kDebug() << "Created one-shot Accessed event" << eventRes;
4994++
4995++ NepomukResourceScoreMaintainer::self()->processResource(event.uri, event.application);
4996++
4997++ break;
4998++ }
4999++
5000++ case Event::Opened:
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: