Example #1
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)
Example #2
0
    def set_values(self):
        self.ip_edit.set_edit_text(self.format_entry("ip"))
        self.netmask_edit.set_edit_text(self.format_entry("netmask"))
        self.gateway_edit.set_edit_text(self.format_entry("gateway"))

        self.global_dns_cb.set_state(bool(wired.GetWiredProperty('use_global_dns')))
        self.static_dns_cb.set_state(bool(wired.GetWiredProperty('use_static_dns')))
        
        # Set static ip checkbox.  Forgot to do this the first time.
        if stringToNone(self.ip_edit.get_edit_text()):
            self.static_ip_cb.set_state(True)
        self.dns1.set_edit_text(self.format_entry( "dns1"))
        self.dns2.set_edit_text(self.format_entry( "dns2"))
        self.dns3.set_edit_text(self.format_entry( "dns3"))
        self.dns_dom_edit.set_edit_text(self.format_entry("dns_domain"))
        self.search_dom_edit.set_edit_text(self.format_entry("search_domain"))

        self.set_default.set_state(to_bool(wired.GetWiredProperty("default")))

        dhcphname = wired.GetWiredProperty("dhcphostname")
        if dhcphname is None:
            dhcphname = os.uname()[1]

        self.use_dhcp_h.set_state(bool(wired.GetWiredProperty('usedhcphostname')))
        self.dhcp_h.set_sensitive(self.use_dhcp_h.get_state())
        self.dhcp_h.set_edit_text(unicode(dhcphname))
Example #3
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
Example #4
0
    def set_values(self):
        self.ip_edit.set_edit_text(self.format_entry("ip"))
        self.netmask_edit.set_edit_text(self.format_entry("netmask"))
        self.gateway_edit.set_edit_text(self.format_entry("gateway"))

        self.global_dns_cb.set_state(bool(wired.GetWiredProperty('use_global_dns')))
        self.static_dns_cb.set_state(bool(wired.GetWiredProperty('use_static_dns')))
        
        # Set static ip checkbox.  Forgot to do this the first time.
        if stringToNone(self.ip_edit.get_edit_text()):
            self.static_ip_cb.set_state(True)
        self.dns1.set_edit_text(self.format_entry( "dns1"))
        self.dns2.set_edit_text(self.format_entry( "dns2"))
        self.dns3.set_edit_text(self.format_entry( "dns3"))
        self.dns_dom_edit.set_edit_text(self.format_entry("dns_domain"))
        self.search_dom_edit.set_edit_text(self.format_entry("search_domain"))

        self.set_default.set_state(to_bool(wired.GetWiredProperty("default")))

        dhcphname = wired.GetWiredProperty("dhcphostname")
        if dhcphname is None:
            dhcphname = os.uname()[1]

        self.use_dhcp_h.set_state(bool(wired.GetWiredProperty('usedhcphostname')))
        self.dhcp_h.set_sensitive(self.use_dhcp_h.get_state())
        self.dhcp_h.set_edit_text(unicode(dhcphname))
Example #5
0
File: gui.py Project: 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
Example #6
0
    def __init__(self, networkID):
        """ Build the wireless network entry. """
        NetworkEntry.__init__(self)

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

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

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

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

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

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

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

        # Show everything
        self.show_all()
        self.advanced_dialog = WirelessSettingsDialog(networkID)
        self.wifides = self.connect("destroy", self.destroy_called)
Example #7
0
    def set_values(self):
        """ Load saved values. """
        self.ip_edit.set_edit_text(self.format_entry("ip"))
        self.netmask_edit.set_edit_text(self.format_entry("netmask"))
        self.gateway_edit.set_edit_text(self.format_entry("gateway"))

        self.global_dns_cb.set_state(
            bool(wired.GetWiredProperty('use_global_dns'))
        )
        self.static_dns_cb.set_state(
            bool(wired.GetWiredProperty('use_static_dns'))
        )

        # Set static ip checkbox.  Forgot to do this the first time.
        if stringToNone(self.ip_edit.get_edit_text()):
            self.static_ip_cb.set_state(True)
        self.dns1.set_edit_text(self.format_entry("dns1"))
        self.dns2.set_edit_text(self.format_entry("dns2"))
        self.dns3.set_edit_text(self.format_entry("dns3"))
        self.dns_dom_edit.set_edit_text(self.format_entry("dns_domain"))
        self.search_dom_edit.set_edit_text(self.format_entry("search_domain"))

        self.set_default.set_state(to_bool(wired.GetWiredProperty("default")))

        # Throw the encryption stuff into a list
        l = []
        activeID = -1  # Set the menu to this item when we are done
        for x, enc_type in enumerate(self.encrypt_types):
            l.append(enc_type['name'])
            if enc_type['type'] == wired.GetWiredProperty("enctype"):
                activeID = x
        self.encryption_combo.set_list(l)

        self.encryption_combo.set_focus(activeID)
        if wired.GetWiredProperty("encryption_enabled"):
            self.encryption_chkbox.set_state(True, do_callback=False)
            self.encryption_combo.set_sensitive(True)
            #self.lbox_encrypt_info.set_sensitive(True)
        else:
            self.encryption_combo.set_focus(0)
            self.encryption_combo.set_sensitive(False)

        self.change_encrypt_method()

        dhcphname = wired.GetWiredProperty("dhcphostname")
        if dhcphname is None:
            dhcphname = os.uname()[1]

        self.use_dhcp_h.set_state(
            bool(wired.GetWiredProperty('usedhcphostname'))
        )
        self.dhcp_h.set_sensitive(self.use_dhcp_h.get_state())
        self.dhcp_h.set_edit_text(unicode(dhcphname))
Example #8
0
    def set_values(self):
        """ Set the various network settings to the right values. """
        networkID = self.networkid
        self.ip_edit.set_edit_text(self.format_entry(networkID,"ip"))
        self.netmask_edit.set_edit_text(self.format_entry(networkID,"netmask"))
        self.gateway_edit.set_edit_text(self.format_entry(networkID,"gateway"))

        self.global_dns_cb.set_state(bool(wireless.GetWirelessProperty(networkID,
                                                                  'use_global_dns')))
        self.static_dns_cb.set_state(bool(wireless.GetWirelessProperty(networkID,
                                                                  'use_static_dns')))
        
        if stringToNone(self.ip_edit.get_edit_text()):
            self.static_ip_cb.set_state(True)
        self.dns1.set_edit_text(self.format_entry(networkID, "dns1"))
        self.dns2.set_edit_text(self.format_entry(networkID, "dns2"))
        self.dns3.set_edit_text(self.format_entry(networkID, "dns3"))
        self.dns_dom_edit.set_edit_text(self.format_entry(networkID, "dns_domain"))
        self.search_dom_edit.set_edit_text(self.format_entry(networkID, "search_domain"))
        
        self.autoconnect_chkbox.set_state(to_bool(self.format_entry(networkID, "automatic")))

        #self.reset_static_checkboxes()
        self.encryption_chkbox.set_state(bool(wireless.GetWirelessProperty(networkID,
            'encryption')),do_callback=False)
        self.global_settings_chkbox.set_state(bool(wireless.GetWirelessProperty(networkID
            ,'use_settings_globally')))

        # Throw the encryption stuff into a list
        list = []
        activeID = -1  # Set the menu to this item when we are done
        for x, enc_type in enumerate(self.encrypt_types):
            list.append(enc_type['name'])
            if enc_type['type'] == wireless.GetWirelessProperty(networkID, "enctype"):
                activeID = x
        self.encryption_combo.set_list(list)

        self.encryption_combo.set_focus(activeID)
        if activeID != -1:
            self.encryption_chkbox.set_state(True,do_callback=False)
            self.encryption_combo.set_sensitive(True)
            #self.lbox_encrypt_info.set_sensitive(True)
        else:
            self.encryption_combo.set_focus(0)

        self.change_encrypt_method()
        dhcphname = wireless.GetWirelessProperty(networkID,"dhcphostname")
        if dhcphname is None:
            dhcphname = os.uname()[1]
        self.use_dhcp_h.set_state(bool(wireless.GetWirelessProperty(networkID,'usedhcphostname')))
        self.dhcp_h.set_sensitive(self.use_dhcp_h.get_state())
        self.dhcp_h.set_edit_text(unicode(dhcphname))
Example #9
0
    def set_values(self):
        """ Set the various network settings to the right values. """
        networkID = self.networkid
        self.ip_edit.set_edit_text(self.format_entry(networkID,"ip"))
        self.netmask_edit.set_edit_text(self.format_entry(networkID,"netmask"))
        self.gateway_edit.set_edit_text(self.format_entry(networkID,"gateway"))

        self.global_dns_cb.set_state(bool(wireless.GetWirelessProperty(networkID,
                                                                  'use_global_dns')))
        self.static_dns_cb.set_state(bool(wireless.GetWirelessProperty(networkID,
                                                                  'use_static_dns')))
        
        if stringToNone(self.ip_edit.get_edit_text()):
            self.static_ip_cb.set_state(True)
        self.dns1.set_edit_text(self.format_entry(networkID, "dns1"))
        self.dns2.set_edit_text(self.format_entry(networkID, "dns2"))
        self.dns3.set_edit_text(self.format_entry(networkID, "dns3"))
        self.dns_dom_edit.set_edit_text(self.format_entry(networkID, "dns_domain"))
        self.search_dom_edit.set_edit_text(self.format_entry(networkID, "search_domain"))
        
        self.autoconnect_chkbox.set_state(to_bool(self.format_entry(networkID, "automatic")))

        #self.reset_static_checkboxes()
        self.encryption_chkbox.set_state(bool(wireless.GetWirelessProperty(networkID,
            'encryption')),do_callback=False)
        self.global_settings_chkbox.set_state(bool(wireless.GetWirelessProperty(networkID
            ,'use_settings_globally')))

        # Throw the encryption stuff into a list
        list = []
        activeID = -1  # Set the menu to this item when we are done
        for x, enc_type in enumerate(self.encrypt_types):
            list.append(enc_type['name'])
            if enc_type['type'] == wireless.GetWirelessProperty(networkID, "enctype"):
                activeID = x
        self.encryption_combo.set_list(list)

        self.encryption_combo.set_focus(activeID)
        if activeID != -1:
            self.encryption_chkbox.set_state(True,do_callback=False)
            self.encryption_combo.set_sensitive(True)
            #self.lbox_encrypt_info.set_sensitive(True)
        else:
            self.encryption_combo.set_focus(0)

        self.change_encrypt_method()
        dhcphname = wireless.GetWirelessProperty(networkID,"dhcphostname")
        if dhcphname is None:
            dhcphname = os.uname()[1]
        self.use_dhcp_h.set_state(bool(wireless.GetWirelessProperty(networkID,'usedhcphostname')))
        self.dhcp_h.set_sensitive(self.use_dhcp_h.get_state())
        self.dhcp_h.set_edit_text(unicode(dhcphname))
Example #10
0
 def update_connect_button(self, state, apbssid):
     """ Update the connection/disconnect button for this entry. """
     if to_bool(self.format_entry(self.networkID, "never")):
         self.connect_button.set_sensitive(False)
     if not apbssid:
         apbssid = wireless.GetApBssid()
     if state == misc.WIRELESS and \
        apbssid == wireless.GetWirelessProperty(self.networkID, "bssid"):
         self.disconnect_button.show()
         self.connect_button.hide()
     else:
         self.disconnect_button.hide()
         self.connect_button.show()
Example #11
0
    def set_values(self):
        """ Load saved values. """
        self.ip_edit.set_edit_text(self.format_entry("ip"))
        self.netmask_edit.set_edit_text(self.format_entry("netmask"))
        self.gateway_edit.set_edit_text(self.format_entry("gateway"))

        self.global_dns_cb.set_state(
            bool(wired.GetWiredProperty('use_global_dns')))
        self.static_dns_cb.set_state(
            bool(wired.GetWiredProperty('use_static_dns')))

        # Set static ip checkbox.  Forgot to do this the first time.
        if stringToNone(self.ip_edit.get_edit_text()):
            self.static_ip_cb.set_state(True)
        self.dns1.set_edit_text(self.format_entry("dns1"))
        self.dns2.set_edit_text(self.format_entry("dns2"))
        self.dns3.set_edit_text(self.format_entry("dns3"))
        self.dns_dom_edit.set_edit_text(self.format_entry("dns_domain"))
        self.search_dom_edit.set_edit_text(self.format_entry("search_domain"))

        self.set_default.set_state(to_bool(wired.GetWiredProperty("default")))

        # Throw the encryption stuff into a list
        l = []
        activeID = -1  # Set the menu to this item when we are done
        for x, enc_type in enumerate(self.encrypt_types):
            l.append(enc_type['name'])
            if enc_type['type'] == wired.GetWiredProperty("enctype"):
                activeID = x
        self.encryption_combo.set_list(l)

        self.encryption_combo.set_focus(activeID)
        if wired.GetWiredProperty("encryption_enabled"):
            self.encryption_chkbox.set_state(True, do_callback=False)
            self.encryption_combo.set_sensitive(True)
            #self.lbox_encrypt_info.set_sensitive(True)
        else:
            self.encryption_combo.set_focus(0)
            self.encryption_combo.set_sensitive(False)

        self.change_encrypt_method()

        dhcphname = wired.GetWiredProperty("dhcphostname")
        if dhcphname is None:
            dhcphname = os.uname()[1]

        self.use_dhcp_h.set_state(
            bool(wired.GetWiredProperty('usedhcphostname')))
        self.dhcp_h.set_sensitive(self.use_dhcp_h.get_state())
        self.dhcp_h.set_edit_text(str(dhcphname))
Example #12
0
        def populate_network_menu(self, data=None):
            """ Populates the network list submenu. """
            def get_prop(net_id, prop):
                return wireless.GetWirelessProperty(net_id, prop)

            net_menuitem = self.manager.get_widget("/Menubar/Menu/Connect/")
            submenu = net_menuitem.get_submenu()
            self._clear_menu(submenu)
            if not DBUS_AVAIL:
                net_menuitem.show()
                return

            is_connecting = daemon.CheckIfConnecting()
            num_networks = wireless.GetNumberOfNetworks()
            [status, info] = daemon.GetConnectionStatus()

            if daemon.GetAlwaysShowWiredInterface() or \
               wired.CheckPluggedIn():
                if status == misc.WIRED:
                    is_active = True
                else:
                    is_active = False
                self._add_item_to_menu(submenu, "Wired Network", "__wired__", 0,
                                       is_connecting, is_active)
                sep = gtk.SeparatorMenuItem()
                submenu.append(sep)
                sep.show()

            if num_networks > 0:
                skip_never_connect = not daemon.GetShowNeverConnect()
                for x in xrange(0, num_networks):
                    if skip_never_connect and \
                      misc.to_bool(get_prop(x,"never")):
                        continue
                    essid = get_prop(x, "essid")
                    if status == misc.WIRELESS and info[1] == essid:
                        is_active = True
                    else:
                        is_active = False
                    self._add_item_to_menu(submenu, essid, "wifi", x,
                                           is_connecting, is_active)
            else:
                no_nets_item = gtk.MenuItem(_('No wireless networks found.'))
                no_nets_item.set_sensitive(False)
                no_nets_item.show()
                submenu.append(no_nets_item)

            submenu.reposition()
            net_menuitem.show()
Example #13
0
        def populate_network_menu(self, data=None):
            """ Populates the network list submenu. """
            def get_prop(net_id, prop):
                return wireless.GetWirelessProperty(net_id, prop)

            net_menuitem = self.manager.get_widget("/Menubar/Menu/Connect/")
            submenu = net_menuitem.get_submenu()
            self._clear_menu(submenu)
            if not DBUS_AVAIL:
                net_menuitem.show()
                return

            is_connecting = daemon.CheckIfConnecting()
            num_networks = wireless.GetNumberOfNetworks()
            [status, info] = daemon.GetConnectionStatus()

            if daemon.GetAlwaysShowWiredInterface() or \
               wired.CheckPluggedIn():
                if status == misc.WIRED:
                    is_active = True
                else:
                    is_active = False
                self._add_item_to_menu(submenu, "Wired Network", "__wired__",
                                       0, is_connecting, is_active)
                sep = gtk.SeparatorMenuItem()
                submenu.append(sep)
                sep.show()

            if num_networks > 0:
                skip_never_connect = not daemon.GetShowNeverConnect()
                for x in range(0, num_networks):
                    if skip_never_connect and \
                      misc.to_bool(get_prop(x,"never")):
                        continue
                    essid = get_prop(x, "essid")
                    if status == misc.WIRELESS and info[1] == essid:
                        is_active = True
                    else:
                        is_active = False
                    self._add_item_to_menu(submenu, essid, "wifi", x,
                                           is_connecting, is_active)
            else:
                no_nets_item = gtk.MenuItem(_('No wireless networks found.'))
                no_nets_item.set_sensitive(False)
                no_nets_item.show()
                submenu.append(no_nets_item)

            submenu.reposition()
            net_menuitem.show()
Example #14
0
    def change_profile(self, widget):
        """ Called when a new profile is chosen from the list. """
        # Make sure the name doesn't change everytime someone types something
        if self.combo_profile_names.get_active() > -1:
            if not self.is_full_gui:
                return
            
            profile_name = self.combo_profile_names.get_active_text()
            wired.ReadWiredNetworkProfile(profile_name)

            if hasattr(self, 'advanced_dialog'):
                self.advanced_dialog.prof_name = profile_name
                self.advanced_dialog.set_values()
            
            is_default = wired.GetWiredProperty("default")
            self.chkbox_default_profile.set_active(to_bool(is_default))
Example #15
0
    def change_profile(self, widget):
        """ Called when a new profile is chosen from the list. """
        # Make sure the name doesn't change everytime someone types something
        if self.combo_profile_names.get_active() > -1:
            if not self.is_full_gui:
                return

            profile_name = self.combo_profile_names.get_active_text()
            wired.ReadWiredNetworkProfile(profile_name)

            if hasattr(self, 'advanced_dialog'):
                self.advanced_dialog.prof_name = profile_name
                self.advanced_dialog.set_values()

            is_default = wired.GetWiredProperty("default")
            self.chkbox_default_profile.set_active(to_bool(is_default))
Example #16
0
def     minterface():
        num_networks = wireless.GetNumberOfNetworks()
        #print   num_networks
        if num_networks > 0:
            skip_never_connect = not daemon.GetShowNeverConnect()
            for x in xrange(0, num_networks):
                if skip_never_connect and misc.to_bool(get_wireless_prop(x,'never')): continue
                tempnet = WirelessNetworkEntry(x)
                print  tempnet

        #encryption_connect(3,"yfa12345!","wpa")
        """
        if wireless.GetWirelessProperty(0, "encryption"):
            print "security"
            set_net_prop(0,"enctype","wpa")
            set_net_prop(0,"key","yfa12345!")
        else:
            set_net_prop(0,"enctype","None")
        connect(0)
        """
        #disconnect(0)
        return  num_networks
Example #17
0
    def __init__(self):
        """ Load the wired network entry. """
        NetworkEntry.__init__(self)
        # Center the picture and pad it a bit
        self.image.set_padding(0, 0)
        self.image.set_alignment(.5, .5)
        self.image.set_size_request(60, -1)
        self.image.set_from_file(wpath.images + "wired-gui.svg")
        self.image.show()
        self.connect_button.show()

        self.name_label.set_use_markup(True)
        self.name_label.set_label("<b>" + language['wired_network'] + "</b>")

        self.is_full_gui = True

        self.button_add = gtk.Button(stock=gtk.STOCK_ADD)
        self.button_delete = gtk.Button(stock=gtk.STOCK_DELETE)
        self.profile_help = gtk.Label(language['wired_network_instructions'])
        self.chkbox_default_profile = gtk.CheckButton(
            language['default_wired'])
        self.combo_profile_names = gtk.combo_box_new_text()

        # Format the profile help label.
        self.profile_help.set_justify(gtk.JUSTIFY_LEFT)
        self.profile_help.set_line_wrap(True)

        # Pack the various VBox objects.
        self.hbox_temp = gtk.HBox(False, 0)
        self.hbox_def = gtk.HBox(False, 0)
        self.vbox_top.pack_start(self.profile_help, True, True)
        self.vbox_top.pack_start(self.hbox_def)
        self.vbox_top.pack_start(self.hbox_temp)
        self.hbox_temp.pack_start(self.combo_profile_names, True, True)
        self.hbox_temp.pack_start(self.button_add, False, False)
        self.hbox_temp.pack_start(self.button_delete, False, False)
        self.hbox_def.pack_start(self.chkbox_default_profile, False, False)

        # Connect events
        self.button_add.connect("clicked", self.add_profile)
        self.button_delete.connect("clicked", self.remove_profile)
        self.chkbox_default_profile.connect("toggled",
                                            self.toggle_default_profile)
        self.combo_profile_names.connect("changed", self.change_profile)

        # Build profile list.
        self.profile_list = wired.GetWiredProfileList()
        default_prof = wired.GetDefaultWiredNetwork()
        if self.profile_list:
            starting_index = 0
            for x, prof in enumerate(self.profile_list):
                self.combo_profile_names.append_text(prof)
                if default_prof == prof:
                    starting_index = x
            self.combo_profile_names.set_active(starting_index)
        else:
            print "no wired profiles found"
            self.profile_help.show()

        self.advanced_dialog = WiredSettingsDialog(
            self.combo_profile_names.get_active_text())

        # Show everything, but hide the profile help label.
        self.show_all()
        self.profile_help.hide()

        # Toggle the default profile checkbox to the correct state.
        if to_bool(wired.GetWiredProperty("default")):
            self.chkbox_default_profile.set_active(True)
        else:
            self.chkbox_default_profile.set_active(False)

        self.check_enable()
        self.wireddis = self.connect("destroy", self.destroy_called)
Example #18
0
    def __init__(self):
        """ Load the wired network entry. """
        NetworkEntry.__init__(self)
        # Center the picture and pad it a bit
        self.image.set_padding(0, 0)
        self.image.set_alignment(.5, .5)
        self.image.set_size_request(60, -1)
        self.image.set_from_file(wpath.images + "wired-gui.svg")
        self.image.show()
        self.connect_button.show()

        self.name_label.set_use_markup(True)
        self.name_label.set_label("<b>" + language['wired_network'] + "</b>")
        
        self.is_full_gui = True
        
        self.button_add = gtk.Button(stock=gtk.STOCK_ADD)
        self.button_delete = gtk.Button(stock=gtk.STOCK_DELETE)
        self.profile_help = gtk.Label(language['wired_network_instructions'])
        self.chkbox_default_profile = gtk.CheckButton(language['default_wired'])
        self.combo_profile_names = gtk.combo_box_new_text() 
        
        # Format the profile help label.
        self.profile_help.set_justify(gtk.JUSTIFY_LEFT)
        self.profile_help.set_line_wrap(True)

        # Pack the various VBox objects.
        self.hbox_temp = gtk.HBox(False, 0)
        self.hbox_def = gtk.HBox(False, 0)
        self.vbox_top.pack_start(self.profile_help, True, True)
        self.vbox_top.pack_start(self.hbox_def)
        self.vbox_top.pack_start(self.hbox_temp)
        self.hbox_temp.pack_start(self.combo_profile_names, True, True)
        self.hbox_temp.pack_start(self.button_add, False, False)
        self.hbox_temp.pack_start(self.button_delete, False, False)
        self.hbox_def.pack_start(self.chkbox_default_profile, False, False)

        # Connect events
        self.button_add.connect("clicked", self.add_profile)
        self.button_delete.connect("clicked", self.remove_profile)
        self.chkbox_default_profile.connect("toggled",
                                            self.toggle_default_profile)
        self.combo_profile_names.connect("changed", self.change_profile)
        
        # Build profile list.
        self.profile_list = wired.GetWiredProfileList()
        default_prof = wired.GetDefaultWiredNetwork()
        if self.profile_list:
            starting_index = 0
            for x, prof in enumerate(self.profile_list):
                self.combo_profile_names.append_text(prof)
                if default_prof == prof:
                    starting_index = x
            self.combo_profile_names.set_active(starting_index)
        else:
            print "no wired profiles found"
            self.profile_help.show()
            
        self.advanced_dialog = WiredSettingsDialog(self.combo_profile_names.get_active_text())            

        # Show everything, but hide the profile help label.
        self.show_all()
        self.profile_help.hide()
        
        # Toggle the default profile checkbox to the correct state.
        if to_bool(wired.GetWiredProperty("default")):
            self.chkbox_default_profile.set_active(True)
        else:
            self.chkbox_default_profile.set_active(False)

        self.check_enable()
        self.wireddis = self.connect("destroy", self.destroy_called)
Example #19
0
 def test_to_boolean_true(self):
     self.assertTrue(misc.to_bool('1'))
Example #20
0
 def test_to_boolean_0(self):
     self.assertFalse(misc.to_bool('0'))
Example #21
0
 def test_to_boolean_false(self):
     self.assertFalse(misc.to_bool('False'))
Example #22
0
 def test_to_boolean_true(self):
     self.assertTrue(misc.to_bool('1'))
Example #23
0
 def test_to_boolean_0(self):
     self.assertFalse(misc.to_bool('0'))
Example #24
0
 def test_to_boolean_false(self):
     self.assertFalse(misc.to_bool('False'))