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
=== modified file 'bindings/generate_vapi'
--- bindings/generate_vapi 2010-04-22 12:33:05 +0000
+++ bindings/generate_vapi 2010-07-22 17:11:00 +0000
@@ -8,3 +8,7 @@
8cd $(dirname $0)8cd $(dirname $0)
9vala-gen-introspect zeitgeist-1.0 .9vala-gen-introspect zeitgeist-1.0 .
10vapigen --pkg gobject-2.0 --pkg glib-2.0 --pkg gio-2.0 --library zeitgeist-1.0 zeitgeist-1.0.gi zeitgeist-1.0-custom.vala10vapigen --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
11# nasty hack to force usage of PtrArray in recent versions of vapigen
12sed -i 's/GenericArray/PtrArray/g' zeitgeist-1.0.vapi
13# workaround a bug introduced in vapigen 0.9.3
14sed -i 's/void \(insert_events_from_ptrarray\)\(.*\);/GLib.Array \1\2 throws GLib.Error;/' zeitgeist-1.0.vapi
1115
=== modified file 'bindings/zeitgeist-1.0.gi'
--- bindings/zeitgeist-1.0.gi 2010-06-17 14:11:59 +0000
+++ bindings/zeitgeist-1.0.gi 2010-07-22 17:11:00 +0000
@@ -63,6 +63,18 @@
63 <parameter name="tv" type="GTimeVal*"/>63 <parameter name="tv" type="GTimeVal*"/>
64 </parameters>64 </parameters>
65 </function>65 </function>
66 <function name="timestamp_next_midnight" symbol="zeitgeist_timestamp_next_midnight">
67 <return-type type="gint64"/>
68 <parameters>
69 <parameter name="timestamp" type="gint64"/>
70 </parameters>
71 </function>
72 <function name="timestamp_prev_midnight" symbol="zeitgeist_timestamp_prev_midnight">
73 <return-type type="gint64"/>
74 <parameters>
75 <parameter name="timestamp" type="gint64"/>
76 </parameters>
77 </function>
66 <function name="timestamp_to_date" symbol="zeitgeist_timestamp_to_date">78 <function name="timestamp_to_date" symbol="zeitgeist_timestamp_to_date">
67 <return-type type="void"/>79 <return-type type="void"/>
68 <parameters>80 <parameters>
@@ -438,6 +450,12 @@
438 <parameter name="error" type="GError**"/>450 <parameter name="error" type="GError**"/>
439 </parameters>451 </parameters>
440 </method>452 </method>
453 <method name="is_connected" symbol="zeitgeist_log_is_connected">
454 <return-type type="gboolean"/>
455 <parameters>
456 <parameter name="self" type="ZeitgeistLog*"/>
457 </parameters>
458 </method>
441 <constructor name="new" symbol="zeitgeist_log_new">459 <constructor name="new" symbol="zeitgeist_log_new">
442 <return-type type="ZeitgeistLog*"/>460 <return-type type="ZeitgeistLog*"/>
443 </constructor>461 </constructor>
@@ -476,6 +494,7 @@
476 <parameter name="error" type="GError**"/>494 <parameter name="error" type="GError**"/>
477 </parameters>495 </parameters>
478 </method>496 </method>
497 <property name="connected" type="gboolean" readable="1" writable="0" construct="0" construct-only="0"/>
479 </object>498 </object>
480 <object name="ZeitgeistMonitor" parent="GObject" type-name="ZeitgeistMonitor" get-type="zeitgeist_monitor_get_type">499 <object name="ZeitgeistMonitor" parent="GObject" type-name="ZeitgeistMonitor" get-type="zeitgeist_monitor_get_type">
481 <implements>500 <implements>
@@ -830,12 +849,6 @@
830 <constant name="ZEITGEIST_NMO_MAILBOX_DATA_OBJECT" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#MailboxDataObject"/>849 <constant name="ZEITGEIST_NMO_MAILBOX_DATA_OBJECT" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#MailboxDataObject"/>
831 <constant name="ZEITGEIST_NMO_MESSAGE" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#Message"/>850 <constant name="ZEITGEIST_NMO_MESSAGE" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#Message"/>
832 <constant name="ZEITGEIST_NMO_MIME_ENTITY" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#MimeEntity"/>851 <constant name="ZEITGEIST_NMO_MIME_ENTITY" type="char*" value="http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#MimeEntity"/>
833 <constant name="ZEITGEIST_TIMESTAMP_DAY" type="int" value="86400000"/>
834 <constant name="ZEITGEIST_TIMESTAMP_HOUR" type="int" value="3600000"/>
835 <constant name="ZEITGEIST_TIMESTAMP_MINUTE" type="int" value="60000"/>
836 <constant name="ZEITGEIST_TIMESTAMP_SECOND" type="int" value="1000"/>
837 <constant name="ZEITGEIST_TIMESTAMP_WEEK" type="int" value="604800000"/>
838 <constant name="ZEITGEIST_TIMESTAMP_YEAR" type="int" value="2147483647"/>
839 <constant name="ZEITGEIST_ZG_ACCESS_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#AccessEvent"/>852 <constant name="ZEITGEIST_ZG_ACCESS_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#AccessEvent"/>
840 <constant name="ZEITGEIST_ZG_CREATE_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#CreateEvent"/>853 <constant name="ZEITGEIST_ZG_CREATE_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#CreateEvent"/>
841 <constant name="ZEITGEIST_ZG_DELETE_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#DeleteEvent"/>854 <constant name="ZEITGEIST_ZG_DELETE_EVENT" type="char*" value="http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#DeleteEvent"/>
842855
=== modified file 'bindings/zeitgeist-1.0.vapi'
--- bindings/zeitgeist-1.0.vapi 2010-06-23 09:43:18 +0000
+++ bindings/zeitgeist-1.0.vapi 2010-07-22 17:11:00 +0000
@@ -24,18 +24,18 @@
24 public static int64 from_iso8601 (string datetime);24 public static int64 from_iso8601 (string datetime);
25 [CCode (cheader_filename = "zeitgeist.h")]25 [CCode (cheader_filename = "zeitgeist.h")]
26 public static int64 from_timeval (GLib.TimeVal tv);26 public static int64 from_timeval (GLib.TimeVal tv);
27 [CCode (cheader_filename = "zeitgeist.h")]
28 public static int64 next_midnight (int64 timestamp);
27 [CCode (cname = "zeitgeist_timestamp_for_now", cheader_filename = "zeitgeist.h")]29 [CCode (cname = "zeitgeist_timestamp_for_now", cheader_filename = "zeitgeist.h")]
28 public static int64 now ();30 public static int64 now ();
29 [CCode (cheader_filename = "zeitgeist.h")]31 [CCode (cheader_filename = "zeitgeist.h")]
32 public static int64 prev_midnight (int64 timestamp);
33 [CCode (cheader_filename = "zeitgeist.h")]
30 public static int64 to_date (int64 timestamp, out GLib.Date date);34 public static int64 to_date (int64 timestamp, out GLib.Date date);
31 [CCode (cheader_filename = "zeitgeist.h")]35 [CCode (cheader_filename = "zeitgeist.h")]
32 public static string to_iso8601 (int64 timestamp);36 public static string to_iso8601 (int64 timestamp);
33 [CCode (cheader_filename = "zeitgeist.h")]37 [CCode (cheader_filename = "zeitgeist.h")]
34 public static int64 to_timeval (int64 timestamp, out GLib.TimeVal tv);38 public static int64 to_timeval (int64 timestamp, out GLib.TimeVal tv);
35 [CCode (cheader_filename = "zeitgeist.h")]
36 public static int64 next_midnight (int64 timestamp);
37 [CCode (cheader_filename = "zeitgeist.h")]
38 public static int64 prev_midnight (int64 timestamp);
39 }39 }
40 [CCode (cheader_filename = "zeitgeist.h")]40 [CCode (cheader_filename = "zeitgeist.h")]
41 public class Event : GLib.InitiallyUnowned {41 public class Event : GLib.InitiallyUnowned {
@@ -67,37 +67,28 @@
67 [CCode (has_construct_function = false)]67 [CCode (has_construct_function = false)]
68 public Index ();68 public Index ();
69 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;69 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;
70 public Zeitgeist.ResultSet search_finish (GLib.AsyncResult res) throws GLib.Error;
71 }70 }
72 [CCode (cheader_filename = "zeitgeist.h")]71 [CCode (cheader_filename = "zeitgeist.h")]
73 public class Log : GLib.Object {72 public class Log : GLib.Object {
74 [CCode (has_construct_function = false)]73 [CCode (has_construct_function = false)]
75 public Log ();74 public Log ();
76 public async bool delete_events (owned GLib.Array event_ids, GLib.Cancellable? cancellable) throws GLib.Error;75 public async bool delete_events (owned GLib.Array event_ids, GLib.Cancellable? cancellable) throws GLib.Error;
77 public bool delete_events_finish (GLib.AsyncResult res) throws GLib.Error;
78 public async bool delete_log (GLib.Cancellable? cancellable) throws GLib.Error;76 public async bool delete_log (GLib.Cancellable? cancellable) throws GLib.Error;
79 public bool delete_log_finish (GLib.AsyncResult res) throws GLib.Error;
80 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;77 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;
81 public GLib.Array find_event_ids_finish (GLib.AsyncResult res) throws GLib.Error;
82 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;78 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;
83 public Zeitgeist.ResultSet find_events_finish (GLib.AsyncResult res) throws GLib.Error;
84 [CCode (array_length = false, array_null_terminated = true)]79 [CCode (array_length = false, array_null_terminated = true)]
85 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;80 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;
86 [CCode (array_length = false, array_null_terminated = true)]
87 public string[] find_related_uris_finish (GLib.AsyncResult res) throws GLib.Error;
88 public async Zeitgeist.ResultSet get_events (owned GLib.Array event_ids, GLib.Cancellable? cancellable) throws GLib.Error;81 public async Zeitgeist.ResultSet get_events (owned GLib.Array event_ids, GLib.Cancellable? cancellable) throws GLib.Error;
89 public Zeitgeist.ResultSet get_events_finish (GLib.AsyncResult res) throws GLib.Error;
90 public async GLib.Array insert_events (GLib.Cancellable? cancellable, ...) throws GLib.Error;82 public async GLib.Array insert_events (GLib.Cancellable? cancellable, ...) throws GLib.Error;
91 public GLib.Array insert_events_finish (GLib.AsyncResult res) throws GLib.Error;
92 [CCode (finish_name = "zeitgeist_log_insert_events_finish")]83 [CCode (finish_name = "zeitgeist_log_insert_events_finish")]
93 public async GLib.Array insert_events_from_ptrarray (owned GLib.PtrArray events, GLib.Cancellable? cancellable) throws GLib.Error;84 public async GLib.Array insert_events_from_ptrarray (owned GLib.PtrArray events, GLib.Cancellable? cancellable) throws GLib.Error;
94 public void insert_events_no_reply (...);85 public void insert_events_no_reply (...);
95 public async bool install_monitor (Zeitgeist.Monitor monitor, GLib.Cancellable? cancellable) throws GLib.Error;86 public async bool install_monitor (Zeitgeist.Monitor monitor, GLib.Cancellable? cancellable) throws GLib.Error;
96 public bool install_monitor_finish (GLib.AsyncResult res) throws GLib.Error;87 public bool is_connected ();
97 public async bool quit (GLib.Cancellable? cancellable) throws GLib.Error;88 public async bool quit (GLib.Cancellable? cancellable) throws GLib.Error;
98 public bool quit_finish (GLib.AsyncResult res) throws GLib.Error;
99 public async bool remove_monitor (Zeitgeist.Monitor monitor, GLib.Cancellable? cancellable) throws GLib.Error;89 public async bool remove_monitor (Zeitgeist.Monitor monitor, GLib.Cancellable? cancellable) throws GLib.Error;
100 public bool remove_monitor_finish (GLib.AsyncResult res) throws GLib.Error;90 [NoAccessorMethod]
91 public bool connected { get; }
101 }92 }
102 [CCode (cheader_filename = "zeitgeist.h")]93 [CCode (cheader_filename = "zeitgeist.h")]
103 public class Monitor : GLib.Object, Zeitgeist.EggZeitgeistMonitor {94 public class Monitor : GLib.Object, Zeitgeist.EggZeitgeistMonitor {
10495
=== modified file 'src/zeitgeist-log.c'
--- src/zeitgeist-log.c 2010-06-26 12:46:27 +0000
+++ src/zeitgeist-log.c 2010-07-22 17:11:00 +0000
@@ -54,6 +54,8 @@
54 EggDBusObjectProxy *log_proxy;54 EggDBusObjectProxy *log_proxy;
55 EggZeitgeistLog *log;55 EggZeitgeistLog *log;
5656
57 gboolean connected;
58
57 /* Hash set of ZeitgeistMonitors we've installed. We actually store59 /* Hash set of ZeitgeistMonitors we've installed. We actually store
58 * a map of (monitor, log) because this is most convenient for use with60 * a map of (monitor, log) because this is most convenient for use with
59 * _zeitgeist_monitor_weak_unref() casted to a GHFunc */61 * _zeitgeist_monitor_weak_unref() casted to a GHFunc */
@@ -65,6 +67,8 @@
65{67{
66 PROP_0,68 PROP_0,
6769
70 PROP_CONNECTED,
71
68 LAST_PROPERTY72 LAST_PROPERTY
69};73};
7074
@@ -122,6 +126,7 @@
122{126{
123 ZeitgeistLogPrivate *priv;127 ZeitgeistLogPrivate *priv;
124 EggDBusConnection *conn;128 EggDBusConnection *conn;
129 gchar *name_owner;
125130
126 priv = ZEITGEIST_LOG_GET_PRIVATE (self);131 priv = ZEITGEIST_LOG_GET_PRIVATE (self);
127 132
@@ -138,6 +143,13 @@
138 priv->log = EGG_ZEITGEIST_QUERY_INTERFACE_LOG (priv->log_proxy);143 priv->log = EGG_ZEITGEIST_QUERY_INTERFACE_LOG (priv->log_proxy);
139 g_object_unref (conn);144 g_object_unref (conn);
140145
146 name_owner = egg_dbus_object_proxy_get_name_owner (priv->log_proxy);
147 priv->connected = name_owner != NULL;
148 if (name_owner)
149 {
150 g_free (name_owner);
151 }
152
141 /* We need to detect if the Zeitgeist daemon leaves/enters the bus */153 /* We need to detect if the Zeitgeist daemon leaves/enters the bus */
142 g_signal_connect_swapped (priv->log_proxy, "notify::name-owner",154 g_signal_connect_swapped (priv->log_proxy, "notify::name-owner",
143 G_CALLBACK (_zeitgeist_log_on_name_owner_changed),155 G_CALLBACK (_zeitgeist_log_on_name_owner_changed),
@@ -214,7 +226,20 @@
214 object_class->finalize = zeitgeist_log_finalize;226 object_class->finalize = zeitgeist_log_finalize;
215 object_class->get_property = zeitgeist_log_get_property;227 object_class->get_property = zeitgeist_log_get_property;
216 object_class->set_property = zeitgeist_log_set_property;228 object_class->set_property = zeitgeist_log_set_property;
217 229
230 /**
231 * ZeitgeistLog:connected:
232 *
233 * Determines if this Log instance is currently connected to Zeitgeist
234 * daemon.
235 */
236 pspec = g_param_spec_boolean ("connected",
237 "Connected",
238 "Whether this instance is connected to Zeitgeist",
239 FALSE,
240 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
241 g_object_class_install_property (object_class, PROP_CONNECTED, pspec);
242
218 g_type_class_add_private (object_class, sizeof (ZeitgeistLogPrivate));243 g_type_class_add_private (object_class, sizeof (ZeitgeistLogPrivate));
219}244}
220245
@@ -1060,10 +1085,13 @@
1060{1085{
1061 ZeitgeistLogPrivate *priv;1086 ZeitgeistLogPrivate *priv;
1062 gchar *name_owner;1087 gchar *name_owner;
1088 gboolean has_owner;
1063 1089
1064 priv = ZEITGEIST_LOG_GET_PRIVATE (self);1090 priv = ZEITGEIST_LOG_GET_PRIVATE (self);
1065 g_object_get (priv->log_proxy, "name-owner", &name_owner, NULL);1091 g_object_get (priv->log_proxy, "name-owner", &name_owner, NULL);
1066 1092
1093 has_owner = name_owner != NULL;
1094
1067 if (name_owner == NULL)1095 if (name_owner == NULL)
1068 {1096 {
1069 /* The Zeitgeist daemon disconnected. Do nothing */1097 /* The Zeitgeist daemon disconnected. Do nothing */
@@ -1081,5 +1109,21 @@
1081 NULL, NULL, NULL);1109 NULL, NULL, NULL);
1082 }1110 }
1083 g_free (name_owner);1111 g_free (name_owner);
1084 } 1112 }
1085}1113
1114 if (has_owner != priv->connected)
1115 {
1116 priv->connected = has_owner;
1117 g_object_notify (G_OBJECT (self), "connected");
1118 }
1119}
1120
1121gboolean
1122zeitgeist_log_is_connected (ZeitgeistLog *self)
1123{
1124 ZeitgeistLogPrivate *priv;
1125
1126 priv = ZEITGEIST_LOG_GET_PRIVATE (self);
1127 return priv->connected;
1128}
1129
10861130
=== modified file 'src/zeitgeist-log.h'
--- src/zeitgeist-log.h 2010-06-10 08:07:41 +0000
+++ src/zeitgeist-log.h 2010-07-22 17:11:00 +0000
@@ -189,6 +189,8 @@
189 GAsyncResult *res,189 GAsyncResult *res,
190 GError **error);190 GError **error);
191191
192gboolean zeitgeist_log_is_connected (ZeitgeistLog *self);
193
192G_END_DECLS194G_END_DECLS
193195
194#endif /* _ZEITGEIST_LOG_H_ */196#endif /* _ZEITGEIST_LOG_H_ */

Subscribers

People subscribed via source and target branches