Merge lp:~rainct/libzeitgeist/986099 into lp:libzeitgeist

Proposed by Siegfried Gevatter
Status: Needs review
Proposed branch: lp:~rainct/libzeitgeist/986099
Merge into: lp:libzeitgeist
Diff against target: 240 lines (+136/-5)
8 files modified
.bzrignore (+1/-0)
bindings/zeitgeist-1.0.gi (+5/-1)
bindings/zeitgeist-1.0.vapi (+6/-1)
examples/Makefile.am (+4/-1)
examples/find-related.c (+104/-0)
src/zeitgeist-enums.h (+14/-0)
src/zeitgeist-log.c (+1/-1)
src/zeitgeist-log.h (+1/-1)
To merge this branch: bzr merge lp:~rainct/libzeitgeist/986099
Reviewer Review Type Date Requested Status
LibZeitgeist Developers Pending
Review via email: mp+103150@code.launchpad.net
To post a comment you must log in.
lp:~rainct/libzeitgeist/986099 updated
238. By Siegfried Gevatter

Update Vala bindings.

Revision history for this message
Michal Hruby (mhr3) wrote :

Looks good to me, although it's a hidden API not-really-break. Not sure if this should go in the 0.3 series.

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Heh, good question... Do we know if this API has any consumers? The latest yelp additions maybe?

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

For the record, I'll +1 this if we a reasonably sure we arent' gonna break some clients. (FWIW - the ABI remains the same... so we shouldn't break installed apps, some may need patching to compile again though)

Unmerged revisions

238. By Siegfried Gevatter

Update Vala bindings.

237. By Siegfried Gevatter

Fix find_related_uris result type (add missing RelevantResultType)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.bzrignore'
2--- .bzrignore 1970-01-01 00:00:00 +0000
3+++ .bzrignore 2012-04-23 19:40:26 +0000
4@@ -0,0 +1,1 @@
5+find-related
6
7=== modified file 'bindings/zeitgeist-1.0.gi'
8--- bindings/zeitgeist-1.0.gi 2012-04-03 12:04:23 +0000
9+++ bindings/zeitgeist-1.0.gi 2012-04-23 19:40:26 +0000
10@@ -150,6 +150,10 @@
11 <parameter name="tv" type="GTimeVal*"/>
12 </parameters>
13 </function>
14+ <enum name="ZeitgeistRelevantResultType" type-name="ZeitgeistRelevantResultType" get-type="zeitgeist_relevant_result_type_get_type">
15+ <member name="ZEITGEIST_RELEVANT_RESULT_TYPE_RECENT" value="0"/>
16+ <member name="ZEITGEIST_RELEVANT_RESULT_TYPE_RELATED" value="1"/>
17+ </enum>
18 <enum name="ZeitgeistResultType" type-name="ZeitgeistResultType" get-type="zeitgeist_result_type_get_type">
19 <member name="ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS" value="0"/>
20 <member name="ZEITGEIST_RESULT_TYPE_LEAST_RECENT_EVENTS" value="1"/>
21@@ -688,7 +692,7 @@
22 <parameter name="result_event_templates" type="GPtrArray*"/>
23 <parameter name="storage_state" type="ZeitgeistStorageState"/>
24 <parameter name="num_events" type="guint32"/>
25- <parameter name="result_type" type="ZeitgeistResultType"/>
26+ <parameter name="result_type" type="ZeitgeistRelevantResultType"/>
27 <parameter name="cancellable" type="GCancellable*"/>
28 <parameter name="callback" type="GAsyncReadyCallback"/>
29 <parameter name="user_data" type="gpointer"/>
30
31=== modified file 'bindings/zeitgeist-1.0.vapi'
32--- bindings/zeitgeist-1.0.vapi 2012-04-04 15:31:01 +0000
33+++ bindings/zeitgeist-1.0.vapi 2012-04-23 19:40:26 +0000
34@@ -127,7 +127,7 @@
35 public async GLib.Array find_event_ids (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;
36 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;
37 [CCode (array_length = false, array_null_terminated = true)]
38- 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;
39+ 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.RelevantResultType result_type, GLib.Cancellable? cancellable) throws GLib.Error;
40 public static unowned Zeitgeist.Log get_default ();
41 public async Zeitgeist.ResultSet get_events (owned GLib.Array event_ids, GLib.Cancellable? cancellable) throws GLib.Error;
42 public void get_version (out int major, out int minor, out int micro);
43@@ -210,6 +210,11 @@
44 public abstract uint size ();
45 public abstract uint tell ();
46 }
47+ [CCode (cheader_filename = "zeitgeist.h", cprefix = "ZEITGEIST_RELEVANT_RESULT_TYPE_")]
48+ public enum RelevantResultType {
49+ RECENT,
50+ RELATED
51+ }
52 [CCode (cheader_filename = "zeitgeist.h", cprefix = "ZEITGEIST_RESULT_TYPE_")]
53 public enum ResultType {
54 MOST_RECENT_EVENTS,
55
56=== modified file 'examples/Makefile.am'
57--- examples/Makefile.am 2011-02-07 13:13:11 +0000
58+++ examples/Makefile.am 2012-04-23 19:40:26 +0000
59@@ -10,6 +10,7 @@
60
61 noinst_PROGRAMS = \
62 find-events \
63+ find-related \
64 monitor-events \
65 search-events
66
67@@ -17,10 +18,12 @@
68 find-events-alt.vala \
69 insert-event.vala
70
71-
72 find_events_SOURCES = find-events.c
73 find_events_LDADD = $(zeitgeist_libs)
74
75+find_related_SOURCES = find-related.c
76+find_related_LDADD = $(zeitgeist_libs)
77+
78 monitor_events_SOURCES = monitor-events.c
79 monitor_events_LDADD = $(zeitgeist_libs)
80
81
82=== added file 'examples/find-related.c'
83--- examples/find-related.c 1970-01-01 00:00:00 +0000
84+++ examples/find-related.c 2012-04-23 19:40:26 +0000
85@@ -0,0 +1,104 @@
86+/*
87+ * Copyright (C) 2010, 2012 Canonical Ltd
88+ *
89+ * This program is free software: you can redistribute it and/or modify
90+ * it under the terms of the GNU General Public License version 3 as
91+ * published by the Free Software Foundation.
92+ *
93+ * This program is distributed in the hope that it will be useful,
94+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
95+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
96+ * GNU General Public License for more details.
97+ *
98+ * You should have received a copy of the GNU General Public License
99+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
100+ *
101+ * Authored by Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com>
102+ * Authored by Siegfried-Angel Gevatter Pujals <sgevatter@collabora.co.uk>
103+ *
104+ */
105+
106+#include <glib.h>
107+#include <glib/gprintf.h>
108+#include <glib-object.h>
109+#include <zeitgeist.h>
110+
111+static void
112+on_uris_received (ZeitgeistLog *log,
113+ GAsyncResult *res,
114+ gpointer user_data)
115+{
116+ gchar **uris;
117+ GError *error;
118+ GMainLoop *mainloop = (GMainLoop*) user_data;
119+ gint i;
120+
121+ error = NULL;
122+ uris = zeitgeist_log_find_related_uris_finish (log, res, &error);
123+
124+ if (error)
125+ {
126+ g_warning ("Error reading results: %s", error->message);
127+ g_error_free (error);
128+ g_main_loop_quit (mainloop);
129+ return;
130+ }
131+
132+ g_printf ("Related URIs:\n");
133+
134+ while (*uris != NULL)
135+ {
136+ g_printf (" - %s\n", *uris);
137+ g_free (*uris);
138+ *uris++;
139+ }
140+
141+ g_main_loop_quit (mainloop);
142+}
143+
144+gint
145+main (gint argc,
146+ gchar *argv[])
147+{
148+ GMainLoop *mainloop;
149+ ZeitgeistLog *log;
150+ ZeitgeistEvent *event_tmpl;
151+ ZeitgeistSubject *subject_tmpl;
152+ GPtrArray *templates, *result_templates;
153+
154+ g_type_init ();
155+
156+ if (argc != 2)
157+ {
158+ g_printerr ("Usage: %s <uri>\n", argv[0]);
159+ return 1;
160+ }
161+
162+ mainloop = g_main_loop_new (NULL, FALSE);
163+ log = g_object_new (ZEITGEIST_TYPE_LOG, NULL);
164+
165+ templates = g_ptr_array_new ();
166+ subject_tmpl = zeitgeist_subject_new ();
167+ zeitgeist_subject_set_uri (subject_tmpl, argv[1]);
168+ event_tmpl = zeitgeist_event_new ();
169+ zeitgeist_event_add_subject (event_tmpl, subject_tmpl);
170+ g_ptr_array_add (templates, event_tmpl);
171+
172+ result_templates = g_ptr_array_new ();
173+ //g_ptr_array_add (result_templates, zeitgeist_event_new ());
174+
175+ zeitgeist_log_find_related_uris (log,
176+ zeitgeist_time_range_new_to_now (),
177+ templates,
178+ result_templates,
179+ ZEITGEIST_STORAGE_STATE_ANY,
180+ 10,
181+ ZEITGEIST_RELEVANT_RESULT_TYPE_RELATED,
182+ NULL,
183+ (GAsyncReadyCallback) on_uris_received,
184+ mainloop);
185+
186+ g_main_loop_run (mainloop);
187+
188+ return 0;
189+}
190
191=== modified file 'src/zeitgeist-enums.h'
192--- src/zeitgeist-enums.h 2012-04-03 12:01:54 +0000
193+++ src/zeitgeist-enums.h 2012-04-23 19:40:26 +0000
194@@ -114,6 +114,20 @@
195 } ZeitgeistResultType;
196
197 /**
198+ * ZeitgeistRelevantResultType:
199+ * @ZEITGEIST_RELEVANT_RESULT_TYPE_RECENT: Ordered by recency
200+ * @ZEITGEIST_RELEVANT_RESULT_TYPE_RELATED: Ordered by relatedness
201+ *
202+ * Used to control how "related events" query results are grouped and sorted.
203+ * See zeitgeist_log_find_related_uris().
204+ */
205+typedef enum
206+{
207+ ZEITGEIST_RELEVANT_RESULT_TYPE_RECENT = 0,
208+ ZEITGEIST_RELEVANT_RESULT_TYPE_RELATED = 1,
209+} ZeitgeistRelevantResultType;
210+
211+/**
212 * ZeitgeistStorageState:
213 * @ZEITGEIST_STORAGE_STATE_NOT_AVAILABLE: The subject is not available right now
214 * @ZEITGEIST_STORAGE_STATE_AVAILABLE: The subject is available
215
216=== modified file 'src/zeitgeist-log.c'
217--- src/zeitgeist-log.c 2012-03-26 11:03:34 +0000
218+++ src/zeitgeist-log.c 2012-04-23 19:40:26 +0000
219@@ -867,7 +867,7 @@
220 GPtrArray *result_event_templates,
221 ZeitgeistStorageState storage_state,
222 guint32 num_events,
223- ZeitgeistResultType result_type,
224+ ZeitgeistRelevantResultType result_type,
225 GCancellable *cancellable,
226 GAsyncReadyCallback callback,
227 gpointer user_data)
228
229=== modified file 'src/zeitgeist-log.h'
230--- src/zeitgeist-log.h 2012-02-13 11:07:20 +0000
231+++ src/zeitgeist-log.h 2012-04-23 19:40:26 +0000
232@@ -135,7 +135,7 @@
233 GPtrArray *result_event_templates,
234 ZeitgeistStorageState storage_state,
235 guint32 num_events,
236- ZeitgeistResultType result_type,
237+ ZeitgeistRelevantResultType result_type,
238 GCancellable *cancellable,
239 GAsyncReadyCallback callback,
240 gpointer user_data);

Subscribers

People subscribed via source and target branches