Ejemplo n.º 1
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
Ejemplo n.º 2
0
 def wrapper(*args, **kargs):
     try:
         return func(*args, **kargs)
     except KeyboardInterrupt:
         #gobject.source_remove(redraw_tag)
         loop.quit()
         ui.stop()
         print >> sys.stderr, "\n" + _('Terminated by user')
         #raise
     except DBusException:
         loop.quit()
         ui.stop()
         print >> sys.stderr, "\n" + _('DBus failure! '
             'This is most likely caused by the wicd daemon '
             'stopping while wicd-curses is running. '
             'Please restart the daemon, and then restart wicd-curses.')
         raise
     except:
         # Quit the loop
         #if 'loop' in locals():
         loop.quit()
         # Zap the screen
         ui.stop()
         # Print out standard notification:
         # This message was far too scary for humans, so it's gone now.
         # print >> sys.stderr, "\n" + _('EXCEPTION! Please report this '
         # 'to the maintainer and file a bug report with the backtrace '
         # 'below:')
         # Flush the buffer so that the notification is always above the
         # backtrace
         sys.stdout.flush()
         # Raise the exception
         raise
Ejemplo n.º 3
0
    def __init__(self, name, parent):
        AdvancedSettingsDialog.__init__(self)
        self.wired = True

        self.set_default = urwid.CheckBox(
            _('Use as default profile (overwrites any previous default)'))
        #self.cur_default =
        # Add widgets to listbox
        self._w.body.body.append(self.set_default)

        self.parent = parent
        encryption_t = _('Use Encryption')

        self.encryption_chkbox = urwid.CheckBox(
            encryption_t, on_state_change=self.encryption_toggle)
        self.encryption_combo = ComboBox(callback=self.combo_on_change)
        self.pile_encrypt = None
        # _w is a Frame, _w.body is a ListBox, _w.body.body is the ListWalker
        # pylint: disable-msg=E1103
        self._listbox.body.append(self.encryption_chkbox)
        # pylint: disable-msg=E1103
        self._listbox.body.append(self.encryption_combo)
        self.encrypt_types = misc.LoadEncryptionMethods(wired=True)
        self.set_values()

        self.prof_name = name
        title = _('Configuring preferences for wired profile "$A"'). \
            replace('$A', self.prof_name)
        self._w.header = urwid.Text(('header', title), align='right')

        self.set_values()
Ejemplo n.º 4
0
    def refresh_networks(self, widget=None, fresh=True, hidden=None):
        """ Refreshes the network list.

        If fresh=True, scans for wireless networks and displays the results.
        If a ethernet connection is available, or the user has chosen to,
        displays a Wired Network entry as well.
        If hidden isn't None, will scan for networks after running
        iwconfig <wireless interface> essid <hidden>.

        """
        if fresh:
            if hidden:
                wireless.SetHiddenNetworkESSID(noneToString(hidden))
            self.refresh_clicked()
            return
        print "refreshing..."
        self.network_list.set_sensitive(False)
        self._remove_items_from_vbox(self.network_list)
        self.wait_for_events()
        printLine = False  # We don't print a separator by default.
        if self._wired_showing:
            printLine = True
        num_networks = wireless.GetNumberOfNetworks()
        instruct_label = self.wTree.get_object("label_instructions")
        if num_networks > 0:
            skip_never_connect = not daemon.GetShowNeverConnect()
            instruct_label.show()
            for x in xrange(0, num_networks):
                if skip_never_connect and \
                  misc.to_bool(get_wireless_prop(x, 'never')):
                    continue
                if printLine:
                    sep = gtk.HSeparator()
                    self.network_list.pack_start(sep, padding=10, fill=False,
                                                 expand=False)
                    sep.show()
                else:
                    printLine = True
                tempnet = WirelessNetworkEntry(x)
                self.network_list.pack_start(tempnet, False, False)
                tempnet.connect_button.connect("clicked",
                                               self.connect, "wireless", x,
                                               tempnet)
                tempnet.disconnect_button.connect("clicked",
                                                  self.disconnect, "wireless",
                                                  x, tempnet)
                tempnet.advanced_button.connect("clicked",
                                                self.edit_advanced, "wireless",
                                                x, tempnet)
        else:
            instruct_label.hide()
            if wireless.GetKillSwitchEnabled():
                label = gtk.Label(_('Wireless Kill Switch Enabled') + ".")
            else:
                label = gtk.Label(_('No wireless networks found.'))
            self.network_list.pack_start(label)
            label.show()
        self.update_connect_buttons(force_check=True)
        self.network_list.set_sensitive(True)
        self.refreshing = False
Ejemplo n.º 5
0
 def wrapper(*args, **kargs):
     try:
         return func(*args, **kargs)
     except KeyboardInterrupt:
         #gobject.source_remove(redraw_tag)
         loop.quit()
         ui.stop()
         print >> sys.stderr, "\n" + _('Terminated by user')
         #raise
     except DBusException:
         loop.quit()
         ui.stop()
         print >> sys.stderr, "\n" + _(
             'DBus failure! '
             'This is most likely caused by the wicd daemon '
             'stopping while wicd-curses is running. '
             'Please restart the daemon, and then restart wicd-curses.')
         raise
     except:
         # Quit the loop
         #if 'loop' in locals():
         loop.quit()
         # Zap the screen
         ui.stop()
         # Print out standard notification:
         # This message was far too scary for humans, so it's gone now.
         # print >> sys.stderr, "\n" + _('EXCEPTION! Please report this '
         # 'to the maintainer and file a bug report with the backtrace '
         # 'below:')
         # Flush the buffer so that the notification is always above the
         # backtrace
         sys.stdout.flush()
         # Raise the exception
         raise
Ejemplo 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']
            )
            # 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
Ejemplo n.º 7
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)
Ejemplo n.º 8
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)
Ejemplo n.º 9
0
    def __init__(self, name, parent):
        AdvancedSettingsDialog.__init__(self)
        self.wired = True

        self.set_default = urwid.CheckBox(
            _('Use as default profile (overwrites any previous default)')
        )
        #self.cur_default =
        # Add widgets to listbox
        self._w.body.body.append(self.set_default)

        self.parent = parent
        encryption_t = _('Use Encryption')

        self.encryption_chkbox = urwid.CheckBox(
            encryption_t,
            on_state_change=self.
            encryption_toggle
        )
        self.encryption_combo = ComboBox(callback=self.combo_on_change)
        self.pile_encrypt = None
        # _w is a Frame, _w.body is a ListBox, _w.body.body is the ListWalker
        # pylint: disable-msg=E1103
        self._listbox.body.append(self.encryption_chkbox)
        # pylint: disable-msg=E1103
        self._listbox.body.append(self.encryption_combo)
        self.encrypt_types = misc.LoadEncryptionMethods(wired=True)
        self.set_values()

        self.prof_name = name
        title = _('Configuring preferences for wired profile "$A"'). \
            replace('$A', self.prof_name)
        self._w.header = urwid.Text(('header', title), align='right')

        self.set_values()
Ejemplo n.º 10
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)
Ejemplo n.º 11
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)
Ejemplo n.º 12
0
    def __init__(self):
        self.to_remove = dict(essid=[], bssid=[])

        header = urwid.AttrWrap(
            urwid.Text('  %20s %20s' % ('ESSID', 'BSSID')),
            'listbar'
        )
        title = urwid.Text(_('Please select the networks to forget'))
        l = [title, header]
        for entry in wireless.GetSavedWirelessNetworks():
            label = '%20s %20s'
            if entry[1] != 'None':
                label = label % (entry[0], entry[1])
                data = entry
            else:
                label = label % (entry[0], 'global')
                data = (entry[0], 'essid:' + entry[0])

            cb = urwid.CheckBox(
                label,
                on_state_change=self.update_to_remove,
                user_data=data
            )
            l.append(cb)
        body = urwid.ListBox(l)

        header = ('header', _('List of saved networks'))
        Dialog2.__init__(self, header, 15, 50, body)
        self.add_buttons([(_('Remove'), 1), (_('Cancel'), -1)])
        self.frame.set_focus('body')
Ejemplo n.º 13
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
Ejemplo n.º 14
0
def run_configscript(parent,netname,nettype):
    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)
    # This code works with many distributions, but not all of them.  So, to
    # limit complications, it has been deactivated.  If you want to run it,
    # be my guest.  Be sure to deactivate the above stuff first.
    """
Ejemplo n.º 15
0
def setup_dbus(force=True):
    """ Initialize DBus. """
    global bus, daemon, wireless, wired
    try:
        dbusmanager.connect_to_dbus()
    except DBusException:
        print >> sys.stderr, \
          _("Can't connect to the daemon, trying to start it automatically...")

    try:
        bus = dbusmanager.get_bus()
        dbus_ifaces = dbusmanager.get_dbus_ifaces()
        daemon = dbus_ifaces['daemon']
        wireless = dbus_ifaces['wireless']
        wired = dbus_ifaces['wired']
    except DBusException:
        print >> sys.stderr, \
          _("Can't automatically start the daemon, this error is fatal...")

    if not daemon:
        print 'Error connecting to wicd via D-Bus. ' \
            'Please make sure the wicd service is running.'
        sys.exit(3)

    netentry_curses.dbus_init(dbus_ifaces)
    return True
Ejemplo n.º 16
0
def setup_dbus(force=True):
    """ Initialize DBus. """
    global bus, daemon, wireless, wired
    try:
        dbusmanager.connect_to_dbus()
    except DBusException:
        print >> sys.stderr, \
          _("Can't connect to the daemon, trying to start it automatically...")

    try:
           bus = dbusmanager.get_bus()
           dbus_ifaces = dbusmanager.get_dbus_ifaces()
           daemon = dbus_ifaces['daemon']
           wireless = dbus_ifaces['wireless']
           wired = dbus_ifaces['wired']
    except DBusException:
        print >> sys.stderr, \
          _("Can't automatically start the daemon, this error is fatal...")

    if not daemon:
        print 'Error connecting to wicd via D-Bus. ' \
            'Please make sure the wicd service is running.'
        sys.exit(3)

    netentry_curses.dbus_init(dbus_ifaces)
    return True
Ejemplo n.º 17
0
 def init_other_optcols(self):
     """ Init "tabbed" preferences dialog. """
     self.prefCols = OptCols(
         [("S", _("Save")), ("page up", _("Tab Left")), ("page down", _("Tab Right")), ("esc", _("Cancel"))],
         self.handle_keys,
     )
     self.confCols = OptCols([("S", _("Save")), ("esc", _("Cancel"))], self.handle_keys)
Ejemplo n.º 18
0
    def __init__(self,networkID,parent):
        global wireless, daemon
        AdvancedSettingsDialog.__init__(self)
        self.wired = False
        
        self.networkid = networkID
        self.parent = parent
        global_settings_t = _('Use these settings for all networks sharing this essid')
        encryption_t = _('Use Encryption')
        autoconnect_t = _('Automatically connect to this network')
        
        self.global_settings_chkbox = urwid.CheckBox(global_settings_t)
        self.encryption_chkbox = urwid.CheckBox(encryption_t,on_state_change=self.encryption_toggle)
        self.encryption_combo = ComboBox(callback=self.combo_on_change)
        self.autoconnect_chkbox = urwid.CheckBox(autoconnect_t)
        self.pile_encrypt = None
        # _w is a Frame, _w.body is a ListBox, _w.body.body is the ListWalker :-)
        self._listbox.body.append(self.global_settings_chkbox)
        self._listbox.body.append(self.autoconnect_chkbox)
        self._listbox.body.append(self.encryption_chkbox)
        self._listbox.body.append(self.encryption_combo)
        self.encrypt_types = misc.LoadEncryptionMethods()
        self.set_values()

        title = _('Configuring preferences for wireless network "$A" ($B)').replace('$A',wireless.GetWirelessProperty(networkID,'essid')).replace('$B',wireless.GetWirelessProperty(networkID,'bssid'))
        self._w.header = urwid.Text(('header',title),align='right' )
Ejemplo n.º 19
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)
Ejemplo n.º 20
0
    def __init__(self):
        self.to_remove = dict(essid=[], bssid=[])

        header = urwid.AttrWrap(urwid.Text('  %20s %20s' % ('ESSID', 'BSSID')),
                                'listbar')
        title = urwid.Text(_('Please select the networks to forget'))
        l = [title, header]
        for entry in wireless.GetSavedWirelessNetworks():
            label = '%20s %20s'
            if entry[1] != 'None':
                label = label % (entry[0], entry[1])
                data = entry
            else:
                label = label % (entry[0], 'global')
                data = (entry[0], 'essid:' + entry[0])

            cb = urwid.CheckBox(label,
                                on_state_change=self.update_to_remove,
                                user_data=data)
            l.append(cb)
        body = urwid.ListBox(l)

        header = ('header', _('List of saved networks'))
        Dialog2.__init__(self, header, 15, 50, body)
        self.add_buttons([(_('Remove'), 1), (_('Cancel'), -1)])
        self.frame.set_focus('body')
Ejemplo n.º 21
0
Archivo: gui.py Proyecto: wmak/wicd
    def refresh_networks(self, widget=None, fresh=True, hidden=None):
        """ Refreshes the network list.

        If fresh=True, scans for wireless networks and displays the results.
        If a ethernet connection is available, or the user has chosen to,
        displays a Wired Network entry as well.
        If hidden isn't None, will scan for networks after running
        iwconfig <wireless interface> essid <hidden>.

        """
        if fresh:
            if hidden:
                wireless.SetHiddenNetworkESSID(noneToString(hidden))
            self.refresh_clicked()
            return
        print "refreshing..."
        self.network_list.set_sensitive(False)
        self._remove_items_from_vbox(self.network_list)
        self.wait_for_events()
        printLine = False  # We don't print a separator by default.
        if self._wired_showing:
            printLine = True
        num_networks = wireless.GetNumberOfNetworks()
        instruct_label = self.wTree.get_object("label_instructions")
        if num_networks > 0:
            skip_never_connect = not daemon.GetShowNeverConnect()
            instruct_label.show()
            for x in xrange(0, num_networks):
                if skip_never_connect and \
                  misc.to_bool(get_wireless_prop(x, 'never')):
                    continue
                if printLine:
                    sep = gtk.HSeparator()
                    self.network_list.pack_start(sep,
                                                 padding=10,
                                                 fill=False,
                                                 expand=False)
                    sep.show()
                else:
                    printLine = True
                tempnet = WirelessNetworkEntry(x)
                self.network_list.pack_start(tempnet, False, False)
                tempnet.connect_button.connect("clicked", self.connect,
                                               "wireless", x, tempnet)
                tempnet.disconnect_button.connect("clicked", self.disconnect,
                                                  "wireless", x, tempnet)
                tempnet.advanced_button.connect("clicked", self.edit_advanced,
                                                "wireless", x, tempnet)
        else:
            instruct_label.hide()
            if wireless.GetKillSwitchEnabled():
                label = gtk.Label(_('Wireless Kill Switch Enabled') + ".")
            else:
                label = gtk.Label(_('No wireless networks found.'))
            self.network_list.pack_start(label)
            label.show()
        self.update_connect_buttons(force_check=True)
        self.network_list.set_sensitive(True)
        self.refreshing = False
Ejemplo n.º 22
0
Archivo: gui.py Proyecto: mcagl/wicd
    def forget_network(self, widget=None):
        """
        Shows a dialog that lists saved wireless networks, and lets the user
        delete them.
        """
        wireless.ReloadConfig()
        dialog = gtk.Dialog(title = _('List of saved networks'),
                            flags = gtk.DIALOG_MODAL,
                            buttons=(gtk.STOCK_DELETE, 1, gtk.STOCK_OK, 2))
        dialog.set_has_separator(True)
        dialog.set_size_request(400, 200)

        networks = gtk.ListStore(str, str)
        for entry in wireless.GetSavedWirelessNetworks():
            if entry[1] != 'None':
                networks.append(entry)
            else:
                networks.append((entry[0], _('Global settings for this ESSID')))
        tree = gtk.TreeView(model=networks)
        tree.get_selection().set_mode(gtk.SELECTION_MULTIPLE)

        cell = gtk.CellRendererText()

        column = gtk.TreeViewColumn(_('ESSID'), cell, text = 0)
        tree.append_column(column)

        column = gtk.TreeViewColumn(_('BSSID'), cell, text = 1)
        tree.append_column(column)

        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scroll.add(tree)
        dialog.vbox.pack_start(scroll)
        dialog.vbox.set_spacing(5)
        dialog.show_all()
        response = dialog.run()
        if response == 1:
            model, pathlist = tree.get_selection().get_selected_rows()
            to_remove = dict(essid=[], bssid=[])
            if pathlist:
                for row in pathlist:
                    iter = model.get_iter(path=row)
                    to_remove['essid'].append(misc.noneToString(model.get_value(iter, 0)))
                    to_remove['bssid'].append(model.get_value(iter, 1))

                confirm = gtk.MessageDialog(
                        flags = gtk.DIALOG_MODAL,
                        type = gtk.MESSAGE_INFO,
                        buttons = gtk.BUTTONS_YES_NO,
                        message_format = _('Are you sure you want to discard' +
                            ' settings for the selected networks?')
                    )
                confirm.format_secondary_text('\n'.join(to_remove['essid']))
                response = confirm.run()
                if response == gtk.RESPONSE_YES:
                    map(wireless.DeleteWirelessNetwork, to_remove['bssid'])
                    wireless.ReloadConfig()
                confirm.destroy()
        dialog.destroy()
Ejemplo n.º 23
0
 def set_encryption(self, on, ttype):
     """ Set the encryption value for the WirelessNetworkEntry. """
     if on and ttype:
         self.lbl_encryption.set_label(str(ttype))
     if on and not ttype: 
         self.lbl_encryption.set_label(_('Secured'))
     if not on:
         self.lbl_encryption.set_label(_('Unsecured'))
Ejemplo n.º 24
0
 def raise_hidden_network_dialog(self):
     dialog = InputDialog(('header',_('Select Hidden Network ESSID')),7,30,_('Scan'))
     exitcode,hidden = dialog.run(ui,self.frame)
     if exitcode != -1:
         # That dialog will sit there for a while if I don't get rid of it
         self.update_ui()
         wireless.SetHiddenNetworkESSID(misc.noneToString(hidden))
         wireless.Scan(False)
     wireless.SetHiddenNetworkESSID("")
Ejemplo n.º 25
0
Archivo: gui.py Proyecto: mcagl/wicd
 def switch_rfkill(self, widget=None):
     """ Switches wifi card on/off. """
     wireless.SwitchRfKill()
     if wireless.GetRfKillEnabled():
         self.rfkill_button.set_stock_id(gtk.STOCK_MEDIA_PLAY)
         self.rfkill_button.set_label(_('Switch On Wi-Fi'))
     else:
         self.rfkill_button.set_stock_id(gtk.STOCK_MEDIA_STOP)
         self.rfkill_button.set_label(_('Switch Off Wi-Fi'))
Ejemplo n.º 26
0
Archivo: gui.py Proyecto: wmak/wicd
 def switch_rfkill(self, widget=None):
     """ Switches wifi card on/off. """
     wireless.SwitchRfKill()
     if wireless.GetRfKillEnabled():
         self.rfkill_button.set_stock_id(gtk.STOCK_MEDIA_PLAY)
         self.rfkill_button.set_label(_('Switch On Wi-Fi'))
     else:
         self.rfkill_button.set_stock_id(gtk.STOCK_MEDIA_STOP)
         self.rfkill_button.set_label(_('Switch Off Wi-Fi'))
Ejemplo n.º 27
0
    def __init__(self, text, height, width, ok_name=_('OK'), edit_text=''):
        self.edit = urwid.Edit(wrap='clip', edit_text=edit_text)
        body = urwid.ListBox([self.edit])
        body = urwid.AttrWrap(body, 'editbx', 'editfc')

        Dialog2.__init__(self, text, height, width, body)

        self.frame.set_focus('body')
        self.add_buttons([(ok_name, 0), (_('Cancel'), -1)])
Ejemplo n.º 28
0
    def __init__(self):
        """ Initializes and runs the wired profile chooser. """
        # Import and init WiredNetworkEntry to steal some of the
        # functions and widgets it uses.
        wired_net_entry = WiredNetworkEntry()

        dialog = gtk.Dialog(
            title=_('Wired connection detected'),
            flags=gtk.DIALOG_MODAL,
            buttons=(gtk.STOCK_CONNECT, 1, gtk.STOCK_CANCEL, 2)
        )
        dialog.set_has_separator(False)
        dialog.set_size_request(400, 150)
        instruct_label = gtk.Label(
            _('Select or create a wired profile to connect with') + ':\n'
        )
        stoppopcheckbox = gtk.CheckButton(
            _('Stop Showing Autoconnect pop-up temporarily')
        )

        wired_net_entry.is_full_gui = False
        instruct_label.set_alignment(0, 0)
        stoppopcheckbox.set_active(False)

        # Remove widgets that were added to the normal WiredNetworkEntry
        # so that they can be added to the pop-up wizard.
        wired_net_entry.vbox_top.remove(wired_net_entry.hbox_temp)
        wired_net_entry.vbox_top.remove(wired_net_entry.profile_help)

        # pylint: disable-msg=E1101
        dialog.vbox.pack_start(instruct_label, fill=False, expand=False)
        # pylint: disable-msg=E1101
        dialog.vbox.pack_start(wired_net_entry.profile_help, False, False)
        # pylint: disable-msg=E1101
        dialog.vbox.pack_start(wired_net_entry.hbox_temp, False, False)
        # pylint: disable-msg=E1101
        dialog.vbox.pack_start(stoppopcheckbox, False, False)
        dialog.show_all()

        wired_profiles = wired_net_entry.combo_profile_names
        wired_net_entry.profile_help.hide()
        if wired_net_entry.profile_list is not None:
            wired_profiles.set_active(0)
            print "wired profiles found"
        else:
            print "no wired profiles found"
            wired_net_entry.profile_help.show()

        response = dialog.run()
        if response == 1:
            print 'reading profile ', wired_profiles.get_active_text()
            wired.ReadWiredNetworkProfile(wired_profiles.get_active_text())
            wired.ConnectWired()
        else:
            if stoppopcheckbox.get_active():
                daemon.SetForcedDisconnect(True)
        dialog.destroy()
Ejemplo n.º 29
0
    def __init__(self, text, height, width, ok_name=_('OK'), edit_text=''):
        self.edit = urwid.Edit(wrap='clip', edit_text=edit_text)
        body = urwid.ListBox([self.edit])
        body = urwid.AttrWrap(body, 'editbx', 'editfc')

        Dialog2.__init__(self, text, height, width, body)

        self.frame.set_focus('body')
        self.add_buttons([(ok_name, 0), (_('Cancel'), -1)])
Ejemplo n.º 30
0
def status_changed_cb(state, details):
    # Nothing has changed
    if state == this.prev_state:
        return

    if state == misc.CONNECTING:
        wired_connecting = wired.CheckIfWiredConnecting()
        wireless_connecting = wireless.CheckIfWirelessConnecting()
        stat = _('Connecting')
        if wireless_connecting:
            iwconfig = wireless.GetIwconfig()
            essid = wireless.GetCurrentNetwork(iwconfig)
            snooty.simple_notify('wicd', essid, stat)
        if wired_connecting:
            snooty.simple_notify('wicd', _('Wired Network'), stat)

    elif state in (misc.WIRELESS, misc.WIRED) and this.prev_state == misc.CONNECTING:
        wired_ip = wired.GetWiredIP('')
        iwconfig = wireless.GetIwconfig()
        network = wireless.GetCurrentNetwork(iwconfig)
        wireless_ip = wireless.GetWirelessIP('')

        if wired.CheckPluggedIn() and wired_ip:
            snooty.simple_notify('wicd', _('Wired Network'), _('Connected'))
        elif network and wireless_ip:
            snooty.simple_notify('wicd', network, _('Connected'))

    elif state == misc.NOT_CONNECTED and this.prev_state in (misc.WIRELESS, misc.WIRED):
        if this.prev_state == misc.WIRED:
            snooty.simple_notify('wicd', _('Wired Network'), _('Not connected'))
        else: # this.prev_state == misc.WIRELESS
            snooty.simple_notify('wicd', _('Wireless Network'), _('Not connected'))

    this.prev_state = state
Ejemplo n.º 31
0
    def __init__(self):
        essid_t = _('ESSID')
        ip_t = _('IP')
        channel_t = _('Channel')
        key_t = "    " + _('Key')
        use_ics_t = _('Activate Internet Connection Sharing')
        use_encrypt_t = _('Use Encryption (WEP only)')

        self.essid_edit = DynEdit(essid_t)
        self.ip_edit = DynEdit(ip_t)
        self.channel_edit = DynIntEdit(channel_t)
        self.key_edit = DynEdit(key_t, sensitive=False)

        self.use_ics_chkb = urwid.CheckBox(use_ics_t)
        self.use_encrypt_chkb = urwid.CheckBox(
            use_encrypt_t, on_state_change=self.encrypt_callback)

        blank = urwid.Text('')

        # Set defaults
        self.essid_edit.set_edit_text("My_Adhoc_Network")
        self.ip_edit.set_edit_text("169.254.12.10")
        self.channel_edit.set_edit_text("3")

        l = [
            self.essid_edit, self.ip_edit, self.channel_edit, blank,
            self.use_ics_chkb, self.use_encrypt_chkb, self.key_edit
        ]
        body = urwid.ListBox(l)

        header = ('header', _('Create an Ad-Hoc Network'))
        Dialog2.__init__(self, header, 15, 50, body)
        self.add_buttons([(_('OK'), 1), (_('Cancel'), -1)])
        self.frame.set_focus('body')
Ejemplo n.º 32
0
    def __init__(self):
        essid_t = _('ESSID')
        ip_t = _('IP')
        channel_t = _('Channel')
        key_t = "    " + _('Key')
        use_ics_t = _('Activate Internet Connection Sharing')
        use_encrypt_t = _('Use Encryption (WEP only)')

        self.essid_edit = DynEdit(essid_t)
        self.ip_edit = DynEdit(ip_t)
        self.channel_edit = DynIntEdit(channel_t)
        self.key_edit = DynEdit(key_t, sensitive=False)

        self.use_ics_chkb = urwid.CheckBox(use_ics_t)
        self.use_encrypt_chkb = urwid.CheckBox(use_encrypt_t,
                on_state_change=self.encrypt_callback)

        blank = urwid.Text('')

        # Set defaults
        self.essid_edit.set_edit_text("My_Adhoc_Network")
        self.ip_edit.set_edit_text("169.254.12.10")
        self.channel_edit.set_edit_text("3")

        l = [self.essid_edit, self.ip_edit, self.channel_edit, blank,
            self.use_ics_chkb, self.use_encrypt_chkb, self.key_edit]
        body = urwid.ListBox(l)

        header = ('header', _('Create an Ad-Hoc Network'))
        Dialog2.__init__(self, header, 15, 50, body)
        self.add_buttons([(_('OK'), 1), (_('Cancel'), -1)])
        self.frame.set_focus('body')
Ejemplo n.º 33
0
 def raise_hidden_network_dialog(self):
     """ Show hidden network dialog. """
     dialog = InputDialog(('header', _('Select Hidden Network ESSID')), 7,
                          30, _('Scan'))
     exitcode, hidden = dialog.run(ui, self.frame)
     if exitcode != -1:
         # That dialog will sit there for a while if I don't get rid of it
         self.update_ui()
         wireless.SetHiddenNetworkESSID(misc.noneToString(hidden))
         wireless.Scan(False)
     wireless.SetHiddenNetworkESSID("")
Ejemplo n.º 34
0
Archivo: gui.py Proyecto: wmak/wicd
    def __init__(self):
        """ Initializes and runs the wired profile chooser. """
        # Import and init WiredNetworkEntry to steal some of the
        # functions and widgets it uses.
        wired_net_entry = WiredNetworkEntry()

        dialog = gtk.Dialog(title=_('Wired connection detected'),
                            flags=gtk.DIALOG_MODAL,
                            buttons=(gtk.STOCK_CONNECT, 1, gtk.STOCK_CANCEL,
                                     2))
        dialog.set_has_separator(False)
        dialog.set_size_request(400, 150)
        instruct_label = gtk.Label(
            _('Select or create a wired profile to connect with') + ':\n')
        stoppopcheckbox = gtk.CheckButton(
            _('Stop Showing Autoconnect pop-up temporarily'))

        wired_net_entry.is_full_gui = False
        instruct_label.set_alignment(0, 0)
        stoppopcheckbox.set_active(False)

        # Remove widgets that were added to the normal WiredNetworkEntry
        # so that they can be added to the pop-up wizard.
        wired_net_entry.vbox_top.remove(wired_net_entry.hbox_temp)
        wired_net_entry.vbox_top.remove(wired_net_entry.profile_help)

        # pylint: disable-msg=E1101
        dialog.vbox.pack_start(instruct_label, fill=False, expand=False)
        # pylint: disable-msg=E1101
        dialog.vbox.pack_start(wired_net_entry.profile_help, False, False)
        # pylint: disable-msg=E1101
        dialog.vbox.pack_start(wired_net_entry.hbox_temp, False, False)
        # pylint: disable-msg=E1101
        dialog.vbox.pack_start(stoppopcheckbox, False, False)
        dialog.show_all()

        wired_profiles = wired_net_entry.combo_profile_names
        wired_net_entry.profile_help.hide()
        if wired_net_entry.profile_list is not None:
            wired_profiles.set_active(0)
            print "wired profiles found"
        else:
            print "no wired profiles found"
            wired_net_entry.profile_help.show()

        response = dialog.run()
        if response == 1:
            print 'reading profile ', wired_profiles.get_active_text()
            wired.ReadWiredNetworkProfile(wired_profiles.get_active_text())
            wired.ConnectWired()
        else:
            if stoppopcheckbox.get_active():
                daemon.SetForcedDisconnect(True)
        dialog.destroy()
Ejemplo n.º 35
0
        def set_wired_state(self, info):
            """ Sets the icon info for a wired state. """
            wired_ip = info[0]
            self.network_addr = str(info[0])
            self.network_type = "wired"
            self.tr.set_from_name("wired")
            # status_string = _('Connected to wired network (IP: $A)'). \
            #    replace('$A',wired_ip)
            # self.tr.set_tooltip(status_string)
            self._show_notification(_("Wired Network"), _("Connection established"), "network-wired")

            self.update_tooltip()
Ejemplo n.º 36
0
 def set_not_connected_state(self, info=None):
     """ Set the icon info for the not connected state. """
     self.tr.set_from_name("no-signal")
     if not DBUS_AVAIL:
         status = _("Wicd daemon unreachable")
     elif wireless.GetKillSwitchEnabled():
         status = _("Not connected") + " (" + _("Wireless Kill Switch Enabled") + ")"
     else:
         status = _("Not connected")
     # self.tr.set_tooltip(status)
     self._show_notification(_("Disconnected"), None, "stop")
     self.update_tooltip()
Ejemplo n.º 37
0
    def __init__(self,name):
        global wired, daemon
        AdvancedSettingsDialog.__init__(self)
        self.set_default = urwid.CheckBox(_('Use as default profile (overwrites any previous default)'))
        #self.cur_default = 
        # Add widgets to listbox
        self._w.body.body.append(self.set_default)
        
        self.prof_name = name
        title = _('Configuring preferences for wired profile "$A"').replace('$A',self.prof_name)
        self._w.header = urwid.Text( ('header',title),align='right' )

        self.set_values()
Ejemplo n.º 38
0
 def set_not_connected_state(self, info=None):
     """ Set the icon info for the not connected state. """
     self.tr.set_from_file(wpath.images + "no-signal.png")
     if not DBUS_AVAIL:
         status = _('Wicd daemon unreachable')
     elif wireless.GetKillSwitchEnabled():
         status = (_('Not connected') + " (" + 
                  _('Wireless Kill Switch Enabled') + ")")
     else:
         status = _('Not connected')
     # self.tr.set_tooltip(status)
     self._show_notification(_('Disconnected'), None, 'stop')
     self.update_tooltip()
Ejemplo n.º 39
0
 def set_not_connected_state(self, info=None):
     """ Set the icon info for the not connected state. """
     self.tr.set_from_name('no-signal')
     if not DBUS_AVAIL:
         status = _('Wicd daemon unreachable')
     elif wireless.GetKillSwitchEnabled():
         status = (_('Not connected') + " (" +
                   _('Wireless Kill Switch Enabled') + ")")
     else:
         status = _('Not connected')
     # self.tr.set_tooltip(status)
     self._show_notification(_('Disconnected'), None, 'stop')
     self.update_tooltip()
Ejemplo n.º 40
0
def main (argv):
    """ Runs the script configuration dialog. """
    if len(argv) < 2:
        print('Network id to configure is missing, aborting.')
        sys.exit(1)

    network = argv[1]
    network_type = argv[2]

    script_info = get_script_info(network, network_type)

    gladefile = os.path.join(wpath.gtk, "wicd.ui")
    wTree = gtk.Builder()
    wTree.set_translation_domain('wicd')
    wTree.add_from_file(gladefile)
    dialog = wTree.get_object("configure_script_dialog")
    wTree.get_object("pre_label").set_label(_('Pre-connection Script') + ":")
    wTree.get_object("post_label").set_label(_('Post-connection Script') + ":")
    wTree.get_object("pre_disconnect_label").\
        set_label(_('Pre-disconnection Script') + ":")
    wTree.get_object("post_disconnect_label").\
        set_label(_('Post-disconnection Script') + ":")
    wTree.get_object("window1").hide()

    pre_entry = wTree.get_object("pre_entry")
    post_entry = wTree.get_object("post_entry")
    pre_disconnect_entry = wTree.get_object("pre_disconnect_entry")
    post_disconnect_entry = wTree.get_object("post_disconnect_entry")

    pre_entry.set_text(none_to_blank(script_info.get("pre_entry")))
    post_entry.set_text(none_to_blank(script_info.get("post_entry")))
    pre_disconnect_entry.set_text(
        none_to_blank(script_info.get("pre_disconnect_entry"))
    )
    post_disconnect_entry.set_text(
        none_to_blank(script_info.get("post_disconnect_entry"))
    )

    dialog.show_all()

    result = dialog.run()
    if result == 1:
        script_info["pre_entry"] = blank_to_none(pre_entry.get_text())
        script_info["post_entry"] = blank_to_none(post_entry.get_text())
        script_info["pre_disconnect_entry"] = \
            blank_to_none(pre_disconnect_entry.get_text())
        script_info["post_disconnect_entry"] = \
            blank_to_none(post_disconnect_entry.get_text())
        write_scripts(network, network_type, script_info)
    dialog.destroy()
Ejemplo n.º 41
0
        def set_wired_state(self, info):
            """ Sets the icon info for a wired state. """
            wired_ip = info[0]
            self.network_addr = str(info[0])
            self.network_type = "wired"
            self.tr.set_from_name('wired')
            #status_string = _('Connected to wired network (IP: $A)'). \
            #    replace('$A',wired_ip)
            #self.tr.set_tooltip(status_string)
            self._show_notification(_('Wired Network'),
                                    _('Connection established'),
                                    'network-wired')

            self.update_tooltip()
Ejemplo n.º 42
0
def main (argv):
    """ Runs the script configuration dialog. """
    if len(argv) < 2:
        print('Network id to configure is missing, aborting.')
        sys.exit(1)

    network = argv[1]
    network_type = argv[2]

    script_info = get_script_info(network, network_type)

    gladefile = os.path.join(wpath.gtk, "wicd.ui")
    wTree = gtk.Builder()
    wTree.set_translation_domain('wicd')
    wTree.add_from_file(gladefile)
    dialog = wTree.get_object("configure_script_dialog")
    wTree.get_object("pre_label").set_label(_('Pre-connection Script') + ":")
    wTree.get_object("post_label").set_label(_('Post-connection Script') + ":")
    wTree.get_object("pre_disconnect_label").\
        set_label(_('Pre-disconnection Script') + ":")
    wTree.get_object("post_disconnect_label").\
        set_label(_('Post-disconnection Script') + ":")
    wTree.get_object("window1").hide()

    pre_entry = wTree.get_object("pre_entry")
    post_entry = wTree.get_object("post_entry")
    pre_disconnect_entry = wTree.get_object("pre_disconnect_entry")
    post_disconnect_entry = wTree.get_object("post_disconnect_entry")

    pre_entry.set_text(none_to_blank(script_info.get("pre_entry")))
    post_entry.set_text(none_to_blank(script_info.get("post_entry")))
    pre_disconnect_entry.set_text(
        none_to_blank(script_info.get("pre_disconnect_entry"))
    )
    post_disconnect_entry.set_text(
        none_to_blank(script_info.get("post_disconnect_entry"))
    )

    dialog.show_all()

    result = dialog.run()
    if result == 1:
        script_info["pre_entry"] = blank_to_none(pre_entry.get_text())
        script_info["post_entry"] = blank_to_none(post_entry.get_text())
        script_info["pre_disconnect_entry"] = \
            blank_to_none(pre_disconnect_entry.get_text())
        script_info["post_disconnect_entry"] = \
            blank_to_none(post_disconnect_entry.get_text())
        write_scripts(network, network_type, script_info)
    dialog.destroy()
Ejemplo n.º 43
0
 def set_wired_state(self, info):
     """ Sets the icon info for a wired state. """
     wired_ip = info[0]
     self.network_addr = str(info[0])
     self.network_type = "wired"
     self.tr.set_from_file(os.path.join(wpath.images, "wired.png"))
     # status_string = _('Connected to wired network (IP: $A)').replace('$A',
     #wired_ip)
     # self.tr.set_tooltip(status_string)
     self._show_notification(_('Wired Network'),
                             _('Connection established'),
                             'network-wired')
     
     self.update_tooltip()
Ejemplo n.º 44
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
Ejemplo n.º 45
0
Archivo: gui.py Proyecto: wmak/wicd
 def set_connecting_state(self, info):
     """ Set connecting state. """
     if not self.connecting:
         if self.update_cb:
             gobject.source_remove(self.update_cb)
         self.update_cb = misc.timeout_add(500,
                                           self.update_statusbar,
                                           milli=True)
         self.connecting = True
     if not self.pulse_active:
         self.pulse_active = True
         misc.timeout_add(100, self.pulse_progress_bar, milli=True)
         gobject.idle_add(self.all_network_list.set_sensitive, False)
         gobject.idle_add(self.status_area.show_all)
     if self.statusID:
         gobject.idle_add(self.status_bar.remove_message, 1, self.statusID)
     if info[0] == "wireless":
         stat = wireless.CheckWirelessConnectingMessage()
         gobject.idle_add(self.set_status, "%s: %s" % (info[1], stat))
     elif info[0] == "wired":
         gobject.idle_add(
             self.set_status,
             _('Wired Network') + ': ' +
             wired.CheckWiredConnectingMessage())
     return True
Ejemplo n.º 46
0
Archivo: gui.py Proyecto: wmak/wicd
 def set_not_connected_state(self, info):
     """ Set not connected state. """
     if self.connecting:
         # Adjust our state from connecting->not-connected.
         self._set_not_connecting_state()
     self.set_status(_('Not connected'))
     return True
Ejemplo n.º 47
0
        def set_wireless_state(self, info):
            """ Sets the icon info for a wireless state. """
            lock = ''
            wireless_ip = info[0]
            self.network = info[1]
            strength = info[2]
            cur_net_id = int(info[3])
            sig_string = daemon.FormatSignalForPrinting(str(strength))
            self.network_type = "wireless"
            self.network_addr = str(info[0])
            self.network_name = info[1]
            self.network_str = sig_string
            self.network_br = info[4]
            self.set_signal_image(int(info[2]), lock)

            if wireless.GetWirelessProperty(cur_net_id, "encryption"):
                lock = "-lock"
            # status_string = (_('Connected to $A at $B (IP: $C)')
            #.replace('$A', self.network)
            #                    .replace('$B', sig_string)
            #                    .replace('$C', str(wireless_ip)))
            #self.tr.set_tooltip(status_string)
            self.set_signal_image(int(strength), lock)
            self._show_notification(self.network,
                                    _('Connection established'),
                                    'network-wireless')

            self.update_tooltip()
Ejemplo n.º 48
0
    def update_status(self):
        """ Update the footer / statusbar. """
        wired_connecting = wired.CheckIfWiredConnecting()
        wireless_connecting = wireless.CheckIfWirelessConnecting()
        self.connecting = wired_connecting or wireless_connecting

        fast = not daemon.NeedsExternalCalls()
        if self.connecting:
            if not self.conn_status:
                self.conn_status = True
                gobject.timeout_add(250, self.set_connecting_status, fast)
            return True
        else:
            if check_for_wired(wired.GetWiredIP(''), self.set_status):
                return True
            if not fast:
                iwconfig = wireless.GetIwconfig()
            else:
                iwconfig = ''
            if check_for_wireless(iwconfig, wireless.GetWirelessIP(""),
                                  self.set_status):
                return True
            else:
                self.set_status(_('Not connected'))
                self.update_ui()
                return True
Ejemplo n.º 49
0
Archivo: gui.py Proyecto: wmak/wicd
def setup_dbus(force=True):
    """ Initialize DBus. """
    global bus, daemon, wireless, wired, DBUS_AVAIL
    try:
        dbusmanager.connect_to_dbus()
    except DBusException:
        if force:
            print "Can't connect to the daemon, ' + \
                'trying to start it automatically..."

            if not misc.PromptToStartDaemon():
                print "Failed to find a graphical sudo program, ' + \
                    'cannot continue."

                return False
            try:
                dbusmanager.connect_to_dbus()
            except DBusException:
                error(
                    None,
                    _("Could not connect to wicd's D-Bus interface. "
                      "Check the wicd log for error messages."))
                return False
        else:
            return False
    prefs.setup_dbus()
    netentry.setup_dbus()
    bus = dbusmanager.get_bus()
    dbus_ifaces = dbusmanager.get_dbus_ifaces()
    daemon = dbus_ifaces['daemon']
    wireless = dbus_ifaces['wireless']
    wired = dbus_ifaces['wired']
    DBUS_AVAIL = True

    return True
Ejemplo n.º 50
0
Archivo: gui.py Proyecto: wmak/wicd
    def refresh_clicked(self, widget=None):
        """ Kick off an asynchronous wireless scan. """
        if not DBUS_AVAIL or self.connecting:
            return
        self.refreshing = True

        # Remove stuff already in there.
        self._remove_items_from_vbox(self.wired_network_box)
        self._remove_items_from_vbox(self.network_list)
        label = gtk.Label("%s..." % _('Scanning'))
        self.network_list.pack_start(label)
        self.network_list.show_all()
        if wired.CheckPluggedIn() or daemon.GetAlwaysShowWiredInterface():
            printLine = True  # In this case we print a separator.
            wirednet = WiredNetworkEntry()
            self.wired_network_box.pack_start(wirednet, False, False)
            wirednet.connect_button.connect("clicked", self.connect, "wired",
                                            0, wirednet)
            wirednet.disconnect_button.connect("clicked", self.disconnect,
                                               "wired", 0, wirednet)
            wirednet.advanced_button.connect("clicked", self.edit_advanced,
                                             "wired", 0, wirednet)
            state, x = daemon.GetConnectionStatus()
            wirednet.update_connect_button(state)

            self._wired_showing = True
        else:
            self._wired_showing = False

        wireless.Scan(False)
Ejemplo n.º 51
0
def check_for_wired(wired_ip, set_status):
    """ Determine if wired is active, and if yes, set the status. """
    if wired_ip and wired.CheckPluggedIn():
        set_status(_("Connected to wired network (IP: $A)").replace("$A", wired_ip))
        return True
    else:
        return False
Ejemplo n.º 52
0
    def update_status(self):
        """ Update the footer / statusbar. """
        wired_connecting = wired.CheckIfWiredConnecting()
        wireless_connecting = wireless.CheckIfWirelessConnecting()
        self.connecting = wired_connecting or wireless_connecting

        fast = not daemon.NeedsExternalCalls()
        if self.connecting:
            if not self.conn_status:
                self.conn_status = True
                gobject.timeout_add(250, self.set_connecting_status, fast)
            return True
        else:
            if check_for_wired(wired.GetWiredIP(''), self.set_status):
                return True
            if not fast:
                iwconfig = wireless.GetIwconfig()
            else:
                iwconfig = ''
            if check_for_wireless(iwconfig, wireless.GetWirelessIP(""),
                    self.set_status):
                return True
            else:
                self.set_status(_('Not connected'))
                self.update_ui()
                return True
Ejemplo n.º 53
0
    def update_status(self, loop=None, user_data=None):
        """ Update the footer / statusbar. """
        if loop:
            loop.set_alarm_in(2, self.update_status)
        wired_connecting = wired.CheckIfWiredConnecting()
        wireless_connecting = wireless.CheckIfWirelessConnecting()
        self.connecting = wired_connecting or wireless_connecting

        fast = not daemon.NeedsExternalCalls()
        if self.connecting:
            if not self.conn_status:
                self.conn_status = True
                if loop:
                    loop.set_alarm_in(.25, self.set_connecting_status, fast)
            return True
        else:
            if check_for_wired(wired.GetWiredIP(''), self.set_status):
                return True
            if not fast:
                iwconfig = wireless.GetIwconfig()
            else:
                iwconfig = ''
            if check_for_wireless(iwconfig, wireless.GetWirelessIP(""),
                                  self.set_status):
                return True
            else:
                self.set_status(_('Not connected'))
                self.update_ui()
                return True
Ejemplo n.º 54
0
        def set_wireless_state(self, info):
            """ Sets the icon info for a wireless state. """
            lock = ''
            wireless_ip = info[0]
            self.network = info[1]
            strength = info[2]
            cur_net_id = int(info[3])
            sig_string = daemon.FormatSignalForPrinting(str(strength))
            self.network_type = "wireless"
            self.network_addr = str(info[0])
            self.network_name = info[1]
            self.network_str = sig_string
            self.network_br = info[4]
            self.set_signal_image(int(info[2]), lock)

            if wireless.GetWirelessProperty(cur_net_id, "encryption"):
                lock = "-lock"
            # status_string = (_('Connected to $A at $B (IP: $C)')
            #.replace('$A', self.network)
            #                    .replace('$B', sig_string)
            #                    .replace('$C', str(wireless_ip)))
            #self.tr.set_tooltip(status_string)
            self.set_signal_image(int(strength), lock)
            self._show_notification(self.network, _('Connection established'),
                                    'network-wireless')

            self.update_tooltip()
Ejemplo n.º 55
0
def setup_dbus(force=True):
    """ Initialize DBus. """
    global daemon, wireless, wired, DBUS_AVAIL, lost_dbus_id
    print("Connecting to daemon...")
    try:
        dbusmanager.connect_to_dbus()
    except DBusException:
        if force:
            print(("Can't connect to the daemon, trying to start it " + \
                "automatically..."))
            misc.PromptToStartDaemon()
            try:
                dbusmanager.connect_to_dbus()
            except DBusException:
                error(
                    None,
                    _("Could not connect to wicd's D-Bus interface. Check "
                      "the wicd log for error messages."))
                return False
        else:
            return False

    if lost_dbus_id:
        gobject.source_remove(lost_dbus_id)
        lost_dbus_id = None
    dbus_ifaces = dbusmanager.get_dbus_ifaces()
    daemon = dbus_ifaces['daemon']
    wireless = dbus_ifaces['wireless']
    wired = dbus_ifaces['wired']
    DBUS_AVAIL = True
    print("Connected.")
    return True
Ejemplo n.º 56
0
def check_for_wired(wired_ip, set_status):
    """ Determine if wired is active, and if yes, set the status. """
    if wired_ip and wired.CheckPluggedIn():
        set_status(
            _('Connected to wired network (IP: $A)').replace('$A', wired_ip))
        return True
    else:
        return False
Ejemplo n.º 57
0
Archivo: gui.py Proyecto: wmak/wicd
 def set_wired_state(self, info):
     """ Set wired state. """
     if self.connecting:
         # Adjust our state from connecting->connected.
         self._set_not_connecting_state()
     self.set_status(
         _('Connected to wired network (IP: $A)').replace('$A', info[0]))
     return True
Ejemplo n.º 58
0
Archivo: gui.py Proyecto: wmak/wicd
    def save_settings(self, nettype, networkid, networkentry):
        """ Verifies and saves the settings for the network entry. """
        entry = networkentry.advanced_dialog
        opt_entlist = []
        req_entlist = []

        # First make sure all the Addresses entered are valid.
        if entry.chkbox_static_ip.get_active():
            req_entlist = [entry.txt_ip, entry.txt_netmask]
            opt_entlist = [entry.txt_gateway]

        if entry.chkbox_static_dns.get_active() and \
           not entry.chkbox_global_dns.get_active():
            for ent in [entry.txt_dns_1, entry.txt_dns_2, entry.txt_dns_3]:
                opt_entlist.append(ent)

        # Required entries.
        for lblent in req_entlist:
            lblent.set_text(lblent.get_text().strip())
            if not misc.IsValidIP(lblent.get_text()):
                error(
                    self.window,
                    _('Invalid address in $A entry.').replace(
                        '$A', lblent.label.get_label()))
                return False

        # Optional entries, only check for validity if they're entered.
        for lblent in opt_entlist:
            lblent.set_text(lblent.get_text().strip())
            if lblent.get_text() and not misc.IsValidIP(lblent.get_text()):
                error(
                    self.window,
                    _('Invalid address in $A entry.').replace(
                        '$A', lblent.label.get_label()))
                return False

        # Now save the settings.
        if nettype == "wireless":
            if not networkentry.save_wireless_settings(networkid):
                return False

        elif nettype == "wired":
            if not networkentry.save_wired_settings():
                return False

        return True
Ejemplo n.º 59
0
        def __init__(self, parent):
            self.list = []
            self.label = None
            self.data = None

            menu = """
                    <ui>
                        <menubar name="Menubar">
                            <menu action="Menu">
                                <menu action="Connect">
                                </menu>
                                <separator/>
                                <menuitem action="Info"/>
                                <menuitem action="Quit"/>
                            </menu>
                        </menubar>
                    </ui>
            """
            actions = [
                ('Menu', None, 'Menu'),
                ('Connect', gtk.STOCK_CONNECT, _('Connect')),
                ('Info', gtk.STOCK_INFO, _('_Connection Info'), None,
                 _('Information about the current connection'),
                 self.on_conn_info),
                ('Quit', gtk.STOCK_QUIT, _('_Quit'), None,
                 _('Quit wicd-tray-icon'), self.on_quit),
            ]
            actg = gtk.ActionGroup('Actions')
            actg.add_actions(actions)
            self.manager = gtk.UIManager()
            self.manager.insert_action_group(actg, 0)
            self.manager.add_ui_from_string(menu)
            self.menu = (
                self.manager.get_widget('/Menubar/Menu/Quit').props.parent)
            self.gui_win = None
            self.current_icon_name = None
            self._is_scanning = False
            net_menuitem = self.manager.get_widget("/Menubar/Menu/Connect/")
            if not USE_APP_INDICATOR:
                net_menuitem.connect("activate", self.on_net_menu_activate)

            self.parent = parent
            self.time = 2  # Time between updates
            self.cont = 'Stop'
            self.conn_info_txt = ''
Ejemplo n.º 60
0
Archivo: gui.py Proyecto: wmak/wicd
 def set_wireless_state(self, info):
     """ Set wireless state. """
     if self.connecting:
         # Adjust our state from connecting->connected.
         self._set_not_connecting_state()
     self.set_status(
         _('Connected to $A at $B (IP: $C)').replace('$A', info[1]).replace(
             '$B', daemon.FormatSignalForPrinting(info[2])).replace(
                 '$C', info[0]))
     return True