Merge lp:~ricotz/slingshot/synapse-zeitgeist-2.0 into lp:~elementary-pantheon/slingshot/trunk

Proposed by Rico Tzschichholz on 2014-07-02
Status: Merged
Merged at revision: 424
Proposed branch: lp:~ricotz/slingshot/synapse-zeitgeist-2.0
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 204 lines (+49/-44)
2 files modified
lib/synapse-core/CMakeLists.txt (+1/-1)
lib/synapse-core/relevancy-backend-zg.vala (+48/-43)
To merge this branch: bzr merge lp:~ricotz/slingshot/synapse-zeitgeist-2.0
Reviewer Review Type Date Requested Status
Tom Beckmann (community) 2014-07-02 Approve on 2014-07-03
Review via email: mp+225393@code.launchpad.net

Commit message

synapse-core: Port to zeitgeist-2.0

Description of the change

synapse-core: Port to zeitgeist-2.0

To post a comment you must log in.
424. By Rico Tzschichholz on 2014-07-03

synapse-core: Port to zeitgeist-2.0

This avoids linking against two zeitgeist libraries.

Tom Beckmann (tombeckmann) wrote :

Looks great!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/synapse-core/CMakeLists.txt'
2--- lib/synapse-core/CMakeLists.txt 2014-06-13 21:09:06 +0000
3+++ lib/synapse-core/CMakeLists.txt 2014-07-03 06:39:48 +0000
4@@ -3,7 +3,7 @@
5 set(CORE_LIBRARY_NAME synapse-core)
6 set(CORE_PKG
7 glib-2.0
8- zeitgeist-1.0
9+ zeitgeist-2.0
10 gio-unix-2.0
11 json-glib-1.0
12 gee-0.8
13
14=== modified file 'lib/synapse-core/relevancy-backend-zg.vala'
15--- lib/synapse-core/relevancy-backend-zg.vala 2014-06-04 19:35:44 +0000
16+++ lib/synapse-core/relevancy-backend-zg.vala 2014-07-03 06:39:48 +0000
17@@ -47,19 +47,16 @@
18 zg_dsr = new Zeitgeist.DataSourceRegistry ();
19 try
20 {
21- var ptr_arr = yield zg_dsr.get_data_sources (null);
22+ var array = yield zg_dsr.get_data_sources (null);
23
24- for (uint i=0; i < ptr_arr.len; i++)
25- {
26- unowned Zeitgeist.DataSource ds;
27- ds = (Zeitgeist.DataSource) ptr_arr.index (i);
28- if (ds.get_unique_id () == "com.zeitgeist-project,datahub,gio-launch-listener"
29- && ds.is_enabled ())
30+ array.foreach ((ds) => {
31+ if (ds.unique_id == "com.zeitgeist-project,datahub,gio-launch-listener"
32+ && ds.enabled)
33 {
34 has_datahub_gio_module = true;
35- break;
36+ return;
37 }
38- }
39+ });
40 }
41 catch (Error err)
42 {
43@@ -79,25 +76,25 @@
44 Idle.add (load_application_relevancies.callback, Priority.LOW);
45 yield;
46
47- int64 end = Zeitgeist.Timestamp.now ();
48+ int64 end = new DateTime.now_local ().to_unix () * 1000;
49 int64 start = end - Zeitgeist.Timestamp.WEEK * 4;
50 Zeitgeist.TimeRange tr = new Zeitgeist.TimeRange (start, end);
51
52 var event = new Zeitgeist.Event ();
53- event.set_interpretation ("!" + Zeitgeist.ZG_LEAVE_EVENT);
54+ event.interpretation = "!" + Zeitgeist.ZG.LEAVE_EVENT;
55 var subject = new Zeitgeist.Subject ();
56- subject.set_interpretation (Zeitgeist.NFO_SOFTWARE);
57- subject.set_uri ("application://*");
58+ subject.interpretation = Zeitgeist.NFO.SOFTWARE;
59+ subject.uri = "application://*";
60 event.add_subject (subject);
61
62- var ptr_arr = new PtrArray ();
63- ptr_arr.add (event);
64+ var array = new GenericArray<Zeitgeist.Event> ();
65+ array.add (event);
66
67 Zeitgeist.ResultSet rs;
68
69 try
70 {
71- rs = yield zg_log.find_events (tr, (owned) ptr_arr,
72+ rs = yield zg_log.find_events (tr, array,
73 Zeitgeist.StorageState.ANY,
74 256,
75 Zeitgeist.ResultType.MOST_POPULAR_SUBJECTS,
76@@ -112,11 +109,11 @@
77 foreach (Zeitgeist.Event e in rs)
78 {
79 if (e.num_subjects () <= 0) continue;
80- Zeitgeist.Subject s = e.get_subject (0);
81+ Zeitgeist.Subject s = e.subjects[0];
82
83 float power = index / (size * 2) + 0.5f; // linearly <0.5, 1.0>
84 float relevancy = 1.0f / Math.powf (index + 1, power);
85- application_popularity[s.get_uri ()] = (int)(relevancy * MULTIPLIER);
86+ application_popularity[s.uri] = (int)(relevancy * MULTIPLIER);
87
88 index++;
89 }
90@@ -133,19 +130,19 @@
91 Idle.add (load_uri_relevancies.callback, Priority.LOW);
92 yield;
93
94- int64 end = Zeitgeist.Timestamp.now ();
95+ int64 end = new DateTime.now_local ().to_unix () * 1000;
96 int64 start = end - Zeitgeist.Timestamp.WEEK * 4;
97 Zeitgeist.TimeRange tr = new Zeitgeist.TimeRange (start, end);
98
99 var event = new Zeitgeist.Event ();
100- event.set_interpretation ("!" + Zeitgeist.ZG_LEAVE_EVENT);
101+ event.interpretation = "!" + Zeitgeist.ZG.LEAVE_EVENT;
102 var subject = new Zeitgeist.Subject ();
103- subject.set_interpretation ("!" + Zeitgeist.NFO_SOFTWARE);
104- subject.set_uri ("file://*");
105+ subject.interpretation = "!" + Zeitgeist.NFO.SOFTWARE;
106+ subject.uri = "file://*";
107 event.add_subject (subject);
108
109- var ptr_arr = new PtrArray ();
110- ptr_arr.add (event);
111+ var array = new GenericArray<Zeitgeist.Event> ();
112+ array.add (event);
113
114 Zeitgeist.ResultSet rs;
115 Gee.Map<string, int> popularity_map = new Gee.HashMap<string, int> ();
116@@ -155,7 +152,7 @@
117 uint size, index;
118 float power, relevancy;
119 /* Get popularity for file uris */
120- rs = yield zg_log.find_events (tr, (owned) ptr_arr,
121+ rs = yield zg_log.find_events (tr, array,
122 Zeitgeist.StorageState.ANY,
123 256,
124 Zeitgeist.ResultType.MOST_POPULAR_SUBJECTS,
125@@ -169,22 +166,22 @@
126 foreach (Zeitgeist.Event e1 in rs)
127 {
128 if (e1.num_subjects () <= 0) continue;
129- Zeitgeist.Subject s1 = e1.get_subject (0);
130+ Zeitgeist.Subject s1 = e1.subjects[0];
131
132 power = index / (size * 2) + 0.5f; // linearly <0.5, 1.0>
133 relevancy = 1.0f / Math.powf (index + 1, power);
134- popularity_map[s1.get_uri ()] = (int)(relevancy * MULTIPLIER);
135+ popularity_map[s1.uri] = (int)(relevancy * MULTIPLIER);
136
137 index++;
138 }
139
140 /* Get popularity for web uris */
141- subject.set_interpretation (Zeitgeist.NFO_WEBSITE);
142- subject.set_uri ("");
143- ptr_arr = new PtrArray ();
144- ptr_arr.add (event);
145+ subject.interpretation = Zeitgeist.NFO.WEBSITE;
146+ subject.uri = "";
147+ array = new GenericArray<Zeitgeist.Event> ();
148+ array.add (event);
149
150- rs = yield zg_log.find_events (tr, (owned) ptr_arr,
151+ rs = yield zg_log.find_events (tr, array,
152 Zeitgeist.StorageState.ANY,
153 128,
154 Zeitgeist.ResultType.MOST_POPULAR_SUBJECTS,
155@@ -198,11 +195,11 @@
156 foreach (Zeitgeist.Event e2 in rs)
157 {
158 if (e2.num_subjects () <= 0) continue;
159- Zeitgeist.Subject s2 = e2.get_subject (0);
160+ Zeitgeist.Subject s2 = e2.subjects[0];
161
162 power = index / (size * 2) + 0.5f; // linearly <0.5, 1.0>
163 relevancy = 1.0f / Math.powf (index + 1, power);
164- popularity_map[s2.get_uri ()] = (int)(relevancy * MULTIPLIER);
165+ popularity_map[s2.uri] = (int)(relevancy * MULTIPLIER);
166
167 index++;
168 }
169@@ -290,18 +287,26 @@
170 var event = new Zeitgeist.Event ();
171 var subject = new Zeitgeist.Subject ();
172
173- event.set_actor ("application://synapse.desktop");
174- event.set_interpretation (Zeitgeist.ZG_ACCESS_EVENT);
175- event.set_manifestation (Zeitgeist.ZG_USER_ACTIVITY);
176+ event.actor = "application://synapse.desktop";
177+ event.interpretation = Zeitgeist.ZG.ACCESS_EVENT;
178+ event.manifestation = Zeitgeist.ZG.USER_ACTIVITY;
179 event.add_subject (subject);
180
181- subject.set_uri (app_uri);
182- subject.set_interpretation (Zeitgeist.NFO_SOFTWARE);
183- subject.set_manifestation (Zeitgeist.NFO_SOFTWARE_ITEM);
184- subject.set_mimetype ("application/x-desktop");
185- subject.set_text (display_name);
186+ subject.uri = app_uri;
187+ subject.interpretation = Zeitgeist.NFO.SOFTWARE;
188+ subject.manifestation = Zeitgeist.NFO.SOFTWARE_ITEM;
189+ subject.mimetype ="application/x-desktop";
190+ subject.text = display_name;
191
192- zg_log.insert_events_no_reply (event, null);
193+ try
194+ {
195+ zg_log.insert_event_no_reply (event);
196+ }
197+ catch (Error err)
198+ {
199+ warning ("%s", err.message);
200+ return;
201+ }
202 }
203 }
204 }

Subscribers

People subscribed via source and target branches