Commit cb948609 authored by Zeeshan Ali (Khattak)'s avatar Zeeshan Ali (Khattak)
Browse files

Refactor a private function

Refactor device_proxy_new_cb()
parent 44f18229
......@@ -227,43 +227,26 @@ on_device_signal (GDBusProxy *proxy,
}
static void
device_proxy_new_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data) {
GUPnPNetworkManager *manager;
GDBusProxy *device_proxy;
NMDevice *nm_device;
use_new_device (GUPnPNetworkManager *manager,
NMDevice *nm_device)
{
NMDeviceState state;
GVariant *value;
GError *error;
manager = GUPNP_NETWORK_MANAGER (user_data);
error = NULL;
device_proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
if (G_UNLIKELY (error != NULL)) {
g_message ("Failed to create D-Bus proxy: %s", error->message);
g_error_free (error);
return;
}
nm_device = nm_device_new (manager, device_proxy);
manager->priv->nm_devices = g_list_append (manager->priv->nm_devices,
nm_device);
g_signal_connect (device_proxy,
g_signal_connect (nm_device->proxy,
"g-signal",
G_CALLBACK (on_device_signal),
nm_device);
value = g_dbus_proxy_get_cached_property (device_proxy, "State");
value = g_dbus_proxy_get_cached_property (nm_device->proxy, "State");
state = g_variant_get_uint32 (value);
g_variant_unref (value);
if (state == NM_DEVICE_STATE_ACTIVATED) {
value = g_dbus_proxy_get_cached_property (device_proxy,
value = g_dbus_proxy_get_cached_property (nm_device->proxy,
"Interface");
create_context_for_device (nm_device,
......@@ -273,6 +256,31 @@ device_proxy_new_cb (GObject *source_object,
}
}
static void
device_proxy_new_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data) {
GUPnPNetworkManager *manager;
GDBusProxy *device_proxy;
NMDevice *nm_device;
GError *error;
manager = GUPNP_NETWORK_MANAGER (user_data);
error = NULL;
device_proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
if (G_UNLIKELY (error != NULL)) {
g_message ("Failed to create D-Bus proxy: %s", error->message);
g_error_free (error);
return;
}
nm_device = nm_device_new (manager, device_proxy);
use_new_device (manager, nm_device);
}
static int
compare_device_path (NMDevice *nm_device, char *device_path)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment