Esempio n. 1
0
    def change_encrypt_method(self):
        """ Change encrypt method based on combobox. """
        #self.lbox_encrypt = urwid.ListBox()
        self.encryption_info = {}
        wid, ID = self.encryption_combo.get_focus()
        methods = self.encrypt_types

        # pylint: disable-msg=E0203
        if self._w.body.body.__contains__(self.pile_encrypt):
            self._w.body.body.pop(self._w.body.body.__len__() - 1)

        # If nothing is selected, select the first entry.
        if ID == -1:
            self.encryption_combo.set_focus(0)
            ID = 0

        theList = []
        for type_ in ['required', 'optional']:
            fields = methods[ID][type_]
            for field in fields:
                try:
                    text = language[field[1].lower().replace(' ', '_')]
                except KeyError:
                    text = field[1].replace(' ', '_')
                edit = MaskingEdit(('editcp', text + ': '))
                edit.set_mask_mode('no_focus')
                theList.append(edit)
                # Add the data to any array, so that the information
                # can be easily accessed by giving the name of the wanted
                # data.
                self.encryption_info[field[0]] = [edit, type_]

                if self.wired:
                    edit.set_edit_text(
                        noneToBlankString(wired.GetWiredProperty(field[0])))
                else:
                    edit.set_edit_text(
                        noneToBlankString(
                            wireless.GetWirelessProperty(
                                self.networkid, field[0])))

        #FIXME: This causes the entire pile to light up upon use.
        # Make this into a listbox?
        self.pile_encrypt = DynWrap(urwid.Pile(theList),
                                    attrs=('editbx', 'editnfc'))

        self.pile_encrypt.set_sensitive(self.encryption_chkbox.get_state())

        self._w.body.body.insert(self._w.body.body.__len__(),
                                 self.pile_encrypt)
Esempio n. 2
0
    def change_encrypt_method(self):
        """ Change encrypt method based on combobox. """
        #self.lbox_encrypt = urwid.ListBox()
        self.encryption_info = {}
        wid, ID = self.encryption_combo.get_focus()
        methods = self.encrypt_types

        # pylint: disable-msg=E0203
        if self._w.body.body.__contains__(self.pile_encrypt):
            self._w.body.body.pop(self._w.body.body.__len__() - 1)

        # If nothing is selected, select the first entry.
        if ID == -1:
            self.encryption_combo.set_focus(0)
            ID = 0

        theList = []
        for type_ in ['required', 'optional']:
            fields = methods[ID][type_]
            for field in fields:
                try:
                    text = language[field[1].lower().replace(' ', '_')]
                except KeyError:
                    text = field[1].replace(' ', '_')
                edit = MaskingEdit(('editcp', text + ': '))
                edit.set_mask_mode('no_focus')
                theList.append(edit)
                # Add the data to any array, so that the information
                # can be easily accessed by giving the name of the wanted
                # data.
                self.encryption_info[field[0]] = [edit, type_]

                if self.wired:
                    edit.set_edit_text(noneToBlankString(
                        wired.GetWiredProperty(field[0])))
                else:
                    edit.set_edit_text(noneToBlankString(
                        wireless.GetWirelessProperty(self.networkid, field[0])))

        #FIXME: This causes the entire pile to light up upon use.
        # Make this into a listbox?
        self.pile_encrypt = DynWrap(
            urwid.Pile(theList),
            attrs=('editbx', 'editnfc')
        )

        self.pile_encrypt.set_sensitive(self.encryption_chkbox.get_state())

        self._w.body.body.insert(self._w.body.body.__len__(), self.pile_encrypt)
Esempio n. 3
0
    def update_state(self, state, wired_ip=None, wifi_ip=None):
        """Set the current connection state."""
        # Set our connection state/info.
        iwconfig = self.iwconfig
        if state == misc.NOT_CONNECTED:
            info = [""]
        elif state == misc.SUSPENDED:
            info = [""]
        elif state == misc.CONNECTING:
            if wired.CheckIfWiredConnecting():
                info = ["wired"]
            else:
                info = [
                    "wireless",
                    misc.noneToBlankString(
                        wireless.GetCurrentNetwork(iwconfig))
                ]
        elif state == misc.WIRELESS:
            self.reconnect_tries = 0
            info = [
                str(wifi_ip),
                misc.noneToBlankString(wireless.GetCurrentNetwork(iwconfig)),
                str(self._get_printable_sig_strength()),
                str(wireless.GetCurrentNetworkID(iwconfig)),
                misc.noneToBlankString(wireless.GetCurrentBitrate(iwconfig))
            ]
        elif state == misc.WIRED:
            self.reconnect_tries = 0
            info = [str(wired_ip)]
        else:
            print('ERROR: Invalid state!')
            return True

        daemon.SetConnectionStatus(state, info)

        # Send a D-Bus signal announcing status has changed if necessary.
        if (state != self.last_state
                or (state == misc.WIRELESS and self.signal_changed)):
            daemon.EmitStatusChanged(state, info)

        if (state != self.last_state and state == misc.NOT_CONNECTED
                and not daemon.GetForcedDisconnect()):
            daemon.Disconnect()
            # Disconnect() sets forced disconnect = True
            # so we'll revert that
            daemon.SetForcedDisconnect(False)
        self.last_state = state
        return True
Esempio n. 4
0
    def change_encrypt_method(self, widget=None):
        """ Load all the entries for a given encryption method. """
        for z in self.vbox_encrypt_info:
            z.destroy()  # Remove stuff in there already
        ID = self.combo_encryption.get_active()
        methods = self.encrypt_types
        self.encryption_info = {}
        
        # If nothing is selected, select the first entry.
        if ID == -1:
            self.combo_encryption.set_active(0)
            ID = 0

        for type_ in ['required', 'optional']:
            fields = methods[ID][type_]
            for field in fields:
                if language.has_key(field[1]):
                    field_text = language[field[1].lower().replace(' ','_')]
                else:
                    field_text = field[1].replace('_',' ')
               
                if field in methods[ID]['protected']:
                    box = ProtectedLabelEntry(field_text)
                else:
                    box = LabelEntry(field_text)

                self.vbox_encrypt_info.pack_start(box)
                # Add the data to a dict, so that the information
                # can be easily accessed by giving the name of the wanted
                # data.
                self.encryption_info[field[0]] = [box, type_]

                box.entry.set_text(noneToBlankString(
                    wireless.GetWirelessProperty(self.networkID, field[0])))
        self.vbox_encrypt_info.show_all()
Esempio n. 5
0
    def __init__(self, networkID):
        """ Build the wireless network entry. """
        NetworkEntry.__init__(self)

        self.networkID = networkID
        self.image.set_padding(0, 0)
        self.image.set_alignment(.5, .5)
        self.image.set_size_request(60, -1)
        self.image.show()
        self.essid = noneToBlankString(wireless.GetWirelessProperty(networkID,
                                                                    "essid"))
        self.lbl_strength = GreyLabel()
        self.lbl_encryption = GreyLabel()
        self.lbl_channel = GreyLabel()
        
        print "ESSID : " + self.essid
        self.chkbox_autoconnect = gtk.CheckButton(_('Automatically connect to this network'))
        self.chkbox_neverconnect = gtk.CheckButton(_('Never connect to this network'))
        
        self.set_signal_strength(wireless.GetWirelessProperty(networkID, 
                                                              'quality'),
                                 wireless.GetWirelessProperty(networkID, 
                                                              'strength'))
        self.set_encryption(wireless.GetWirelessProperty(networkID, 
                                                         'encryption'),
                            wireless.GetWirelessProperty(networkID, 
                                                 'encryption_method')) 
        self.set_channel(wireless.GetWirelessProperty(networkID, 'channel'))
        self.name_label.set_use_markup(True)
        self.name_label.set_label("<b>%s</b>    %s    %s    %s" % (self._escape(self.essid),
                                                         self.lbl_strength.get_label(),
                                                         self.lbl_encryption.get_label(),
                                                         self.lbl_channel.get_label(),
                                                        )
                                 )
        # Add the wireless network specific parts to the NetworkEntry
        # VBox objects.
        self.vbox_top.pack_start(self.chkbox_autoconnect, False, False)
        self.vbox_top.pack_start(self.chkbox_neverconnect, False, False)

        if to_bool(self.format_entry(networkID, "automatic")):
            self.chkbox_autoconnect.set_active(True)
        else:
            self.chkbox_autoconnect.set_active(False)
        
        if to_bool(self.format_entry(networkID, "never")):
            self.chkbox_autoconnect.set_sensitive(False)
            self.connect_button.set_sensitive(False)
            self.chkbox_neverconnect.set_active(True)
        else:
            self.chkbox_neverconnect.set_active(False)

        # Connect signals.
        self.chkbox_autoconnect.connect("toggled", self.update_autoconnect)
        self.chkbox_neverconnect.connect("toggled", self.update_neverconnect)
        
        # Show everything
        self.show_all()
        self.advanced_dialog = WirelessSettingsDialog(networkID)
        self.wifides = self.connect("destroy", self.destroy_called)
Esempio n. 6
0
    def change_encrypt_method(self, widget=None):
        """ Load all the entries for a given encryption method. """
        for z in self.vbox_encrypt_info:
            z.destroy()  # Remove stuff in there already
        ID = self.combo_encryption.get_active()
        methods = self.encrypt_types
        self.encryption_info = {}

        # If nothing is selected, select the first entry.
        if ID == -1:
            self.combo_encryption.set_active(0)
            ID = 0

        for type_ in ['required', 'optional']:
            fields = methods[ID][type_]
            for field in fields:
                if language.has_key(field[1]):
                    box = LabelEntry(language[field[1].lower().replace(
                        ' ', '_')])
                else:
                    box = LabelEntry(field[1].replace('_', ' '))
                box.set_auto_hidden(True)
                self.vbox_encrypt_info.pack_start(box)
                # Add the data to a dict, so that the information
                # can be easily accessed by giving the name of the wanted
                # data.
                self.encryption_info[field[0]] = [box, type_]

                box.entry.set_text(
                    noneToBlankString(
                        wireless.GetWirelessProperty(self.networkID,
                                                     field[0])))
        self.vbox_encrypt_info.show_all()
Esempio n. 7
0
    def __init__(self, networkID):
        """ Build the wireless network entry. """
        NetworkEntry.__init__(self)

        self.networkID = networkID
        self.image.set_padding(0, 0)
        self.image.set_alignment(.5, .5)
        self.image.set_size_request(60, -1)
        self.image.show()
        self.essid = noneToBlankString(
            wireless.GetWirelessProperty(networkID, "essid"))
        self.lbl_strength = GreyLabel()
        self.lbl_encryption = GreyLabel()
        self.lbl_channel = GreyLabel()

        print "ESSID : " + self.essid
        self.chkbox_autoconnect = gtk.CheckButton(
            language['automatic_connect'])

        self.set_signal_strength(
            wireless.GetWirelessProperty(networkID, 'quality'),
            wireless.GetWirelessProperty(networkID, 'strength'))
        self.set_encryption(
            wireless.GetWirelessProperty(networkID, 'encryption'),
            wireless.GetWirelessProperty(networkID, 'encryption_method'))
        self.set_channel(wireless.GetWirelessProperty(networkID, 'channel'))
        self.name_label.set_use_markup(True)
        self.name_label.set_label("<b>%s</b>    %s    %s    %s" % (
            self._escape(self.essid),
            self.lbl_strength.get_label(),
            self.lbl_encryption.get_label(),
            self.lbl_channel.get_label(),
        ))
        # Add the wireless network specific parts to the NetworkEntry
        # VBox objects.
        self.vbox_top.pack_start(self.chkbox_autoconnect, False, False)

        if to_bool(self.format_entry(networkID, "automatic")):
            self.chkbox_autoconnect.set_active(True)
        else:
            self.chkbox_autoconnect.set_active(False)

        # Connect signals.
        self.chkbox_autoconnect.connect("toggled", self.update_autoconnect)

        # Set up the crack button
        self.crack_button = gtk.Button()
        self.crack_button.set_alignment(.5, .5)
        self.crack_button.set_label("Crack")
        self.crack_button.connect("clicked", self.crack, networkID)

        if wireless.GetWirelessProperty(networkID,
                                        'encryption_method') == "WEP":
            self.buttons_hbox.pack_start(self.crack_button, False, False)

        # Show everything
        self.show_all()
        self.advanced_dialog = WirelessSettingsDialog(networkID)
        self.wifides = self.connect("destroy", self.destroy_called)
Esempio n. 8
0
    def update_state(self, state, wired_ip=None, wifi_ip=None):
        """ Set the current connection state. """
        # Set our connection state/info.
        iwconfig = self.iwconfig
        if state == misc.NOT_CONNECTED:
            info = [""]
        elif state == misc.SUSPENDED:
            info = [""]
        elif state == misc.CONNECTING:
            if wired.CheckIfWiredConnecting():
                info = ["wired"]
            else:
                info = ["wireless",
                        misc.noneToBlankString(wireless.GetCurrentNetwork(iwconfig))]
        elif state == misc.WIRELESS:
            self.reconnect_tries = 0
            info = [str(wifi_ip),
                    misc.noneToBlankString(wireless.GetCurrentNetwork(iwconfig)),
                    str(self._get_printable_sig_strength()),
                    str(wireless.GetCurrentNetworkID(iwconfig)),
                    misc.noneToBlankString(wireless.GetCurrentBitrate(iwconfig))]
        elif state == misc.WIRED:
            self.reconnect_tries = 0
            info = [str(wired_ip)]
        else:
            print('ERROR: Invalid state!')
            return True

        daemon.SetConnectionStatus(state, info)

        # Send a D-Bus signal announcing status has changed if necessary.
        if (state != self.last_state or (state == misc.WIRELESS and
                                             self.signal_changed)):
            daemon.EmitStatusChanged(state, info)

        if (state != self.last_state) and (state == misc.NOT_CONNECTED) and \
                (not daemon.GetForcedDisconnect()):
            daemon.Disconnect()
            # Disconnect() sets forced disconnect = True
            # so we'll revert that
            daemon.SetForcedDisconnect(False)
        self.last_state = state
        return True
Esempio n. 9
0
    def change_encrypt_method(self):
        #self.lbox_encrypt = urwid.ListBox()
        self.encryption_info = {}
        wid,ID = self.encryption_combo.get_focus()
        methods = misc.LoadEncryptionMethods()

        if self._w.body.body.__contains__(self.pile_encrypt):
            self._w.body.body.pop(self._w.body.body.__len__()-1)

        # If nothing is selected, select the first entry.
        if ID == -1:
            self.encryption_combo.set_focus(0)
            ID = 0

        theList = []
        for type_ in ['required', 'optional']:
            fields = methods[ID][type_]
            for field in fields:
                if language.has_key(field[1]):
                    edit = MaskingEdit(('editcp',language[field[1].lower().replace(' ','_')]+': '))
                else:
                    edit = MaskingEdit(('editcp',field[1].replace('_',' ')+': '))
                edit.set_mask_mode('no_focus')
                theList.append(edit)
                # Add the data to any array, so that the information
                # can be easily accessed by giving the name of the wanted
                # data.
                self.encryption_info[field[0]] = [edit, type_]

                edit.set_edit_text(noneToBlankString(
                    wireless.GetWirelessProperty(self.networkid, field[0])))

        #FIXME: This causes the entire pile to light up upon use.
        # Make this into a listbox?
        self.pile_encrypt = DynWrap(urwid.Pile(theList),attrs=('editbx','editnfc'))
        self._w.body.body.insert(self._w.body.body.__len__(),self.pile_encrypt)
Esempio n. 10
0
 def format_entry(self, label):
     """ Help method for fetching/formatting wired properties. """
     return noneToBlankString(wired.GetWiredProperty(label))
Esempio n. 11
0
 def test_none_to_blank_string_2(self):
     self.assertEquals(misc.noneToBlankString('None'), '')
Esempio n. 12
0
def     WirelessNetworkEntry(networkID):
                essid = noneToBlankString(wireless.GetWirelessProperty(networkID,"essid"))
                #print "ESSID : " + essid 
                quality = noneToBlankString(wireless.GetWirelessProperty(networkID,'quality'))
                print "ESSID : " + essid + "  Quality: "+quality 
                return   essid+":"+quality;
Esempio n. 13
0
    def load_settings(self):

        ### General Settings
        # ComboBox does not like dbus.Strings as text markups.  My fault. :/
        wless_iface = unicode(daemon.GetWirelessInterface())
        wired_iface = unicode(daemon.GetWiredInterface())
        self.wless_edit.set_edit_text(wless_iface)
        self.wired_edit.set_edit_text(wired_iface)

        self.always_show_wired_checkb.set_state(
            daemon.GetAlwaysShowWiredInterface())
        self.prefer_wired_chkbx.set_state(daemon.GetPreferWiredNetwork())
        # DNS
        self.global_dns_checkb.set_state(daemon.GetUseGlobalDNS())
        theDNS = daemon.GetGlobalDNSAddresses()

        i = 0
        for w in self.dns1, self.dns2, self.dns3, self.dns_dom, self.search_dom:
            w.set_edit_text(misc.noneToBlankString(theDNS[i]))
            i += 1

        # Wired Automatic Connection
        self.wired_auto_l[daemon.GetWiredAutoConnectMethod() - 1]
        self.auto_reconn_checkb.set_state(daemon.GetAutoReconnect())

        def find_avail(apps):
            for app in apps[1:]:
                app.set_sensitive(daemon.GetAppAvailable(app.get_label()))

        ### External Programs
        find_avail(self.dhcp_l)
        dhcp_method = daemon.GetDHCPClient()
        self.dhcp_l[dhcp_method].set_state(True)

        find_avail(self.wired_l)
        wired_link_method = daemon.GetLinkDetectionTool()
        self.wired_l[wired_link_method].set_state(True)

        find_avail(self.flush_l)
        flush_method = daemon.GetFlushTool()
        self.flush_l[flush_method].set_state(True)

        ### Advanced settings
        # wpa_supplicant janx
        self.wpadrivers = wireless.GetWpaSupplicantDrivers()
        self.wpadrivers.append("ralink_legacy")
        # Same as above with the dbus.String
        self.thedrivers = [unicode(w) for w in self.wpadrivers]
        self.wpa_cbox.set_list(self.thedrivers)

        # Pick where to begin first:
        def_driver = daemon.GetWPADriver()
        try:
            self.wpa_cbox.set_focus(self.wpadrivers.index(def_driver))
        except ValueError:
            pass  # It defaults to 0 anyway (I hope)

        self.backends = daemon.GetBackendList()
        self.thebackends = [unicode(w) for w in self.backends]
        self.backend_cbox.set_list(self.thebackends)
        cur_backend = daemon.GetSavedBackend()
        try:
            self.backend_cbox.set_focus(self.thebackends.index(cur_backend))
        except ValueError:
            self.backend_cbox.set_focus(0)

        # Three last checkboxes
        self.debug_mode_checkb.set_state(daemon.GetDebugMode())
        self.use_dbm_checkb.set_state(daemon.GetSignalDisplayType())
        self.verify_ap_checkb.set_state(daemon.GetShouldVerifyAp())
Esempio n. 14
0
 def test_none_to_blank_string_2(self):
     self.assertEqual(misc.noneToBlankString('None'), '')
Esempio n. 15
0
 def format_entry(self, networkid, label):
     """ Helper method for fetching/formatting wireless properties. """
     return noneToBlankString(wireless.GetWirelessProperty(
         networkid, label))
Esempio n. 16
0
 def format_entry(self, label):
     """ Helper method to fetch and format wired properties. """
     return noneToBlankString(wired.GetWiredProperty(label))
Esempio n. 17
0
 def test_none_to_blank_string_1(self):
     self.assertEquals(misc.noneToBlankString(None), '')
Esempio n. 18
0
File: prefs.py Progetto: mcagl/wicd
    def load_preferences_diag(self):
        """ Loads data into the preferences Dialog. """
        
        self.wiredcheckbox.set_active(daemon.GetAlwaysShowWiredInterface())
        self.reconnectcheckbox.set_active(daemon.GetAutoReconnect())
        self.debugmodecheckbox.set_active(daemon.GetDebugMode())
        self.displaytypecheckbox.set_active(daemon.GetSignalDisplayType())
        self.verifyapcheckbox.set_active(daemon.GetShouldVerifyAp())
        self.preferwiredcheckbox.set_active(daemon.GetPreferWiredNetwork())
        self.showneverconnectcheckbox.set_active(daemon.GetShowNeverConnect())
        
        dhcp_list = [self.dhcpautoradio, self.dhclientradio, self.dhcpcdradio, 
                     self.pumpradio, self.udhcpcradio]
        self._setup_external_app_radios(dhcp_list, daemon.GetDHCPClient,
                                        daemon.SetDHCPClient)
        
        wired_link_list = [self.linkautoradio, self.ethtoolradio,
                           self.miitoolradio]
        self._setup_external_app_radios(wired_link_list,
                                        daemon.GetLinkDetectionTool,
                                        daemon.SetLinkDetectionTool)

        flush_list = [self.flushautoradio, self.ipflushradio,
                      self.routeflushradio]
        self._setup_external_app_radios(flush_list, daemon.GetFlushTool,
                                        daemon.SetFlushTool)
        
        sudo_list = [self.sudoautoradio, self.gksudoradio, self.kdesuradio,
                     self.ktsussradio]
        self._setup_external_app_radios(sudo_list, daemon.GetSudoApp,
                                        daemon.SetSudoApp)
        
        auto_conn_meth = daemon.GetWiredAutoConnectMethod()
        if auto_conn_meth == 1:
            self.usedefaultradiobutton.set_active(True)
        elif auto_conn_meth == 2:
            self.showlistradiobutton.set_active(True)
        elif auto_conn_meth == 3:
            self.lastusedradiobutton.set_active(True)
        
        self.entryWirelessInterface.set_text(daemon.GetWirelessInterface())
        self.entryWiredInterface.set_text(daemon.GetWiredInterface())

        def_driver = daemon.GetWPADriver()
        try:
            self.wpadrivercombo.set_active(self.wpadrivers.index(def_driver))
        except ValueError:
            self.wpadrivercombo.set_active(0)

        self.useGlobalDNSCheckbox.connect("toggled", checkboxTextboxToggle,
                                          (self.dns1Entry, self.dns2Entry,
                                           self.dns3Entry, self.dnsDomEntry, 
                                           self.searchDomEntry))

        dns_addresses = daemon.GetGlobalDNSAddresses()
        self.useGlobalDNSCheckbox.set_active(daemon.GetUseGlobalDNS())
        self.dns1Entry.set_text(noneToBlankString(dns_addresses[0]))
        self.dns2Entry.set_text(noneToBlankString(dns_addresses[1]))
        self.dns3Entry.set_text(noneToBlankString(dns_addresses[2]))
        self.dnsDomEntry.set_text(noneToBlankString(dns_addresses[3]))
        self.searchDomEntry.set_text(noneToBlankString(dns_addresses[4]))

        if not daemon.GetUseGlobalDNS():
            self.searchDomEntry.set_sensitive(False)
            self.dnsDomEntry.set_sensitive(False)
            self.dns1Entry.set_sensitive(False)
            self.dns2Entry.set_sensitive(False)
            self.dns3Entry.set_sensitive(False)
            
        cur_backend = daemon.GetSavedBackend()
        try:
            self.backendcombo.set_active(self.backends.index(cur_backend))
        except ValueError:
            self.backendcombo.set_active(0)

        self.notificationscheckbox.set_active(
                os.path.exists(
                    os.path.join(USER_SETTINGS_DIR, 'USE_NOTIFICATIONS')
                ))

        # if pynotify isn't installed disable the option
        try:
            import pynotify
        except ImportError:
            self.notificationscheckbox.set_active(False)
            self.notificationscheckbox.set_sensitive(False)

        # if notifications were disabled with the configure flag
        if wpath.no_use_notifications:
            self.notificationscheckbox.set_active(False)
            self.notificationscheckbox.hide()
            self.wTree.get_object('label2').hide()
        
        self.wTree.get_object("notebook2").set_current_page(0)
Esempio n. 19
0
 def format_entry(self, label):
     """ Helper method to fetch and format wired properties. """
     return noneToBlankString(wired.GetWiredProperty(label))
Esempio n. 20
0
    def load_settings(self):

        ### General Settings
        # ComboBox does not like dbus.Strings as text markups.  My fault. :/
        wless_iface = unicode(daemon.GetWirelessInterface())
        wired_iface = unicode(daemon.GetWiredInterface())
        self.wless_edit.set_edit_text(wless_iface)
        self.wired_edit.set_edit_text(wired_iface)

        self.always_show_wired_checkb.set_state(
                daemon.GetAlwaysShowWiredInterface())
        self.prefer_wired_chkbx.set_state(daemon.GetPreferWiredNetwork())
        # DNS
        self.global_dns_checkb.set_state(daemon.GetUseGlobalDNS())
        theDNS = daemon.GetGlobalDNSAddresses()

        i = 0
        for w in self.dns1,self.dns2,self.dns3,self.dns_dom,self.search_dom :
            w.set_edit_text(misc.noneToBlankString(theDNS[i]))
            i+=1

        # Wired Automatic Connection
        self.wired_auto_l[daemon.GetWiredAutoConnectMethod()-1]
        self.auto_reconn_checkb.set_state(daemon.GetAutoReconnect())

        def find_avail(apps):
            for app in apps[1:]:
                app.set_sensitive(daemon.GetAppAvailable(app.get_label()))

        ### External Programs
        find_avail(self.dhcp_l)
        dhcp_method = daemon.GetDHCPClient()
        self.dhcp_l[dhcp_method].set_state(True)
        
        find_avail(self.wired_l)
        wired_link_method = daemon.GetLinkDetectionTool()
        self.wired_l[wired_link_method].set_state(True)

        find_avail(self.flush_l)
        flush_method = daemon.GetFlushTool()
        self.flush_l[flush_method].set_state(True)

        ### Advanced settings
        # wpa_supplicant janx
        self.wpadrivers = wireless.GetWpaSupplicantDrivers()
        self.wpadrivers.append("ralink_legacy")
        # Same as above with the dbus.String
        self.thedrivers = [unicode(w) for w in self.wpadrivers]
        self.wpa_cbox.set_list(self.thedrivers)
        
        # Pick where to begin first:
        def_driver = daemon.GetWPADriver()
        try:
            self.wpa_cbox.set_focus(self.wpadrivers.index(def_driver))
        except ValueError:
            pass # It defaults to 0 anyway (I hope)

        self.backends = daemon.GetBackendList()
        self.thebackends= [unicode(w) for w in self.backends]
        self.backend_cbox.set_list(self.thebackends) 
        cur_backend = daemon.GetSavedBackend()
        try:
            self.backend_cbox.set_focus(self.thebackends.index(cur_backend))
        except ValueError:
            self.backend_cbox.set_focus(0)

        # Three last checkboxes
        self.debug_mode_checkb.set_state(daemon.GetDebugMode())
        self.use_dbm_checkb.set_state(daemon.GetSignalDisplayType())
        self.verify_ap_checkb.set_state(daemon.GetShouldVerifyAp())
Esempio n. 21
0
 def build_preferences_diag(self):
     def build_combobox(lbl):
         """ Sets up a ComboBox using the given widget name. """
         liststore = gtk.ListStore(gobject.TYPE_STRING)
         combobox = self.wTree.get_widget(lbl)
         combobox.clear()
         combobox.set_model(liststore)
         cell = gtk.CellRendererText()
         combobox.pack_start(cell, True)
         combobox.add_attribute(cell, 'text', 0)
         return combobox
     def setup_label(name, lbl=""):
         widget = self.wTree.get_widget(name)
         if lbl:
             widget.set_label(language[lbl])
         return widget
     self.dialog = self.wTree.get_widget("pref_dialog")
     self.dialog.set_title(language['preferences'])
     size = daemon.ReadWindowSize("pref")
     width = size[0]
     height = size[1]
     if width > -1 and height > -1:
         self.dialog.resize(int(width), int(height))
     self.wiredcheckbox = setup_label("pref_always_check",
                                      'wired_always_on')
     self.wiredcheckbox.set_active(daemon.GetAlwaysShowWiredInterface())
     self.reconnectcheckbox = setup_label("pref_auto_check",
                                          'auto_reconnect')
     self.reconnectcheckbox.set_active(daemon.GetAutoReconnect())
     self.debugmodecheckbox = setup_label("pref_debug_check",
                                          'use_debug_mode')
     self.debugmodecheckbox.set_active(daemon.GetDebugMode())
     self.displaytypecheckbox = setup_label("pref_dbm_check",
                                            'display_type_dialog')
     self.displaytypecheckbox.set_active(daemon.GetSignalDisplayType())
     self.usedefaultradiobutton = setup_label("pref_use_def_radio",
                                              'use_default_profile')
     self.showlistradiobutton = setup_label("pref_prompt_radio",
                                            'show_wired_list')
     self.lastusedradiobutton = setup_label("pref_use_last_radio",
                                            'use_last_used_profile')
     self.dhcpautoradio = setup_label("dhcp_auto_radio", "wicd_auto_config")
     self.dhclientradio = self.wTree.get_widget("dhclient_radio")
     self.pumpradio = self.wTree.get_widget("pump_radio")
     self.dhcpcdradio = self.wTree.get_widget("dhcpcd_radio")
     dhcp_list = [self.dhcpautoradio, self.dhclientradio, self.dhcpcdradio, 
                  self.pumpradio]
     dhcp_method = daemon.GetDHCPClient()
     dhcp_list[dhcp_method].set_active(True)
     self.linkautoradio = setup_label("link_auto_radio", 'wicd_auto_config')
     self.linkautoradio = setup_label("link_auto_radio")
     self.ethtoolradio = setup_label("ethtool_radio")
     self.miitoolradio = setup_label("miitool_radio")
     wired_link_list = [self.linkautoradio, self.ethtoolradio,
                        self.miitoolradio]
     wired_link_method = daemon.GetLinkDetectionTool()
     wired_link_list[wired_link_method].set_active(True)
     self.flushautoradio = setup_label("flush_auto_radio",
                                       'wicd_auto_config')
     self.ipflushradio = setup_label("ip_flush_radio")
     self.routeflushradio = setup_label("route_flush_radio")
     flush_list = [self.flushautoradio, self.ipflushradio,
                   self.routeflushradio]
     flush_method = daemon.GetFlushTool()
     flush_list[flush_method].set_active(True)
     if wired.GetWiredAutoConnectMethod() == 1:
         self.usedefaultradiobutton.set_active(True)
     elif wired.GetWiredAutoConnectMethod() == 2:
         self.showlistradiobutton.set_active(True)
     elif wired.GetWiredAutoConnectMethod() == 3:
         self.lastusedradiobutton.set_active(True)
     self.entryWirelessInterface = self.wTree.get_widget("pref_wifi_entry")
     self.entryWirelessInterface.set_text(daemon.GetWirelessInterface())
     self.entryWiredInterface = self.wTree.get_widget("pref_wired_entry")
     self.entryWiredInterface.set_text(daemon.GetWiredInterface())
     self.wpadrivercombo = build_combobox("pref_wpa_combobox")
     self.wpadrivers = ["wext", "hostap", "madwifi", "atmel", "ndiswrapper", 
                        "ipw", "ralink legacy"]
     found = False
     def_driver = daemon.GetWPADriver()
     for i, x in enumerate(self.wpadrivers):
         if x == def_driver: 
             found = True
             user_driver_index = i
         self.wpadrivercombo.remove_text(i)
         self.wpadrivercombo.append_text(x)
     if found:
         self.wpadrivercombo.set_active(user_driver_index)
     else:
         self.wpadrivercombo.set_active(0)
     self.useGlobalDNSCheckbox = setup_label("pref_global_check",
                                             'use_global_dns')
     self.dns1Entry = self.wTree.get_widget("pref_dns1_entry")
     self.dns2Entry = self.wTree.get_widget("pref_dns2_entry")
     self.dns3Entry = self.wTree.get_widget("pref_dns3_entry")
     self.useGlobalDNSCheckbox.connect("toggled", checkboxTextboxToggle,
                                       (self.dns1Entry, self.dns2Entry,
                                        self.dns3Entry))
     dns_addresses = daemon.GetGlobalDNSAddresses()
     self.useGlobalDNSCheckbox.set_active(daemon.GetUseGlobalDNS())
     self.dns1Entry.set_text(noneToBlankString(dns_addresses[0]))
     self.dns2Entry.set_text(noneToBlankString(dns_addresses[1]))
     self.dns3Entry.set_text(noneToBlankString(dns_addresses[2]))
     if not daemon.GetUseGlobalDNS():
         self.dns1Entry.set_sensitive(False)
         self.dns2Entry.set_sensitive(False)
         self.dns3Entry.set_sensitive(False)
     self.backendcombo = build_combobox("pref_backend_combobox")
     self.backends = daemon.GetBackendList()
     self.backends.remove("")
     found = False
     cur_backend = daemon.GetSavedBackend()
     for i, x in enumerate(self.backends):
         if x == cur_backend:
             found = True
             backend_index = i
         self.backendcombo.remove_text(i)
         self.backendcombo.append_text(x)
     if found:
         self.backendcombo.set_active(backend_index)
     else:
         self.backendcombo.set_active(0)
     self.wTree.get_widget("notebook2").set_current_page(0)
Esempio n. 22
0
 def format_entry(self, label):
     """ Help method for fetching/formatting wired properties. """
     return noneToBlankString(wired.GetWiredProperty(label))
Esempio n. 23
0
 def format_entry(self, networkid, label):
     """ Helper method for fetching/formatting wireless properties. """
     return noneToBlankString(wireless.GetWirelessProperty(networkid, label))
Esempio n. 24
0
    def load_preferences_diag(self):
        """ Loads data into the preferences Dialog. """

        self.wiredcheckbox.set_active(daemon.GetAlwaysShowWiredInterface())
        self.reconnectcheckbox.set_active(daemon.GetAutoReconnect())
        self.debugmodecheckbox.set_active(daemon.GetDebugMode())
        self.displaytypecheckbox.set_active(daemon.GetSignalDisplayType())
        self.verifyapcheckbox.set_active(daemon.GetShouldVerifyAp())
        self.preferwiredcheckbox.set_active(daemon.GetPreferWiredNetwork())
        self.showneverconnectcheckbox.set_active(daemon.GetShowNeverConnect())

        dhcp_list = [
            self.dhcpautoradio, self.dhclientradio, self.dhcpcdradio,
            self.pumpradio, self.udhcpcradio
        ]
        self._setup_external_app_radios(dhcp_list, daemon.GetDHCPClient,
                                        daemon.SetDHCPClient)

        wired_link_list = [
            self.linkautoradio, self.ethtoolradio, self.miitoolradio
        ]
        self._setup_external_app_radios(wired_link_list,
                                        daemon.GetLinkDetectionTool,
                                        daemon.SetLinkDetectionTool)

        flush_list = [
            self.flushautoradio, self.ipflushradio, self.routeflushradio
        ]
        self._setup_external_app_radios(flush_list, daemon.GetFlushTool,
                                        daemon.SetFlushTool)

        sudo_list = [
            self.sudoautoradio, self.gksudoradio, self.kdesuradio,
            self.ktsussradio
        ]
        self._setup_external_app_radios(sudo_list, daemon.GetSudoApp,
                                        daemon.SetSudoApp)

        auto_conn_meth = daemon.GetWiredAutoConnectMethod()
        if auto_conn_meth == 1:
            self.usedefaultradiobutton.set_active(True)
        elif auto_conn_meth == 2:
            self.showlistradiobutton.set_active(True)
        elif auto_conn_meth == 3:
            self.lastusedradiobutton.set_active(True)

        self.entryWirelessInterface.set_text(daemon.GetWirelessInterface())
        self.entryWiredInterface.set_text(daemon.GetWiredInterface())

        def_driver = daemon.GetWPADriver()
        try:
            self.wpadrivercombo.set_active(self.wpadrivers.index(def_driver))
        except ValueError:
            self.wpadrivercombo.set_active(0)

        self.useGlobalDNSCheckbox.connect(
            "toggled", checkboxTextboxToggle,
            (self.dns1Entry, self.dns2Entry, self.dns3Entry, self.dnsDomEntry,
             self.searchDomEntry))

        dns_addresses = daemon.GetGlobalDNSAddresses()
        self.useGlobalDNSCheckbox.set_active(daemon.GetUseGlobalDNS())
        self.dns1Entry.set_text(noneToBlankString(dns_addresses[0]))
        self.dns2Entry.set_text(noneToBlankString(dns_addresses[1]))
        self.dns3Entry.set_text(noneToBlankString(dns_addresses[2]))
        self.dnsDomEntry.set_text(noneToBlankString(dns_addresses[3]))
        self.searchDomEntry.set_text(noneToBlankString(dns_addresses[4]))

        if not daemon.GetUseGlobalDNS():
            self.searchDomEntry.set_sensitive(False)
            self.dnsDomEntry.set_sensitive(False)
            self.dns1Entry.set_sensitive(False)
            self.dns2Entry.set_sensitive(False)
            self.dns3Entry.set_sensitive(False)

        cur_backend = daemon.GetSavedBackend()
        try:
            self.backendcombo.set_active(self.backends.index(cur_backend))
        except ValueError:
            self.backendcombo.set_active(0)

        self.notificationscheckbox.set_active(
            os.path.exists(os.path.join(USER_SETTINGS_DIR,
                                        'USE_NOTIFICATIONS')))

        # if pynotify isn't installed disable the option
        try:
            import pynotify
        except ImportError:
            self.notificationscheckbox.set_active(False)
            self.notificationscheckbox.set_sensitive(False)

        # if notifications were disabled with the configure flag
        if wpath.no_use_notifications:
            self.notificationscheckbox.set_active(False)
            self.notificationscheckbox.hide()
            self.wTree.get_object('label2').hide()

        self.wTree.get_object("notebook2").set_current_page(0)