710
713
GVariantBuilder itembuilder;
711
g_variant_builder_init(&itembuilder, G_VARIANT_TYPE_ARRAY);
714
gboolean item_init = FALSE;
716
GVariantBuilder removeitembuilder;
717
gboolean removeitem_init = FALSE;
713
719
for (i = 0; i < priv->prop_array->len; i++) {
714
720
prop_idle_item_t * iitem = &g_array_index(priv->prop_array, prop_idle_item_t, i);
716
GVariantBuilder tuplebuilder;
717
g_variant_builder_init(&tuplebuilder, G_VARIANT_TYPE_TUPLE);
719
g_variant_builder_add_value(&tuplebuilder, g_variant_new_int32(iitem->id));
721
722
GVariantBuilder dictbuilder;
722
g_variant_builder_init(&dictbuilder, G_VARIANT_TYPE_DICTIONARY);
723
gboolean dictinit = FALSE;
725
GVariantBuilder removedictbuilder;
726
gboolean removedictinit = FALSE;
728
/* Go throught each item and see if it should go in the removal list
729
or the additive list. */
724
730
for (j = 0; j < iitem->array->len; j++) {
725
731
prop_idle_prop_t * iprop = &g_array_index(iitem->array, prop_idle_prop_t, j);
727
GVariant * entry = g_variant_new_dict_entry(g_variant_new_string(iprop->property),
728
g_variant_new_variant(iprop->variant));
730
g_variant_builder_add_value(&dictbuilder, entry);
733
g_variant_builder_add_value(&tuplebuilder, g_variant_builder_end(&dictbuilder));
735
g_variant_builder_add_value(&itembuilder, g_variant_builder_end(&tuplebuilder));
738
GVariant * megadata = g_variant_builder_end(&itembuilder);
733
if (iprop->variant != NULL) {
735
g_variant_builder_init(&dictbuilder, G_VARIANT_TYPE_DICTIONARY);
739
GVariant * entry = g_variant_new_dict_entry(g_variant_new_string(iprop->property),
740
g_variant_new_variant(iprop->variant));
742
g_variant_builder_add_value(&dictbuilder, entry);
744
if (!removedictinit) {
745
g_variant_builder_init(&removedictbuilder, G_VARIANT_TYPE_ARRAY);
746
removedictinit = TRUE;
749
g_variant_builder_add_value(&removedictbuilder, g_variant_new_string(iprop->property));
753
/* If we've got new values that are real values we need to add that
754
to the list of items to send the value of */
756
GVariantBuilder tuplebuilder;
757
g_variant_builder_init(&tuplebuilder, G_VARIANT_TYPE_TUPLE);
759
g_variant_builder_add_value(&tuplebuilder, g_variant_new_int32(iitem->id));
760
g_variant_builder_add_value(&tuplebuilder, g_variant_builder_end(&dictbuilder));
763
g_variant_builder_init(&itembuilder, G_VARIANT_TYPE_ARRAY);
767
g_variant_builder_add_value(&itembuilder, g_variant_builder_end(&tuplebuilder));
770
/* If we've got properties that have been removed then we need to add
771
them to the list of removed items */
772
if (removedictinit) {
773
GVariantBuilder tuplebuilder;
774
g_variant_builder_init(&tuplebuilder, G_VARIANT_TYPE_TUPLE);
776
g_variant_builder_add_value(&tuplebuilder, g_variant_new_int32(iitem->id));
777
g_variant_builder_add_value(&tuplebuilder, g_variant_builder_end(&removedictbuilder));
779
if (!removeitem_init) {
780
g_variant_builder_init(&removeitembuilder, G_VARIANT_TYPE_ARRAY);
781
removeitem_init = TRUE;
784
g_variant_builder_add_value(&removeitembuilder, g_variant_builder_end(&tuplebuilder));
788
GVariant * megadata[2];
791
megadata[0] = g_variant_builder_end(&itembuilder);
793
GError * error = NULL;
794
megadata[0] = g_variant_parse(G_VARIANT_TYPE("a(ia{sv})"), "[ ]", NULL, NULL, &error);
797
g_warning("Unable to parse '[ ]' as a 'a(ia{sv})': %s", error->message);
802
if (removeitem_init) {
803
megadata[1] = g_variant_builder_end(&removeitembuilder);
805
GError * error = NULL;
806
megadata[1] = g_variant_parse(G_VARIANT_TYPE("a(ia(s))"), "[ ]", NULL, NULL, &error);
809
g_warning("Unable to parse '[ ]' as a 'a(ia(s))': %s", error->message);
740
814
if (priv->dbusobject != NULL && priv->bus != NULL) {
741
815
g_dbus_connection_emit_signal(priv->bus,