mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-30 20:10:10 +01:00
2006-05-21 Dan Williams <dcbw@redhat.com>
Fix gnome.org #330832 based on patch from Crispin Flowerday <crispin@gnome.org> * src/NetworkManagerDbus.[ch] - nm_dbus_get_device_from_object_path -> nm_dbus_get_device_from_escaped_object_path: clarify that function's argument should be an escaped dbus object path, and look for path segment end before returning a match * src/nm-dbus-nm.c: - Fix up users of nm_dbus_get_device_from_escaped_object_path() git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1749 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
28e809b751
commit
bc52f21f37
4 changed files with 45 additions and 46 deletions
11
ChangeLog
11
ChangeLog
|
|
@ -1,3 +1,14 @@
|
|||
2006-05-21 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
Fix gnome.org #330832 based on patch from Crispin Flowerday <crispin@gnome.org>
|
||||
|
||||
* src/NetworkManagerDbus.[ch]
|
||||
- nm_dbus_get_device_from_object_path -> nm_dbus_get_device_from_escaped_object_path:
|
||||
clarify that function's argument should be an escaped dbus object
|
||||
path, and look for path segment end before returning a match
|
||||
* src/nm-dbus-nm.c:
|
||||
- Fix up users of nm_dbus_get_device_from_escaped_object_path()
|
||||
|
||||
2006-05-17 Robert Love <rml@novell.com>
|
||||
|
||||
Functionality to differentiate Ad-Hoc networks from infrastructure
|
||||
|
|
|
|||
|
|
@ -119,52 +119,50 @@ char * nm_dbus_get_object_path_for_network (NMDevice *dev, NMAccessPoint *ap)
|
|||
|
||||
|
||||
/*
|
||||
* nm_dbus_get_device_from_object_path
|
||||
* nm_dbus_get_device_from_escaped_object_path
|
||||
*
|
||||
* Returns the device associated with a dbus object path
|
||||
* Returns the device associated with an _escaped_ dbus object path
|
||||
*
|
||||
*/
|
||||
NMDevice *nm_dbus_get_device_from_object_path (NMData *data, const char *path)
|
||||
NMDevice *nm_dbus_get_device_from_escaped_object_path (NMData *data, const char *path)
|
||||
{
|
||||
NMDevice *dev = NULL;
|
||||
NMDevice *dev = NULL;
|
||||
GSList * elt;
|
||||
|
||||
g_return_val_if_fail (path != NULL, NULL);
|
||||
g_return_val_if_fail (data != NULL, NULL);
|
||||
|
||||
/* FIXME
|
||||
* This function could be much more efficient, for example we could
|
||||
* actually _parse_ the object path, but that's a lot more code and
|
||||
* stupid stuff. The approach below is slower, less efficient, but
|
||||
* less code and less error-prone.
|
||||
*/
|
||||
if (!nm_try_acquire_mutex (data->dev_list_mutex, __FUNCTION__))
|
||||
return NULL;
|
||||
|
||||
/* Iterate over device list */
|
||||
if (nm_try_acquire_mutex (data->dev_list_mutex, __FUNCTION__))
|
||||
/* Iterate over the device list looking for the device with the matching object path. */
|
||||
for (elt = data->dev_list; elt; elt = g_slist_next (elt))
|
||||
{
|
||||
GSList *elt;
|
||||
char compare_path[100];
|
||||
char *escaped_compare_path;
|
||||
char *compare_path;
|
||||
char *escaped_compare_path;
|
||||
int len;
|
||||
|
||||
for (elt = data->dev_list; elt; elt = g_slist_next (elt))
|
||||
if (!(dev = (NMDevice *)(elt->data)))
|
||||
continue;
|
||||
|
||||
compare_path = g_strdup_printf ("%s/%s", NM_DBUS_PATH_DEVICES, nm_device_get_iface (dev));
|
||||
escaped_compare_path = nm_dbus_escape_object_path (compare_path);
|
||||
g_free (compare_path);
|
||||
len = strlen (escaped_compare_path);
|
||||
|
||||
/* Compare against our constructed path, but ignore any trailing elements */
|
||||
if ( (strncmp (path, escaped_compare_path, len) == 0)
|
||||
&& ((path[len] == '\0' || path[len] == '/')))
|
||||
{
|
||||
if ((dev = (NMDevice *)(elt->data)))
|
||||
{
|
||||
snprintf (compare_path, 100, "%s/%s", NM_DBUS_PATH_DEVICES, nm_device_get_iface (dev));
|
||||
escaped_compare_path = nm_dbus_escape_object_path (compare_path);
|
||||
/* Compare against our constructed path, but ignore any trailing elements */
|
||||
if (strncmp (path, compare_path, strlen (escaped_compare_path)) == 0)
|
||||
{
|
||||
g_free (escaped_compare_path);
|
||||
break;
|
||||
}
|
||||
g_free (escaped_compare_path);
|
||||
dev = NULL;
|
||||
}
|
||||
g_free (escaped_compare_path);
|
||||
break;
|
||||
}
|
||||
nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
|
||||
g_free (escaped_compare_path);
|
||||
dev = NULL;
|
||||
}
|
||||
nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
|
||||
|
||||
return (dev);
|
||||
return dev;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -617,7 +615,7 @@ static DBusHandlerResult nm_dbus_devices_message_handler (DBusConnection *connec
|
|||
|
||||
path = dbus_message_get_path (message);
|
||||
|
||||
if (!(dev = nm_dbus_get_device_from_object_path (data, path)))
|
||||
if (!(dev = nm_dbus_get_device_from_escaped_object_path (data, path)))
|
||||
reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE, "DeviceNotFound", "The requested network device does not exist.");
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ void nm_dbus_signal_state_change (DBusConnection *connection, NMData *data);
|
|||
void nm_dbus_signal_wireless_network_change (DBusConnection *connection, NMDevice80211Wireless *dev, NMAccessPoint *ap, NMNetworkStatus status, gint strength);
|
||||
void nm_dbus_signal_device_strength_change (DBusConnection *connection, NMDevice80211Wireless *dev, gint strength);
|
||||
|
||||
NMDevice * nm_dbus_get_device_from_object_path (NMData *data, const char *path);
|
||||
NMDevice * nm_dbus_get_device_from_escaped_object_path (NMData *data, const char *path);
|
||||
|
||||
NMState nm_get_app_state_from_data (NMData *data);
|
||||
|
||||
|
|
|
|||
|
|
@ -228,7 +228,6 @@ static DBusMessage *nm_dbus_nm_set_active_device (DBusConnection *connection, DB
|
|||
NMDevice * dev = NULL;
|
||||
DBusMessage * reply = NULL;
|
||||
char * dev_path;
|
||||
char * unescaped_dev_path = NULL;
|
||||
NMAccessPoint * ap = NULL;
|
||||
DBusMessageIter iter;
|
||||
|
||||
|
|
@ -247,9 +246,7 @@ static DBusMessage *nm_dbus_nm_set_active_device (DBusConnection *connection, DB
|
|||
}
|
||||
|
||||
dbus_message_iter_get_basic (&iter, &dev_path);
|
||||
unescaped_dev_path = nm_dbus_unescape_object_path (dev_path);
|
||||
dev = nm_dbus_get_device_from_object_path (data->data, unescaped_dev_path);
|
||||
g_free (unescaped_dev_path);
|
||||
dev = nm_dbus_get_device_from_escaped_object_path (data->data, dev_path);
|
||||
|
||||
/* Ensure the device exists in our list and is supported */
|
||||
if (!dev || !(nm_device_get_capabilities (dev) & NM_DEVICE_CAP_NM_SUPPORTED))
|
||||
|
|
@ -332,7 +329,6 @@ static DBusMessage *nm_dbus_nm_create_wireless_network (DBusConnection *connecti
|
|||
NMDevice * dev = NULL;
|
||||
DBusMessage * reply = NULL;
|
||||
char * dev_path = NULL;
|
||||
char * unescaped_dev_path = NULL;
|
||||
NMAccessPoint * new_ap = NULL;
|
||||
NMAPSecurity * security = NULL;
|
||||
char * essid = NULL;
|
||||
|
|
@ -352,9 +348,7 @@ static DBusMessage *nm_dbus_nm_create_wireless_network (DBusConnection *connecti
|
|||
}
|
||||
|
||||
dbus_message_iter_get_basic (&iter, &dev_path);
|
||||
unescaped_dev_path = nm_dbus_unescape_object_path (dev_path);
|
||||
dev = nm_dbus_get_device_from_object_path (data->data, unescaped_dev_path);
|
||||
g_free (unescaped_dev_path);
|
||||
dev = nm_dbus_get_device_from_escaped_object_path (data->data, dev_path);
|
||||
|
||||
/* Ensure the device exists in our list and is supported */
|
||||
if (!dev || !(nm_device_get_capabilities (dev) & NM_DEVICE_CAP_NM_SUPPORTED))
|
||||
|
|
@ -452,9 +446,7 @@ static DBusMessage *nm_dbus_nm_remove_test_device (DBusConnection *connection, D
|
|||
{
|
||||
NMDevice *dev;
|
||||
|
||||
dev_path = nm_dbus_unescape_object_path (dev_path);
|
||||
|
||||
if ((dev = nm_dbus_get_device_from_object_path (data->data, dev_path)))
|
||||
if ((dev = nm_dbus_get_device_from_escaped_object_path (data->data, dev_path)))
|
||||
{
|
||||
if (nm_device_is_test_device (dev))
|
||||
nm_remove_device (data->data, dev);
|
||||
|
|
@ -467,8 +459,6 @@ static DBusMessage *nm_dbus_nm_remove_test_device (DBusConnection *connection, D
|
|||
reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE, "DeviceNotFound",
|
||||
"The requested network device does not exist.");
|
||||
}
|
||||
|
||||
g_free (dev_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue