|
|
|
|
@@ -41,6 +41,11 @@ class SmallLabel(gtk.Label):
|
|
|
|
|
def __init__(self, text=''):
|
|
|
|
|
gtk.Label.__init__(self, text)
|
|
|
|
|
self.set_size_request(50, -1)
|
|
|
|
|
|
|
|
|
|
class LeftAlignedLabel(gtk.Label):
|
|
|
|
|
def __init__(self, label=None):
|
|
|
|
|
gtk.Label.__init__(self, label)
|
|
|
|
|
self.set_alignment(0.0, 0.5)
|
|
|
|
|
|
|
|
|
|
class LabelEntry(gtk.HBox):
|
|
|
|
|
""" A label on the left with a textbox on the right. """
|
|
|
|
|
@@ -126,6 +131,19 @@ class AdvancedSettingsDialog(gtk.Dialog):
|
|
|
|
|
self.hbox_dns.pack_start(self.chkbox_static_dns)
|
|
|
|
|
self.hbox_dns.pack_start(self.chkbox_global_dns)
|
|
|
|
|
|
|
|
|
|
# Set up the script settings button
|
|
|
|
|
self.script_button = gtk.Button()
|
|
|
|
|
script_image = gtk.Image()
|
|
|
|
|
script_image.set_from_stock(gtk.STOCK_EXECUTE, 4)
|
|
|
|
|
script_image.set_padding(4, 0)
|
|
|
|
|
#self.script_button.set_alignment(.5, .5)
|
|
|
|
|
self.script_button.set_image(script_image)
|
|
|
|
|
self.script_button.set_label(language['scripts'])
|
|
|
|
|
|
|
|
|
|
self.button_hbox = gtk.HBox(False, 2)
|
|
|
|
|
self.button_hbox.pack_start(self.script_button, fill=False, expand=False)
|
|
|
|
|
self.button_hbox.show()
|
|
|
|
|
|
|
|
|
|
assert(isinstance(self.vbox, gtk.VBox))
|
|
|
|
|
self.vbox.pack_start(self.chkbox_static_ip, fill=False, expand=False)
|
|
|
|
|
self.vbox.pack_start(self.txt_ip, fill=False, expand=False)
|
|
|
|
|
@@ -137,6 +155,7 @@ class AdvancedSettingsDialog(gtk.Dialog):
|
|
|
|
|
self.vbox.pack_start(self.txt_dns_1, fill=False, expand=False)
|
|
|
|
|
self.vbox.pack_start(self.txt_dns_2, fill=False, expand=False)
|
|
|
|
|
self.vbox.pack_start(self.txt_dns_3, fill=False, expand=False)
|
|
|
|
|
self.vbox.pack_end(self.button_hbox, fill=False, expand=False, padding=5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Connect the events to the actions
|
|
|
|
|
@@ -277,12 +296,27 @@ class WiredSettingsDialog(AdvancedSettingsDialog):
|
|
|
|
|
""" Build the wired settings dialog. """
|
|
|
|
|
AdvancedSettingsDialog.__init__(self)
|
|
|
|
|
self.des = self.connect("destroy", self.destroy_called)
|
|
|
|
|
self.script_button.connect("button-press-event", self.edit_scripts)
|
|
|
|
|
self.prof_name = name
|
|
|
|
|
|
|
|
|
|
def set_net_prop(self, option, value):
|
|
|
|
|
""" Sets the given option to the given value for this network. """
|
|
|
|
|
wired.SetWiredProperty(option, value)
|
|
|
|
|
|
|
|
|
|
def edit_scripts(self, widget=None, event=None):
|
|
|
|
|
""" Launch the script editting dialog. """
|
|
|
|
|
profile = self.combo_profile_names.get_active_text()
|
|
|
|
|
cmdend = [os.path.join(wpath.lib, "configscript.py"), profile, "wired"]
|
|
|
|
|
if os.getuid() != 0:
|
|
|
|
|
cmdbase = misc.get_sudo_cmd(language['scripts_need_pass'])
|
|
|
|
|
if not cmdbase:
|
|
|
|
|
error(None, language["no_sudo_prog"])
|
|
|
|
|
return
|
|
|
|
|
cmdbase.extend(cmdend)
|
|
|
|
|
misc.LaunchAndWait(cmdbase)
|
|
|
|
|
else:
|
|
|
|
|
misc.LaunchAndWait(cmdend)
|
|
|
|
|
|
|
|
|
|
def set_values(self):
|
|
|
|
|
""" Fill in the Gtk.Entry objects with the correct values. """
|
|
|
|
|
self.txt_ip.set_text(self.format_entry("ip"))
|
|
|
|
|
@@ -330,12 +364,16 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
|
|
|
|
|
self.combo_encryption.set_sensitive(False)
|
|
|
|
|
self.encrypt_types = misc.LoadEncryptionMethods()
|
|
|
|
|
|
|
|
|
|
information_button = gtk.Button(stock=gtk.STOCK_INFO)
|
|
|
|
|
self.button_hbox.pack_start(information_button, False, False)
|
|
|
|
|
information_button.connect('clicked', lambda *a, **k: WirelessInformationDialog(networkID))
|
|
|
|
|
information_button.show()
|
|
|
|
|
|
|
|
|
|
# Build the encryption menu
|
|
|
|
|
activeID = -1 # Set the menu to this item when we are done
|
|
|
|
|
for x, enc_type in enumerate(self.encrypt_types):
|
|
|
|
|
self.combo_encryption.append_text(enc_type[0])
|
|
|
|
|
if enc_type[1] == wireless.GetWirelessProperty(networkID,
|
|
|
|
|
"enctype"):
|
|
|
|
|
if enc_type[1] == wireless.GetWirelessProperty(networkID, "enctype"):
|
|
|
|
|
activeID = x
|
|
|
|
|
self.combo_encryption.set_active(activeID)
|
|
|
|
|
if activeID != -1:
|
|
|
|
|
@@ -354,6 +392,7 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
|
|
|
|
|
# Connect signals.
|
|
|
|
|
self.chkbox_encryption.connect("toggled", self.toggle_encryption)
|
|
|
|
|
self.combo_encryption.connect("changed", self.change_encrypt_method)
|
|
|
|
|
self.script_button.connect("button-press-event", self.edit_scripts)
|
|
|
|
|
self.des = self.connect("destroy", self.destroy_called)
|
|
|
|
|
|
|
|
|
|
def destroy_called(self, *args):
|
|
|
|
|
@@ -363,6 +402,20 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
|
|
|
|
|
self.destroy()
|
|
|
|
|
del self
|
|
|
|
|
|
|
|
|
|
def edit_scripts(self, widget=None, event=None):
|
|
|
|
|
""" Launch the script editting dialog. """
|
|
|
|
|
cmdend = [os.path.join(wpath.lib, "configscript.py"),
|
|
|
|
|
str(self.networkID), "wireless"]
|
|
|
|
|
if os.getuid() != 0:
|
|
|
|
|
cmdbase = misc.get_sudo_cmd(language['scripts_need_pass'])
|
|
|
|
|
if not cmdbase:
|
|
|
|
|
error(None, language["no_sudo_prog"])
|
|
|
|
|
return
|
|
|
|
|
cmdbase.extend(cmdend)
|
|
|
|
|
misc.LaunchAndWait(cmdbase)
|
|
|
|
|
else:
|
|
|
|
|
misc.LaunchAndWait(cmdend)
|
|
|
|
|
|
|
|
|
|
def set_net_prop(self, option, value):
|
|
|
|
|
""" Sets the given option to the given value for this network. """
|
|
|
|
|
wireless.SetWirelessProperty(self.networkID, option, value)
|
|
|
|
|
@@ -479,7 +532,7 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
|
|
|
|
|
|
|
|
|
|
box.entry.set_text(noneToBlankString(
|
|
|
|
|
wireless.GetWirelessProperty(self.networkID, opts[x][1])))
|
|
|
|
|
self.vbox_encrypt_info.show_all()
|
|
|
|
|
self.vbox_encrypt_info.show_all()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NetworkEntry(gtk.HBox):
|
|
|
|
|
@@ -495,9 +548,11 @@ class NetworkEntry(gtk.HBox):
|
|
|
|
|
wired = dbus_ifaces["wired"]
|
|
|
|
|
wireless = dbus_ifaces["wireless"]
|
|
|
|
|
gtk.HBox.__init__(self, False, 2)
|
|
|
|
|
self.expander = gtk.Expander()
|
|
|
|
|
self.image = gtk.Image()
|
|
|
|
|
self.pack_start(self.image, False, False)
|
|
|
|
|
|
|
|
|
|
# Create an HBox to hold the buttons
|
|
|
|
|
self.buttons_hbox = gtk.HBox(False, 6)
|
|
|
|
|
|
|
|
|
|
# Set up the Connect button
|
|
|
|
|
self.connect_button = gtk.Button(stock=gtk.STOCK_CONNECT)
|
|
|
|
|
@@ -508,12 +563,14 @@ class NetworkEntry(gtk.HBox):
|
|
|
|
|
# Set up the Disconnect button
|
|
|
|
|
self.disconnect_button = gtk.Button(stock=gtk.STOCK_DISCONNECT)
|
|
|
|
|
self.connect_hbox.pack_start(self.disconnect_button, False, False)
|
|
|
|
|
|
|
|
|
|
# Create a label to hold the name of the entry
|
|
|
|
|
self.name_label = gtk.Label()
|
|
|
|
|
self.name_label.set_alignment(0, 0.5)
|
|
|
|
|
|
|
|
|
|
# Set up the VBox that goes in the gtk.Expander
|
|
|
|
|
self.expander_vbox = gtk.VBox(False, 1)
|
|
|
|
|
self.expander_vbox.show()
|
|
|
|
|
self.expander_vbox.pack_start(self.expander)
|
|
|
|
|
self.expander_vbox.pack_start(self.connect_hbox, False, False)
|
|
|
|
|
self.pack_end(self.expander_vbox)
|
|
|
|
|
|
|
|
|
|
# Set up the advanced settings button
|
|
|
|
|
@@ -525,27 +582,18 @@ class NetworkEntry(gtk.HBox):
|
|
|
|
|
self.advanced_button.set_label(language['advanced_settings'])
|
|
|
|
|
self.advanced_button.set_image(self.advanced_image)
|
|
|
|
|
|
|
|
|
|
# Set up the script settings button
|
|
|
|
|
self.script_button = gtk.Button()
|
|
|
|
|
self.script_image = gtk.Image()
|
|
|
|
|
self.script_image.set_from_stock(gtk.STOCK_EXECUTE, 4)
|
|
|
|
|
self.script_image.set_padding(4, 0)
|
|
|
|
|
self.script_button.set_alignment(.5, .5)
|
|
|
|
|
self.script_button.set_image(self.script_image)
|
|
|
|
|
self.script_button.set_label(language['scripts'])
|
|
|
|
|
|
|
|
|
|
self.settings_hbox = gtk.HBox(False, 3)
|
|
|
|
|
self.settings_hbox.set_border_width(5)
|
|
|
|
|
self.settings_hbox.pack_start(self.script_button, False, False)
|
|
|
|
|
self.settings_hbox.pack_start(self.advanced_button, False, False)
|
|
|
|
|
|
|
|
|
|
#self.buttons_hbox.pack_start(self.script_button, False, False)
|
|
|
|
|
self.buttons_hbox.pack_start(self.connect_hbox, False, False)
|
|
|
|
|
self.buttons_hbox.pack_start(self.advanced_button, False, False)
|
|
|
|
|
|
|
|
|
|
self.vbox_top = gtk.VBox(False, 0)
|
|
|
|
|
self.vbox_top.pack_end(self.settings_hbox, False, False)
|
|
|
|
|
#self.vbox_top.pack_end(self.buttons_hbox, False, False)
|
|
|
|
|
#self.vbox_top.pack_end(self.connect_hbox, False, False)
|
|
|
|
|
|
|
|
|
|
aligner = gtk.Alignment(xscale=1.0)
|
|
|
|
|
aligner.add(self.vbox_top)
|
|
|
|
|
aligner.set_padding(0, 0, 15, 0)
|
|
|
|
|
self.expander.add(aligner)
|
|
|
|
|
|
|
|
|
|
self.expander_vbox.pack_start(self.name_label)
|
|
|
|
|
self.expander_vbox.pack_start(self.vbox_top)
|
|
|
|
|
self.expander_vbox.pack_start(self.buttons_hbox)
|
|
|
|
|
|
|
|
|
|
def destroy_called(self, *args):
|
|
|
|
|
""" Clean up everything. """
|
|
|
|
|
@@ -564,10 +612,10 @@ class WiredNetworkEntry(NetworkEntry):
|
|
|
|
|
#self.image.set_from_icon_name("network-wired", 6)
|
|
|
|
|
self.image.set_from_file(wpath.images + "wired.png")
|
|
|
|
|
self.image.show()
|
|
|
|
|
self.expander.show()
|
|
|
|
|
self.connect_button.show()
|
|
|
|
|
|
|
|
|
|
self.name_label.set_label(language['wired_network'])
|
|
|
|
|
|
|
|
|
|
self.expander.set_label(language['wired_network'])
|
|
|
|
|
#self.reset_static_checkboxes()
|
|
|
|
|
self.is_full_gui = True
|
|
|
|
|
|
|
|
|
|
@@ -628,11 +676,8 @@ class WiredNetworkEntry(NetworkEntry):
|
|
|
|
|
else:
|
|
|
|
|
self.combo_profile_names.set_active(0)
|
|
|
|
|
print "wired profiles found"
|
|
|
|
|
self.expander.set_expanded(False)
|
|
|
|
|
else:
|
|
|
|
|
print "no wired profiles found"
|
|
|
|
|
if not wired.GetAlwaysShowWiredInterface():
|
|
|
|
|
self.expander.set_expanded(True)
|
|
|
|
|
self.profile_help.show()
|
|
|
|
|
self.check_enable()
|
|
|
|
|
self.wireddis = self.connect("destroy", self.destroy_called)
|
|
|
|
|
@@ -649,20 +694,6 @@ class WiredNetworkEntry(NetworkEntry):
|
|
|
|
|
def save_wired_settings(self):
|
|
|
|
|
""" Save wired network settings. """
|
|
|
|
|
return self.advanced_dialog.save_settings()
|
|
|
|
|
|
|
|
|
|
def edit_scripts(self, widget=None, event=None):
|
|
|
|
|
""" Launch the script editting dialog. """
|
|
|
|
|
profile = self.combo_profile_names.get_active_text()
|
|
|
|
|
cmdend = [os.path.join(wpath.lib, "configscript.py"), profile, "wired"]
|
|
|
|
|
if os.getuid() != 0:
|
|
|
|
|
cmdbase = misc.get_sudo_cmd(language['scripts_need_pass'])
|
|
|
|
|
if not cmdbase:
|
|
|
|
|
error(None, language["no_sudo_prog"])
|
|
|
|
|
return
|
|
|
|
|
cmdbase.extend(cmdend)
|
|
|
|
|
misc.LaunchAndWait(cmdbase)
|
|
|
|
|
else:
|
|
|
|
|
misc.LaunchAndWait(cmdend)
|
|
|
|
|
|
|
|
|
|
def check_enable(self):
|
|
|
|
|
""" Disable objects if the profile list is empty. """
|
|
|
|
|
@@ -765,53 +796,39 @@ class WirelessNetworkEntry(NetworkEntry):
|
|
|
|
|
|
|
|
|
|
self.networkID = networkID
|
|
|
|
|
self.image.set_padding(0, 0)
|
|
|
|
|
self.image.set_alignment(.5, 0)
|
|
|
|
|
self.image.set_alignment(.5, .5)
|
|
|
|
|
self.image.set_size_request(60, -1)
|
|
|
|
|
self.image.show()
|
|
|
|
|
#self.image.set_from_icon_name("network-wired", 6)
|
|
|
|
|
self.essid = noneToBlankString(wireless.GetWirelessProperty(networkID,
|
|
|
|
|
"essid"))
|
|
|
|
|
print "ESSID : " + self.essid
|
|
|
|
|
# Make the combo box.
|
|
|
|
|
self.lbl_strength = GreyLabel()
|
|
|
|
|
self.lbl_encryption = GreyLabel()
|
|
|
|
|
self.lbl_mac = GreyLabel()
|
|
|
|
|
self.lbl_channel = GreyLabel()
|
|
|
|
|
self.lbl_mode = GreyLabel()
|
|
|
|
|
self.hbox_status = gtk.HBox(False, 5)
|
|
|
|
|
|
|
|
|
|
print "ESSID : " + self.essid
|
|
|
|
|
self.chkbox_autoconnect = gtk.CheckButton(language['automatic_connect'])
|
|
|
|
|
|
|
|
|
|
# Set the values of the network info labels.
|
|
|
|
|
self.set_signal_strength(wireless.GetWirelessProperty(networkID,
|
|
|
|
|
'quality'),
|
|
|
|
|
wireless.GetWirelessProperty(networkID,
|
|
|
|
|
'strength'))
|
|
|
|
|
self.set_mac_address(wireless.GetWirelessProperty(networkID, 'bssid'))
|
|
|
|
|
self.set_mode(wireless.GetWirelessProperty(networkID, 'mode'))
|
|
|
|
|
self.set_channel(wireless.GetWirelessProperty(networkID, 'channel'))
|
|
|
|
|
self.set_encryption(wireless.GetWirelessProperty(networkID,
|
|
|
|
|
self.set_encryption(wireless.GetWirelessProperty(networkID,
|
|
|
|
|
'encryption'),
|
|
|
|
|
wireless.GetWirelessProperty(networkID,
|
|
|
|
|
'encryption_method'))
|
|
|
|
|
|
|
|
|
|
# The the expander label.
|
|
|
|
|
self.expander.set_use_markup(True)
|
|
|
|
|
|
|
|
|
|
self.expander.set_label(self._escape(self.essid) + " " +
|
|
|
|
|
self.lbl_strength.get_label() + " " +
|
|
|
|
|
self.lbl_encryption.get_label() + " " +
|
|
|
|
|
self.lbl_mac.get_label())
|
|
|
|
|
|
|
|
|
|
# Pack the network status HBox.
|
|
|
|
|
self.hbox_status.pack_start(self.lbl_strength, True, True)
|
|
|
|
|
self.hbox_status.pack_start(self.lbl_encryption, True, True)
|
|
|
|
|
self.hbox_status.pack_start(self.lbl_mac, True, True)
|
|
|
|
|
self.hbox_status.pack_start(self.lbl_mode, True, True)
|
|
|
|
|
self.hbox_status.pack_start(self.lbl_channel, True, True)
|
|
|
|
|
|
|
|
|
|
'encryption_method'))
|
|
|
|
|
self.set_channel(wireless.GetWirelessProperty(networkID, 'channel'))
|
|
|
|
|
self.name_label.set_use_markup(True)
|
|
|
|
|
self.name_label.set_label("%s %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.hbox_status, True, True)
|
|
|
|
|
# self.vbox_top.pack_start(self.hbox_status, True, True)
|
|
|
|
|
|
|
|
|
|
if to_bool(self.format_entry(networkID, "automatic")):
|
|
|
|
|
self.chkbox_autoconnect.set_active(True)
|
|
|
|
|
@@ -819,14 +836,13 @@ class WirelessNetworkEntry(NetworkEntry):
|
|
|
|
|
self.chkbox_autoconnect.set_active(False)
|
|
|
|
|
|
|
|
|
|
# Connect signals.
|
|
|
|
|
self.chkbox_autoconnect.connect("toggled", self.update_autoconnect)
|
|
|
|
|
self.script_button.connect("button-press-event", self.edit_scripts)
|
|
|
|
|
self.chkbox_autoconnect.connect("toggled", self.update_autoconnect)
|
|
|
|
|
|
|
|
|
|
# Show everything
|
|
|
|
|
self.show_all()
|
|
|
|
|
self.advanced_dialog = WirelessSettingsDialog(networkID)
|
|
|
|
|
self.wifides = self.connect("destroy", self.destroy_called)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _escape(self, val):
|
|
|
|
|
""" Escapes special characters so they're displayed correctly. """
|
|
|
|
|
return val.replace("&", "&").replace("<", "<").\
|
|
|
|
|
@@ -835,7 +851,14 @@ class WirelessNetworkEntry(NetworkEntry):
|
|
|
|
|
def save_wireless_settings(self, networkid):
|
|
|
|
|
""" Save wireless network settings. """
|
|
|
|
|
return self.advanced_dialog.save_settings(networkid)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_autoconnect(self, widget=None):
|
|
|
|
|
""" Called when the autoconnect checkbox is toggled. """
|
|
|
|
|
wireless.SetWirelessProperty(self.networkID, "automatic",
|
|
|
|
|
noneToString(self.chkbox_autoconnect.
|
|
|
|
|
get_active()))
|
|
|
|
|
wireless.SaveWirelessNetworkProperty(self.networkID, "automatic")
|
|
|
|
|
|
|
|
|
|
def destroy_called(self, *args):
|
|
|
|
|
""" Clean up everything. """
|
|
|
|
|
self.disconnect(self.wifides)
|
|
|
|
|
@@ -844,7 +867,19 @@ class WirelessNetworkEntry(NetworkEntry):
|
|
|
|
|
super(WirelessNetworkEntry, self).destroy_called()
|
|
|
|
|
self.destroy()
|
|
|
|
|
del self
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_connect_button(self, state, apbssid):
|
|
|
|
|
""" Update the connection/disconnect button for this entry. """
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
|
def set_signal_strength(self, strength, dbm_strength):
|
|
|
|
|
""" Set the signal strength displayed in the WirelessNetworkEntry. """
|
|
|
|
|
if strength is not None:
|
|
|
|
|
@@ -883,21 +918,127 @@ class WirelessNetworkEntry(NetworkEntry):
|
|
|
|
|
signal_img = 'signal-25.png'
|
|
|
|
|
ending = "%"
|
|
|
|
|
disp_strength = str(strength)
|
|
|
|
|
|
|
|
|
|
self.image.set_from_file(wpath.images + signal_img)
|
|
|
|
|
self.lbl_strength.set_label(disp_strength + ending)
|
|
|
|
|
self.image.show()
|
|
|
|
|
|
|
|
|
|
def update_connect_button(self, state, apbssid):
|
|
|
|
|
""" Update the connection/disconnect button for this entry. """
|
|
|
|
|
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()
|
|
|
|
|
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(language['secured'])
|
|
|
|
|
if not on:
|
|
|
|
|
self.lbl_encryption.set_label(language['unsecured'])
|
|
|
|
|
|
|
|
|
|
def set_channel(self, channel):
|
|
|
|
|
""" Set the channel value for the WirelessNetworkEntry. """
|
|
|
|
|
self.lbl_channel.set_label(language['channel'] + ' ' + str(channel))
|
|
|
|
|
|
|
|
|
|
def format_entry(self, networkid, label):
|
|
|
|
|
""" Helper method for fetching/formatting wireless properties. """
|
|
|
|
|
return noneToBlankString(wireless.GetWirelessProperty(networkid, label))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class WirelessInformationDialog(gtk.Dialog):
|
|
|
|
|
def __init__(self, networkID):
|
|
|
|
|
gtk.Dialog.__init__(self)
|
|
|
|
|
|
|
|
|
|
# Make the combo box.
|
|
|
|
|
self.lbl_strength = gtk.Label()
|
|
|
|
|
self.lbl_strength.set_alignment(0, 0.5)
|
|
|
|
|
self.lbl_encryption = gtk.Label()
|
|
|
|
|
self.lbl_encryption.set_alignment(0, 0.5)
|
|
|
|
|
self.lbl_mac = gtk.Label()
|
|
|
|
|
self.lbl_mac.set_alignment(0, 0.5)
|
|
|
|
|
self.lbl_channel = gtk.Label()
|
|
|
|
|
self.lbl_channel.set_alignment(0, 0.5)
|
|
|
|
|
self.lbl_mode = gtk.Label()
|
|
|
|
|
self.lbl_mode.set_alignment(0, 0.5)
|
|
|
|
|
self.hbox_status = gtk.HBox(False, 5)
|
|
|
|
|
|
|
|
|
|
# Set the values of the network info labels.
|
|
|
|
|
self.set_signal_strength(wireless.GetWirelessProperty(networkID,
|
|
|
|
|
'quality'),
|
|
|
|
|
wireless.GetWirelessProperty(networkID,
|
|
|
|
|
'strength'))
|
|
|
|
|
self.set_mac_address(wireless.GetWirelessProperty(networkID, 'bssid'))
|
|
|
|
|
self.set_mode(wireless.GetWirelessProperty(networkID, 'mode'))
|
|
|
|
|
self.set_channel(wireless.GetWirelessProperty(networkID, 'channel'))
|
|
|
|
|
self.set_encryption(wireless.GetWirelessProperty(networkID,
|
|
|
|
|
'encryption'),
|
|
|
|
|
wireless.GetWirelessProperty(networkID,
|
|
|
|
|
'encryption_method'))
|
|
|
|
|
|
|
|
|
|
self.set_title('Network Information')
|
|
|
|
|
vbox = self.vbox
|
|
|
|
|
self.set_has_separator(False)
|
|
|
|
|
table = gtk.Table(5, 2)
|
|
|
|
|
table.set_col_spacings(12)
|
|
|
|
|
vbox.pack_start(table)
|
|
|
|
|
|
|
|
|
|
# Pack the network status HBox.
|
|
|
|
|
table.attach(LeftAlignedLabel('Signal strength:'), 0, 1, 0, 1)
|
|
|
|
|
table.attach(self.lbl_strength, 1, 2, 0, 1)
|
|
|
|
|
|
|
|
|
|
table.attach(LeftAlignedLabel('Encryption type:'), 0, 1, 1, 2)
|
|
|
|
|
table.attach(self.lbl_encryption, 1, 2, 1, 2)
|
|
|
|
|
|
|
|
|
|
table.attach(LeftAlignedLabel('Access point address:'), 0, 1, 2, 3)
|
|
|
|
|
table.attach(self.lbl_mac, 1, 2, 2, 3)
|
|
|
|
|
|
|
|
|
|
table.attach(LeftAlignedLabel('Mode:'), 0, 1, 3, 4)
|
|
|
|
|
table.attach(self.lbl_mode, 1, 2, 3, 4)
|
|
|
|
|
|
|
|
|
|
table.attach(LeftAlignedLabel('Channel:'), 0, 1, 4, 5)
|
|
|
|
|
table.attach(self.lbl_channel, 1, 2, 4, 5)
|
|
|
|
|
|
|
|
|
|
vbox.show_all()
|
|
|
|
|
|
|
|
|
|
self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
|
|
|
|
|
self.show()
|
|
|
|
|
self.run()
|
|
|
|
|
self.destroy()
|
|
|
|
|
|
|
|
|
|
def set_signal_strength(self, strength, dbm_strength):
|
|
|
|
|
""" Set the signal strength displayed in the WirelessNetworkEntry. """
|
|
|
|
|
if strength is not None:
|
|
|
|
|
strength = int(strength)
|
|
|
|
|
else:
|
|
|
|
|
self.disconnect_button.hide()
|
|
|
|
|
self.connect_button.show()
|
|
|
|
|
strength = -1
|
|
|
|
|
if dbm_strength is not None:
|
|
|
|
|
dbm_strength = int(dbm_strength)
|
|
|
|
|
else:
|
|
|
|
|
dbm_strength = -100
|
|
|
|
|
display_type = daemon.GetSignalDisplayType()
|
|
|
|
|
if daemon.GetWPADriver() == 'ralink legacy' or display_type == 1:
|
|
|
|
|
# Use the -xx dBm signal strength to display a signal icon
|
|
|
|
|
# I'm not sure how accurately the dBm strength is being
|
|
|
|
|
# "converted" to strength bars, so suggestions from people
|
|
|
|
|
# for a better way would be welcome.
|
|
|
|
|
if dbm_strength >= -60:
|
|
|
|
|
signal_img = 'signal-100.png'
|
|
|
|
|
elif dbm_strength >= -70:
|
|
|
|
|
signal_img = 'signal-75.png'
|
|
|
|
|
elif dbm_strength >= -80:
|
|
|
|
|
signal_img = 'signal-50.png'
|
|
|
|
|
else:
|
|
|
|
|
signal_img = 'signal-25.png'
|
|
|
|
|
ending = "dBm"
|
|
|
|
|
disp_strength = str(dbm_strength)
|
|
|
|
|
else:
|
|
|
|
|
# Uses normal link quality, should be fine in most cases
|
|
|
|
|
if strength > 75:
|
|
|
|
|
signal_img = 'signal-100.png'
|
|
|
|
|
elif strength > 50:
|
|
|
|
|
signal_img = 'signal-75.png'
|
|
|
|
|
elif strength > 25:
|
|
|
|
|
signal_img = 'signal-50.png'
|
|
|
|
|
else:
|
|
|
|
|
signal_img = 'signal-25.png'
|
|
|
|
|
ending = "%"
|
|
|
|
|
disp_strength = str(strength)
|
|
|
|
|
self.lbl_strength.set_label(disp_strength + ending)
|
|
|
|
|
|
|
|
|
|
def set_mac_address(self, address):
|
|
|
|
|
""" Set the MAC address for the WirelessNetworkEntry. """
|
|
|
|
|
@@ -923,24 +1064,3 @@ class WirelessNetworkEntry(NetworkEntry):
|
|
|
|
|
def format_entry(self, networkid, label):
|
|
|
|
|
""" Helper method for fetching/formatting wireless properties. """
|
|
|
|
|
return noneToBlankString(wireless.GetWirelessProperty(networkid, label))
|
|
|
|
|
|
|
|
|
|
def edit_scripts(self, widget=None, event=None):
|
|
|
|
|
""" Launch the script editting dialog. """
|
|
|
|
|
cmdend = [os.path.join(wpath.lib, "configscript.py"),
|
|
|
|
|
str(self.networkID), "wireless"]
|
|
|
|
|
if os.getuid() != 0:
|
|
|
|
|
cmdbase = misc.get_sudo_cmd(language['scripts_need_pass'])
|
|
|
|
|
if not cmdbase:
|
|
|
|
|
error(None, language["no_sudo_prog"])
|
|
|
|
|
return
|
|
|
|
|
cmdbase.extend(cmdend)
|
|
|
|
|
misc.LaunchAndWait(cmdbase)
|
|
|
|
|
else:
|
|
|
|
|
misc.LaunchAndWait(cmdend)
|
|
|
|
|
|
|
|
|
|
def update_autoconnect(self, widget=None):
|
|
|
|
|
""" Called when the autoconnect checkbox is toggled. """
|
|
|
|
|
wireless.SetWirelessProperty(self.networkID, "automatic",
|
|
|
|
|
noneToString(self.chkbox_autoconnect.
|
|
|
|
|
get_active()))
|
|
|
|
|
wireless.SaveWirelessNetworkProperty(self.networkID, "automatic")
|
|
|
|
|
|