hi all,
I have trimmed the program comes with gnome. The program compiles but doesnt give any output.There may be some problem.here I am attaching the code.
#include<stdlib.h>
#include<stdio.h>
#include<dbus-1.0/dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include <string.h>
#include<glib-object.h>
#include "marshal.h"
extern void marshal_VOID__STRING_UINT_INT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
extern void marshal_VOID__STRING_STRING (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
static void remote_device_found(DBusGProxy *object, const char *address,
const unsigned int class, const int rssi, gpointer user_data)
{
//DBusGConnection *conn = user_data;
/* bluetooth_device_store_add_device(BLUETOOTH_DEVICE_STORE(store), address, class, rssi);*/
printf("(%s )\n :Remote device address found",address);
#if 0
object = dbus_g_proxy_new_for_name(conn, "org.bluez",
"/org/bluez/hci0", "org.bluez.Test");
dbus_g_proxy_call(object, "AuditRemoteDevice", NULL, G_TYPE_STRING, address, G_TYPE_INVALID);
#endif
}
static void discovery_started(DBusGProxy *object, gpointer user_data)
{
printf("devices discovered: DiscoveryStarted()\n");
}
static void setup_dbus(DBusGConnection *conn)
{
/*creating the proxy object*/
DBusGProxy *object;
/*creating a message and sending a message to the remote object blocking call*/
object = dbus_g_proxy_new_for_name(conn, "
org.bluez", "/org/bluez/hci0", "org.bluez.Adapter");
/*registering a marshal */
dbus_g_object_register_marshaller(marshal_VOID__STRING_UINT_INT, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID);
dbus_g_proxy_add_signal(object, "RemoteDeviceFound", G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(object, "RemoteDeviceFound", G_CALLBACK(remote_device_found), conn, NULL);
dbus_g_proxy_add_signal(object, "DiscoveryStarted", G_TYPE_INVALID);
dbus_g_proxy_connect_signal(object, "DiscoveryStarted", G_CALLBACK(discovery_started), NULL, NULL);
}
int main(int argc, char *argv[])
{
DBusGConnection *conn;
GError *error = NULL;
g_type_init();
/*getting the system bus connection*/
conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
if (error != NULL) {
g_printerr("Connecting to system bus failed: %s\n",
error->message);
g_error_free(error);
exit(EXIT_FAILURE);
}
setup_dbus(conn);
DBusGProxy *object;
object = dbus_g_proxy_new_for_name(conn, "org.bluez",
"/org/bluez/hci0", "org.bluez.Adapter
");
dbus_g_proxy_call(object, "DiscoverDevices", &error,
G_TYPE_INVALID, G_TYPE_INVALID);
if (error != NULL) {
printf ("\n Error ... message is %s",error->message);
}
dbus_g_connection_unref(conn);
return 0;
can some one figure out the problem.
Thanks
Rohit