1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
3
* libnm_glib -- Access network status & information from glib applications
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the
17
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
* Boston, MA 02110-1301 USA.
20
* Copyright (C) 2007 - 2008 Novell, Inc.
23
#include "nm-dbus-utils.h"
26
_nm_dbus_get_string_property (DBusGProxy *proxy,
27
const char *interface,
28
const char *prop_name)
34
g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), NULL);
36
if (dbus_g_proxy_call (proxy, "Get", &err,
37
G_TYPE_STRING, interface,
38
G_TYPE_STRING, prop_name,
42
str = g_strdup (g_value_get_string (&value));
44
g_warning ("Error in device_get_property: %s\n", err->message);
52
_nm_dbus_get_object_path_property (DBusGProxy *proxy,
53
const char *interface,
54
const char *prop_name)
60
g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), NULL);
62
if (dbus_g_proxy_call (proxy, "Get", &err,
63
G_TYPE_STRING, interface,
64
G_TYPE_STRING, prop_name,
68
path = g_strdup (g_value_get_boxed (&value));
70
g_warning ("Error in device_get_property: %s\n", err->message);
78
_nm_dbus_get_int_property (DBusGProxy *proxy,
79
const char *interface,
80
const char *prop_name)
86
g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), 0);
88
if (dbus_g_proxy_call (proxy, "Get", &err,
89
G_TYPE_STRING, interface,
90
G_TYPE_STRING, prop_name,
94
i = g_value_get_int (&value);
96
g_warning ("Error in device_get_property: %s\n", err->message);
104
_nm_dbus_get_uint_property (DBusGProxy *proxy,
105
const char *interface,
106
const char *prop_name)
112
g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), 0);
114
if (dbus_g_proxy_call (proxy, "Get", &err,
115
G_TYPE_STRING, interface,
116
G_TYPE_STRING, prop_name,
118
G_TYPE_VALUE, &value,
120
i = g_value_get_uint (&value);
122
g_warning ("Error in device_get_property: %s\n", err->message);
130
_nm_dbus_get_property (DBusGProxy *proxy,
131
const char *interface,
132
const char *prop_name,
135
DBusGProxy *properties_proxy;
139
g_return_val_if_fail (proxy != NULL, FALSE);
140
g_return_val_if_fail (interface != NULL, FALSE);
141
g_return_val_if_fail (prop_name != NULL, FALSE);
143
properties_proxy = dbus_g_proxy_new_from_proxy (proxy,
144
"org.freedesktop.DBus.Properties",
145
dbus_g_proxy_get_path (proxy));
147
if (!dbus_g_proxy_call (properties_proxy, "Get", &err,
148
G_TYPE_STRING, interface,
149
G_TYPE_STRING, prop_name,
153
g_warning ("Error in device_get_property: %s\n", err->message);
158
g_object_unref (properties_proxy);
164
_nm_dbus_set_property (DBusGProxy *proxy,
165
const char *interface,
166
const char *prop_name,
169
DBusGProxy *properties_proxy;
171
g_return_if_fail (proxy != NULL);
172
g_return_if_fail (interface != NULL);
173
g_return_if_fail (prop_name != NULL);
175
properties_proxy = dbus_g_proxy_new_from_proxy (proxy,
176
"org.freedesktop.DBus.Properties",
177
dbus_g_proxy_get_path (proxy));
179
dbus_g_proxy_call_no_reply (properties_proxy, "Set",
180
G_TYPE_STRING, interface,
181
G_TYPE_STRING, prop_name,
185
g_object_unref (properties_proxy);
189
_nm_dbus_introspect (DBusGConnection *connection,
190
const char *interface,
193
DBusGProxy *remote_object_introspectable;
194
char *introspect_data = NULL;
197
g_return_val_if_fail (connection != NULL, NULL);
198
g_return_val_if_fail (interface != NULL, NULL);
199
g_return_val_if_fail (path != NULL, NULL);
201
remote_object_introspectable = dbus_g_proxy_new_for_name (connection,
204
"org.freedesktop.DBus.Introspectable");
205
if (!dbus_g_proxy_call (remote_object_introspectable, "Introspect", &err,
207
G_TYPE_STRING, &introspect_data, G_TYPE_INVALID)) {
208
g_error ("Failed to complete Introspect %s", err->message);
212
g_object_unref (G_OBJECT (remote_object_introspectable));
214
return introspect_data;