Merge lp:~mhr3/libzeitgeist/data-source-registry into lp:libzeitgeist

Proposed by Michal Hruby
Status: Merged
Approved by: Mikkel Kamstrup Erlandsen
Approved revision: 151
Merged at revision: 149
Proposed branch: lp:~mhr3/libzeitgeist/data-source-registry
Merge into: lp:libzeitgeist
Diff against target: 2120 lines (+1715/-118)
18 files modified
bindings/zeitgeist-1.0.gi (+186/-0)
bindings/zeitgeist-1.0.metadata (+8/-0)
bindings/zeitgeist-1.0.vapi (+32/-0)
doc/reference/zeitgeist-1.0-docs.sgml (+3/-1)
doc/reference/zeitgeist-1.0-sections.txt (+163/-107)
doc/reference/zeitgeist-1.0.types (+8/-6)
src/Makefile.am (+12/-0)
src/marshal.list (+4/-0)
src/org.gnome.zeitgeist.Log.xml (+73/-0)
src/zeitgeist-data-source-registry.c (+527/-0)
src/zeitgeist-data-source-registry.h (+108/-0)
src/zeitgeist-data-source.c (+349/-0)
src/zeitgeist-data-source.h (+101/-0)
src/zeitgeist-eggdbusconversions.c (+51/-0)
src/zeitgeist-eggdbusconversions.h (+8/-2)
src/zeitgeist.h (+3/-1)
tests/Makefile.am (+2/-0)
tests/test-eggdbusconversions.c (+77/-1)
To merge this branch: bzr merge lp:~mhr3/libzeitgeist/data-source-registry
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen Approve
Review via email: mp+30754@code.launchpad.net

This proposal supersedes a proposal from 2010-07-22.

Description of the change

Adds API which talks to the DataSourceRegistry extension.

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

Outstanding work Michal! A few comments, but nothing critical:

 1) There is a comment "... coming from this Index instance ..." which should probably be s/Index/data source registry/

 2) You need a line break after the symbol name in the docstring for zeitgeist_data_source_registry_new()

 3) Can you add a bit of documentation to the ZeitgeistDataSource section?

 4) Can you document that you are stealing the ref to the GPtrArray in zeitgeist_data_source_set_templates()

 5) I prefer that getters returning booleans are named as foo_is_*(). This affects zeitgeist_data_source_get_{running,enabled}()

 6) Please add some unit tests for the conversion between the eggdbus stuff and the native types

 7) Integrate the two new types into the gtk-doc

If you fix this I'd be delighted to merge you branch :-)

And as a bonus you could perhaps add some more doc strings, but it's ok if you don't...

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

Top notch work Michal. Approved!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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-23 10:53:43 +0000
@@ -101,6 +101,192 @@
101 <member name="ZEITGEIST_STORAGE_STATE_AVAILABLE" value="1"/>101 <member name="ZEITGEIST_STORAGE_STATE_AVAILABLE" value="1"/>
102 <member name="ZEITGEIST_STORAGE_STATE_ANY" value="2"/>102 <member name="ZEITGEIST_STORAGE_STATE_ANY" value="2"/>
103 </enum>103 </enum>
104 <object name="ZeitgeistDataSource" parent="GInitiallyUnowned" type-name="ZeitgeistDataSource" get-type="zeitgeist_data_source_get_type">
105 <method name="get_description" symbol="zeitgeist_data_source_get_description">
106 <return-type type="gchar*"/>
107 <parameters>
108 <parameter name="src" type="ZeitgeistDataSource*"/>
109 </parameters>
110 </method>
111 <method name="get_enabled" symbol="zeitgeist_data_source_get_enabled">
112 <return-type type="gboolean"/>
113 <parameters>
114 <parameter name="src" type="ZeitgeistDataSource*"/>
115 </parameters>
116 </method>
117 <method name="get_event_templates" symbol="zeitgeist_data_source_get_event_templates">
118 <return-type type="GPtrArray*"/>
119 <parameters>
120 <parameter name="src" type="ZeitgeistDataSource*"/>
121 </parameters>
122 </method>
123 <method name="get_name" symbol="zeitgeist_data_source_get_name">
124 <return-type type="gchar*"/>
125 <parameters>
126 <parameter name="src" type="ZeitgeistDataSource*"/>
127 </parameters>
128 </method>
129 <method name="get_running" symbol="zeitgeist_data_source_get_running">
130 <return-type type="gboolean"/>
131 <parameters>
132 <parameter name="src" type="ZeitgeistDataSource*"/>
133 </parameters>
134 </method>
135 <method name="get_timestamp" symbol="zeitgeist_data_source_get_timestamp">
136 <return-type type="gint64"/>
137 <parameters>
138 <parameter name="src" type="ZeitgeistDataSource*"/>
139 </parameters>
140 </method>
141 <method name="get_unique_id" symbol="zeitgeist_data_source_get_unique_id">
142 <return-type type="gchar*"/>
143 <parameters>
144 <parameter name="src" type="ZeitgeistDataSource*"/>
145 </parameters>
146 </method>
147 <constructor name="new" symbol="zeitgeist_data_source_new">
148 <return-type type="ZeitgeistDataSource*"/>
149 </constructor>
150 <constructor name="new_full" symbol="zeitgeist_data_source_new_full">
151 <return-type type="ZeitgeistDataSource*"/>
152 <parameters>
153 <parameter name="id" type="gchar*"/>
154 <parameter name="name" type="gchar*"/>
155 <parameter name="desc" type="gchar*"/>
156 <parameter name="event_templates" type="GPtrArray*"/>
157 </parameters>
158 </constructor>
159 <method name="set_description" symbol="zeitgeist_data_source_set_description">
160 <return-type type="void"/>
161 <parameters>
162 <parameter name="src" type="ZeitgeistDataSource*"/>
163 <parameter name="description" type="gchar*"/>
164 </parameters>
165 </method>
166 <method name="set_enabled" symbol="zeitgeist_data_source_set_enabled">
167 <return-type type="void"/>
168 <parameters>
169 <parameter name="src" type="ZeitgeistDataSource*"/>
170 <parameter name="enabled" type="gboolean"/>
171 </parameters>
172 </method>
173 <method name="set_event_templates" symbol="zeitgeist_data_source_set_event_templates">
174 <return-type type="void"/>
175 <parameters>
176 <parameter name="src" type="ZeitgeistDataSource*"/>
177 <parameter name="event_templates" type="GPtrArray*"/>
178 </parameters>
179 </method>
180 <method name="set_name" symbol="zeitgeist_data_source_set_name">
181 <return-type type="void"/>
182 <parameters>
183 <parameter name="src" type="ZeitgeistDataSource*"/>
184 <parameter name="name" type="gchar*"/>
185 </parameters>
186 </method>
187 <method name="set_running" symbol="zeitgeist_data_source_set_running">
188 <return-type type="void"/>
189 <parameters>
190 <parameter name="src" type="ZeitgeistDataSource*"/>
191 <parameter name="running" type="gboolean"/>
192 </parameters>
193 </method>
194 <method name="set_timestamp" symbol="zeitgeist_data_source_set_timestamp">
195 <return-type type="void"/>
196 <parameters>
197 <parameter name="src" type="ZeitgeistDataSource*"/>
198 <parameter name="timestamp" type="gint64"/>
199 </parameters>
200 </method>
201 <method name="set_unique_id" symbol="zeitgeist_data_source_set_unique_id">
202 <return-type type="void"/>
203 <parameters>
204 <parameter name="src" type="ZeitgeistDataSource*"/>
205 <parameter name="unique_id" type="gchar*"/>
206 </parameters>
207 </method>
208 </object>
209 <object name="ZeitgeistDataSourceRegistry" parent="GObject" type-name="ZeitgeistDataSourceRegistry" get-type="zeitgeist_data_source_registry_get_type">
210 <method name="get_data_sources" symbol="zeitgeist_data_source_registry_get_data_sources">
211 <return-type type="void"/>
212 <parameters>
213 <parameter name="self" type="ZeitgeistDataSourceRegistry*"/>
214 <parameter name="cancellable" type="GCancellable*"/>
215 <parameter name="callback" type="GAsyncReadyCallback"/>
216 <parameter name="user_data" type="gpointer"/>
217 </parameters>
218 </method>
219 <method name="get_data_sources_finish" symbol="zeitgeist_data_source_registry_get_data_sources_finish">
220 <return-type type="GPtrArray*"/>
221 <parameters>
222 <parameter name="self" type="ZeitgeistDataSourceRegistry*"/>
223 <parameter name="res" type="GAsyncResult*"/>
224 <parameter name="error" type="GError**"/>
225 </parameters>
226 </method>
227 <constructor name="new" symbol="zeitgeist_data_source_registry_new">
228 <return-type type="ZeitgeistDataSourceRegistry*"/>
229 </constructor>
230 <method name="register_data_source" symbol="zeitgeist_data_source_registry_register_data_source">
231 <return-type type="void"/>
232 <parameters>
233 <parameter name="self" type="ZeitgeistDataSourceRegistry*"/>
234 <parameter name="source" type="ZeitgeistDataSource*"/>
235 <parameter name="cancellable" type="GCancellable*"/>
236 <parameter name="callback" type="GAsyncReadyCallback"/>
237 <parameter name="user_data" type="gpointer"/>
238 </parameters>
239 </method>
240 <method name="register_data_source_finish" symbol="zeitgeist_data_source_registry_register_data_source_finish">
241 <return-type type="gboolean"/>
242 <parameters>
243 <parameter name="self" type="ZeitgeistDataSourceRegistry*"/>
244 <parameter name="res" type="GAsyncResult*"/>
245 <parameter name="error" type="GError**"/>
246 </parameters>
247 </method>
248 <method name="set_data_source_enabled" symbol="zeitgeist_data_source_registry_set_data_source_enabled">
249 <return-type type="void"/>
250 <parameters>
251 <parameter name="self" type="ZeitgeistDataSourceRegistry*"/>
252 <parameter name="unique_id" type="gchar*"/>
253 <parameter name="enabled" type="gboolean"/>
254 <parameter name="cancellable" type="GCancellable*"/>
255 <parameter name="callback" type="GAsyncReadyCallback"/>
256 <parameter name="user_data" type="gpointer"/>
257 </parameters>
258 </method>
259 <method name="set_data_source_enabled_finish" symbol="zeitgeist_data_source_registry_set_data_source_enabled_finish">
260 <return-type type="void"/>
261 <parameters>
262 <parameter name="self" type="ZeitgeistDataSourceRegistry*"/>
263 <parameter name="res" type="GAsyncResult*"/>
264 <parameter name="error" type="GError**"/>
265 </parameters>
266 </method>
267 <signal name="source-disconnected" when="FIRST">
268 <return-type type="void"/>
269 <parameters>
270 <parameter name="registry" type="ZeitgeistDataSourceRegistry*"/>
271 <parameter name="source" type="ZeitgeistDataSource*"/>
272 </parameters>
273 </signal>
274 <signal name="source-enabled" when="FIRST">
275 <return-type type="void"/>
276 <parameters>
277 <parameter name="registry" type="ZeitgeistDataSourceRegistry*"/>
278 <parameter name="unique_id" type="char*"/>
279 <parameter name="enabled" type="gboolean"/>
280 </parameters>
281 </signal>
282 <signal name="source-registered" when="FIRST">
283 <return-type type="void"/>
284 <parameters>
285 <parameter name="registry" type="ZeitgeistDataSourceRegistry*"/>
286 <parameter name="source" type="ZeitgeistDataSource*"/>
287 </parameters>
288 </signal>
289 </object>
104 <object name="ZeitgeistEvent" parent="GInitiallyUnowned" type-name="ZeitgeistEvent" get-type="zeitgeist_event_get_type">290 <object name="ZeitgeistEvent" parent="GInitiallyUnowned" type-name="ZeitgeistEvent" get-type="zeitgeist_event_get_type">
105 <method name="add_subject" symbol="zeitgeist_event_add_subject">291 <method name="add_subject" symbol="zeitgeist_event_add_subject">
106 <return-type type="void"/>292 <return-type type="void"/>
107293
=== modified file 'bindings/zeitgeist-1.0.metadata'
--- bindings/zeitgeist-1.0.metadata 2010-06-17 14:11:59 +0000
+++ bindings/zeitgeist-1.0.metadata 2010-07-23 10:53:43 +0000
@@ -1,5 +1,12 @@
1Zeitgeist cheader_filename="zeitgeist.h"1Zeitgeist cheader_filename="zeitgeist.h"
2Zeitgeist.Timestamp cheader_filename="zeitgeist.h"2Zeitgeist.Timestamp cheader_filename="zeitgeist.h"
3zeitgeist_data_source_new_full.event_templates transfer_ownership="1"
4zeitgeist_data_source_set_event_templates.event_templates transfer_ownership="1"
5zeitgeist_data_source_registry_get_data_sources async="1"
6zeitgeist_data_source_registry_get_data_sources_finish transfer_ownership="1"
7zeitgeist_data_source_registry_register_data_source async="1"
8zeitgeist_data_source_registry_register_data_source.source transfer_ownership="1"
9zeitgeist_data_source_registry_set_data_source_enabled async="1"
3zeitgeist_index_search async="1"10zeitgeist_index_search async="1"
4zeitgeist_index_search.event_templates transfer_ownership="1"11zeitgeist_index_search.event_templates transfer_ownership="1"
5zeitgeist_index_search_finish transfer_ownership="1"12zeitgeist_index_search_finish transfer_ownership="1"
@@ -33,6 +40,7 @@
33zeitgeist_event_set_payload.payload transfer_ownership="1"40zeitgeist_event_set_payload.payload transfer_ownership="1"
34zeitgeist_monitor_new.event_templates transfer_ownership="1"41zeitgeist_monitor_new.event_templates transfer_ownership="1"
3542
43zeitgeist_data_source_registry_*.cancellable nullable="1"
36zeitgeist_log_*.cancellable nullable="1"44zeitgeist_log_*.cancellable nullable="1"
37zeitgeist_index_*.cancellable nullable="1"45zeitgeist_index_*.cancellable nullable="1"
3846
3947
=== 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-23 10:53:43 +0000
@@ -38,6 +38,38 @@
38 public static int64 prev_midnight (int64 timestamp);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 DataSource : GLib.InitiallyUnowned {
42 [CCode (has_construct_function = false)]
43 public DataSource ();
44 [CCode (has_construct_function = false)]
45 public DataSource.full (string id, string name, string desc, owned GLib.PtrArray event_templates);
46 public unowned string get_description ();
47 public bool get_enabled ();
48 public unowned GLib.PtrArray get_event_templates ();
49 public unowned string get_name ();
50 public bool get_running ();
51 public int64 get_timestamp ();
52 public unowned string get_unique_id ();
53 public void set_description (string description);
54 public void set_enabled (bool enabled);
55 public void set_event_templates (owned GLib.PtrArray event_templates);
56 public void set_name (string name);
57 public void set_running (bool running);
58 public void set_timestamp (int64 timestamp);
59 public void set_unique_id (string unique_id);
60 }
61 [CCode (cheader_filename = "zeitgeist.h")]
62 public class DataSourceRegistry : GLib.Object {
63 [CCode (has_construct_function = false)]
64 public DataSourceRegistry ();
65 public async GLib.PtrArray get_data_sources (GLib.Cancellable? cancellable) throws GLib.Error;
66 public async bool register_data_source (owned Zeitgeist.DataSource source, GLib.Cancellable? cancellable) throws GLib.Error;
67 public async void set_data_source_enabled (string unique_id, bool enabled, GLib.Cancellable? cancellable) throws GLib.Error;
68 public virtual signal void source_disconnected (Zeitgeist.DataSource source);
69 public virtual signal void source_enabled (string unique_id, bool enabled);
70 public virtual signal void source_registered (Zeitgeist.DataSource source);
71 }
72 [CCode (cheader_filename = "zeitgeist.h")]
41 public class Event : GLib.InitiallyUnowned {73 public class Event : GLib.InitiallyUnowned {
42 [CCode (has_construct_function = false)]74 [CCode (has_construct_function = false)]
43 public Event ();75 public Event ();
4476
=== modified file 'doc/reference/zeitgeist-1.0-docs.sgml'
--- doc/reference/zeitgeist-1.0-docs.sgml 2010-06-17 09:22:18 +0000
+++ doc/reference/zeitgeist-1.0-docs.sgml 2010-07-23 10:53:43 +0000
@@ -34,7 +34,9 @@
34 34
35 <chapter>35 <chapter>
36 <title>API for Zeitgeist Extensions</title>36 <title>API for Zeitgeist Extensions</title>
37 <xi:include href="xml/zeitgeist-index.xml"/>37 <xi:include href="xml/zeitgeist-index.xml"/>
38 <xi:include href="xml/zeitgeist-data-source.xml"/>
39 <xi:include href="xml/zeitgeist-data-source-registry.xml"/>
38 </chapter>40 </chapter>
39 41
40 <chapter id="object-tree">42 <chapter id="object-tree">
4143
=== modified file 'doc/reference/zeitgeist-1.0-sections.txt'
--- doc/reference/zeitgeist-1.0-sections.txt 2010-06-23 09:43:18 +0000
+++ doc/reference/zeitgeist-1.0-sections.txt 2010-07-23 10:53:43 +0000
@@ -1,63 +1,32 @@
1<SECTION>1<SECTION>
2<FILE>zeitgeist-timerange</FILE>2<FILE>zeitgeist-data-source</FILE>
3<TITLE>ZeitgeistTimeRange</TITLE>3<TITLE>ZeitgeistDataSource</TITLE>
4ZeitgeistTimeRange4ZeitgeistDataSource
5ZeitgeistTimeRangeClass5ZeitgeistDataSourceClass
6zeitgeist_time_range_new6zeitgeist_data_source_new
7zeitgeist_time_range_new_from_now7zeitgeist_data_source_new_full
8zeitgeist_time_range_new_to_now8zeitgeist_data_source_get_unique_id
9zeitgeist_time_range_new_anytime9zeitgeist_data_source_set_unique_id
10zeitgeist_time_range_get_start10zeitgeist_data_source_get_name
11zeitgeist_time_range_get_end11zeitgeist_data_source_set_name
12zeitgeist_time_range_get_start_iso860112zeitgeist_data_source_get_description
13zeitgeist_time_range_get_end_iso860113zeitgeist_data_source_set_description
14<SUBSECTION Standard>14zeitgeist_data_source_get_event_templates
15ZEITGEIST_TIME_RANGE15zeitgeist_data_source_set_event_templates
16ZEITGEIST_IS_TIME_RANGE16zeitgeist_data_source_is_running
17ZEITGEIST_TYPE_TIME_RANGE17zeitgeist_data_source_set_running
18zeitgeist_time_range_get_type18zeitgeist_data_source_get_timestamp
19ZEITGEIST_TIME_RANGE_CLASS19zeitgeist_data_source_set_timestamp
20ZEITGEIST_IS_TIME_RANGE_CLASS20zeitgeist_data_source_is_enabled
21ZEITGEIST_TIME_RANGE_GET_CLASS21zeitgeist_data_source_set_enabled
22</SECTION>22<SUBSECTION Standard>
2323ZEITGEIST_DATA_SOURCE
24<SECTION>24ZEITGEIST_IS_DATA_SOURCE
25<FILE>zeitgeist-log</FILE>25ZEITGEIST_TYPE_DATA_SOURCE
26<TITLE>ZeitgeistLog</TITLE>26zeitgeist_data_source_get_type
27ZeitgeistLog27ZEITGEIST_DATA_SOURCE_CLASS
28ZeitgeistLogClass28ZEITGEIST_IS_DATA_SOURCE_CLASS
29zeitgeist_log_new29ZEITGEIST_DATA_SOURCE_GET_CLASS
30zeitgeist_log_insert_events
31zeitgeist_log_insert_events_no_reply
32zeitgeist_log_insert_events_valist
33zeitgeist_log_insert_events_from_ptrarray
34zeitgeist_log_insert_events_finish
35zeitgeist_log_find_events
36zeitgeist_log_find_events_finish
37zeitgeist_log_find_event_ids
38zeitgeist_log_find_event_ids_finish
39zeitgeist_log_get_events
40zeitgeist_log_get_events_finish
41zeitgeist_log_find_related_uris
42zeitgeist_log_find_related_uris_finish
43zeitgeist_log_delete_events
44zeitgeist_log_delete_events_finish
45zeitgeist_log_delete_log
46zeitgeist_log_delete_log_finish
47zeitgeist_log_quit
48zeitgeist_log_quit_finish
49zeitgeist_log_install_monitor
50zeitgeist_log_install_monitor_finish
51zeitgeist_log_remove_monitor
52zeitgeist_log_remove_monitor_finish
53<SUBSECTION Standard>
54ZEITGEIST_LOG
55ZEITGEIST_IS_LOG
56ZEITGEIST_TYPE_LOG
57zeitgeist_log_get_type
58ZEITGEIST_LOG_CLASS
59ZEITGEIST_IS_LOG_CLASS
60ZEITGEIST_LOG_GET_CLASS
61</SECTION>30</SECTION>
6231
63<SECTION>32<SECTION>
@@ -92,6 +61,67 @@
92</SECTION>61</SECTION>
9362
94<SECTION>63<SECTION>
64<FILE>zeitgeist-timerange</FILE>
65<TITLE>ZeitgeistTimeRange</TITLE>
66ZeitgeistTimeRange
67ZeitgeistTimeRangeClass
68zeitgeist_time_range_new
69zeitgeist_time_range_new_from_now
70zeitgeist_time_range_new_to_now
71zeitgeist_time_range_new_anytime
72zeitgeist_time_range_get_start
73zeitgeist_time_range_get_end
74zeitgeist_time_range_get_start_iso8601
75zeitgeist_time_range_get_end_iso8601
76<SUBSECTION Standard>
77ZEITGEIST_TIME_RANGE
78ZEITGEIST_IS_TIME_RANGE
79ZEITGEIST_TYPE_TIME_RANGE
80zeitgeist_time_range_get_type
81ZEITGEIST_TIME_RANGE_CLASS
82ZEITGEIST_IS_TIME_RANGE_CLASS
83ZEITGEIST_TIME_RANGE_GET_CLASS
84</SECTION>
85
86<SECTION>
87<FILE>zeitgeist-index</FILE>
88<TITLE>ZeitgeistIndex</TITLE>
89ZeitgeistIndex
90ZeitgeistIndexClass
91zeitgeist_index_new
92zeitgeist_index_search
93zeitgeist_index_search_finish
94<SUBSECTION Standard>
95ZEITGEIST_INDEX
96ZEITGEIST_IS_INDEX
97ZEITGEIST_TYPE_INDEX
98zeitgeist_index_get_type
99ZEITGEIST_INDEX_CLASS
100ZEITGEIST_IS_INDEX_CLASS
101ZEITGEIST_INDEX_GET_CLASS
102</SECTION>
103
104<SECTION>
105<FILE>zeitgeist-result-set</FILE>
106<TITLE>ZeitgeistResultSet</TITLE>
107ZeitgeistResultSetIface
108ZeitgeistResultSet
109zeitgeist_result_set_size
110zeitgeist_result_set_estimated_matches
111zeitgeist_result_set_next
112zeitgeist_result_set_has_next
113zeitgeist_result_set_peek
114zeitgeist_result_set_seek
115zeitgeist_result_set_tell
116<SUBSECTION Standard>
117ZEITGEIST_RESULT_SET
118ZEITGEIST_IS_RESULT_SET
119ZEITGEIST_TYPE_RESULT_SET
120zeitgeist_result_set_get_type
121ZEITGEIST_RESULT_SET_GET_IFACE
122</SECTION>
123
124<SECTION>
95<FILE>zeitgeist-event</FILE>125<FILE>zeitgeist-event</FILE>
96<TITLE>ZeitgeistEvent</TITLE>126<TITLE>ZeitgeistEvent</TITLE>
97ZeitgeistEvent127ZeitgeistEvent
@@ -109,6 +139,7 @@
109zeitgeist_event_set_manifestation139zeitgeist_event_set_manifestation
110zeitgeist_event_get_actor140zeitgeist_event_get_actor
111zeitgeist_event_set_actor141zeitgeist_event_set_actor
142zeitgeist_event_set_actor_from_app_info
112zeitgeist_event_get_subject143zeitgeist_event_get_subject
113zeitgeist_event_num_subjects144zeitgeist_event_num_subjects
114zeitgeist_event_add_subject145zeitgeist_event_add_subject
@@ -125,6 +156,28 @@
125</SECTION>156</SECTION>
126157
127<SECTION>158<SECTION>
159<FILE>zeitgeist-data-source-registry</FILE>
160<TITLE>ZeitgeistDataSourceRegistry</TITLE>
161ZeitgeistDataSourceRegistry
162ZeitgeistDataSourceRegistryClass
163zeitgeist_data_source_registry_new
164zeitgeist_data_source_registry_get_data_sources
165zeitgeist_data_source_registry_get_data_sources_finish
166zeitgeist_data_source_registry_register_data_source
167zeitgeist_data_source_registry_register_data_source_finish
168zeitgeist_data_source_registry_set_data_source_enabled
169zeitgeist_data_source_registry_set_data_source_enabled_finish
170<SUBSECTION Standard>
171ZEITGEIST_DATA_SOURCE_REGISTRY
172ZEITGEIST_IS_DATA_SOURCE_REGISTRY
173ZEITGEIST_TYPE_DATA_SOURCE_REGISTRY
174zeitgeist_data_source_registry_get_type
175ZEITGEIST_DATA_SOURCE_REGISTRY_CLASS
176ZEITGEIST_IS_DATA_SOURCE_REGISTRY_CLASS
177ZEITGEIST_DATA_SOURCE_REGISTRY_GET_CLASS
178</SECTION>
179
180<SECTION>
128<FILE>zeitgeist-monitor</FILE>181<FILE>zeitgeist-monitor</FILE>
129<TITLE>ZeitgeistMonitor</TITLE>182<TITLE>ZeitgeistMonitor</TITLE>
130ZeitgeistMonitor183ZeitgeistMonitor
@@ -137,12 +190,52 @@
137ZEITGEIST_MONITOR190ZEITGEIST_MONITOR
138ZEITGEIST_IS_MONITOR191ZEITGEIST_IS_MONITOR
139ZEITGEIST_TYPE_MONITOR192ZEITGEIST_TYPE_MONITOR
193zeitgeist_monitor_get_type
140ZEITGEIST_MONITOR_CLASS194ZEITGEIST_MONITOR_CLASS
141ZEITGEIST_IS_MONITOR_CLASS195ZEITGEIST_IS_MONITOR_CLASS
142ZEITGEIST_MONITOR_GET_CLASS196ZEITGEIST_MONITOR_GET_CLASS
143</SECTION>197</SECTION>
144198
145<SECTION>199<SECTION>
200<FILE>zeitgeist-log</FILE>
201<TITLE>ZeitgeistLog</TITLE>
202ZeitgeistLog
203ZeitgeistLogClass
204zeitgeist_log_new
205zeitgeist_log_insert_events
206zeitgeist_log_insert_events_no_reply
207zeitgeist_log_insert_events_valist
208zeitgeist_log_insert_events_from_ptrarray
209zeitgeist_log_insert_events_finish
210zeitgeist_log_find_events
211zeitgeist_log_find_events_finish
212zeitgeist_log_find_event_ids
213zeitgeist_log_find_event_ids_finish
214zeitgeist_log_get_events
215zeitgeist_log_get_events_finish
216zeitgeist_log_find_related_uris
217zeitgeist_log_find_related_uris_finish
218zeitgeist_log_delete_events
219zeitgeist_log_delete_events_finish
220zeitgeist_log_delete_log
221zeitgeist_log_delete_log_finish
222zeitgeist_log_quit
223zeitgeist_log_quit_finish
224zeitgeist_log_install_monitor
225zeitgeist_log_install_monitor_finish
226zeitgeist_log_remove_monitor
227zeitgeist_log_remove_monitor_finish
228<SUBSECTION Standard>
229ZEITGEIST_LOG
230ZEITGEIST_IS_LOG
231ZEITGEIST_TYPE_LOG
232zeitgeist_log_get_type
233ZEITGEIST_LOG_CLASS
234ZEITGEIST_IS_LOG_CLASS
235ZEITGEIST_LOG_GET_CLASS
236</SECTION>
237
238<SECTION>
146<FILE>zeitgeist-enumtypes</FILE>239<FILE>zeitgeist-enumtypes</FILE>
147zeitgeist_result_type_get_type240zeitgeist_result_type_get_type
148ZEITGEIST_TYPE_RESULT_TYPE241ZEITGEIST_TYPE_RESULT_TYPE
@@ -162,6 +255,16 @@
162</SECTION>255</SECTION>
163256
164<SECTION>257<SECTION>
258<FILE>zeitgeist-mimetypes</FILE>
259<TITLE>Mimetype mapping and URI comprehension</TITLE>
260zeitgeist_register_mimetype
261zeitgeist_register_mimetype_regex
262zeitgeist_interpretation_for_mimetype
263zeitgeist_register_uri_scheme
264zeitgeist_manifestation_for_uri
265</SECTION>
266
267<SECTION>
165<FILE>zeitgeist-ontology-interpretations</FILE>268<FILE>zeitgeist-ontology-interpretations</FILE>
166<TITLE>Interpretation Ontology</TITLE>269<TITLE>Interpretation Ontology</TITLE>
167ZEITGEIST_NCAL_ALARM270ZEITGEIST_NCAL_ALARM
@@ -250,54 +353,6 @@
250</SECTION>353</SECTION>
251354
252<SECTION>355<SECTION>
253<FILE>zeitgeist-mimetypes</FILE>
254<TITLE>Mimetype mapping and URI comprehension</TITLE>
255zeitgeist_register_mimetype
256zeitgeist_register_mimetype_regex
257zeitgeist_interpretation_for_mimetype
258zeitgeist_register_uri_scheme
259zeitgeist_manifestation_for_uri
260</SECTION>
261
262<SECTION>
263<FILE>zeitgeist-index</FILE>
264<TITLE>ZeitgeistIndex</TITLE>
265ZeitgeistIndex
266ZeitgeistIndexClass
267zeitgeist_index_new
268zeitgeist_index_search
269zeitgeist_index_search_finish
270<SUBSECTION Standard>
271ZEITGEIST_INDEX
272ZEITGEIST_IS_INDEX
273ZEITGEIST_TYPE_INDEX
274zeitgeist_index_get_type
275ZEITGEIST_INDEX_CLASS
276ZEITGEIST_IS_INDEX_CLASS
277ZEITGEIST_INDEX_GET_CLASS
278</SECTION>
279
280<SECTION>
281<FILE>zeitgeist-result-set</FILE>
282<TITLE>ZeitgeistResultSet</TITLE>
283ZeitgeistResultSet
284ZeitgeistResultSetIface
285zeitgeist_result_set_size
286zeitgeist_result_set_estimated_matches
287zeitgeist_result_set_next
288zeitgeist_result_set_has_next
289zeitgeist_result_set_peek
290zeitgeist_result_set_seek
291zeitgeist_result_set_tell
292<SUBSECTION Standard>
293ZEITGEIST_RESULT_SET
294ZEITGEIST_IS_RESULT_SET
295ZEITGEIST_TYPE_RESULT_SET
296ZEITGEIST_RESULT_SET_GET_IFACE
297zeitgeist_result_set_get_type
298</SECTION>
299
300<SECTION>
301<FILE>zeitgeist-timestamp</FILE>356<FILE>zeitgeist-timestamp</FILE>
302<TITLE>Timestamp handling</TITLE>357<TITLE>Timestamp handling</TITLE>
303ZEITGEIST_TIMESTAMP_SECOND358ZEITGEIST_TIMESTAMP_SECOND
@@ -317,3 +372,4 @@
317zeitgeist_timestamp_next_midnight372zeitgeist_timestamp_next_midnight
318zeitgeist_timestamp_prev_midnight373zeitgeist_timestamp_prev_midnight
319</SECTION>374</SECTION>
375
320376
=== modified file 'doc/reference/zeitgeist-1.0.types'
--- doc/reference/zeitgeist-1.0.types 2010-06-09 14:36:16 +0000
+++ doc/reference/zeitgeist-1.0.types 2010-07-23 10:53:43 +0000
@@ -1,9 +1,11 @@
1zeitgeist_data_source_get_type
2zeitgeist_data_source_registry_get_type
3zeitgeist_event_get_type
4zeitgeist_index_get_type
1zeitgeist_log_get_type5zeitgeist_log_get_type
2zeitgeist_event_get_type6zeitgeist_monitor_get_type
7zeitgeist_result_set_get_type
8zeitgeist_result_type_get_type
9zeitgeist_storage_state_get_type
3zeitgeist_subject_get_type10zeitgeist_subject_get_type
4zeitgeist_time_range_get_type11zeitgeist_time_range_get_type
5zeitgeist_monitor_get_type
6zeitgeist_storage_state_get_type
7zeitgeist_result_type_get_type
8zeitgeist_index_get_type
9
1012
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2010-06-28 13:50:12 +0000
+++ src/Makefile.am 2010-07-23 10:53:43 +0000
@@ -40,6 +40,10 @@
40 eggzeitgeistbindingstypes.h \40 eggzeitgeistbindingstypes.h \
41 eggzeitgeistblacklist.h \41 eggzeitgeistblacklist.h \
42 eggzeitgeistblacklist.c \42 eggzeitgeistblacklist.c \
43 eggzeitgeistdatasource.h \
44 eggzeitgeistdatasource.c \
45 eggzeitgeistdatasourceregistry.h \
46 eggzeitgeistdatasourceregistry.c \
43 eggzeitgeistevent.c \47 eggzeitgeistevent.c \
44 eggzeitgeistevent.h \48 eggzeitgeistevent.h \
45 eggzeitgeisteventdataoffset.c \49 eggzeitgeisteventdataoffset.c \
@@ -66,9 +70,11 @@
66 docbook-enum-StorageState.xml \70 docbook-enum-StorageState.xml \
67 docbook-enum-SubjectDataOffset.xml \71 docbook-enum-SubjectDataOffset.xml \
68 docbook-interface-org.gnome.zeitgeist.Blacklist.xml \72 docbook-interface-org.gnome.zeitgeist.Blacklist.xml \
73 docbook-interface-org.gnome.zeitgeist.DataSourceRegistry.xml \
69 docbook-interface-org.gnome.zeitgeist.Index.xml \74 docbook-interface-org.gnome.zeitgeist.Index.xml \
70 docbook-interface-org.gnome.zeitgeist.Log.xml \75 docbook-interface-org.gnome.zeitgeist.Log.xml \
71 docbook-interface-org.gnome.zeitgeist.Monitor.xml \76 docbook-interface-org.gnome.zeitgeist.Monitor.xml \
77 docbook-struct-DataSource.xml \
72 docbook-struct-Event.xml \78 docbook-struct-Event.xml \
73 docbook-struct-TimeRange.xml \79 docbook-struct-TimeRange.xml \
74 $(NULL)80 $(NULL)
@@ -99,6 +105,10 @@
99lib_LTLIBRARIES = libzeitgeist-1.0.la105lib_LTLIBRARIES = libzeitgeist-1.0.la
100106
101libzeitgeist_1_0_la_SOURCES = \107libzeitgeist_1_0_la_SOURCES = \
108 zeitgeist-data-source.h \
109 zeitgeist-data-source.c \
110 zeitgeist-data-source-registry.h \
111 zeitgeist-data-source-registry.c \
102 zeitgeist-eggdbusconversions.h \112 zeitgeist-eggdbusconversions.h \
103 zeitgeist-eggdbusconversions.c \113 zeitgeist-eggdbusconversions.c \
104 zeitgeist-enums.h \114 zeitgeist-enums.h \
@@ -142,6 +152,8 @@
142devel_headersdir = $(includedir)/zeitgeist-1.0152devel_headersdir = $(includedir)/zeitgeist-1.0
143153
144devel_headers = \154devel_headers = \
155 zeitgeist-data-source.h \
156 zeitgeist-data-source-registry.h \
145 zeitgeist-enums.h \157 zeitgeist-enums.h \
146 zeitgeist-enumtypes.h \158 zeitgeist-enumtypes.h \
147 zeitgeist-event.h \159 zeitgeist-event.h \
148160
=== modified file 'src/marshal.list'
--- src/marshal.list 2010-06-10 09:14:22 +0000
+++ src/marshal.list 2010-07-23 10:53:43 +0000
@@ -3,3 +3,7 @@
33
4# ZeitgeistMonitor::events-deleted4# ZeitgeistMonitor::events-deleted
5VOID:OBJECT,BOXED5VOID:OBJECT,BOXED
6
7# ZeitgeistDataSourceRegistry::source-enabled
8VOID:STRING,BOOLEAN
9
610
=== modified file 'src/org.gnome.zeitgeist.Log.xml'
--- src/org.gnome.zeitgeist.Log.xml 2010-06-09 13:22:12 +0000
+++ src/org.gnome.zeitgeist.Log.xml 2010-07-23 10:53:43 +0000
@@ -37,6 +37,41 @@
37 </annotation>37 </annotation>
38 </annotation>38 </annotation>
3939
40 <annotation name="org.gtk.EggDBus.DeclareStruct" value="DataSource">
41 <annotation name="org.gtk.EggDBus.DocString"
42 value="The #DataSource type is used to represent registered data sources"/>
43 <annotation name="org.gtk.EggDBus.DocString.Summary" value="DataSource"/>
44
45 <annotation name="org.gtk.EggDBus.Struct.Member"
46 value="String:unique_id">
47 <annotation name="org.gtk.EggDBus.DocString" value="Unique ID of the data source"/>
48 </annotation>
49 <annotation name="org.gtk.EggDBus.Struct.Member" value="String:name">
50 <annotation name="org.gtk.EggDBus.DocString"
51 value="Name of the data source"/>
52 </annotation>
53 <annotation name="org.gtk.EggDBus.Struct.Member" value="String:description">
54 <annotation name="org.gtk.EggDBus.DocString"
55 value="Description of the data source"/>
56 </annotation>
57 <annotation name="org.gtk.EggDBus.Struct.Member" value="Array<Event>:event_templates">
58 <annotation name="org.gtk.EggDBus.DocString"
59 value="Event templates for this data source"/>
60 </annotation>
61 <annotation name="org.gtk.EggDBus.Struct.Member" value="Boolean:running">
62 <annotation name="org.gtk.EggDBus.DocString"
63 value="Whether data source is currently running"/>
64 </annotation>
65 <annotation name="org.gtk.EggDBus.Struct.Member" value="Int64:last_seen">
66 <annotation name="org.gtk.EggDBus.DocString"
67 value="Timestamp of last action of this data source"/>
68 </annotation>
69 <annotation name="org.gtk.EggDBus.Struct.Member" value="Boolean:enabled">
70 <annotation name="org.gtk.EggDBus.DocString"
71 value="Whether data source is enabled"/>
72 </annotation>
73 </annotation>
74
40 <annotation name="org.gtk.EggDBus.DeclareEnum" value="EventDataOffset">75 <annotation name="org.gtk.EggDBus.DeclareEnum" value="EventDataOffset">
41 <annotation name="org.gtk.EggDBus.DocString"76 <annotation name="org.gtk.EggDBus.DocString"
42 value="Offsets into the event data array on which to find particular fields"/>77 value="Offsets into the event data array on which to find particular fields"/>
@@ -349,4 +384,42 @@
349 <arg direction="out" type="u" name="hit_count"/>384 <arg direction="out" type="u" name="hit_count"/>
350 </method> 385 </method>
351 </interface>386 </interface>
387
388 <interface name="org.gnome.zeitgeist.DataSourceRegistry">
389 <annotation name="org.gtk.EggDBus.DocString" value="An extension which allows you to registers data sources in a central repository. This allows for example to disable some data sources."/>
390 <method name="RegisterDataSource">
391 <arg direction="in" type="s" name="unique_id"/>
392 <arg direction="in" type="s" name="name"/>
393 <arg direction="in" type="s" name="description"/>
394 <arg direction="in" type="a(asaasay)" name="event_templates">
395 <annotation name="org.gtk.EggDBus.Type" value="Array<Event>"/>
396 </arg>
397 <arg direction="out" type="b" name="result"/>
398 </method>
399 <method name="SetDataSourceEnabled">
400 <arg direction="in" type="s" name="unique_id"/>
401 <arg direction="in" type="b" name="enabled"/>
402 </method>
403 <method name="GetDataSources">
404 <arg direction="out" type="a(sssa(asaasay)bxb)">
405 <annotation name="org.gtk.EggDBus.Type" value="Array<DataSource>"/>
406 </arg>
407 </method>
408
409 <signal name="DataSourceRegistered">
410 <arg type="(sssa(asaasay)bxb)">
411 <annotation name="org.gtk.EggDBus.Type" value="DataSource"/>
412 </arg>
413 </signal>
414 <signal name="DataSourceDisconnected">
415 <arg type="(sssa(asaasay)bxb)">
416 <annotation name="org.gtk.EggDBus.Type" value="DataSource"/>
417 </arg>
418 </signal>
419 <signal name="DataSourceEnabled">
420 <arg type="s" name="unique_id"/>
421 <arg type="b" name="enabled"/>
422 </signal>
423 </interface>
424
352</node>425</node>
353426
=== added file 'src/zeitgeist-data-source-registry.c'
--- src/zeitgeist-data-source-registry.c 1970-01-01 00:00:00 +0000
+++ src/zeitgeist-data-source-registry.c 2010-07-23 10:53:43 +0000
@@ -0,0 +1,527 @@
1/*
2 * Copyright (C) 2010 Canonical, Ltd.
3 *
4 * This library is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License
6 * version 3.0 as published by the Free Software Foundation.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License version 3.0 for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library. If not, see
15 * <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Michal Hruby <michal.mhr@gmail.com>
18 */
19
20#if HAVE_CONFIG_H
21#include <config.h>
22#endif
23
24#include "zeitgeist-data-source-registry.h"
25#include "zeitgeist-eggdbusconversions.h"
26#include "zeitgeist-marshal.h"
27#include "eggzeitgeistbindings.h"
28
29/**
30 * SECTION:zeitgeist-data-source-registry
31 * @short_description: Query the Zeitgeist Data Source Registry extension
32 * @include: zeitgeist.h
33 *
34 * The Zeitgeist engine maintains a publicly available list of recognized
35 * data-sources (components inserting information into Zeitgeist).
36 * #ZeitgeistDataSourceRegistry is used to register new data sources,
37 * get information about them and gives the ability to enable or disable
38 * the data sources.
39 */
40
41G_DEFINE_TYPE (ZeitgeistDataSourceRegistry,
42 zeitgeist_data_source_registry,
43 G_TYPE_OBJECT);
44#define ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE(obj) \
45 (G_TYPE_INSTANCE_GET_PRIVATE(obj, ZEITGEIST_TYPE_DATA_SOURCE_REGISTRY, \
46 ZeitgeistDataSourceRegistryPrivate))
47
48typedef struct
49{
50 /* The connection to the ZG daemon
51 * Note: The EggZeitgeistDataSourceRegistry is owned by
52 * the EggDBusObjectProxy!
53 */
54 EggDBusObjectProxy *registry_proxy;
55 EggZeitgeistDataSourceRegistry *registry;
56
57 gulong src_registered_id;
58 gulong src_disconnected_id;
59 gulong src_enabled_id;
60
61} ZeitgeistDataSourceRegistryPrivate;
62
63/* Property ids */
64enum
65{
66 PROP_0,
67
68 LAST_PROPERTY
69};
70
71enum
72{
73 SOURCE_REGISTERED,
74 SOURCE_ENABLED,
75 SOURCE_DISCONNECTED,
76
77 LAST_SIGNAL
78};
79static guint _registry_signals[LAST_SIGNAL] = { 0 };
80
81static void
82zeitgeist_data_source_registry_init (ZeitgeistDataSourceRegistry *self)
83{
84 ZeitgeistDataSourceRegistryPrivate *priv;
85 EggDBusConnection *conn;
86
87 priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (self);
88
89 /* Set up the connection to the ZG daemon */
90 conn = egg_dbus_connection_get_for_bus (EGG_DBUS_BUS_TYPE_SESSION);
91 priv->registry_proxy =
92 egg_dbus_connection_get_object_proxy (conn,
93 "org.gnome.zeitgeist.Engine",
94 "/org/gnome/zeitgeist/data_source_registry");
95
96 priv->registry =
97 EGG_ZEITGEIST_QUERY_INTERFACE_DATA_SOURCE_REGISTRY (priv->registry_proxy);
98 g_object_unref (conn);
99}
100
101static void
102zeitgeist_data_source_registry_finalize (GObject *object)
103{
104 ZeitgeistDataSourceRegistry *registry;
105 ZeitgeistDataSourceRegistryPrivate *priv;
106
107 registry = ZEITGEIST_DATA_SOURCE_REGISTRY (object);
108 priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (registry);
109
110 if (priv->src_registered_id)
111 {
112 g_signal_handler_disconnect (priv->registry, priv->src_registered_id);
113 }
114
115 if (priv->src_disconnected_id)
116 {
117 g_signal_handler_disconnect (priv->registry, priv->src_disconnected_id);
118 }
119
120 if (priv->src_enabled_id)
121 {
122 g_signal_handler_disconnect (priv->registry, priv->src_enabled_id);
123 }
124
125 /* Note: priv->registry is owned by priv->registry_proxy */
126 if (priv->registry_proxy)
127 {
128 g_object_unref (priv->registry_proxy);
129 }
130
131 G_OBJECT_CLASS (zeitgeist_data_source_registry_parent_class)->finalize (object);
132}
133
134static void
135zeitgeist_data_source_registry_get_property (GObject *object,
136 guint prop_id,
137 GValue *value,
138 GParamSpec *pspec)
139{
140 ZeitgeistDataSourceRegistryPrivate *priv;
141
142 priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (object);
143
144 switch (prop_id)
145 {
146 default:
147 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
148 return;
149 break;
150 }
151}
152
153static void
154zeitgeist_data_source_registry_set_property (GObject *object,
155 guint prop_id,
156 const GValue *value,
157 GParamSpec *pspec)
158{
159 ZeitgeistDataSourceRegistryPrivate *priv;
160
161 priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (object);
162
163 switch (prop_id)
164 {
165 default:
166 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
167 return;
168 break;
169 }
170}
171
172static void
173zeitgeist_data_source_registry_src_registered (
174 ZeitgeistDataSourceRegistry *registry,
175 EggZeitgeistDataSource *source)
176{
177 ZeitgeistDataSource *data_source;
178
179 data_source = _egg_zeitgeist_data_source_to_zeitgeist_data_source (source);
180
181 g_signal_emit (registry, _registry_signals[SOURCE_REGISTERED],
182 0, data_source);
183
184 g_object_unref (data_source);
185}
186
187static void
188zeitgeist_data_source_registry_src_disconnected (
189 ZeitgeistDataSourceRegistry *registry,
190 EggZeitgeistDataSource *source)
191{
192 ZeitgeistDataSource *data_source;
193
194 data_source = _egg_zeitgeist_data_source_to_zeitgeist_data_source (source);
195
196 g_signal_emit (registry, _registry_signals[SOURCE_DISCONNECTED],
197 0, data_source);
198
199 g_object_unref (data_source);
200}
201
202static void
203zeitgeist_data_source_registry_src_enabled (
204 ZeitgeistDataSourceRegistry *registry,
205 gchar *unique_id,
206 gboolean enabled)
207{
208 g_signal_emit (registry, _registry_signals[SOURCE_ENABLED],
209 0, unique_id, enabled);
210}
211
212static void
213zeitgeist_data_source_registry_constructed (GObject *object)
214{
215 ZeitgeistDataSourceRegistryPrivate *priv;
216
217 priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (object);
218
219 priv->src_registered_id = g_signal_connect_swapped (
220 priv->registry, "data-source-registered",
221 G_CALLBACK (zeitgeist_data_source_registry_src_registered),
222 object);
223 priv->src_disconnected_id = g_signal_connect_swapped (
224 priv->registry, "data-source-disconnected",
225 G_CALLBACK (zeitgeist_data_source_registry_src_disconnected),
226 object);
227 priv->src_enabled_id = g_signal_connect_swapped (
228 priv->registry, "data-source-enabled",
229 G_CALLBACK (zeitgeist_data_source_registry_src_enabled),
230 object);
231}
232
233static void
234zeitgeist_data_source_registry_class_init (ZeitgeistDataSourceRegistryClass *klass)
235{
236 GObjectClass *object_class = G_OBJECT_CLASS (klass);
237 GParamSpec *pspec;
238
239 object_class->finalize = zeitgeist_data_source_registry_finalize;
240 object_class->get_property = zeitgeist_data_source_registry_get_property;
241 object_class->set_property = zeitgeist_data_source_registry_set_property;
242 object_class->constructed = zeitgeist_data_source_registry_constructed;
243
244 _registry_signals[SOURCE_REGISTERED] =
245 g_signal_new ("source-registered",
246 G_OBJECT_CLASS_TYPE (object_class),
247 G_SIGNAL_RUN_FIRST,
248 G_STRUCT_OFFSET (ZeitgeistDataSourceRegistryClass, source_registered),
249 NULL, NULL,
250 g_cclosure_marshal_VOID__OBJECT,
251 G_TYPE_NONE, 1, ZEITGEIST_TYPE_DATA_SOURCE);
252
253 _registry_signals[SOURCE_DISCONNECTED] =
254 g_signal_new ("source-disconnected",
255 G_OBJECT_CLASS_TYPE (object_class),
256 G_SIGNAL_RUN_FIRST,
257 G_STRUCT_OFFSET (ZeitgeistDataSourceRegistryClass, source_disconnected),
258 NULL, NULL,
259 g_cclosure_marshal_VOID__OBJECT,
260 G_TYPE_NONE, 1, ZEITGEIST_TYPE_DATA_SOURCE);
261
262 _registry_signals[SOURCE_ENABLED] =
263 g_signal_new ("source-enabled",
264 G_OBJECT_CLASS_TYPE (object_class),
265 G_SIGNAL_RUN_FIRST,
266 G_STRUCT_OFFSET (ZeitgeistDataSourceRegistryClass, source_enabled),
267 NULL, NULL,
268 _zeitgeist_cclosure_marshal_VOID__STRING_BOOLEAN,
269 G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_BOOLEAN);
270
271 g_type_class_add_private (object_class,
272 sizeof (ZeitgeistDataSourceRegistryPrivate));
273}
274
275/* Used to marshal the async callbacks from EggDBus into ones
276 * coming from this DataSourceRegistry instance */
277static void
278dispatch_async_callback (GObject *source_object,
279 GAsyncResult *res,
280 gpointer user_data)
281{
282 gpointer *data = (gpointer*) user_data;
283 ZeitgeistDataSourceRegistry *self = ZEITGEIST_DATA_SOURCE_REGISTRY (data[0]);
284 GAsyncReadyCallback callback = (GAsyncReadyCallback) data[1];
285 gpointer _user_data = data[2];
286
287 if (callback != NULL)
288 {
289 callback (G_OBJECT (self), res, _user_data);
290 }
291
292 g_object_unref (self);
293 g_free (user_data);
294}
295
296/*
297 * API BELOW HERE
298 */
299
300/**
301 * zeitgeist_data_source_registry_new:
302 *
303 * Create a new data source registry instance.
304 *
305 * DataSourceRegistry instances are not overly expensive for neither
306 * client or the Zeitgeist daemon so there's no need to go to lengths
307 * to keep singleton instances around.
308 *
309 * Returns: A reference to a newly allocated registry.
310 */
311ZeitgeistDataSourceRegistry*
312zeitgeist_data_source_registry_new (void)
313{
314 ZeitgeistDataSourceRegistry *registry;
315
316 registry = (ZeitgeistDataSourceRegistry*)
317 g_object_new (ZEITGEIST_TYPE_DATA_SOURCE_REGISTRY, NULL);
318
319 return registry;
320}
321
322void
323zeitgeist_data_source_registry_get_data_sources (
324 ZeitgeistDataSourceRegistry *self,
325 GCancellable *cancellable,
326 GAsyncReadyCallback callback,
327 gpointer user_data)
328{
329 ZeitgeistDataSourceRegistryPrivate *priv;
330 gpointer *dispatch_data;
331
332 g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE_REGISTRY (self));
333 g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
334
335 priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (self);
336
337 dispatch_data = g_new (gpointer, 3);
338 dispatch_data[0] = g_object_ref (self);
339 dispatch_data[1] = callback;
340 dispatch_data[2] = user_data;
341
342 egg_zeitgeist_data_source_registry_get_data_sources (
343 priv->registry,
344 EGG_DBUS_CALL_FLAGS_NONE,
345 cancellable,
346 dispatch_async_callback,
347 dispatch_data);
348}
349
350/**
351 * zeitgeist_data_source_registry_get_data_sources_finish:
352 * @self: Instance of #ZeitgeistDataSourceRegistry.
353 * @res: a #GAsyncResult.
354 * @error: a #GError or #NULL.
355 *
356 * Returns: Newly created #GPtrArray containing #ZeitgeistDataSource<!-- -->(s)
357 * registered in Zeitgeist. Free using g_ptr_array_unref() once
358 * you're done using it.
359 */
360GPtrArray*
361zeitgeist_data_source_registry_get_data_sources_finish (
362 ZeitgeistDataSourceRegistry *self,
363 GAsyncResult *res,
364 GError **error)
365{
366 ZeitgeistDataSourceRegistryPrivate *priv;
367 EggDBusArraySeq *array_seq;
368 gboolean call_result;
369 GPtrArray *data_sources = NULL;
370
371 g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE_REGISTRY (self), NULL);
372
373 priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (self);
374
375 call_result = egg_zeitgeist_data_source_registry_get_data_sources_finish (
376 priv->registry,
377 &array_seq,
378 res,
379 error);
380
381 data_sources =
382 _egg_zeitgeist_data_sources_to_zeitgeist_data_sources (array_seq);
383 g_ptr_array_set_free_func (data_sources, g_object_unref);
384
385 g_object_unref (array_seq);
386
387 return data_sources;
388}
389
390/**
391 * zeitgeist_data_source_registry_register_data_source:
392 * @self: Instance of #ZeitgeistDataSourceRegistry.
393 * @source: Data source to register.
394 * @cancellable: a #GCancellable or #NULL.
395 * @callback: a GAsyncReadyCallback to call when the request is finished.
396 * @user_data: the data to pass to callback function.
397 *
398 * Registers new data source in the registry, the @source parameter needs to
399 * have unique-id, name, description and optionally event_templates set,
400 * therefore it is useful to pass #ZeitgeistDataSource instance created using
401 * zeitgeist_data_source_new_full(). The registry will assume its ownership.
402 */
403void
404zeitgeist_data_source_registry_register_data_source (
405 ZeitgeistDataSourceRegistry *self,
406 ZeitgeistDataSource *source,
407 GCancellable *cancellable,
408 GAsyncReadyCallback callback,
409 gpointer user_data)
410{
411 ZeitgeistDataSourceRegistryPrivate *priv;
412 gpointer *dispatch_data;
413 EggDBusArraySeq *templates;
414
415 g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE_REGISTRY (self));
416 g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE (source));
417 g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
418
419 priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (self);
420
421 g_object_ref_sink (G_OBJECT (source));
422
423 dispatch_data = g_new (gpointer, 3);
424 dispatch_data[0] = g_object_ref (self);
425 dispatch_data[1] = callback;
426 dispatch_data[2] = user_data;
427
428 templates = _zeitgeist_events_to_egg_zeitgeist_events (
429 zeitgeist_data_source_get_event_templates (source)
430 );
431
432 egg_zeitgeist_data_source_registry_register_data_source (
433 priv->registry,
434 EGG_DBUS_CALL_FLAGS_NONE,
435 zeitgeist_data_source_get_unique_id (source),
436 zeitgeist_data_source_get_name (source),
437 zeitgeist_data_source_get_description (source),
438 templates,
439 cancellable,
440 dispatch_async_callback,
441 dispatch_data);
442
443 g_object_unref (templates);
444 g_object_unref (source);
445}
446
447/**
448 * zeitgeist_data_source_registry_register_data_source_finish:
449 * @self: Instance of #ZeitgeistDataSourceRegistry.
450 * @res: Result of the asynchronous operation.
451 * @error: a #GError or NULL.
452 *
453 * Returns: If error is unset, returns whether this data source is enabled.
454 */
455gboolean
456zeitgeist_data_source_registry_register_data_source_finish (
457 ZeitgeistDataSourceRegistry *self,
458 GAsyncResult *res,
459 GError **error)
460{
461 ZeitgeistDataSourceRegistryPrivate *priv;
462 gboolean result = FALSE;
463
464 g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE_REGISTRY (self), FALSE);
465
466 priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (self);
467
468 egg_zeitgeist_data_source_registry_register_data_source_finish (
469 priv->registry,
470 &result,
471 res,
472 error);
473
474 return result;
475}
476
477void
478zeitgeist_data_source_registry_set_data_source_enabled (
479 ZeitgeistDataSourceRegistry *self,
480 const gchar *unique_id,
481 gboolean enabled,
482 GCancellable *cancellable,
483 GAsyncReadyCallback callback,
484 gpointer user_data)
485{
486 ZeitgeistDataSourceRegistryPrivate *priv;
487 gpointer *dispatch_data;
488
489 g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE_REGISTRY (self));
490 g_return_if_fail (unique_id != NULL);
491 g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
492
493 priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (self);
494
495 dispatch_data = g_new (gpointer, 3);
496 dispatch_data[0] = g_object_ref (self);
497 dispatch_data[1] = callback;
498 dispatch_data[2] = user_data;
499
500 egg_zeitgeist_data_source_registry_set_data_source_enabled (
501 priv->registry,
502 EGG_DBUS_CALL_FLAGS_NONE,
503 unique_id,
504 enabled,
505 cancellable,
506 dispatch_async_callback,
507 dispatch_data);
508}
509
510void
511zeitgeist_data_source_registry_set_data_source_enabled_finish (
512 ZeitgeistDataSourceRegistry *self,
513 GAsyncResult *res,
514 GError **error)
515{
516 ZeitgeistDataSourceRegistryPrivate *priv;
517
518 g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE_REGISTRY (self));
519
520 priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (self);
521
522 egg_zeitgeist_data_source_registry_set_data_source_enabled_finish (
523 priv->registry,
524 res,
525 error);
526}
527
0528
=== added file 'src/zeitgeist-data-source-registry.h'
--- src/zeitgeist-data-source-registry.h 1970-01-01 00:00:00 +0000
+++ src/zeitgeist-data-source-registry.h 2010-07-23 10:53:43 +0000
@@ -0,0 +1,108 @@
1/*
2 * Copyright (C) 2010 Canonical, Ltd.
3 *
4 * This library is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License
6 * version 3.0 as published by the Free Software Foundation.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License version 3.0 for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library. If not, see
15 * <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Michal Hruby <michal.mhr@gmail.com>
18 */
19
20#if !defined (_ZEITGEIST_H_INSIDE_) && !defined (ZEITGEIST_COMPILATION)
21#error "Only <zeitgeist.h> can be included directly."
22#endif
23
24#ifndef _ZEITGEIST_DATA_SOURCE_REGISTRY_H_
25#define _ZEITGEIST_DATA_SOURCE_REGISTRY_H_
26
27#include <glib.h>
28#include <glib-object.h>
29#include <gio/gio.h>
30#include <zeitgeist-event.h>
31#include <zeitgeist-enums.h>
32#include <zeitgeist-data-source.h>
33
34G_BEGIN_DECLS
35
36#define ZEITGEIST_TYPE_DATA_SOURCE_REGISTRY (zeitgeist_data_source_registry_get_type())
37#define ZEITGEIST_DATA_SOURCE_REGISTRY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZEITGEIST_TYPE_DATA_SOURCE_REGISTRY, ZeitgeistDataSourceRegistry))
38#define ZEITGEIST_DATA_SOURCE_REGISTRY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZEITGEIST_TYPE_DATA_SOURCE_REGISTRY, ZeitgeistDataSourceRegistryClass))
39#define ZEITGEIST_DATA_SOURCE_REGISTRY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZEITGEIST_TYPE_DATA_SOURCE_REGISTRY, ZeitgeistDataSourceRegistryClass))
40#define ZEITGEIST_IS_DATA_SOURCE_REGISTRY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZEITGEIST_TYPE_DATA_SOURCE_REGISTRY))
41#define ZEITGEIST_IS_DATA_SOURCE_REGISTRY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZEITGEIST_TYPE_DATA_SOURCE_REGISTRY))
42
43typedef struct _ZeitgeistDataSourceRegistry ZeitgeistDataSourceRegistry;
44typedef struct _ZeitgeistDataSourceRegistryClass ZeitgeistDataSourceRegistryClass;
45
46struct _ZeitgeistDataSourceRegistryClass
47{
48 GObjectClass parent_class;
49
50 void (*source_registered) (ZeitgeistDataSourceRegistry *registry,
51 ZeitgeistDataSource *source);
52 void (*source_disconnected) (ZeitgeistDataSourceRegistry *registry,
53 ZeitgeistDataSource *source);
54 void (*source_enabled) (ZeitgeistDataSourceRegistry *registry,
55 gchar *unique_id,
56 gboolean enabled);
57};
58
59
60struct _ZeitgeistDataSourceRegistry
61{
62 GObject parent_instance;
63};
64
65GType zeitgeist_data_source_registry_get_type (void);
66
67ZeitgeistDataSourceRegistry* zeitgeist_data_source_registry_new (void);
68
69void zeitgeist_data_source_registry_get_data_sources (
70 ZeitgeistDataSourceRegistry *self,
71 GCancellable *cancellable,
72 GAsyncReadyCallback callback,
73 gpointer user_data);
74
75GPtrArray* zeitgeist_data_source_registry_get_data_sources_finish (
76 ZeitgeistDataSourceRegistry *self,
77 GAsyncResult *res,
78 GError **error);
79
80void zeitgeist_data_source_registry_register_data_source (
81 ZeitgeistDataSourceRegistry *self,
82 ZeitgeistDataSource *source,
83 GCancellable *cancellable,
84 GAsyncReadyCallback callback,
85 gpointer user_data);
86
87gboolean zeitgeist_data_source_registry_register_data_source_finish (
88 ZeitgeistDataSourceRegistry *self,
89 GAsyncResult *res,
90 GError **error);
91
92void zeitgeist_data_source_registry_set_data_source_enabled (
93 ZeitgeistDataSourceRegistry *self,
94 const gchar *unique_id,
95 gboolean enabled,
96 GCancellable *cancellable,
97 GAsyncReadyCallback callback,
98 gpointer user_data);
99
100void zeitgeist_data_source_registry_set_data_source_enabled_finish (
101 ZeitgeistDataSourceRegistry *self,
102 GAsyncResult *res,
103 GError **error);
104
105G_END_DECLS
106
107#endif /* _ZEITGEIST_DATA_SOURCE_REGISTRY_H_ */
108
0109
=== added file 'src/zeitgeist-data-source.c'
--- src/zeitgeist-data-source.c 1970-01-01 00:00:00 +0000
+++ src/zeitgeist-data-source.c 2010-07-23 10:53:43 +0000
@@ -0,0 +1,349 @@
1/*
2 * Copyright (C) 2010 Canonical, Ltd.
3 *
4 * This library is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License
6 * version 3.0 as published by the Free Software Foundation.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License version 3.0 for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library. If not, see
15 * <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Michal Hruby <michal.mhr@gmail.com>
18 */
19
20/**
21 * SECTION:zeitgeist-data-source
22 * @short_description: Abstracts data sources used by
23 * the #ZeitgeistDataSourceRegistry extension
24 * @include: zeitgeist.h
25 *
26 * #ZeitgeistDataSource represents a data source used to insert events into
27 * Zeitgeist. The data sources are identified using the unique_id property,
28 * and when querying the data source registry you get other interesting
29 * information like timestamp of the last action of the data source, flag
30 * whether it is currently running etc.
31 */
32#if HAVE_CONFIG_H
33#include <config.h>
34#endif
35
36#include "zeitgeist-data-source.h"
37
38G_DEFINE_TYPE (ZeitgeistDataSource, zeitgeist_data_source, G_TYPE_INITIALLY_UNOWNED);
39#define ZEITGEIST_DATA_SOURCE_GET_PRIVATE(obj) \
40 (G_TYPE_INSTANCE_GET_PRIVATE(obj, ZEITGEIST_TYPE_DATA_SOURCE, ZeitgeistDataSourcePrivate))
41
42typedef struct
43{
44 gchar *unique_id;
45 gchar *name;
46 gchar *description;
47 GPtrArray *templates;
48 gboolean running;
49 gint64 timestamp;
50 gboolean enabled;
51} ZeitgeistDataSourcePrivate;
52
53/**
54 * zeitgeist_data_source_new:
55 *
56 * Create a new empty data source structure.
57 *
58 * Returns: A new instance of #ZeitgeistDataSource. The returned src will
59 * have a floating reference which will be consumed if you pass the
60 * data source to any of the methods provided by this library (like
61 * registering the data source). If you do not do that then you
62 * must free the data source youself with g_object_unref().
63 */
64ZeitgeistDataSource*
65zeitgeist_data_source_new (void)
66{
67 return g_object_new (ZEITGEIST_TYPE_DATA_SOURCE, NULL);
68}
69/**
70 * zeitgeist_data_source_new_full:
71 * @id: Unique ID for the data source.
72 * @name: Name of the data source (may be translated).
73 * @desc: Data source description.
74 * @event_templates: A #GPtrArray of #ZeitgeistEvent<!-- -->s. This parameter
75 * is optional and purely informational to let data-source
76 * management applications and other data-sources know what
77 * sort of information the data source logs.
78 * The data source will assume ownership of the events and
79 * the pointer array.
80 * If you want to keep a reference for yourself you must do a
81 * g_ptr_array_ref() on @event_templates as well as reffing
82 * the events held by it before calling this method.
83 *
84 * Creates a new instance of DataSource with the given ID, name and
85 * description.
86 *
87 * Returns: New instance of #ZeitgeistDataSource with floating reference,
88 * if you do not pass the instance to method like
89 * zeitgeist_data_source_registry_register_data_source(), then you
90 * have to free the data source yourself using g_object_unref().
91 */
92ZeitgeistDataSource*
93zeitgeist_data_source_new_full (const gchar *id,
94 const gchar *name,
95 const gchar *desc,
96 GPtrArray *templates)
97{
98 ZeitgeistDataSource* src = zeitgeist_data_source_new ();
99
100 zeitgeist_data_source_set_unique_id (src, id);
101 zeitgeist_data_source_set_name (src, name);
102 zeitgeist_data_source_set_description (src, desc);
103 zeitgeist_data_source_set_event_templates (src, templates);
104
105 return src;
106}
107
108const gchar*
109zeitgeist_data_source_get_unique_id (ZeitgeistDataSource *src)
110{
111 ZeitgeistDataSourcePrivate *priv;
112 g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE (src), NULL);
113
114 priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src);
115
116 return priv->unique_id;
117}
118
119void
120zeitgeist_data_source_set_unique_id (ZeitgeistDataSource *src,
121 const gchar* unique_id)
122{
123 ZeitgeistDataSourcePrivate *priv;
124 g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE (src));
125
126 priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src);
127
128 if (priv->unique_id)
129 {
130 g_free (priv->unique_id);
131 }
132
133 priv->unique_id = g_strdup (unique_id);
134}
135
136const gchar*
137zeitgeist_data_source_get_name (ZeitgeistDataSource *src)
138{
139 ZeitgeistDataSourcePrivate *priv;
140 g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE (src), NULL);
141
142 priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src);
143
144 return priv->name;
145}
146
147void
148zeitgeist_data_source_set_name (ZeitgeistDataSource *src,
149 const gchar *name)
150{
151 ZeitgeistDataSourcePrivate *priv;
152 g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE (src));
153
154 priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src);
155
156 if (priv->name)
157 {
158 g_free (priv->name);
159 }
160
161 priv->name = g_strdup (name);
162}
163
164const gchar*
165zeitgeist_data_source_get_description (ZeitgeistDataSource *src)
166{
167 ZeitgeistDataSourcePrivate *priv;
168 g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE (src), NULL);
169
170 priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src);
171
172 return priv->description;
173}
174
175void
176zeitgeist_data_source_set_description (ZeitgeistDataSource *src,
177 const gchar *description)
178{
179 ZeitgeistDataSourcePrivate *priv;
180 g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE (src));
181
182 priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src);
183
184 if (priv->description)
185 {
186 g_free (priv->description);
187 }
188
189 priv->description = g_strdup (description);
190}
191
192GPtrArray*
193zeitgeist_data_source_get_event_templates (ZeitgeistDataSource *src)
194{
195 ZeitgeistDataSourcePrivate *priv;
196 g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE (src), NULL);
197
198 priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src);
199
200 return priv->templates;
201}
202
203/**
204 * zeitgeist_data_source_set_event_templates:
205 * @src: Instance of #ZeitgeistDataSource.
206 * @event_templates: A #GPtrArray which contains elements of type
207 * #ZeitgeistEvent.
208 * The data source will assume ownership of the events and
209 * the pointer array.
210 * If you want to keep a reference for yourself you must do a
211 * g_ptr_array_ref() on @templates as well as reffing
212 * the events held by it before calling this method.
213 *
214 * Sets event templates which are logged by this #ZeitgeistDataSource
215 * instance.
216 */
217void
218zeitgeist_data_source_set_event_templates (ZeitgeistDataSource *src,
219 GPtrArray *event_templates)
220{
221 ZeitgeistDataSourcePrivate *priv;
222 g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE (src));
223
224 priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src);
225
226 if (priv->templates)
227 {
228 g_ptr_array_unref (priv->templates);
229 }
230
231 if (event_templates)
232 {
233 g_ptr_array_foreach (event_templates, (GFunc) g_object_ref_sink, NULL);
234 g_ptr_array_set_free_func (event_templates, g_object_unref);
235 }
236
237 priv->templates = event_templates;
238}
239
240gboolean
241zeitgeist_data_source_is_running (ZeitgeistDataSource *src)
242{
243 ZeitgeistDataSourcePrivate *priv;
244 g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE (src), FALSE);
245
246 priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src);
247
248 return priv->running;
249}
250
251void
252zeitgeist_data_source_set_running (ZeitgeistDataSource *src,
253 gboolean running)
254{
255 ZeitgeistDataSourcePrivate *priv;
256 g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE (src));
257
258 priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src);
259
260 priv->running = running;
261}
262
263gint64
264zeitgeist_data_source_get_timestamp (ZeitgeistDataSource *src)
265{
266 ZeitgeistDataSourcePrivate *priv;
267 g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE (src), 0);
268
269 priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src);
270
271 return priv->timestamp;
272}
273
274void
275zeitgeist_data_source_set_timestamp (ZeitgeistDataSource *src,
276 gint64 timestamp)
277{
278 ZeitgeistDataSourcePrivate *priv;
279 g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE (src));
280
281 priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src);
282
283 priv->timestamp = timestamp;
284}
285
286gboolean
287zeitgeist_data_source_is_enabled (ZeitgeistDataSource *src)
288{
289 ZeitgeistDataSourcePrivate *priv;
290 g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE (src), FALSE);
291
292 priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src);
293
294 return priv->enabled;
295}
296
297void
298zeitgeist_data_source_set_enabled (ZeitgeistDataSource *src,
299 gboolean enabled)
300{
301 ZeitgeistDataSourcePrivate *priv;
302 g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE (src));
303
304 priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src);
305
306 priv->enabled = enabled;
307}
308
309static void
310zeitgeist_data_source_init (ZeitgeistDataSource *object)
311{
312 ZeitgeistDataSourcePrivate *priv;
313
314 priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (object);
315 priv->unique_id = NULL;
316 priv->name = NULL;
317 priv->description = NULL;
318 priv->templates = NULL;
319 priv->running = FALSE;
320 priv->timestamp = 0;
321 priv->enabled = TRUE;
322}
323
324static void
325zeitgeist_data_source_finalize (GObject *object)
326{
327 ZeitgeistDataSource *src = ZEITGEIST_DATA_SOURCE (object);
328 ZeitgeistDataSourcePrivate *priv;
329
330 priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src);
331
332 zeitgeist_data_source_set_unique_id (src, NULL);
333 zeitgeist_data_source_set_name (src, NULL);
334 zeitgeist_data_source_set_description (src, NULL);
335 zeitgeist_data_source_set_event_templates (src, NULL);
336
337 G_OBJECT_CLASS (zeitgeist_data_source_parent_class)->finalize (object);
338}
339
340static void
341zeitgeist_data_source_class_init (ZeitgeistDataSourceClass *klass)
342{
343 GObjectClass* object_class = G_OBJECT_CLASS (klass);
344
345 object_class->finalize = zeitgeist_data_source_finalize;
346
347 g_type_class_add_private (object_class, sizeof (ZeitgeistDataSourcePrivate));
348}
349
0350
=== added file 'src/zeitgeist-data-source.h'
--- src/zeitgeist-data-source.h 1970-01-01 00:00:00 +0000
+++ src/zeitgeist-data-source.h 2010-07-23 10:53:43 +0000
@@ -0,0 +1,101 @@
1/*
2 * Copyright (C) 2010 Canonical, Ltd.
3 *
4 * This library is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License
6 * version 3.0 as published by the Free Software Foundation.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License version 3.0 for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library. If not, see
15 * <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Michal Hruby <michal.mhr@gmail.com>
18 */
19
20#if !defined (_ZEITGEIST_H_INSIDE_) && !defined (ZEITGEIST_COMPILATION)
21#error "Only <zeitgeist.h> can be included directly."
22#endif
23
24#ifndef _ZEITGEIST_DATA_SOURCE_H_
25#define _ZEITGEIST_DATA_SOURCE_H_
26
27#include <glib.h>
28#include <glib-object.h>
29
30G_BEGIN_DECLS
31
32#define ZEITGEIST_TYPE_DATA_SOURCE (zeitgeist_data_source_get_type ())
33
34#define ZEITGEIST_DATA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
35 ZEITGEIST_TYPE_DATA_SOURCE, ZeitgeistDataSource))
36
37#define ZEITGEIST_DATA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
38 ZEITGEIST_TYPE_DATA_SOURCE, ZeitgeistDataSourceClass))
39
40#define ZEITGEIST_IS_DATA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
41 ZEITGEIST_TYPE_DATA_SOURCE))
42
43#define ZEITGEIST_IS_DATA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
44 ZEITGEIST_TYPE_DATA_SOURCE))
45
46#define ZEITGEIST_DATA_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
47 ZEITGEIST_TYPE_DATA_SOURCE, ZeitgeistDataSourceClass))
48
49typedef struct _ZeitgeistDataSource ZeitgeistDataSource;
50typedef struct _ZeitgeistDataSourceClass ZeitgeistDataSourceClass;
51
52struct _ZeitgeistDataSourceClass
53{
54 GInitiallyUnownedClass parent_class;
55};
56
57
58struct _ZeitgeistDataSource
59{
60 GInitiallyUnowned parent_instance;
61};
62
63GType zeitgeist_data_source_get_type (void);
64
65ZeitgeistDataSource* zeitgeist_data_source_new (void);
66ZeitgeistDataSource* zeitgeist_data_source_new_full (const gchar *id,
67 const gchar *name,
68 const gchar *desc,
69 GPtrArray *event_templates);
70
71const gchar* zeitgeist_data_source_get_unique_id (ZeitgeistDataSource *src);
72void zeitgeist_data_source_set_unique_id (ZeitgeistDataSource *src,
73 const gchar* unique_id);
74
75const gchar* zeitgeist_data_source_get_name (ZeitgeistDataSource *src);
76void zeitgeist_data_source_set_name (ZeitgeistDataSource *src,
77 const gchar *name);
78
79const gchar* zeitgeist_data_source_get_description (ZeitgeistDataSource *src);
80void zeitgeist_data_source_set_description (ZeitgeistDataSource *src,
81 const gchar *description);
82
83GPtrArray* zeitgeist_data_source_get_event_templates (ZeitgeistDataSource *src);
84void zeitgeist_data_source_set_event_templates (ZeitgeistDataSource *src,
85 GPtrArray *event_templates);
86
87gboolean zeitgeist_data_source_is_running (ZeitgeistDataSource *src);
88void zeitgeist_data_source_set_running (ZeitgeistDataSource *src,
89 gboolean running);
90
91gint64 zeitgeist_data_source_get_timestamp (ZeitgeistDataSource *src);
92void zeitgeist_data_source_set_timestamp (ZeitgeistDataSource *src,
93 gint64 timestamp);
94
95gboolean zeitgeist_data_source_is_enabled (ZeitgeistDataSource *src);
96void zeitgeist_data_source_set_enabled (ZeitgeistDataSource *src,
97 gboolean enabled);
98
99G_END_DECLS
100
101#endif /* _ZEITGEIST_DATA_SOURCE_H_ */
0102
=== modified file 'src/zeitgeist-eggdbusconversions.c'
--- src/zeitgeist-eggdbusconversions.c 2010-05-09 00:13:04 +0000
+++ src/zeitgeist-eggdbusconversions.c 2010-07-23 10:53:43 +0000
@@ -298,3 +298,54 @@
298298
299 return result;299 return result;
300}300}
301
302ZeitgeistDataSource*
303_egg_zeitgeist_data_source_to_zeitgeist_data_source (EggZeitgeistDataSource *data_source)
304{
305 ZeitgeistDataSource *result;
306 GPtrArray *templates;
307 gboolean running;
308 gboolean enabled;
309 gint64 timestamp;
310
311 g_return_val_if_fail (EGG_ZEITGEIST_IS_DATA_SOURCE (data_source), NULL);
312
313 templates = _egg_zeitgeist_events_to_zeitgeist_events (egg_zeitgeist_data_source_get_event_templates (data_source));
314
315 result = zeitgeist_data_source_new_full (
316 egg_zeitgeist_data_source_get_unique_id (data_source),
317 egg_zeitgeist_data_source_get_name (data_source),
318 egg_zeitgeist_data_source_get_description (data_source),
319 templates);
320
321 running = egg_zeitgeist_data_source_get_running (data_source);
322 enabled = egg_zeitgeist_data_source_get_enabled (data_source);
323 timestamp = egg_zeitgeist_data_source_get_last_seen (data_source);
324
325 zeitgeist_data_source_set_running (result, running);
326 zeitgeist_data_source_set_timestamp (result, timestamp);
327 zeitgeist_data_source_set_enabled (result, enabled);
328
329 return result;
330}
331
332GPtrArray*
333_egg_zeitgeist_data_sources_to_zeitgeist_data_sources (EggDBusArraySeq *data_sources)
334{
335 GPtrArray *result;
336 EggZeitgeistDataSource *source;
337 gint i, num_sources;
338
339 g_return_val_if_fail (EGG_DBUS_IS_ARRAY_SEQ (data_sources), NULL);
340
341 num_sources = egg_dbus_array_seq_get_size (data_sources);
342 result = g_ptr_array_sized_new (num_sources);
343 for (i = 0; i < num_sources; i++)
344 {
345 source = EGG_ZEITGEIST_DATA_SOURCE (egg_dbus_array_seq_get (data_sources, i));
346 g_ptr_array_add (result, _egg_zeitgeist_data_source_to_zeitgeist_data_source (source));
347 }
348
349 return result;
350}
351
301352
=== modified file 'src/zeitgeist-eggdbusconversions.h'
--- src/zeitgeist-eggdbusconversions.h 2010-04-19 14:58:18 +0000
+++ src/zeitgeist-eggdbusconversions.h 2010-07-23 10:53:43 +0000
@@ -22,8 +22,10 @@
22#define _ZEITGEIST_EGGDBUSCONVERSIONS_H_22#define _ZEITGEIST_EGGDBUSCONVERSIONS_H_
2323
24#include <glib-object.h>24#include <glib-object.h>
25#include "zeitgeist-data-source.h"
25#include "zeitgeist-event.h"26#include "zeitgeist-event.h"
26#include "zeitgeist-timerange.h"27#include "zeitgeist-timerange.h"
28#include "eggzeitgeistdatasource.h"
27#include "eggzeitgeistevent.h"29#include "eggzeitgeistevent.h"
28#include "eggzeitgeisttimerange.h"30#include "eggzeitgeisttimerange.h"
29#include "eggzeitgeisteventdataoffset.h"31#include "eggzeitgeisteventdataoffset.h"
@@ -40,12 +42,16 @@
4042
41EggDBusArraySeq* _zeitgeist_events_to_egg_zeitgeist_events (GPtrArray *events);43EggDBusArraySeq* _zeitgeist_events_to_egg_zeitgeist_events (GPtrArray *events);
4244
43GPtrArray* _zeitgeist_events_from_valist (va_list events);45GPtrArray* _zeitgeist_events_from_valist (va_list events);
4446
45EggZeitgeistTimeRange* _zeitgeist_time_range_to_egg_zeitgeist_time_range (ZeitgeistTimeRange *time_range);47EggZeitgeistTimeRange* _zeitgeist_time_range_to_egg_zeitgeist_time_range (ZeitgeistTimeRange *time_range);
4648
47ZeitgeistTimeRange* _egg_zeitgeist_time_range_to_zeitgeist_time_range (EggZeitgeistTimeRange *time_range);49ZeitgeistTimeRange* _egg_zeitgeist_time_range_to_zeitgeist_time_range (EggZeitgeistTimeRange *time_range);
4850
51ZeitgeistDataSource* _egg_zeitgeist_data_source_to_zeitgeist_data_source (EggZeitgeistDataSource *data_source);
52
53GPtrArray* _egg_zeitgeist_data_sources_to_zeitgeist_data_sources (EggDBusArraySeq *data_sources);
54
49G_END_DECLS55G_END_DECLS
5056
51#endif /* _ZEITGEIST_EGGDBUSCONVERSIONS_H_ */
52\ No newline at end of file57\ No newline at end of file
58#endif /* _ZEITGEIST_EGGDBUSCONVERSIONS_H_ */
5359
=== modified file 'src/zeitgeist.h'
--- src/zeitgeist.h 2010-06-16 13:32:40 +0000
+++ src/zeitgeist.h 2010-07-23 10:53:43 +0000
@@ -23,6 +23,8 @@
2323
24#define _ZEITGEIST_H_INSIDE_24#define _ZEITGEIST_H_INSIDE_
2525
26#include <zeitgeist-data-source.h>
27#include <zeitgeist-data-source-registry.h>
26#include <zeitgeist-enums.h>28#include <zeitgeist-enums.h>
27#include <zeitgeist-enumtypes.h>29#include <zeitgeist-enumtypes.h>
28#include <zeitgeist-event.h>30#include <zeitgeist-event.h>
@@ -39,4 +41,4 @@
3941
40#undef _ZEITGEIST_H_INSIDE_42#undef _ZEITGEIST_H_INSIDE_
4143
42#endif /* _ZEITGEIST_H_ */
43\ No newline at end of file44\ No newline at end of file
45#endif /* _ZEITGEIST_H_ */
4446
=== modified file 'tests/Makefile.am'
--- tests/Makefile.am 2010-06-17 11:26:15 +0000
+++ tests/Makefile.am 2010-07-23 10:53:43 +0000
@@ -18,6 +18,8 @@
18 test.desktop18 test.desktop
1919
20helper_sources = \20helper_sources = \
21 $(top_srcdir)/src/eggzeitgeistdatasource.c \
22 $(top_srcdir)/src/eggzeitgeistdatasource.h \
21 $(top_srcdir)/src/eggzeitgeistevent.c \23 $(top_srcdir)/src/eggzeitgeistevent.c \
22 $(top_srcdir)/src/eggzeitgeistevent.h \24 $(top_srcdir)/src/eggzeitgeistevent.h \
23 $(top_srcdir)/src/eggzeitgeisttimerange.c \25 $(top_srcdir)/src/eggzeitgeisttimerange.c \
2426
=== modified file 'tests/test-eggdbusconversions.c'
--- tests/test-eggdbusconversions.c 2010-05-04 16:55:56 +0000
+++ tests/test-eggdbusconversions.c 2010-07-23 10:53:43 +0000
@@ -19,9 +19,11 @@
1919
20#include <glib.h>20#include <glib.h>
21#include <glib-object.h>21#include <glib-object.h>
22#include "zeitgeist-data-source.h"
22#include "zeitgeist-event.h"23#include "zeitgeist-event.h"
23#include "zeitgeist-subject.h"24#include "zeitgeist-subject.h"
24#include "zeitgeist-eggdbusconversions.h"25#include "zeitgeist-eggdbusconversions.h"
26#include "zeitgeist-timestamp.h"
2527
26typedef struct28typedef struct
27{29{
@@ -410,6 +412,74 @@
410}412}
411413
412static void414static void
415test_egg_to_z_ds_empty (Fixture *fix, gconstpointer data)
416{
417 ZeitgeistDataSource *zds;
418 EggZeitgeistDataSource *eggds;
419 EggDBusArraySeq *templates;
420
421 templates = egg_dbus_array_seq_new (EGG_ZEITGEIST_TYPE_DATA_SOURCE,
422 g_object_unref,
423 NULL,
424 NULL);
425
426 eggds = egg_zeitgeist_data_source_new ("", "", "", templates,
427 FALSE, 0, FALSE);
428
429 zds = _egg_zeitgeist_data_source_to_zeitgeist_data_source (eggds);
430
431 /* We unref the eggds here to assert that we have completely separated
432 * the memory of the converted data source */
433 g_object_unref (eggds);
434 g_object_unref (templates);
435
436 g_assert_cmpstr ("", ==, zeitgeist_data_source_get_unique_id (zds));
437 g_assert_cmpstr ("", ==, zeitgeist_data_source_get_name (zds));
438 g_assert_cmpstr ("", ==, zeitgeist_data_source_get_description (zds));
439 g_assert_cmpint (0, ==, zeitgeist_data_source_is_running (zds));
440 g_assert_cmpint (0, ==, zeitgeist_data_source_is_enabled (zds));
441 g_assert_cmpint (0, ==, zeitgeist_data_source_get_timestamp (zds));
442
443 g_object_unref (zds);
444}
445
446static void
447test_egg_to_z_ds_full (Fixture *fix, gconstpointer data)
448{
449 ZeitgeistDataSource *zds;
450 EggZeitgeistDataSource *eggds;
451 EggDBusArraySeq *templates;
452 gint64 timestamp;
453
454 templates = egg_dbus_array_seq_new (EGG_ZEITGEIST_TYPE_DATA_SOURCE,
455 g_object_unref,
456 NULL,
457 NULL);
458 timestamp = zeitgeist_timestamp_for_now ();
459
460 eggds = egg_zeitgeist_data_source_new ("id", "name", "desc", templates,
461 FALSE,
462 timestamp,
463 TRUE);
464
465 zds = _egg_zeitgeist_data_source_to_zeitgeist_data_source (eggds);
466
467 /* We unref the eggds here to assert that we have completely separated
468 * the memory of the converted data source */
469 g_object_unref (eggds);
470 g_object_unref (templates);
471
472 g_assert_cmpstr ("id", ==, zeitgeist_data_source_get_unique_id (zds));
473 g_assert_cmpstr ("name", ==, zeitgeist_data_source_get_name (zds));
474 g_assert_cmpstr ("desc", ==, zeitgeist_data_source_get_description (zds));
475 g_assert_cmpint (0, ==, zeitgeist_data_source_is_running (zds));
476 g_assert_cmpint (0, !=, zeitgeist_data_source_is_enabled (zds));
477 g_assert_cmpint (timestamp, ==, zeitgeist_data_source_get_timestamp (zds));
478
479 g_object_unref (zds);
480}
481
482static void
413test_timestamp (Fixture *fix, gconstpointer data)483test_timestamp (Fixture *fix, gconstpointer data)
414{484{
415 ZeitgeistEvent *zev;485 ZeitgeistEvent *zev;
@@ -469,8 +539,14 @@
469 g_test_add ("/Zeitgeist/EggDBusConversions/EggToZEmpty", Fixture, NULL,539 g_test_add ("/Zeitgeist/EggDBusConversions/EggToZEmpty", Fixture, NULL,
470 setup, test_egg_to_z_empty, teardown);540 setup, test_egg_to_z_empty, teardown);
471541
542 g_test_add ("/Zeitgeist/EggDBusConversions/EggToZDSFull", Fixture, NULL,
543 setup, test_egg_to_z_ds_full, teardown);
544
545 g_test_add ("/Zeitgeist/EggDBusConversions/EggToZDSEmpty", Fixture, NULL,
546 setup, test_egg_to_z_ds_empty, teardown);
547
472 g_test_add ("/Zeitgeist/EggDBusConversions/Timestamp", Fixture, NULL,548 g_test_add ("/Zeitgeist/EggDBusConversions/Timestamp", Fixture, NULL,
473 setup, test_timestamp, teardown);549 setup, test_timestamp, teardown);
474 550
475 return g_test_run();551 return g_test_run();
476}
477\ No newline at end of file552\ No newline at end of file
553}

Subscribers

People subscribed via source and target branches