Bug 18220 - Add tp_asv_set_… for types we generally permit in "a{sv}"s.
Summary: Add tp_asv_set_… for types we generally permit in "a{sv}"s.
Status: RESOLVED FIXED
Alias: None
Product: Telepathy
Classification: Unclassified
Component: tp-glib (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Telepathy bugs list
QA Contact: Telepathy bugs list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-25 03:16 UTC by Will Thompson
Modified: 2009-03-05 02:51 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Will Thompson 2008-10-25 03:16:14 UTC
Currently, to pull values out of an a{sv} in C we can use tp_asv_get_string and friends, but to populate one we need to say tp_g_value_slice_new (type); g_value_set_...; g_hash_table_insert (asv, key, value); which is kind of verbose.

I suspect we should also have tp_asv_new () which creates a GHashTable with appropriate key and value destructors.

tp_asv_set_handle (cf. tp_message_set_handle) would be nice, but would involve using a type other than GHashTable (or some incredible GValue trickery behind the curtains) for a{sv}s which might end in tears.
Comment 1 Simon McVittie 2009-03-05 02:51:28 UTC
I think this is fixed in a different way by my 'sliced-woot' branch, which I just merged. This adds functions like tp_g_value_slice_new_uint, allowing for this syntax (code copied from one of the tests):

    GHashTable *details = g_hash_table_new_full (g_str_hash, g_str_equal,
        NULL, (GDestroyNotify) tp_g_value_slice_free);
    ...
    g_hash_table_insert (details, "actor", tp_g_value_slice_new_uint (camel2));
    ...
    g_hash_table_insert (details, "change-reason",
        tp_g_value_slice_new_uint (TP_CHANNEL_GROUP_CHANGE_REASON_KICKED));

This avoids the problem that tp_asv_set_foo needs to know how the memory for the GValue is meant to be allocated (g_slice_new vs. g_malloc), by making it explicit.

wjt agrees that this is sufficient, so I'm closing this bug.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.