Trouble using the dbus method GetDevices() with the glib library..



When I try to use the GetDevices() method using the glib library, I get the following error message:

** ERROR **: Error calling GetDevices: Unregistered object at path '/org/freedesktop/NetworkManager/Devices/0'

I've attached the program that causes the error.

I just want to make sure that this is a issue with the dbus-glib library, if so I'll report it.

Any help/advice would be appreciated.
#include <stdio.h>
#include <stdlib.h> // for exit()
#include <dbus/dbus-glib.h>

//	gcc `pkg-config --cflags --libs dbus-glib-1 glib-2.0`  nmtest.c -o nmtest

int main()
{
	DBusGConnection *connection;
	GError *error;
	DBusGProxy *proxy;
	GPtrArray *name_list;

	g_type_init ();

	error = NULL;
	connection = dbus_g_bus_get (DBUS_BUS_SYSTEM,
		                         &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.freedesktop.DBus") */
	proxy = NULL;
	proxy = dbus_g_proxy_new_for_name (connection,
													"org.freedesktop.NetworkManager",
													"/org/freedesktop/NetworkManager",
													"org.freedesktop.NetworkManager");


	if (proxy == NULL)		
	{
		g_error ("Error creating proxy\n");
	}



	/* Call GetDevices method, wait for reply */
	error = NULL;
	if (dbus_g_proxy_call(proxy, "GetDevices", &error, G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_ARRAY, &name_list, G_TYPE_INVALID) )
	{
		printf("Success\n");
		GString *list = g_string_new ("");
		const gchar *path;
		gint i;
		for (i = 0; i < name_list->len; i++)
		{
			path = dbus_g_proxy_get_path (g_ptr_array_index (name_list, i));
			i == 0 ? g_string_append (list, path) : (g_string_append_printf (list, ", %s", path));
		}
		g_debug("List: %s \n", list->str);
		g_string_free (list, TRUE);
		g_ptr_array_set_free_func (name_list, (GDestroyNotify)g_object_unref);
		g_ptr_array_free (name_list, TRUE);
	}
	else
	{
		g_error("Error calling GetDevices: %s\n", error->message);   
	}

return 0;
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]