Re: [PATCH] supplicant: switched to new supplicant's DBus API

2009-11-19 Thread Witold Sowa
Patch resent with a bug fix. There was a bug in adding a blob
procedure, witch caused to fail when adding an already added blob.
Fixed. Now NM tries to remove each blob before adding.
Corrected patch is below:

NetworkManager now uses the new DBus API of wpa_supplicant. It
changes interfaces and methods and signals names to, change some
signals to PropertyChanged signal and some method calls to property
Get calls in order to fit new API. General principle of operation
supplicant manager is not changed.
---
 src/NetworkManagerAP.c   |   14 +-
 src/nm-device-wifi.c |2 -
 src/supplicant-manager/nm-supplicant-interface.c |  579 +++---
 src/supplicant-manager/nm-supplicant-interface.h |3 +-
 src/supplicant-manager/nm-supplicant-manager.c   |2 +-
 src/supplicant-manager/nm-supplicant-manager.h   |6 +-
 6 files changed, 308 insertions(+), 298 deletions(-)

diff --git a/src/NetworkManagerAP.c b/src/NetworkManagerAP.c
index 9b95924..274862a 100644
--- a/src/NetworkManagerAP.c
+++ b/src/NetworkManagerAP.c
@@ -380,7 +380,7 @@ foreach_property_cb (gpointer key, gpointer value, gpointer 
user_data)
if (G_VALUE_HOLDS_BOXED (variant)) {
GArray *array = g_value_get_boxed (variant);
 
-   if (!strcmp (key, ssid)) {
+   if (!strcmp (key, SSID)) {
guint32 len = MIN (IW_ESSID_MAX_SIZE, array-len);
GByteArray * ssid;
 
@@ -396,7 +396,7 @@ foreach_property_cb (gpointer key, gpointer value, gpointer 
user_data)
g_byte_array_append (ssid, (const guint8 *) 
array-data, len);
nm_ap_set_ssid (ap, ssid);
g_byte_array_free (ssid, TRUE);
-   } else if (!strcmp (key, bssid)) {
+   } else if (!strcmp (key, BSSID)) {
struct ether_addr addr;
 
if (array-len != ETH_ALEN)
@@ -404,7 +404,7 @@ foreach_property_cb (gpointer key, gpointer value, gpointer 
user_data)
memset (addr, 0, sizeof (struct ether_addr));
memcpy (addr, array-data, ETH_ALEN);
nm_ap_set_address (ap, addr);
-   } else if (!strcmp (key, wpaie)) {
+   } else if (!strcmp (key, WPAIE)) {
guint8 * ie = (guint8 *) array-data;
guint32 flags = nm_ap_get_wpa_flags (ap);
 
@@ -412,7 +412,7 @@ foreach_property_cb (gpointer key, gpointer value, gpointer 
user_data)
return;
flags = nm_ap_add_security_from_ie (flags, ie, 
array-len);
nm_ap_set_wpa_flags (ap, flags);
-   } else if (!strcmp (key, rsnie)) {
+   } else if (!strcmp (key, RSNIE)) {
guint8 * ie = (guint8 *) array-data;
guint32 flags = nm_ap_get_rsn_flags (ap);
 
@@ -424,16 +424,16 @@ foreach_property_cb (gpointer key, gpointer value, 
gpointer user_data)
} else if (G_VALUE_HOLDS_INT (variant)) {
gint32 int_val = g_value_get_int (variant);
 
-   if (!strcmp (key, frequency)) {
+   if (!strcmp (key, Frequency)) {
nm_ap_set_freq (ap, (guint32) int_val);
-   } else if (!strcmp (key, maxrate)) {
+   } else if (!strcmp (key, MaxRate)) {
/* Supplicant reports as b/s, we use Kb/s internally */
nm_ap_set_max_bitrate (ap, int_val / 1000);
}
} else if (G_VALUE_HOLDS_UINT (variant)) {
guint32 val = g_value_get_uint (variant);
 
-   if (!strcmp (key, capabilities)) {
+   if (!strcmp (key, Capabilities)) {
if (val  IEEE80211_CAP_ESS) {
nm_ap_set_mode (ap, NM_802_11_MODE_INFRA);
} else if (val  IEEE80211_CAP_IBSS) {
diff --git a/src/nm-device-wifi.c b/src/nm-device-wifi.c
index 6307ae6..b83e34d 100644
--- a/src/nm-device-wifi.c
+++ b/src/nm-device-wifi.c
@@ -208,7 +208,6 @@ static void supplicant_iface_scanned_ap_cb 
(NMSupplicantInterface * iface,
 NMDeviceWifi * self);
 
 static void supplicant_iface_scan_request_result_cb (NMSupplicantInterface * 
iface,
- gboolean success,
  NMDeviceWifi * self);
 
 static void supplicant_iface_scan_results_cb (NMSupplicantInterface * iface,
@@ -1782,7 +1781,6 @@ cancel_pending_scan (NMDeviceWifi *self)
 
 static void
 supplicant_iface_scan_request_result_cb (NMSupplicantInterface *iface,
- gboolean success,
  NMDeviceWifi *self)
 {
if (can_scan (self))
diff --git 

Re: [PATCH] supplicant: switched to new supplicant's DBus API

2009-11-19 Thread Witold Sowa
One more bug fix, I hope it's the last one. Fixed reading
AP properties while calculating signal strength from
wpa_supplicant. Corrected patch is below:

NetworkManager now uses the new DBus API of wpa_supplicant. It
changes interfaces and methods and signals names to, change some
signals to PropertyChanged signal and some method calls to property
Get calls in order to fit new API. General principle of operation
supplicant manager is not changed.
---
 src/NetworkManagerAP.c   |   14 +-
 src/nm-device-wifi.c |   18 +-
 src/supplicant-manager/nm-supplicant-interface.c |  579 +++---
 src/supplicant-manager/nm-supplicant-interface.h |3 +-
 src/supplicant-manager/nm-supplicant-manager.c   |2 +-
 src/supplicant-manager/nm-supplicant-manager.h   |6 +-
 6 files changed, 316 insertions(+), 306 deletions(-)

diff --git a/src/NetworkManagerAP.c b/src/NetworkManagerAP.c
index 9b95924..274862a 100644
--- a/src/NetworkManagerAP.c
+++ b/src/NetworkManagerAP.c
@@ -380,7 +380,7 @@ foreach_property_cb (gpointer key, gpointer value, gpointer 
user_data)
if (G_VALUE_HOLDS_BOXED (variant)) {
GArray *array = g_value_get_boxed (variant);
 
-   if (!strcmp (key, ssid)) {
+   if (!strcmp (key, SSID)) {
guint32 len = MIN (IW_ESSID_MAX_SIZE, array-len);
GByteArray * ssid;
 
@@ -396,7 +396,7 @@ foreach_property_cb (gpointer key, gpointer value, gpointer 
user_data)
g_byte_array_append (ssid, (const guint8 *) 
array-data, len);
nm_ap_set_ssid (ap, ssid);
g_byte_array_free (ssid, TRUE);
-   } else if (!strcmp (key, bssid)) {
+   } else if (!strcmp (key, BSSID)) {
struct ether_addr addr;
 
if (array-len != ETH_ALEN)
@@ -404,7 +404,7 @@ foreach_property_cb (gpointer key, gpointer value, gpointer 
user_data)
memset (addr, 0, sizeof (struct ether_addr));
memcpy (addr, array-data, ETH_ALEN);
nm_ap_set_address (ap, addr);
-   } else if (!strcmp (key, wpaie)) {
+   } else if (!strcmp (key, WPAIE)) {
guint8 * ie = (guint8 *) array-data;
guint32 flags = nm_ap_get_wpa_flags (ap);
 
@@ -412,7 +412,7 @@ foreach_property_cb (gpointer key, gpointer value, gpointer 
user_data)
return;
flags = nm_ap_add_security_from_ie (flags, ie, 
array-len);
nm_ap_set_wpa_flags (ap, flags);
-   } else if (!strcmp (key, rsnie)) {
+   } else if (!strcmp (key, RSNIE)) {
guint8 * ie = (guint8 *) array-data;
guint32 flags = nm_ap_get_rsn_flags (ap);
 
@@ -424,16 +424,16 @@ foreach_property_cb (gpointer key, gpointer value, 
gpointer user_data)
} else if (G_VALUE_HOLDS_INT (variant)) {
gint32 int_val = g_value_get_int (variant);
 
-   if (!strcmp (key, frequency)) {
+   if (!strcmp (key, Frequency)) {
nm_ap_set_freq (ap, (guint32) int_val);
-   } else if (!strcmp (key, maxrate)) {
+   } else if (!strcmp (key, MaxRate)) {
/* Supplicant reports as b/s, we use Kb/s internally */
nm_ap_set_max_bitrate (ap, int_val / 1000);
}
} else if (G_VALUE_HOLDS_UINT (variant)) {
guint32 val = g_value_get_uint (variant);
 
-   if (!strcmp (key, capabilities)) {
+   if (!strcmp (key, Capabilities)) {
if (val  IEEE80211_CAP_ESS) {
nm_ap_set_mode (ap, NM_802_11_MODE_INFRA);
} else if (val  IEEE80211_CAP_IBSS) {
diff --git a/src/nm-device-wifi.c b/src/nm-device-wifi.c
index 6307ae6..ab3b138 100644
--- a/src/nm-device-wifi.c
+++ b/src/nm-device-wifi.c
@@ -107,7 +107,7 @@ typedef enum {
 } NMWifiError;
 
 #define NM_WIFI_ERROR (nm_wifi_error_quark ())
-#define NM_TYPE_WIFI_ERROR (nm_wifi_error_get_type ()) 
+#define NM_TYPE_WIFI_ERROR (nm_wifi_error_get_type ())
 
 typedef struct SupplicantStateTask {
NMDeviceWifi *self;
@@ -156,7 +156,7 @@ struct _NMDeviceWifiPrivate {
NMAccessPoint *   current_ap;
guint32   rate;
gboolean  enabled; /* rfkilled or not */
-   
+
glong scheduled_scan_time;
guint8scan_interval; /* seconds */
guint pending_scan_id;
@@ -208,7 +208,6 @@ static void supplicant_iface_scanned_ap_cb 
(NMSupplicantInterface * iface,
 NMDeviceWifi * self);
 
 static void supplicant_iface_scan_request_result_cb (NMSupplicantInterface * 
iface,
-