2006-08-06 Dan Williams <dcbw@redhat.com>
* gnome/applet/applet-dbus-devices.c gnome/applet/applet-dbus-vpn.c gnome/applet/applet-dbus.c gnome/applet/applet-dbus.h src/nm-dbus-nmi.c utils/nm-utils.c utils/nm-utils.h - Make pending call tracking code generic, so we can use it in NM as well as the applet git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1940 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
12
ChangeLog
12
ChangeLog
@@ -1,3 +1,15 @@
|
|||||||
|
2006-08-06 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
|
* gnome/applet/applet-dbus-devices.c
|
||||||
|
gnome/applet/applet-dbus-vpn.c
|
||||||
|
gnome/applet/applet-dbus.c
|
||||||
|
gnome/applet/applet-dbus.h
|
||||||
|
src/nm-dbus-nmi.c
|
||||||
|
utils/nm-utils.c
|
||||||
|
utils/nm-utils.h
|
||||||
|
- Make pending call tracking code generic,
|
||||||
|
so we can use it in NM as well as the applet
|
||||||
|
|
||||||
2006-08-06 Dan Williams <dcbw@redhat.com>
|
2006-08-06 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
* src/nm-activation-request.c
|
* src/nm-activation-request.c
|
||||||
|
@@ -56,7 +56,7 @@ static void nma_dbus_nm_state_cb (DBusPendingCall *pcall, void *user_data)
|
|||||||
g_return_if_fail (pcall != NULL);
|
g_return_if_fail (pcall != NULL);
|
||||||
g_return_if_fail (applet != NULL);
|
g_return_if_fail (applet != NULL);
|
||||||
|
|
||||||
nma_dbus_send_with_callback_replied (pcall, __func__);
|
nm_dbus_send_with_callback_replied (pcall, __func__);
|
||||||
|
|
||||||
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
||||||
goto out;
|
goto out;
|
||||||
@@ -97,7 +97,7 @@ void nma_dbus_update_nm_state (NMApplet *applet)
|
|||||||
|
|
||||||
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "state")))
|
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "state")))
|
||||||
{
|
{
|
||||||
nma_dbus_send_with_callback (applet->connection, message,
|
nm_dbus_send_with_callback (applet->connection, message,
|
||||||
nma_dbus_nm_state_cb, applet, NULL, __func__);
|
nma_dbus_nm_state_cb, applet, NULL, __func__);
|
||||||
dbus_message_unref (message);
|
dbus_message_unref (message);
|
||||||
}
|
}
|
||||||
@@ -127,7 +127,7 @@ static void nma_dbus_device_get_driver_cb (DBusPendingCall *pcall, void *user_da
|
|||||||
g_return_if_fail (pcall != NULL);
|
g_return_if_fail (pcall != NULL);
|
||||||
g_return_if_fail (applet != NULL);
|
g_return_if_fail (applet != NULL);
|
||||||
|
|
||||||
nma_dbus_send_with_callback_replied (pcall, __func__);
|
nm_dbus_send_with_callback_replied (pcall, __func__);
|
||||||
|
|
||||||
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
||||||
goto out;
|
goto out;
|
||||||
@@ -186,7 +186,7 @@ static void nma_dbus_device_get_driver (NetworkDevice *dev, NMApplet *applet)
|
|||||||
data->dev = dev;
|
data->dev = dev;
|
||||||
data->applet = applet;
|
data->applet = applet;
|
||||||
|
|
||||||
if (!nma_dbus_send_with_callback (applet->connection, message,
|
if (!nm_dbus_send_with_callback (applet->connection, message,
|
||||||
nma_dbus_device_get_driver_cb, data, NULL, __func__))
|
nma_dbus_device_get_driver_cb, data, NULL, __func__))
|
||||||
{
|
{
|
||||||
network_device_unref (dev);
|
network_device_unref (dev);
|
||||||
@@ -212,7 +212,7 @@ static void nma_dbus_update_wireless_enabled_cb (DBusPendingCall *pcall, void *u
|
|||||||
g_return_if_fail (pcall != NULL);
|
g_return_if_fail (pcall != NULL);
|
||||||
g_return_if_fail (applet != NULL);
|
g_return_if_fail (applet != NULL);
|
||||||
|
|
||||||
nma_dbus_send_with_callback_replied (pcall, __func__);
|
nm_dbus_send_with_callback_replied (pcall, __func__);
|
||||||
|
|
||||||
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
||||||
goto out;
|
goto out;
|
||||||
@@ -256,7 +256,7 @@ static void nma_dbus_update_wireless_enabled (NMApplet *applet)
|
|||||||
|
|
||||||
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "getWirelessEnabled")))
|
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "getWirelessEnabled")))
|
||||||
{
|
{
|
||||||
nma_dbus_send_with_callback (applet->connection, message,
|
nm_dbus_send_with_callback (applet->connection, message,
|
||||||
nma_dbus_update_wireless_enabled_cb, applet, NULL, __func__);
|
nma_dbus_update_wireless_enabled_cb, applet, NULL, __func__);
|
||||||
dbus_message_unref (message);
|
dbus_message_unref (message);
|
||||||
}
|
}
|
||||||
@@ -303,7 +303,7 @@ static void hal_info_product_cb (DBusPendingCall *pcall, void *user_data)
|
|||||||
g_return_if_fail (cb_data->parent_op != NULL);
|
g_return_if_fail (cb_data->parent_op != NULL);
|
||||||
g_return_if_fail (cb_data->vendor != NULL);
|
g_return_if_fail (cb_data->vendor != NULL);
|
||||||
|
|
||||||
nma_dbus_send_with_callback_replied (pcall, __func__);
|
nm_dbus_send_with_callback_replied (pcall, __func__);
|
||||||
|
|
||||||
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
||||||
goto out;
|
goto out;
|
||||||
@@ -351,7 +351,7 @@ static void hal_info_vendor_cb (DBusPendingCall *pcall, void *user_data)
|
|||||||
g_return_if_fail (cb_data->dev != NULL);
|
g_return_if_fail (cb_data->dev != NULL);
|
||||||
g_return_if_fail (cb_data->parent_op != NULL);
|
g_return_if_fail (cb_data->parent_op != NULL);
|
||||||
|
|
||||||
nma_dbus_send_with_callback_replied (pcall, __func__);
|
nm_dbus_send_with_callback_replied (pcall, __func__);
|
||||||
|
|
||||||
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
||||||
goto out;
|
goto out;
|
||||||
@@ -386,7 +386,7 @@ static void hal_info_vendor_cb (DBusPendingCall *pcall, void *user_data)
|
|||||||
product_cb_data->parent_op = g_strdup (cb_data->parent_op);
|
product_cb_data->parent_op = g_strdup (cb_data->parent_op);
|
||||||
product_cb_data->vendor = g_strdup (info_vendor);
|
product_cb_data->vendor = g_strdup (info_vendor);
|
||||||
|
|
||||||
nma_dbus_send_with_callback (cb_data->applet->connection, message,
|
nm_dbus_send_with_callback (cb_data->applet->connection, message,
|
||||||
hal_info_product_cb, product_cb_data,
|
hal_info_product_cb, product_cb_data,
|
||||||
(DBusFreeFunction) free_hal_info_cb_data, __func__);
|
(DBusFreeFunction) free_hal_info_cb_data, __func__);
|
||||||
dbus_message_unref (message);
|
dbus_message_unref (message);
|
||||||
@@ -416,7 +416,7 @@ static void hal_net_physdev_cb (DBusPendingCall *pcall, void *user_data)
|
|||||||
g_return_if_fail (cb_data->applet != NULL);
|
g_return_if_fail (cb_data->applet != NULL);
|
||||||
g_return_if_fail (cb_data->dev != NULL);
|
g_return_if_fail (cb_data->dev != NULL);
|
||||||
|
|
||||||
nma_dbus_send_with_callback_replied (pcall, __func__);
|
nm_dbus_send_with_callback_replied (pcall, __func__);
|
||||||
|
|
||||||
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
||||||
goto out;
|
goto out;
|
||||||
@@ -451,7 +451,7 @@ static void hal_net_physdev_cb (DBusPendingCall *pcall, void *user_data)
|
|||||||
vendor_cb_data->dev = cb_data->dev;
|
vendor_cb_data->dev = cb_data->dev;
|
||||||
vendor_cb_data->parent_op = g_strdup (op);
|
vendor_cb_data->parent_op = g_strdup (op);
|
||||||
|
|
||||||
nma_dbus_send_with_callback (cb_data->applet->connection, message,
|
nm_dbus_send_with_callback (cb_data->applet->connection, message,
|
||||||
hal_info_vendor_cb, vendor_cb_data,
|
hal_info_vendor_cb, vendor_cb_data,
|
||||||
(DBusFreeFunction) free_hal_info_cb_data, __func__);
|
(DBusFreeFunction) free_hal_info_cb_data, __func__);
|
||||||
dbus_message_unref (message);
|
dbus_message_unref (message);
|
||||||
@@ -490,7 +490,7 @@ static void nma_dbus_update_device_info_from_hal (NetworkDevice *dev, NMApplet *
|
|||||||
network_device_ref (dev);
|
network_device_ref (dev);
|
||||||
cb_data->dev = dev;
|
cb_data->dev = dev;
|
||||||
|
|
||||||
nma_dbus_send_with_callback (cb_data->applet->connection, message,
|
nm_dbus_send_with_callback (cb_data->applet->connection, message,
|
||||||
hal_net_physdev_cb, cb_data,
|
hal_net_physdev_cb, cb_data,
|
||||||
(DBusFreeFunction) free_hal_info_cb_data, __func__);
|
(DBusFreeFunction) free_hal_info_cb_data, __func__);
|
||||||
dbus_message_unref (message);
|
dbus_message_unref (message);
|
||||||
@@ -555,7 +555,7 @@ static void nma_dbus_net_properties_cb (DBusPendingCall *pcall, void *user_data)
|
|||||||
g_return_if_fail (cb_data->applet != NULL);
|
g_return_if_fail (cb_data->applet != NULL);
|
||||||
g_return_if_fail (cb_data->dev_op != NULL);
|
g_return_if_fail (cb_data->dev_op != NULL);
|
||||||
|
|
||||||
nma_dbus_send_with_callback_replied (pcall, __func__);
|
nm_dbus_send_with_callback_replied (pcall, __func__);
|
||||||
|
|
||||||
applet = cb_data->applet;
|
applet = cb_data->applet;
|
||||||
|
|
||||||
@@ -647,7 +647,7 @@ void nma_dbus_device_update_one_network (NMApplet *applet, const char *dev_path,
|
|||||||
cb_data->act_net = (active_net_path && strlen (active_net_path)) ? g_strdup (active_net_path) : NULL;
|
cb_data->act_net = (active_net_path && strlen (active_net_path)) ? g_strdup (active_net_path) : NULL;
|
||||||
cb_data->applet = applet;
|
cb_data->applet = applet;
|
||||||
|
|
||||||
nma_dbus_send_with_callback (applet->connection, message,
|
nm_dbus_send_with_callback (applet->connection, message,
|
||||||
nma_dbus_net_properties_cb, cb_data,
|
nma_dbus_net_properties_cb, cb_data,
|
||||||
(DBusFreeFunction) free_net_prop_cb_data, __func__);
|
(DBusFreeFunction) free_net_prop_cb_data, __func__);
|
||||||
dbus_message_unref (message);
|
dbus_message_unref (message);
|
||||||
@@ -761,7 +761,7 @@ static void nma_dbus_device_properties_cb (DBusPendingCall *pcall, void *user_da
|
|||||||
g_return_if_fail (pcall != NULL);
|
g_return_if_fail (pcall != NULL);
|
||||||
g_return_if_fail (applet != NULL);
|
g_return_if_fail (applet != NULL);
|
||||||
|
|
||||||
nma_dbus_send_with_callback_replied (pcall, __func__);
|
nm_dbus_send_with_callback_replied (pcall, __func__);
|
||||||
|
|
||||||
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
||||||
goto out;
|
goto out;
|
||||||
@@ -871,7 +871,7 @@ void nma_dbus_device_update_one_device (NMApplet *applet, const char *dev_path)
|
|||||||
|
|
||||||
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, dev_path, NM_DBUS_INTERFACE_DEVICES, "getProperties")))
|
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, dev_path, NM_DBUS_INTERFACE_DEVICES, "getProperties")))
|
||||||
{
|
{
|
||||||
nma_dbus_send_with_callback (applet->connection, message,
|
nm_dbus_send_with_callback (applet->connection, message,
|
||||||
nma_dbus_device_properties_cb, applet, NULL, __func__);
|
nma_dbus_device_properties_cb, applet, NULL, __func__);
|
||||||
dbus_message_unref (message);
|
dbus_message_unref (message);
|
||||||
}
|
}
|
||||||
@@ -905,7 +905,7 @@ static void nma_dbus_device_activated_cb (DBusPendingCall *pcall, void *user_dat
|
|||||||
char * icon = NULL;
|
char * icon = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nma_dbus_send_with_callback_replied (pcall, __func__);
|
nm_dbus_send_with_callback_replied (pcall, __func__);
|
||||||
|
|
||||||
nma_dbus_device_properties_cb (pcall, applet);
|
nma_dbus_device_properties_cb (pcall, applet);
|
||||||
|
|
||||||
@@ -961,7 +961,7 @@ void nma_dbus_device_activated (NMApplet *applet, const char *dev_path, const ch
|
|||||||
|
|
||||||
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, dev_path, NM_DBUS_INTERFACE_DEVICES, "getProperties")))
|
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, dev_path, NM_DBUS_INTERFACE_DEVICES, "getProperties")))
|
||||||
{
|
{
|
||||||
nma_dbus_send_with_callback (applet->connection, message,
|
nm_dbus_send_with_callback (applet->connection, message,
|
||||||
nma_dbus_device_activated_cb, cb_data, NULL, __func__);
|
nma_dbus_device_activated_cb, cb_data, NULL, __func__);
|
||||||
dbus_message_unref (message);
|
dbus_message_unref (message);
|
||||||
}
|
}
|
||||||
@@ -972,7 +972,7 @@ static void nma_dbus_device_deactivated_cb (DBusPendingCall *pcall, void *user_d
|
|||||||
{
|
{
|
||||||
NMApplet * applet = (NMApplet *) user_data;
|
NMApplet * applet = (NMApplet *) user_data;
|
||||||
|
|
||||||
nma_dbus_send_with_callback_replied (pcall, __func__);
|
nm_dbus_send_with_callback_replied (pcall, __func__);
|
||||||
|
|
||||||
nma_dbus_device_properties_cb (pcall, applet);
|
nma_dbus_device_properties_cb (pcall, applet);
|
||||||
|
|
||||||
@@ -995,7 +995,7 @@ void nma_dbus_device_deactivated (NMApplet *applet, const char *dev_path)
|
|||||||
|
|
||||||
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, dev_path, NM_DBUS_INTERFACE_DEVICES, "getProperties")))
|
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, dev_path, NM_DBUS_INTERFACE_DEVICES, "getProperties")))
|
||||||
{
|
{
|
||||||
nma_dbus_send_with_callback (applet->connection, message,
|
nm_dbus_send_with_callback (applet->connection, message,
|
||||||
nma_dbus_device_deactivated_cb, applet, NULL, __func__);
|
nma_dbus_device_deactivated_cb, applet, NULL, __func__);
|
||||||
dbus_message_unref (message);
|
dbus_message_unref (message);
|
||||||
}
|
}
|
||||||
@@ -1018,7 +1018,7 @@ static void nma_dbus_update_devices_cb (DBusPendingCall *pcall, void *user_data)
|
|||||||
g_return_if_fail (pcall != NULL);
|
g_return_if_fail (pcall != NULL);
|
||||||
g_return_if_fail (applet != NULL);
|
g_return_if_fail (applet != NULL);
|
||||||
|
|
||||||
nma_dbus_send_with_callback_replied (pcall, __func__);
|
nm_dbus_send_with_callback_replied (pcall, __func__);
|
||||||
|
|
||||||
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
||||||
goto out;
|
goto out;
|
||||||
@@ -1072,7 +1072,7 @@ void nma_dbus_update_devices (NMApplet *applet)
|
|||||||
|
|
||||||
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "getDevices")))
|
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "getDevices")))
|
||||||
{
|
{
|
||||||
nma_dbus_send_with_callback (applet->connection, message,
|
nm_dbus_send_with_callback (applet->connection, message,
|
||||||
nma_dbus_update_devices_cb, applet, NULL, __func__);
|
nma_dbus_update_devices_cb, applet, NULL, __func__);
|
||||||
dbus_message_unref (message);
|
dbus_message_unref (message);
|
||||||
}
|
}
|
||||||
@@ -1096,7 +1096,7 @@ static void nma_dbus_update_dialup_cb (DBusPendingCall *pcall, void *user_data)
|
|||||||
g_return_if_fail (pcall != NULL);
|
g_return_if_fail (pcall != NULL);
|
||||||
g_return_if_fail (applet != NULL);
|
g_return_if_fail (applet != NULL);
|
||||||
|
|
||||||
nma_dbus_send_with_callback_replied (pcall, __func__);
|
nm_dbus_send_with_callback_replied (pcall, __func__);
|
||||||
|
|
||||||
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
||||||
goto out;
|
goto out;
|
||||||
@@ -1158,7 +1158,7 @@ void nma_dbus_update_dialup (NMApplet *applet)
|
|||||||
|
|
||||||
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "getDialup")))
|
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "getDialup")))
|
||||||
{
|
{
|
||||||
nma_dbus_send_with_callback (applet->connection, message,
|
nm_dbus_send_with_callback (applet->connection, message,
|
||||||
nma_dbus_update_dialup_cb, applet, NULL, __func__);
|
nma_dbus_update_dialup_cb, applet, NULL, __func__);
|
||||||
dbus_message_unref (message);
|
dbus_message_unref (message);
|
||||||
}
|
}
|
||||||
|
@@ -117,7 +117,7 @@ static void nma_dbus_vpn_properties_cb (DBusPendingCall *pcall, void *user_data)
|
|||||||
g_return_if_fail (cb_data->applet != NULL);
|
g_return_if_fail (cb_data->applet != NULL);
|
||||||
g_return_if_fail (cb_data->name != NULL);
|
g_return_if_fail (cb_data->name != NULL);
|
||||||
|
|
||||||
nma_dbus_send_with_callback_replied (pcall, __func__);
|
nm_dbus_send_with_callback_replied (pcall, __func__);
|
||||||
|
|
||||||
applet = cb_data->applet;
|
applet = cb_data->applet;
|
||||||
|
|
||||||
@@ -188,7 +188,7 @@ void nma_dbus_vpn_update_one_vpn_connection (NMApplet *applet, const char *vpn_n
|
|||||||
cb_data->applet = applet;
|
cb_data->applet = applet;
|
||||||
cb_data->name = g_strdup (vpn_name);
|
cb_data->name = g_strdup (vpn_name);
|
||||||
|
|
||||||
nma_dbus_send_with_callback (applet->connection, message,
|
nm_dbus_send_with_callback (applet->connection, message,
|
||||||
nma_dbus_vpn_properties_cb, cb_data,
|
nma_dbus_vpn_properties_cb, cb_data,
|
||||||
(DBusFreeFunction) free_vpn_props_cb_data, __func__);
|
(DBusFreeFunction) free_vpn_props_cb_data, __func__);
|
||||||
dbus_message_unref (message);
|
dbus_message_unref (message);
|
||||||
@@ -212,7 +212,7 @@ static void nma_dbus_vpn_update_vpn_connections_cb (DBusPendingCall *pcall, void
|
|||||||
g_return_if_fail (pcall != NULL);
|
g_return_if_fail (pcall != NULL);
|
||||||
g_return_if_fail (applet != NULL);
|
g_return_if_fail (applet != NULL);
|
||||||
|
|
||||||
nma_dbus_send_with_callback_replied (pcall, __func__);
|
nm_dbus_send_with_callback_replied (pcall, __func__);
|
||||||
|
|
||||||
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
||||||
goto out;
|
goto out;
|
||||||
@@ -268,7 +268,7 @@ void nma_dbus_vpn_update_vpn_connections (NMApplet *applet)
|
|||||||
|
|
||||||
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH_VPN, NM_DBUS_INTERFACE_VPN, "getVPNConnections")))
|
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH_VPN, NM_DBUS_INTERFACE_VPN, "getVPNConnections")))
|
||||||
{
|
{
|
||||||
nma_dbus_send_with_callback (applet->connection, message,
|
nm_dbus_send_with_callback (applet->connection, message,
|
||||||
nma_dbus_vpn_update_vpn_connections_cb, applet, NULL, __func__);
|
nma_dbus_vpn_update_vpn_connections_cb, applet, NULL, __func__);
|
||||||
dbus_message_unref (message);
|
dbus_message_unref (message);
|
||||||
}
|
}
|
||||||
|
@@ -43,135 +43,17 @@
|
|||||||
#define DBUS_NO_SERVICE_ERROR "org.freedesktop.DBus.Error.ServiceDoesNotExist"
|
#define DBUS_NO_SERVICE_ERROR "org.freedesktop.DBus.Error.ServiceDoesNotExist"
|
||||||
|
|
||||||
|
|
||||||
/* #define DBUS_PENDING_CALL_DEBUG */
|
|
||||||
|
|
||||||
typedef struct PCallInfo
|
|
||||||
{
|
|
||||||
DBusPendingCall * pcall;
|
|
||||||
char * caller;
|
|
||||||
guint32 id;
|
|
||||||
GTimeVal start;
|
|
||||||
} PCallInfo;
|
|
||||||
|
|
||||||
static GStaticMutex pcall_mutex = G_STATIC_MUTEX_INIT;
|
|
||||||
static GHashTable * pcall_table = NULL;
|
|
||||||
static guint32 pcall_gid = 0;
|
|
||||||
static guint32 pcall_pending = 0;
|
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
nma_dbus_send_with_callback (DBusConnection *connection,
|
|
||||||
DBusMessage *msg,
|
|
||||||
DBusPendingCallNotifyFunction func,
|
|
||||||
gpointer data,
|
|
||||||
DBusFreeFunction free_func,
|
|
||||||
const char *caller)
|
|
||||||
{
|
|
||||||
PCallInfo * info;
|
|
||||||
DBusPendingCall * pcall = NULL;
|
|
||||||
|
|
||||||
g_return_val_if_fail (connection != NULL, FALSE);
|
|
||||||
g_return_val_if_fail (msg != NULL, FALSE);
|
|
||||||
g_return_val_if_fail (func != NULL, FALSE);
|
|
||||||
g_return_val_if_fail (caller != NULL, FALSE);
|
|
||||||
|
|
||||||
dbus_connection_send_with_reply (connection, msg, &pcall, -1);
|
|
||||||
if (!pcall)
|
|
||||||
{
|
|
||||||
g_warning ("Error: '%s' couldn't send dbus message.", caller);
|
|
||||||
if (free_func)
|
|
||||||
(*free_func)(data);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
dbus_pending_call_set_notify (pcall, func, data, free_func);
|
|
||||||
|
|
||||||
if (!(info = g_malloc0 (sizeof (PCallInfo))))
|
|
||||||
return FALSE;
|
|
||||||
info->caller = g_strdup (caller);
|
|
||||||
info->pcall = pcall;
|
|
||||||
g_get_current_time (&info->start);
|
|
||||||
dbus_pending_call_ref (pcall);
|
|
||||||
|
|
||||||
g_static_mutex_lock (&pcall_mutex);
|
|
||||||
info->id = pcall_gid++;
|
|
||||||
pcall_pending++;
|
|
||||||
|
|
||||||
if (!pcall_table)
|
|
||||||
pcall_table = g_hash_table_new (g_direct_hash, g_direct_equal);
|
|
||||||
g_hash_table_insert (pcall_table, pcall, info);
|
|
||||||
|
|
||||||
#ifdef DBUS_PENDING_CALL_DEBUG
|
|
||||||
nm_info ("PCall Debug: registered ID %d (%p), initiated by '%s'. Total "
|
|
||||||
"pending: %d", info->id, pcall, info->caller, pcall_pending);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_static_mutex_unlock (&pcall_mutex);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
nma_dbus_send_with_callback_replied (DBusPendingCall *pcall,
|
|
||||||
const char *caller)
|
|
||||||
{
|
|
||||||
PCallInfo * info;
|
|
||||||
#ifdef DBUS_PENDING_CALL_DEBUG
|
|
||||||
GTimeVal now;
|
|
||||||
long elapsed_ms = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_return_if_fail (pcall != NULL);
|
|
||||||
g_return_if_fail (caller != NULL);
|
|
||||||
|
|
||||||
g_static_mutex_lock (&pcall_mutex);
|
|
||||||
if (!(info = g_hash_table_lookup (pcall_table, pcall)))
|
|
||||||
{
|
|
||||||
nm_warning ("Error: couldn't find pending call %p in tracking"
|
|
||||||
" table.", pcall);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
pcall_pending--;
|
|
||||||
#ifdef DBUS_PENDING_CALL_DEBUG
|
|
||||||
g_get_current_time (&now);
|
|
||||||
if (info->start.tv_usec > now.tv_usec)
|
|
||||||
{
|
|
||||||
now.tv_sec--;
|
|
||||||
now.tv_usec = G_USEC_PER_SEC - (info->start.tv_usec - now.tv_usec);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
now.tv_usec -= info->start.tv_usec;
|
|
||||||
now.tv_sec -= info->start.tv_sec;
|
|
||||||
elapsed_ms = now.tv_sec * G_USEC_PER_SEC + now.tv_usec;
|
|
||||||
elapsed_ms /= 1000;
|
|
||||||
|
|
||||||
nm_info ("PCall Debug: unregistered ID %d (%p), %s -> %s,"
|
|
||||||
" %lums elapsed. Total pending: %d", info->id, info->pcall, info->caller,
|
|
||||||
caller, elapsed_ms, pcall_pending);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_hash_table_remove (pcall_table, pcall);
|
|
||||||
g_free (info->caller);
|
|
||||||
dbus_pending_call_unref (info->pcall);
|
|
||||||
g_free (info);
|
|
||||||
|
|
||||||
out:
|
|
||||||
g_static_mutex_unlock (&pcall_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nma_dbus_filter
|
* nma_dbus_filter
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static DBusHandlerResult nma_dbus_filter (DBusConnection *connection, DBusMessage *message, void *user_data)
|
static DBusHandlerResult nma_dbus_filter (DBusConnection *connection, DBusMessage *message, void *user_data)
|
||||||
{
|
{
|
||||||
NMApplet *applet = (NMApplet *)user_data;
|
NMApplet * applet = (NMApplet *)user_data;
|
||||||
gboolean handled = TRUE;
|
gboolean handled = TRUE;
|
||||||
|
const char * object_path;
|
||||||
const char * object_path;
|
const char * member;
|
||||||
const char * member;
|
const char * interface;
|
||||||
const char * interface;
|
|
||||||
|
|
||||||
g_return_val_if_fail (applet != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
g_return_val_if_fail (applet != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
||||||
g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
||||||
|
@@ -40,13 +40,4 @@ void nma_dbus_enable_networking (NMApplet *applet, gboolean enabled);
|
|||||||
void nma_free_gui_data_model (NMApplet *applet);
|
void nma_free_gui_data_model (NMApplet *applet);
|
||||||
void nma_free_dbus_data_model (NMApplet *applet);
|
void nma_free_dbus_data_model (NMApplet *applet);
|
||||||
|
|
||||||
gboolean nma_dbus_send_with_callback (DBusConnection *connection,
|
|
||||||
DBusMessage *msg,
|
|
||||||
DBusPendingCallNotifyFunction func,
|
|
||||||
gpointer data,
|
|
||||||
DBusFreeFunction free_func,
|
|
||||||
const char *caller);
|
|
||||||
void nma_dbus_send_with_callback_replied(DBusPendingCall *pcall,
|
|
||||||
const char *caller);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -57,10 +57,9 @@ static void nm_dbus_get_user_key_for_network_cb (DBusPendingCall *pcall, NMActRe
|
|||||||
ap = nm_act_request_get_ap (req);
|
ap = nm_act_request_get_ap (req);
|
||||||
g_assert (ap);
|
g_assert (ap);
|
||||||
|
|
||||||
dbus_pending_call_ref (pcall);
|
nm_dbus_send_with_callback_replied (pcall, __func__);
|
||||||
|
|
||||||
if (!dbus_pending_call_get_completed (pcall))
|
dbus_pending_call_ref (pcall);
|
||||||
goto out;
|
|
||||||
|
|
||||||
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
||||||
goto out;
|
goto out;
|
||||||
@@ -162,12 +161,13 @@ void nm_dbus_get_user_key_for_network (DBusConnection *connection, NMActRequest
|
|||||||
DBUS_TYPE_INT32, &attempt,
|
DBUS_TYPE_INT32, &attempt,
|
||||||
DBUS_TYPE_BOOLEAN, &new_key,
|
DBUS_TYPE_BOOLEAN, &new_key,
|
||||||
DBUS_TYPE_INVALID);
|
DBUS_TYPE_INVALID);
|
||||||
if (dbus_connection_send_with_reply (connection, message, &pcall, INT_MAX) && pcall)
|
if ((pcall = nm_dbus_send_with_callback (connection, message,
|
||||||
|
(DBusPendingCallNotifyFunction) nm_dbus_get_user_key_for_network_cb,
|
||||||
|
req, NULL, __func__)))
|
||||||
{
|
{
|
||||||
nm_act_request_ref (req);
|
nm_act_request_ref (req);
|
||||||
nm_act_request_set_stage (req, NM_ACT_STAGE_NEED_USER_KEY);
|
nm_act_request_set_stage (req, NM_ACT_STAGE_NEED_USER_KEY);
|
||||||
nm_act_request_set_user_key_pending_call (req, pcall);
|
nm_act_request_set_user_key_pending_call (req, pcall);
|
||||||
dbus_pending_call_set_notify (pcall, (DBusPendingCallNotifyFunction) nm_dbus_get_user_key_for_network_cb, req, NULL);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
nm_warning ("nm_dbus_get_user_key_for_network(): could not send dbus message");
|
nm_warning ("nm_dbus_get_user_key_for_network(): could not send dbus message");
|
||||||
@@ -357,6 +357,8 @@ static void nm_dbus_get_network_data_cb (DBusPendingCall *pcall, void *user_data
|
|||||||
g_return_if_fail (cb_data->network != NULL);
|
g_return_if_fail (cb_data->network != NULL);
|
||||||
g_return_if_fail (cb_data->list != NULL);
|
g_return_if_fail (cb_data->list != NULL);
|
||||||
|
|
||||||
|
nm_dbus_send_with_callback_replied (pcall, __func__);
|
||||||
|
|
||||||
dbus_pending_call_ref (pcall);
|
dbus_pending_call_ref (pcall);
|
||||||
|
|
||||||
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
||||||
@@ -496,19 +498,12 @@ static void nm_dbus_get_networks_cb (DBusPendingCall *pcall, void *user_data)
|
|||||||
g_return_if_fail (cb_data->list != NULL);
|
g_return_if_fail (cb_data->list != NULL);
|
||||||
g_return_if_fail (cb_data->data != NULL);
|
g_return_if_fail (cb_data->data != NULL);
|
||||||
|
|
||||||
|
nm_dbus_send_with_callback_replied (pcall, __func__);
|
||||||
|
|
||||||
dbus_pending_call_ref (pcall);
|
dbus_pending_call_ref (pcall);
|
||||||
|
|
||||||
if (!dbus_pending_call_get_completed (pcall))
|
|
||||||
{
|
|
||||||
nm_warning ("pending call was not completed.");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
||||||
{
|
|
||||||
nm_warning ("could not retrieve the reply.");
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
if (message_is_error (reply))
|
if (message_is_error (reply))
|
||||||
{
|
{
|
||||||
@@ -533,24 +528,19 @@ static void nm_dbus_get_networks_cb (DBusPendingCall *pcall, void *user_data)
|
|||||||
if ((message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "getNetworkProperties")))
|
if ((message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "getNetworkProperties")))
|
||||||
{
|
{
|
||||||
dbus_int32_t type_as_int32 = nm_ap_list_get_type (cb_data->list);
|
dbus_int32_t type_as_int32 = nm_ap_list_get_type (cb_data->list);
|
||||||
DBusPendingCall * net_pcall = NULL;
|
GetOneNetworkCBData * net_cb_data = g_slice_new0 (GetOneNetworkCBData);
|
||||||
|
|
||||||
|
net_cb_data->data = cb_data->data;
|
||||||
|
net_cb_data->network = g_strdup (value);
|
||||||
|
nm_ap_list_ref (cb_data->list);
|
||||||
|
net_cb_data->list = cb_data->list;
|
||||||
|
|
||||||
dbus_message_append_args (message, DBUS_TYPE_STRING, &value, DBUS_TYPE_INT32, &type_as_int32, DBUS_TYPE_INVALID);
|
dbus_message_append_args (message, DBUS_TYPE_STRING, &value, DBUS_TYPE_INT32, &type_as_int32, DBUS_TYPE_INVALID);
|
||||||
dbus_connection_send_with_reply (cb_data->data->dbus_connection, message, &net_pcall, -1);
|
nm_dbus_send_with_callback (cb_data->data->dbus_connection, message,
|
||||||
|
(DBusPendingCallNotifyFunction) nm_dbus_get_network_data_cb, net_cb_data,
|
||||||
|
(DBusFreeFunction) free_get_one_network_cb_data, __func__);
|
||||||
dbus_message_unref (message);
|
dbus_message_unref (message);
|
||||||
if (net_pcall)
|
|
||||||
{
|
|
||||||
GetOneNetworkCBData * net_cb_data = g_slice_new0 (GetOneNetworkCBData);
|
|
||||||
|
|
||||||
net_cb_data->data = cb_data->data;
|
|
||||||
net_cb_data->network = g_strdup (value);
|
|
||||||
nm_ap_list_ref (cb_data->list);
|
|
||||||
net_cb_data->list = cb_data->list;
|
|
||||||
|
|
||||||
dbus_pending_call_set_notify (net_pcall, nm_dbus_get_network_data_cb, net_cb_data, (DBusFreeFunction) free_get_one_network_cb_data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus_message_iter_next(&array_iter);
|
dbus_message_iter_next(&array_iter);
|
||||||
}
|
}
|
||||||
dbus_message_unref (reply);
|
dbus_message_unref (reply);
|
||||||
@@ -570,7 +560,7 @@ void nm_dbus_update_allowed_networks (DBusConnection *connection, NMAccessPointL
|
|||||||
{
|
{
|
||||||
DBusMessage * message;
|
DBusMessage * message;
|
||||||
dbus_int32_t type_as_int32 = nm_ap_list_get_type (list);
|
dbus_int32_t type_as_int32 = nm_ap_list_get_type (list);
|
||||||
DBusPendingCall * pcall = NULL;
|
GetNetworksCBData * cb_data;
|
||||||
|
|
||||||
g_return_if_fail (connection != NULL);
|
g_return_if_fail (connection != NULL);
|
||||||
g_return_if_fail (list != NULL);
|
g_return_if_fail (list != NULL);
|
||||||
@@ -578,19 +568,17 @@ void nm_dbus_update_allowed_networks (DBusConnection *connection, NMAccessPointL
|
|||||||
|
|
||||||
if (!(message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "getNetworks")))
|
if (!(message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "getNetworks")))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dbus_message_append_args (message, DBUS_TYPE_INT32, &type_as_int32, DBUS_TYPE_INVALID);
|
dbus_message_append_args (message, DBUS_TYPE_INT32, &type_as_int32, DBUS_TYPE_INVALID);
|
||||||
dbus_connection_send_with_reply (connection, message, &pcall, -1);
|
|
||||||
dbus_message_unref (message);
|
|
||||||
if (pcall)
|
|
||||||
{
|
|
||||||
GetNetworksCBData * cb_data = g_slice_new0 (GetNetworksCBData);
|
|
||||||
|
|
||||||
cb_data->data = data;
|
cb_data = g_slice_new0 (GetNetworksCBData);
|
||||||
nm_ap_list_ref (list);
|
cb_data->data = data;
|
||||||
cb_data->list = list;
|
nm_ap_list_ref (list);
|
||||||
dbus_pending_call_set_notify (pcall, nm_dbus_get_networks_cb, cb_data, (DBusFreeFunction) free_get_networks_cb_data);
|
cb_data->list = list;
|
||||||
}
|
|
||||||
|
nm_dbus_send_with_callback (cb_data->data->dbus_connection, message,
|
||||||
|
(DBusPendingCallNotifyFunction) nm_dbus_get_networks_cb, cb_data,
|
||||||
|
(DBusFreeFunction) free_get_networks_cb_data, __func__);
|
||||||
|
dbus_message_unref (message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -604,7 +592,6 @@ void nm_dbus_update_one_allowed_network (DBusConnection *connection, const char
|
|||||||
{
|
{
|
||||||
DBusMessage * message;
|
DBusMessage * message;
|
||||||
dbus_int32_t type_as_int32 = NETWORK_TYPE_ALLOWED;
|
dbus_int32_t type_as_int32 = NETWORK_TYPE_ALLOWED;
|
||||||
DBusPendingCall * pcall = NULL;
|
|
||||||
GetOneNetworkCBData * cb_data = NULL;
|
GetOneNetworkCBData * cb_data = NULL;
|
||||||
|
|
||||||
g_return_if_fail (connection != NULL);
|
g_return_if_fail (connection != NULL);
|
||||||
@@ -615,19 +602,17 @@ void nm_dbus_update_one_allowed_network (DBusConnection *connection, const char
|
|||||||
nm_warning ("nm_dbus_update_one_allowed_network(): Couldn't allocate the dbus message");
|
nm_warning ("nm_dbus_update_one_allowed_network(): Couldn't allocate the dbus message");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
dbus_message_append_args (message, DBUS_TYPE_STRING, &network, DBUS_TYPE_INT32, &type_as_int32, DBUS_TYPE_INVALID);
|
||||||
|
|
||||||
cb_data = g_slice_new0 (GetOneNetworkCBData);
|
cb_data = g_slice_new0 (GetOneNetworkCBData);
|
||||||
cb_data->data = data;
|
cb_data->data = data;
|
||||||
cb_data->network = g_strdup (network);
|
cb_data->network = g_strdup (network);
|
||||||
cb_data->list = data->allowed_ap_list;
|
cb_data->list = data->allowed_ap_list;
|
||||||
|
|
||||||
dbus_message_append_args (message, DBUS_TYPE_STRING, &network, DBUS_TYPE_INT32, &type_as_int32, DBUS_TYPE_INVALID);
|
nm_dbus_send_with_callback (cb_data->data->dbus_connection, message,
|
||||||
dbus_connection_send_with_reply (connection, message, &pcall, -1);
|
(DBusPendingCallNotifyFunction) nm_dbus_get_network_data_cb, cb_data,
|
||||||
|
(DBusFreeFunction) free_get_one_network_cb_data, __func__);
|
||||||
dbus_message_unref (message);
|
dbus_message_unref (message);
|
||||||
if (!pcall)
|
|
||||||
nm_warning ("nm_dbus_update_one_allowed_network(): pending call was NULL");
|
|
||||||
else
|
|
||||||
dbus_pending_call_set_notify (pcall, nm_dbus_get_network_data_cb, cb_data, (DBusFreeFunction) free_get_one_network_cb_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
130
utils/nm-utils.c
130
utils/nm-utils.c
@@ -25,6 +25,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <dbus/dbus.h>
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
|
|
||||||
gchar *nm_dbus_escape_object_path (const gchar *utf8_string)
|
gchar *nm_dbus_escape_object_path (const gchar *utf8_string)
|
||||||
@@ -348,3 +349,132 @@ nm_utils_essid_to_utf8 (const char *orig_essid)
|
|||||||
|
|
||||||
return new_essid;
|
return new_essid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pending Call Debug stuff
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
typedef struct PCallInfo
|
||||||
|
{
|
||||||
|
DBusPendingCall * pcall;
|
||||||
|
char * caller;
|
||||||
|
guint32 id;
|
||||||
|
GTimeVal start;
|
||||||
|
} PCallInfo;
|
||||||
|
|
||||||
|
static GStaticMutex pcall_mutex = G_STATIC_MUTEX_INIT;
|
||||||
|
static GHashTable * pcall_table = NULL;
|
||||||
|
static guint32 pcall_gid = 0;
|
||||||
|
static guint32 pcall_pending = 0;
|
||||||
|
|
||||||
|
|
||||||
|
DBusPendingCall *
|
||||||
|
nm_dbus_send_with_callback (DBusConnection *connection,
|
||||||
|
DBusMessage *msg,
|
||||||
|
DBusPendingCallNotifyFunction func,
|
||||||
|
gpointer data,
|
||||||
|
DBusFreeFunction free_func,
|
||||||
|
const char *caller)
|
||||||
|
{
|
||||||
|
PCallInfo * info = NULL;
|
||||||
|
DBusPendingCall * pcall = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (connection != NULL, NULL);
|
||||||
|
g_return_val_if_fail (msg != NULL, NULL);
|
||||||
|
g_return_val_if_fail (func != NULL, NULL);
|
||||||
|
g_return_val_if_fail (caller != NULL, NULL);
|
||||||
|
|
||||||
|
if (!(info = g_malloc0 (sizeof (PCallInfo))))
|
||||||
|
{
|
||||||
|
g_warning ("Error: '%s' couldn't allocate memory for tracking PCall.", caller);
|
||||||
|
if (free_func)
|
||||||
|
(*free_func)(data);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbus_connection_send_with_reply (connection, msg, &pcall, -1);
|
||||||
|
if (!pcall)
|
||||||
|
{
|
||||||
|
g_warning ("Error: '%s' couldn't send dbus message.", caller);
|
||||||
|
if (free_func)
|
||||||
|
(*free_func)(data);
|
||||||
|
g_free (info);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
dbus_pending_call_set_notify (pcall, func, data, free_func);
|
||||||
|
|
||||||
|
info->caller = g_strdup (caller);
|
||||||
|
info->pcall = pcall;
|
||||||
|
g_get_current_time (&info->start);
|
||||||
|
dbus_pending_call_ref (pcall);
|
||||||
|
|
||||||
|
g_static_mutex_lock (&pcall_mutex);
|
||||||
|
info->id = pcall_gid++;
|
||||||
|
pcall_pending++;
|
||||||
|
|
||||||
|
if (!pcall_table)
|
||||||
|
pcall_table = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||||
|
g_hash_table_insert (pcall_table, pcall, info);
|
||||||
|
|
||||||
|
#ifdef DBUS_PENDING_CALL_DEBUG
|
||||||
|
nm_info ("PCall Debug: new id %d (%p), from '%s' (%s), "
|
||||||
|
"%d pending.", info->id, pcall, info->caller,
|
||||||
|
dbus_message_get_member (msg), pcall_pending);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
g_static_mutex_unlock (&pcall_mutex);
|
||||||
|
|
||||||
|
return pcall;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nm_dbus_send_with_callback_replied (DBusPendingCall *pcall,
|
||||||
|
const char *caller)
|
||||||
|
{
|
||||||
|
PCallInfo * info;
|
||||||
|
#ifdef DBUS_PENDING_CALL_DEBUG
|
||||||
|
GTimeVal now;
|
||||||
|
long elapsed_ms = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
g_return_if_fail (pcall != NULL);
|
||||||
|
g_return_if_fail (caller != NULL);
|
||||||
|
|
||||||
|
g_static_mutex_lock (&pcall_mutex);
|
||||||
|
if (!(info = g_hash_table_lookup (pcall_table, pcall)))
|
||||||
|
{
|
||||||
|
nm_warning ("Error: couldn't find pending call %p in tracking"
|
||||||
|
" table.", pcall);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
pcall_pending--;
|
||||||
|
#ifdef DBUS_PENDING_CALL_DEBUG
|
||||||
|
g_get_current_time (&now);
|
||||||
|
if (info->start.tv_usec > now.tv_usec)
|
||||||
|
{
|
||||||
|
now.tv_sec--;
|
||||||
|
now.tv_usec = G_USEC_PER_SEC - (info->start.tv_usec - now.tv_usec);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
now.tv_usec -= info->start.tv_usec;
|
||||||
|
now.tv_sec -= info->start.tv_sec;
|
||||||
|
elapsed_ms = now.tv_sec * G_USEC_PER_SEC + now.tv_usec;
|
||||||
|
elapsed_ms /= 1000;
|
||||||
|
|
||||||
|
nm_info ("PCall Debug: unregistered ID %d (%p), %s -> %s,"
|
||||||
|
" %lums elapsed. Total pending: %d", info->id, info->pcall, info->caller,
|
||||||
|
caller, elapsed_ms, pcall_pending);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
g_hash_table_remove (pcall_table, pcall);
|
||||||
|
g_free (info->caller);
|
||||||
|
dbus_pending_call_unref (info->pcall);
|
||||||
|
g_free (info);
|
||||||
|
|
||||||
|
out:
|
||||||
|
g_static_mutex_unlock (&pcall_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
|
#include <dbus/dbus.h>
|
||||||
|
|
||||||
#define nm_print_backtrace() \
|
#define nm_print_backtrace() \
|
||||||
G_STMT_START \
|
G_STMT_START \
|
||||||
@@ -130,4 +131,15 @@ gchar *nm_dbus_unescape_object_path (const gchar *object_path);
|
|||||||
|
|
||||||
char *nm_utils_essid_to_utf8 (const char *orig_essid);
|
char *nm_utils_essid_to_utf8 (const char *orig_essid);
|
||||||
|
|
||||||
|
/* #define DBUS_PENDING_CALL_DEBUG */
|
||||||
|
|
||||||
|
DBusPendingCall * nm_dbus_send_with_callback (DBusConnection *connection,
|
||||||
|
DBusMessage *msg,
|
||||||
|
DBusPendingCallNotifyFunction func,
|
||||||
|
gpointer data,
|
||||||
|
DBusFreeFunction free_func,
|
||||||
|
const char *caller);
|
||||||
|
void nm_dbus_send_with_callback_replied (DBusPendingCall *pcall,
|
||||||
|
const char *caller);
|
||||||
|
|
||||||
#endif /* NM_UTILS_H */
|
#endif /* NM_UTILS_H */
|
||||||
|
Reference in New Issue
Block a user