<br><br><div class="gmail_quote">On Tue, Apr 14, 2009 at 8:43 PM, Fujitaka Daidouji <span dir="ltr"><<a href="mailto:fujitaka.daidouji@gmail.com">fujitaka.daidouji@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have been tring to awhile now to figure this out. Tring to recieve track information from banshee-1. The field type is Dict of {String, variant} CurrentTrack. <-- So far I have not been successful on get information from it. This is what I tried. The for outputs the keys from the hashtable, but not values beside it. All the values are things like @ < ( symbols. <br>
<br>#include <stdio.h><br>#include <dbus/dbus-glib.h><br>#include <string.h><br><br><br> banshee_hash_str(GHashTable *table, const char *key, char *dest)<br> {<br> GValue* value = (GValue*) g_hash_table_lookup(table, key);<br>
//if (value != NULL && G_VALUE_HOLDS_STRING(value)) {<br> strncpy(dest, g_value_get_string(value), strlen(g_value_get_string(value)));<br> //}<br><br> }<br><br>static void print_hash_value (gpointer key, gpointer val, gpointer data)<br>
{<br> printf ("%s -> %s\n", (char *) key, (char *) val);<br>}<br><br>int main (int argc, char **argv)<br>{<br> DBusGConnection *connection;<br> GError *error;<br> DBusGProxy *proxy;<br> GHashTable* table;<br>
<br> struct TrackInfo {<br> char *album;<br> };<br> struct TrackInfo ti;<br><br> g_type_init ();<br><br> error = NULL;<br> connection = dbus_g_bus_get (DBUS_BUS_SESSION,<br> &error);<br>
if (connection == NULL)<br> {<br> g_printerr ("Failed to open connection to bus: %s\n",<br> error->message);<br> g_error_free (error);<br> exit (1);<br> }<br><br> /* Create a proxy object for the "bus driver" (name "org.bansheeproject.Banshee") */<br>
<br> proxy = dbus_g_proxy_new_for_name (connection,<br> "org.bansheeproject.Banshee",<br> "/org/bansheeproject/Banshee/PlayerEngine",<br>
"org.bansheeproject.Banshee.PlayerEngine");<br><br> /* Call GetCurrentTrack method, wait for reply */<br> error = NULL;<br> <br> if (!dbus_g_proxy_call (proxy, "GetCurrentTrack", &error, G_TYPE_INVALID,<br>
dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &table,<br> G_TYPE_INVALID))<br> {<br> <br> g_printerr ("Error: %s\n", error->message);<br>
g_error_free (error);<br> exit (1);<br> }<br><br> /* Print the results */<br>g_hash_table_foreach (table, print_hash_value, NULL);<br>//banshee_hash_str(table, "album", ti->album);<br><br> g_object_unref (proxy);<br>
<br> return 0;<br>}<br><br>Using to compile it: <br><span><span>gcc `pkg-config --libs --cflags glib-2.0 dbus-glib-1` spammer.c<br><br>Maby someone can help me on this. Thanks.<br></span></span>
</blockquote></div><br>