1
0
mirror of https://github.com/gryf/wicd.git synced 2026-01-08 06:44:20 +01:00

Add a domain entry for dns settings.

Display an error if global dns is enabled for a network, but global dns entries aren't entered in the general preferences window.
This commit is contained in:
Dan O'Reilly
2008-12-30 23:20:00 -05:00
parent ec682a2fce
commit 997e523722
9 changed files with 134 additions and 66 deletions

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.5 on Sat Dec 27 18:31:41 2008 --> <!--Generated with glade3 3.4.5 on Tue Dec 30 22:52:49 2008 -->
<glade-interface> <glade-interface>
<widget class="GtkWindow" id="window1"> <widget class="GtkWindow" id="window1">
<property name="width_request">450</property> <property name="width_request">450</property>
@@ -424,7 +424,7 @@
<child> <child>
<widget class="GtkTable" id="table1"> <widget class="GtkTable" id="table1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="n_rows">16</property> <property name="n_rows">17</property>
<property name="n_columns">2</property> <property name="n_columns">2</property>
<property name="column_spacing">4</property> <property name="column_spacing">4</property>
<property name="row_spacing">4</property> <property name="row_spacing">4</property>
@@ -458,8 +458,8 @@
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">6</property> <property name="top_attach">7</property>
<property name="bottom_attach">7</property> <property name="bottom_attach">8</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@@ -471,8 +471,8 @@
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">7</property> <property name="top_attach">8</property>
<property name="bottom_attach">8</property> <property name="bottom_attach">9</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@@ -484,8 +484,8 @@
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">8</property> <property name="top_attach">9</property>
<property name="bottom_attach">9</property> <property name="bottom_attach">10</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@@ -537,8 +537,8 @@
</child> </child>
</widget> </widget>
<packing> <packing>
<property name="top_attach">6</property> <property name="top_attach">7</property>
<property name="bottom_attach">7</property> <property name="bottom_attach">8</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@@ -555,8 +555,8 @@
</child> </child>
</widget> </widget>
<packing> <packing>
<property name="top_attach">7</property> <property name="top_attach">8</property>
<property name="bottom_attach">8</property> <property name="bottom_attach">9</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@@ -573,8 +573,8 @@
</child> </child>
</widget> </widget>
<packing> <packing>
<property name="top_attach">8</property> <property name="top_attach">9</property>
<property name="bottom_attach">9</property> <property name="bottom_attach">10</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@@ -586,8 +586,8 @@
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">9</property> <property name="top_attach">10</property>
<property name="bottom_attach">10</property> <property name="bottom_attach">11</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@@ -604,8 +604,8 @@
</child> </child>
</widget> </widget>
<packing> <packing>
<property name="top_attach">9</property> <property name="top_attach">10</property>
<property name="bottom_attach">10</property> <property name="bottom_attach">11</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@@ -692,8 +692,8 @@
</widget> </widget>
<packing> <packing>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">10</property> <property name="top_attach">11</property>
<property name="bottom_attach">11</property> <property name="bottom_attach">12</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@@ -715,8 +715,8 @@
</widget> </widget>
<packing> <packing>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">11</property> <property name="top_attach">12</property>
<property name="bottom_attach">12</property> <property name="bottom_attach">13</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@@ -738,8 +738,8 @@
</widget> </widget>
<packing> <packing>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">12</property> <property name="top_attach">13</property>
<property name="bottom_attach">13</property> <property name="bottom_attach">14</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@@ -760,8 +760,8 @@
</widget> </widget>
<packing> <packing>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">13</property> <property name="top_attach">14</property>
<property name="bottom_attach">14</property> <property name="bottom_attach">15</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@@ -774,8 +774,8 @@
</widget> </widget>
<packing> <packing>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">14</property> <property name="top_attach">15</property>
<property name="bottom_attach">15</property> <property name="bottom_attach">16</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@@ -795,8 +795,38 @@
</widget> </widget>
<packing> <packing>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">15</property> <property name="top_attach">16</property>
<property name="bottom_attach">16</property> <property name="bottom_attach">17</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="pref_dns_dom_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment23">
<property name="visible">True</property>
<property name="left_padding">24</property>
<child>
<widget class="GtkLabel" id="pref_dns_dom_label">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">DNS domain:</property>
</widget>
</child>
</widget>
<packing>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>

View File

@@ -26,7 +26,7 @@ reusable for other purposes as well.
from ConfigParser import RawConfigParser from ConfigParser import RawConfigParser
from wicd.misc import stringToNone from wicd.misc import stringToNone, Noneify
class ConfigManager(RawConfigParser): class ConfigManager(RawConfigParser):
@@ -89,12 +89,12 @@ class ConfigManager(RawConfigParser):
ret = default ret = default
else: else:
ret = None ret = None
# Try to intelligently handle the type of the return value. # Try to intelligently handle the type of the return value.
try: try:
ret = int(ret) ret = int(ret)
except (ValueError, TypeError): except (ValueError, TypeError):
ret = stringToNone(ret) ret = Noneify(ret)
return ret return ret
def get(self, *args, **kargs): def get(self, *args, **kargs):

View File

@@ -303,9 +303,9 @@ class appGui(object):
bus.add_signal_receiver(handle_no_dbus, "DaemonClosing", bus.add_signal_receiver(handle_no_dbus, "DaemonClosing",
"org.wicd.daemon") "org.wicd.daemon")
try: try:
gobject.timeout_add_seconds(1, self.update_statusbar) gobject.timeout_add_seconds(2, self.update_statusbar)
except: except:
gobject.timeout_add(1000, self.update_statusbar) gobject.timeout_add(2000, self.update_statusbar)
self.refresh_clicked() self.refresh_clicked()
@@ -689,6 +689,7 @@ class appGui(object):
not entry.chkbox_global_dns.get_active(): not entry.chkbox_global_dns.get_active():
entry.set_net_prop('use_static_dns', True) entry.set_net_prop('use_static_dns', True)
entry.set_net_prop('use_global_dns', False) entry.set_net_prop('use_global_dns', False)
entry.set_net_prop('dns_domain', noneToString(entry.txt_domain.get_text()))
entry.set_net_prop("search_domain", noneToString(entry.txt_search_dom.get_text())) entry.set_net_prop("search_domain", noneToString(entry.txt_search_dom.get_text()))
entry.set_net_prop("dns1", noneToString(entry.txt_dns_1.get_text())) entry.set_net_prop("dns1", noneToString(entry.txt_dns_1.get_text()))
entry.set_net_prop("dns2", noneToString(entry.txt_dns_2.get_text())) entry.set_net_prop("dns2", noneToString(entry.txt_dns_2.get_text()))
@@ -700,6 +701,7 @@ class appGui(object):
else: else:
entry.set_net_prop('use_static_dns', False) entry.set_net_prop('use_static_dns', False)
entry.set_net_prop('use_global_dns', False) entry.set_net_prop('use_global_dns', False)
entry.set_net_prop('dns_domain', '')
entry.set_net_prop("search_domain", '') entry.set_net_prop("search_domain", '')
entry.set_net_prop("dns1", '') entry.set_net_prop("dns1", '')
entry.set_net_prop("dns2", '') entry.set_net_prop("dns2", '')

View File

@@ -498,10 +498,12 @@ def get_language_list_gui():
language["route_flush"] = _("Route Table Flushing") language["route_flush"] = _("Route Table Flushing")
language["backend"] = _("Backend") language["backend"] = _("Backend")
language["backend_alert"] = _("Changes to your backend won't occur until the daemon is restarted.") language["backend_alert"] = _("Changes to your backend won't occur until the daemon is restarted.")
language['search_domain'] = _("Search Domain") language['dns_domain'] = _("DNS domain")
language['search_domain'] = _("Search domain")
language['global_dns_not_enabled'] = _("Global DNS has not been enabled in general preferences.")
language['scripts_need_pass'] = _('You must enter your password to configure scripts') language['scripts_need_pass'] = _('You must enter your password to configure scripts')
language['no_sudo_prog'] = _("Could not find a graphical sudo program. The script editor could not be launched." + language['no_sudo_prog'] = _("Could not find a graphical sudo program. The script editor could not be launched." +
"You'll have to edit scripts directly your configuration file.") " You'll have to edit scripts directly your configuration file.")
language['0'] = _('0') language['0'] = _('0')
language['1'] = _('1') language['1'] = _('1')

View File

@@ -115,6 +115,7 @@ class AdvancedSettingsDialog(gtk.Dialog):
self.txt_netmask = LabelEntry(language['netmask']) self.txt_netmask = LabelEntry(language['netmask'])
self.txt_gateway = LabelEntry(language['gateway']) self.txt_gateway = LabelEntry(language['gateway'])
self.txt_search_dom = LabelEntry(language['search_domain']) self.txt_search_dom = LabelEntry(language['search_domain'])
self.txt_domain = LabelEntry(language['dns_domain'])
self.txt_dns_1 = LabelEntry(language['dns'] + ' ' + language['1']) self.txt_dns_1 = LabelEntry(language['dns'] + ' ' + language['1'])
self.txt_dns_2 = LabelEntry(language['dns'] + ' ' + language['2']) self.txt_dns_2 = LabelEntry(language['dns'] + ' ' + language['2'])
self.txt_dns_3 = LabelEntry(language['dns'] + ' ' + language['3']) self.txt_dns_3 = LabelEntry(language['dns'] + ' ' + language['3'])
@@ -125,16 +126,19 @@ class AdvancedSettingsDialog(gtk.Dialog):
self.hbox_dns.pack_start(self.chkbox_static_dns) self.hbox_dns.pack_start(self.chkbox_static_dns)
self.hbox_dns.pack_start(self.chkbox_global_dns) self.hbox_dns.pack_start(self.chkbox_global_dns)
assert(isinstance(self.vbox, gtk.VBox))
self.vbox.pack_start(self.chkbox_static_ip, fill=False, expand=False) self.vbox.pack_start(self.chkbox_static_ip, fill=False, expand=False)
self.vbox.pack_start(self.txt_ip, fill=False, expand=False) self.vbox.pack_start(self.txt_ip, fill=False, expand=False)
self.vbox.pack_start(self.txt_netmask, fill=False, expand=False) self.vbox.pack_start(self.txt_netmask, fill=False, expand=False)
self.vbox.pack_start(self.txt_gateway, fill=False, expand=False) self.vbox.pack_start(self.txt_gateway, fill=False, expand=False)
self.vbox.pack_start(self.hbox_dns, fill=False, expand=False) self.vbox.pack_start(self.hbox_dns, fill=False, expand=False)
self.vbox.pack_start(self.txt_domain, fill=False, expand=False)
self.vbox.pack_start(self.txt_search_dom, fill=False, expand=False) self.vbox.pack_start(self.txt_search_dom, fill=False, expand=False)
self.vbox.pack_start(self.txt_dns_1, fill=False, expand=False) 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_2, fill=False, expand=False)
self.vbox.pack_start(self.txt_dns_3, fill=False, expand=False) self.vbox.pack_start(self.txt_dns_3, fill=False, expand=False)
# Connect the events to the actions # Connect the events to the actions
self.chkbox_static_ip.connect("toggled", self.toggle_ip_checkbox) self.chkbox_static_ip.connect("toggled", self.toggle_ip_checkbox)
self.chkbox_static_dns.connect("toggled", self.toggle_dns_checkbox) self.chkbox_static_dns.connect("toggled", self.toggle_dns_checkbox)
@@ -206,7 +210,7 @@ class AdvancedSettingsDialog(gtk.Dialog):
self.chkbox_global_dns.set_sensitive(self.chkbox_static_dns. self.chkbox_global_dns.set_sensitive(self.chkbox_static_dns.
get_active()) get_active())
l = [self.txt_dns_1, self.txt_dns_2, self.txt_dns_3, l = [self.txt_dns_1, self.txt_dns_2, self.txt_dns_3, self.txt_domain,
self.txt_search_dom] self.txt_search_dom]
if self.chkbox_static_dns.get_active(): if self.chkbox_static_dns.get_active():
# If global dns is on, don't use local dns # If global dns is on, don't use local dns
@@ -219,9 +223,13 @@ class AdvancedSettingsDialog(gtk.Dialog):
def toggle_global_dns_checkbox(self, widget=None): def toggle_global_dns_checkbox(self, widget=None):
""" Set the DNS entries' sensitivity based on the Global checkbox. """ """ Set the DNS entries' sensitivity based on the Global checkbox. """
global_dns_active = daemon.GetUseGlobalDNS()
if not global_dns_active and self.chkbox_global_dns.get_active():
error(None, language['global_dns_not_enabled'])
self.chkbox_global_dns.set_active(False)
if daemon.GetUseGlobalDNS() and self.chkbox_static_dns.get_active(): if daemon.GetUseGlobalDNS() and self.chkbox_static_dns.get_active():
for w in [self.txt_dns_1, self.txt_dns_2, for w in [self.txt_dns_1, self.txt_dns_2, self.txt_dns_3,
self.txt_dns_3, self.txt_search_dom]: self.txt_domain, self.txt_search_dom]:
w.set_sensitive(not self.chkbox_global_dns.get_active()) w.set_sensitive(not self.chkbox_global_dns.get_active())
def destroy_called(self, *args): def destroy_called(self, *args):
@@ -251,6 +259,7 @@ class WiredSettingsDialog(AdvancedSettingsDialog):
self.txt_dns_1.set_text(self.format_entry("dns1")) self.txt_dns_1.set_text(self.format_entry("dns1"))
self.txt_dns_2.set_text(self.format_entry("dns2")) self.txt_dns_2.set_text(self.format_entry("dns2"))
self.txt_dns_3.set_text(self.format_entry("dns3")) self.txt_dns_3.set_text(self.format_entry("dns3"))
self.txt_domain.set_text(self.format_entry("dns_domain"))
self.txt_search_dom.set_text(self.format_entry("search_domain")) self.txt_search_dom.set_text(self.format_entry("search_domain"))
self.chkbox_global_dns.set_active(bool(wired.GetWiredProperty("use_global_dns"))) self.chkbox_global_dns.set_active(bool(wired.GetWiredProperty("use_global_dns")))
self.reset_static_checkboxes() self.reset_static_checkboxes()
@@ -335,6 +344,7 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
self.txt_dns_1.set_text(self.format_entry(networkID, "dns1")) self.txt_dns_1.set_text(self.format_entry(networkID, "dns1"))
self.txt_dns_2.set_text(self.format_entry(networkID, "dns2")) self.txt_dns_2.set_text(self.format_entry(networkID, "dns2"))
self.txt_dns_3.set_text(self.format_entry(networkID, "dns3")) self.txt_dns_3.set_text(self.format_entry(networkID, "dns3"))
self.txt_domain.set_text(self.format_entry(networkID, "dns_domain"))
self.txt_search_dom.set_text(self.format_entry(networkID, "search_domain")) self.txt_search_dom.set_text(self.format_entry(networkID, "search_domain"))
self.reset_static_checkboxes() self.reset_static_checkboxes()

View File

@@ -109,6 +109,7 @@ class Controller(object):
self.global_dns_1 = None self.global_dns_1 = None
self.global_dns_2 = None self.global_dns_2 = None
self.global_dns_3 = None self.global_dns_3 = None
self.global_dns_dom = None
self.global_search_dom = None self.global_search_dom = None
self._dhcp_client = None self._dhcp_client = None
self._flush_tool = None self._flush_tool = None
@@ -226,7 +227,7 @@ class ConnectThread(threading.Thread):
lock = thread.allocate_lock() lock = thread.allocate_lock()
def __init__(self, network, interface_name, before_script, after_script, def __init__(self, network, interface_name, before_script, after_script,
disconnect_script, gdns1, gdns2, gdns3, gsearch_dom, disconnect_script, gdns1, gdns2, gdns3, gdns_dom, gsearch_dom,
iface, debug): iface, debug):
""" Initialise the required object variables and the thread. """ Initialise the required object variables and the thread.
@@ -258,6 +259,7 @@ class ConnectThread(threading.Thread):
self.global_dns_1 = gdns1 self.global_dns_1 = gdns1
self.global_dns_2 = gdns2 self.global_dns_2 = gdns2
self.global_dns_3 = gdns3 self.global_dns_3 = gdns3
self.global_dns_dom = gdns_dom
self.global_search_dom = gsearch_dom self.global_search_dom = gsearch_dom
self.iface = iface self.iface = iface
@@ -383,16 +385,18 @@ class ConnectThread(threading.Thread):
""" """
if self.network.get('use_global_dns'): if self.network.get('use_global_dns'):
BACKEND.SetDNS(misc.Noneify(self.global_dns_1), BACKEND.SetDNS(misc.Noneify(self.global_dns_1),
misc.Noneify(self.global_dns_2), misc.Noneify(self.global_dns_2),
misc.Noneify(self.global_dns_3), misc.Noneify(self.global_dns_3),
misc.Noneify(self.global_search_dom)) misc.Noneify(self.global_dns_dom),
misc.Noneify(self.global_search_dom))
elif self.network.get('use_static_dns') and (self.network.get('dns1') or elif self.network.get('use_static_dns') and (self.network.get('dns1') or
self.network.get('dns2') or self.network.get('dns3')): self.network.get('dns2') or self.network.get('dns3')):
self.SetStatus('setting_static_dns') self.SetStatus('setting_static_dns')
BACKEND.SetDNS(self.network.get('dns1'), BACKEND.SetDNS(self.network.get('dns1'),
self.network.get('dns2'), self.network.get('dns2'),
self.network.get('dns3'), self.network.get('dns3'),
self.network.get('search_domain')) self.network.get('dns_domain'),
self.network.get('search_domain'))
@abortable @abortable
def release_dhcp_clients(self, iface): def release_dhcp_clients(self, iface):
@@ -543,8 +547,8 @@ class Wireless(Controller):
self.connecting_thread = WirelessConnectThread(network, self.connecting_thread = WirelessConnectThread(network,
self.wireless_interface, self.wpa_driver, self.before_script, self.wireless_interface, self.wpa_driver, self.before_script,
self.after_script, self.disconnect_script, self.global_dns_1, self.after_script, self.disconnect_script, self.global_dns_1,
self.global_dns_2, self.global_dns_3, self.global_search_dom, self.global_dns_2, self.global_dns_3, self.global_dns_dom,
self.wiface, debug) self.global_search_dom, self.wiface, debug)
self.connecting_thread.setDaemon(True) self.connecting_thread.setDaemon(True)
self.connecting_thread.start() self.connecting_thread.start()
return True return True
@@ -673,7 +677,7 @@ class WirelessConnectThread(ConnectThread):
def __init__(self, network, wireless, wpa_driver, before_script, def __init__(self, network, wireless, wpa_driver, before_script,
after_script, disconnect_script, gdns1, gdns2, gdns3, after_script, disconnect_script, gdns1, gdns2, gdns3,
gsearch_dom, wiface, debug=False): gdns_dom, gsearch_dom, wiface, debug=False):
""" Initialise the thread with network information. """ Initialise the thread with network information.
Keyword arguments: Keyword arguments:
@@ -690,7 +694,7 @@ class WirelessConnectThread(ConnectThread):
""" """
ConnectThread.__init__(self, network, wireless, before_script, ConnectThread.__init__(self, network, wireless, before_script,
after_script, disconnect_script, gdns1, gdns2, after_script, disconnect_script, gdns1, gdns2,
gdns3, gsearch_dom, wiface, debug) gdns3, gdns_dom, gsearch_dom, wiface, debug)
self.wpa_driver = wpa_driver self.wpa_driver = wpa_driver
@@ -856,7 +860,8 @@ class Wired(Controller):
self.connecting_thread = WiredConnectThread(network, self.connecting_thread = WiredConnectThread(network,
self.wired_interface, self.before_script, self.after_script, self.wired_interface, self.before_script, self.after_script,
self.disconnect_script, self.global_dns_1, self.global_dns_2, self.disconnect_script, self.global_dns_1, self.global_dns_2,
self.global_dns_3, self.global_search_dom, self.liface, debug) self.global_dns_3, self.global_dns_dom, self.global_search_dom,
self.liface, debug)
self.connecting_thread.setDaemon(True) self.connecting_thread.setDaemon(True)
self.connecting_thread.start() self.connecting_thread.start()
return self.connecting_thread return self.connecting_thread
@@ -877,8 +882,8 @@ class WiredConnectThread(ConnectThread):
""" """
def __init__(self, network, wired, before_script, after_script, def __init__(self, network, wired, before_script, after_script,
disconnect_script, gdns1, gdns2, gdns3, gsearch_dom, liface, disconnect_script, gdns1, gdns2, gdns3, gdns_dom, gsearch_dom,
debug=False): liface, debug=False):
""" Initialise the thread with network information. """ Initialise the thread with network information.
Keyword arguments: Keyword arguments:
@@ -895,7 +900,7 @@ class WiredConnectThread(ConnectThread):
""" """
ConnectThread.__init__(self, network, wired, before_script, ConnectThread.__init__(self, network, wired, before_script,
after_script, disconnect_script, gdns1, gdns2, after_script, disconnect_script, gdns1, gdns2,
gdns3, gsearch_dom, liface, debug) gdns3, gdns_dom, gsearch_dom, liface, debug)
def run(self): def run(self):
""" The main function of the connection thread. """ The main function of the connection thread.

View File

@@ -102,17 +102,20 @@ class PreferencesDialog(object):
self.useGlobalDNSCheckbox.connect("toggled", checkboxTextboxToggle, self.useGlobalDNSCheckbox.connect("toggled", checkboxTextboxToggle,
(self.dns1Entry, self.dns2Entry, (self.dns1Entry, self.dns2Entry,
self.dns3Entry, self.searchDomEntry)) self.dns3Entry, self.dnsDomEntry,
self.searchDomEntry))
dns_addresses = daemon.GetGlobalDNSAddresses() dns_addresses = daemon.GetGlobalDNSAddresses()
self.useGlobalDNSCheckbox.set_active(daemon.GetUseGlobalDNS()) self.useGlobalDNSCheckbox.set_active(daemon.GetUseGlobalDNS())
self.dns1Entry.set_text(noneToBlankString(dns_addresses[0])) self.dns1Entry.set_text(noneToBlankString(dns_addresses[0]))
self.dns2Entry.set_text(noneToBlankString(dns_addresses[1])) self.dns2Entry.set_text(noneToBlankString(dns_addresses[1]))
self.dns3Entry.set_text(noneToBlankString(dns_addresses[2])) self.dns3Entry.set_text(noneToBlankString(dns_addresses[2]))
self.searchDomEntry.set_text(noneToBlankString(dns_addresses[3])) self.dnsDomEntry.set_text(noneToBlankString(dns_addresses[3]))
self.searchDomEntry.set_text(noneToBlankString(dns_addresses[4]))
if not daemon.GetUseGlobalDNS(): if not daemon.GetUseGlobalDNS():
self.searchDomEntry.set_sensitive(False) self.searchDomEntry.set_sensitive(False)
self.dnsDomEntry.set_sensitive(False)
self.dns1Entry.set_sensitive(False) self.dns1Entry.set_sensitive(False)
self.dns2Entry.set_sensitive(False) self.dns2Entry.set_sensitive(False)
self.dns3Entry.set_sensitive(False) self.dns3Entry.set_sensitive(False)
@@ -144,7 +147,8 @@ class PreferencesDialog(object):
""" Pushes the selected settings to the daemon. """ """ Pushes the selected settings to the daemon. """
daemon.SetUseGlobalDNS(self.useGlobalDNSCheckbox.get_active()) daemon.SetUseGlobalDNS(self.useGlobalDNSCheckbox.get_active())
daemon.SetGlobalDNS(self.dns1Entry.get_text(), self.dns2Entry.get_text(), daemon.SetGlobalDNS(self.dns1Entry.get_text(), self.dns2Entry.get_text(),
self.dns3Entry.get_text(), self.searchDomEntry.get_text()) self.dns3Entry.get_text(), self.dnsDomEntry.get_text(),
self.searchDomEntry.get_text())
daemon.SetWirelessInterface(self.entryWirelessInterface.get_text()) daemon.SetWirelessInterface(self.entryWirelessInterface.get_text())
daemon.SetWiredInterface(self.entryWiredInterface.get_text()) daemon.SetWiredInterface(self.entryWiredInterface.get_text())
daemon.SetWPADriver(self.wpadrivers[self.wpadrivercombo.get_active()]) daemon.SetWPADriver(self.wpadrivers[self.wpadrivercombo.get_active()])
@@ -305,6 +309,7 @@ class PreferencesDialog(object):
self.useGlobalDNSCheckbox = setup_label("pref_global_check", self.useGlobalDNSCheckbox = setup_label("pref_global_check",
'use_global_dns') 'use_global_dns')
self.searchDomEntry = self.wTree.get_widget("pref_search_dom_entry") self.searchDomEntry = self.wTree.get_widget("pref_search_dom_entry")
self.dnsDomEntry = self.wTree.get_widget("pref_dns_dom_entry")
self.dns1Entry = self.wTree.get_widget("pref_dns1_entry") self.dns1Entry = self.wTree.get_widget("pref_dns1_entry")
self.dns2Entry = self.wTree.get_widget("pref_dns2_entry") self.dns2Entry = self.wTree.get_widget("pref_dns2_entry")
self.dns3Entry = self.wTree.get_widget("pref_dns3_entry") self.dns3Entry = self.wTree.get_widget("pref_dns3_entry")

View File

@@ -166,27 +166,35 @@ class WicdDaemon(dbus.service.Object):
self.wired.use_global_dns = use self.wired.use_global_dns = use
@dbus.service.method('org.wicd.daemon') @dbus.service.method('org.wicd.daemon')
def SetGlobalDNS(self, dns1=None, dns2=None, dns3=None, search_dom=None): def SetGlobalDNS(self, dns1=None, dns2=None, dns3=None,
dns_dom =None, search_dom=None):
""" Sets the global dns addresses. """ """ Sets the global dns addresses. """
print "setting global dns" print "setting global dns"
self.config.set("Settings", "global_dns_1", misc.noneToString(dns1), True) self.config.set("Settings", "global_dns_1", misc.noneToString(dns1))
self.dns1 = dns1 self.dns1 = dns1
self.wifi.global_dns_1 = dns1 self.wifi.global_dns_1 = dns1
self.wired.global_dns_1 = dns1 self.wired.global_dns_1 = dns1
self.config.set("Settings", "global_dns_2", misc.noneToString(dns2), True) self.config.set("Settings", "global_dns_2", misc.noneToString(dns2))
self.dns2 = dns2 self.dns2 = dns2
self.wifi.global_dns_2 = dns2 self.wifi.global_dns_2 = dns2
self.wired.global_dns_2 = dns2 self.wired.global_dns_2 = dns2
self.config.set("Settings", "global_dns_3", misc.noneToString(dns3), True) self.config.set("Settings", "global_dns_3", misc.noneToString(dns3))
self.dns3 = dns3 self.dns3 = dns3
self.wifi.global_dns_3 = dns3 self.wifi.global_dns_3 = dns3
self.wired.global_dns_3 = dns3 self.wired.global_dns_3 = dns3
self.config.set("Settings", "global_search_dom", misc.noneToString(search_dom), True) self.config.set("Settings", "global_dns_dom", misc.noneToString(dns_dom))
self.dns_dom = dns_dom
self.wifi.dns_dom = dns_dom
self.wired.dns_dom = dns_dom
self.config.set("Settings", "global_search_dom", misc.noneToString(search_dom))
self.search_dom = search_dom self.search_dom = search_dom
self.wifi.global_search_dom = search_dom self.wifi.global_search_dom = search_dom
self.wired.global_search_dom = search_dom self.wired.global_search_dom = search_dom
print 'global dns servers are', dns1, dns2, dns3 print 'global dns servers are', dns1, dns2, dns3
print 'domain is %s' % dns_dom
print 'search domain is %s' % search_dom print 'search domain is %s' % search_dom
self.config.write()
@dbus.service.method('org.wicd.daemon') @dbus.service.method('org.wicd.daemon')
def SetBackend(self, backend): def SetBackend(self, backend):
@@ -340,7 +348,8 @@ class WicdDaemon(dbus.service.Object):
def GetGlobalDNSAddresses(self): def GetGlobalDNSAddresses(self):
""" Returns the global dns addresses. """ """ Returns the global dns addresses. """
return (misc.noneToString(self.dns1), misc.noneToString(self.dns2), return (misc.noneToString(self.dns1), misc.noneToString(self.dns2),
misc.noneToString(self.dns3), misc.noneToString(self.search_dom)) misc.noneToString(self.dns3), misc.noneToString(self.dns_dom),
misc.noneToString(self.search_dom))
@dbus.service.method('org.wicd.daemon') @dbus.service.method('org.wicd.daemon')
def CheckIfConnecting(self): def CheckIfConnecting(self):
@@ -798,8 +807,9 @@ class WicdDaemon(dbus.service.Object):
dns1 = app_conf.get("Settings", "global_dns_1", default='None') dns1 = app_conf.get("Settings", "global_dns_1", default='None')
dns2 = app_conf.get("Settings", "global_dns_2", default='None') dns2 = app_conf.get("Settings", "global_dns_2", default='None')
dns3 = app_conf.get("Settings", "global_dns_3", default='None') dns3 = app_conf.get("Settings", "global_dns_3", default='None')
dns_dom =app_conf.get("Settings", "global_dns_dom", default='None')
search_dom = app_conf.get("Settings", "global_search_dom", default='None') search_dom = app_conf.get("Settings", "global_search_dom", default='None')
self.SetGlobalDNS(dns1, dns2, dns3, search_dom) self.SetGlobalDNS(dns1, dns2, dns3, dns_dom, search_dom)
self.SetAutoReconnect(app_conf.get("Settings", "auto_reconnect", self.SetAutoReconnect(app_conf.get("Settings", "auto_reconnect",
default=True)) default=True))
self.SetDebugMode(app_conf.get("Settings", "debug_mode", default=False)) self.SetDebugMode(app_conf.get("Settings", "debug_mode", default=False))

View File

@@ -57,7 +57,7 @@ def _sanitize_string_strict(string):
else: else:
return string return string
def SetDNS(dns1=None, dns2=None, dns3=None, search_dom=None): def SetDNS(dns1=None, dns2=None, dns3=None, dns_dom=None, search_dom=None):
""" Set the DNS of the system to the specified DNS servers. """ Set the DNS of the system to the specified DNS servers.
Opens up resolv.conf and writes in the nameservers. Opens up resolv.conf and writes in the nameservers.
@@ -66,9 +66,13 @@ def SetDNS(dns1=None, dns2=None, dns3=None, search_dom=None):
dns1 -- IP address of DNS server 1 dns1 -- IP address of DNS server 1
dns2 -- IP address of DNS server 2 dns2 -- IP address of DNS server 2
dns3 -- IP address of DNS server 3 dns3 -- IP address of DNS server 3
dns_dom -- DNS domain
search_dom -- DNS search domain
""" """
resolv = open("/etc/resolv.conf", "w") resolv = open("/etc/resolv.conf", "w")
if dns_dom:
resolv.write("domain %s\n" % dns_dom)
if search_dom: if search_dom:
resolv.write('search %s\n' % search_dom) resolv.write('search %s\n' % search_dom)
for dns in [dns1, dns2, dns3]: for dns in [dns1, dns2, dns3]: