Exemple #1
0
def run_configscript(parent, netname, nettype):
    """ Run configuration script. """
    configfile = wpath.etc + netname + '-settings.conf'
    if nettype != 'wired':
        header = 'profile'
    else:
        header = 'BSSID'
    if nettype == 'wired':
        profname = nettype
    else:
        profname = wireless.GetWirelessProperty(int(netname), 'bssid')
    theText = [
        _('To avoid various complications, wicd-curses does not support directly '
          'editing the scripts. However, you can edit them manually. First, (as root), '
          'open the "$A" config file, and look for the section labeled by the $B in '
          'question. In this case, this is:').replace('$A',
                                                      configfile).replace(
                                                          '$B', header),
        "\n\n[" + profname + "]\n\n",
        _('You can also configure the wireless networks by looking for the "[<ESSID>]" '
          'field in the config file.'),
        _('Once there, you can adjust (or add) the "beforescript", "afterscript", '
          '"predisconnectscript" and "postdisconnectscript" variables as needed, to '
          'change the preconnect, postconnect, predisconnect and postdisconnect scripts '
          'respectively.  Note that you will be specifying the full path to the scripts '
          '- not the actual script contents.  You will need to add/edit the script '
          'contents separately.  Refer to the wicd manual page for more information.'
          )
    ]
    dialog = TextDialog(theText, 20, 80)
    dialog.run(ui, parent)
Exemple #2
0
def about_dialog(body):
    """ About dialog. """
    # This looks A LOT better when it is actually displayed.  I promise :-).
    # The ASCII Art "Wicd" was made from the "smslant" font on one of those
    # online ASCII big text generators.
    theText = [
        ('green', "   ///       \\\\\\"), "       _      ___        __\n",
        ('green', "  ///         \\\\\\"), "     | | /| / (_)______/ /\n",
        ('green', " ///           \\\\\\"), "    | |/ |/ / / __/ _  / \n",
        ('green', "/||  //     \\\\  ||\\"), "   |__/|__/_/\__/\_,_/  \n",
        ('green', "|||  ||"), "(|^|)", ('green', "||  |||"),
        "         ($VERSION)       \n".replace("$VERSION", daemon.Hello()),
        ('green', "\\||  \\\\"), " |+| ", ('green', "//  ||/    \n"),
        ('green', " \\\\\\"), "    |+|    ",
        ('green', "///"), "      http://launchpad.net/wicd\n",
        ('green', "  \\\\\\"), "   |+|   ", ('green', "///"), "      ",
        _('Brought to you by:'), "\n", ('green', "   \\\\\\"), "  |+|  ",
        ('green', "///"), "       * Tom Van Braeckel\n",
        "      __|+|__          * Adam Blackburn\n",
        "     ___|+|___         * Dan O'Reilly\n",
        "    ____|+|____        * Andrew Psaltis\n",
        "   |-----------|       * David Paleino\n"
    ]
    about = TextDialog(theText, 18, 55, header=('header', _('About Wicd')))
    about.run(ui, body)
Exemple #3
0
def run_configscript(parent, netname, nettype):
    """ Run configuration script. """
    configfile = wpath.etc + netname + '-settings.conf'
    if nettype != 'wired':
        header = 'profile'
    else:
        header = 'BSSID'
    if nettype == 'wired':
        profname = nettype
    else:
        profname = wireless.GetWirelessProperty(int(netname), 'bssid')
    theText = [
_('To avoid various complications, wicd-curses does not support directly '
'editing the scripts. However, you can edit them manually. First, (as root), '
'open the "$A" config file, and look for the section labeled by the $B in '
'question. In this case, this is:').
replace('$A', configfile).replace('$B', header),
"\n\n[" + profname + "]\n\n",
_('You can also configure the wireless networks by looking for the "[<ESSID>]" '
'field in the config file.'),
_('Once there, you can adjust (or add) the "beforescript", "afterscript", '
'"predisconnectscript" and "postdisconnectscript" variables as needed, to '
'change the preconnect, postconnect, predisconnect and postdisconnect scripts '
'respectively.  Note that you will be specifying the full path to the scripts '
'- not the actual script contents.  You will need to add/edit the script '
'contents separately.  Refer to the wicd manual page for more information.')
    ]
    dialog = TextDialog(theText, 20, 80)
    dialog.run(ui, parent)
Exemple #4
0
def about_dialog(body):
    """ About dialog. """
    # This looks A LOT better when it is actually displayed.  I promise :-).
    # The ASCII Art "Wicd" was made from the "smslant" font on one of those
    # online ASCII big text generators.
    theText = [
('green', "   ///       \\\\\\"), "       _      ___        __\n",
('green', "  ///         \\\\\\"), "     | | /| / (_)______/ /\n",
('green', " ///           \\\\\\"), "    | |/ |/ / / __/ _  / \n",
('green', "/||  //     \\\\  ||\\"), "   |__/|__/_/\__/\_,_/  \n",
('green', "|||  ||"), "(|^|)", ('green', "||  |||"),
"         ($VERSION)       \n".replace("$VERSION", daemon.Hello()),

('green', "\\||  \\\\"), " |+| ", ('green', "//  ||/    \n"),
('green', " \\\\\\"), "    |+|    ", ('green', "///"),
    "      http://wicd.net\n",
('green', "  \\\\\\"), "   |+|   ", ('green', "///"), "      ",
    _('Brought to you by:'), "\n",
('green', "   \\\\\\"), "  |+|  ", ('green', "///"), "       Adam Blackburn\n",
"     ___|+|___         Dan O'Reilly\n",
"    ____|+|____        Andrew Psaltis\n",
"   |-----------|       David Paleino\n",
"-----------------------------------------------------"]
    about = TextDialog(theText, 16, 55, header=('header', _('About Wicd')))
    about.run(ui, body)
Exemple #5
0
def about_dialog(body):
    """ About dialog. """
    # This looks A LOT better when it is actually displayed.  I promise :-).
    # The ASCII Art "Wicd" was made from the "smslant" font on one of those
    # online ASCII big text generators.
    theText = [
        ("green", "   ///       \\\\\\"),
        "       _      ___        __\n",
        ("green", "  ///         \\\\\\"),
        "     | | /| / (_)______/ /\n",
        ("green", " ///           \\\\\\"),
        "    | |/ |/ / / __/ _  / \n",
        ("green", "/||  //     \\\\  ||\\"),
        "   |__/|__/_/\__/\_,_/  \n",
        ("green", "|||  ||"),
        "(|^|)",
        ("green", "||  |||"),
        "         ($VERSION)       \n".replace("$VERSION", daemon.Hello()),
        ("green", "\\||  \\\\"),
        " |+| ",
        ("green", "//  ||/    \n"),
        ("green", " \\\\\\"),
        "    |+|    ",
        ("green", "///"),
        "      http://launchpad.net/wicd\n",
        ("green", "  \\\\\\"),
        "   |+|   ",
        ("green", "///"),
        "      ",
        _("Brought to you by:"),
        "\n",
        ("green", "   \\\\\\"),
        "  |+|  ",
        ("green", "///"),
        "       * Tom Van Braeckel\n",
        "      __|+|__          * Adam Blackburn\n",
        "     ___|+|___         * Dan O'Reilly\n",
        "    ____|+|____        * Andrew Psaltis\n",
        "   |-----------|       * David Paleino\n",
    ]
    about = TextDialog(theText, 18, 55, header=("header", _("About Wicd")))
    about.run(ui, body)
Exemple #6
0
    def handle_keys(self, keys):
        """ Handle keys. """
        if not self.diag:
            # Handle keystrokes
            if "f8" in keys or 'Q' in keys or 'q' in keys:
                loop.quit()
                #return False
            if "f5" in keys or 'R' in keys:
                self.lock_screen()
                self.doScan()
            if 'k' in keys or 'K' in keys:
                wireless.SwitchRfKill()
                self.update_netlist()
            if "D" in keys:
                # Disconnect from all networks.
                daemon.Disconnect()
                self.update_netlist()
            if 'right' in keys:
                if not self.scanning:
                    focus = self.thePile.get_focus()
                    self.frame.set_footer(
                        urwid.Pile([self.confCols, self.footer2]))
                    if focus == self.wiredCB:
                        self.diag = WiredSettingsDialog(
                            self.wiredCB.get_body().get_selected_profile(),
                            self.frame)
                        self.diag.ready_widgets(ui, self.frame)
                        self.frame.set_body(self.diag)
                    else:
                        # wireless list only other option
                        trash, pos = self.thePile.get_focus().get_focus()
                        self.diag = WirelessSettingsDialog(pos, self.frame)
                        self.diag.ready_widgets(ui, self.frame)
                        self.frame.set_body(self.diag)
                    self.diag_type = 'conf'
            if "enter" in keys or 'C' in keys:
                if not self.scanning:
                    focus = self.frame.body.get_focus()
                    if focus == self.wiredCB:
                        self.special = focus
                        self.connect("wired", 0)
                    else:
                        # wless list only other option, if it is around
                        if self.wlessLB != self.no_wlan:
                            wid, pos = self.thePile.get_focus().get_focus()
                            self.connect("wireless", pos)
            if "esc" in keys:
                # Force disconnect here if connection in progress
                if self.connecting:
                    daemon.CancelConnect()
                    # Prevents automatic reconnecting if that option is enabled
                    daemon.SetForcedDisconnect(True)
            if "P" in keys:
                if not self.pref:
                    self.pref = PrefsDialog(self.frame, (0, 1), ui,
                                            dbusmanager.get_dbus_ifaces())
                self.pref.load_settings()
                self.pref.ready_widgets(ui, self.frame)
                self.frame.set_footer(urwid.Pile([self.prefCols,
                                                  self.footer2]))
                self.diag = self.pref
                self.diag_type = 'pref'
                self.frame.set_body(self.diag)
                # Halt here, keypress gets passed to the dialog otherwise
                return True
            if "A" in keys:
                about_dialog(self.frame)
            if "I" in keys:
                self.raise_hidden_network_dialog()
            if "H" in keys or 'h' in keys or '?' in keys:
                # FIXME I shouldn't need this, OptCols messes up this one
                # particular button
                if not self.diag:
                    help_dialog(self.frame)
            if "S" in keys:
                focus = self.thePile.get_focus()
                if focus == self.wiredCB:
                    nettype = 'wired'
                    netname = self.wiredCB.get_body().get_selected_profile()
                else:
                    nettype = 'wireless'
                    netname = str(self.wlessLB.get_focus()[1])
                run_configscript(self.frame, netname, nettype)
            if "O" in keys:
                exitcode, data = AdHocDialog().run(ui, self.frame)
                #data = (essid,ip,channel,use_ics,use_encrypt,key_edit)
                if exitcode == 1:
                    wireless.CreateAdHocNetwork(data[0], data[2], data[1],
                                                "WEP", data[5], data[4], False)
            if 'X' in keys:
                exitcode, data = ForgetDialog().run(ui, self.frame)
                if exitcode == 1:
                    text = _('Are you sure you want to discard settings for '
                             'the selected networks?')
                    text += '\n\n' + '\n'.join(data['essid'])
                    confirm, trash = TextDialog(
                        text,
                        20,
                        50,
                        buttons=[(_('OK'), 1), (_('Cancel'), -1)],
                    ).run(ui, self.frame)
                    if confirm == 1:
                        for x in data['bssid']:
                            wireless.DeleteWirelessNetwork(x)

        for k in keys:
            if urwid.VERSION < (1, 0, 0):
                check_mouse_event = urwid.is_mouse_event
            else:
                check_mouse_event = urwid.util.is_mouse_event
            if check_mouse_event(k):
                event, button, col, row = k
                self.frame.mouse_event(self.size,
                                       event,
                                       button,
                                       col,
                                       row,
                                       focus=True)
                continue
            k = self.frame.keypress(self.size, k)
            if self.diag:
                if k == 'esc' or k == 'q' or k == 'Q':
                    self.restore_primary()
                    break
                # F10 has been changed to S to avoid using function keys,
                # which are often caught by the terminal emulator.
                # But F10 still works, because it doesn't hurt and some users might be used to it.
                if k == 'f10' or k == 'S' or k == 's':
                    self.diag.save_settings()
                    self.restore_primary()
                    break
            if k == "window resize":
                self.size = ui.get_cols_rows()
                continue