Merge lp:~mhr3/libzeitgeist/various-fixes into lp:libzeitgeist

Proposed by Michal Hruby
Status: Merged
Approved by: Mikkel Kamstrup Erlandsen
Approved revision: no longer in the revision history of the source branch.
Merged at revision: 148
Proposed branch: lp:~mhr3/libzeitgeist/various-fixes
Merge into: lp:libzeitgeist
Diff against target: 254 lines (+80/-26)
5 files modified
bindings/generate_vapi (+4/-0)
bindings/zeitgeist-1.0.gi (+19/-6)
bindings/zeitgeist-1.0.vapi (+7/-16)
src/zeitgeist-log.c (+48/-4)
src/zeitgeist-log.h (+2/-0)
To merge this branch: bzr merge lp:~mhr3/libzeitgeist/various-fixes
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen Approve
Review via email: mp+30529@code.launchpad.net

Description of the change

Implements ZeitgeistLog:connected property.

To post a comment you must log in.
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Looks good - can you rename the getter method to is_connected () in stead? That seems more natural, with that change I'll approve this.

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

At first I wanted to call it "is-connected", but I looked on Gtk+ API, they don't do is-sensitive / is-enabled... not to mention zeitgeist_log_get_is_connected looks a bit weird...

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

Oh - You misunderstood me :-)

The method is zeitgeist_log_is_connected(), but the property is still called just "connected"

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

Changed to zeitgeist_log_is_connected.

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

Mmmmm.... sorry to be picky... :-) But did you read my second comment?

I meant that the method is called zeitgeist_log_is_connected() and the property name is just "connected", _not_ "is-connected"... Gtk+ does it this way many places as well.

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

Oh, guess I'm blind, sorry about that...

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

Super. Approved!

review: Approve
lp:~mhr3/libzeitgeist/various-fixes updated
148. By Mikkel Kamstrup Erlandsen <kamstrup@hardback>

Merge branch lp:~mhr3/libzeitgeist/various-fixes from Michal Hruby:

 * Adds a "connected" property to ZeitgeistLog telling you whether or not the Zeitgeist daemon is running

 * Clean up some of the VAPI and GI stuff

 * Remove _finish() functions from VAPI

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bindings/generate_vapi'
2--- bindings/generate_vapi 2010-04-22 12:33:05 +0000
3+++ bindings/generate_vapi 2010-07-22 17:11:00 +0000
4@@ -8,3 +8,7 @@
5 cd $(dirname $0)
6 vala-gen-introspect zeitgeist-1.0 .
7 vapigen --pkg gobject-2.0 --pkg glib-2.0 --pkg gio-2.0 --library zeitgeist-1.0 zeitgeist-1.0.gi zeitgeist-1.0-custom.vala
8+# nasty hack to force usage of PtrArray in recent versions of vapigen
9+sed -i 's/GenericArray/PtrArray/g' zeitgeist-1.0.vapi
10+# workaround a bug introduced in vapigen 0.9.3
11+sed -i 's/void \(insert_events_from_ptrarray\)\(.*\);/GLib.Array \1\2 throws GLib.Error;/' zeitgeist-1.0.vapi
12
13=== modified file 'bindings/zeitgeist-1.0.gi'
14--- bindings/zeitgeist-1.0.gi 2010-06-17 14:11:59 +0000
15+++ bindings/zeitgeist-1.0.gi 2010-07-22 17:11:00 +0000
16@@ -63,6 +63,18 @@
17 <parameter name="tv" type="GTimeVal*"/>
18 </parameters>
19 </function>
20+ <function name="timestamp_next_midnight" symbol="zeitgeist_timestamp_next_midnight">
21+ <return-type type="gint64"/>
22+ <parameters>
23+ <parameter name="timestamp" type="gint64"/>
24+ </parameters>
25+ </function>
26+ <function name="timestamp_prev_midnight" symbol="zeitgeist_timestamp_prev_midnight">
27+ <return-type type="gint64"/>
28+ <parameters>
29+ <parameter name="timestamp" type="gint64"/>
30+ </parameters>
31+ </function>
32 <function name="timestamp_to_date" symbol="zeitgeist_timestamp_to_date">
33 <return-type type="void"/>
34 <parameters>
35@@ -438,6 +450,12 @@
36 <parameter name="error" type="GError**"/>
37 </parameters>
38 </method>
39+ <method name="is_connected" symbol="zeitgeist_log_is_connected">
40+ <return-type type="gboolean"/>
41+ <parameters>
42+ <parameter name="self" type="ZeitgeistLog*"/>
43+ </parameters>
44+ </method>
45 <constructor name="new" symbol="zeitgeist_log_new">
46 <return-type type="ZeitgeistLog*"/>
47 </constructor>
48@@ -476,6 +494,7 @@
49 <parameter name="error" type="GError**"/>
50 </parameters>
51 </method>
52+ <property name="connected" type="gboolean" readable="1" writable="0" construct="0" construct-only="0"/>
53 </object>
54 <object name="ZeitgeistMonitor" parent="GObject" type-name="ZeitgeistMonitor" get-type="zeitgeist_monitor_get_type">
55 <implements>
56@@ -830,12 +849,6 @@
57 <constant name="ZEITGEIST_NMO_MAILBOX_DATA_OBJECT" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#MailboxDataObject"/>
58 <constant name="ZEITGEIST_NMO_MESSAGE" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#Message"/>
59 <constant name="ZEITGEIST_NMO_MIME_ENTITY" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#MimeEntity"/>
60- <constant name="ZEITGEIST_TIMESTAMP_DAY" type="int" value="86400000"/>
61- <constant name="ZEITGEIST_TIMESTAMP_HOUR" type="int" value="3600000"/>
62- <constant name="ZEITGEIST_TIMESTAMP_MINUTE" type="int" value="60000"/>
63- <constant name="ZEITGEIST_TIMESTAMP_SECOND" type="int" value="1000"/>
64- <constant name="ZEITGEIST_TIMESTAMP_WEEK" type="int" value="604800000"/>
65- <constant name="ZEITGEIST_TIMESTAMP_YEAR" type="int" value="2147483647"/>
66 <constant name="ZEITGEIST_ZG_ACCESS_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#AccessEvent"/>
67 <constant name="ZEITGEIST_ZG_CREATE_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#CreateEvent"/>
68 <constant name="ZEITGEIST_ZG_DELETE_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#DeleteEvent"/>
69
70=== modified file 'bindings/zeitgeist-1.0.vapi'
71--- bindings/zeitgeist-1.0.vapi 2010-06-23 09:43:18 +0000
72+++ bindings/zeitgeist-1.0.vapi 2010-07-22 17:11:00 +0000
73@@ -24,18 +24,18 @@
74 public static int64 from_iso8601 (string datetime);
75 [CCode (cheader_filename = "zeitgeist.h")]
76 public static int64 from_timeval (GLib.TimeVal tv);
77+ [CCode (cheader_filename = "zeitgeist.h")]
78+ public static int64 next_midnight (int64 timestamp);
79 [CCode (cname = "zeitgeist_timestamp_for_now", cheader_filename = "zeitgeist.h")]
80 public static int64 now ();
81 [CCode (cheader_filename = "zeitgeist.h")]
82+ public static int64 prev_midnight (int64 timestamp);
83+ [CCode (cheader_filename = "zeitgeist.h")]
84 public static int64 to_date (int64 timestamp, out GLib.Date date);
85 [CCode (cheader_filename = "zeitgeist.h")]
86 public static string to_iso8601 (int64 timestamp);
87 [CCode (cheader_filename = "zeitgeist.h")]
88 public static int64 to_timeval (int64 timestamp, out GLib.TimeVal tv);
89- [CCode (cheader_filename = "zeitgeist.h")]
90- public static int64 next_midnight (int64 timestamp);
91- [CCode (cheader_filename = "zeitgeist.h")]
92- public static int64 prev_midnight (int64 timestamp);
93 }
94 [CCode (cheader_filename = "zeitgeist.h")]
95 public class Event : GLib.InitiallyUnowned {
96@@ -67,37 +67,28 @@
97 [CCode (has_construct_function = false)]
98 public Index ();
99 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;
100- public Zeitgeist.ResultSet search_finish (GLib.AsyncResult res) throws GLib.Error;
101 }
102 [CCode (cheader_filename = "zeitgeist.h")]
103 public class Log : GLib.Object {
104 [CCode (has_construct_function = false)]
105 public Log ();
106 public async bool delete_events (owned GLib.Array event_ids, GLib.Cancellable? cancellable) throws GLib.Error;
107- public bool delete_events_finish (GLib.AsyncResult res) throws GLib.Error;
108 public async bool delete_log (GLib.Cancellable? cancellable) throws GLib.Error;
109- public bool delete_log_finish (GLib.AsyncResult res) throws GLib.Error;
110 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;
111- public GLib.Array find_event_ids_finish (GLib.AsyncResult res) throws GLib.Error;
112 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;
113- public Zeitgeist.ResultSet find_events_finish (GLib.AsyncResult res) throws GLib.Error;
114 [CCode (array_length = false, array_null_terminated = true)]
115 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;
116- [CCode (array_length = false, array_null_terminated = true)]
117- public string[] find_related_uris_finish (GLib.AsyncResult res) throws GLib.Error;
118 public async Zeitgeist.ResultSet get_events (owned GLib.Array event_ids, GLib.Cancellable? cancellable) throws GLib.Error;
119- public Zeitgeist.ResultSet get_events_finish (GLib.AsyncResult res) throws GLib.Error;
120 public async GLib.Array insert_events (GLib.Cancellable? cancellable, ...) throws GLib.Error;
121- public GLib.Array insert_events_finish (GLib.AsyncResult res) throws GLib.Error;
122 [CCode (finish_name = "zeitgeist_log_insert_events_finish")]
123 public async GLib.Array insert_events_from_ptrarray (owned GLib.PtrArray events, GLib.Cancellable? cancellable) throws GLib.Error;
124 public void insert_events_no_reply (...);
125 public async bool install_monitor (Zeitgeist.Monitor monitor, GLib.Cancellable? cancellable) throws GLib.Error;
126- public bool install_monitor_finish (GLib.AsyncResult res) throws GLib.Error;
127+ public bool is_connected ();
128 public async bool quit (GLib.Cancellable? cancellable) throws GLib.Error;
129- public bool quit_finish (GLib.AsyncResult res) throws GLib.Error;
130 public async bool remove_monitor (Zeitgeist.Monitor monitor, GLib.Cancellable? cancellable) throws GLib.Error;
131- public bool remove_monitor_finish (GLib.AsyncResult res) throws GLib.Error;
132+ [NoAccessorMethod]
133+ public bool connected { get; }
134 }
135 [CCode (cheader_filename = "zeitgeist.h")]
136 public class Monitor : GLib.Object, Zeitgeist.EggZeitgeistMonitor {
137
138=== modified file 'src/zeitgeist-log.c'
139--- src/zeitgeist-log.c 2010-06-26 12:46:27 +0000
140+++ src/zeitgeist-log.c 2010-07-22 17:11:00 +0000
141@@ -54,6 +54,8 @@
142 EggDBusObjectProxy *log_proxy;
143 EggZeitgeistLog *log;
144
145+ gboolean connected;
146+
147 /* Hash set of ZeitgeistMonitors we've installed. We actually store
148 * a map of (monitor, log) because this is most convenient for use with
149 * _zeitgeist_monitor_weak_unref() casted to a GHFunc */
150@@ -65,6 +67,8 @@
151 {
152 PROP_0,
153
154+ PROP_CONNECTED,
155+
156 LAST_PROPERTY
157 };
158
159@@ -122,6 +126,7 @@
160 {
161 ZeitgeistLogPrivate *priv;
162 EggDBusConnection *conn;
163+ gchar *name_owner;
164
165 priv = ZEITGEIST_LOG_GET_PRIVATE (self);
166
167@@ -138,6 +143,13 @@
168 priv->log = EGG_ZEITGEIST_QUERY_INTERFACE_LOG (priv->log_proxy);
169 g_object_unref (conn);
170
171+ name_owner = egg_dbus_object_proxy_get_name_owner (priv->log_proxy);
172+ priv->connected = name_owner != NULL;
173+ if (name_owner)
174+ {
175+ g_free (name_owner);
176+ }
177+
178 /* We need to detect if the Zeitgeist daemon leaves/enters the bus */
179 g_signal_connect_swapped (priv->log_proxy, "notify::name-owner",
180 G_CALLBACK (_zeitgeist_log_on_name_owner_changed),
181@@ -214,7 +226,20 @@
182 object_class->finalize = zeitgeist_log_finalize;
183 object_class->get_property = zeitgeist_log_get_property;
184 object_class->set_property = zeitgeist_log_set_property;
185-
186+
187+ /**
188+ * ZeitgeistLog:connected:
189+ *
190+ * Determines if this Log instance is currently connected to Zeitgeist
191+ * daemon.
192+ */
193+ pspec = g_param_spec_boolean ("connected",
194+ "Connected",
195+ "Whether this instance is connected to Zeitgeist",
196+ FALSE,
197+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
198+ g_object_class_install_property (object_class, PROP_CONNECTED, pspec);
199+
200 g_type_class_add_private (object_class, sizeof (ZeitgeistLogPrivate));
201 }
202
203@@ -1060,10 +1085,13 @@
204 {
205 ZeitgeistLogPrivate *priv;
206 gchar *name_owner;
207+ gboolean has_owner;
208
209 priv = ZEITGEIST_LOG_GET_PRIVATE (self);
210 g_object_get (priv->log_proxy, "name-owner", &name_owner, NULL);
211-
212+
213+ has_owner = name_owner != NULL;
214+
215 if (name_owner == NULL)
216 {
217 /* The Zeitgeist daemon disconnected. Do nothing */
218@@ -1081,5 +1109,21 @@
219 NULL, NULL, NULL);
220 }
221 g_free (name_owner);
222- }
223-}
224+ }
225+
226+ if (has_owner != priv->connected)
227+ {
228+ priv->connected = has_owner;
229+ g_object_notify (G_OBJECT (self), "connected");
230+ }
231+}
232+
233+gboolean
234+zeitgeist_log_is_connected (ZeitgeistLog *self)
235+{
236+ ZeitgeistLogPrivate *priv;
237+
238+ priv = ZEITGEIST_LOG_GET_PRIVATE (self);
239+ return priv->connected;
240+}
241+
242
243=== modified file 'src/zeitgeist-log.h'
244--- src/zeitgeist-log.h 2010-06-10 08:07:41 +0000
245+++ src/zeitgeist-log.h 2010-07-22 17:11:00 +0000
246@@ -189,6 +189,8 @@
247 GAsyncResult *res,
248 GError **error);
249
250+gboolean zeitgeist_log_is_connected (ZeitgeistLog *self);
251+
252 G_END_DECLS
253
254 #endif /* _ZEITGEIST_LOG_H_ */

Subscribers

People subscribed via source and target branches