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