1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-22 14:07:59 +01:00

Merged with r291 of mainline 1.6.

This commit is contained in:
Andrew Psaltis
2009-02-10 20:55:11 -05:00
8 changed files with 57 additions and 57 deletions

View File

@@ -2,3 +2,4 @@ experimental.wpr
install.log
uninstall.log
.bzrignore
vcsinfo.py

View File

@@ -223,10 +223,7 @@ class appGui(object):
self._do_statusbar_update(*daemon.GetConnectionStatus())
self.wait_for_events(0.1)
if hasattr(gobject, "timeout_add_seconds"):
self.update_cb = gobject.timeout_add_seconds(2, self.update_statusbar)
else:
self.update_cb = gobject.timeout_add(2000, self.update_statusbar)
self.update_cb = misc.timeout_add(2, self.update_statusbar)
self.refresh_clicked()
def handle_connection_results(self, results):
@@ -412,7 +409,7 @@ class appGui(object):
self.connecting = True
if not self.pulse_active:
self.pulse_active = True
gobject.timeout_add(100, self.pulse_progress_bar)
misc.timeout_add(100, self.pulse_progress_bar, milli=True)
gobject.idle_add(self.network_list.set_sensitive, False)
gobject.idle_add(self.status_area.show_all)
if self.statusID:
@@ -715,10 +712,7 @@ class appGui(object):
gobject.idle_add(self.refresh_clicked)
bus.add_signal_receiver(self._do_statusbar_update, 'StatusChanged',
'org.wicd.daemon')
if hasattr(gobject, "timeout_add_seconds"):
self.update_cb = gobject.timeout_add_seconds(2, self.update_statusbar)
else:
self.update_cb = gobject.timeout_add(2000, self.update_statusbar)
self.update_cb = misc.timeout_add(2, self.update_statusbar)
if __name__ == '__main__':

View File

@@ -22,6 +22,7 @@ import locale
import gettext
import sys
import re
import gobject
from threading import Thread
from subprocess import Popen, STDOUT, PIPE, call
from commands import getoutput
@@ -313,16 +314,20 @@ def get_gettext():
# http://www.learningpython.com/2006/12/03/translating-your-pythonpygtk-application/
local_path = wpath.translations
langs = []
osLanguage = os.environ.get('LANGUAGE', None)
if osLanguage:
langs += osLanguage.split(":")
osLanguage = None
osLanguage = os.environ.get('LC_MESSAGES', None)
if osLanguage:
langs += osLanguage.split(":")
try:
lc, encoding = locale.getdefaultlocale()
except ValueError, e:
print str(e)
print "Default locale unavailable, falling back to en_US"
if (lc):
langs = [lc]
osLanguage = os.environ.get('LANGUAGE', None)
if (osLanguage):
langs += osLanguage.split(":")
langs += [lc]
langs += ["en_US"]
lang = gettext.translation('wicd', local_path, languages=langs,
fallback=True)
@@ -405,15 +410,16 @@ def choose_sudo_prog(prog_num=0):
return find_path(sudo_dict[prog_num])
desktop_env = detect_desktop_environment()
env_path = os.environ['PATH'].split(":")
paths = []
if desktop_env == "kde":
paths = []
for p in env_path:
paths.extend([p + '/kdesu', p + '/kdesudo', p + '/ktsuss'])
progs = ["kdesu", "kdesudo", "ktusss"]
else:
paths = []
for p in env_path:
paths.extend([p + '/gksudo', p + "/gksu", p + '/ktsuss'])
progs = ["gksudo", "gksu", "ktsuss"]
for prog in progs:
paths.extend([os.path.join(p, prog) for p in env_path])
for path in paths:
if os.path.exists(path):
return path
@@ -455,6 +461,7 @@ def get_language_list_gui():
language['use_static_dns'] = _('Use Static DNS')
language['use_encryption'] = _('Use Encryption')
language['advanced_settings'] = _('Advanced Settings')
language['properties'] = _('Properties')
language['wired_network'] = _('Wired Network')
language['wired_network_instructions'] = _('To connect to a wired network,'
' you must create a network profile. To create a network profile, type a'
@@ -650,3 +657,12 @@ def threaded(f):
wrapper.__module__ = f.__module__
return wrapper
def timeout_add(time, func, milli=False):
""" Convience function for running a function on a timer. """
if hasattr(gobject, "timeout_add_seconds") and not milli:
return gobject.timeout_add_seconds(time, func)
else:
if not milli: time = time * 1000
return gobject.timeout_add(time, func)

View File

@@ -330,12 +330,8 @@ def err_handle(error):
def add_poll_callback():
global monitor, to_time, update_callback
if hasattr(gobject, "timeout_add_seconds"):
update_callback = gobject.timeout_add_seconds(to_time,
monitor.update_connection_status)
else:
update_callback = gobject.timeout_add(to_time * 1000,
monitor.update_connection_status)
update_callback = misc.timeout_add(to_time,
monitor.update_connection_status)
def main():
""" Starts the connection monitor.

View File

@@ -45,7 +45,7 @@ class AdvancedSettingsDialog(gtk.Dialog):
the WiredSettingsDialog and WirelessSettingsDialog.
"""
gtk.Dialog.__init__(self, title=language['advanced_settings'],
gtk.Dialog.__init__(self, title=language['properties'],
flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_CANCEL,
gtk.RESPONSE_REJECT,
gtk.STOCK_OK,
@@ -149,7 +149,6 @@ class AdvancedSettingsDialog(gtk.Dialog):
self.chkbox_static_dns.set_sensitive(False)
else:
self.chkbox_static_dns.set_sensitive(True)
#self.chkbox_static_dns.set_active(False)
self.txt_ip.set_sensitive(self.chkbox_static_ip.get_active())
self.txt_netmask.set_sensitive(self.chkbox_static_ip.get_active())
@@ -513,18 +512,13 @@ class NetworkEntry(gtk.HBox):
self.advanced_image.set_from_stock(gtk.STOCK_EDIT, 4)
self.advanced_image.set_padding(4, 0)
self.advanced_button.set_alignment(.5, .5)
self.advanced_button.set_label(language['advanced_settings'])
self.advanced_button.set_label(language['properties'])
self.advanced_button.set_image(self.advanced_image)
#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.buttons_hbox, False, False)
#self.vbox_top.pack_end(self.connect_hbox, False, False)
self.expander_vbox.pack_start(self.name_label)
self.expander_vbox.pack_start(self.vbox_top)
self.expander_vbox.pack_start(self.buttons_hbox)
@@ -550,7 +544,6 @@ class WiredNetworkEntry(NetworkEntry):
self.name_label.set_label(language['wired_network'])
#self.reset_static_checkboxes()
self.is_full_gui = True
self.button_add = gtk.Button(stock=gtk.STOCK_ADD)
@@ -759,7 +752,6 @@ class WirelessNetworkEntry(NetworkEntry):
# 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)
if to_bool(self.format_entry(networkID, "automatic")):
self.chkbox_autoconnect.set_active(True)
@@ -813,11 +805,11 @@ class WirelessNetworkEntry(NetworkEntry):
def set_signal_strength(self, strength, dbm_strength):
""" Set the signal strength displayed in the WirelessNetworkEntry. """
if strength is not None:
if strength:
strength = int(strength)
else:
strength = -1
if dbm_strength is not None:
if dbm_strength:
dbm_strength = int(dbm_strength)
else:
dbm_strength = -100

View File

@@ -254,7 +254,6 @@ class ConnectThread(threading.Thread):
"""
is_connecting = None
connecting_thread = None
should_die = False
lock = thread.allocate_lock()

View File

@@ -69,7 +69,7 @@ misc.RenameProcess("wicd-client")
if __name__ == '__main__':
wpath.chdir(__file__)
daemon = wireless = wired = None
daemon = wireless = wired = lost_dbus_id = None
DBUS_AVAIL = False
language = misc.get_language_list_tray()
@@ -664,7 +664,7 @@ Arguments:
""" % wpath.version
def setup_dbus(force=True):
global daemon, wireless, wired, DBUS_AVAIL
global daemon, wireless, wired, DBUS_AVAIL, lost_dbus_id
print "Connecting to daemon..."
try:
dbusmanager.connect_to_dbus()
@@ -681,13 +681,15 @@ def setup_dbus(force=True):
else:
return False
if lost_dbus_id:
gobject.source_remove(lost_dbus_id)
lost_dbus_id = None
dbus_ifaces = dbusmanager.get_dbus_ifaces()
daemon = dbus_ifaces['daemon']
wireless = dbus_ifaces['wireless']
wired = dbus_ifaces['wired']
DBUS_AVAIL = True
print "Connected."
return True
def on_exit():
@@ -698,11 +700,13 @@ def on_exit():
pass
def handle_no_dbus():
global DBUS_AVAIL
""" Called when dbus announces its shutting down. """
global DBUS_AVAIL, lost_dbus_id
DBUS_AVAIL = False
gui.handle_no_dbus(from_tray=True)
print "Wicd daemon is shutting down!"
error(None, language['lost_dbus'], block=False)
lost_dbus_id = misc.timeout_add(5, lambda:error(None, language['lost_dbus'],
block=False))
return False
def main(argv):

View File

@@ -921,6 +921,7 @@ class WirelessDaemon(dbus.service.Object):
self.wifi = wifi
self._debug_mode = debug
self.forced_disconnect = False
self._scanning = False
self.LastScan = []
self.config = ConfigManager(os.path.join(wpath.etc,
"wireless-settings.conf"),
@@ -949,6 +950,10 @@ class WirelessDaemon(dbus.service.Object):
be done synchronously.
"""
if self._scanning:
if self.debug_mode:
print "scan already in progress, skipping"
return False
if self.debug_mode:
print 'scanning start'
self.SendStartScanSignal()
@@ -956,6 +961,7 @@ class WirelessDaemon(dbus.service.Object):
self._sync_scan()
else:
self._async_scan()
return True
@misc.threaded
def _async_scan(self):
@@ -1006,10 +1012,7 @@ class WirelessDaemon(dbus.service.Object):
value = self.LastScan[networkid].get(property)
except IndexError:
return ""
try:
value = misc.to_unicode(value)
except:
pass
value = misc.to_unicode(value)
return value
@dbus.service.method('org.wicd.daemon.wireless')
@@ -1021,14 +1024,13 @@ class WirelessDaemon(dbus.service.Object):
+ " permitted."
return False
self.LastScan[networkid][property] = misc.Noneify(value)
#end function SetProperty
@dbus.service.method('org.wicd.daemon.wireless')
def DetectWirelessInterface(self):
""" Returns an automatically detected wireless interface. """
iface = self.wifi.DetectWirelessInterface()
if iface:
print 'automatically detected wireless interface ' + iface
print 'Automatically detected wireless interface ' + iface
else:
print "Couldn't detect a wireless interface."
return str(iface)
@@ -1251,12 +1253,12 @@ class WirelessDaemon(dbus.service.Object):
@dbus.service.signal(dbus_interface='org.wicd.daemon.wireless', signature='')
def SendStartScanSignal(self):
""" Emits a signal announcing a scan has started. """
pass
self._scanning = True
@dbus.service.signal(dbus_interface='org.wicd.daemon.wireless', signature='')
def SendEndScanSignal(self):
""" Emits a signal announcing a scan has finished. """
pass
self._scanning = False
def _wireless_autoconnect(self, fresh=True):
""" Attempts to autoconnect to a wireless network. """
@@ -1266,9 +1268,7 @@ class WirelessDaemon(dbus.service.Object):
print 'Autoconnect failed because wireless interface returned None'
return
if fresh:
print 'start scan'
self.Scan(sync=True)
print 'end scan'
for x, network in enumerate(self.LastScan):
if bool(network["has_profile"]):
@@ -1674,10 +1674,8 @@ def main(argv):
wicd_bus = dbus.service.BusName('org.wicd.daemon', bus=bus)
daemon = WicdDaemon(wicd_bus, auto_connect=auto_connect)
if not no_poll:
(child_pid, x, x, x) = gobject.spawn_async(
[misc.find_path("python"), "-O", os.path.join(wpath.lib, "monitor.py")],
flags=gobject.SPAWN_CHILD_INHERITS_STDIN
)
(child_pid, x, y, z) = gobject.spawn_async(
[misc.find_path("python"), "-O", os.path.join(wpath.lib, "monitor.py")])
signal.signal(signal.SIGTERM, sigterm_caught)
# Enter the main loop