Esempio n. 1
0
    def save_settings(self):
        """ Save settings to disk. """
        # Check encryption info
        if self.encryption_chkbox.get_state():
            encrypt_info = self.encryption_info
            encrypt_methods = self.encrypt_types
            self.set_net_prop(
                "enctype",
                encrypt_methods[self.encryption_combo.get_focus()[1]]['type']
            )
            # Make sure all required fields are filled in.
            for entry_info in encrypt_info.itervalues():
                if entry_info[0].get_edit_text() == "" \
                    and entry_info[1] == 'required':
                    error(
                        self.ui,
                        self.parent,
                        "%s (%s)" % (
                            _('Required encryption information is missing.'),
                            entry_info[0].get_caption()[0:-2]
                        )
                    )
                    return False

            for entry_key, entry_info in encrypt_info.iteritems():
                self.set_net_prop(entry_key, noneToString(entry_info[0].
                                                   get_edit_text()))
        elif not self.encryption_chkbox.get_state() and \
             wireless.GetWirelessProperty(self.networkid, "encryption"):
            # Encrypt checkbox is off, but the network needs it.
            error(
                self.ui,
                self.parent,
                _('This network requires encryption to be enabled.')
            )
            return False
        else:
            self.set_net_prop("enctype", "None")
        AdvancedSettingsDialog.save_settings(self)

        # Save the autoconnect setting.  This is not where it originally was
        # in the GTK UI.
        self.set_net_prop("automatic", self.autoconnect_chkbox.get_state())

        if self.global_settings_chkbox.get_state():
            self.set_net_prop('use_settings_globally', True)
        else:
            self.set_net_prop('use_settings_globally', False)
            wireless.RemoveGlobalEssidEntry(self.networkid)

        self.set_net_prop(
            'bitrate',
            self.bitrates[self.bitrate_combo.get_focus()[1]]
        )
        self.set_net_prop(
            'allow_lower_bitrates',
            self.allow_lower_bitrates_chkbox.get_state()
        )
        wireless.SaveWirelessNetworkProfile(self.networkid)
        return True
Esempio n. 2
0
    def keypress(self, size, key):
        """ Handle keypresses. """
        prev_focus = self.get_focus()[1]
        key = ComboBox.keypress(self, size, key)
        if key == ' ':
            if self.get_focus()[1] == len(self.list) - 1:
                dialog = InputDialog(
                    ('header', _('Add a new wired profile')),
                    7, 30
                )
                exitcode, name = dialog.run(ui, self.parent)
                if exitcode == 0:
                    name = name.strip()
                    if not name:
                        error(ui, self.parent, 'Invalid profile name')
                        self.set_focus(prev_focus)
                        return key

                    wired.CreateWiredNetworkProfile(name, False)
                    self.set_list(wired.GetWiredProfileList())
                    self.rebuild_combobox()
                self.set_focus(prev_focus)
            else:
                wired.ReadWiredNetworkProfile(self.get_selected_profile())
        if key == 'delete':
            if len(self.theList) == 1:
                error(
                    self.ui,
                    self.parent,
                    _('wicd-curses does not support deleting the last wired '
                    'profile.  Try renaming it ("F2")')
                )
                return key
            wired.DeleteWiredNetworkProfile(self.get_selected_profile())
            # Return to the top of the list if something is deleted.

            if wired.GetDefaultWiredNetwork() is not None:
                self.set_focus(
                    self.theList.index(wired.GetDefaultWiredNetwork())
                )
            else:
                prev_focus -= 1
                self.set_focus(prev_focus)
            self.set_list(wired.GetWiredProfileList())
            self.rebuild_combobox()
        if key == 'f2':
            dialog = InputDialog(
                ('header', _('Rename wired profile')),
                7, 30,
                edit_text=unicode(self.get_selected_profile())
            )
            exitcode, name = dialog.run(ui, self.parent)
            if exitcode == 0:
                # Save the new one, then kill the old one
                wired.SaveWiredNetworkProfile(name)
                wired.DeleteWiredNetworkProfile(self.get_selected_profile())
                self.set_list(wired.GetWiredProfileList())
                self.set_focus(self.theList.index(name))
                self.rebuild_combobox()
        return key
Esempio n. 3
0
    def keypress(self, size, key):
        """ Handle keypresses. """
        prev_focus = self.get_focus()[1]
        key = ComboBox.keypress(self, size, key)
        if key == ' ':
            if self.get_focus()[1] == len(self.list) - 1:
                dialog = InputDialog(
                    ('header', _('Add a new wired profile')),
                    7, 30
                )
                exitcode, name = dialog.run(ui, self.parent)
                if exitcode == 0:
                    name = name.strip()
                    if not name:
                        error(ui, self.parent, 'Invalid profile name')
                        self.set_focus(prev_focus)
                        return key

                    wired.CreateWiredNetworkProfile(name, False)
                    self.set_list(wired.GetWiredProfileList())
                    self.rebuild_combobox()
                self.set_focus(prev_focus)
            else:
                wired.ReadWiredNetworkProfile(self.get_selected_profile())
        if key == 'delete':
            if len(self.theList) == 1:
                error(
                    self.ui,
                    self.parent,
                    _('wicd-curses does not support deleting the last wired '
                    'profile.  Try renaming it ("F2")')
                )
                return key
            wired.DeleteWiredNetworkProfile(self.get_selected_profile())
            # Return to the top of the list if something is deleted.

            if wired.GetDefaultWiredNetwork() is not None:
                self.set_focus(
                    self.theList.index(wired.GetDefaultWiredNetwork())
                )
            else:
                prev_focus -= 1
                self.set_focus(prev_focus)
            self.set_list(wired.GetWiredProfileList())
            self.rebuild_combobox()
        if key == 'f2':
            dialog = InputDialog(
                ('header', _('Rename wired profile')),
                7, 30,
                edit_text=unicode(self.get_selected_profile())
            )
            exitcode, name = dialog.run(ui, self.parent)
            if exitcode == 0:
                # Save the new one, then kill the old one
                wired.SaveWiredNetworkProfile(name)
                wired.DeleteWiredNetworkProfile(self.get_selected_profile())
                self.set_list(wired.GetWiredProfileList())
                self.set_focus(self.theList.index(name))
                self.rebuild_combobox()
        return key
Esempio n. 4
0
    def save_settings(self):
        # Check encryption info
        if self.encryption_chkbox.get_state():
            encrypt_info = self.encryption_info
            encrypt_methods = self.encrypt_types
            self.set_net_prop("enctype",
                               encrypt_methods[self.encryption_combo.get_focus()[1] ]['type'])
            self.set_net_prop("encryption_enabled", True)
            # Make sure all required fields are filled in.
            for entry_info in encrypt_info.itervalues():
                if entry_info[0].get_edit_text() == "" \
                    and entry_info[1] == 'required':
                    error(self.ui, self.parent,"%s (%s)" \
                            % (_('Required encryption information is missing.'),
                                entry_info[0].get_caption()[0:-2] )
                          )
                    return False

            for entry_key, entry_info in encrypt_info.iteritems():
                self.set_net_prop(entry_key, noneToString(entry_info[0].
                                                   get_edit_text()))
        else:
            self.set_net_prop("enctype", "None")
            self.set_net_prop("encryption_enabled", False)
        
        AdvancedSettingsDialog.save_settings(self)
        if self.set_default.get_state():
            wired.UnsetWiredDefault()
        if self.set_default.get_state():
            bool = True
        else:
            bool = False
        wired.SetWiredProperty("default",bool)
        wired.SaveWiredNetworkProfile(self.prof_name)
        return True
Esempio n. 5
0
    def save_settings(self):
        """ Save settings to disk. """
        # Check encryption info
        if self.encryption_chkbox.get_state():
            encrypt_info = self.encryption_info
            encrypt_methods = self.encrypt_types
            self.set_net_prop(
                "enctype",
                encrypt_methods[self.encryption_combo.get_focus()[1]]['type'])
            # Make sure all required fields are filled in.
            for entry_info in encrypt_info.values():
                if entry_info[0].get_edit_text() == "" \
                    and entry_info[1] == 'required':
                    error(
                        self.ui, self.parent, "%s (%s)" %
                        (_('Required encryption information is missing.'),
                         entry_info[0].get_caption()[0:-2]))
                    return False

            for entry_key, entry_info in encrypt_info.items():
                self.set_net_prop(entry_key,
                                  noneToString(entry_info[0].get_edit_text()))
        elif not self.encryption_chkbox.get_state() and \
             wireless.GetWirelessProperty(self.networkid, "encryption"):
            # Encrypt checkbox is off, but the network needs it.
            error(self.ui, self.parent,
                  _('This network requires encryption to be enabled.'))
            return False
        else:
            self.set_net_prop("enctype", "None")
        AdvancedSettingsDialog.save_settings(self)

        # Save the autoconnect setting.  This is not where it originally was
        # in the GTK UI.
        self.set_net_prop("automatic", self.autoconnect_chkbox.get_state())

        if self.global_settings_chkbox.get_state():
            self.set_net_prop('use_settings_globally', True)
        else:
            self.set_net_prop('use_settings_globally', False)
            wireless.RemoveGlobalEssidEntry(self.networkid)

        self.set_net_prop('bitrate',
                          self.bitrates[self.bitrate_combo.get_focus()[1]])
        self.set_net_prop('allow_lower_bitrates',
                          self.allow_lower_bitrates_chkbox.get_state())
        wireless.SaveWirelessNetworkProfile(self.networkid)
        return True
Esempio n. 6
0
    def save_settings(self):
        """ Save settings to disk. """
        # Check encryption info
        if self.encryption_chkbox.get_state():
            encrypt_info = self.encryption_info
            encrypt_methods = self.encrypt_types
            self.set_net_prop(
                "enctype",
                encrypt_methods[self.encryption_combo.get_focus()[1]]['type'])
            self.set_net_prop("encryption_enabled", True)
            # Make sure all required fields are filled in.
            for entry_info in encrypt_info.values():
                if entry_info[0].get_edit_text() == "" \
                  and entry_info[1] == 'required':
                    error(
                        self.ui, self.parent, "%s (%s)" %
                        (_('Required encryption information is missing.'),
                         entry_info[0].get_caption()[0:-2]))
                    return False

            for entry_key, entry_info in encrypt_info.items():
                self.set_net_prop(entry_key,
                                  noneToString(entry_info[0].get_edit_text()))
        else:
            self.set_net_prop("enctype", "None")
            self.set_net_prop("encryption_enabled", False)

        AdvancedSettingsDialog.save_settings(self)
        if self.set_default.get_state():
            wired.UnsetWiredDefault()
        if self.set_default.get_state():
            set_default = True
        else:
            set_default = False
        wired.SetWiredProperty("default", set_default)
        wired.SaveWiredNetworkProfile(self.prof_name)
        return True