[network-manager-applet/bg/mm-device-race-bgo776384: 3/4] applet: re-add broadband devices when MM becomes available



commit c3fbe6eddbee90d0af2db87b4db53b299cf592e5
Author: Beniamino Galvani <bgalvani redhat com>
Date:   Thu Dec 29 23:58:39 2016 +0100

    applet: re-add broadband devices when MM becomes available
    
    Broadband devices stay uninitialized if they are added before the
    ModemManager is running. Call again the device_added method after MM
    becomes available.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=776384

 src/applet-device-broadband.c |    3 +++
 src/applet.c                  |   20 ++++++++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/src/applet-device-broadband.c b/src/applet-device-broadband.c
index 59dd462..585166f 100644
--- a/src/applet-device-broadband.c
+++ b/src/applet-device-broadband.c
@@ -1009,6 +1009,9 @@ device_added (NMDevice *device,
        if (!udi)
                return;
 
+       if (g_object_get_data (G_OBJECT (modem), BROADBAND_INFO_TAG))
+               return;
+
        if (!applet->mm1) {
                g_warning ("Cannot grab information for modem at %s: No ModemManager support",
                           nm_device_get_udi (device));
diff --git a/src/applet.c b/src/applet.c
index 5b013d1..73f659b 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -2372,6 +2372,26 @@ mm1_name_owner_changed_cb (GDBusObjectManagerClient *mm1,
        name_owner = g_dbus_object_manager_client_get_name_owner (mm1);
        applet->mm1_running = !!name_owner;
        g_free (name_owner);
+
+       if (applet->mm1_running) {
+               const GPtrArray *devices;
+               NMADeviceClass *dclass;
+               NMDevice *device;
+               int i;
+
+               devices = nm_client_get_devices (applet->nm_client);
+               for (i = 0; devices && (i < devices->len); i++) {
+                       device = NM_DEVICE (g_ptr_array_index (devices, i));
+                       if (NM_IS_DEVICE_MODEM (device)) {
+                               dclass = get_device_class (device, applet);
+                               if (dclass && dclass->device_added)
+                                       dclass->device_added (device, applet);
+
+                               applet_schedule_update_icon (applet);
+                               applet_schedule_update_menu (applet);
+                       }
+               }
+       }
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]