2005-01-09 Dan Williams <dcbw@redhat.com>
* dhcpcd/client.c - Use correct timeout value * info-daemon/NetworkManagerInfoDbus.c src/NetworkManagerDbus.c - Consolidate communication between NM and NMI by doing only 1 dbus method call to get Wireless Network info from NMI instead of 6 * src/NetworkManager.c - Make sure to cancel activation when we receive a SIGTERM, otherwise when we didn't have an AP to use, we'd wait for one forever without quitting * src/NetworkManagerDevice.c - nm_device_activation_cancel(): Fix a race between dhcp and quitting activation, dhcp might not have started yet but we don't quit activation before starting it, so the quit signal gets lost git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@363 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
20
ChangeLog
20
ChangeLog
@@ -1,3 +1,23 @@
|
|||||||
|
2005-01-09 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
|
* dhcpcd/client.c
|
||||||
|
- Use correct timeout value
|
||||||
|
|
||||||
|
* info-daemon/NetworkManagerInfoDbus.c
|
||||||
|
src/NetworkManagerDbus.c
|
||||||
|
- Consolidate communication between NM and NMI by doing only 1 dbus
|
||||||
|
method call to get Wireless Network info from NMI instead of 6
|
||||||
|
|
||||||
|
* src/NetworkManager.c
|
||||||
|
- Make sure to cancel activation when we receive a SIGTERM, otherwise
|
||||||
|
when we didn't have an AP to use, we'd wait for one forever without
|
||||||
|
quitting
|
||||||
|
|
||||||
|
* src/NetworkManagerDevice.c
|
||||||
|
- nm_device_activation_cancel(): Fix a race between dhcp and quitting
|
||||||
|
activation, dhcp might not have started yet but we don't quit activation
|
||||||
|
before starting it, so the quit signal gets lost
|
||||||
|
|
||||||
2005-01-07 Dan Williams <dcbw@redhat.com>
|
2005-01-07 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
* dhcpcd/client.c
|
* dhcpcd/client.c
|
||||||
|
@@ -555,7 +555,8 @@ int dhcp_handle_transaction (dhcp_interface *iface, unsigned int expected_reply_
|
|||||||
|
|
||||||
/* Packet receive loop */
|
/* Packet receive loop */
|
||||||
data_good = 0;
|
data_good = 0;
|
||||||
while ((timeval_subtract (&diff, &overall_end, &recv_end) == 0) && !data_good)
|
gettimeofday (¤t, NULL);
|
||||||
|
while ((timeval_subtract (&diff, &recv_end, ¤t) == 0) && !data_good)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
int o;
|
int o;
|
||||||
@@ -571,6 +572,8 @@ int dhcp_handle_transaction (dhcp_interface *iface, unsigned int expected_reply_
|
|||||||
}
|
}
|
||||||
syslog (LOG_INFO, "DHCP: Got some data to check for reply packet.");
|
syslog (LOG_INFO, "DHCP: Got some data to check for reply packet.");
|
||||||
|
|
||||||
|
gettimeofday (¤t, NULL);
|
||||||
|
|
||||||
/* Ok, we allegedly have the data we need, so grab it from the queue */
|
/* Ok, we allegedly have the data we need, so grab it from the queue */
|
||||||
o = sizeof (struct sockaddr_ll);
|
o = sizeof (struct sockaddr_ll);
|
||||||
len = recvfrom (recv_sk, pkt_recv, ETH_FRAME_LEN, 0, (struct sockaddr *)&server_hw_addr, &o);
|
len = recvfrom (recv_sk, pkt_recv, ETH_FRAME_LEN, 0, (struct sockaddr *)&server_hw_addr, &o);
|
||||||
|
@@ -328,25 +328,31 @@ static DBusMessage *nmi_dbus_get_networks (NMIAppInfo *info, DBusMessage *messag
|
|||||||
|
|
||||||
return (reply_message);
|
return (reply_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nmi_dbus_get_network_timestamp
|
* nmi_dbus_get_network
|
||||||
*
|
*
|
||||||
* If the specified network exists, get its timestamp from gconf
|
* Returns the properties of a specific wireless network from gconf
|
||||||
* and pass it back as a dbus message.
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static DBusMessage *nmi_dbus_get_network_timestamp (NMIAppInfo *info, DBusMessage *message)
|
static DBusMessage *nmi_dbus_get_network_properties (NMIAppInfo *info, DBusMessage *message)
|
||||||
{
|
{
|
||||||
DBusMessage *reply_message = NULL;
|
DBusMessage *reply_message = NULL;
|
||||||
gchar *key = NULL;
|
gchar *gconf_key = NULL;
|
||||||
char *network = NULL;
|
char *network = NULL;
|
||||||
GConfValue *value;
|
GConfValue *value;
|
||||||
|
GConfValue *ap_addrs_value;
|
||||||
DBusError error;
|
DBusError error;
|
||||||
NMNetworkType type;
|
NMNetworkType type;
|
||||||
char *escaped_network;
|
char *escaped_network;
|
||||||
|
|
||||||
|
char *essid = NULL;
|
||||||
|
gint timestamp = -1;
|
||||||
|
char *key = NULL;
|
||||||
|
NMEncKeyType key_type = -1;
|
||||||
|
gboolean trusted = FALSE;
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
g_return_val_if_fail (info != NULL, NULL);
|
||||||
g_return_val_if_fail (message != NULL, NULL);
|
g_return_val_if_fail (message != NULL, NULL);
|
||||||
|
|
||||||
@@ -356,270 +362,127 @@ static DBusMessage *nmi_dbus_get_network_timestamp (NMIAppInfo *info, DBusMessag
|
|||||||
|| (strlen (network) <= 0))
|
|| (strlen (network) <= 0))
|
||||||
{
|
{
|
||||||
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments",
|
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments",
|
||||||
"NetworkManagerInfo::getNetworkTimestamp called with invalid arguments.");
|
"NetworkManagerInfo::getNetworkProperties called with invalid arguments.");
|
||||||
return (reply_message);
|
return (reply_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Grab timestamp key for our access point from GConf */
|
|
||||||
escaped_network = gconf_escape_key (network, strlen (network));
|
escaped_network = gconf_escape_key (network, strlen (network));
|
||||||
key = g_strdup_printf ("%s/%s/timestamp", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
|
||||||
g_free (escaped_network);
|
|
||||||
value = gconf_client_get (info->gconf_client, key, NULL);
|
|
||||||
g_free (key);
|
|
||||||
|
|
||||||
if (value)
|
|
||||||
{
|
|
||||||
reply_message = dbus_message_new_method_return (message);
|
|
||||||
dbus_message_append_args (reply_message, DBUS_TYPE_INT32, gconf_value_get_int (value), DBUS_TYPE_INVALID);
|
|
||||||
gconf_value_free (value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadNetworkData",
|
|
||||||
"NetworkManagerInfo::getNetworkTimestamp could not access data for network '%s'", network);
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_free (network);
|
|
||||||
return (reply_message);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nmi_dbus_get_network_essid
|
|
||||||
*
|
|
||||||
* If the specified network exists, get its essid from gconf
|
|
||||||
* and pass it back as a dbus message.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static DBusMessage *nmi_dbus_get_network_essid (NMIAppInfo *info, DBusMessage *message)
|
|
||||||
{
|
|
||||||
DBusMessage *reply_message = NULL;
|
|
||||||
gchar *key = NULL;
|
|
||||||
char *network = NULL;
|
|
||||||
GConfValue *value;
|
|
||||||
DBusError error;
|
|
||||||
NMNetworkType type;
|
|
||||||
char *escaped_network;
|
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
|
||||||
g_return_val_if_fail (message != NULL, NULL);
|
|
||||||
|
|
||||||
dbus_error_init (&error);
|
|
||||||
if ( !dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &network, DBUS_TYPE_INT32, &type, DBUS_TYPE_INVALID)
|
|
||||||
|| !nmi_network_type_valid (type)
|
|
||||||
|| (strlen (network) <= 0))
|
|
||||||
{
|
|
||||||
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments",
|
|
||||||
"NetworkManagerInfo::getNetworkEssid called with invalid arguments.");
|
|
||||||
return (reply_message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Grab essid key for our access point from GConf */
|
/* Grab essid key for our access point from GConf */
|
||||||
escaped_network = gconf_escape_key (network, strlen (network));
|
gconf_key = g_strdup_printf ("%s/%s/essid", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
||||||
key = g_strdup_printf ("%s/%s/essid", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
if ((value = gconf_client_get (info->gconf_client, gconf_key, NULL)))
|
||||||
g_free (escaped_network);
|
|
||||||
value = gconf_client_get (info->gconf_client, key, NULL);
|
|
||||||
g_free (key);
|
|
||||||
|
|
||||||
if (value)
|
|
||||||
{
|
{
|
||||||
reply_message = dbus_message_new_method_return (message);
|
essid = g_strdup (gconf_value_get_string (value));
|
||||||
dbus_message_append_args (reply_message, DBUS_TYPE_STRING, gconf_value_get_string (value), DBUS_TYPE_INVALID);
|
gconf_value_free (value);
|
||||||
|
}
|
||||||
|
g_free (gconf_key);
|
||||||
|
|
||||||
|
/* Grab timestamp key for our access point from GConf */
|
||||||
|
gconf_key = g_strdup_printf ("%s/%s/timestamp", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
||||||
|
if ((value = gconf_client_get (info->gconf_client, gconf_key, NULL)))
|
||||||
|
{
|
||||||
|
timestamp = gconf_value_get_int (value);
|
||||||
|
gconf_value_free (value);
|
||||||
|
}
|
||||||
|
g_free (gconf_key);
|
||||||
|
|
||||||
|
/* Grab user-key key for our access point from GConf */
|
||||||
|
gconf_key = g_strdup_printf ("%s/%s/key", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
||||||
|
if ((value = gconf_client_get (info->gconf_client, gconf_key, NULL)))
|
||||||
|
{
|
||||||
|
key = g_strdup (gconf_value_get_string (value));
|
||||||
gconf_value_free (value);
|
gconf_value_free (value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
key = g_strdup ("");
|
||||||
|
g_free (gconf_key);
|
||||||
|
|
||||||
|
gconf_key = g_strdup_printf ("%s/%s/key_type", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
||||||
|
if ((value = gconf_client_get (info->gconf_client, gconf_key, NULL)))
|
||||||
{
|
{
|
||||||
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadNetworkData",
|
key_type = gconf_value_get_int (value);
|
||||||
"NetworkManagerInfo::getNetworkEssid could not access data for network '%s'", network);
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_free (network);
|
|
||||||
return (reply_message);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nmi_dbus_get_network_key
|
|
||||||
*
|
|
||||||
* If the specified network exists, get its key and key type from gconf
|
|
||||||
* and pass it back as a dbus message.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static DBusMessage *nmi_dbus_get_network_key (NMIAppInfo *info, DBusMessage *message)
|
|
||||||
{
|
|
||||||
DBusMessage *reply_message = NULL;
|
|
||||||
gchar *key = NULL;
|
|
||||||
char *network = NULL;
|
|
||||||
GConfValue *key_value;
|
|
||||||
GConfValue *key_type_value;
|
|
||||||
DBusError error;
|
|
||||||
NMNetworkType type;
|
|
||||||
char *escaped_network;
|
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
|
||||||
g_return_val_if_fail (message != NULL, NULL);
|
|
||||||
|
|
||||||
dbus_error_init (&error);
|
|
||||||
if ( !dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &network, DBUS_TYPE_INT32, &type, DBUS_TYPE_INVALID)
|
|
||||||
|| !nmi_network_type_valid (type)
|
|
||||||
|| (strlen (network) <= 0))
|
|
||||||
{
|
|
||||||
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments",
|
|
||||||
"NetworkManagerInfo::getNetworkKey called with invalid arguments.");
|
|
||||||
return (reply_message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Grab user-key key for our access point from GConf */
|
|
||||||
escaped_network = gconf_escape_key (network, strlen (network));
|
|
||||||
key = g_strdup_printf ("%s/%s/key", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
|
||||||
key_value = gconf_client_get (info->gconf_client, key, NULL);
|
|
||||||
g_free (key);
|
|
||||||
|
|
||||||
key = g_strdup_printf ("%s/%s/key_type", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
|
||||||
key_type_value = gconf_client_get (info->gconf_client, key, NULL);
|
|
||||||
g_free (key);
|
|
||||||
g_free (escaped_network);
|
|
||||||
|
|
||||||
/* We don't error out if no key was found in gconf, we return blank key */
|
|
||||||
reply_message = dbus_message_new_method_return (message);
|
|
||||||
if (key_value && key_type_value)
|
|
||||||
{
|
|
||||||
dbus_message_append_args (reply_message, DBUS_TYPE_STRING, gconf_value_get_string (key_value),
|
|
||||||
DBUS_TYPE_INT32, gconf_value_get_int (key_type_value), DBUS_TYPE_INVALID);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
dbus_message_append_args (reply_message, DBUS_TYPE_STRING, "", DBUS_TYPE_INT32, -1, DBUS_TYPE_INVALID);
|
|
||||||
|
|
||||||
if (key_value)
|
|
||||||
gconf_value_free (key_value);
|
|
||||||
if (key_type_value)
|
|
||||||
gconf_value_free (key_type_value);
|
|
||||||
|
|
||||||
return (reply_message);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nmi_dbus_get_network_trusted
|
|
||||||
*
|
|
||||||
* If the specified network exists, get its "trusted" value
|
|
||||||
* from gconf and pass it back.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static DBusMessage *nmi_dbus_get_network_trusted (NMIAppInfo *info, DBusMessage *message)
|
|
||||||
{
|
|
||||||
DBusMessage *reply_message = NULL;
|
|
||||||
gchar *key = NULL;
|
|
||||||
char *network = NULL;
|
|
||||||
GConfValue *value;
|
|
||||||
DBusError error;
|
|
||||||
NMNetworkType type;
|
|
||||||
char *escaped_network;
|
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
|
||||||
g_return_val_if_fail (message != NULL, NULL);
|
|
||||||
|
|
||||||
dbus_error_init (&error);
|
|
||||||
if ( !dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &network, DBUS_TYPE_INT32, &type, DBUS_TYPE_INVALID)
|
|
||||||
|| !nmi_network_type_valid (type)
|
|
||||||
|| (strlen (network) <= 0))
|
|
||||||
{
|
|
||||||
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments",
|
|
||||||
"NetworkManagerInfo::getNetworkTrusted called with invalid arguments.");
|
|
||||||
return (reply_message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Grab user-key key for our access point from GConf */
|
|
||||||
escaped_network = gconf_escape_key (network, strlen (network));
|
|
||||||
key = g_strdup_printf ("%s/%s/trusted", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
|
||||||
g_free (escaped_network);
|
|
||||||
value = gconf_client_get (info->gconf_client, key, NULL);
|
|
||||||
g_free (key);
|
|
||||||
|
|
||||||
/* We don't error out if no key was found in gconf, we return blank key */
|
|
||||||
reply_message = dbus_message_new_method_return (message);
|
|
||||||
if (value)
|
|
||||||
{
|
|
||||||
dbus_message_append_args (reply_message, DBUS_TYPE_BOOLEAN, gconf_value_get_bool (value), DBUS_TYPE_INVALID);
|
|
||||||
gconf_value_free (value);
|
gconf_value_free (value);
|
||||||
}
|
}
|
||||||
else
|
g_free (gconf_key);
|
||||||
dbus_message_append_args (reply_message, DBUS_TYPE_BOOLEAN, FALSE, DBUS_TYPE_INVALID);
|
|
||||||
|
|
||||||
return (reply_message);
|
/* Grab the network's trusted status */
|
||||||
}
|
gconf_key = g_strdup_printf ("%s/%s/trusted", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
||||||
|
if ((value = gconf_client_get (info->gconf_client, gconf_key, NULL)))
|
||||||
|
|
||||||
/*
|
|
||||||
* nmi_dbus_get_network_addresses
|
|
||||||
*
|
|
||||||
* If the specified network exists, grabs a list of AP MAC addresses
|
|
||||||
* from gconf and pass it back.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static DBusMessage *nmi_dbus_get_network_addresses (NMIAppInfo *info, DBusMessage *message)
|
|
||||||
{
|
|
||||||
DBusMessage *reply_message = NULL;
|
|
||||||
char *network = NULL;
|
|
||||||
NMNetworkType type;
|
|
||||||
char *key;
|
|
||||||
GConfValue *value;
|
|
||||||
DBusError error;
|
|
||||||
char *escaped_network;
|
|
||||||
gboolean success = FALSE;
|
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
|
||||||
g_return_val_if_fail (message != NULL, NULL);
|
|
||||||
|
|
||||||
dbus_error_init (&error);
|
|
||||||
if ( !dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &network, DBUS_TYPE_INT32, &type, DBUS_TYPE_INVALID)
|
|
||||||
|| !nmi_network_type_valid (type)
|
|
||||||
|| (strlen (network) <= 0))
|
|
||||||
{
|
{
|
||||||
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments",
|
trusted = gconf_value_get_bool (value);
|
||||||
"NetworkManagerInfo::getNetworkAddresses called with invalid arguments.");
|
gconf_value_free (value);
|
||||||
return (reply_message);
|
|
||||||
}
|
}
|
||||||
|
g_free (gconf_key);
|
||||||
|
|
||||||
/* Grab user-key key for our access point from GConf */
|
/* Grab the list of stored AP MAC addresses */
|
||||||
escaped_network = gconf_escape_key (network, strlen (network));
|
gconf_key = g_strdup_printf ("%s/%s/addresses", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
||||||
key = g_strdup_printf ("%s/%s/addresses", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
ap_addrs_value = gconf_client_get (info->gconf_client, gconf_key, NULL);
|
||||||
g_free (escaped_network);
|
g_free (gconf_key);
|
||||||
value = gconf_client_get (info->gconf_client, key, NULL);
|
|
||||||
g_free (key);
|
|
||||||
|
|
||||||
/* We don't error out if no key was found in gconf, we return blank key */
|
if (!essid || (timestamp < 0) || (key_type < 0))
|
||||||
reply_message = dbus_message_new_method_return (message);
|
{
|
||||||
if (value && (value->type == GCONF_VALUE_LIST) && (gconf_value_get_list_type (value) == GCONF_VALUE_STRING))
|
if (!essid)
|
||||||
|
{
|
||||||
|
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadNetworkData",
|
||||||
|
"NetworkManagerInfo::getNetworkProperties could not access essid for network '%s'", network);
|
||||||
|
}
|
||||||
|
else if (timestamp < 0)
|
||||||
|
{
|
||||||
|
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadNetworkData",
|
||||||
|
"NetworkManagerInfo::getNetworkProperties could not access timestamp for network '%s'", network);
|
||||||
|
}
|
||||||
|
else if (key_type < 0)
|
||||||
|
{
|
||||||
|
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadNetworkData",
|
||||||
|
"NetworkManagerInfo::getNetworkProperties could not access key_type for network '%s'", network);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
DBusMessageIter iter;
|
DBusMessageIter iter;
|
||||||
DBusMessageIter iter_array;
|
DBusMessageIter iter_array;
|
||||||
GSList *list = gconf_value_get_list (value);
|
gboolean success = FALSE;
|
||||||
GSList *elem = list;
|
|
||||||
|
|
||||||
|
reply_message = dbus_message_new_method_return (message);
|
||||||
dbus_message_iter_init (reply_message, &iter);
|
dbus_message_iter_init (reply_message, &iter);
|
||||||
|
|
||||||
|
/* Add general properties to dbus reply */
|
||||||
|
dbus_message_iter_append_string (&iter, essid);
|
||||||
|
dbus_message_iter_append_int32 (&iter, timestamp);
|
||||||
|
dbus_message_iter_append_string (&iter, key);
|
||||||
|
dbus_message_iter_append_int32 (&iter, key_type);
|
||||||
|
dbus_message_iter_append_boolean(&iter, trusted);
|
||||||
|
|
||||||
dbus_message_iter_append_array (&iter, &iter_array, DBUS_TYPE_STRING);
|
dbus_message_iter_append_array (&iter, &iter_array, DBUS_TYPE_STRING);
|
||||||
|
|
||||||
while (elem != NULL)
|
/* Add a string array of access point MAC addresses if the array is valid */
|
||||||
|
if (ap_addrs_value && (ap_addrs_value->type == GCONF_VALUE_LIST) && (gconf_value_get_list_type (ap_addrs_value) == GCONF_VALUE_STRING))
|
||||||
{
|
{
|
||||||
const char *string = gconf_value_get_string ((GConfValue *)elem->data);
|
GSList *list = gconf_value_get_list (ap_addrs_value);
|
||||||
if (string)
|
GSList *elem = list;
|
||||||
|
|
||||||
|
while (elem != NULL)
|
||||||
{
|
{
|
||||||
dbus_message_iter_append_string (&iter_array, string);
|
const char *string = gconf_value_get_string ((GConfValue *)elem->data);
|
||||||
success = TRUE;
|
if (string)
|
||||||
|
{
|
||||||
|
dbus_message_iter_append_string (&iter_array, string);
|
||||||
|
success = TRUE;
|
||||||
|
}
|
||||||
|
elem = g_slist_next (elem);
|
||||||
}
|
}
|
||||||
elem = g_slist_next (elem);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
gconf_value_free (value);
|
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
dbus_message_iter_append_string (&iter_array, "");
|
||||||
dbus_message_unref (reply_message);
|
}
|
||||||
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "NoAddresses",
|
gconf_value_free (ap_addrs_value);
|
||||||
"There were no stored addresses for this wireless network.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
g_free (essid);
|
||||||
|
g_free (key);
|
||||||
|
|
||||||
|
g_free (escaped_network);
|
||||||
|
dbus_free (network);
|
||||||
return (reply_message);
|
return (reply_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -761,16 +624,8 @@ static DBusHandlerResult nmi_dbus_nmi_message_handler (DBusConnection *connectio
|
|||||||
}
|
}
|
||||||
else if (strcmp ("getNetworks", method) == 0)
|
else if (strcmp ("getNetworks", method) == 0)
|
||||||
reply_message = nmi_dbus_get_networks (info, message);
|
reply_message = nmi_dbus_get_networks (info, message);
|
||||||
else if (strcmp ("getNetworkTimestamp", method) == 0)
|
else if (strcmp ("getNetworkProperties", method) == 0)
|
||||||
reply_message = nmi_dbus_get_network_timestamp (info, message);
|
reply_message = nmi_dbus_get_network_properties (info, message);
|
||||||
else if (strcmp ("getNetworkEssid", method) == 0)
|
|
||||||
reply_message = nmi_dbus_get_network_essid (info, message);
|
|
||||||
else if (strcmp ("getNetworkKey", method) == 0)
|
|
||||||
reply_message = nmi_dbus_get_network_key (info, message);
|
|
||||||
else if (strcmp ("getNetworkTrusted", method) == 0)
|
|
||||||
reply_message = nmi_dbus_get_network_trusted (info, message);
|
|
||||||
else if (strcmp ("getNetworkAddresses", method) == 0)
|
|
||||||
reply_message = nmi_dbus_get_network_addresses (info, message);
|
|
||||||
else if (strcmp ("addNetworkAddress", method) == 0)
|
else if (strcmp ("addNetworkAddress", method) == 0)
|
||||||
nmi_dbus_add_network_address (info, message);
|
nmi_dbus_add_network_address (info, message);
|
||||||
else
|
else
|
||||||
|
@@ -621,6 +621,8 @@ static gboolean sigterm_pipe_handler (GIOChannel *src, GIOCondition condition, g
|
|||||||
{
|
{
|
||||||
NMData *data = user_data;
|
NMData *data = user_data;
|
||||||
syslog (LOG_NOTICE, "Caught terminiation signal");
|
syslog (LOG_NOTICE, "Caught terminiation signal");
|
||||||
|
if (data->active_device && nm_device_is_activating (data->active_device))
|
||||||
|
nm_device_activation_cancel (data->active_device);
|
||||||
g_main_loop_quit (data->main_loop);
|
g_main_loop_quit (data->main_loop);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@@ -299,76 +299,35 @@ NMAccessPoint *nm_ap_list_get_ap_by_address (NMAccessPointList *list, const stru
|
|||||||
void nm_ap_list_update_network (NMAccessPointList *list, const char *network, NMData *data)
|
void nm_ap_list_update_network (NMAccessPointList *list, const char *network, NMData *data)
|
||||||
{
|
{
|
||||||
NMAccessPoint *ap = NULL;
|
NMAccessPoint *ap = NULL;
|
||||||
|
NMAccessPoint *list_ap = NULL;
|
||||||
char *essid = NULL;
|
char *essid = NULL;
|
||||||
|
|
||||||
g_return_if_fail (list != NULL);
|
g_return_if_fail (list != NULL);
|
||||||
g_return_if_fail (network != NULL);
|
g_return_if_fail (network != NULL);
|
||||||
g_return_if_fail (list->type == NETWORK_TYPE_ALLOWED);
|
g_return_if_fail (list->type == NETWORK_TYPE_ALLOWED);
|
||||||
|
|
||||||
/* Get the allowed access point's details from NetworkManagerInfo */
|
if ((ap = nm_dbus_get_network_object (data->dbus_connection, list->type, network)))
|
||||||
if ((essid = nm_dbus_get_network_essid (data->dbus_connection, list->type, network)))
|
|
||||||
{
|
{
|
||||||
NMEncKeyType enc_method;
|
if ((list_ap = nm_ap_list_get_ap_by_essid (list, network)))
|
||||||
char *key = nm_dbus_get_network_key (data->dbus_connection, list->type, network, &enc_method);
|
|
||||||
GTimeVal *timestamp = nm_dbus_get_network_timestamp (data->dbus_connection, list->type, network);
|
|
||||||
gboolean trusted = nm_dbus_get_network_trusted (data->dbus_connection, list->type, network);
|
|
||||||
int num_addrs;
|
|
||||||
char **addrs = nm_dbus_get_network_addresses (data->dbus_connection, list->type, network, &num_addrs);
|
|
||||||
|
|
||||||
if (timestamp != NULL)
|
|
||||||
{
|
{
|
||||||
gboolean new = FALSE;
|
nm_ap_set_essid (list_ap, nm_ap_get_essid (ap));
|
||||||
|
nm_ap_set_timestamp (list_ap, nm_ap_get_timestamp (ap));
|
||||||
/* Find access point in list, if not found create a new AP and add it to the list */
|
nm_ap_set_trusted (list_ap, nm_ap_get_trusted (ap));
|
||||||
if (!(ap = nm_ap_list_get_ap_by_essid (list, network)))
|
nm_ap_set_enc_key_source (list_ap, nm_ap_get_enc_key_source (ap), nm_ap_get_enc_method (ap));
|
||||||
{
|
nm_ap_set_user_addresses (list_ap, nm_ap_get_user_addresses (ap));
|
||||||
ap = nm_ap_new ();
|
}
|
||||||
new = TRUE;
|
else
|
||||||
}
|
{
|
||||||
|
/* New AP, just add it to the list */
|
||||||
nm_ap_set_essid (ap, essid);
|
nm_ap_list_append_ap (list, ap);
|
||||||
nm_ap_set_timestamp (ap, timestamp);
|
nm_ap_unref (ap);
|
||||||
nm_ap_set_trusted (ap, trusted);
|
|
||||||
if (key && strlen (key))
|
|
||||||
nm_ap_set_enc_key_source (ap, key, enc_method);
|
|
||||||
else
|
|
||||||
nm_ap_set_enc_key_source (ap, NULL, NM_ENC_TYPE_UNKNOWN);
|
|
||||||
|
|
||||||
/* Get user addresses, form into a GSList, and stuff into the AP */
|
|
||||||
{
|
|
||||||
GSList *addr_list = NULL;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!addrs)
|
|
||||||
num_addrs = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < num_addrs; i++)
|
|
||||||
{
|
|
||||||
if (addrs[i] && (strlen (addrs[i]) >= 11))
|
|
||||||
addr_list = g_slist_append (addr_list, g_strdup (addrs[i]));
|
|
||||||
}
|
|
||||||
nm_ap_set_user_addresses (ap, addr_list);
|
|
||||||
g_slist_foreach (addr_list, (GFunc)g_free, NULL);
|
|
||||||
g_slist_free (addr_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (new)
|
|
||||||
{
|
|
||||||
nm_ap_list_append_ap (list, ap);
|
|
||||||
nm_ap_unref (ap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus_free_string_array (addrs);
|
|
||||||
g_free (timestamp);
|
|
||||||
g_free (essid);
|
|
||||||
g_free (key);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* AP got deleted, remove it from our list */
|
/* AP got deleted, remove it from our list */
|
||||||
if ((ap = nm_ap_list_get_ap_by_essid (list, network)))
|
if ((list_ap = nm_ap_list_get_ap_by_essid (list, network)))
|
||||||
nm_ap_list_remove_ap (list, ap);
|
nm_ap_list_remove_ap (list, list_ap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -808,312 +808,118 @@ void nm_dbus_cancel_get_user_key_for_network (DBusConnection *connection)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nm_dbus_get_network_essid
|
* nm_dbus_get_network_properties
|
||||||
*
|
*
|
||||||
* Get a network's essid from NetworkManagerInfo
|
* Get a wireless network from NetworkManagerInfo
|
||||||
*
|
|
||||||
* NOTE: caller MUST free returned value
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
char * nm_dbus_get_network_essid (DBusConnection *connection, NMNetworkType type, const char *network)
|
NMAccessPoint *nm_dbus_get_network_object (DBusConnection *connection, NMNetworkType type, const char *network)
|
||||||
{
|
|
||||||
DBusMessage *message;
|
|
||||||
DBusError error;
|
|
||||||
DBusMessage *reply;
|
|
||||||
char *essid = NULL;
|
|
||||||
|
|
||||||
g_return_val_if_fail (connection != NULL, NULL);
|
|
||||||
g_return_val_if_fail (network != NULL, NULL);
|
|
||||||
g_return_val_if_fail (type != NETWORK_TYPE_UNKNOWN, NULL);
|
|
||||||
|
|
||||||
message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH,
|
|
||||||
NMI_DBUS_INTERFACE, "getNetworkEssid");
|
|
||||||
if (!message)
|
|
||||||
{
|
|
||||||
syslog (LOG_ERR, "nm_dbus_get_network_essid(): Couldn't allocate the dbus message");
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_message_append_args (message, DBUS_TYPE_STRING, network,
|
|
||||||
DBUS_TYPE_INT32, (int)type,
|
|
||||||
DBUS_TYPE_INVALID);
|
|
||||||
|
|
||||||
/* Send message and get essid back from NetworkManagerInfo */
|
|
||||||
dbus_error_init (&error);
|
|
||||||
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
syslog (LOG_ERR, "nm_dbus_get_network_essid(): %s raised %s", error.name, error.message);
|
|
||||||
else if (!reply)
|
|
||||||
syslog (LOG_NOTICE, "nm_dbus_get_network_essid(): reply was NULL.");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char *dbus_string;
|
|
||||||
|
|
||||||
dbus_error_init (&error);
|
|
||||||
if (dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &dbus_string, DBUS_TYPE_INVALID))
|
|
||||||
{
|
|
||||||
essid = (dbus_string == NULL ? NULL : strdup (dbus_string));
|
|
||||||
dbus_free (dbus_string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_message_unref (message);
|
|
||||||
if (reply)
|
|
||||||
dbus_message_unref (reply);
|
|
||||||
|
|
||||||
return (essid);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nm_dbus_get_network_key
|
|
||||||
*
|
|
||||||
* Get a network's key and key type from NetworkManagerInfo.
|
|
||||||
*
|
|
||||||
* NOTE: caller MUST free returned value
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
char * nm_dbus_get_network_key (DBusConnection *connection, NMNetworkType type, const char *network, NMEncKeyType *enc_method)
|
|
||||||
{
|
|
||||||
DBusMessage *message;
|
|
||||||
DBusError error;
|
|
||||||
DBusMessage *reply;
|
|
||||||
char *key = NULL;
|
|
||||||
|
|
||||||
g_return_val_if_fail (enc_method != NULL, NULL);
|
|
||||||
*enc_method = NM_ENC_TYPE_UNKNOWN;
|
|
||||||
|
|
||||||
g_return_val_if_fail (connection != NULL, NULL);
|
|
||||||
g_return_val_if_fail (network != NULL, NULL);
|
|
||||||
g_return_val_if_fail (type != NETWORK_TYPE_UNKNOWN, NULL);
|
|
||||||
|
|
||||||
message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH,
|
|
||||||
NMI_DBUS_INTERFACE, "getNetworkKey");
|
|
||||||
if (!message)
|
|
||||||
{
|
|
||||||
syslog (LOG_ERR, "nm_dbus_get_network_key(): Couldn't allocate the dbus message");
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_message_append_args (message, DBUS_TYPE_STRING, network,
|
|
||||||
DBUS_TYPE_INT32, (int)type,
|
|
||||||
DBUS_TYPE_INVALID);
|
|
||||||
|
|
||||||
/* Send message and get key back from NetworkManagerInfo */
|
|
||||||
dbus_error_init (&error);
|
|
||||||
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
|
|
||||||
dbus_message_unref (message);
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
{
|
|
||||||
syslog (LOG_ERR, "nm_dbus_get_network_key(): %s raised %s", error.name, error.message);
|
|
||||||
dbus_error_free (&error);
|
|
||||||
}
|
|
||||||
else if (!reply)
|
|
||||||
syslog (LOG_NOTICE, "nm_dbus_get_network_key(): reply was NULL.");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char *dbus_key;
|
|
||||||
|
|
||||||
dbus_error_init (&error);
|
|
||||||
if (dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &dbus_key, DBUS_TYPE_INT32, enc_method, DBUS_TYPE_INVALID))
|
|
||||||
{
|
|
||||||
key = (dbus_key == NULL ? NULL : strdup (dbus_key));
|
|
||||||
dbus_free (dbus_key);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
*enc_method = NM_ENC_TYPE_UNKNOWN;
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
dbus_error_free (&error);
|
|
||||||
|
|
||||||
dbus_message_unref (reply);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (key);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nm_dbus_get_network_timestamp
|
|
||||||
*
|
|
||||||
* Get a network's timestamp from NetworkManagerInfo
|
|
||||||
*
|
|
||||||
* Returns: NULL on error
|
|
||||||
* timestamp if no error
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
GTimeVal *nm_dbus_get_network_timestamp (DBusConnection *connection, NMNetworkType type, const char *network)
|
|
||||||
{
|
|
||||||
DBusMessage *message;
|
|
||||||
DBusError error;
|
|
||||||
DBusMessage *reply;
|
|
||||||
guint32 timestamp_secs;
|
|
||||||
GTimeVal *timestamp;
|
|
||||||
|
|
||||||
g_return_val_if_fail (connection != NULL, NULL);
|
|
||||||
g_return_val_if_fail (network != NULL, NULL);
|
|
||||||
g_return_val_if_fail (type != NETWORK_TYPE_UNKNOWN, NULL);
|
|
||||||
|
|
||||||
message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH,
|
|
||||||
NMI_DBUS_INTERFACE, "getNetworkTimestamp");
|
|
||||||
if (!message)
|
|
||||||
{
|
|
||||||
syslog (LOG_ERR, "nm_dbus_get_network_timestamp(): Couldn't allocate the dbus message");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_message_append_args (message, DBUS_TYPE_STRING, network,
|
|
||||||
DBUS_TYPE_INT32, (int)type,
|
|
||||||
DBUS_TYPE_INVALID);
|
|
||||||
|
|
||||||
/* Send message and get timestamp back from NetworkManagerInfo */
|
|
||||||
dbus_error_init (&error);
|
|
||||||
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
syslog (LOG_ERR, "nm_dbus_get_network_timestamp(): %s raised %s", error.name, error.message);
|
|
||||||
else if (!reply)
|
|
||||||
syslog (LOG_NOTICE, "nm_dbus_get_network_timestamp(): reply was NULL.");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dbus_error_init (&error);
|
|
||||||
if (!dbus_message_get_args (reply, &error, DBUS_TYPE_INT32, ×tamp_secs, DBUS_TYPE_INVALID))
|
|
||||||
timestamp_secs = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_message_unref (message);
|
|
||||||
if (reply)
|
|
||||||
dbus_message_unref (reply);
|
|
||||||
|
|
||||||
if (timestamp_secs < 0)
|
|
||||||
return NULL;
|
|
||||||
timestamp = g_new0 (GTimeVal, 1);
|
|
||||||
timestamp->tv_sec = timestamp_secs;
|
|
||||||
timestamp->tv_usec = 0;
|
|
||||||
|
|
||||||
return (timestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nm_dbus_get_network_trusted
|
|
||||||
*
|
|
||||||
* Get whether or not a network is a "trusted" network from NetworkManagerInfo
|
|
||||||
*
|
|
||||||
* Returns: FALSE on error or if network is not trusted
|
|
||||||
* TRUE if the network is trusted
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
gboolean nm_dbus_get_network_trusted (DBusConnection *connection, NMNetworkType type, const char *network)
|
|
||||||
{
|
|
||||||
DBusMessage *message;
|
|
||||||
DBusError error;
|
|
||||||
DBusMessage *reply;
|
|
||||||
gboolean trusted = FALSE;
|
|
||||||
|
|
||||||
g_return_val_if_fail (connection != NULL, FALSE);
|
|
||||||
g_return_val_if_fail (network != NULL, FALSE);
|
|
||||||
g_return_val_if_fail (type != NETWORK_TYPE_UNKNOWN, FALSE);
|
|
||||||
|
|
||||||
message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH,
|
|
||||||
NMI_DBUS_INTERFACE, "getNetworkTrusted");
|
|
||||||
if (!message)
|
|
||||||
{
|
|
||||||
syslog (LOG_ERR, "nm_dbus_get_network_trusted(): Couldn't allocate the dbus message");
|
|
||||||
return (FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_message_append_args (message, DBUS_TYPE_STRING, network,
|
|
||||||
DBUS_TYPE_INT32, (int)type,
|
|
||||||
DBUS_TYPE_INVALID);
|
|
||||||
|
|
||||||
/* Send message and get trusted status back from NetworkManagerInfo */
|
|
||||||
dbus_error_init (&error);
|
|
||||||
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
{
|
|
||||||
syslog (LOG_ERR, "nm_dbus_get_network_trusted(): %s raised %s", error.name, error.message);
|
|
||||||
dbus_error_free (&error);
|
|
||||||
}
|
|
||||||
else if (!reply)
|
|
||||||
syslog (LOG_NOTICE, "nm_dbus_get_network_trusted(): reply was NULL.");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dbus_error_init (&error);
|
|
||||||
dbus_message_get_args (reply, &error, DBUS_TYPE_BOOLEAN, &trusted, DBUS_TYPE_INVALID);
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
dbus_error_free (&error);
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_message_unref (message);
|
|
||||||
if (reply)
|
|
||||||
dbus_message_unref (reply);
|
|
||||||
|
|
||||||
return (trusted);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nm_dbus_get_network_addresses
|
|
||||||
*
|
|
||||||
* Query NetworkManagerInfo for known MAC address of a wireless network
|
|
||||||
*
|
|
||||||
* Returns: NULL on error of if no MAC address exists for that network
|
|
||||||
* char array of addresses on success, num_addr = # items
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
char **nm_dbus_get_network_addresses (DBusConnection *connection, NMNetworkType type, const char *network, int *num_addr)
|
|
||||||
{
|
{
|
||||||
DBusMessage *message;
|
DBusMessage *message;
|
||||||
DBusError error;
|
DBusError error;
|
||||||
DBusMessage *reply;
|
DBusMessage *reply;
|
||||||
gboolean success = FALSE;
|
gboolean success = FALSE;
|
||||||
char **list = NULL;
|
NMAccessPoint *ap = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (connection != NULL, FALSE);
|
char *essid = NULL;
|
||||||
g_return_val_if_fail (network != NULL, FALSE);
|
gint timestamp_secs = -1;
|
||||||
g_return_val_if_fail (type != NETWORK_TYPE_UNKNOWN, FALSE);
|
char *key = NULL;
|
||||||
g_return_val_if_fail (num_addr != NULL, FALSE);
|
NMEncKeyType key_type = -1;
|
||||||
|
gboolean trusted = FALSE;
|
||||||
|
char **addrs = NULL;
|
||||||
|
gint num_addr = -1;
|
||||||
|
|
||||||
|
g_return_val_if_fail (connection != NULL, NULL);
|
||||||
|
g_return_val_if_fail (network != NULL, NULL);
|
||||||
|
g_return_val_if_fail (type != NETWORK_TYPE_UNKNOWN, NULL);
|
||||||
|
|
||||||
*num_addr = 0;
|
if (!(message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "getNetworkProperties")))
|
||||||
|
|
||||||
message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH,
|
|
||||||
NMI_DBUS_INTERFACE, "getNetworkAddresses");
|
|
||||||
if (!message)
|
|
||||||
{
|
{
|
||||||
syslog (LOG_ERR, "nm_dbus_get_network_ap_mac_address(): Couldn't allocate the dbus message");
|
syslog (LOG_ERR, "nm_dbus_get_network_object(): Couldn't allocate the dbus message");
|
||||||
return (FALSE);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus_message_append_args (message, DBUS_TYPE_STRING, network,
|
dbus_message_append_args (message, DBUS_TYPE_STRING, network,
|
||||||
DBUS_TYPE_INT32, (int)type,
|
DBUS_TYPE_INT32, (int)type,
|
||||||
DBUS_TYPE_INVALID);
|
DBUS_TYPE_INVALID);
|
||||||
|
|
||||||
/* Send message and get trusted status back from NetworkManagerInfo */
|
/* Send message and get properties back from NetworkManagerInfo */
|
||||||
dbus_error_init (&error);
|
dbus_error_init (&error);
|
||||||
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
|
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
|
||||||
|
dbus_message_unref (message);
|
||||||
|
|
||||||
if (dbus_error_is_set (&error))
|
if (dbus_error_is_set (&error))
|
||||||
{
|
{
|
||||||
/* Ignore the "NoAddresses" error */
|
syslog (LOG_ERR, "nm_dbus_get_network_object(): %s raised '%s'", error.name, error.message);
|
||||||
if (strcmp (error.name, "org.freedesktop.NetworkManagerInfo.NoAddresses"))
|
goto out;
|
||||||
syslog (LOG_ERR, "nm_dbus_get_network_addresses(): %s raised %s", error.name, error.message);
|
|
||||||
dbus_error_free (&error);
|
|
||||||
}
|
}
|
||||||
else if (!reply)
|
|
||||||
syslog (LOG_NOTICE, "nm_dbus_get_network_addresses(): reply was NULL.");
|
if (!reply)
|
||||||
else
|
|
||||||
{
|
{
|
||||||
DBusMessageIter iter;
|
syslog (LOG_NOTICE, "nm_dbus_get_network_object(): reply was NULL.");
|
||||||
|
goto out;
|
||||||
dbus_message_iter_init (reply, &iter);
|
|
||||||
dbus_message_iter_get_string_array (&iter, &list, num_addr);
|
|
||||||
if (*num_addr > 0)
|
|
||||||
success = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus_message_unref (message);
|
dbus_error_init (&error);
|
||||||
|
success = dbus_message_get_args (reply, &error,
|
||||||
|
DBUS_TYPE_STRING, &essid,
|
||||||
|
DBUS_TYPE_INT32, ×tamp_secs,
|
||||||
|
DBUS_TYPE_STRING, &key,
|
||||||
|
DBUS_TYPE_INT32, &key_type,
|
||||||
|
DBUS_TYPE_BOOLEAN, &trusted,
|
||||||
|
DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &addrs, &num_addr,
|
||||||
|
DBUS_TYPE_INVALID);
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
if (timestamp_secs > 0)
|
||||||
|
{
|
||||||
|
GTimeVal *timestamp = g_new0 (GTimeVal, 1);
|
||||||
|
|
||||||
|
ap = nm_ap_new ();
|
||||||
|
nm_ap_set_essid (ap, essid);
|
||||||
|
|
||||||
|
timestamp->tv_sec = timestamp_secs;
|
||||||
|
timestamp->tv_usec = 0;
|
||||||
|
nm_ap_set_timestamp (ap, timestamp);
|
||||||
|
g_free (timestamp);
|
||||||
|
|
||||||
|
nm_ap_set_trusted (ap, trusted);
|
||||||
|
|
||||||
|
if (key && strlen (key))
|
||||||
|
nm_ap_set_enc_key_source (ap, key, key_type);
|
||||||
|
else
|
||||||
|
nm_ap_set_enc_key_source (ap, NULL, NM_ENC_TYPE_UNKNOWN);
|
||||||
|
|
||||||
|
/* Get user addresses, form into a GSList, and stuff into the AP */
|
||||||
|
{
|
||||||
|
GSList *addr_list = NULL;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!addrs)
|
||||||
|
num_addr = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < num_addr; i++)
|
||||||
|
{
|
||||||
|
if (addrs[i] && (strlen (addrs[i]) >= 11))
|
||||||
|
addr_list = g_slist_append (addr_list, g_strdup (addrs[i]));
|
||||||
|
}
|
||||||
|
nm_ap_set_user_addresses (ap, addr_list);
|
||||||
|
g_slist_foreach (addr_list, (GFunc)g_free, NULL);
|
||||||
|
g_slist_free (addr_list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dbus_free_string_array (addrs);
|
||||||
|
g_free (essid);
|
||||||
|
g_free (key);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
syslog (LOG_ERR, "nm_dbus_get_network_object(): bad data, %s raised %s", error.name, error.message);
|
||||||
|
|
||||||
|
out:
|
||||||
if (reply)
|
if (reply)
|
||||||
dbus_message_unref (reply);
|
dbus_message_unref (reply);
|
||||||
|
|
||||||
return (list);
|
return (ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -57,11 +57,8 @@ void nm_dbus_get_user_key_for_network (DBusConnection *connection, NMDevice *
|
|||||||
|
|
||||||
void nm_dbus_cancel_get_user_key_for_network (DBusConnection *connection);
|
void nm_dbus_cancel_get_user_key_for_network (DBusConnection *connection);
|
||||||
|
|
||||||
char * nm_dbus_get_network_essid (DBusConnection *connection, NMNetworkType type, const char *network);
|
NMAccessPoint *nm_dbus_get_network_object (DBusConnection *connection, NMNetworkType type, const char *network);
|
||||||
char * nm_dbus_get_network_key (DBusConnection *connection, NMNetworkType type, const char *network, NMEncKeyType *enc_method);
|
|
||||||
GTimeVal * nm_dbus_get_network_timestamp (DBusConnection *connection, NMNetworkType type, const char *network);
|
|
||||||
gboolean nm_dbus_get_network_trusted (DBusConnection *connection, NMNetworkType type, const char *network);
|
|
||||||
char ** nm_dbus_get_network_addresses (DBusConnection *connection, NMNetworkType type, const char *network, int *num_addr);
|
|
||||||
gboolean nm_dbus_add_network_address (DBusConnection *connection, NMNetworkType type, const char *network, struct ether_addr *addr);
|
gboolean nm_dbus_add_network_address (DBusConnection *connection, NMNetworkType type, const char *network, struct ether_addr *addr);
|
||||||
|
|
||||||
char ** nm_dbus_get_networks (DBusConnection *connection, NMNetworkType type, int *num_networks);
|
char ** nm_dbus_get_networks (DBusConnection *connection, NMNetworkType type, int *num_networks);
|
||||||
|
@@ -2173,15 +2173,23 @@ void nm_device_activation_cancel (NMDevice *dev)
|
|||||||
{
|
{
|
||||||
syslog (LOG_DEBUG, "nm_device_activation_cancel(%s): cancelling...", nm_device_get_iface (dev));
|
syslog (LOG_DEBUG, "nm_device_activation_cancel(%s): cancelling...", nm_device_get_iface (dev));
|
||||||
dev->quit_activation = TRUE;
|
dev->quit_activation = TRUE;
|
||||||
if (dev->dhcp_iface)
|
|
||||||
nm_device_dhcp_cease (dev);
|
|
||||||
|
|
||||||
/* Spin until cancelled. Possible race conditions or deadlocks here.
|
/* Spin until cancelled. Possible race conditions or deadlocks here.
|
||||||
* The other problem with waiting here is that we hold up dbus traffic
|
* The other problem with waiting here is that we hold up dbus traffic
|
||||||
* that we should respond to.
|
* that we should respond to.
|
||||||
*/
|
*/
|
||||||
while (nm_device_is_activating (dev))
|
while (nm_device_is_activating (dev))
|
||||||
|
{
|
||||||
|
/* Nice race here between quit activation and dhcp. We may not have
|
||||||
|
* started DHCP when we're told to quit activation, so we need to keep
|
||||||
|
* signalling dhcp to quit, which it will pick up whenever it starts.
|
||||||
|
* This should really be taken care of a better way.
|
||||||
|
*/
|
||||||
|
if (dev->dhcp_iface)
|
||||||
|
nm_device_dhcp_cease (dev);
|
||||||
|
|
||||||
g_usleep (G_USEC_PER_SEC / 2);
|
g_usleep (G_USEC_PER_SEC / 2);
|
||||||
|
}
|
||||||
syslog (LOG_DEBUG, "nm_device_activation_cancel(%s): cancelled.", nm_device_get_iface (dev));
|
syslog (LOG_DEBUG, "nm_device_activation_cancel(%s): cancelled.", nm_device_get_iface (dev));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user