Merge lp:~mhr3/libzeitgeist/search-with-relevancies into lp:libzeitgeist

Proposed by Michal Hruby
Status: Merged
Merged at revision: 223
Proposed branch: lp:~mhr3/libzeitgeist/search-with-relevancies
Merge into: lp:libzeitgeist
Diff against target: 577 lines (+300/-19)
5 files modified
bindings/zeitgeist-1.0.gi (+66/-0)
bindings/zeitgeist-1.0.metadata (+4/-0)
bindings/zeitgeist-1.0.vapi (+37/-12)
src/zeitgeist-index.c (+170/-5)
src/zeitgeist-index.h (+23/-2)
To merge this branch: bzr merge lp:~mhr3/libzeitgeist/search-with-relevancies
Reviewer Review Type Date Requested Status
Siegfried Gevatter Approve
Review via email: mp+92553@code.launchpad.net

Description of the change

Adds the new search_with_relevancies method. Regenerated vapi.

To post a comment you must log in.
Revision history for this message
Siegfried Gevatter (rainct) wrote :

No tests? :(

> The #ZeitgeistResultType determining the sort order.

two spaces in there

> The #GAsyncResult you received in the #GAsyncReadyCallback you passed
> to zeitgeist_index_search()

_with_relevancies

> The total hit count of the query will be avilable via the returned

avilable

> often be bigger than actual number of events held in the result set, which

s/than/than the/

> is limited by the @num_events paramter passed to

parameter

review: Needs Fixing
223. By Michal Hruby

Fix typos

Revision history for this message
Siegfried Gevatter (rainct) wrote :

Nice.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bindings/zeitgeist-1.0.gi'
2--- bindings/zeitgeist-1.0.gi 2011-03-23 10:44:25 +0000
3+++ bindings/zeitgeist-1.0.gi 2012-02-10 20:01:26 +0000
4@@ -417,6 +417,12 @@
5 <parameter name="event" type="ZeitgeistEvent*"/>
6 </parameters>
7 </method>
8+ <method name="get_origin" symbol="zeitgeist_event_get_origin">
9+ <return-type type="gchar*"/>
10+ <parameters>
11+ <parameter name="event" type="ZeitgeistEvent*"/>
12+ </parameters>
13+ </method>
14 <method name="get_payload" symbol="zeitgeist_event_get_payload">
15 <return-type type="GByteArray*"/>
16 <parameters>
17@@ -503,6 +509,13 @@
18 <parameter name="manifestation" type="gchar*"/>
19 </parameters>
20 </method>
21+ <method name="set_origin" symbol="zeitgeist_event_set_origin">
22+ <return-type type="void"/>
23+ <parameters>
24+ <parameter name="event" type="ZeitgeistEvent*"/>
25+ <parameter name="origin" type="gchar*"/>
26+ </parameters>
27+ </method>
28 <method name="set_payload" symbol="zeitgeist_event_set_payload">
29 <return-type type="void"/>
30 <parameters>
31@@ -551,6 +564,32 @@
32 <parameter name="error" type="GError**"/>
33 </parameters>
34 </method>
35+ <method name="search_with_relevancies" symbol="zeitgeist_index_search_with_relevancies">
36+ <return-type type="void"/>
37+ <parameters>
38+ <parameter name="self" type="ZeitgeistIndex*"/>
39+ <parameter name="query" type="gchar*"/>
40+ <parameter name="time_range" type="ZeitgeistTimeRange*"/>
41+ <parameter name="event_templates" type="GPtrArray*"/>
42+ <parameter name="storage_state" type="ZeitgeistStorageState"/>
43+ <parameter name="offset" type="guint32"/>
44+ <parameter name="num_events" type="guint32"/>
45+ <parameter name="result_type" type="ZeitgeistResultType"/>
46+ <parameter name="cancellable" type="GCancellable*"/>
47+ <parameter name="callback" type="GAsyncReadyCallback"/>
48+ <parameter name="user_data" type="gpointer"/>
49+ </parameters>
50+ </method>
51+ <method name="search_with_relevancies_finish" symbol="zeitgeist_index_search_with_relevancies_finish">
52+ <return-type type="ZeitgeistResultSet*"/>
53+ <parameters>
54+ <parameter name="self" type="ZeitgeistIndex*"/>
55+ <parameter name="res" type="GAsyncResult*"/>
56+ <parameter name="relevancies" type="gdouble**"/>
57+ <parameter name="relevancies_size" type="gint*"/>
58+ <parameter name="error" type="GError**"/>
59+ </parameters>
60+ </method>
61 </object>
62 <object name="ZeitgeistLog" parent="GObject" type-name="ZeitgeistLog" get-type="zeitgeist_log_get_type">
63 <method name="delete_events" symbol="zeitgeist_log_delete_events">
64@@ -655,6 +694,9 @@
65 <parameter name="error" type="GError**"/>
66 </parameters>
67 </method>
68+ <method name="get_default" symbol="zeitgeist_log_get_default">
69+ <return-type type="ZeitgeistLog*"/>
70+ </method>
71 <method name="get_events" symbol="zeitgeist_log_get_events">
72 <return-type type="void"/>
73 <parameters>
74@@ -804,6 +846,12 @@
75 </signal>
76 </object>
77 <object name="ZeitgeistSubject" parent="GInitiallyUnowned" type-name="ZeitgeistSubject" get-type="zeitgeist_subject_get_type">
78+ <method name="get_current_uri" symbol="zeitgeist_subject_get_current_uri">
79+ <return-type type="gchar*"/>
80+ <parameters>
81+ <parameter name="subject" type="ZeitgeistSubject*"/>
82+ </parameters>
83+ </method>
84 <method name="get_interpretation" symbol="zeitgeist_subject_get_interpretation">
85 <return-type type="gchar*"/>
86 <parameters>
87@@ -861,6 +909,13 @@
88 <parameter name="storage" type="gchar*"/>
89 </parameters>
90 </constructor>
91+ <method name="set_current_uri" symbol="zeitgeist_subject_set_current_uri">
92+ <return-type type="void"/>
93+ <parameters>
94+ <parameter name="subject" type="ZeitgeistSubject*"/>
95+ <parameter name="current_uri" type="gchar*"/>
96+ </parameters>
97+ </method>
98 <method name="set_interpretation" symbol="zeitgeist_subject_set_interpretation">
99 <return-type type="void"/>
100 <parameters>
101@@ -1068,6 +1123,12 @@
102 <constant name="ZEITGEIST_NCAL_JOURNAL" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#Journal"/>
103 <constant name="ZEITGEIST_NCAL_TIMEZONE" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#Timezone"/>
104 <constant name="ZEITGEIST_NCAL_TODO" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#Todo"/>
105+ <constant name="ZEITGEIST_NCO_CONTACT" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact"/>
106+ <constant name="ZEITGEIST_NCO_CONTACT_GROUP" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nco#ContactGroup"/>
107+ <constant name="ZEITGEIST_NCO_CONTACT_LIST" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nco#ContactList"/>
108+ <constant name="ZEITGEIST_NCO_CONTACT_LIST_DATA_OBJECT" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nco#ContactListDataObject"/>
109+ <constant name="ZEITGEIST_NCO_ORGANIZATION_CONTACT" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nco#OrganizationContact"/>
110+ <constant name="ZEITGEIST_NCO_PERSON_CONTACT" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nco#PersonContact"/>
111 <constant name="ZEITGEIST_NFO_APPLICATION" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Application"/>
112 <constant name="ZEITGEIST_NFO_ARCHIVE" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Archive"/>
113 <constant name="ZEITGEIST_NFO_ARCHIVE_ITEM" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#ArchiveItem"/>
114@@ -1112,6 +1173,7 @@
115 <constant name="ZEITGEIST_NFO_VIDEO" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Video"/>
116 <constant name="ZEITGEIST_NFO_VISUAL" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Visual"/>
117 <constant name="ZEITGEIST_NFO_WEBSITE" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Website"/>
118+ <constant name="ZEITGEIST_NFO_WEB_DATA_OBJECT" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#WebDataObject"/>
119 <constant name="ZEITGEIST_NMM_MOVIE" type="char*" value="http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#Movie"/>
120 <constant name="ZEITGEIST_NMM_MUSIC_ALBUM" type="char*" value="http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#MusicAlbum"/>
121 <constant name="ZEITGEIST_NMM_MUSIC_PIECE" type="char*" value="http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#MusicPiece"/>
122@@ -1124,14 +1186,18 @@
123 <constant name="ZEITGEIST_NMO_MESSAGE" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#Message"/>
124 <constant name="ZEITGEIST_NMO_MIME_ENTITY" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#MimeEntity"/>
125 <constant name="ZEITGEIST_TIME_RANGE_VARIANT_SIGNATURE" type="char*" value="(xx)"/>
126+ <constant name="ZEITGEIST_ZG_ACCEPT_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#AcceptEvent"/>
127 <constant name="ZEITGEIST_ZG_ACCESS_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#AccessEvent"/>
128 <constant name="ZEITGEIST_ZG_CREATE_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#CreateEvent"/>
129 <constant name="ZEITGEIST_ZG_DELETE_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#DeleteEvent"/>
130+ <constant name="ZEITGEIST_ZG_DENY_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#DenyEvent"/>
131 <constant name="ZEITGEIST_ZG_EVENT_INTERPRETATION" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventInterpretation"/>
132 <constant name="ZEITGEIST_ZG_EVENT_MANIFESTATION" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventManifestation"/>
133+ <constant name="ZEITGEIST_ZG_EXPIRE_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#ExpireEvent"/>
134 <constant name="ZEITGEIST_ZG_HEURISTIC_ACTIVITY" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#HeuristicActivity"/>
135 <constant name="ZEITGEIST_ZG_LEAVE_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#LeaveEvent"/>
136 <constant name="ZEITGEIST_ZG_MODIFY_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#ModifyEvent"/>
137+ <constant name="ZEITGEIST_ZG_MOVE_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#MoveEvent"/>
138 <constant name="ZEITGEIST_ZG_RECEIVE_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#ReceiveEvent"/>
139 <constant name="ZEITGEIST_ZG_SCHEDULED_ACTIVITY" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#ScheduledActivity"/>
140 <constant name="ZEITGEIST_ZG_SEND_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#SendEvent"/>
141
142=== modified file 'bindings/zeitgeist-1.0.metadata'
143--- bindings/zeitgeist-1.0.metadata 2011-03-23 10:53:38 +0000
144+++ bindings/zeitgeist-1.0.metadata 2012-02-10 20:01:26 +0000
145@@ -10,6 +10,10 @@
146 zeitgeist_index_search async="1"
147 zeitgeist_index_search.event_templates transfer_ownership="1"
148 zeitgeist_index_search_finish transfer_ownership="1"
149+zeitgeist_index_search_with_relevancies async="1"
150+zeitgeist_index_search_with_relevancies.event_templates transfer_ownership="1"
151+zeitgeist_index_search_with_relevancies_finish.relevancies is_array="1" is_out="1" transfer_ownership="1"
152+zeitgeist_index_search_with_relevancies_finish transfer_ownership="1"
153 zeitgeist_log_new transfer_ownership="1"
154 zeitgeist_log_insert_events ellipsis="1" async="1"
155 zeitgeist_log_insert_events_from_ptrarray async="1" finish_name="zeitgeist_log_insert_events_finish"
156
157=== modified file 'bindings/zeitgeist-1.0.vapi'
158--- bindings/zeitgeist-1.0.vapi 2011-03-23 10:53:38 +0000
159+++ bindings/zeitgeist-1.0.vapi 2012-02-10 20:01:26 +0000
160@@ -1,8 +1,6 @@
161 /* zeitgeist-1.0.vapi generated by vapigen, do not modify. */
162
163-[CCode (cprefix = "Zeitgeist", lower_case_cprefix = "zeitgeist_")]
164 namespace Zeitgeist {
165- [CCode (cprefix = "ZeitgeistSymbol", lower_case_cprefix = "zeitgeist_symbol_")]
166 namespace Symbol {
167 [CCode (cheader_filename = "zeitgeist.h")]
168 public static GLib.List<weak string> get_all_children (string symbol);
169@@ -13,19 +11,18 @@
170 [CCode (cheader_filename = "zeitgeist.h")]
171 public static bool is_a (string symbol, string parent);
172 }
173- [CCode (cprefix = "ZeitgeistTimestamp", lower_case_cprefix = "zeitgeist_timestamp_")]
174 namespace Timestamp {
175- [CCode (cname = "ZEITGEIST_TIMESTAMP_DAY", cheader_filename = "zeitgeist.h")]
176+ [CCode (cheader_filename = "zeitgeist.h", cname = "ZEITGEIST_TIMESTAMP_DAY")]
177 public static int64 DAY;
178- [CCode (cname = "ZEITGEIST_TIMESTAMP_HOUR", cheader_filename = "zeitgeist.h")]
179+ [CCode (cheader_filename = "zeitgeist.h", cname = "ZEITGEIST_TIMESTAMP_HOUR")]
180 public static int64 HOUR;
181- [CCode (cname = "ZEITGEIST_TIMESTAMP_MINUTE", cheader_filename = "zeitgeist.h")]
182+ [CCode (cheader_filename = "zeitgeist.h", cname = "ZEITGEIST_TIMESTAMP_MINUTE")]
183 public static int64 MINUTE;
184- [CCode (cname = "ZEITGEIST_TIMESTAMP_SECOND", cheader_filename = "zeitgeist.h")]
185+ [CCode (cheader_filename = "zeitgeist.h", cname = "ZEITGEIST_TIMESTAMP_SECOND")]
186 public static int64 SECOND;
187- [CCode (cname = "ZEITGEIST_TIMESTAMP_WEEK", cheader_filename = "zeitgeist.h")]
188+ [CCode (cheader_filename = "zeitgeist.h", cname = "ZEITGEIST_TIMESTAMP_WEEK")]
189 public static int64 WEEK;
190- [CCode (cname = "ZEITGEIST_TIMESTAMP_YEAR", cheader_filename = "zeitgeist.h")]
191+ [CCode (cheader_filename = "zeitgeist.h", cname = "ZEITGEIST_TIMESTAMP_YEAR")]
192 public static int64 YEAR;
193 [CCode (cheader_filename = "zeitgeist.h")]
194 public static int64 from_date (GLib.Date date);
195@@ -37,7 +34,7 @@
196 public static int64 from_timeval (GLib.TimeVal tv);
197 [CCode (cheader_filename = "zeitgeist.h")]
198 public static int64 next_midnight (int64 timestamp);
199- [CCode (cname = "zeitgeist_timestamp_for_now", cheader_filename = "zeitgeist.h")]
200+ [CCode (cheader_filename = "zeitgeist.h", cname = "zeitgeist_timestamp_for_now")]
201 public static int64 now ();
202 [CCode (cheader_filename = "zeitgeist.h")]
203 public static int64 prev_midnight (int64 timestamp);
204@@ -99,6 +96,7 @@
205 public uint32 get_id ();
206 public unowned string get_interpretation ();
207 public unowned string get_manifestation ();
208+ public unowned string get_origin ();
209 public unowned GLib.ByteArray get_payload ();
210 public unowned Zeitgeist.Subject get_subject (int index);
211 public int64 get_timestamp ();
212@@ -108,6 +106,7 @@
213 public void set_id (uint32 id);
214 public void set_interpretation (string interpretation);
215 public void set_manifestation (string manifestation);
216+ public void set_origin (string origin);
217 public void set_payload (owned GLib.ByteArray payload);
218 public void set_timestamp (int64 timestamp);
219 public unowned GLib.Variant to_variant ();
220@@ -117,6 +116,7 @@
221 [CCode (has_construct_function = false)]
222 public Index ();
223 public async Zeitgeist.ResultSet search (string query, Zeitgeist.TimeRange time_range, owned GLib.PtrArray event_templates, uint32 offset, uint32 num_events, Zeitgeist.ResultType result_type, GLib.Cancellable? cancellable) throws GLib.Error;
224+ public async Zeitgeist.ResultSet search_with_relevancies (string query, Zeitgeist.TimeRange time_range, owned GLib.PtrArray event_templates, Zeitgeist.StorageState storage_state, uint32 offset, uint32 num_events, Zeitgeist.ResultType result_type, GLib.Cancellable? cancellable, out double[] relevancies) throws GLib.Error;
225 }
226 [CCode (cheader_filename = "zeitgeist.h")]
227 public class Log : GLib.Object {
228@@ -128,6 +128,7 @@
229 public async Zeitgeist.ResultSet find_events (Zeitgeist.TimeRange time_range, owned GLib.PtrArray event_templates, Zeitgeist.StorageState storage_state, uint32 num_events, Zeitgeist.ResultType result_type, GLib.Cancellable? cancellable) throws GLib.Error;
230 [CCode (array_length = false, array_null_terminated = true)]
231 public async string[] find_related_uris (Zeitgeist.TimeRange time_range, owned GLib.PtrArray event_templates, owned GLib.PtrArray result_event_templates, Zeitgeist.StorageState storage_state, uint32 num_events, Zeitgeist.ResultType result_type, GLib.Cancellable? cancellable) throws GLib.Error;
232+ public static unowned Zeitgeist.Log get_default ();
233 public async Zeitgeist.ResultSet get_events (owned GLib.Array event_ids, GLib.Cancellable? cancellable) throws GLib.Error;
234 public async GLib.Array insert_events (GLib.Cancellable? cancellable, ...) throws GLib.Error;
235 [CCode (finish_name = "zeitgeist_log_insert_events_finish")]
236@@ -159,6 +160,7 @@
237 public Subject ();
238 [CCode (has_construct_function = false)]
239 public Subject.full (string uri, string interpretation, string manifestation, string mimetype, string origin, string text, string storage);
240+ public unowned string get_current_uri ();
241 public unowned string get_interpretation ();
242 public unowned string get_manifestation ();
243 public unowned string get_mimetype ();
244@@ -166,6 +168,7 @@
245 public unowned string get_storage ();
246 public unowned string get_text ();
247 public unowned string get_uri ();
248+ public void set_current_uri (string current_uri);
249 public void set_interpretation (string interpretation);
250 public void set_manifestation (string manifestation);
251 public void set_mimetype (string mimetype);
252@@ -209,7 +212,7 @@
253 public abstract uint size ();
254 public abstract uint tell ();
255 }
256- [CCode (cprefix = "ZEITGEIST_RESULT_TYPE_", cheader_filename = "zeitgeist.h")]
257+ [CCode (cheader_filename = "zeitgeist.h", cprefix = "ZEITGEIST_RESULT_TYPE_")]
258 public enum ResultType {
259 MOST_RECENT_EVENTS,
260 LEAST_RECENT_EVENTS,
261@@ -236,7 +239,7 @@
262 LEAST_POPULAR_MIMETYPE,
263 RELEVANCY
264 }
265- [CCode (cprefix = "ZEITGEIST_STORAGE_STATE_", cheader_filename = "zeitgeist.h")]
266+ [CCode (cheader_filename = "zeitgeist.h", cprefix = "ZEITGEIST_STORAGE_STATE_")]
267 public enum StorageState {
268 NOT_AVAILABLE,
269 AVAILABLE,
270@@ -267,6 +270,18 @@
271 [CCode (cheader_filename = "zeitgeist.h")]
272 public const string NCAL_TODO;
273 [CCode (cheader_filename = "zeitgeist.h")]
274+ public const string NCO_CONTACT;
275+ [CCode (cheader_filename = "zeitgeist.h")]
276+ public const string NCO_CONTACT_GROUP;
277+ [CCode (cheader_filename = "zeitgeist.h")]
278+ public const string NCO_CONTACT_LIST;
279+ [CCode (cheader_filename = "zeitgeist.h")]
280+ public const string NCO_CONTACT_LIST_DATA_OBJECT;
281+ [CCode (cheader_filename = "zeitgeist.h")]
282+ public const string NCO_ORGANIZATION_CONTACT;
283+ [CCode (cheader_filename = "zeitgeist.h")]
284+ public const string NCO_PERSON_CONTACT;
285+ [CCode (cheader_filename = "zeitgeist.h")]
286 public const string NFO_APPLICATION;
287 [CCode (cheader_filename = "zeitgeist.h")]
288 public const string NFO_ARCHIVE;
289@@ -355,6 +370,8 @@
290 [CCode (cheader_filename = "zeitgeist.h")]
291 public const string NFO_WEBSITE;
292 [CCode (cheader_filename = "zeitgeist.h")]
293+ public const string NFO_WEB_DATA_OBJECT;
294+ [CCode (cheader_filename = "zeitgeist.h")]
295 public const string NMM_MOVIE;
296 [CCode (cheader_filename = "zeitgeist.h")]
297 public const string NMM_MUSIC_ALBUM;
298@@ -379,22 +396,30 @@
299 [CCode (cheader_filename = "zeitgeist.h")]
300 public const string TIME_RANGE_VARIANT_SIGNATURE;
301 [CCode (cheader_filename = "zeitgeist.h")]
302+ public const string ZG_ACCEPT_EVENT;
303+ [CCode (cheader_filename = "zeitgeist.h")]
304 public const string ZG_ACCESS_EVENT;
305 [CCode (cheader_filename = "zeitgeist.h")]
306 public const string ZG_CREATE_EVENT;
307 [CCode (cheader_filename = "zeitgeist.h")]
308 public const string ZG_DELETE_EVENT;
309 [CCode (cheader_filename = "zeitgeist.h")]
310+ public const string ZG_DENY_EVENT;
311+ [CCode (cheader_filename = "zeitgeist.h")]
312 public const string ZG_EVENT_INTERPRETATION;
313 [CCode (cheader_filename = "zeitgeist.h")]
314 public const string ZG_EVENT_MANIFESTATION;
315 [CCode (cheader_filename = "zeitgeist.h")]
316+ public const string ZG_EXPIRE_EVENT;
317+ [CCode (cheader_filename = "zeitgeist.h")]
318 public const string ZG_HEURISTIC_ACTIVITY;
319 [CCode (cheader_filename = "zeitgeist.h")]
320 public const string ZG_LEAVE_EVENT;
321 [CCode (cheader_filename = "zeitgeist.h")]
322 public const string ZG_MODIFY_EVENT;
323 [CCode (cheader_filename = "zeitgeist.h")]
324+ public const string ZG_MOVE_EVENT;
325+ [CCode (cheader_filename = "zeitgeist.h")]
326 public const string ZG_RECEIVE_EVENT;
327 [CCode (cheader_filename = "zeitgeist.h")]
328 public const string ZG_SCHEDULED_ACTIVITY;
329
330=== modified file 'src/zeitgeist-index.c'
331--- src/zeitgeist-index.c 2011-07-11 18:26:20 +0000
332+++ src/zeitgeist-index.c 2012-02-10 20:01:26 +0000
333@@ -1,5 +1,5 @@
334 /*
335- * Copyright (C) 2010 Canonical, Ltd.
336+ * Copyright (C) 2010-2012 Canonical, Ltd.
337 *
338 * This library is free software; you can redistribute it and/or modify
339 * it under the terms of the GNU Lesser General Public License
340@@ -17,6 +17,7 @@
341 *
342 * Authored by
343 * Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com>
344+ * Michal Hruby <michal.hruby@canonical.com>
345 */
346
347 #if HAVE_CONFIG_H
348@@ -254,7 +255,7 @@
349 * templates
350 * @offset: Offset into the result set to read events from
351 * @num_events: Maximal number of events to retrieve
352- * @result_type: The #ZeitgeistResultType determining the sort order.
353+ * @result_type: The #ZeitgeistResultType determining the sort order.
354 * You may pass #ZEITGEIST_RESULT_TYPE_RELEVANCY to this method
355 * to have the results ordered by relevancy calculated in relation
356 * to @query
357@@ -348,10 +349,11 @@
358 * Retrieve the result from an asynchronous query started with
359 * zeitgeist_index_search().
360 *
361- * The total hit count of the query will be avilable via the returned
362+ * The total hit count of the query will be available via the returned
363 * result set by calling zeitgeist_result_set_estimated_matches(). This will
364- * often be bigger than actual number of events held in the result set, which
365- * is limited by the @num_events paramter passed to zeitgeist_index_search().
366+ * often be bigger than the actual number of events held in the result set,
367+ * which is limited by the @num_events parameter passed to
368+ * zeitgeist_index_search().
369 *
370 * Returns: A newly allocated #ZeitgeistResultSet containing the
371 * #ZeitgeistEvent<!-- -->s matching the query. You must free the
372@@ -389,6 +391,169 @@
373 return _zeitgeist_simple_result_set_new (events, num_hits);
374 }
375
376+/**
377+ * zeitgeist_index_search_with_relevancies:
378+ * @self: The #ZeitgeistIndex you want to query
379+ * @query: The search string to send to Zeitgeist
380+ * @time_range: Restrict matched events to ones within this time range. If you
381+ * are not interested in restricting the timerange pass
382+ * zeitgeist_time_range_new_anytime() as Zeitgeist will detect this
383+ * and optimize the query accordingly
384+ * @event_templates: Restrict matched events to ones matching these
385+ * templates
386+ * @storage_state: Filter the events by availability of the storage medium.
387+ * @offset: Offset into the result set to read events from
388+ * @num_events: Maximal number of events to retrieve
389+ * @result_type: The #ZeitgeistResultType determining the sort order.
390+ * You may pass #ZEITGEIST_RESULT_TYPE_RELEVANCY to this method
391+ * to have the results ordered by relevancy calculated in relation
392+ * to @query
393+ * @cancellable: A #GCancellable used to cancel the call or %NULL
394+ * @callback: A #GAsyncReadyCallback to invoke when the search results are ready
395+ * @user_data: User data to pass back with @callback
396+ *
397+ * Perform a full text search possibly restricted to a #ZeitgeistTimeRange
398+ * and/or set of event templates. As opposed to zeitgeist_index_search(), this
399+ * call will also return numeric relevancies of the events
400+ * in the #ZeitgeistResultSet.
401+ *
402+ * See zeitgeist_index_search() for more details on how to create the query.
403+ */
404+void
405+zeitgeist_index_search_with_relevancies (ZeitgeistIndex *self,
406+ const gchar *query,
407+ ZeitgeistTimeRange *time_range,
408+ GPtrArray *event_templates,
409+ ZeitgeistStorageState storage_state,
410+ guint32 offset,
411+ guint32 num_events,
412+ ZeitgeistResultType result_type,
413+ GCancellable *cancellable,
414+ GAsyncReadyCallback callback,
415+ gpointer user_data)
416+{
417+ ZeitgeistIndexPrivate *priv;
418+ GVariant *vevents, *vtime_range, *params;
419+ GVariantBuilder b;
420+ MethodDispatchContext *ctx;
421+
422+ g_return_if_fail (ZEITGEIST_IS_INDEX (self));
423+ g_return_if_fail (query != NULL);
424+ g_return_if_fail (ZEITGEIST_IS_TIME_RANGE (time_range));
425+ g_return_if_fail (event_templates != NULL);
426+ g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE(cancellable));
427+
428+ priv = ZEITGEIST_INDEX_GET_PRIVATE (self);
429+
430+ /* Own all floating refs on the events, and frees the events array */
431+ vevents = zeitgeist_events_to_variant (event_templates);
432+
433+ /* Owns floating ref on time_range */
434+ vtime_range = zeitgeist_time_range_to_variant (time_range);
435+
436+ /* Build the method params */
437+ g_variant_builder_init (&b, G_VARIANT_TYPE ("(s(xx)a(asaasay)uuuu)"));
438+ g_variant_builder_add (&b, "s", query);
439+ g_variant_builder_add_value (&b, vtime_range); // owns ref
440+ g_variant_builder_add_value (&b, vevents); // owns ref
441+ g_variant_builder_add (&b, "u", storage_state);
442+ g_variant_builder_add (&b, "u", offset);
443+ g_variant_builder_add (&b, "u", num_events);
444+ g_variant_builder_add (&b, "u", result_type);
445+ params = g_variant_builder_end (&b);
446+
447+ ctx = g_new0 (MethodDispatchContext, 1);
448+ ctx->self = g_object_ref (self);
449+ ctx->method_name = "SearchWithRelevancies";
450+ ctx->params = params;
451+ ctx->cancellable = cancellable;
452+ ctx->cb = callback;
453+ ctx->user_data = user_data;
454+
455+ dispatch_method (ctx);
456+}
457+
458+/**
459+ * zeitgeist_index_search_with_relevancies_finish:
460+ * @self: The #ZeitgeistIndex to retrieve results from
461+ * @res: The #GAsyncResult you received in the #GAsyncReadyCallback you passed
462+ * to zeitgeist_index_search_with_relevancies()
463+ * @relevancies: (out) (array): Location for the newly allocated array
464+ * with relevancies.
465+ * @relevancies_size: (out): Location for the size of the newly allocated array.
466+ * @error: A place to store a #GError or %NULL in case you want to ignore errors
467+ *
468+ * Retrieve the result from an asynchronous query started with
469+ * zeitgeist_index_search_with_relevancies().
470+ *
471+ * The total hit count of the query will be available via the returned
472+ * result set by calling zeitgeist_result_set_estimated_matches(). This will
473+ * often be bigger than the actual number of events held in the result set,
474+ * which is limited by the @num_events parameter passed to
475+ * zeitgeist_index_search_with_relevancies().
476+ *
477+ * Returns: A newly allocated #ZeitgeistResultSet containing the
478+ * #ZeitgeistEvent<!-- -->s matching the query. You must free the
479+ * result set with g_object_unref(). The events held in the result set
480+ * will automatically be unreffed when it is finalized.
481+ */
482+ZeitgeistResultSet*
483+zeitgeist_index_search_with_relevancies_finish (ZeitgeistIndex *self,
484+ GAsyncResult *res,
485+ gdouble **relevancies,
486+ gint *relevancies_size,
487+ GError **error)
488+{
489+ ZeitgeistIndexPrivate *priv;
490+ GPtrArray *events;
491+ guint32 num_hits;
492+ GVariant *val, *vevents, *vrelevancies, *vnum_hits;
493+
494+ g_return_val_if_fail (ZEITGEIST_IS_INDEX (self), NULL);
495+ g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
496+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
497+
498+ priv = ZEITGEIST_INDEX_GET_PRIVATE (self);
499+ val = g_dbus_proxy_call_finish (priv->index, res, error);
500+
501+ if (val == NULL)
502+ return NULL;
503+
504+ /* Unpack return value from wrapper struct */
505+ vevents = g_variant_get_child_value (val, 0);
506+ vrelevancies = g_variant_get_child_value (val, 1);
507+ vnum_hits = g_variant_get_child_value (val, 2);
508+
509+ events = zeitgeist_events_from_variant (vevents);
510+ num_hits = g_variant_get_uint32 (vnum_hits);
511+ if (relevancies_size)
512+ {
513+ *relevancies_size = g_variant_n_children (vrelevancies);
514+ }
515+ if (relevancies)
516+ {
517+ GVariantIter iter;
518+ gdouble relevancy;
519+ int i;
520+
521+ *relevancies = g_new (gdouble, g_variant_n_children (vrelevancies));
522+
523+ i = 0;
524+ g_variant_iter_init (&iter, vrelevancies);
525+ while (g_variant_iter_loop (&iter, "d", &relevancy))
526+ {
527+ (*relevancies)[i++] = relevancy;
528+ }
529+ }
530+
531+ g_variant_unref (val);
532+ g_variant_unref (vevents);
533+ g_variant_unref (vrelevancies);
534+ g_variant_unref (vnum_hits);
535+
536+ return _zeitgeist_simple_result_set_new (events, num_hits);
537+}
538+
539 static void
540 on_proxy_acquired (GObject *source_object,
541 GAsyncResult *res,
542
543=== modified file 'src/zeitgeist-index.h'
544--- src/zeitgeist-index.h 2011-03-07 14:19:39 +0000
545+++ src/zeitgeist-index.h 2012-02-10 20:01:26 +0000
546@@ -74,8 +74,29 @@
547 gpointer user_data);
548
549 ZeitgeistResultSet*
550- zeitgeist_index_search_finish (ZeitgeistIndex *self,
551- GAsyncResult *res,
552+ zeitgeist_index_search_finish (ZeitgeistIndex *self,
553+ GAsyncResult *res,
554+ GError **error);
555+
556+void zeitgeist_index_search_with_relevancies
557+ (ZeitgeistIndex *self,
558+ const gchar *query,
559+ ZeitgeistTimeRange *time_range,
560+ GPtrArray *event_templates,
561+ ZeitgeistStorageState storage_state,
562+ guint32 offset,
563+ guint32 num_events,
564+ ZeitgeistResultType result_type,
565+ GCancellable *cancellable,
566+ GAsyncReadyCallback callback,
567+ gpointer user_data);
568+
569+ZeitgeistResultSet*
570+ zeitgeist_index_search_with_relevancies_finish
571+ (ZeitgeistIndex *self,
572+ GAsyncResult *res,
573+ gdouble **relevancies,
574+ gint *relevancies_size,
575 GError **error);
576
577 G_END_DECLS

Subscribers

People subscribed via source and target branches