|
Lines 51-57
Link Here
|
| 51 |
static NetworkStatusInfo *nm_get_first_active_device_info (NetworkStatusAgent *); |
51 |
static NetworkStatusInfo *nm_get_first_active_device_info (NetworkStatusAgent *); |
| 52 |
static NetworkStatusInfo *nm_get_device_info (NetworkStatusAgent *, NMDevice *); |
52 |
static NetworkStatusInfo *nm_get_device_info (NetworkStatusAgent *, NMDevice *); |
| 53 |
|
53 |
|
| 54 |
static void nm_state_change_cb (NMDevice *device, NMDeviceState state, gpointer user_data); |
54 |
static void nm_state_change_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data); |
| 55 |
|
55 |
|
| 56 |
static NetworkStatusInfo *gtop_get_first_active_device_info (void); |
56 |
static NetworkStatusInfo *gtop_get_first_active_device_info (void); |
| 57 |
|
57 |
|
|
Lines 150-174
Link Here
|
| 150 |
|
150 |
|
| 151 |
NetworkStatusInfo *info = NULL; |
151 |
NetworkStatusInfo *info = NULL; |
| 152 |
|
152 |
|
| 153 |
GSList *devices; |
153 |
const GPtrArray *devices; |
| 154 |
GSList *node; |
154 |
gint i; |
| 155 |
|
155 |
|
| 156 |
if (!priv->nm_client) |
156 |
if (!priv->nm_client) |
| 157 |
return NULL; |
157 |
return NULL; |
| 158 |
|
158 |
|
| 159 |
devices = nm_client_get_devices (priv->nm_client); |
159 |
devices = nm_client_get_devices (priv->nm_client); |
| 160 |
|
160 |
|
| 161 |
for (node = devices; node; node = node->next) |
161 |
for (i = 0; devices && i < devices->len; i++) |
| 162 |
{ |
162 |
{ |
| 163 |
info = nm_get_device_info (agent, NM_DEVICE (node->data)); |
163 |
NMDevice *nm_device; |
| 164 |
|
164 |
|
|
|
165 |
nm_device = NM_DEVICE (g_ptr_array_index (devices, i)); |
| 166 |
info = nm_get_device_info (agent, nm_device); |
| 167 |
|
| 165 |
if (info) |
168 |
if (info) |
| 166 |
{ |
169 |
{ |
| 167 |
if (info->active) |
170 |
if (info->active) |
| 168 |
{ |
171 |
{ |
| 169 |
NMDevice * nm_device; |
172 |
g_signal_connect (nm_device, "notify::state", G_CALLBACK (nm_state_change_cb), agent); |
| 170 |
nm_device = NM_DEVICE (node->data); |
|
|
| 171 |
g_signal_connect (nm_device, "state-changed", G_CALLBACK (nm_state_change_cb), agent); |
| 172 |
break; |
173 |
break; |
| 173 |
} |
174 |
} |
| 174 |
|
175 |
|
|
Lines 178-186
Link Here
|
| 178 |
} |
179 |
} |
| 179 |
} |
180 |
} |
| 180 |
|
181 |
|
| 181 |
//the NM internal code does not free these. g_slist_foreach (devices, (GFunc) g_object_unref, NULL); |
|
|
| 182 |
g_slist_free (devices); |
| 183 |
|
| 184 |
return info; |
182 |
return info; |
| 185 |
} |
183 |
} |
| 186 |
|
184 |
|
|
Lines 200-209
Link Here
|
| 200 |
nm_get_device_info (NetworkStatusAgent * agent, NMDevice * device) |
198 |
nm_get_device_info (NetworkStatusAgent * agent, NMDevice * device) |
| 201 |
{ |
199 |
{ |
| 202 |
NetworkStatusInfo *info = g_object_new (NETWORK_STATUS_INFO_TYPE, NULL); |
200 |
NetworkStatusInfo *info = g_object_new (NETWORK_STATUS_INFO_TYPE, NULL); |
| 203 |
GArray *array; |
201 |
const GArray *array; |
| 204 |
|
202 |
|
| 205 |
info->iface = nm_device_get_iface (device); |
203 |
info->iface = g_strdup (nm_device_get_iface (device)); |
| 206 |
info->driver = nm_device_get_driver (device); |
204 |
info->driver = g_strdup (nm_device_get_driver (device)); |
| 207 |
info->active = (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) ? TRUE : FALSE; |
205 |
info->active = (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) ? TRUE : FALSE; |
| 208 |
if (! info->active) |
206 |
if (! info->active) |
| 209 |
return info; |
207 |
return info; |
|
Lines 225-273
Link Here
|
| 225 |
if (array->len > 1) |
223 |
if (array->len > 1) |
| 226 |
info->secondary_dns = ip4_address_as_string (g_array_index (array, guint32, 1)); |
224 |
info->secondary_dns = ip4_address_as_string (g_array_index (array, guint32, 1)); |
| 227 |
} |
225 |
} |
| 228 |
g_array_free (array, TRUE); |
|
|
| 229 |
|
226 |
|
| 230 |
g_object_unref (cfg); |
|
|
| 231 |
|
| 232 |
if (NM_IS_DEVICE_802_11_WIRELESS(device)) |
227 |
if (NM_IS_DEVICE_802_11_WIRELESS(device)) |
| 233 |
{ |
228 |
{ |
| 234 |
GSList *iter; |
229 |
const GPtrArray *aps; |
| 235 |
GSList *aps; |
230 |
gint i; |
| 236 |
info->type = DEVICE_TYPE_802_11_WIRELESS; |
231 |
info->type = DEVICE_TYPE_802_11_WIRELESS; |
| 237 |
|
232 |
|
| 238 |
info->speed_mbs = nm_device_802_11_wireless_get_bitrate (NM_DEVICE_802_11_WIRELESS(device)); |
233 |
info->speed_mbs = nm_device_802_11_wireless_get_bitrate (NM_DEVICE_802_11_WIRELESS(device)); |
| 239 |
info->hw_addr = g_strdup (nm_device_802_11_wireless_get_hw_address (NM_DEVICE_802_11_WIRELESS(device))); |
234 |
info->hw_addr = g_strdup (nm_device_802_11_wireless_get_hw_address (NM_DEVICE_802_11_WIRELESS(device))); |
| 240 |
aps = nm_device_802_11_wireless_get_access_points (NM_DEVICE_802_11_WIRELESS(device)); |
235 |
aps = nm_device_802_11_wireless_get_access_points (NM_DEVICE_802_11_WIRELESS(device)); |
| 241 |
for (iter = aps; iter; iter = iter->next) |
236 |
for (i = 0; aps && i < aps->len; i++) |
| 242 |
{ |
237 |
{ |
| 243 |
const GByteArray * ssid; |
238 |
const GByteArray * ssid; |
| 244 |
ssid = nm_access_point_get_ssid (NM_ACCESS_POINT (iter->data)); |
239 |
ssid = nm_access_point_get_ssid (NM_ACCESS_POINT (g_ptr_array_index (aps, i))); |
| 245 |
if (ssid) |
240 |
if (ssid) |
| 246 |
info->essid = g_strdup (nm_utils_escape_ssid (ssid->data, ssid->len)); |
241 |
info->essid = g_strdup (nm_utils_escape_ssid (ssid->data, ssid->len)); |
| 247 |
else |
242 |
else |
| 248 |
info->essid = g_strdup ("(none)"); |
243 |
info->essid = g_strdup ("(none)"); |
| 249 |
break; //fixme - we only show one for now |
244 |
break; //fixme - we only show one for now |
| 250 |
} |
245 |
} |
| 251 |
|
|
|
| 252 |
g_slist_foreach (aps, (GFunc) g_object_unref, NULL); |
| 253 |
g_slist_free (aps); |
| 254 |
} |
246 |
} |
| 255 |
else if (NM_IS_DEVICE_802_3_ETHERNET (device)) |
247 |
else if (NM_IS_DEVICE_802_3_ETHERNET (device)) |
| 256 |
{ |
248 |
{ |
| 257 |
info->type = DEVICE_TYPE_802_3_ETHERNET; |
249 |
info->type = DEVICE_TYPE_802_3_ETHERNET; |
| 258 |
info->speed_mbs = nm_device_802_3_ethernet_get_speed (NM_DEVICE_802_3_ETHERNET(device)); |
250 |
info->speed_mbs = nm_device_802_3_ethernet_get_speed (NM_DEVICE_802_3_ETHERNET(device)); |
| 259 |
info->hw_addr = nm_device_802_3_ethernet_get_hw_address (NM_DEVICE_802_3_ETHERNET(device)); |
251 |
info->hw_addr = g_strdup (nm_device_802_3_ethernet_get_hw_address (NM_DEVICE_802_3_ETHERNET(device))); |
| 260 |
} |
252 |
} |
| 261 |
|
253 |
|
| 262 |
return info; |
254 |
return info; |
| 263 |
} |
255 |
} |
| 264 |
|
256 |
|
| 265 |
static void |
257 |
static void |
| 266 |
nm_state_change_cb (NMDevice *device, NMDeviceState state, gpointer user_data) |
258 |
nm_state_change_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data) |
| 267 |
{ |
259 |
{ |
| 268 |
NetworkStatusAgent *this = NETWORK_STATUS_AGENT (user_data); |
260 |
NetworkStatusAgent *this = NETWORK_STATUS_AGENT (user_data); |
| 269 |
NetworkStatusAgentPrivate *priv = NETWORK_STATUS_AGENT_GET_PRIVATE (this); |
261 |
NetworkStatusAgentPrivate *priv = NETWORK_STATUS_AGENT_GET_PRIVATE (this); |
|
|
262 |
NMDeviceState state; |
| 270 |
|
263 |
|
|
|
264 |
state = nm_device_get_state (device); |
| 265 |
|
| 271 |
if (priv->state_curr == state) |
266 |
if (priv->state_curr == state) |
| 272 |
return; |
267 |
return; |
| 273 |
|
268 |
|