-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Mostly ack, comments below. On Tue, 27 Apr 2010, Radek Vykydal wrote:
--- gui.py | 18 ++++++++++++++- iw/network_gui.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ network.py | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+), 1 deletions(-) diff --git a/gui.py b/gui.py index 1008d93..50c542f 100755 --- a/gui.py +++ b/gui.py @@ -962,7 +962,8 @@ class InstallInterface(InstallInterfaceBase): return False from network_gui import (runNMCE, - selectNetDevicesDialog) + selectNetDevicesDialog, + selectSSIDsDialog) networkEnabled = False while not networkEnabled: @@ -981,6 +982,21 @@ class InstallInterface(InstallInterfaceBase): if not just_setup: self.anaconda.network.updateActiveDevices([install_device]) + # we might want to do this only once + # NOTE: For wireless, we need supplicant to go to ready state, + # that means to get the wireless device managed by NM + # - we do it above in setNMControlledDevices. + # TODORV: put into Network objects + if network.hasWirelessDev(): + w = self.anaconda.intf.waitWindow(_("Wireless setup"), + _("Scanning access points for wireless devices")) + # get available wireless APs + dev_all_ssids = self.anaconda.network.getSSIDs() + w.pop() + # select wireless APs + dev_ssids = selectSSIDsDialog(dev_all_ssids) or dev_all_ssids + self.anaconda.network.updateIfcfgsSSID(dev_ssids) + network.logIfcfgFiles(header="========== before nm-c-e run\n") runNMCE(self.anaconda) network.logIfcfgFiles(header="========== after nm-c-e run\n") diff --git a/iw/network_gui.py b/iw/network_gui.py index 00cb1d9..0d28d0c 100644 --- a/iw/network_gui.py +++ b/iw/network_gui.py @@ -233,5 +233,61 @@ def selectNetDevicesDialog(network, select_install_device=True): dialog.destroy() return retval +def selectSSIDsDialog(devssids): + """Dialog for access point selection. + + devssids - dict iface->[ssid1, ssid2, ssid3, ...] + returns - dict iface->[ssidX] or None on Cancel + """ + + # If there are no choices, don't ask + for dev, ssids in devssids.items(): + if len(ssids) > 1: + break + else: + return devssids + + rv = {} + dialog = gtk.Dialog(_("Select APs")) + dialog.add_button('gtk-cancel', 2) + dialog.add_button('gtk-ok', 1) + dialog.set_position(gtk.WIN_POS_CENTER) + gui.addFrame(dialog) + + dialog.vbox.pack_start(gui.WrappingLabel( + _("Select APs for wireless devices"))) + + table = gtk.Table(len(devssids), 2) + table.set_row_spacings(5) + table.set_col_spacings(5) + + combos = {} + for i, (dev, ssids) in enumerate(devssids.items()): + + label = gtk.Label(dev) + table.attach(label, 0, 1, i, i+1, gtk.FILL, gtk.FILL) + + combo = gtk.combo_box_new_text() + for ssid in ssids: + combo.append_text(ssid) + table.attach(combo, 1, 2, i, i+1, gtk.FILL, gtk.FILL) + combo.set_active(0) + combos[dev] = combo + + dialog.vbox.pack_start(table) + + dialog.show_all() + + rc = dialog.run() + + # cancel + if rc in [2, gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
Same as previous patch. I think this should be gtk.RESPONSE_REJECT.
+ rv = None + else: + for dev, combo in combos.items(): + rv[dev] = [combo.get_active_text()] + + dialog.destroy() + return rv diff --git a/network.py b/network.py index 24f029d..9fc67a1 100644 --- a/network.py +++ b/network.py @@ -208,6 +208,15 @@ def hasActiveNetDev(): except: return False +def hasWirelessDev(): + devprops = isys.getDeviceProperties() + for dev, props in devprops.items(): + device_type = int(props.Get(isys.NM_MANAGER_IFACE, "DeviceType")) + if device_type == 2: + return True + return False + + # Return a list of device names (e.g., eth0) for all active devices. # Returning a list here even though we will almost always have one # device. NM uses lists throughout its D-Bus communication, so trying @@ -462,6 +471,16 @@ class Network: ifaces.append(iface) return ifaces + def updateIfcfgsSSID(self, devssids): + for devname, device in self.netdevices.items(): + if devname in devssids.keys(): + device.set(('ESSID', devssids[devname][0])) + device.writeIfcfgFile() + device.log_file("updateIfcfgSSID\n") + + def getSSIDs(self): + return getSSIDs(self.netdevices.keys()) + def writeKS(self, f): devNames = self.netdevices.keys() devNames.sort() @@ -803,3 +822,45 @@ class Network: netargs += ",%s" % (','.join(options)) return netargs + +def getSSIDs(devices_to_scan=None): + + rv = {} + bus = dbus.SystemBus() + nm = bus.get_object(isys.NM_SERVICE, isys.NM_MANAGER_PATH) + device_paths = nm.get_dbus_method("GetDevices")() + + for device_path in device_paths: + + device = bus.get_object(isys.NM_SERVICE, device_path) + device_props_iface = dbus.Interface(device, isys.DBUS_PROPS_IFACE) + # interface name, eg. "eth0", "wlan0" + dev = str(device_props_iface.Get(isys.NM_MANAGER_IFACE, "Interface")) + + if (isys.isWireless(dev) and + (not devices_to_scan or dev in devices_to_scan)): + + i = 0 + log.info("scanning APs for %s" % dev) + while i < 5: + ap_paths = device.GetAccessPoints(dbus_interface='org.freedesktop.NetworkManager.Device.Wireless') + if ap_paths: + break + time.sleep(0.5) + i += 0.5 + + ssids = [] + for ap_path in ap_paths: + ap = bus.get_object(isys.NM_SERVICE, ap_path) + ap_props = dbus.Interface(ap, isys.DBUS_PROPS_IFACE) + ssid_bytearray = ap_props.Get(isys.NM_MANAGER_IFACE, "Ssid") + ssid = "".join((str(b) for b in ssid_bytearray)) + ssids.append(ssid) + log.info("APs found for %s: %s" % (dev, str(ssids))) + # XXX there can be duplicates in a list, but maybe + # we want to keep them when/if we differentiate on something + # more then just ssids; for now, remove them + rv[dev]=list(set(ssids)) + + return rv +
- -- David Cantrell <dcantrell@xxxxxxxxxx>
Red Hat / Honolulu, HI -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEARECAAYFAkvfkMoACgkQ5hsjjIy1Vkk2YgCeIAQv1TZ5rj07y8ezh7qfSScm 0ocAoIJQs5FnN4louVRqedBqUIqJSqty =TXzw -----END PGP SIGNATURE----- _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list