~ubuntu-branches/ubuntu/trusty/libzeitgeist/trusty

« back to all changes in this revision

Viewing changes to src/zeitgeist-data-source.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2011-02-24 10:48:37 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20110224104837-3vwwxn3x6549e5j7
Tags: 0.3.4-0ubuntu1
* New upstream release:
  - Remove libzeitgeist GIO module - zeitgeist-datahub does the same now
    (LP: #724199)
  - Order of subject parameters is wrong in 0.3 series (LP: #718472)
* debian/control, debian/libzeitgeist-gio.install:
  - remove libzeitgeist-gio package
* debian/libzeitgeist-1.0-1.symbols:
  - updated

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
/**
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
 
116
 *         will be consumed.
116
117
 *
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().
119
120
 *
120
121
 * Returns: A newly allocated #ZeitgeistDataSource filled with the metadata and
121
122
 *          event templates described by @src. The returned data source will
138
139
 
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, &timestamp, &enabled);
144
145
 
405
406
}
406
407
 
407
408
/**
 
409
 * zeitgeist_data_source_to_variant_full:
 
410
 * @events: A #ZeitgeistDataSource. If this is a
 
411
 *          floating reference it will be consumed
 
412
 *
 
413
 * Convert a #ZeitgeistDataSource to a #GVariant with signature
 
414
 * #ZEITGEIST_DATA_SOURCE_WITH_INFO_VARIANT_SIGNATURE.
 
415
 *
 
416
 * Returns: A floating reference to a #GVariant as described above. Unless the
 
417
 *          floating reference is consumed somewhere you must free it with
 
418
 *          g_variant_unref().
 
419
 */
 
420
GVariant*
 
421
zeitgeist_data_source_to_variant_full (ZeitgeistDataSource *src)
 
422
{
 
423
  GVariantBuilder      b;
 
424
  GPtrArray           *event_templates;
 
425
  GVariant            *vevent_templates;
 
426
  const gchar         *str;
 
427
 
 
428
  g_return_val_if_fail (ZEITGEIST_IS_DATA_SOURCE (src), NULL);
 
429
 
 
430
  g_object_ref_sink (src);
 
431
  g_variant_builder_init (&b, ZEITGEIST_DATA_SOURCE_WITH_INFO_VARIANT_TYPE);
 
432
 
 
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 : ""));
 
437
 
 
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 */);
 
443
 
 
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));
 
448
 
 
449
  /* Clean up */
 
450
  g_object_unref (src);
 
451
 
 
452
  return g_variant_builder_end (&b);
 
453
}
 
454
 
 
455
/**
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 */);
442
490
 
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));
447
 
 
448
491
  /* Clean up */
449
492
  g_object_unref (src);
450
493
 
482
525
    {
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);
488
531
    }
498
541
/**
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.
503
547
 *
504
548
 * Returns: A reference to a #GPtrArray of #ZeitgeistDataSource<!-- -->s.
505
549
 *          All the events will be floating references, and the