112
112
* zeitgeist_data_source_new_from_variant:
113
113
* @event: A #GVariant with signature defined in
114
* #ZEITGEIST_DATA_SOURCE_VARIANT_SIGNATURE. If @src is a floating
115
* reference the floating reference will be consumed.
114
* #ZEITGEIST_DATA_SOURCE_WITH_INFO_VARIANT_SIGNATURE.
115
* If @src is a floating reference the floating reference
117
118
* Parse the data in a #GVariant and build a #ZeitgeistDataSource from it.
118
* The reverse operation of this is zeitgeist_data_source_to_variant().
119
* The reverse operation of this is zeitgeist_data_source_to_variant_full().
120
121
* Returns: A newly allocated #ZeitgeistDataSource filled with the metadata and
121
122
* event templates described by @src. The returned data source will
139
140
/* Parse the variant */
140
141
g_variant_ref_sink (src);
141
g_variant_get (src, ZEITGEIST_DATA_SOURCE_VARIANT_SIGNATURE,
142
g_variant_get (src, ZEITGEIST_DATA_SOURCE_WITH_INFO_VARIANT_SIGNATURE,
142
143
&unique_id, &name, &description,
143
144
NULL, &running, ×tamp, &enabled);
409
* zeitgeist_data_source_to_variant_full:
410
* @events: A #ZeitgeistDataSource. If this is a
411
* floating reference it will be consumed
413
* Convert a #ZeitgeistDataSource to a #GVariant with signature
414
* #ZEITGEIST_DATA_SOURCE_WITH_INFO_VARIANT_SIGNATURE.
416
* Returns: A floating reference to a #GVariant as described above. Unless the
417
* floating reference is consumed somewhere you must free it with
421
zeitgeist_data_source_to_variant_full (ZeitgeistDataSource *src)
424
GPtrArray *event_templates;
425
GVariant *vevent_templates;
428
g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE (src), NULL);
430
g_object_ref_sink (src);
431
g_variant_builder_init (&b, ZEITGEIST_DATA_SOURCE_WITH_INFO_VARIANT_TYPE);
433
/* Add static metadata */
434
g_variant_builder_add (&b, "s", (str = zeitgeist_data_source_get_unique_id(src), str ? str : ""));
435
g_variant_builder_add (&b, "s", (str = zeitgeist_data_source_get_name(src), str ? str : ""));
436
g_variant_builder_add (&b, "s", (str = zeitgeist_data_source_get_description(src), str ? str : ""));
438
/* Add event templates */
439
event_templates = g_ptr_array_ref (
440
zeitgeist_data_source_get_event_templates (src));
441
vevent_templates = zeitgeist_events_to_variant (event_templates);
442
g_variant_builder_add_value (&b, vevent_templates /* own ref */);
444
/* Add volatile metadata */
445
g_variant_builder_add (&b, "b", zeitgeist_data_source_is_running(src));
446
g_variant_builder_add (&b, "x", zeitgeist_data_source_get_timestamp(src));
447
g_variant_builder_add (&b, "b", zeitgeist_data_source_is_enabled(src));
450
g_object_unref (src);
452
return g_variant_builder_end (&b);
408
456
* zeitgeist_data_source_to_variant:
409
457
* @events: A #ZeitgeistDataSource. If this is a
410
458
* floating reference it will be consumed
440
488
vevent_templates = zeitgeist_events_to_variant (event_templates);
441
489
g_variant_builder_add_value (&b, vevent_templates /* own ref */);
443
/* Add volatile metadata */
444
g_variant_builder_add (&b, "b", zeitgeist_data_source_is_running(src));
445
g_variant_builder_add (&b, "x", zeitgeist_data_source_get_timestamp(src));
446
g_variant_builder_add (&b, "b", zeitgeist_data_source_is_enabled(src));
449
492
g_object_unref (src);
483
526
src = ZEITGEIST_DATA_SOURCE (g_ptr_array_index (sources, i));
484
527
g_object_ref_sink (src);
485
vsrc = zeitgeist_data_source_to_variant (src);
528
vsrc = zeitgeist_data_source_to_variant_full (src);
486
529
g_variant_builder_add_value (&b, vsrc);
487
530
g_object_unref (src);
499
542
* zeitgeist_data_sources_from_variant:
500
543
* @sources: A #GVariant with signature as an array of
501
* #ZEITGEIST_DATA_SOURCE_VARIANT_SIGNATURE. If @sources is floating
502
* this method will consume the floating reference.
544
* #ZEITGEIST_DATA_SOURCE_WITH_INFO_VARIANT_SIGNATURE.
545
* If @sources is floating this method will consume
546
* the floating reference.
504
548
* Returns: A reference to a #GPtrArray of #ZeitgeistDataSource<!-- -->s.
505
549
* All the events will be floating references, and the