mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-24 10:10:07 +01:00
* libnm-glib/nm-device.c (nm_device_get_description): Implement. * libnm-glib/nm-client.c (nm_client_manager_is_running): Implement. Also add a "manager-running" signal that notifies the appearance/disappearance of NM. (nm_client_sleep): Implement. * libnm-glib/nm-device.c: * libnm-glib/nm-device-802-11-wireless.c: * libnm-glib/nm-device-802-3-ethernet.c: Don't inherit from DBusGProxy, add a proxy to private data. The reason is, classes inherited from NMDevice wouldn't get any dbus signals for anything but their own dbus interface. DBusGProxy objects support only one interfaces and to work around this, NMDevice has spearate proxy for each dbus interface. The nice side effect of this change is that we do not create a new DBusGProxy object for each property access. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2479 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
193 lines
4.6 KiB
C
193 lines
4.6 KiB
C
#include "nm-utils.h"
|
|
|
|
char *
|
|
nm_dbus_get_string_property (DBusGProxy *proxy,
|
|
const char *interface,
|
|
const char *prop_name)
|
|
{
|
|
GError *err = NULL;
|
|
char *str = NULL;
|
|
GValue value = {0,};
|
|
|
|
g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), NULL);
|
|
|
|
if (dbus_g_proxy_call (proxy, "Get", &err,
|
|
G_TYPE_STRING, interface,
|
|
G_TYPE_STRING, prop_name,
|
|
G_TYPE_INVALID,
|
|
G_TYPE_VALUE, &value,
|
|
G_TYPE_INVALID)) {
|
|
str = g_strdup (g_value_get_string (&value));
|
|
} else {
|
|
g_warning ("Error in device_get_property: %s\n", err->message);
|
|
g_error_free (err);
|
|
}
|
|
|
|
return str;
|
|
}
|
|
|
|
char *
|
|
nm_dbus_get_object_path_property (DBusGProxy *proxy,
|
|
const char *interface,
|
|
const char *prop_name)
|
|
{
|
|
GError *err = NULL;
|
|
char *path = NULL;
|
|
GValue value = {0,};
|
|
|
|
g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), NULL);
|
|
|
|
if (dbus_g_proxy_call (proxy, "Get", &err,
|
|
G_TYPE_STRING, interface,
|
|
G_TYPE_STRING, prop_name,
|
|
G_TYPE_INVALID,
|
|
G_TYPE_VALUE, &value,
|
|
G_TYPE_INVALID)) {
|
|
path = g_strdup (g_value_get_boxed (&value));
|
|
} else {
|
|
g_warning ("Error in device_get_property: %s\n", err->message);
|
|
g_error_free (err);
|
|
}
|
|
|
|
return path;
|
|
}
|
|
|
|
gint32
|
|
nm_dbus_get_int_property (DBusGProxy *proxy,
|
|
const char *interface,
|
|
const char *prop_name)
|
|
{
|
|
GError *err = NULL;
|
|
gint32 i = 0;
|
|
GValue value = {0,};
|
|
|
|
g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), 0);
|
|
|
|
if (dbus_g_proxy_call (proxy, "Get", &err,
|
|
G_TYPE_STRING, interface,
|
|
G_TYPE_STRING, prop_name,
|
|
G_TYPE_INVALID,
|
|
G_TYPE_VALUE, &value,
|
|
G_TYPE_INVALID)) {
|
|
i = g_value_get_int (&value);
|
|
} else {
|
|
g_warning ("Error in device_get_property: %s\n", err->message);
|
|
g_error_free (err);
|
|
}
|
|
|
|
return i;
|
|
}
|
|
|
|
guint32
|
|
nm_dbus_get_uint_property (DBusGProxy *proxy,
|
|
const char *interface,
|
|
const char *prop_name)
|
|
{
|
|
GError *err = NULL;
|
|
guint32 i = 0;
|
|
GValue value = {0,};
|
|
|
|
g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), 0);
|
|
|
|
if (dbus_g_proxy_call (proxy, "Get", &err,
|
|
G_TYPE_STRING, interface,
|
|
G_TYPE_STRING, prop_name,
|
|
G_TYPE_INVALID,
|
|
G_TYPE_VALUE, &value,
|
|
G_TYPE_INVALID)) {
|
|
i = g_value_get_uint (&value);
|
|
} else {
|
|
g_warning ("Error in device_get_property: %s\n", err->message);
|
|
g_error_free (err);
|
|
}
|
|
|
|
return i;
|
|
}
|
|
|
|
gboolean
|
|
nm_dbus_get_property (DBusGProxy *proxy,
|
|
const char *interface,
|
|
const char *prop_name,
|
|
GValue *value)
|
|
{
|
|
DBusGProxy *properties_proxy;
|
|
GError *err = NULL;
|
|
gboolean ret = TRUE;
|
|
|
|
g_return_val_if_fail (proxy != NULL, FALSE);
|
|
g_return_val_if_fail (interface != NULL, FALSE);
|
|
g_return_val_if_fail (prop_name != NULL, FALSE);
|
|
|
|
properties_proxy = dbus_g_proxy_new_from_proxy (proxy,
|
|
"org.freedesktop.DBus.Properties",
|
|
dbus_g_proxy_get_path (proxy));
|
|
|
|
if (!dbus_g_proxy_call (properties_proxy, "Get", &err,
|
|
G_TYPE_STRING, interface,
|
|
G_TYPE_STRING, prop_name,
|
|
G_TYPE_INVALID,
|
|
G_TYPE_VALUE, value,
|
|
G_TYPE_INVALID)) {
|
|
g_warning ("Error in device_get_property: %s\n", err->message);
|
|
g_error_free (err);
|
|
ret = FALSE;
|
|
}
|
|
|
|
g_object_unref (properties_proxy);
|
|
|
|
return ret;
|
|
}
|
|
|
|
void
|
|
nm_dbus_set_property (DBusGProxy *proxy,
|
|
const char *interface,
|
|
const char *prop_name,
|
|
GValue *value)
|
|
{
|
|
DBusGProxy *properties_proxy;
|
|
|
|
g_return_if_fail (proxy != NULL);
|
|
g_return_if_fail (interface != NULL);
|
|
g_return_if_fail (prop_name != NULL);
|
|
|
|
properties_proxy = dbus_g_proxy_new_from_proxy (proxy,
|
|
"org.freedesktop.DBus.Properties",
|
|
dbus_g_proxy_get_path (proxy));
|
|
|
|
dbus_g_proxy_call_no_reply (properties_proxy, "Set",
|
|
G_TYPE_STRING, interface,
|
|
G_TYPE_STRING, prop_name,
|
|
G_TYPE_VALUE, value,
|
|
G_TYPE_INVALID);
|
|
|
|
g_object_unref (properties_proxy);
|
|
}
|
|
|
|
char *
|
|
nm_dbus_introspect (DBusGConnection *connection,
|
|
const char *interface,
|
|
const char *path)
|
|
{
|
|
DBusGProxy *remote_object_introspectable;
|
|
char *introspect_data = NULL;
|
|
GError *err = NULL;
|
|
|
|
g_return_val_if_fail (connection != NULL, NULL);
|
|
g_return_val_if_fail (interface != NULL, NULL);
|
|
g_return_val_if_fail (path != NULL, NULL);
|
|
|
|
remote_object_introspectable = dbus_g_proxy_new_for_name (connection,
|
|
interface,
|
|
path,
|
|
"org.freedesktop.DBus.Introspectable");
|
|
if (!dbus_g_proxy_call (remote_object_introspectable, "Introspect", &err,
|
|
G_TYPE_INVALID,
|
|
G_TYPE_STRING, &introspect_data, G_TYPE_INVALID)) {
|
|
g_error ("Failed to complete Introspect %s", err->message);
|
|
g_error_free (err);
|
|
}
|
|
|
|
g_object_unref (G_OBJECT (remote_object_introspectable));
|
|
|
|
return introspect_data;
|
|
}
|