I am tring to write a Banshee 1.4.3 spammer in c on Linux Debian Lenny using C and dbus-glib.
But I can't figure out how to grab the track information right. x.x I get an error on compile, stating:
spammer.c:57: error: dereferencing pointer to incomplete type.
Code:
#include <stdio.h>
#include <dbus/dbus-glib.h>
#include <string.h>
void banshee_get(GHashTable *table, const char *key, char *dest)
{
GValue* value = (GValue*) g_hash_table_lookup(table, key);
if (value != NULL && G_VALUE_HOLDS_STRING(value)) {
strncpy(dest, g_value_get_string(value), strlen-1);
}
}
int main (int argc, char **argv)
{
DBusGConnection *connection;
GError *error;
DBusGProxy *proxy;
struct TrackInfo *tinfo;
GHashTable* table;
g_type_init ();
error = NULL;
connection = dbus_g_bus_get (DBUS_BUS_SESSION,
&error);
if (connection == NULL)
{
g_printerr ("Failed to open connection to bus: %s\n",
error->message);
g_error_free (error);
exit (1);
}
/* Create a proxy object for the "bus driver" (name "org.bansheeproject.Banshee") */
proxy = dbus_g_proxy_new_for_name (connection,
"org.bansheeproject.Banshee",
"/org/bansheeproject/Banshee/PlayerEngine",
"org.bansheeproject.Banshee.PlayerEngine");
/* Call GetCurrentTrack method, wait for reply */
error = NULL;
if (!dbus_g_proxy_call (proxy, "GetCurrentTrack", &error, G_TYPE_INVALID,
dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &table,
G_TYPE_INVALID))
{
g_printerr ("Error: %s\n", error->message);
g_error_free (error);
exit (1);
}
/* Print the results */
banshee_get(table, "album", tinfo->album);
g_object_unref (proxy);
return 0;
}
gcc `pkg-config --libs --cflags glib-2.0 dbus-glib-1` spammer.c