Merge lp:~mhr3/libzeitgeist/data-source-registry into lp:libzeitgeist
- data-source-registry
- Merge into trunk
Proposed by
Michal Hruby
Status: | Superseded |
---|---|
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mikkel Kamstrup Erlandsen | Needs Fixing | ||
Review via email: mp+30624@code.launchpad.net |
This proposal has been superseded by a proposal from 2010-07-23.
Commit message
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 : | # |
review:
Needs Fixing
- 149. By Michal Hruby
-
Fixes for a couple of issues brought up during merge review
- 150. By Michal Hruby
-
Add some more documentation
- 151. By Michal Hruby
-
Added conversion tests
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'bindings/zeitgeist-1.0.gi' |
2 | --- bindings/zeitgeist-1.0.gi 2010-06-17 14:11:59 +0000 |
3 | +++ bindings/zeitgeist-1.0.gi 2010-07-23 10:53:42 +0000 |
4 | @@ -101,6 +101,192 @@ |
5 | <member name="ZEITGEIST_STORAGE_STATE_AVAILABLE" value="1"/> |
6 | <member name="ZEITGEIST_STORAGE_STATE_ANY" value="2"/> |
7 | </enum> |
8 | + <object name="ZeitgeistDataSource" parent="GInitiallyUnowned" type-name="ZeitgeistDataSource" get-type="zeitgeist_data_source_get_type"> |
9 | + <method name="get_description" symbol="zeitgeist_data_source_get_description"> |
10 | + <return-type type="gchar*"/> |
11 | + <parameters> |
12 | + <parameter name="src" type="ZeitgeistDataSource*"/> |
13 | + </parameters> |
14 | + </method> |
15 | + <method name="get_enabled" symbol="zeitgeist_data_source_get_enabled"> |
16 | + <return-type type="gboolean"/> |
17 | + <parameters> |
18 | + <parameter name="src" type="ZeitgeistDataSource*"/> |
19 | + </parameters> |
20 | + </method> |
21 | + <method name="get_event_templates" symbol="zeitgeist_data_source_get_event_templates"> |
22 | + <return-type type="GPtrArray*"/> |
23 | + <parameters> |
24 | + <parameter name="src" type="ZeitgeistDataSource*"/> |
25 | + </parameters> |
26 | + </method> |
27 | + <method name="get_name" symbol="zeitgeist_data_source_get_name"> |
28 | + <return-type type="gchar*"/> |
29 | + <parameters> |
30 | + <parameter name="src" type="ZeitgeistDataSource*"/> |
31 | + </parameters> |
32 | + </method> |
33 | + <method name="get_running" symbol="zeitgeist_data_source_get_running"> |
34 | + <return-type type="gboolean"/> |
35 | + <parameters> |
36 | + <parameter name="src" type="ZeitgeistDataSource*"/> |
37 | + </parameters> |
38 | + </method> |
39 | + <method name="get_timestamp" symbol="zeitgeist_data_source_get_timestamp"> |
40 | + <return-type type="gint64"/> |
41 | + <parameters> |
42 | + <parameter name="src" type="ZeitgeistDataSource*"/> |
43 | + </parameters> |
44 | + </method> |
45 | + <method name="get_unique_id" symbol="zeitgeist_data_source_get_unique_id"> |
46 | + <return-type type="gchar*"/> |
47 | + <parameters> |
48 | + <parameter name="src" type="ZeitgeistDataSource*"/> |
49 | + </parameters> |
50 | + </method> |
51 | + <constructor name="new" symbol="zeitgeist_data_source_new"> |
52 | + <return-type type="ZeitgeistDataSource*"/> |
53 | + </constructor> |
54 | + <constructor name="new_full" symbol="zeitgeist_data_source_new_full"> |
55 | + <return-type type="ZeitgeistDataSource*"/> |
56 | + <parameters> |
57 | + <parameter name="id" type="gchar*"/> |
58 | + <parameter name="name" type="gchar*"/> |
59 | + <parameter name="desc" type="gchar*"/> |
60 | + <parameter name="event_templates" type="GPtrArray*"/> |
61 | + </parameters> |
62 | + </constructor> |
63 | + <method name="set_description" symbol="zeitgeist_data_source_set_description"> |
64 | + <return-type type="void"/> |
65 | + <parameters> |
66 | + <parameter name="src" type="ZeitgeistDataSource*"/> |
67 | + <parameter name="description" type="gchar*"/> |
68 | + </parameters> |
69 | + </method> |
70 | + <method name="set_enabled" symbol="zeitgeist_data_source_set_enabled"> |
71 | + <return-type type="void"/> |
72 | + <parameters> |
73 | + <parameter name="src" type="ZeitgeistDataSource*"/> |
74 | + <parameter name="enabled" type="gboolean"/> |
75 | + </parameters> |
76 | + </method> |
77 | + <method name="set_event_templates" symbol="zeitgeist_data_source_set_event_templates"> |
78 | + <return-type type="void"/> |
79 | + <parameters> |
80 | + <parameter name="src" type="ZeitgeistDataSource*"/> |
81 | + <parameter name="event_templates" type="GPtrArray*"/> |
82 | + </parameters> |
83 | + </method> |
84 | + <method name="set_name" symbol="zeitgeist_data_source_set_name"> |
85 | + <return-type type="void"/> |
86 | + <parameters> |
87 | + <parameter name="src" type="ZeitgeistDataSource*"/> |
88 | + <parameter name="name" type="gchar*"/> |
89 | + </parameters> |
90 | + </method> |
91 | + <method name="set_running" symbol="zeitgeist_data_source_set_running"> |
92 | + <return-type type="void"/> |
93 | + <parameters> |
94 | + <parameter name="src" type="ZeitgeistDataSource*"/> |
95 | + <parameter name="running" type="gboolean"/> |
96 | + </parameters> |
97 | + </method> |
98 | + <method name="set_timestamp" symbol="zeitgeist_data_source_set_timestamp"> |
99 | + <return-type type="void"/> |
100 | + <parameters> |
101 | + <parameter name="src" type="ZeitgeistDataSource*"/> |
102 | + <parameter name="timestamp" type="gint64"/> |
103 | + </parameters> |
104 | + </method> |
105 | + <method name="set_unique_id" symbol="zeitgeist_data_source_set_unique_id"> |
106 | + <return-type type="void"/> |
107 | + <parameters> |
108 | + <parameter name="src" type="ZeitgeistDataSource*"/> |
109 | + <parameter name="unique_id" type="gchar*"/> |
110 | + </parameters> |
111 | + </method> |
112 | + </object> |
113 | + <object name="ZeitgeistDataSourceRegistry" parent="GObject" type-name="ZeitgeistDataSourceRegistry" get-type="zeitgeist_data_source_registry_get_type"> |
114 | + <method name="get_data_sources" symbol="zeitgeist_data_source_registry_get_data_sources"> |
115 | + <return-type type="void"/> |
116 | + <parameters> |
117 | + <parameter name="self" type="ZeitgeistDataSourceRegistry*"/> |
118 | + <parameter name="cancellable" type="GCancellable*"/> |
119 | + <parameter name="callback" type="GAsyncReadyCallback"/> |
120 | + <parameter name="user_data" type="gpointer"/> |
121 | + </parameters> |
122 | + </method> |
123 | + <method name="get_data_sources_finish" symbol="zeitgeist_data_source_registry_get_data_sources_finish"> |
124 | + <return-type type="GPtrArray*"/> |
125 | + <parameters> |
126 | + <parameter name="self" type="ZeitgeistDataSourceRegistry*"/> |
127 | + <parameter name="res" type="GAsyncResult*"/> |
128 | + <parameter name="error" type="GError**"/> |
129 | + </parameters> |
130 | + </method> |
131 | + <constructor name="new" symbol="zeitgeist_data_source_registry_new"> |
132 | + <return-type type="ZeitgeistDataSourceRegistry*"/> |
133 | + </constructor> |
134 | + <method name="register_data_source" symbol="zeitgeist_data_source_registry_register_data_source"> |
135 | + <return-type type="void"/> |
136 | + <parameters> |
137 | + <parameter name="self" type="ZeitgeistDataSourceRegistry*"/> |
138 | + <parameter name="source" type="ZeitgeistDataSource*"/> |
139 | + <parameter name="cancellable" type="GCancellable*"/> |
140 | + <parameter name="callback" type="GAsyncReadyCallback"/> |
141 | + <parameter name="user_data" type="gpointer"/> |
142 | + </parameters> |
143 | + </method> |
144 | + <method name="register_data_source_finish" symbol="zeitgeist_data_source_registry_register_data_source_finish"> |
145 | + <return-type type="gboolean"/> |
146 | + <parameters> |
147 | + <parameter name="self" type="ZeitgeistDataSourceRegistry*"/> |
148 | + <parameter name="res" type="GAsyncResult*"/> |
149 | + <parameter name="error" type="GError**"/> |
150 | + </parameters> |
151 | + </method> |
152 | + <method name="set_data_source_enabled" symbol="zeitgeist_data_source_registry_set_data_source_enabled"> |
153 | + <return-type type="void"/> |
154 | + <parameters> |
155 | + <parameter name="self" type="ZeitgeistDataSourceRegistry*"/> |
156 | + <parameter name="unique_id" type="gchar*"/> |
157 | + <parameter name="enabled" type="gboolean"/> |
158 | + <parameter name="cancellable" type="GCancellable*"/> |
159 | + <parameter name="callback" type="GAsyncReadyCallback"/> |
160 | + <parameter name="user_data" type="gpointer"/> |
161 | + </parameters> |
162 | + </method> |
163 | + <method name="set_data_source_enabled_finish" symbol="zeitgeist_data_source_registry_set_data_source_enabled_finish"> |
164 | + <return-type type="void"/> |
165 | + <parameters> |
166 | + <parameter name="self" type="ZeitgeistDataSourceRegistry*"/> |
167 | + <parameter name="res" type="GAsyncResult*"/> |
168 | + <parameter name="error" type="GError**"/> |
169 | + </parameters> |
170 | + </method> |
171 | + <signal name="source-disconnected" when="FIRST"> |
172 | + <return-type type="void"/> |
173 | + <parameters> |
174 | + <parameter name="registry" type="ZeitgeistDataSourceRegistry*"/> |
175 | + <parameter name="source" type="ZeitgeistDataSource*"/> |
176 | + </parameters> |
177 | + </signal> |
178 | + <signal name="source-enabled" when="FIRST"> |
179 | + <return-type type="void"/> |
180 | + <parameters> |
181 | + <parameter name="registry" type="ZeitgeistDataSourceRegistry*"/> |
182 | + <parameter name="unique_id" type="char*"/> |
183 | + <parameter name="enabled" type="gboolean"/> |
184 | + </parameters> |
185 | + </signal> |
186 | + <signal name="source-registered" when="FIRST"> |
187 | + <return-type type="void"/> |
188 | + <parameters> |
189 | + <parameter name="registry" type="ZeitgeistDataSourceRegistry*"/> |
190 | + <parameter name="source" type="ZeitgeistDataSource*"/> |
191 | + </parameters> |
192 | + </signal> |
193 | + </object> |
194 | <object name="ZeitgeistEvent" parent="GInitiallyUnowned" type-name="ZeitgeistEvent" get-type="zeitgeist_event_get_type"> |
195 | <method name="add_subject" symbol="zeitgeist_event_add_subject"> |
196 | <return-type type="void"/> |
197 | |
198 | === modified file 'bindings/zeitgeist-1.0.metadata' |
199 | --- bindings/zeitgeist-1.0.metadata 2010-06-17 14:11:59 +0000 |
200 | +++ bindings/zeitgeist-1.0.metadata 2010-07-23 10:53:42 +0000 |
201 | @@ -1,5 +1,12 @@ |
202 | Zeitgeist cheader_filename="zeitgeist.h" |
203 | Zeitgeist.Timestamp cheader_filename="zeitgeist.h" |
204 | +zeitgeist_data_source_new_full.event_templates transfer_ownership="1" |
205 | +zeitgeist_data_source_set_event_templates.event_templates transfer_ownership="1" |
206 | +zeitgeist_data_source_registry_get_data_sources async="1" |
207 | +zeitgeist_data_source_registry_get_data_sources_finish transfer_ownership="1" |
208 | +zeitgeist_data_source_registry_register_data_source async="1" |
209 | +zeitgeist_data_source_registry_register_data_source.source transfer_ownership="1" |
210 | +zeitgeist_data_source_registry_set_data_source_enabled async="1" |
211 | zeitgeist_index_search async="1" |
212 | zeitgeist_index_search.event_templates transfer_ownership="1" |
213 | zeitgeist_index_search_finish transfer_ownership="1" |
214 | @@ -33,6 +40,7 @@ |
215 | zeitgeist_event_set_payload.payload transfer_ownership="1" |
216 | zeitgeist_monitor_new.event_templates transfer_ownership="1" |
217 | |
218 | +zeitgeist_data_source_registry_*.cancellable nullable="1" |
219 | zeitgeist_log_*.cancellable nullable="1" |
220 | zeitgeist_index_*.cancellable nullable="1" |
221 | |
222 | |
223 | === modified file 'bindings/zeitgeist-1.0.vapi' |
224 | --- bindings/zeitgeist-1.0.vapi 2010-06-23 09:43:18 +0000 |
225 | +++ bindings/zeitgeist-1.0.vapi 2010-07-23 10:53:42 +0000 |
226 | @@ -38,6 +38,38 @@ |
227 | public static int64 prev_midnight (int64 timestamp); |
228 | } |
229 | [CCode (cheader_filename = "zeitgeist.h")] |
230 | + public class DataSource : GLib.InitiallyUnowned { |
231 | + [CCode (has_construct_function = false)] |
232 | + public DataSource (); |
233 | + [CCode (has_construct_function = false)] |
234 | + public DataSource.full (string id, string name, string desc, owned GLib.PtrArray event_templates); |
235 | + public unowned string get_description (); |
236 | + public bool get_enabled (); |
237 | + public unowned GLib.PtrArray get_event_templates (); |
238 | + public unowned string get_name (); |
239 | + public bool get_running (); |
240 | + public int64 get_timestamp (); |
241 | + public unowned string get_unique_id (); |
242 | + public void set_description (string description); |
243 | + public void set_enabled (bool enabled); |
244 | + public void set_event_templates (owned GLib.PtrArray event_templates); |
245 | + public void set_name (string name); |
246 | + public void set_running (bool running); |
247 | + public void set_timestamp (int64 timestamp); |
248 | + public void set_unique_id (string unique_id); |
249 | + } |
250 | + [CCode (cheader_filename = "zeitgeist.h")] |
251 | + public class DataSourceRegistry : GLib.Object { |
252 | + [CCode (has_construct_function = false)] |
253 | + public DataSourceRegistry (); |
254 | + public async GLib.PtrArray get_data_sources (GLib.Cancellable? cancellable) throws GLib.Error; |
255 | + public async bool register_data_source (owned Zeitgeist.DataSource source, GLib.Cancellable? cancellable) throws GLib.Error; |
256 | + public async void set_data_source_enabled (string unique_id, bool enabled, GLib.Cancellable? cancellable) throws GLib.Error; |
257 | + public virtual signal void source_disconnected (Zeitgeist.DataSource source); |
258 | + public virtual signal void source_enabled (string unique_id, bool enabled); |
259 | + public virtual signal void source_registered (Zeitgeist.DataSource source); |
260 | + } |
261 | + [CCode (cheader_filename = "zeitgeist.h")] |
262 | public class Event : GLib.InitiallyUnowned { |
263 | [CCode (has_construct_function = false)] |
264 | public Event (); |
265 | |
266 | === modified file 'doc/reference/zeitgeist-1.0-docs.sgml' |
267 | --- doc/reference/zeitgeist-1.0-docs.sgml 2010-06-17 09:22:18 +0000 |
268 | +++ doc/reference/zeitgeist-1.0-docs.sgml 2010-07-23 10:53:42 +0000 |
269 | @@ -34,7 +34,9 @@ |
270 | |
271 | <chapter> |
272 | <title>API for Zeitgeist Extensions</title> |
273 | - <xi:include href="xml/zeitgeist-index.xml"/> |
274 | + <xi:include href="xml/zeitgeist-index.xml"/> |
275 | + <xi:include href="xml/zeitgeist-data-source.xml"/> |
276 | + <xi:include href="xml/zeitgeist-data-source-registry.xml"/> |
277 | </chapter> |
278 | |
279 | <chapter id="object-tree"> |
280 | |
281 | === modified file 'doc/reference/zeitgeist-1.0-sections.txt' |
282 | --- doc/reference/zeitgeist-1.0-sections.txt 2010-06-23 09:43:18 +0000 |
283 | +++ doc/reference/zeitgeist-1.0-sections.txt 2010-07-23 10:53:42 +0000 |
284 | @@ -1,63 +1,32 @@ |
285 | <SECTION> |
286 | -<FILE>zeitgeist-timerange</FILE> |
287 | -<TITLE>ZeitgeistTimeRange</TITLE> |
288 | -ZeitgeistTimeRange |
289 | -ZeitgeistTimeRangeClass |
290 | -zeitgeist_time_range_new |
291 | -zeitgeist_time_range_new_from_now |
292 | -zeitgeist_time_range_new_to_now |
293 | -zeitgeist_time_range_new_anytime |
294 | -zeitgeist_time_range_get_start |
295 | -zeitgeist_time_range_get_end |
296 | -zeitgeist_time_range_get_start_iso8601 |
297 | -zeitgeist_time_range_get_end_iso8601 |
298 | -<SUBSECTION Standard> |
299 | -ZEITGEIST_TIME_RANGE |
300 | -ZEITGEIST_IS_TIME_RANGE |
301 | -ZEITGEIST_TYPE_TIME_RANGE |
302 | -zeitgeist_time_range_get_type |
303 | -ZEITGEIST_TIME_RANGE_CLASS |
304 | -ZEITGEIST_IS_TIME_RANGE_CLASS |
305 | -ZEITGEIST_TIME_RANGE_GET_CLASS |
306 | -</SECTION> |
307 | - |
308 | -<SECTION> |
309 | -<FILE>zeitgeist-log</FILE> |
310 | -<TITLE>ZeitgeistLog</TITLE> |
311 | -ZeitgeistLog |
312 | -ZeitgeistLogClass |
313 | -zeitgeist_log_new |
314 | -zeitgeist_log_insert_events |
315 | -zeitgeist_log_insert_events_no_reply |
316 | -zeitgeist_log_insert_events_valist |
317 | -zeitgeist_log_insert_events_from_ptrarray |
318 | -zeitgeist_log_insert_events_finish |
319 | -zeitgeist_log_find_events |
320 | -zeitgeist_log_find_events_finish |
321 | -zeitgeist_log_find_event_ids |
322 | -zeitgeist_log_find_event_ids_finish |
323 | -zeitgeist_log_get_events |
324 | -zeitgeist_log_get_events_finish |
325 | -zeitgeist_log_find_related_uris |
326 | -zeitgeist_log_find_related_uris_finish |
327 | -zeitgeist_log_delete_events |
328 | -zeitgeist_log_delete_events_finish |
329 | -zeitgeist_log_delete_log |
330 | -zeitgeist_log_delete_log_finish |
331 | -zeitgeist_log_quit |
332 | -zeitgeist_log_quit_finish |
333 | -zeitgeist_log_install_monitor |
334 | -zeitgeist_log_install_monitor_finish |
335 | -zeitgeist_log_remove_monitor |
336 | -zeitgeist_log_remove_monitor_finish |
337 | -<SUBSECTION Standard> |
338 | -ZEITGEIST_LOG |
339 | -ZEITGEIST_IS_LOG |
340 | -ZEITGEIST_TYPE_LOG |
341 | -zeitgeist_log_get_type |
342 | -ZEITGEIST_LOG_CLASS |
343 | -ZEITGEIST_IS_LOG_CLASS |
344 | -ZEITGEIST_LOG_GET_CLASS |
345 | +<FILE>zeitgeist-data-source</FILE> |
346 | +<TITLE>ZeitgeistDataSource</TITLE> |
347 | +ZeitgeistDataSource |
348 | +ZeitgeistDataSourceClass |
349 | +zeitgeist_data_source_new |
350 | +zeitgeist_data_source_new_full |
351 | +zeitgeist_data_source_get_unique_id |
352 | +zeitgeist_data_source_set_unique_id |
353 | +zeitgeist_data_source_get_name |
354 | +zeitgeist_data_source_set_name |
355 | +zeitgeist_data_source_get_description |
356 | +zeitgeist_data_source_set_description |
357 | +zeitgeist_data_source_get_event_templates |
358 | +zeitgeist_data_source_set_event_templates |
359 | +zeitgeist_data_source_is_running |
360 | +zeitgeist_data_source_set_running |
361 | +zeitgeist_data_source_get_timestamp |
362 | +zeitgeist_data_source_set_timestamp |
363 | +zeitgeist_data_source_is_enabled |
364 | +zeitgeist_data_source_set_enabled |
365 | +<SUBSECTION Standard> |
366 | +ZEITGEIST_DATA_SOURCE |
367 | +ZEITGEIST_IS_DATA_SOURCE |
368 | +ZEITGEIST_TYPE_DATA_SOURCE |
369 | +zeitgeist_data_source_get_type |
370 | +ZEITGEIST_DATA_SOURCE_CLASS |
371 | +ZEITGEIST_IS_DATA_SOURCE_CLASS |
372 | +ZEITGEIST_DATA_SOURCE_GET_CLASS |
373 | </SECTION> |
374 | |
375 | <SECTION> |
376 | @@ -92,6 +61,67 @@ |
377 | </SECTION> |
378 | |
379 | <SECTION> |
380 | +<FILE>zeitgeist-timerange</FILE> |
381 | +<TITLE>ZeitgeistTimeRange</TITLE> |
382 | +ZeitgeistTimeRange |
383 | +ZeitgeistTimeRangeClass |
384 | +zeitgeist_time_range_new |
385 | +zeitgeist_time_range_new_from_now |
386 | +zeitgeist_time_range_new_to_now |
387 | +zeitgeist_time_range_new_anytime |
388 | +zeitgeist_time_range_get_start |
389 | +zeitgeist_time_range_get_end |
390 | +zeitgeist_time_range_get_start_iso8601 |
391 | +zeitgeist_time_range_get_end_iso8601 |
392 | +<SUBSECTION Standard> |
393 | +ZEITGEIST_TIME_RANGE |
394 | +ZEITGEIST_IS_TIME_RANGE |
395 | +ZEITGEIST_TYPE_TIME_RANGE |
396 | +zeitgeist_time_range_get_type |
397 | +ZEITGEIST_TIME_RANGE_CLASS |
398 | +ZEITGEIST_IS_TIME_RANGE_CLASS |
399 | +ZEITGEIST_TIME_RANGE_GET_CLASS |
400 | +</SECTION> |
401 | + |
402 | +<SECTION> |
403 | +<FILE>zeitgeist-index</FILE> |
404 | +<TITLE>ZeitgeistIndex</TITLE> |
405 | +ZeitgeistIndex |
406 | +ZeitgeistIndexClass |
407 | +zeitgeist_index_new |
408 | +zeitgeist_index_search |
409 | +zeitgeist_index_search_finish |
410 | +<SUBSECTION Standard> |
411 | +ZEITGEIST_INDEX |
412 | +ZEITGEIST_IS_INDEX |
413 | +ZEITGEIST_TYPE_INDEX |
414 | +zeitgeist_index_get_type |
415 | +ZEITGEIST_INDEX_CLASS |
416 | +ZEITGEIST_IS_INDEX_CLASS |
417 | +ZEITGEIST_INDEX_GET_CLASS |
418 | +</SECTION> |
419 | + |
420 | +<SECTION> |
421 | +<FILE>zeitgeist-result-set</FILE> |
422 | +<TITLE>ZeitgeistResultSet</TITLE> |
423 | +ZeitgeistResultSetIface |
424 | +ZeitgeistResultSet |
425 | +zeitgeist_result_set_size |
426 | +zeitgeist_result_set_estimated_matches |
427 | +zeitgeist_result_set_next |
428 | +zeitgeist_result_set_has_next |
429 | +zeitgeist_result_set_peek |
430 | +zeitgeist_result_set_seek |
431 | +zeitgeist_result_set_tell |
432 | +<SUBSECTION Standard> |
433 | +ZEITGEIST_RESULT_SET |
434 | +ZEITGEIST_IS_RESULT_SET |
435 | +ZEITGEIST_TYPE_RESULT_SET |
436 | +zeitgeist_result_set_get_type |
437 | +ZEITGEIST_RESULT_SET_GET_IFACE |
438 | +</SECTION> |
439 | + |
440 | +<SECTION> |
441 | <FILE>zeitgeist-event</FILE> |
442 | <TITLE>ZeitgeistEvent</TITLE> |
443 | ZeitgeistEvent |
444 | @@ -109,6 +139,7 @@ |
445 | zeitgeist_event_set_manifestation |
446 | zeitgeist_event_get_actor |
447 | zeitgeist_event_set_actor |
448 | +zeitgeist_event_set_actor_from_app_info |
449 | zeitgeist_event_get_subject |
450 | zeitgeist_event_num_subjects |
451 | zeitgeist_event_add_subject |
452 | @@ -125,6 +156,28 @@ |
453 | </SECTION> |
454 | |
455 | <SECTION> |
456 | +<FILE>zeitgeist-data-source-registry</FILE> |
457 | +<TITLE>ZeitgeistDataSourceRegistry</TITLE> |
458 | +ZeitgeistDataSourceRegistry |
459 | +ZeitgeistDataSourceRegistryClass |
460 | +zeitgeist_data_source_registry_new |
461 | +zeitgeist_data_source_registry_get_data_sources |
462 | +zeitgeist_data_source_registry_get_data_sources_finish |
463 | +zeitgeist_data_source_registry_register_data_source |
464 | +zeitgeist_data_source_registry_register_data_source_finish |
465 | +zeitgeist_data_source_registry_set_data_source_enabled |
466 | +zeitgeist_data_source_registry_set_data_source_enabled_finish |
467 | +<SUBSECTION Standard> |
468 | +ZEITGEIST_DATA_SOURCE_REGISTRY |
469 | +ZEITGEIST_IS_DATA_SOURCE_REGISTRY |
470 | +ZEITGEIST_TYPE_DATA_SOURCE_REGISTRY |
471 | +zeitgeist_data_source_registry_get_type |
472 | +ZEITGEIST_DATA_SOURCE_REGISTRY_CLASS |
473 | +ZEITGEIST_IS_DATA_SOURCE_REGISTRY_CLASS |
474 | +ZEITGEIST_DATA_SOURCE_REGISTRY_GET_CLASS |
475 | +</SECTION> |
476 | + |
477 | +<SECTION> |
478 | <FILE>zeitgeist-monitor</FILE> |
479 | <TITLE>ZeitgeistMonitor</TITLE> |
480 | ZeitgeistMonitor |
481 | @@ -137,12 +190,52 @@ |
482 | ZEITGEIST_MONITOR |
483 | ZEITGEIST_IS_MONITOR |
484 | ZEITGEIST_TYPE_MONITOR |
485 | +zeitgeist_monitor_get_type |
486 | ZEITGEIST_MONITOR_CLASS |
487 | ZEITGEIST_IS_MONITOR_CLASS |
488 | ZEITGEIST_MONITOR_GET_CLASS |
489 | </SECTION> |
490 | |
491 | <SECTION> |
492 | +<FILE>zeitgeist-log</FILE> |
493 | +<TITLE>ZeitgeistLog</TITLE> |
494 | +ZeitgeistLog |
495 | +ZeitgeistLogClass |
496 | +zeitgeist_log_new |
497 | +zeitgeist_log_insert_events |
498 | +zeitgeist_log_insert_events_no_reply |
499 | +zeitgeist_log_insert_events_valist |
500 | +zeitgeist_log_insert_events_from_ptrarray |
501 | +zeitgeist_log_insert_events_finish |
502 | +zeitgeist_log_find_events |
503 | +zeitgeist_log_find_events_finish |
504 | +zeitgeist_log_find_event_ids |
505 | +zeitgeist_log_find_event_ids_finish |
506 | +zeitgeist_log_get_events |
507 | +zeitgeist_log_get_events_finish |
508 | +zeitgeist_log_find_related_uris |
509 | +zeitgeist_log_find_related_uris_finish |
510 | +zeitgeist_log_delete_events |
511 | +zeitgeist_log_delete_events_finish |
512 | +zeitgeist_log_delete_log |
513 | +zeitgeist_log_delete_log_finish |
514 | +zeitgeist_log_quit |
515 | +zeitgeist_log_quit_finish |
516 | +zeitgeist_log_install_monitor |
517 | +zeitgeist_log_install_monitor_finish |
518 | +zeitgeist_log_remove_monitor |
519 | +zeitgeist_log_remove_monitor_finish |
520 | +<SUBSECTION Standard> |
521 | +ZEITGEIST_LOG |
522 | +ZEITGEIST_IS_LOG |
523 | +ZEITGEIST_TYPE_LOG |
524 | +zeitgeist_log_get_type |
525 | +ZEITGEIST_LOG_CLASS |
526 | +ZEITGEIST_IS_LOG_CLASS |
527 | +ZEITGEIST_LOG_GET_CLASS |
528 | +</SECTION> |
529 | + |
530 | +<SECTION> |
531 | <FILE>zeitgeist-enumtypes</FILE> |
532 | zeitgeist_result_type_get_type |
533 | ZEITGEIST_TYPE_RESULT_TYPE |
534 | @@ -162,6 +255,16 @@ |
535 | </SECTION> |
536 | |
537 | <SECTION> |
538 | +<FILE>zeitgeist-mimetypes</FILE> |
539 | +<TITLE>Mimetype mapping and URI comprehension</TITLE> |
540 | +zeitgeist_register_mimetype |
541 | +zeitgeist_register_mimetype_regex |
542 | +zeitgeist_interpretation_for_mimetype |
543 | +zeitgeist_register_uri_scheme |
544 | +zeitgeist_manifestation_for_uri |
545 | +</SECTION> |
546 | + |
547 | +<SECTION> |
548 | <FILE>zeitgeist-ontology-interpretations</FILE> |
549 | <TITLE>Interpretation Ontology</TITLE> |
550 | ZEITGEIST_NCAL_ALARM |
551 | @@ -250,54 +353,6 @@ |
552 | </SECTION> |
553 | |
554 | <SECTION> |
555 | -<FILE>zeitgeist-mimetypes</FILE> |
556 | -<TITLE>Mimetype mapping and URI comprehension</TITLE> |
557 | -zeitgeist_register_mimetype |
558 | -zeitgeist_register_mimetype_regex |
559 | -zeitgeist_interpretation_for_mimetype |
560 | -zeitgeist_register_uri_scheme |
561 | -zeitgeist_manifestation_for_uri |
562 | -</SECTION> |
563 | - |
564 | -<SECTION> |
565 | -<FILE>zeitgeist-index</FILE> |
566 | -<TITLE>ZeitgeistIndex</TITLE> |
567 | -ZeitgeistIndex |
568 | -ZeitgeistIndexClass |
569 | -zeitgeist_index_new |
570 | -zeitgeist_index_search |
571 | -zeitgeist_index_search_finish |
572 | -<SUBSECTION Standard> |
573 | -ZEITGEIST_INDEX |
574 | -ZEITGEIST_IS_INDEX |
575 | -ZEITGEIST_TYPE_INDEX |
576 | -zeitgeist_index_get_type |
577 | -ZEITGEIST_INDEX_CLASS |
578 | -ZEITGEIST_IS_INDEX_CLASS |
579 | -ZEITGEIST_INDEX_GET_CLASS |
580 | -</SECTION> |
581 | - |
582 | -<SECTION> |
583 | -<FILE>zeitgeist-result-set</FILE> |
584 | -<TITLE>ZeitgeistResultSet</TITLE> |
585 | -ZeitgeistResultSet |
586 | -ZeitgeistResultSetIface |
587 | -zeitgeist_result_set_size |
588 | -zeitgeist_result_set_estimated_matches |
589 | -zeitgeist_result_set_next |
590 | -zeitgeist_result_set_has_next |
591 | -zeitgeist_result_set_peek |
592 | -zeitgeist_result_set_seek |
593 | -zeitgeist_result_set_tell |
594 | -<SUBSECTION Standard> |
595 | -ZEITGEIST_RESULT_SET |
596 | -ZEITGEIST_IS_RESULT_SET |
597 | -ZEITGEIST_TYPE_RESULT_SET |
598 | -ZEITGEIST_RESULT_SET_GET_IFACE |
599 | -zeitgeist_result_set_get_type |
600 | -</SECTION> |
601 | - |
602 | -<SECTION> |
603 | <FILE>zeitgeist-timestamp</FILE> |
604 | <TITLE>Timestamp handling</TITLE> |
605 | ZEITGEIST_TIMESTAMP_SECOND |
606 | @@ -317,3 +372,4 @@ |
607 | zeitgeist_timestamp_next_midnight |
608 | zeitgeist_timestamp_prev_midnight |
609 | </SECTION> |
610 | + |
611 | |
612 | === modified file 'doc/reference/zeitgeist-1.0.types' |
613 | --- doc/reference/zeitgeist-1.0.types 2010-06-09 14:36:16 +0000 |
614 | +++ doc/reference/zeitgeist-1.0.types 2010-07-23 10:53:42 +0000 |
615 | @@ -1,9 +1,11 @@ |
616 | +zeitgeist_data_source_get_type |
617 | +zeitgeist_data_source_registry_get_type |
618 | +zeitgeist_event_get_type |
619 | +zeitgeist_index_get_type |
620 | zeitgeist_log_get_type |
621 | -zeitgeist_event_get_type |
622 | +zeitgeist_monitor_get_type |
623 | +zeitgeist_result_set_get_type |
624 | +zeitgeist_result_type_get_type |
625 | +zeitgeist_storage_state_get_type |
626 | zeitgeist_subject_get_type |
627 | zeitgeist_time_range_get_type |
628 | -zeitgeist_monitor_get_type |
629 | -zeitgeist_storage_state_get_type |
630 | -zeitgeist_result_type_get_type |
631 | -zeitgeist_index_get_type |
632 | - |
633 | |
634 | === modified file 'src/Makefile.am' |
635 | --- src/Makefile.am 2010-06-28 13:50:12 +0000 |
636 | +++ src/Makefile.am 2010-07-23 10:53:42 +0000 |
637 | @@ -40,6 +40,10 @@ |
638 | eggzeitgeistbindingstypes.h \ |
639 | eggzeitgeistblacklist.h \ |
640 | eggzeitgeistblacklist.c \ |
641 | + eggzeitgeistdatasource.h \ |
642 | + eggzeitgeistdatasource.c \ |
643 | + eggzeitgeistdatasourceregistry.h \ |
644 | + eggzeitgeistdatasourceregistry.c \ |
645 | eggzeitgeistevent.c \ |
646 | eggzeitgeistevent.h \ |
647 | eggzeitgeisteventdataoffset.c \ |
648 | @@ -66,9 +70,11 @@ |
649 | docbook-enum-StorageState.xml \ |
650 | docbook-enum-SubjectDataOffset.xml \ |
651 | docbook-interface-org.gnome.zeitgeist.Blacklist.xml \ |
652 | + docbook-interface-org.gnome.zeitgeist.DataSourceRegistry.xml \ |
653 | docbook-interface-org.gnome.zeitgeist.Index.xml \ |
654 | docbook-interface-org.gnome.zeitgeist.Log.xml \ |
655 | docbook-interface-org.gnome.zeitgeist.Monitor.xml \ |
656 | + docbook-struct-DataSource.xml \ |
657 | docbook-struct-Event.xml \ |
658 | docbook-struct-TimeRange.xml \ |
659 | $(NULL) |
660 | @@ -99,6 +105,10 @@ |
661 | lib_LTLIBRARIES = libzeitgeist-1.0.la |
662 | |
663 | libzeitgeist_1_0_la_SOURCES = \ |
664 | + zeitgeist-data-source.h \ |
665 | + zeitgeist-data-source.c \ |
666 | + zeitgeist-data-source-registry.h \ |
667 | + zeitgeist-data-source-registry.c \ |
668 | zeitgeist-eggdbusconversions.h \ |
669 | zeitgeist-eggdbusconversions.c \ |
670 | zeitgeist-enums.h \ |
671 | @@ -142,6 +152,8 @@ |
672 | devel_headersdir = $(includedir)/zeitgeist-1.0 |
673 | |
674 | devel_headers = \ |
675 | + zeitgeist-data-source.h \ |
676 | + zeitgeist-data-source-registry.h \ |
677 | zeitgeist-enums.h \ |
678 | zeitgeist-enumtypes.h \ |
679 | zeitgeist-event.h \ |
680 | |
681 | === modified file 'src/marshal.list' |
682 | --- src/marshal.list 2010-06-10 09:14:22 +0000 |
683 | +++ src/marshal.list 2010-07-23 10:53:42 +0000 |
684 | @@ -3,3 +3,7 @@ |
685 | |
686 | # ZeitgeistMonitor::events-deleted |
687 | VOID:OBJECT,BOXED |
688 | + |
689 | +# ZeitgeistDataSourceRegistry::source-enabled |
690 | +VOID:STRING,BOOLEAN |
691 | + |
692 | |
693 | === modified file 'src/org.gnome.zeitgeist.Log.xml' |
694 | --- src/org.gnome.zeitgeist.Log.xml 2010-06-09 13:22:12 +0000 |
695 | +++ src/org.gnome.zeitgeist.Log.xml 2010-07-23 10:53:42 +0000 |
696 | @@ -37,6 +37,41 @@ |
697 | </annotation> |
698 | </annotation> |
699 | |
700 | + <annotation name="org.gtk.EggDBus.DeclareStruct" value="DataSource"> |
701 | + <annotation name="org.gtk.EggDBus.DocString" |
702 | + value="The #DataSource type is used to represent registered data sources"/> |
703 | + <annotation name="org.gtk.EggDBus.DocString.Summary" value="DataSource"/> |
704 | + |
705 | + <annotation name="org.gtk.EggDBus.Struct.Member" |
706 | + value="String:unique_id"> |
707 | + <annotation name="org.gtk.EggDBus.DocString" value="Unique ID of the data source"/> |
708 | + </annotation> |
709 | + <annotation name="org.gtk.EggDBus.Struct.Member" value="String:name"> |
710 | + <annotation name="org.gtk.EggDBus.DocString" |
711 | + value="Name of the data source"/> |
712 | + </annotation> |
713 | + <annotation name="org.gtk.EggDBus.Struct.Member" value="String:description"> |
714 | + <annotation name="org.gtk.EggDBus.DocString" |
715 | + value="Description of the data source"/> |
716 | + </annotation> |
717 | + <annotation name="org.gtk.EggDBus.Struct.Member" value="Array<Event>:event_templates"> |
718 | + <annotation name="org.gtk.EggDBus.DocString" |
719 | + value="Event templates for this data source"/> |
720 | + </annotation> |
721 | + <annotation name="org.gtk.EggDBus.Struct.Member" value="Boolean:running"> |
722 | + <annotation name="org.gtk.EggDBus.DocString" |
723 | + value="Whether data source is currently running"/> |
724 | + </annotation> |
725 | + <annotation name="org.gtk.EggDBus.Struct.Member" value="Int64:last_seen"> |
726 | + <annotation name="org.gtk.EggDBus.DocString" |
727 | + value="Timestamp of last action of this data source"/> |
728 | + </annotation> |
729 | + <annotation name="org.gtk.EggDBus.Struct.Member" value="Boolean:enabled"> |
730 | + <annotation name="org.gtk.EggDBus.DocString" |
731 | + value="Whether data source is enabled"/> |
732 | + </annotation> |
733 | + </annotation> |
734 | + |
735 | <annotation name="org.gtk.EggDBus.DeclareEnum" value="EventDataOffset"> |
736 | <annotation name="org.gtk.EggDBus.DocString" |
737 | value="Offsets into the event data array on which to find particular fields"/> |
738 | @@ -349,4 +384,42 @@ |
739 | <arg direction="out" type="u" name="hit_count"/> |
740 | </method> |
741 | </interface> |
742 | + |
743 | + <interface name="org.gnome.zeitgeist.DataSourceRegistry"> |
744 | + <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."/> |
745 | + <method name="RegisterDataSource"> |
746 | + <arg direction="in" type="s" name="unique_id"/> |
747 | + <arg direction="in" type="s" name="name"/> |
748 | + <arg direction="in" type="s" name="description"/> |
749 | + <arg direction="in" type="a(asaasay)" name="event_templates"> |
750 | + <annotation name="org.gtk.EggDBus.Type" value="Array<Event>"/> |
751 | + </arg> |
752 | + <arg direction="out" type="b" name="result"/> |
753 | + </method> |
754 | + <method name="SetDataSourceEnabled"> |
755 | + <arg direction="in" type="s" name="unique_id"/> |
756 | + <arg direction="in" type="b" name="enabled"/> |
757 | + </method> |
758 | + <method name="GetDataSources"> |
759 | + <arg direction="out" type="a(sssa(asaasay)bxb)"> |
760 | + <annotation name="org.gtk.EggDBus.Type" value="Array<DataSource>"/> |
761 | + </arg> |
762 | + </method> |
763 | + |
764 | + <signal name="DataSourceRegistered"> |
765 | + <arg type="(sssa(asaasay)bxb)"> |
766 | + <annotation name="org.gtk.EggDBus.Type" value="DataSource"/> |
767 | + </arg> |
768 | + </signal> |
769 | + <signal name="DataSourceDisconnected"> |
770 | + <arg type="(sssa(asaasay)bxb)"> |
771 | + <annotation name="org.gtk.EggDBus.Type" value="DataSource"/> |
772 | + </arg> |
773 | + </signal> |
774 | + <signal name="DataSourceEnabled"> |
775 | + <arg type="s" name="unique_id"/> |
776 | + <arg type="b" name="enabled"/> |
777 | + </signal> |
778 | + </interface> |
779 | + |
780 | </node> |
781 | |
782 | === added file 'src/zeitgeist-data-source-registry.c' |
783 | --- src/zeitgeist-data-source-registry.c 1970-01-01 00:00:00 +0000 |
784 | +++ src/zeitgeist-data-source-registry.c 2010-07-23 10:53:42 +0000 |
785 | @@ -0,0 +1,527 @@ |
786 | +/* |
787 | + * Copyright (C) 2010 Canonical, Ltd. |
788 | + * |
789 | + * This library is free software; you can redistribute it and/or modify |
790 | + * it under the terms of the GNU Lesser General Public License |
791 | + * version 3.0 as published by the Free Software Foundation. |
792 | + * |
793 | + * This library is distributed in the hope that it will be useful, |
794 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
795 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
796 | + * GNU Lesser General Public License version 3.0 for more details. |
797 | + * |
798 | + * You should have received a copy of the GNU Lesser General Public |
799 | + * License along with this library. If not, see |
800 | + * <http://www.gnu.org/licenses/>. |
801 | + * |
802 | + * Authored by: Michal Hruby <michal.mhr@gmail.com> |
803 | + */ |
804 | + |
805 | +#if HAVE_CONFIG_H |
806 | +#include <config.h> |
807 | +#endif |
808 | + |
809 | +#include "zeitgeist-data-source-registry.h" |
810 | +#include "zeitgeist-eggdbusconversions.h" |
811 | +#include "zeitgeist-marshal.h" |
812 | +#include "eggzeitgeistbindings.h" |
813 | + |
814 | +/** |
815 | + * SECTION:zeitgeist-data-source-registry |
816 | + * @short_description: Query the Zeitgeist Data Source Registry extension |
817 | + * @include: zeitgeist.h |
818 | + * |
819 | + * The Zeitgeist engine maintains a publicly available list of recognized |
820 | + * data-sources (components inserting information into Zeitgeist). |
821 | + * #ZeitgeistDataSourceRegistry is used to register new data sources, |
822 | + * get information about them and gives the ability to enable or disable |
823 | + * the data sources. |
824 | + */ |
825 | + |
826 | +G_DEFINE_TYPE (ZeitgeistDataSourceRegistry, |
827 | + zeitgeist_data_source_registry, |
828 | + G_TYPE_OBJECT); |
829 | +#define ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE(obj) \ |
830 | + (G_TYPE_INSTANCE_GET_PRIVATE(obj, ZEITGEIST_TYPE_DATA_SOURCE_REGISTRY, \ |
831 | + ZeitgeistDataSourceRegistryPrivate)) |
832 | + |
833 | +typedef struct |
834 | +{ |
835 | + /* The connection to the ZG daemon |
836 | + * Note: The EggZeitgeistDataSourceRegistry is owned by |
837 | + * the EggDBusObjectProxy! |
838 | + */ |
839 | + EggDBusObjectProxy *registry_proxy; |
840 | + EggZeitgeistDataSourceRegistry *registry; |
841 | + |
842 | + gulong src_registered_id; |
843 | + gulong src_disconnected_id; |
844 | + gulong src_enabled_id; |
845 | + |
846 | +} ZeitgeistDataSourceRegistryPrivate; |
847 | + |
848 | +/* Property ids */ |
849 | +enum |
850 | +{ |
851 | + PROP_0, |
852 | + |
853 | + LAST_PROPERTY |
854 | +}; |
855 | + |
856 | +enum |
857 | +{ |
858 | + SOURCE_REGISTERED, |
859 | + SOURCE_ENABLED, |
860 | + SOURCE_DISCONNECTED, |
861 | + |
862 | + LAST_SIGNAL |
863 | +}; |
864 | +static guint _registry_signals[LAST_SIGNAL] = { 0 }; |
865 | + |
866 | +static void |
867 | +zeitgeist_data_source_registry_init (ZeitgeistDataSourceRegistry *self) |
868 | +{ |
869 | + ZeitgeistDataSourceRegistryPrivate *priv; |
870 | + EggDBusConnection *conn; |
871 | + |
872 | + priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (self); |
873 | + |
874 | + /* Set up the connection to the ZG daemon */ |
875 | + conn = egg_dbus_connection_get_for_bus (EGG_DBUS_BUS_TYPE_SESSION); |
876 | + priv->registry_proxy = |
877 | + egg_dbus_connection_get_object_proxy (conn, |
878 | + "org.gnome.zeitgeist.Engine", |
879 | + "/org/gnome/zeitgeist/data_source_registry"); |
880 | + |
881 | + priv->registry = |
882 | + EGG_ZEITGEIST_QUERY_INTERFACE_DATA_SOURCE_REGISTRY (priv->registry_proxy); |
883 | + g_object_unref (conn); |
884 | +} |
885 | + |
886 | +static void |
887 | +zeitgeist_data_source_registry_finalize (GObject *object) |
888 | +{ |
889 | + ZeitgeistDataSourceRegistry *registry; |
890 | + ZeitgeistDataSourceRegistryPrivate *priv; |
891 | + |
892 | + registry = ZEITGEIST_DATA_SOURCE_REGISTRY (object); |
893 | + priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (registry); |
894 | + |
895 | + if (priv->src_registered_id) |
896 | + { |
897 | + g_signal_handler_disconnect (priv->registry, priv->src_registered_id); |
898 | + } |
899 | + |
900 | + if (priv->src_disconnected_id) |
901 | + { |
902 | + g_signal_handler_disconnect (priv->registry, priv->src_disconnected_id); |
903 | + } |
904 | + |
905 | + if (priv->src_enabled_id) |
906 | + { |
907 | + g_signal_handler_disconnect (priv->registry, priv->src_enabled_id); |
908 | + } |
909 | + |
910 | + /* Note: priv->registry is owned by priv->registry_proxy */ |
911 | + if (priv->registry_proxy) |
912 | + { |
913 | + g_object_unref (priv->registry_proxy); |
914 | + } |
915 | + |
916 | + G_OBJECT_CLASS (zeitgeist_data_source_registry_parent_class)->finalize (object); |
917 | +} |
918 | + |
919 | +static void |
920 | +zeitgeist_data_source_registry_get_property (GObject *object, |
921 | + guint prop_id, |
922 | + GValue *value, |
923 | + GParamSpec *pspec) |
924 | +{ |
925 | + ZeitgeistDataSourceRegistryPrivate *priv; |
926 | + |
927 | + priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (object); |
928 | + |
929 | + switch (prop_id) |
930 | + { |
931 | + default: |
932 | + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
933 | + return; |
934 | + break; |
935 | + } |
936 | +} |
937 | + |
938 | +static void |
939 | +zeitgeist_data_source_registry_set_property (GObject *object, |
940 | + guint prop_id, |
941 | + const GValue *value, |
942 | + GParamSpec *pspec) |
943 | +{ |
944 | + ZeitgeistDataSourceRegistryPrivate *priv; |
945 | + |
946 | + priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (object); |
947 | + |
948 | + switch (prop_id) |
949 | + { |
950 | + default: |
951 | + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
952 | + return; |
953 | + break; |
954 | + } |
955 | +} |
956 | + |
957 | +static void |
958 | +zeitgeist_data_source_registry_src_registered ( |
959 | + ZeitgeistDataSourceRegistry *registry, |
960 | + EggZeitgeistDataSource *source) |
961 | +{ |
962 | + ZeitgeistDataSource *data_source; |
963 | + |
964 | + data_source = _egg_zeitgeist_data_source_to_zeitgeist_data_source (source); |
965 | + |
966 | + g_signal_emit (registry, _registry_signals[SOURCE_REGISTERED], |
967 | + 0, data_source); |
968 | + |
969 | + g_object_unref (data_source); |
970 | +} |
971 | + |
972 | +static void |
973 | +zeitgeist_data_source_registry_src_disconnected ( |
974 | + ZeitgeistDataSourceRegistry *registry, |
975 | + EggZeitgeistDataSource *source) |
976 | +{ |
977 | + ZeitgeistDataSource *data_source; |
978 | + |
979 | + data_source = _egg_zeitgeist_data_source_to_zeitgeist_data_source (source); |
980 | + |
981 | + g_signal_emit (registry, _registry_signals[SOURCE_DISCONNECTED], |
982 | + 0, data_source); |
983 | + |
984 | + g_object_unref (data_source); |
985 | +} |
986 | + |
987 | +static void |
988 | +zeitgeist_data_source_registry_src_enabled ( |
989 | + ZeitgeistDataSourceRegistry *registry, |
990 | + gchar *unique_id, |
991 | + gboolean enabled) |
992 | +{ |
993 | + g_signal_emit (registry, _registry_signals[SOURCE_ENABLED], |
994 | + 0, unique_id, enabled); |
995 | +} |
996 | + |
997 | +static void |
998 | +zeitgeist_data_source_registry_constructed (GObject *object) |
999 | +{ |
1000 | + ZeitgeistDataSourceRegistryPrivate *priv; |
1001 | + |
1002 | + priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (object); |
1003 | + |
1004 | + priv->src_registered_id = g_signal_connect_swapped ( |
1005 | + priv->registry, "data-source-registered", |
1006 | + G_CALLBACK (zeitgeist_data_source_registry_src_registered), |
1007 | + object); |
1008 | + priv->src_disconnected_id = g_signal_connect_swapped ( |
1009 | + priv->registry, "data-source-disconnected", |
1010 | + G_CALLBACK (zeitgeist_data_source_registry_src_disconnected), |
1011 | + object); |
1012 | + priv->src_enabled_id = g_signal_connect_swapped ( |
1013 | + priv->registry, "data-source-enabled", |
1014 | + G_CALLBACK (zeitgeist_data_source_registry_src_enabled), |
1015 | + object); |
1016 | +} |
1017 | + |
1018 | +static void |
1019 | +zeitgeist_data_source_registry_class_init (ZeitgeistDataSourceRegistryClass *klass) |
1020 | +{ |
1021 | + GObjectClass *object_class = G_OBJECT_CLASS (klass); |
1022 | + GParamSpec *pspec; |
1023 | + |
1024 | + object_class->finalize = zeitgeist_data_source_registry_finalize; |
1025 | + object_class->get_property = zeitgeist_data_source_registry_get_property; |
1026 | + object_class->set_property = zeitgeist_data_source_registry_set_property; |
1027 | + object_class->constructed = zeitgeist_data_source_registry_constructed; |
1028 | + |
1029 | + _registry_signals[SOURCE_REGISTERED] = |
1030 | + g_signal_new ("source-registered", |
1031 | + G_OBJECT_CLASS_TYPE (object_class), |
1032 | + G_SIGNAL_RUN_FIRST, |
1033 | + G_STRUCT_OFFSET (ZeitgeistDataSourceRegistryClass, source_registered), |
1034 | + NULL, NULL, |
1035 | + g_cclosure_marshal_VOID__OBJECT, |
1036 | + G_TYPE_NONE, 1, ZEITGEIST_TYPE_DATA_SOURCE); |
1037 | + |
1038 | + _registry_signals[SOURCE_DISCONNECTED] = |
1039 | + g_signal_new ("source-disconnected", |
1040 | + G_OBJECT_CLASS_TYPE (object_class), |
1041 | + G_SIGNAL_RUN_FIRST, |
1042 | + G_STRUCT_OFFSET (ZeitgeistDataSourceRegistryClass, source_disconnected), |
1043 | + NULL, NULL, |
1044 | + g_cclosure_marshal_VOID__OBJECT, |
1045 | + G_TYPE_NONE, 1, ZEITGEIST_TYPE_DATA_SOURCE); |
1046 | + |
1047 | + _registry_signals[SOURCE_ENABLED] = |
1048 | + g_signal_new ("source-enabled", |
1049 | + G_OBJECT_CLASS_TYPE (object_class), |
1050 | + G_SIGNAL_RUN_FIRST, |
1051 | + G_STRUCT_OFFSET (ZeitgeistDataSourceRegistryClass, source_enabled), |
1052 | + NULL, NULL, |
1053 | + _zeitgeist_cclosure_marshal_VOID__STRING_BOOLEAN, |
1054 | + G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_BOOLEAN); |
1055 | + |
1056 | + g_type_class_add_private (object_class, |
1057 | + sizeof (ZeitgeistDataSourceRegistryPrivate)); |
1058 | +} |
1059 | + |
1060 | +/* Used to marshal the async callbacks from EggDBus into ones |
1061 | + * coming from this DataSourceRegistry instance */ |
1062 | +static void |
1063 | +dispatch_async_callback (GObject *source_object, |
1064 | + GAsyncResult *res, |
1065 | + gpointer user_data) |
1066 | +{ |
1067 | + gpointer *data = (gpointer*) user_data; |
1068 | + ZeitgeistDataSourceRegistry *self = ZEITGEIST_DATA_SOURCE_REGISTRY (data[0]); |
1069 | + GAsyncReadyCallback callback = (GAsyncReadyCallback) data[1]; |
1070 | + gpointer _user_data = data[2]; |
1071 | + |
1072 | + if (callback != NULL) |
1073 | + { |
1074 | + callback (G_OBJECT (self), res, _user_data); |
1075 | + } |
1076 | + |
1077 | + g_object_unref (self); |
1078 | + g_free (user_data); |
1079 | +} |
1080 | + |
1081 | +/* |
1082 | + * API BELOW HERE |
1083 | + */ |
1084 | + |
1085 | +/** |
1086 | + * zeitgeist_data_source_registry_new: |
1087 | + * |
1088 | + * Create a new data source registry instance. |
1089 | + * |
1090 | + * DataSourceRegistry instances are not overly expensive for neither |
1091 | + * client or the Zeitgeist daemon so there's no need to go to lengths |
1092 | + * to keep singleton instances around. |
1093 | + * |
1094 | + * Returns: A reference to a newly allocated registry. |
1095 | + */ |
1096 | +ZeitgeistDataSourceRegistry* |
1097 | +zeitgeist_data_source_registry_new (void) |
1098 | +{ |
1099 | + ZeitgeistDataSourceRegistry *registry; |
1100 | + |
1101 | + registry = (ZeitgeistDataSourceRegistry*) |
1102 | + g_object_new (ZEITGEIST_TYPE_DATA_SOURCE_REGISTRY, NULL); |
1103 | + |
1104 | + return registry; |
1105 | +} |
1106 | + |
1107 | +void |
1108 | +zeitgeist_data_source_registry_get_data_sources ( |
1109 | + ZeitgeistDataSourceRegistry *self, |
1110 | + GCancellable *cancellable, |
1111 | + GAsyncReadyCallback callback, |
1112 | + gpointer user_data) |
1113 | +{ |
1114 | + ZeitgeistDataSourceRegistryPrivate *priv; |
1115 | + gpointer *dispatch_data; |
1116 | + |
1117 | + g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE_REGISTRY (self)); |
1118 | + g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); |
1119 | + |
1120 | + priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (self); |
1121 | + |
1122 | + dispatch_data = g_new (gpointer, 3); |
1123 | + dispatch_data[0] = g_object_ref (self); |
1124 | + dispatch_data[1] = callback; |
1125 | + dispatch_data[2] = user_data; |
1126 | + |
1127 | + egg_zeitgeist_data_source_registry_get_data_sources ( |
1128 | + priv->registry, |
1129 | + EGG_DBUS_CALL_FLAGS_NONE, |
1130 | + cancellable, |
1131 | + dispatch_async_callback, |
1132 | + dispatch_data); |
1133 | +} |
1134 | + |
1135 | +/** |
1136 | + * zeitgeist_data_source_registry_get_data_sources_finish: |
1137 | + * @self: Instance of #ZeitgeistDataSourceRegistry. |
1138 | + * @res: a #GAsyncResult. |
1139 | + * @error: a #GError or #NULL. |
1140 | + * |
1141 | + * Returns: Newly created #GPtrArray containing #ZeitgeistDataSource<!-- -->(s) |
1142 | + * registered in Zeitgeist. Free using g_ptr_array_unref() once |
1143 | + * you're done using it. |
1144 | + */ |
1145 | +GPtrArray* |
1146 | +zeitgeist_data_source_registry_get_data_sources_finish ( |
1147 | + ZeitgeistDataSourceRegistry *self, |
1148 | + GAsyncResult *res, |
1149 | + GError **error) |
1150 | +{ |
1151 | + ZeitgeistDataSourceRegistryPrivate *priv; |
1152 | + EggDBusArraySeq *array_seq; |
1153 | + gboolean call_result; |
1154 | + GPtrArray *data_sources = NULL; |
1155 | + |
1156 | + g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE_REGISTRY (self), NULL); |
1157 | + |
1158 | + priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (self); |
1159 | + |
1160 | + call_result = egg_zeitgeist_data_source_registry_get_data_sources_finish ( |
1161 | + priv->registry, |
1162 | + &array_seq, |
1163 | + res, |
1164 | + error); |
1165 | + |
1166 | + data_sources = |
1167 | + _egg_zeitgeist_data_sources_to_zeitgeist_data_sources (array_seq); |
1168 | + g_ptr_array_set_free_func (data_sources, g_object_unref); |
1169 | + |
1170 | + g_object_unref (array_seq); |
1171 | + |
1172 | + return data_sources; |
1173 | +} |
1174 | + |
1175 | +/** |
1176 | + * zeitgeist_data_source_registry_register_data_source: |
1177 | + * @self: Instance of #ZeitgeistDataSourceRegistry. |
1178 | + * @source: Data source to register. |
1179 | + * @cancellable: a #GCancellable or #NULL. |
1180 | + * @callback: a GAsyncReadyCallback to call when the request is finished. |
1181 | + * @user_data: the data to pass to callback function. |
1182 | + * |
1183 | + * Registers new data source in the registry, the @source parameter needs to |
1184 | + * have unique-id, name, description and optionally event_templates set, |
1185 | + * therefore it is useful to pass #ZeitgeistDataSource instance created using |
1186 | + * zeitgeist_data_source_new_full(). The registry will assume its ownership. |
1187 | + */ |
1188 | +void |
1189 | +zeitgeist_data_source_registry_register_data_source ( |
1190 | + ZeitgeistDataSourceRegistry *self, |
1191 | + ZeitgeistDataSource *source, |
1192 | + GCancellable *cancellable, |
1193 | + GAsyncReadyCallback callback, |
1194 | + gpointer user_data) |
1195 | +{ |
1196 | + ZeitgeistDataSourceRegistryPrivate *priv; |
1197 | + gpointer *dispatch_data; |
1198 | + EggDBusArraySeq *templates; |
1199 | + |
1200 | + g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE_REGISTRY (self)); |
1201 | + g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE (source)); |
1202 | + g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); |
1203 | + |
1204 | + priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (self); |
1205 | + |
1206 | + g_object_ref_sink (G_OBJECT (source)); |
1207 | + |
1208 | + dispatch_data = g_new (gpointer, 3); |
1209 | + dispatch_data[0] = g_object_ref (self); |
1210 | + dispatch_data[1] = callback; |
1211 | + dispatch_data[2] = user_data; |
1212 | + |
1213 | + templates = _zeitgeist_events_to_egg_zeitgeist_events ( |
1214 | + zeitgeist_data_source_get_event_templates (source) |
1215 | + ); |
1216 | + |
1217 | + egg_zeitgeist_data_source_registry_register_data_source ( |
1218 | + priv->registry, |
1219 | + EGG_DBUS_CALL_FLAGS_NONE, |
1220 | + zeitgeist_data_source_get_unique_id (source), |
1221 | + zeitgeist_data_source_get_name (source), |
1222 | + zeitgeist_data_source_get_description (source), |
1223 | + templates, |
1224 | + cancellable, |
1225 | + dispatch_async_callback, |
1226 | + dispatch_data); |
1227 | + |
1228 | + g_object_unref (templates); |
1229 | + g_object_unref (source); |
1230 | +} |
1231 | + |
1232 | +/** |
1233 | + * zeitgeist_data_source_registry_register_data_source_finish: |
1234 | + * @self: Instance of #ZeitgeistDataSourceRegistry. |
1235 | + * @res: Result of the asynchronous operation. |
1236 | + * @error: a #GError or NULL. |
1237 | + * |
1238 | + * Returns: If error is unset, returns whether this data source is enabled. |
1239 | + */ |
1240 | +gboolean |
1241 | +zeitgeist_data_source_registry_register_data_source_finish ( |
1242 | + ZeitgeistDataSourceRegistry *self, |
1243 | + GAsyncResult *res, |
1244 | + GError **error) |
1245 | +{ |
1246 | + ZeitgeistDataSourceRegistryPrivate *priv; |
1247 | + gboolean result = FALSE; |
1248 | + |
1249 | + g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE_REGISTRY (self), FALSE); |
1250 | + |
1251 | + priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (self); |
1252 | + |
1253 | + egg_zeitgeist_data_source_registry_register_data_source_finish ( |
1254 | + priv->registry, |
1255 | + &result, |
1256 | + res, |
1257 | + error); |
1258 | + |
1259 | + return result; |
1260 | +} |
1261 | + |
1262 | +void |
1263 | +zeitgeist_data_source_registry_set_data_source_enabled ( |
1264 | + ZeitgeistDataSourceRegistry *self, |
1265 | + const gchar *unique_id, |
1266 | + gboolean enabled, |
1267 | + GCancellable *cancellable, |
1268 | + GAsyncReadyCallback callback, |
1269 | + gpointer user_data) |
1270 | +{ |
1271 | + ZeitgeistDataSourceRegistryPrivate *priv; |
1272 | + gpointer *dispatch_data; |
1273 | + |
1274 | + g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE_REGISTRY (self)); |
1275 | + g_return_if_fail (unique_id != NULL); |
1276 | + g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); |
1277 | + |
1278 | + priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (self); |
1279 | + |
1280 | + dispatch_data = g_new (gpointer, 3); |
1281 | + dispatch_data[0] = g_object_ref (self); |
1282 | + dispatch_data[1] = callback; |
1283 | + dispatch_data[2] = user_data; |
1284 | + |
1285 | + egg_zeitgeist_data_source_registry_set_data_source_enabled ( |
1286 | + priv->registry, |
1287 | + EGG_DBUS_CALL_FLAGS_NONE, |
1288 | + unique_id, |
1289 | + enabled, |
1290 | + cancellable, |
1291 | + dispatch_async_callback, |
1292 | + dispatch_data); |
1293 | +} |
1294 | + |
1295 | +void |
1296 | +zeitgeist_data_source_registry_set_data_source_enabled_finish ( |
1297 | + ZeitgeistDataSourceRegistry *self, |
1298 | + GAsyncResult *res, |
1299 | + GError **error) |
1300 | +{ |
1301 | + ZeitgeistDataSourceRegistryPrivate *priv; |
1302 | + |
1303 | + g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE_REGISTRY (self)); |
1304 | + |
1305 | + priv = ZEITGEIST_DATA_SOURCE_REGISTRY_GET_PRIVATE (self); |
1306 | + |
1307 | + egg_zeitgeist_data_source_registry_set_data_source_enabled_finish ( |
1308 | + priv->registry, |
1309 | + res, |
1310 | + error); |
1311 | +} |
1312 | + |
1313 | |
1314 | === added file 'src/zeitgeist-data-source-registry.h' |
1315 | --- src/zeitgeist-data-source-registry.h 1970-01-01 00:00:00 +0000 |
1316 | +++ src/zeitgeist-data-source-registry.h 2010-07-23 10:53:42 +0000 |
1317 | @@ -0,0 +1,108 @@ |
1318 | +/* |
1319 | + * Copyright (C) 2010 Canonical, Ltd. |
1320 | + * |
1321 | + * This library is free software; you can redistribute it and/or modify |
1322 | + * it under the terms of the GNU Lesser General Public License |
1323 | + * version 3.0 as published by the Free Software Foundation. |
1324 | + * |
1325 | + * This library is distributed in the hope that it will be useful, |
1326 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1327 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1328 | + * GNU Lesser General Public License version 3.0 for more details. |
1329 | + * |
1330 | + * You should have received a copy of the GNU Lesser General Public |
1331 | + * License along with this library. If not, see |
1332 | + * <http://www.gnu.org/licenses/>. |
1333 | + * |
1334 | + * Authored by: Michal Hruby <michal.mhr@gmail.com> |
1335 | + */ |
1336 | + |
1337 | +#if !defined (_ZEITGEIST_H_INSIDE_) && !defined (ZEITGEIST_COMPILATION) |
1338 | +#error "Only <zeitgeist.h> can be included directly." |
1339 | +#endif |
1340 | + |
1341 | +#ifndef _ZEITGEIST_DATA_SOURCE_REGISTRY_H_ |
1342 | +#define _ZEITGEIST_DATA_SOURCE_REGISTRY_H_ |
1343 | + |
1344 | +#include <glib.h> |
1345 | +#include <glib-object.h> |
1346 | +#include <gio/gio.h> |
1347 | +#include <zeitgeist-event.h> |
1348 | +#include <zeitgeist-enums.h> |
1349 | +#include <zeitgeist-data-source.h> |
1350 | + |
1351 | +G_BEGIN_DECLS |
1352 | + |
1353 | +#define ZEITGEIST_TYPE_DATA_SOURCE_REGISTRY (zeitgeist_data_source_registry_get_type()) |
1354 | +#define ZEITGEIST_DATA_SOURCE_REGISTRY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZEITGEIST_TYPE_DATA_SOURCE_REGISTRY, ZeitgeistDataSourceRegistry)) |
1355 | +#define ZEITGEIST_DATA_SOURCE_REGISTRY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZEITGEIST_TYPE_DATA_SOURCE_REGISTRY, ZeitgeistDataSourceRegistryClass)) |
1356 | +#define ZEITGEIST_DATA_SOURCE_REGISTRY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZEITGEIST_TYPE_DATA_SOURCE_REGISTRY, ZeitgeistDataSourceRegistryClass)) |
1357 | +#define ZEITGEIST_IS_DATA_SOURCE_REGISTRY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZEITGEIST_TYPE_DATA_SOURCE_REGISTRY)) |
1358 | +#define ZEITGEIST_IS_DATA_SOURCE_REGISTRY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZEITGEIST_TYPE_DATA_SOURCE_REGISTRY)) |
1359 | + |
1360 | +typedef struct _ZeitgeistDataSourceRegistry ZeitgeistDataSourceRegistry; |
1361 | +typedef struct _ZeitgeistDataSourceRegistryClass ZeitgeistDataSourceRegistryClass; |
1362 | + |
1363 | +struct _ZeitgeistDataSourceRegistryClass |
1364 | +{ |
1365 | + GObjectClass parent_class; |
1366 | + |
1367 | + void (*source_registered) (ZeitgeistDataSourceRegistry *registry, |
1368 | + ZeitgeistDataSource *source); |
1369 | + void (*source_disconnected) (ZeitgeistDataSourceRegistry *registry, |
1370 | + ZeitgeistDataSource *source); |
1371 | + void (*source_enabled) (ZeitgeistDataSourceRegistry *registry, |
1372 | + gchar *unique_id, |
1373 | + gboolean enabled); |
1374 | +}; |
1375 | + |
1376 | + |
1377 | +struct _ZeitgeistDataSourceRegistry |
1378 | +{ |
1379 | + GObject parent_instance; |
1380 | +}; |
1381 | + |
1382 | +GType zeitgeist_data_source_registry_get_type (void); |
1383 | + |
1384 | +ZeitgeistDataSourceRegistry* zeitgeist_data_source_registry_new (void); |
1385 | + |
1386 | +void zeitgeist_data_source_registry_get_data_sources ( |
1387 | + ZeitgeistDataSourceRegistry *self, |
1388 | + GCancellable *cancellable, |
1389 | + GAsyncReadyCallback callback, |
1390 | + gpointer user_data); |
1391 | + |
1392 | +GPtrArray* zeitgeist_data_source_registry_get_data_sources_finish ( |
1393 | + ZeitgeistDataSourceRegistry *self, |
1394 | + GAsyncResult *res, |
1395 | + GError **error); |
1396 | + |
1397 | +void zeitgeist_data_source_registry_register_data_source ( |
1398 | + ZeitgeistDataSourceRegistry *self, |
1399 | + ZeitgeistDataSource *source, |
1400 | + GCancellable *cancellable, |
1401 | + GAsyncReadyCallback callback, |
1402 | + gpointer user_data); |
1403 | + |
1404 | +gboolean zeitgeist_data_source_registry_register_data_source_finish ( |
1405 | + ZeitgeistDataSourceRegistry *self, |
1406 | + GAsyncResult *res, |
1407 | + GError **error); |
1408 | + |
1409 | +void zeitgeist_data_source_registry_set_data_source_enabled ( |
1410 | + ZeitgeistDataSourceRegistry *self, |
1411 | + const gchar *unique_id, |
1412 | + gboolean enabled, |
1413 | + GCancellable *cancellable, |
1414 | + GAsyncReadyCallback callback, |
1415 | + gpointer user_data); |
1416 | + |
1417 | +void zeitgeist_data_source_registry_set_data_source_enabled_finish ( |
1418 | + ZeitgeistDataSourceRegistry *self, |
1419 | + GAsyncResult *res, |
1420 | + GError **error); |
1421 | + |
1422 | +G_END_DECLS |
1423 | + |
1424 | +#endif /* _ZEITGEIST_DATA_SOURCE_REGISTRY_H_ */ |
1425 | + |
1426 | |
1427 | === added file 'src/zeitgeist-data-source.c' |
1428 | --- src/zeitgeist-data-source.c 1970-01-01 00:00:00 +0000 |
1429 | +++ src/zeitgeist-data-source.c 2010-07-23 10:53:42 +0000 |
1430 | @@ -0,0 +1,349 @@ |
1431 | +/* |
1432 | + * Copyright (C) 2010 Canonical, Ltd. |
1433 | + * |
1434 | + * This library is free software; you can redistribute it and/or modify |
1435 | + * it under the terms of the GNU Lesser General Public License |
1436 | + * version 3.0 as published by the Free Software Foundation. |
1437 | + * |
1438 | + * This library is distributed in the hope that it will be useful, |
1439 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1440 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1441 | + * GNU Lesser General Public License version 3.0 for more details. |
1442 | + * |
1443 | + * You should have received a copy of the GNU Lesser General Public |
1444 | + * License along with this library. If not, see |
1445 | + * <http://www.gnu.org/licenses/>. |
1446 | + * |
1447 | + * Authored by: Michal Hruby <michal.mhr@gmail.com> |
1448 | + */ |
1449 | + |
1450 | +/** |
1451 | + * SECTION:zeitgeist-data-source |
1452 | + * @short_description: Abstracts data sources used by |
1453 | + * the #ZeitgeistDataSourceRegistry extension |
1454 | + * @include: zeitgeist.h |
1455 | + * |
1456 | + * #ZeitgeistDataSource represents a data source used to insert events into |
1457 | + * Zeitgeist. The data sources are identified using the unique_id property, |
1458 | + * and when querying the data source registry you get other interesting |
1459 | + * information like timestamp of the last action of the data source, flag |
1460 | + * whether it is currently running etc. |
1461 | + */ |
1462 | +#if HAVE_CONFIG_H |
1463 | +#include <config.h> |
1464 | +#endif |
1465 | + |
1466 | +#include "zeitgeist-data-source.h" |
1467 | + |
1468 | +G_DEFINE_TYPE (ZeitgeistDataSource, zeitgeist_data_source, G_TYPE_INITIALLY_UNOWNED); |
1469 | +#define ZEITGEIST_DATA_SOURCE_GET_PRIVATE(obj) \ |
1470 | + (G_TYPE_INSTANCE_GET_PRIVATE(obj, ZEITGEIST_TYPE_DATA_SOURCE, ZeitgeistDataSourcePrivate)) |
1471 | + |
1472 | +typedef struct |
1473 | +{ |
1474 | + gchar *unique_id; |
1475 | + gchar *name; |
1476 | + gchar *description; |
1477 | + GPtrArray *templates; |
1478 | + gboolean running; |
1479 | + gint64 timestamp; |
1480 | + gboolean enabled; |
1481 | +} ZeitgeistDataSourcePrivate; |
1482 | + |
1483 | +/** |
1484 | + * zeitgeist_data_source_new: |
1485 | + * |
1486 | + * Create a new empty data source structure. |
1487 | + * |
1488 | + * Returns: A new instance of #ZeitgeistDataSource. The returned src will |
1489 | + * have a floating reference which will be consumed if you pass the |
1490 | + * data source to any of the methods provided by this library (like |
1491 | + * registering the data source). If you do not do that then you |
1492 | + * must free the data source youself with g_object_unref(). |
1493 | + */ |
1494 | +ZeitgeistDataSource* |
1495 | +zeitgeist_data_source_new (void) |
1496 | +{ |
1497 | + return g_object_new (ZEITGEIST_TYPE_DATA_SOURCE, NULL); |
1498 | +} |
1499 | +/** |
1500 | + * zeitgeist_data_source_new_full: |
1501 | + * @id: Unique ID for the data source. |
1502 | + * @name: Name of the data source (may be translated). |
1503 | + * @desc: Data source description. |
1504 | + * @event_templates: A #GPtrArray of #ZeitgeistEvent<!-- -->s. This parameter |
1505 | + * is optional and purely informational to let data-source |
1506 | + * management applications and other data-sources know what |
1507 | + * sort of information the data source logs. |
1508 | + * The data source will assume ownership of the events and |
1509 | + * the pointer array. |
1510 | + * If you want to keep a reference for yourself you must do a |
1511 | + * g_ptr_array_ref() on @event_templates as well as reffing |
1512 | + * the events held by it before calling this method. |
1513 | + * |
1514 | + * Creates a new instance of DataSource with the given ID, name and |
1515 | + * description. |
1516 | + * |
1517 | + * Returns: New instance of #ZeitgeistDataSource with floating reference, |
1518 | + * if you do not pass the instance to method like |
1519 | + * zeitgeist_data_source_registry_register_data_source(), then you |
1520 | + * have to free the data source yourself using g_object_unref(). |
1521 | + */ |
1522 | +ZeitgeistDataSource* |
1523 | +zeitgeist_data_source_new_full (const gchar *id, |
1524 | + const gchar *name, |
1525 | + const gchar *desc, |
1526 | + GPtrArray *templates) |
1527 | +{ |
1528 | + ZeitgeistDataSource* src = zeitgeist_data_source_new (); |
1529 | + |
1530 | + zeitgeist_data_source_set_unique_id (src, id); |
1531 | + zeitgeist_data_source_set_name (src, name); |
1532 | + zeitgeist_data_source_set_description (src, desc); |
1533 | + zeitgeist_data_source_set_event_templates (src, templates); |
1534 | + |
1535 | + return src; |
1536 | +} |
1537 | + |
1538 | +const gchar* |
1539 | +zeitgeist_data_source_get_unique_id (ZeitgeistDataSource *src) |
1540 | +{ |
1541 | + ZeitgeistDataSourcePrivate *priv; |
1542 | + g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE (src), NULL); |
1543 | + |
1544 | + priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src); |
1545 | + |
1546 | + return priv->unique_id; |
1547 | +} |
1548 | + |
1549 | +void |
1550 | +zeitgeist_data_source_set_unique_id (ZeitgeistDataSource *src, |
1551 | + const gchar* unique_id) |
1552 | +{ |
1553 | + ZeitgeistDataSourcePrivate *priv; |
1554 | + g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE (src)); |
1555 | + |
1556 | + priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src); |
1557 | + |
1558 | + if (priv->unique_id) |
1559 | + { |
1560 | + g_free (priv->unique_id); |
1561 | + } |
1562 | + |
1563 | + priv->unique_id = g_strdup (unique_id); |
1564 | +} |
1565 | + |
1566 | +const gchar* |
1567 | +zeitgeist_data_source_get_name (ZeitgeistDataSource *src) |
1568 | +{ |
1569 | + ZeitgeistDataSourcePrivate *priv; |
1570 | + g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE (src), NULL); |
1571 | + |
1572 | + priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src); |
1573 | + |
1574 | + return priv->name; |
1575 | +} |
1576 | + |
1577 | +void |
1578 | +zeitgeist_data_source_set_name (ZeitgeistDataSource *src, |
1579 | + const gchar *name) |
1580 | +{ |
1581 | + ZeitgeistDataSourcePrivate *priv; |
1582 | + g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE (src)); |
1583 | + |
1584 | + priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src); |
1585 | + |
1586 | + if (priv->name) |
1587 | + { |
1588 | + g_free (priv->name); |
1589 | + } |
1590 | + |
1591 | + priv->name = g_strdup (name); |
1592 | +} |
1593 | + |
1594 | +const gchar* |
1595 | +zeitgeist_data_source_get_description (ZeitgeistDataSource *src) |
1596 | +{ |
1597 | + ZeitgeistDataSourcePrivate *priv; |
1598 | + g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE (src), NULL); |
1599 | + |
1600 | + priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src); |
1601 | + |
1602 | + return priv->description; |
1603 | +} |
1604 | + |
1605 | +void |
1606 | +zeitgeist_data_source_set_description (ZeitgeistDataSource *src, |
1607 | + const gchar *description) |
1608 | +{ |
1609 | + ZeitgeistDataSourcePrivate *priv; |
1610 | + g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE (src)); |
1611 | + |
1612 | + priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src); |
1613 | + |
1614 | + if (priv->description) |
1615 | + { |
1616 | + g_free (priv->description); |
1617 | + } |
1618 | + |
1619 | + priv->description = g_strdup (description); |
1620 | +} |
1621 | + |
1622 | +GPtrArray* |
1623 | +zeitgeist_data_source_get_event_templates (ZeitgeistDataSource *src) |
1624 | +{ |
1625 | + ZeitgeistDataSourcePrivate *priv; |
1626 | + g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE (src), NULL); |
1627 | + |
1628 | + priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src); |
1629 | + |
1630 | + return priv->templates; |
1631 | +} |
1632 | + |
1633 | +/** |
1634 | + * zeitgeist_data_source_set_event_templates: |
1635 | + * @src: Instance of #ZeitgeistDataSource. |
1636 | + * @event_templates: A #GPtrArray which contains elements of type |
1637 | + * #ZeitgeistEvent. |
1638 | + * The data source will assume ownership of the events and |
1639 | + * the pointer array. |
1640 | + * If you want to keep a reference for yourself you must do a |
1641 | + * g_ptr_array_ref() on @templates as well as reffing |
1642 | + * the events held by it before calling this method. |
1643 | + * |
1644 | + * Sets event templates which are logged by this #ZeitgeistDataSource |
1645 | + * instance. |
1646 | + */ |
1647 | +void |
1648 | +zeitgeist_data_source_set_event_templates (ZeitgeistDataSource *src, |
1649 | + GPtrArray *event_templates) |
1650 | +{ |
1651 | + ZeitgeistDataSourcePrivate *priv; |
1652 | + g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE (src)); |
1653 | + |
1654 | + priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src); |
1655 | + |
1656 | + if (priv->templates) |
1657 | + { |
1658 | + g_ptr_array_unref (priv->templates); |
1659 | + } |
1660 | + |
1661 | + if (event_templates) |
1662 | + { |
1663 | + g_ptr_array_foreach (event_templates, (GFunc) g_object_ref_sink, NULL); |
1664 | + g_ptr_array_set_free_func (event_templates, g_object_unref); |
1665 | + } |
1666 | + |
1667 | + priv->templates = event_templates; |
1668 | +} |
1669 | + |
1670 | +gboolean |
1671 | +zeitgeist_data_source_is_running (ZeitgeistDataSource *src) |
1672 | +{ |
1673 | + ZeitgeistDataSourcePrivate *priv; |
1674 | + g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE (src), FALSE); |
1675 | + |
1676 | + priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src); |
1677 | + |
1678 | + return priv->running; |
1679 | +} |
1680 | + |
1681 | +void |
1682 | +zeitgeist_data_source_set_running (ZeitgeistDataSource *src, |
1683 | + gboolean running) |
1684 | +{ |
1685 | + ZeitgeistDataSourcePrivate *priv; |
1686 | + g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE (src)); |
1687 | + |
1688 | + priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src); |
1689 | + |
1690 | + priv->running = running; |
1691 | +} |
1692 | + |
1693 | +gint64 |
1694 | +zeitgeist_data_source_get_timestamp (ZeitgeistDataSource *src) |
1695 | +{ |
1696 | + ZeitgeistDataSourcePrivate *priv; |
1697 | + g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE (src), 0); |
1698 | + |
1699 | + priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src); |
1700 | + |
1701 | + return priv->timestamp; |
1702 | +} |
1703 | + |
1704 | +void |
1705 | +zeitgeist_data_source_set_timestamp (ZeitgeistDataSource *src, |
1706 | + gint64 timestamp) |
1707 | +{ |
1708 | + ZeitgeistDataSourcePrivate *priv; |
1709 | + g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE (src)); |
1710 | + |
1711 | + priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src); |
1712 | + |
1713 | + priv->timestamp = timestamp; |
1714 | +} |
1715 | + |
1716 | +gboolean |
1717 | +zeitgeist_data_source_is_enabled (ZeitgeistDataSource *src) |
1718 | +{ |
1719 | + ZeitgeistDataSourcePrivate *priv; |
1720 | + g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE (src), FALSE); |
1721 | + |
1722 | + priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src); |
1723 | + |
1724 | + return priv->enabled; |
1725 | +} |
1726 | + |
1727 | +void |
1728 | +zeitgeist_data_source_set_enabled (ZeitgeistDataSource *src, |
1729 | + gboolean enabled) |
1730 | +{ |
1731 | + ZeitgeistDataSourcePrivate *priv; |
1732 | + g_return_if_fail (ZEITGEIST_IS_DATA_SOURCE (src)); |
1733 | + |
1734 | + priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src); |
1735 | + |
1736 | + priv->enabled = enabled; |
1737 | +} |
1738 | + |
1739 | +static void |
1740 | +zeitgeist_data_source_init (ZeitgeistDataSource *object) |
1741 | +{ |
1742 | + ZeitgeistDataSourcePrivate *priv; |
1743 | + |
1744 | + priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (object); |
1745 | + priv->unique_id = NULL; |
1746 | + priv->name = NULL; |
1747 | + priv->description = NULL; |
1748 | + priv->templates = NULL; |
1749 | + priv->running = FALSE; |
1750 | + priv->timestamp = 0; |
1751 | + priv->enabled = TRUE; |
1752 | +} |
1753 | + |
1754 | +static void |
1755 | +zeitgeist_data_source_finalize (GObject *object) |
1756 | +{ |
1757 | + ZeitgeistDataSource *src = ZEITGEIST_DATA_SOURCE (object); |
1758 | + ZeitgeistDataSourcePrivate *priv; |
1759 | + |
1760 | + priv = ZEITGEIST_DATA_SOURCE_GET_PRIVATE (src); |
1761 | + |
1762 | + zeitgeist_data_source_set_unique_id (src, NULL); |
1763 | + zeitgeist_data_source_set_name (src, NULL); |
1764 | + zeitgeist_data_source_set_description (src, NULL); |
1765 | + zeitgeist_data_source_set_event_templates (src, NULL); |
1766 | + |
1767 | + G_OBJECT_CLASS (zeitgeist_data_source_parent_class)->finalize (object); |
1768 | +} |
1769 | + |
1770 | +static void |
1771 | +zeitgeist_data_source_class_init (ZeitgeistDataSourceClass *klass) |
1772 | +{ |
1773 | + GObjectClass* object_class = G_OBJECT_CLASS (klass); |
1774 | + |
1775 | + object_class->finalize = zeitgeist_data_source_finalize; |
1776 | + |
1777 | + g_type_class_add_private (object_class, sizeof (ZeitgeistDataSourcePrivate)); |
1778 | +} |
1779 | + |
1780 | |
1781 | === added file 'src/zeitgeist-data-source.h' |
1782 | --- src/zeitgeist-data-source.h 1970-01-01 00:00:00 +0000 |
1783 | +++ src/zeitgeist-data-source.h 2010-07-23 10:53:42 +0000 |
1784 | @@ -0,0 +1,101 @@ |
1785 | +/* |
1786 | + * Copyright (C) 2010 Canonical, Ltd. |
1787 | + * |
1788 | + * This library is free software; you can redistribute it and/or modify |
1789 | + * it under the terms of the GNU Lesser General Public License |
1790 | + * version 3.0 as published by the Free Software Foundation. |
1791 | + * |
1792 | + * This library is distributed in the hope that it will be useful, |
1793 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1794 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1795 | + * GNU Lesser General Public License version 3.0 for more details. |
1796 | + * |
1797 | + * You should have received a copy of the GNU Lesser General Public |
1798 | + * License along with this library. If not, see |
1799 | + * <http://www.gnu.org/licenses/>. |
1800 | + * |
1801 | + * Authored by: Michal Hruby <michal.mhr@gmail.com> |
1802 | + */ |
1803 | + |
1804 | +#if !defined (_ZEITGEIST_H_INSIDE_) && !defined (ZEITGEIST_COMPILATION) |
1805 | +#error "Only <zeitgeist.h> can be included directly." |
1806 | +#endif |
1807 | + |
1808 | +#ifndef _ZEITGEIST_DATA_SOURCE_H_ |
1809 | +#define _ZEITGEIST_DATA_SOURCE_H_ |
1810 | + |
1811 | +#include <glib.h> |
1812 | +#include <glib-object.h> |
1813 | + |
1814 | +G_BEGIN_DECLS |
1815 | + |
1816 | +#define ZEITGEIST_TYPE_DATA_SOURCE (zeitgeist_data_source_get_type ()) |
1817 | + |
1818 | +#define ZEITGEIST_DATA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ |
1819 | + ZEITGEIST_TYPE_DATA_SOURCE, ZeitgeistDataSource)) |
1820 | + |
1821 | +#define ZEITGEIST_DATA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \ |
1822 | + ZEITGEIST_TYPE_DATA_SOURCE, ZeitgeistDataSourceClass)) |
1823 | + |
1824 | +#define ZEITGEIST_IS_DATA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ |
1825 | + ZEITGEIST_TYPE_DATA_SOURCE)) |
1826 | + |
1827 | +#define ZEITGEIST_IS_DATA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \ |
1828 | + ZEITGEIST_TYPE_DATA_SOURCE)) |
1829 | + |
1830 | +#define ZEITGEIST_DATA_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ |
1831 | + ZEITGEIST_TYPE_DATA_SOURCE, ZeitgeistDataSourceClass)) |
1832 | + |
1833 | +typedef struct _ZeitgeistDataSource ZeitgeistDataSource; |
1834 | +typedef struct _ZeitgeistDataSourceClass ZeitgeistDataSourceClass; |
1835 | + |
1836 | +struct _ZeitgeistDataSourceClass |
1837 | +{ |
1838 | + GInitiallyUnownedClass parent_class; |
1839 | +}; |
1840 | + |
1841 | + |
1842 | +struct _ZeitgeistDataSource |
1843 | +{ |
1844 | + GInitiallyUnowned parent_instance; |
1845 | +}; |
1846 | + |
1847 | +GType zeitgeist_data_source_get_type (void); |
1848 | + |
1849 | +ZeitgeistDataSource* zeitgeist_data_source_new (void); |
1850 | +ZeitgeistDataSource* zeitgeist_data_source_new_full (const gchar *id, |
1851 | + const gchar *name, |
1852 | + const gchar *desc, |
1853 | + GPtrArray *event_templates); |
1854 | + |
1855 | +const gchar* zeitgeist_data_source_get_unique_id (ZeitgeistDataSource *src); |
1856 | +void zeitgeist_data_source_set_unique_id (ZeitgeistDataSource *src, |
1857 | + const gchar* unique_id); |
1858 | + |
1859 | +const gchar* zeitgeist_data_source_get_name (ZeitgeistDataSource *src); |
1860 | +void zeitgeist_data_source_set_name (ZeitgeistDataSource *src, |
1861 | + const gchar *name); |
1862 | + |
1863 | +const gchar* zeitgeist_data_source_get_description (ZeitgeistDataSource *src); |
1864 | +void zeitgeist_data_source_set_description (ZeitgeistDataSource *src, |
1865 | + const gchar *description); |
1866 | + |
1867 | +GPtrArray* zeitgeist_data_source_get_event_templates (ZeitgeistDataSource *src); |
1868 | +void zeitgeist_data_source_set_event_templates (ZeitgeistDataSource *src, |
1869 | + GPtrArray *event_templates); |
1870 | + |
1871 | +gboolean zeitgeist_data_source_is_running (ZeitgeistDataSource *src); |
1872 | +void zeitgeist_data_source_set_running (ZeitgeistDataSource *src, |
1873 | + gboolean running); |
1874 | + |
1875 | +gint64 zeitgeist_data_source_get_timestamp (ZeitgeistDataSource *src); |
1876 | +void zeitgeist_data_source_set_timestamp (ZeitgeistDataSource *src, |
1877 | + gint64 timestamp); |
1878 | + |
1879 | +gboolean zeitgeist_data_source_is_enabled (ZeitgeistDataSource *src); |
1880 | +void zeitgeist_data_source_set_enabled (ZeitgeistDataSource *src, |
1881 | + gboolean enabled); |
1882 | + |
1883 | +G_END_DECLS |
1884 | + |
1885 | +#endif /* _ZEITGEIST_DATA_SOURCE_H_ */ |
1886 | |
1887 | === modified file 'src/zeitgeist-eggdbusconversions.c' |
1888 | --- src/zeitgeist-eggdbusconversions.c 2010-05-09 00:13:04 +0000 |
1889 | +++ src/zeitgeist-eggdbusconversions.c 2010-07-23 10:53:42 +0000 |
1890 | @@ -298,3 +298,54 @@ |
1891 | |
1892 | return result; |
1893 | } |
1894 | + |
1895 | +ZeitgeistDataSource* |
1896 | +_egg_zeitgeist_data_source_to_zeitgeist_data_source (EggZeitgeistDataSource *data_source) |
1897 | +{ |
1898 | + ZeitgeistDataSource *result; |
1899 | + GPtrArray *templates; |
1900 | + gboolean running; |
1901 | + gboolean enabled; |
1902 | + gint64 timestamp; |
1903 | + |
1904 | + g_return_val_if_fail (EGG_ZEITGEIST_IS_DATA_SOURCE (data_source), NULL); |
1905 | + |
1906 | + templates = _egg_zeitgeist_events_to_zeitgeist_events (egg_zeitgeist_data_source_get_event_templates (data_source)); |
1907 | + |
1908 | + result = zeitgeist_data_source_new_full ( |
1909 | + egg_zeitgeist_data_source_get_unique_id (data_source), |
1910 | + egg_zeitgeist_data_source_get_name (data_source), |
1911 | + egg_zeitgeist_data_source_get_description (data_source), |
1912 | + templates); |
1913 | + |
1914 | + running = egg_zeitgeist_data_source_get_running (data_source); |
1915 | + enabled = egg_zeitgeist_data_source_get_enabled (data_source); |
1916 | + timestamp = egg_zeitgeist_data_source_get_last_seen (data_source); |
1917 | + |
1918 | + zeitgeist_data_source_set_running (result, running); |
1919 | + zeitgeist_data_source_set_timestamp (result, timestamp); |
1920 | + zeitgeist_data_source_set_enabled (result, enabled); |
1921 | + |
1922 | + return result; |
1923 | +} |
1924 | + |
1925 | +GPtrArray* |
1926 | +_egg_zeitgeist_data_sources_to_zeitgeist_data_sources (EggDBusArraySeq *data_sources) |
1927 | +{ |
1928 | + GPtrArray *result; |
1929 | + EggZeitgeistDataSource *source; |
1930 | + gint i, num_sources; |
1931 | + |
1932 | + g_return_val_if_fail (EGG_DBUS_IS_ARRAY_SEQ (data_sources), NULL); |
1933 | + |
1934 | + num_sources = egg_dbus_array_seq_get_size (data_sources); |
1935 | + result = g_ptr_array_sized_new (num_sources); |
1936 | + for (i = 0; i < num_sources; i++) |
1937 | + { |
1938 | + source = EGG_ZEITGEIST_DATA_SOURCE (egg_dbus_array_seq_get (data_sources, i)); |
1939 | + g_ptr_array_add (result, _egg_zeitgeist_data_source_to_zeitgeist_data_source (source)); |
1940 | + } |
1941 | + |
1942 | + return result; |
1943 | +} |
1944 | + |
1945 | |
1946 | === modified file 'src/zeitgeist-eggdbusconversions.h' |
1947 | --- src/zeitgeist-eggdbusconversions.h 2010-04-19 14:58:18 +0000 |
1948 | +++ src/zeitgeist-eggdbusconversions.h 2010-07-23 10:53:42 +0000 |
1949 | @@ -22,8 +22,10 @@ |
1950 | #define _ZEITGEIST_EGGDBUSCONVERSIONS_H_ |
1951 | |
1952 | #include <glib-object.h> |
1953 | +#include "zeitgeist-data-source.h" |
1954 | #include "zeitgeist-event.h" |
1955 | #include "zeitgeist-timerange.h" |
1956 | +#include "eggzeitgeistdatasource.h" |
1957 | #include "eggzeitgeistevent.h" |
1958 | #include "eggzeitgeisttimerange.h" |
1959 | #include "eggzeitgeisteventdataoffset.h" |
1960 | @@ -40,12 +42,16 @@ |
1961 | |
1962 | EggDBusArraySeq* _zeitgeist_events_to_egg_zeitgeist_events (GPtrArray *events); |
1963 | |
1964 | -GPtrArray* _zeitgeist_events_from_valist (va_list events); |
1965 | +GPtrArray* _zeitgeist_events_from_valist (va_list events); |
1966 | |
1967 | EggZeitgeistTimeRange* _zeitgeist_time_range_to_egg_zeitgeist_time_range (ZeitgeistTimeRange *time_range); |
1968 | |
1969 | ZeitgeistTimeRange* _egg_zeitgeist_time_range_to_zeitgeist_time_range (EggZeitgeistTimeRange *time_range); |
1970 | |
1971 | +ZeitgeistDataSource* _egg_zeitgeist_data_source_to_zeitgeist_data_source (EggZeitgeistDataSource *data_source); |
1972 | + |
1973 | +GPtrArray* _egg_zeitgeist_data_sources_to_zeitgeist_data_sources (EggDBusArraySeq *data_sources); |
1974 | + |
1975 | G_END_DECLS |
1976 | |
1977 | -#endif /* _ZEITGEIST_EGGDBUSCONVERSIONS_H_ */ |
1978 | \ No newline at end of file |
1979 | +#endif /* _ZEITGEIST_EGGDBUSCONVERSIONS_H_ */ |
1980 | |
1981 | === modified file 'src/zeitgeist.h' |
1982 | --- src/zeitgeist.h 2010-06-16 13:32:40 +0000 |
1983 | +++ src/zeitgeist.h 2010-07-23 10:53:42 +0000 |
1984 | @@ -23,6 +23,8 @@ |
1985 | |
1986 | #define _ZEITGEIST_H_INSIDE_ |
1987 | |
1988 | +#include <zeitgeist-data-source.h> |
1989 | +#include <zeitgeist-data-source-registry.h> |
1990 | #include <zeitgeist-enums.h> |
1991 | #include <zeitgeist-enumtypes.h> |
1992 | #include <zeitgeist-event.h> |
1993 | @@ -39,4 +41,4 @@ |
1994 | |
1995 | #undef _ZEITGEIST_H_INSIDE_ |
1996 | |
1997 | -#endif /* _ZEITGEIST_H_ */ |
1998 | \ No newline at end of file |
1999 | +#endif /* _ZEITGEIST_H_ */ |
2000 | |
2001 | === modified file 'tests/Makefile.am' |
2002 | --- tests/Makefile.am 2010-06-17 11:26:15 +0000 |
2003 | +++ tests/Makefile.am 2010-07-23 10:53:42 +0000 |
2004 | @@ -18,6 +18,8 @@ |
2005 | test.desktop |
2006 | |
2007 | helper_sources = \ |
2008 | + $(top_srcdir)/src/eggzeitgeistdatasource.c \ |
2009 | + $(top_srcdir)/src/eggzeitgeistdatasource.h \ |
2010 | $(top_srcdir)/src/eggzeitgeistevent.c \ |
2011 | $(top_srcdir)/src/eggzeitgeistevent.h \ |
2012 | $(top_srcdir)/src/eggzeitgeisttimerange.c \ |
2013 | |
2014 | === modified file 'tests/test-eggdbusconversions.c' |
2015 | --- tests/test-eggdbusconversions.c 2010-05-04 16:55:56 +0000 |
2016 | +++ tests/test-eggdbusconversions.c 2010-07-23 10:53:42 +0000 |
2017 | @@ -19,9 +19,11 @@ |
2018 | |
2019 | #include <glib.h> |
2020 | #include <glib-object.h> |
2021 | +#include "zeitgeist-data-source.h" |
2022 | #include "zeitgeist-event.h" |
2023 | #include "zeitgeist-subject.h" |
2024 | #include "zeitgeist-eggdbusconversions.h" |
2025 | +#include "zeitgeist-timestamp.h" |
2026 | |
2027 | typedef struct |
2028 | { |
2029 | @@ -410,6 +412,74 @@ |
2030 | } |
2031 | |
2032 | static void |
2033 | +test_egg_to_z_ds_empty (Fixture *fix, gconstpointer data) |
2034 | +{ |
2035 | + ZeitgeistDataSource *zds; |
2036 | + EggZeitgeistDataSource *eggds; |
2037 | + EggDBusArraySeq *templates; |
2038 | + |
2039 | + templates = egg_dbus_array_seq_new (EGG_ZEITGEIST_TYPE_DATA_SOURCE, |
2040 | + g_object_unref, |
2041 | + NULL, |
2042 | + NULL); |
2043 | + |
2044 | + eggds = egg_zeitgeist_data_source_new ("", "", "", templates, |
2045 | + FALSE, 0, FALSE); |
2046 | + |
2047 | + zds = _egg_zeitgeist_data_source_to_zeitgeist_data_source (eggds); |
2048 | + |
2049 | + /* We unref the eggds here to assert that we have completely separated |
2050 | + * the memory of the converted data source */ |
2051 | + g_object_unref (eggds); |
2052 | + g_object_unref (templates); |
2053 | + |
2054 | + g_assert_cmpstr ("", ==, zeitgeist_data_source_get_unique_id (zds)); |
2055 | + g_assert_cmpstr ("", ==, zeitgeist_data_source_get_name (zds)); |
2056 | + g_assert_cmpstr ("", ==, zeitgeist_data_source_get_description (zds)); |
2057 | + g_assert_cmpint (0, ==, zeitgeist_data_source_is_running (zds)); |
2058 | + g_assert_cmpint (0, ==, zeitgeist_data_source_is_enabled (zds)); |
2059 | + g_assert_cmpint (0, ==, zeitgeist_data_source_get_timestamp (zds)); |
2060 | + |
2061 | + g_object_unref (zds); |
2062 | +} |
2063 | + |
2064 | +static void |
2065 | +test_egg_to_z_ds_full (Fixture *fix, gconstpointer data) |
2066 | +{ |
2067 | + ZeitgeistDataSource *zds; |
2068 | + EggZeitgeistDataSource *eggds; |
2069 | + EggDBusArraySeq *templates; |
2070 | + gint64 timestamp; |
2071 | + |
2072 | + templates = egg_dbus_array_seq_new (EGG_ZEITGEIST_TYPE_DATA_SOURCE, |
2073 | + g_object_unref, |
2074 | + NULL, |
2075 | + NULL); |
2076 | + timestamp = zeitgeist_timestamp_for_now (); |
2077 | + |
2078 | + eggds = egg_zeitgeist_data_source_new ("id", "name", "desc", templates, |
2079 | + FALSE, |
2080 | + timestamp, |
2081 | + TRUE); |
2082 | + |
2083 | + zds = _egg_zeitgeist_data_source_to_zeitgeist_data_source (eggds); |
2084 | + |
2085 | + /* We unref the eggds here to assert that we have completely separated |
2086 | + * the memory of the converted data source */ |
2087 | + g_object_unref (eggds); |
2088 | + g_object_unref (templates); |
2089 | + |
2090 | + g_assert_cmpstr ("id", ==, zeitgeist_data_source_get_unique_id (zds)); |
2091 | + g_assert_cmpstr ("name", ==, zeitgeist_data_source_get_name (zds)); |
2092 | + g_assert_cmpstr ("desc", ==, zeitgeist_data_source_get_description (zds)); |
2093 | + g_assert_cmpint (0, ==, zeitgeist_data_source_is_running (zds)); |
2094 | + g_assert_cmpint (0, !=, zeitgeist_data_source_is_enabled (zds)); |
2095 | + g_assert_cmpint (timestamp, ==, zeitgeist_data_source_get_timestamp (zds)); |
2096 | + |
2097 | + g_object_unref (zds); |
2098 | +} |
2099 | + |
2100 | +static void |
2101 | test_timestamp (Fixture *fix, gconstpointer data) |
2102 | { |
2103 | ZeitgeistEvent *zev; |
2104 | @@ -469,8 +539,14 @@ |
2105 | g_test_add ("/Zeitgeist/EggDBusConversions/EggToZEmpty", Fixture, NULL, |
2106 | setup, test_egg_to_z_empty, teardown); |
2107 | |
2108 | + g_test_add ("/Zeitgeist/EggDBusConversions/EggToZDSFull", Fixture, NULL, |
2109 | + setup, test_egg_to_z_ds_full, teardown); |
2110 | + |
2111 | + g_test_add ("/Zeitgeist/EggDBusConversions/EggToZDSEmpty", Fixture, NULL, |
2112 | + setup, test_egg_to_z_ds_empty, teardown); |
2113 | + |
2114 | g_test_add ("/Zeitgeist/EggDBusConversions/Timestamp", Fixture, NULL, |
2115 | setup, test_timestamp, teardown); |
2116 | |
2117 | return g_test_run(); |
2118 | -} |
2119 | \ No newline at end of file |
2120 | +} |
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...