Hi Guanhua,
On 07/04/2013 02:26 AM, Guanhua Wang wrote:
Hi Mark,
Thanks for the help, it is indeed painful to do this in C since I've
known nothing about glib and I have couple of more questions regarding
the dms-info.c file.
1. I made change like this :
g_variant_new("(s)", ""), ----->
g_variant_new("(suu@ass)", "Type
derivedfrom \"audio\"", 0, 3, filterv, "-DisplayName"),
and within prv_dump_container_props(GVariant *props) function (for
printing),
g_variant_iter_next(&iter, "{sv}", &key, &value)) ::
"{sv}"
------> "a{sv}"
I got top three files' information, but the whole information shows up
for 3 time like this:
([{'DisplayName': <'first'>}, {'DisplayName':
<'second'>},
{'DisplayName': <'third'>}], 3)
([{'DisplayName': <'first'>}, {'DisplayName':
<'second'>},
{'DisplayName': <'third'>}], 3)
([{'DisplayName': <'first'>}, {'DisplayName':
<'second'>},
{'DisplayName': <'third'>}], 3)
You need to check the documentation for SearchObjectsEx. It returns a
tuple containing an array and an integer. The array contains all the
requested objects and the integer indicates the total number of objects
in the DMS that match your search string. Each element in the array is
a dictionary of objects, so you need two loops, one for iterating
through the array elements and one to iterate through the properties of
each element. It should look something like this
while (g_variant_iter_next(&iter, "@a{sv}", &item)) {
(void) g_variant_iter_init(&iter2, item);
while (g_variant_iter_next(&iter2, "{&sv}", &key, &value)) {
formatted_value = g_variant_print(value, FALSE);
printf("%s: %s\n", key, formatted_value);
g_free(formatted_value);
g_variant_unref(value);
}
g_variant_unref(item);
}
which is weird. And also I got notification like this:
GLib-CRITICAL **: g_variant_unref: assertion `value->ref_count > 0' failed
Do you know how to fix this one?
2. When I tried to compile the dms-info.c file individually like this:
gcc dms-info.c -o test `pkg-config --cflags --libs glib-2.0`
there is a lot of "undefined reference " errors like:
/tmp/ccQth59A.o: In function `prv_dms_info_free':
dms-info.c:(.text+0xa3): undefined reference to `g_object_unref'
dms-info.c:(.text+0xf4): undefined reference to `g_object_unref'
dms-info.c:(.text+0x26a): undefined reference to
`g_dbus_proxy_get_object_path'
dms-info.c:(.text+0x2a9): undefined reference to
`g_cancellable_is_cancelled'
dms-info.c:(.text+0x2f0): undefined reference to `g_dbus_proxy_call_finish'
do you know what is the problem and how to compile the dms-info.c
individually?
You probably just need to add gio-2.0 to your call to pkg-config
Best Regards,
Mark
Any help would be most appreciated!
Regards,
Guanhua Wang
On Wed, Jul 3, 2013 at 12:40 AM, Mark Ryan <mark.d.ryan(a)linux.intel.com
<mailto:mark.d.ryan@linux.intel.com>> wrote:
Hi Guanhua,
On 07/02/2013 06:54 PM, Guanhua Wang wrote:
...
I want to make some change to this function in order to realize the
search function to retrieve the media files, the changing I've
made are:
1 DMS_INFO_PROPERTIES_IF ------> org.gnome.UPnP.MediaContainer2
2 DMS_INFO_GET_ALL ---------> SearchObjectsEx
3 g_variant_new("(s)", ""), ----------->
g_variant_new("(s)",
"Type
derivedfrom \"*\"", 0, 10,
"[\"DisplayName\"]", "-DisplayName"),
I think there are two problems with your code.
Firstly, the search query is incorrect. From the looks of things
you are simply trying to retrieve the first 10 media objects on the
server sorted in reverse order of DisplayName. Is this correct? If
so you can simply use the search string "*"
Secondly, the parameters for Search are different for the parameters
for GetAll, so you need to change the signature of the GVariant
argument you pass to SearchObjectsEx. It should be something like
this (Note I haven't actually tested this)
const gchar *filters[] = {"DisplayName", NULL};
GVariant* filterv = g_variant_new_strv(filters, -1);
g_variant_new("(suu@ass)", "*", 0, 10, filterv,
"-DisplayName"),
This stuff is a real pain to do in C isn't it?
Best Regards,
Mark
_________________________________________________
dLeyna mailing list
dLeyna(a)lists.01.org <mailto:dLeyna@lists.01.org>
https://lists.01.org/mailman/__listinfo/dleyna
<
https://lists.01.org/mailman/listinfo/dleyna>