Handle roaming profiles in radar_window.update_auto_profile_order()
[wifi-radar.git] / wifi-radar
blob46ebcef1a0f36627053c0986cee1a4fe0c8df41c
1 #!/usr/bin/python
3 # A wireless profile manager for Linux
5 # Originally created for x1000 Linux:
6 # http://x1000.bitbuilder.com
8 # Created by:
9 # Ahmad Baitalmal <ahmad@baitalmal.com>
11 # Maintained 2006-2009 by:
12 # Brian Elliott Finley <brian@thefinleys.com>
14 # Maintained by:
15 # Sean Robinson <seankrobinson@gmail.com>
17 # License:
18 # GPL
20 # http://wifi-radar.berlios.de
22 # See CREDITS file for more contributors.
23 # See ChangeLog file for, well, changes.
25 # NOTE: Remove the '-OO' from '#!/usr/bin/python -OO' in the first line to
26 # turn on console debugging.
28 import ConfigParser
29 import errno
30 import gtk
31 import logging
32 import logging.handlers
33 import os
34 import Queue
35 import re
36 import string
37 import sys
38 import threading
39 from signal import SIGTERM
40 from subprocess import call, Popen, PIPE
41 from time import sleep
42 from types import *
44 WIFI_RADAR_VERSION = "0.0.0"
47 # Where the conf file should live could be different for your distro. Please change
48 # at install time with "make install sysconfdir=/etc/wifi-radar" or similar. -BEF-
50 CONF_FILE = "/etc/wifi-radar/wifi-radar.conf"
52 os.environ['LC_MESSAGES'] = 'C'
55 ####################################################################################################
56 ####################################################################################################
58 # Sets the interface to the specified network device
60 #Parameters:
62 # 'device' -- string - The network device to use
64 #Returns:
66 # nothing
67 def set_network_device( device ):
68 #print "set_network_device: ", device
69 if device != "auto_detect":
70 confFile.set_opt('DEFAULT.interface', device)
71 else: # auto detect network device
72 # Get a list of 802.11 enabled devices by parsing the output of iwconfig.
73 # If no devices are found, default to eth1.
74 # call iwconfig command and read output
75 iwconfig_info = Popen(confFile.get_opt('DEFAULT.iwconfig_command'), shell=True, stdout=PIPE).stdout
76 wireless_devices = [ (x[0:x.find(" ")]) for x in iwconfig_info if("ESSID" in x)]
77 if len(wireless_devices) > 0:
78 confFile.set_opt('DEFAULT.interface', wireless_devices[0])
79 #else:
80 #print "No wifi-device found. Exiting."
81 #sys.exit()
83 # Return a blank profile
85 #Parameters:
87 # none
89 #Returns:
91 # dictionary -- An AP profile with defaults set.
92 def get_new_profile():
93 return { 'known': False,
94 'available': False,
95 'encrypted': False,
96 'essid': '',
97 'bssid': '',
98 'roaming': False,
99 'protocol': 'g',
100 'signal': 0,
101 'channel': 'auto',
102 'con_prescript': '',
103 'con_postscript': '',
104 'dis_prescript': '',
105 'dis_postscript': '',
106 'key': '',
107 'mode': 'auto',
108 'security': '',
109 'use_wpa': False,
110 'wpa_driver': '',
111 'use_dhcp': True,
112 'ip': '',
113 'netmask': '',
114 'gateway': '',
115 'domain': '',
116 'dns1': '',
117 'dns2': ''
120 # Combine essid and bssid to make a config file section name
122 #Parameters:
124 # 'essid' -- string - AP ESSID
126 # 'bssid' -- string - AP BSSID
128 #Returns:
130 # string -- the bssid concatenated to a colon, concatenated to the essid
131 def make_section_name( essid, bssid ):
132 return essid + ':' + bssid
134 # Split a config file section name into an essid and a bssid
136 #Parameters:
138 # 'section' -- string - Config file section name
140 #Returns:
142 # list -- the essid and bssid
143 def split_section_name( section ):
144 parts = re.split(':', section)
145 return [ ':'.join(parts[0:len(parts)-6]), ':'.join(parts[len(parts)-6:len(parts)]) ]
147 # Run commands through the shell
149 #Parameters:
151 # 'command' -- tuple - The command and arguments to run.
153 # 'environment' -- dictionary - Environment variables (as keys) and their values.
155 #Returns:
157 # boolean -- True on success, otherwise, False
158 def shellcmd( command, environment = None ):
159 try:
160 env_tmp = os.environ
161 env_tmp.update(environment)
162 command = ' '.join(command)
163 return_code = call(command, shell=True, env=env_tmp)
164 if return_code >= 0:
165 return True
166 else:
167 print >>sys.stderr, "Child was terminated by signal", -return_code
168 except OSError, exception:
169 print >>sys.stderr, "Execution failed:", exception
170 return False
172 # Speak feedback message to user
174 #Parameters:
176 # 'words' -- string - Message to speak to user
178 #Returns:
180 # nothing
181 def say( words ):
182 if not confFile.get_opt_as_bool('DEFAULT.speak_up'): return
183 words = words.replace( "\"", "\\\"" )
184 shellcmd([confFile.get_opt('DEFAULT.speak_command'), words])
186 # Scan for a limited time and return AP names and bssid found.
187 # Access points we find will be put on the outgoing Queue, apQueue.
189 #Parameters:
191 # 'confFile' -- ConfigFile - Config file object
193 # 'apQueue' -- Queue - Queue on which to put AP profiles
195 # 'commandQueue' -- Queue - Queue from which to read commands
197 # 'logger' -- Logger - Python's logging facility
199 #Returns:
201 # nothing
202 def scanning_thread( confFile, apQueue, commandQueue, logger ):
203 logger.debug("Begin thread.")
204 # Setup our essid pattern matcher
205 essid_pattern = re.compile( "ESSID\s*(:|=)\s*\"([^\"]+)\"", re.I | re.M | re.S )
206 bssid_pattern = re.compile( "Address\s*(:|=)\s*([a-zA-Z0-9:]+)", re.I | re.M | re.S )
207 protocol_pattern = re.compile( "Protocol\s*(:|=)\s*IEEE 802.11\s*([abgn]+)", re.I | re.M | re.S )
208 mode_pattern = re.compile( "Mode\s*(:|=)\s*([^\n]+)", re.I | re.M | re.S )
209 channel_pattern = re.compile( "Channel\s*(:|=)*\s*(\d+)", re.I | re.M | re.S )
210 enckey_pattern = re.compile( "Encryption key\s*(:|=)\s*(on|off)", re.I | re.M | re.S )
211 signal_pattern = re.compile( "Signal level\s*(:|=)\s*(-?[0-9]+)", re.I | re.M | re.S )
213 access_points = {}
214 command = "scan"
215 while True:
216 try:
217 command = commandQueue.get_nowait()
218 logger.debug("received command: %s" % ( command, ))
219 command_read = True
220 except Queue.Empty:
221 command_read = False
222 if command == "scan":
223 #logger.debug("Beginning scan pass")
224 # Some cards need to have the interface up to scan
225 if confFile.get_opt_as_bool('DEFAULT.ifup_required'):
226 # call ifconfig command and wait for return
227 shellcmd([confFile.get_opt('DEFAULT.ifconfig_command'), confFile.get_opt('DEFAULT.interface'), 'up'])
228 # update the signal strengths
229 scandata = Popen([confFile.get_opt('DEFAULT.iwlist_command'), confFile.get_opt('DEFAULT.interface'), 'scan'], stdout=PIPE).stdout.read()
230 #logger.debug("Current IP: %s\nCurrent ESSID: %s\nCurrent BSSID: %s" % (get_current_ip(), get_current_essid(), get_current_bssid()))
231 # zero out the signal levels for all access points
232 for bssid in access_points:
233 access_points[bssid]['signal'] = 0
234 # split the scan data based on the address line
235 hits = scandata.split(' - ')
236 for hit in hits:
237 # set the defaults for profile template
238 profile = get_new_profile()
239 m = essid_pattern.search( hit )
240 if m:
241 # we found an essid
242 profile['essid'] = m.groups()[1]
243 m = bssid_pattern.search( hit ) # get BSSID from scan
244 if m: profile['bssid'] = m.groups()[1]
245 m = protocol_pattern.search( hit ) # get protocol from scan
246 if m: profile['protocol'] = m.groups()[1]
247 m = mode_pattern.search( hit ) # get mode from scan
248 if m: profile['mode'] = m.groups()[1]
249 m = channel_pattern.search( hit ) # get channel from scan
250 if m: profile['channel'] = m.groups()[1]
251 m = enckey_pattern.search( hit ) # get encryption key from scan
252 if m: profile['encrypted'] = ( m.groups()[1] == 'on' )
253 m = signal_pattern.search( hit ) # get signal strength from scan
254 if m: profile['signal'] = m.groups()[1]
255 access_points[ profile['bssid'] ] = profile
256 for bssid in access_points:
257 access_points[bssid]['available'] = ( access_points[bssid]['signal'] > 0 )
258 # Put all, now or previously, sensed access_points into apQueue
259 try:
260 apQueue.put_nowait( access_points[bssid] )
261 except Queue.Full:
262 pass
263 elif command == "exit":
264 logger.debug("Exiting.")
265 return
266 if command_read: commandQueue.task_done()
267 if confFile.get_opt('DEFAULT.interface').find('ath') == 0:
268 sleep( 3 )
269 else:
270 sleep( 1 )
273 # Read scanned AP info from ap_queue and combine with
274 # configured profiles, then update the UI.
276 #Parameters:
278 # 'ui' -- Object - Must provide update_list() method
280 # 'confFile' -- ConfigFile - Config file object
282 # 'apQueue' -- Queue - Queue on which to put AP profiles
284 # 'commandQueue' -- Queue - Queue from which to read commands
286 # 'logger' -- Logger - Python's logging facility
288 #Returns:
290 # nothing
291 def update_profiles(ui, conf_file, ap_queue, command_queue, logger):
292 logger.debug("Begin thread.")
293 command = 'scan'
294 while True:
295 # Get APs scanned by iwlist
296 try:
297 ap = ap_queue.get_nowait()
298 except Queue.Empty:
299 pass
300 else:
301 # Attempt to match to known profiles, normal then roaming
302 profile = conf_file.get_profile(make_section_name(ap['essid'], ap['bssid']))
303 if not profile:
304 profile = conf_file.get_profile(make_section_name(ap['essid'], ''))
305 if not profile:
306 profile = {}
307 profile.update(ap)
308 # update UI
309 ui.update_list(profile)
310 # Check for exit command.
311 try:
312 command = command_queue.get_nowait()
313 except Queue.Empty:
314 pass
315 if command == "exit":
316 logger.debug("Exiting.")
317 return
318 # Sleep before starting over. Should be less than 1/2 sleep length of scanning_thread()
319 sleep(0.1)
322 # Manage a connection; including reporting connection state,
323 # connecting/disconnecting from an AP, and returning current IP, ESSID, and BSSID.
324 class ConnectionManager():
325 # Create a new connection manager which can read a config file and send to scanning thread
326 # command Queue. A new manager checks for a pre-existing connection and takes
327 # its AP profile from the ESSID and BSSID to which it is currently attached.
329 #Parameters:
331 # 'confFile' -- ConfigFile - Config file object
333 # 'commandQueue' -- Queue - The Queue on which to put commands to the scanning thread
335 # 'logger' -- Logger - Python's logging facility
337 #Returns:
339 # ConnectionManager instance
340 def __init__( self, confFile, commandQueue, logger ):
341 self.confFile = confFile
342 self.commQueue = commandQueue
343 self.logger = logger
344 # is connection running?
345 self.state = False
346 if self.get_current_ip():
347 self.state = True
348 self.profile = self.confFile.get_profile( make_section_name(self.get_current_essid(), self.get_current_bssid()) )
350 # Change the interface state: up or down.
352 #Parameters:
354 # 'state' -- string - The state to which to change the interface.
356 #Returns:
358 # nothing
359 def if_change( self, state ):
360 if ( (state.lower() == 'up') or (state.lower() == 'down') ):
361 self.logger.debug("changing interface state to %s" % ( state, ))
362 # call ifconfig command and wait for return
363 shellcmd([self.confFile.get_opt('DEFAULT.ifconfig_command'), self.confFile.get_opt('DEFAULT.interface'), state])
365 # Connect to the specified AP.
367 #Parameters:
369 # 'profile' -- dictionary - The profile for the AP (i.e. network) with which to connect.
371 # 'status' -- status implementer - Object which implements status interface.
373 #Returns:
375 # nothing
376 def connect_to_network( self, profile, status ):
377 self.profile = profile
378 msg = "Connecting to the %s (%s) network" % ( self.profile['essid'], self.profile['bssid'] )
379 say( msg )
380 self.logger.debug(msg)
381 # ready to dance
382 # Let's run the connection prescript
383 if self.profile['con_prescript'].strip() != '':
384 # got something to execute
385 # run connection prescript through shell and wait for return
386 self.logger.debug("executing connection prescript: %s" % ( self.profile['con_prescript'], ))
387 shellcmd([self.profile['con_prescript']], environment={"WIFIRADAR_IF": self.confFile.get_opt('DEFAULT.interface')})
388 status.show()
389 # Some cards need to have the interface up
390 if self.confFile.get_opt_as_bool('DEFAULT.ifup_required'):
391 self.if_change('up')
392 # Start building iwconfig command line, command
393 iwconfig_command = [ self.confFile.get_opt('DEFAULT.iwconfig_command') ]
394 iwconfig_command.append( self.confFile.get_opt('DEFAULT.interface') )
395 # Setting essid
396 iwconfig_command.append( 'essid' )
397 iwconfig_command.append( "'" + self.profile['essid'] + "'" )
398 # Setting nick
399 #iwconfig_commands.append( 'nick "%s"' % self.profile['essid'] )
400 # Setting key
401 iwconfig_command.append( 'key' )
402 if self.profile['key'] == '':
403 iwconfig_command.append( 'off' )
404 else:
405 iwconfig_command.append( "'" + self.profile['key'] + "'" )
406 #iwconfig_commands.append( "key %s %s" % ( self.profile['security'], self.profile['key'] ) )
407 # Setting mode
408 if self.profile['mode'].lower() == 'master':
409 self.profile['mode'] = 'Managed'
410 iwconfig_command.append( 'mode' )
411 iwconfig_command.append( self.profile['mode'] )
412 # Setting channel
413 if self.profile['channel'] != '':
414 iwconfig_command.append( 'channel' )
415 iwconfig_command.append( self.profile['channel'] )
416 # Now we do the ap by address (do this last since iwconfig seems to want it only there)
417 iwconfig_command.append( 'ap' )
418 iwconfig_command.append( self.profile['bssid'] )
419 # Some cards require a commit
420 if self.confFile.get_opt_as_bool('DEFAULT.commit_required'):
421 self.logger.debug("iwconfig_args %s " % ( iwconfig_args, ))
422 iwconfig_command.append( 'commit' )
423 # call iwconfig command and wait for return
424 if not shellcmd(iwconfig_command): return
425 # Now normal network stuff
426 # Kill off any existing DHCP clients running
427 if os.path.isfile(self.confFile.get_opt('DHCP.pidfile')):
428 self.logger.debug("Killing existing DHCP...")
429 try:
430 if self.confFile.get_opt('DHCP.kill_args') != '':
431 # call DHCP client kill command and wait for return
432 self.logger.debug("%s %s", ( self.confFile.get_opt('DHCP.command'), self.confFile.get_opt('DHCP.kill_args'), ))
433 shellcmd([self.confFile.get_opt('DHCP.command'), self.confFile.get_opt('DHCP.kill_args')])
434 else:
435 os.kill(int(open(self.confFile.get_opt('DHCP.pidfile'), mode='r').readline()), SIGTERM)
436 except OSError:
437 print "failed to kill DHCP client"
438 sys.exit()
439 finally:
440 print "Stale pid file. Removing..."
441 os.remove(self.confFile.get_opt('DHCP.pidfile'))
442 # Kill off any existing WPA supplicants running
443 if os.access(self.confFile.get_opt('WPA.pidfile'), os.R_OK):
444 self.logger.debug("Killing existing WPA supplicant...")
445 try:
446 if not self.confFile.get_opt('WPA.kill_command') != '':
447 # call WPA supplicant kill command and wait for return
448 shellcmd([self.confFile.get_opt('WPA.kill_command'), self.confFile.get_opt('WPA.kill_command')])
449 else:
450 os.kill(int(open(self.confFile.get_opt('WPA.pidfile'), mode='r').readline()), SIGTERM)
451 except OSError:
452 print "failed to kill WPA supplicant"
453 sys.exit()
454 finally:
455 print "Stale pid file. Removing..."
456 os.remove(self.confFile.get_opt('WPA.pidfile'))
457 # Begin WPA supplicant
458 if self.profile['use_wpa'] :
459 self.logger.debug("WPA args: %s" % ( self.confFile.get_opt('WPA.args'), ))
460 status.update_message("WPA supplicant starting")
461 if sys.modules.has_key("gtk"):
462 while gtk.events_pending():
463 gtk.main_iteration(False)
464 # call WPA supplicant command and do not wait for return
465 wpa_proc = Popen([self.confFile.get_opt('WPA.command'), self.confFile.get_opt('WPA.args'), self.confFile.get_opt('DEFAULT.interface')])
466 if self.profile['use_dhcp'] :
467 self.logger.debug("Disable iwlist while dhcp in progress...")
468 try:
469 self.commQueue.put("pause")
470 except Queue.Full:
471 pass
472 status.update_message("Acquiring IP Address (DHCP)")
473 if sys.modules.has_key("gtk"):
474 while gtk.events_pending():
475 gtk.main_iteration(False)
476 # call DHCP client command and do not wait for return
477 dhcp_command = [ self.confFile.get_opt('DHCP.command') ]
478 dhcp_command.extend( self.confFile.get_opt('DHCP.args').split(' ') )
479 dhcp_command.append( self.confFile.get_opt('DEFAULT.interface') )
480 dhcp_proc = Popen(dhcp_command, stdout=None)
481 timer = self.confFile.get_opt_as_int('DHCP.timeout') + 3
482 tick = 0.25
483 waiting = dhcp_proc.poll()
484 while waiting == None:
485 waiting = dhcp_proc.poll()
486 if timer < 0:
487 os.kill(dhcp_proc.pid, SIGTERM)
488 break
489 if sys.modules.has_key("gtk"):
490 while gtk.events_pending():
491 gtk.main_iteration(False)
492 timer -= tick
493 sleep(tick)
494 # Re-enable iwlist
495 try:
496 self.commQueue.put("scan")
497 except Queue.Full:
498 pass
499 if not self.get_current_ip():
500 status.update_message("Could not get IP address!")
501 if sys.modules.has_key("gtk"):
502 while gtk.events_pending():
503 gtk.main_iteration(False)
504 sleep(1)
505 if self.state:
506 self.disconnect_interface()
507 status.hide()
508 return
509 else:
510 status.update_message("Got IP address. Done.")
511 self.state = True
512 if sys.modules.has_key("gtk"):
513 while gtk.events_pending():
514 gtk.main_iteration(False)
515 sleep(2)
516 else:
517 ifconfig_command= "%s %s down; %s %s %s netmask %s" % ( self.confFile.get_opt('DEFAULT.ifconfig_command'), self.confFile.get_opt('DEFAULT.interface'), self.confFile.get_opt('DEFAULT.ifconfig_command'), self.confFile.get_opt('DEFAULT.interface'), self.profile['ip'], self.profile['netmask'] )
518 route_command = "%s add default gw %s" % ( self.confFile.get_opt('DEFAULT.route_command'), self.profile['gateway'] )
519 resolv_contents = ''
520 if self.profile['domain'] != '': resolv_contents += "domain %s\n" % domain
521 if self.profile['dns1'] != '': resolv_contents += "nameserver %s\n" % dns1
522 if self.profile['dns2'] != '': resolv_contents += "nameserver %s\n" % dns2
523 if ( resolv_contents != '' ):
524 resolv_file=open('/etc/resolv.conf', 'w')
525 resolv_file.write(s)
526 resolv_file.close
527 if not shellcmd([ifconfig_command]): return
528 if not shellcmd([route_command]): return
529 self.state = True
530 # Let's run the connection postscript
531 con_postscript = self.profile['con_postscript']
532 if self.profile['con_postscript'].strip() != '':
533 self.logger.debug("executing connection postscript: %s" % ( self.profile['con_postscript'], ))
534 shellcmd([self.profile['con_postscript']],
535 environment = { "WIFIRADAR_IP": self.get_current_ip() or '0.0.0.0',
536 "WIFIRADAR_ESSID": self.get_current_essid() or '',
537 "WIFIRADAR_BSSID": self.get_current_bssid() or '00:00:00:00:00:00',
538 "WIFIRADAR_IF": self.confFile.get_opt('DEFAULT.interface') or ''
541 status.hide()
543 # Disconnect from the AP with which a connection has been established/attempted.
545 #Parameters:
547 # nothing
549 #Returns:
551 # nothing
552 def disconnect_interface( self ):
553 msg = "Disconnecting"
554 say( msg )
555 self.logger.debug(msg)
556 # Pause scanning while manipulating card
557 try:
558 self.commQueue.put("pause")
559 except Queue.Full:
560 pass
561 if self.state:
562 self.profile = self.confFile.get_profile( make_section_name(self.get_current_essid(), self.get_current_bssid()) )
563 # Let's run the disconnection prescript
564 if self.profile['dis_prescript'].strip() != '':
565 self.logger.debug("executing disconnection prescript: %s" % ( self.profile['dis_prescript'], ))
566 shellcmd([self.profile['dis_prescript']],
567 environment = { "WIFIRADAR_IP": self.get_current_ip() or '0.0.0.0',
568 "WIFIRADAR_ESSID": self.get_current_essid() or '',
569 "WIFIRADAR_BSSID": self.get_current_bssid() or '00:00:00:00:00:00',
570 "WIFIRADAR_IF": self.confFile.get_opt('DEFAULT.interface') or ''
573 self.logger.debug("Kill off any existing DHCP clients running...")
574 if os.path.isfile(self.confFile.get_opt('DHCP.pidfile')):
575 self.logger.debug("Killing existing DHCP...")
576 try:
577 if self.confFile.get_opt('DHCP.kill_args').strip() != '':
578 dhcp_command = [ self.confFile.get_opt('DHCP.command') ]
579 dhcp_command.extend( self.confFile.get_opt('DHCP.kill_args').split(' ') )
580 dhcp_command.append( self.confFile.get_opt('DEFAULT.interface') )
581 self.logger.debug("DHCP command: %s" % ( dhcp_command, ))
582 # call DHCP client command and wait for return
583 if not shellcmd(dhcp_command): return
584 else:
585 self.logger.debug("Killing DHCP manually...")
586 os.kill(int(open(self.confFile.get_opt('DHCP.pidfile'), mode='r').readline()), SIGTERM)
587 except OSError:
588 print "failed to kill DHCP client"
589 self.logger.debug("Kill off any existing WPA supplicants running...")
590 if os.access(self.confFile.get_opt('WPA.pidfile'), os.R_OK):
591 self.logger.debug("Killing existing WPA supplicant...")
592 try:
593 if not self.confFile.get_opt('WPA.kill_command') != '':
594 wpa_command = [ self.confFile.get_opt('WPA.kill_command').split(' ') ]
595 if not shellcmd(wpa_command): return
596 else:
597 os.kill(int(open(self.confFile.get_opt('WPA.pidfile'), mode='r').readline()), SIGTERM)
598 except OSError:
599 print "failed to kill WPA supplicant"
600 shellcmd([self.confFile.get_opt('DEFAULT.iwconfig_command'), self.confFile.get_opt('DEFAULT.interface'), 'essid', 'any', 'key', 'off', 'mode', 'managed', 'channel', 'auto', 'ap', 'off'])
601 self.logger.debug("Let's clear out the wireless stuff")
602 self.logger.debug("Now take the interface down")
603 # taking down the interface too quickly can crash my system, so pause a moment
604 sleep(1)
605 self.if_change('down')
606 self.logger.debug("Since it may be brought back up by the next scan, lets unset its IP")
607 shellcmd([self.confFile.get_opt('DEFAULT.ifconfig_command'), self.confFile.get_opt('DEFAULT.interface'), '0.0.0.0'])
608 # Let's run the disconnection postscript
609 if self.profile['dis_postscript'].strip() != '':
610 self.logger.debug("executing disconnection postscript: %s" % ( self.profile['dis_postscript'], ))
611 shellcmd([self.profile['dis_postscript']], environment={"WIFIRADAR_IF": self.confFile.get_opt('DEFAULT.interface')})
612 self.state = False
613 self.logger.debug("Disconnect complete.")
614 # Begin scanning again
615 try:
616 self.commQueue.put("scan")
617 except Queue.Full:
618 pass
620 # Returns the current IP, if any, by calling ifconfig.
622 #Parameters:
624 # nothing
626 #Returns:
628 # string or None -- the IP address or None (if no there is no current connection)
629 def get_current_ip( self ):
630 ifconfig_command = [ confFile.get_opt('DEFAULT.ifconfig_command'), confFile.get_opt('DEFAULT.interface') ]
631 ifconfig_info = Popen(ifconfig_command, stdout=PIPE).stdout
632 # Be careful to the language (inet adr: in French for example)
634 # Hi Brian
636 # I'm using wifi-radar on a system with German translations (de_CH-UTF-8).
637 # There the string in ifconfig is inet Adresse for the IP which isn't
638 # found by the current get_current_ip function in wifi-radar. I changed
639 # the according line (#289; gentoo, v1.9.6-r1) to
640 # >ip_re = re.compile(r'inet [Aa]d?dr[^.]*:([^.]*\.[^.]*\.[^.]*\.[0-9]*)')
641 # which works on my system (LC_ALL=de_CH.UTF-8) and still works with LC_ALL=C.
643 # I'd be happy if you could incorporate this small change because as now
644 # I've got to change the file every time it is updated.
646 # Best wishes
648 # Simon
649 ip_re = re.compile(r'inet [Aa]d?dr[^.]*:([^.]*\.[^.]*\.[^.]*\.[0-9]*)')
650 line = ifconfig_info.read()
651 if ip_re.search( line ):
652 return ip_re.search( line ).group(1)
653 return None
655 # Returns the current ESSID, if any, by calling iwconfig.
657 #Parameters:
659 # nothing
661 #Returns:
663 # string or None -- the ESSID or None (if no there is no current association)
664 def get_current_essid( self ):
665 """Returns the current ESSID if any by calling iwconfig"""
666 iwconfig_info = Popen([self.confFile.get_opt('DEFAULT.iwconfig_command'), self.confFile.get_opt('DEFAULT.interface')], stdout=PIPE).stdout
667 # Be careful to the language (inet adr: in French for example)
668 essid_re = re.compile( "ESSID\s*(:|=)\s*\"([^\"]+)\"", re.I | re.M | re.S )
669 line = iwconfig_info.read()
670 if essid_re.search( line ):
671 return essid_re.search( line ).group(2)
672 return None
674 # Returns the current BSSID, if any, by calling iwconfig.
676 #Parameters:
678 # nothing
680 #Returns:
682 # string or None -- the BSSID or None (if no there is no current association)
683 def get_current_bssid( self ):
684 """Returns the current BSSID if any by calling iwconfig"""
685 iwconfig_info = Popen([self.confFile.get_opt('DEFAULT.iwconfig_command'), self.confFile.get_opt('DEFAULT.interface')], stdout=PIPE).stdout
686 bssid_re = re.compile( "Access Point\s*(:|=)\s*([a-zA-Z0-9:]+)", re.I | re.M | re.S )
687 line = iwconfig_info.read()
688 if bssid_re.search( line ):
689 return bssid_re.search( line ).group(2)
690 return None
694 # The main user interface window for WiFi Radar. This class also is the control
695 # center for most of the rest of the operations.
696 class radar_window:
697 # Create a new radar_window.
699 #Parameters:
701 # 'confFile' -- ConfigFile - The config file in which to store/read settings.
703 # 'apQueue' -- Queue - The Queue from which AP profiles are read.
705 # 'commQueue' -- Queue - The Queue to which to send commands to the scanning thread.
707 # 'logger' -- Logger - Python's logging facility
709 #Returns:
711 # radar_window instance
712 def __init__( self, confFile, apQueue, commQueue, logger ):
713 global signal_xpm_none
714 global signal_xpm_low
715 global signal_xpm_barely
716 global signal_xpm_ok
717 global signal_xpm_best
718 global known_profile_icon
719 global unknown_profile_icon
720 global wifi_radar_icon
722 self.confFile = confFile
723 self.apQueue = apQueue
724 self.commandQueue = commQueue
725 self.logger = logger
726 self.connection = None
728 self.known_profile_icon = gtk.gdk.pixbuf_new_from_inline( len( known_profile_icon[0] ), known_profile_icon[0], False )
729 self.unknown_profile_icon = gtk.gdk.pixbuf_new_from_inline( len( unknown_profile_icon[0] ), unknown_profile_icon[0], False )
730 self.signal_none_pb = gtk.gdk.pixbuf_new_from_xpm_data( signal_xpm_none )
731 self.signal_low_pb = gtk.gdk.pixbuf_new_from_xpm_data( signal_xpm_low )
732 self.signal_barely_pb = gtk.gdk.pixbuf_new_from_xpm_data( signal_xpm_barely )
733 self.signal_ok_pb = gtk.gdk.pixbuf_new_from_xpm_data( signal_xpm_ok )
734 self.signal_best_pb = gtk.gdk.pixbuf_new_from_xpm_data( signal_xpm_best )
735 self.window = gtk.Dialog('WiFi Radar', None, gtk.DIALOG_MODAL )
736 icon = gtk.gdk.pixbuf_new_from_inline( len( wifi_radar_icon[0] ), wifi_radar_icon[0], False )
737 self.window.set_icon( icon )
738 self.window.set_border_width( 10 )
739 self.window.set_size_request( 550, 300 )
740 self.window.set_title( "WiFi Radar" )
741 self.window.connect( 'delete_event', self.delete_event )
742 self.window.connect( 'destroy', self.destroy )
743 # let's create all our widgets
744 self.current_network = gtk.Label()
745 self.current_network.set_property('justify', gtk.JUSTIFY_CENTER)
746 self.current_network.show()
747 self.close_button = gtk.Button( "Close", gtk.STOCK_CLOSE )
748 self.close_button.show()
749 self.close_button.connect( 'clicked', self.delete_event, None )
750 self.about_button = gtk.Button( "About", gtk.STOCK_ABOUT )
751 self.about_button.show()
752 self.about_button.connect( 'clicked', self.show_about_info, None )
753 self.preferences_button = gtk.Button( "Preferences", gtk.STOCK_PREFERENCES )
754 self.preferences_button.show()
755 self.preferences_button.connect( 'clicked', self.edit_preferences, None )
756 # essid + bssid known_icon known available wep_icon signal_level mode protocol channel
757 self.pstore = gtk.ListStore( str, gtk.gdk.Pixbuf, bool, bool, str, gtk.gdk.Pixbuf, str, str, str )
758 self.plist = gtk.TreeView( self.pstore )
759 # The icons column, known and encryption
760 self.pix_cell = gtk.CellRendererPixbuf()
761 self.wep_cell = gtk.CellRendererPixbuf()
762 self.icons_cell = gtk.CellRendererText()
763 self.icons_col = gtk.TreeViewColumn()
764 self.icons_col.pack_start( self.pix_cell, False )
765 self.icons_col.pack_start( self.wep_cell, False )
766 self.icons_col.add_attribute( self.pix_cell, 'pixbuf', 1 )
767 self.icons_col.add_attribute( self.wep_cell, 'stock-id', 4 )
768 self.plist.append_column( self.icons_col )
769 # The AP column
770 self.ap_cell = gtk.CellRendererText()
771 self.ap_col = gtk.TreeViewColumn( "Access Point" )
772 self.ap_col.pack_start( self.ap_cell, True )
773 self.ap_col.add_attribute( self.ap_cell, 'text', 0 )
774 self.plist.append_column( self.ap_col )
775 # The signal column
776 self.sig_cell = gtk.CellRendererPixbuf()
777 self.signal_col = gtk.TreeViewColumn( "Signal" )
778 self.signal_col.pack_start( self.sig_cell, True )
779 self.signal_col.add_attribute( self.sig_cell, 'pixbuf', 5 )
780 self.plist.append_column( self.signal_col )
781 # The mode column
782 self.mode_cell = gtk.CellRendererText()
783 self.mode_col = gtk.TreeViewColumn( "Mode" )
784 self.mode_col.pack_start( self.mode_cell, True )
785 self.mode_col.add_attribute( self.mode_cell, 'text', 6 )
786 self.plist.append_column( self.mode_col )
787 # The protocol column
788 self.prot_cell = gtk.CellRendererText()
789 self.protocol_col = gtk.TreeViewColumn( "802.11" )
790 self.protocol_col.pack_start( self.prot_cell, True )
791 self.protocol_col.add_attribute( self.prot_cell, 'text', 7 )
792 self.plist.append_column( self.protocol_col )
793 # The channel column
794 self.channel_cell = gtk.CellRendererText()
795 self.channel_col = gtk.TreeViewColumn( "Channel" )
796 self.channel_col.pack_start( self.channel_cell, True )
797 self.channel_col.add_attribute( self.channel_cell, 'text', 8 )
798 self.plist.append_column( self.channel_col )
799 # DnD Ordering
800 self.plist.set_reorderable( True )
801 # detect d-n-d of AP in round-about way, since rows-reordered does not work as advertised
802 self.pstore.connect( 'row-deleted', self.update_auto_profile_order )
803 # enable/disable buttons based on the selected network
804 self.selected_network = self.plist.get_selection()
805 self.selected_network.connect( 'changed', self.on_network_selection, None )
806 # the list scroll bar
807 sb = gtk.VScrollbar( self.plist.get_vadjustment() )
808 sb.show()
809 self.plist.show()
810 # Add New button
811 self.new_button = gtk.Button( "_New" )
812 self.new_button.connect( 'clicked', self.create_new_profile, get_new_profile(), None )
813 self.new_button.show()
814 # Add Configure button
815 self.edit_button = gtk.Button( "C_onfigure" )
816 self.edit_button.connect( 'clicked', self.edit_profile, None )
817 self.edit_button.show()
818 self.edit_button.set_sensitive(False)
819 # Add Delete button
820 self.delete_button = gtk.Button( "_Delete" )
821 self.delete_button.connect( 'clicked', self.delete_profile, None )
822 self.delete_button.show()
823 self.delete_button.set_sensitive(False)
824 # Add Connect button
825 self.connect_button = gtk.Button( "Co_nnect" )
826 self.connect_button.connect( 'clicked', self.connect_profile, None )
827 # Add Disconnect button
828 self.disconnect_button = gtk.Button( "D_isconnect" )
829 self.disconnect_button.connect( 'clicked', self.disconnect_profile, None )
830 # lets add our widgets
831 rows = gtk.VBox( False, 3 )
832 net_list = gtk.HBox( False, 0 )
833 listcols = gtk.HBox( False, 0 )
834 prows = gtk.VBox( False, 0 )
835 # lets start packing
836 # the network list
837 net_list.pack_start( self.plist, True, True, 0 )
838 net_list.pack_start( sb, False, False, 0 )
839 # the rows level
840 rows.pack_start( net_list , True, True, 0 )
841 rows.pack_start( self.current_network, False, True, 0 )
842 # the list columns
843 listcols.pack_start( rows, True, True, 0 )
844 listcols.pack_start( prows, False, False, 5 )
845 # the list buttons
846 prows.pack_start( self.new_button, False, False, 2 )
847 prows.pack_start( self.edit_button, False, False, 2 )
848 prows.pack_start( self.delete_button, False, False, 2 )
849 prows.pack_end( self.connect_button, False, False, 2 )
850 prows.pack_end( self.disconnect_button, False, False, 2 )
852 self.window.action_area.pack_start( self.about_button )
853 self.window.action_area.pack_start( self.preferences_button )
854 self.window.action_area.pack_start( self.close_button )
856 rows.show()
857 prows.show()
858 listcols.show()
859 self.window.vbox.add( listcols )
860 self.window.vbox.set_spacing( 3 )
861 self.window.show_all()
863 # Now, immediately hide these two. The proper one will be
864 # displayed later, based on interface state. -BEF-
865 self.disconnect_button.hide()
866 self.connect_button.hide()
867 self.connect_button.set_sensitive(False)
869 # set up connection manager for later use
870 self.connection = ConnectionManager( self.confFile, self.commandQueue, self.logger )
871 # set up status window for later use
872 self.status_window = StatusWindow( self )
873 self.status_window.cancel_button.connect('clicked', self.disconnect_profile, "cancel")
875 # Add our known profiles in order
876 for profile_name in self.confFile.auto_profile_order:
877 profile = self.confFile.get_profile( profile_name.strip() )
878 wep = None
879 if profile['encrypted']: wep = gtk.STOCK_DIALOG_AUTHENTICATION
880 self.update_list(profile)
881 # This is the first run (or, at least, no config file was present), so pop up the preferences window
882 if ( self.confFile.get_opt_as_bool('DEFAULT.new_file') == True ):
883 self.confFile.remove_option('DEFAULT', 'new_file')
884 self.edit_preferences(self.preferences_button)
886 # Begin running radar_window in Gtk event loop.
888 #Parameters:
890 # nothing
892 #Returns:
894 # nothing
895 def main( self ):
896 gtk.main()
898 # Quit application.
900 #Parameters:
902 # 'widget' -- gtk.Widget - The widget sending the event.
904 #Returns:
906 # nothing
907 def destroy( self, widget = None):
908 if self.status_window:
909 self.status_window.destroy()
910 gtk.main_quit()
912 # Kill scanning thread, update profile order for config file, and ask to be destroyed.
914 #Parameters:
916 # 'widget' -- gtk.Widget - The widget sending the event.
918 # 'data' -- tuple - list of arbitrary arguments (not used)
920 #Returns:
922 # boolean -- always return False (i.e. do not propigate the signal which called)
923 def delete_event( self, widget, data = None ):
924 # Put "exit" on the command Queue and wait indefinitely for it to be accepted
925 # signal each listening thread, should be two
926 try:
927 self.commandQueue.put("exit", True)
928 self.commandQueue.put("exit", True)
929 except Queue.Full:
930 pass
931 self.destroy()
932 return False
934 # Updates the on-screen profiles list.
936 #Parameters:
938 # nothing
940 #Returns:
942 # boolean -- always return True
943 def update_list( self, profile ):
944 # Indicate to PyGtk that only one Gtk thread should run here
945 gtk.gdk.threads_enter()
946 # update the current ip and essid
947 # set the state of connect/disconnect buttons based on whether we have an IP address
948 if self.connection:
949 if self.connection.state:
950 self.current_network.set_text( "Connected to %s\nIP Address %s" % ( make_section_name( self.connection.get_current_essid(), self.connection.get_current_bssid() ), self.connection.get_current_ip() ) )
951 self.connect_button.hide()
952 self.disconnect_button.show()
953 else:
954 self.current_network.set_text( "Not Connected." )
955 self.disconnect_button.hide()
956 self.connect_button.show()
958 if profile['roaming']:
959 prow_iter = self.get_row_by_ap(profile['essid'], ' Multiple APs')
960 else:
961 prow_iter = self.get_row_by_ap(profile['essid'], profile['bssid'])
962 wep = None
963 if prow_iter != None:
964 # the AP is in the list of APs on the screen
965 # Set the 'known' values
966 self.pstore.set_value(prow_iter, 1, self.pixbuf_from_known( profile[ 'known' ] ))
967 self.pstore.set_value(prow_iter, 2, profile[ 'known' ])
968 self.pstore.set_value(prow_iter, 3, profile['available'])
969 if profile['encrypted']: wep = gtk.STOCK_DIALOG_AUTHENTICATION
970 self.pstore.set_value(prow_iter, 4, wep)
971 self.pstore.set_value(prow_iter, 5, self.pixbuf_from_signal( profile['signal'] ))
972 self.pstore.set_value(prow_iter, 6, profile['mode'])
973 self.pstore.set_value(prow_iter, 7, profile['protocol'])
974 self.pstore.set_value(prow_iter, 8, profile['channel'])
975 #print "update_plist_items: profile update", profile[ 'essid' ], profile['bssid']
976 #for val in self.pstore[prow_iter]:
977 #print val,
978 else:
979 # the AP is not in the list of APs on the screen
980 if profile['roaming']:
981 ap_name = profile[ 'essid' ] + "\n" + ' Multiple APs'
982 else:
983 ap_name = profile[ 'essid' ] + "\n" + profile['bssid']
984 self.pstore.append([ap_name, self.pixbuf_from_known(profile['known']), profile['known'], profile['available'], wep, self.pixbuf_from_signal(profile['signal']), profile['mode'], profile['protocol'], profile['channel']])
985 #print "update_plist_items: new profile", profile[ 'essid' ], profile['bssid']
986 # Allow other Gtk threads to run
987 gtk.gdk.threads_leave()
988 #print "update_plist_items: Empty apQueue"
989 return True
991 # Return the proper icon for a value of known.
993 #Parameters:
995 # 'known' -- boolean - Whether the AP is known (i.e. configured)
997 #Returns:
999 # gtk.gdk.Pixbuf -- icon for a known or unknown AP
1000 def pixbuf_from_known( self, known ):
1001 """ return the proper icon for value of known """
1002 if known:
1003 return self.known_profile_icon
1004 else:
1005 return self.unknown_profile_icon
1007 # Return an icon indicating the signal level.
1009 #Parameters:
1011 # 'signal' -- integer - signal level reported by iwlist (may be arbitrary scale in 0-100 or -X dBm)
1013 #Returns:
1015 # gtk.gdk.Pixbuf -- 1 of 5 icons indicating signal level
1016 def pixbuf_from_signal( self, signal ):
1017 signal = int( signal )
1018 # shift signal up by 80 to convert dBm scale to arbitrary scale
1019 if signal < 0: signal = signal + 80
1020 #print "signal level:", signal
1021 if signal < 3:
1022 return self.signal_none_pb
1023 elif signal < 12:
1024 return self.signal_low_pb
1025 elif signal < 20:
1026 return self.signal_barely_pb
1027 elif signal < 35:
1028 return self.signal_ok_pb
1029 elif signal >= 35:
1030 return self.signal_best_pb
1031 else:
1032 return None
1034 # Return row which holds specified ESSID and BSSID.
1036 #Parameters:
1038 # 'essid' -- string - ESSID to match
1040 # 'bssid' -- string - BSSID to match
1042 #Returns:
1044 # gtk.TreeIter or None -- pointer to the row containing the match or None for no match found
1045 def get_row_by_ap( self, essid, bssid ):
1046 for row in self.pstore:
1047 if ( row[0] == essid + "\n" + bssid ):
1048 #print "matched:", row.iter, essid, bssid
1049 return row.iter
1050 return None
1052 # Enable/disable buttons based on the selected network.
1054 #Parameters:
1056 # 'widget' -- gtk.Widget - The widget sending the event.
1058 # 'data' -- tuple - list of arbitrary arguments (not used)
1060 #Returns:
1062 # nothing
1063 def on_network_selection( self, widget, data = None ):
1064 ( store, selected_iter ) = self.selected_network.get_selected()
1065 # if no networks are selected, disable all buttons except New
1066 # (this occurs after a drag-and-drop)
1067 if selected_iter == None:
1068 self.edit_button.set_sensitive(False)
1069 self.delete_button.set_sensitive(False)
1070 self.connect_button.set_sensitive(False)
1071 return
1072 # enable/disable buttons
1073 self.connect_button.set_sensitive(True)
1074 if (store.get_value(selected_iter, 2) == True): # is selected network known?
1075 self.edit_button.set_sensitive(True)
1076 self.delete_button.set_sensitive(True)
1077 else:
1078 self.edit_button.set_sensitive(True)
1079 self.delete_button.set_sensitive(False)
1081 # Init and run the about dialog
1083 #Parameters:
1085 # 'widget' -- gtk.Widget - The widget sending the event.
1087 # 'data' -- tuple - list of arbitrary arguments (not used)
1089 #Returns:
1091 # nothing
1092 def show_about_info( self, widget, data=None ):
1093 about = about_dialog()
1094 about.run()
1095 about.destroy()
1097 # Init and run the preferences dialog
1099 #Parameters:
1101 # 'widget' -- gtk.Widget - The widget sending the event.
1103 # 'data' -- tuple - list of arbitrary arguments (not used)
1105 #Returns:
1107 # nothing
1108 def edit_preferences( self, widget, data=None ):
1109 # get raw strings from config file
1110 self.confFile.raw = True
1111 prefs = preferences_dialog( self, self.confFile )
1112 response = prefs.run()
1113 prefs.destroy()
1114 if response == int(gtk.RESPONSE_ACCEPT):
1115 prefs.save()
1116 # get cooked strings from config file
1117 self.confFile.raw = False
1119 # Respond to a request to create a new AP profile
1121 #Parameters:
1123 # 'widget' -- gtk.Widget - The widget sending the event.
1125 # 'profile' -- dictionary - The AP profile to use as basis for new profile.
1127 # 'data' -- tuple - list of arbitrary arguments (not used)
1129 #Returns:
1131 # boolean -- True if a profile was created and False if profile creation was canceled.
1132 def create_new_profile( self, widget, profile, data=None ):
1133 profile_editor = profile_dialog( self, profile )
1134 try:
1135 profile = profile_editor.run()
1136 except ValueError:
1137 error_dlg = ErrorDialog(None, "Cannot save empty ESSID")
1138 del error_dlg
1139 return False
1140 finally:
1141 profile_editor.destroy()
1142 if profile:
1143 apname = make_section_name( profile['essid'], profile['bssid'] )
1144 # Check that the ap does not exist already
1145 if apname in self.confFile.profiles():
1146 error_dlg = ErrorDialog(None, "A profile for %s already exists" % (apname))
1147 del error_dlg
1148 # try again
1149 self.confFile.set_section( apname, profile )
1150 # if it is not in the auto_profile_order add it
1151 if apname not in self.confFile.auto_profile_order:
1152 self.confFile.auto_profile_order.append(apname)
1153 # add to the store
1154 wep = None
1155 if profile['encrypted']: wep = gtk.STOCK_DIALOG_AUTHENTICATION
1156 try:
1157 self.confFile.write()
1158 except IOError, (error_number, error_str):
1159 if error_number == errno.ENOENT:
1160 error_dlg = ErrorDialog( self.window, "Could not save configuration file:\n%s\n\n%s" % (self.confFile.filename, error_str) )
1161 del error_dlg
1162 else:
1163 raise IOError(error_number, error_str)
1164 # Add AP to the list displayed to user
1165 try:
1166 self.apQueue.put_nowait(profile)
1167 except Queue.Full:
1168 pass
1169 return True
1170 else:
1171 # Did not create new profile
1172 return False
1174 # Respond to a request to edit an AP profile. Edit selected AP profile if it
1175 # is known. Otherwise, create a new profile with the selected ESSID and BSSID.
1177 #Parameters:
1179 # 'widget' -- gtk.Widget - The widget sending the event.
1181 # 'data' -- tuple - list of arbitrary arguments (not used)
1183 #Returns:
1185 # nothing
1186 def edit_profile(self, widget, data=None):
1187 (store, selected_iter) = self.plist.get_selection().get_selected()
1188 if not selected_iter: return
1189 (essid, bssid) = str(self.pstore.get_value(selected_iter, 0)).split("\n")
1190 if bssid == ' Multiple APs':
1191 apname = make_section_name(essid, '')
1192 else:
1193 apname = make_section_name(essid, bssid)
1194 profile = self.confFile.get_profile(apname)
1195 if profile:
1196 profile_editor = profile_dialog(self, profile)
1197 try:
1198 edited_profile = profile_editor.run()
1199 except ValueError:
1200 error_dlg = ErrorDialog(None, "Cannot save empty ESSID")
1201 del error_dlg
1202 return False
1203 finally:
1204 profile_editor.destroy()
1205 if edited_profile:
1206 if edited_profile['essid'] != profile['essid'] or edited_profile['bssid'] != profile['bssid'] or edited_profile['roaming'] != profile['roaming']:
1207 self.delete_profile(widget)
1208 self.confFile.remove_section(make_section_name(profile['essid'], profile['bssid']))
1209 apname = make_section_name(edited_profile['essid'], edited_profile['bssid'])
1210 self.confFile.set_section(apname, edited_profile)
1211 try:
1212 self.confFile.write()
1213 except IOError, (error_number, error_str):
1214 if error_number == errno.ENOENT:
1215 error_dlg = ErrorDialog(self.window, "Could not save configuration file:\n%s\n\n%s" % (self.confFile.filename, error_str))
1216 del error_dlg
1217 else:
1218 raise IOError(error_number, error_str)
1219 else:
1220 # The AP does not already have a profile
1221 profile = get_new_profile()
1222 ( profile['essid'], profile['bssid'] ) = store.get_value( selected_iter, 0 ).split("\n")
1223 self.create_new_profile( widget, profile, data )
1225 # Respond to a request to delete an AP profile (i.e. make profile unknown)
1227 #Parameters:
1229 # 'widget' -- gtk.Widget - The widget sending the event.
1231 # 'data' -- tuple - list of arbitrary arguments (not used)
1233 #Returns:
1235 # nothing
1236 def delete_profile( self, widget, data=None ):
1237 ( store, selected_iter ) = self.plist.get_selection().get_selected()
1238 if not selected_iter: return
1239 ( essid, bssid ) = store.get_value( selected_iter, 0 ).split("\n")
1240 known = store.get_value( selected_iter, 1 )
1241 if not known: return
1242 dlg = gtk.MessageDialog(
1243 self.window,
1244 gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_MODAL,
1245 gtk.MESSAGE_QUESTION,
1246 gtk.BUTTONS_YES_NO,
1247 "Are you sure you want to delete the %s (%s) profile?" % (essid, bssid) )
1248 res = dlg.run()
1249 dlg.destroy()
1250 del dlg
1251 if res == gtk.RESPONSE_NO: return
1252 # Remove it
1253 apname = make_section_name( essid, bssid )
1254 self.confFile.remove_section( apname )
1255 self.logger.debug(apname)
1256 if apname in self.confFile.auto_profile_order: self.confFile.auto_profile_order.remove(apname)
1257 self.pstore.remove( selected_iter )
1258 # Let's save our current state
1259 self.update_auto_profile_order()
1260 try:
1261 self.confFile.write()
1262 except IOError, (error_number, error_str):
1263 if error_number == errno.ENOENT:
1264 error_dlg = ErrorDialog( self.window, "Could not save configuration file:\n%s\n\n%s" % (self.confFile.filename, error_str) )
1265 del error_dlg
1266 else:
1267 raise IOError(error_number, error_str)
1269 # Respond to a request to connect to an AP.
1271 #Parameters:
1273 # 'widget' -- gtk.Widget - The widget sending the event.
1275 # 'profile' -- dictionary - The AP profile to which to connect.
1277 # 'data' -- tuple - list of arbitrary arguments (not used)
1279 #Returns:
1281 # nothing
1282 def connect_profile( self, widget, profile, data=None ):
1283 ( store, selected_iter ) = self.plist.get_selection().get_selected()
1284 if not selected_iter: return
1285 ( essid, bssid ) = store.get_value( selected_iter, 0 ).split("\n")
1286 known = store.get_value( selected_iter, 2 )
1287 if not known:
1288 if data != 'noconnect':
1289 dlg = gtk.MessageDialog(
1290 self.window,
1291 gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_MODAL,
1292 gtk.MESSAGE_QUESTION,
1293 gtk.BUTTONS_YES_NO,
1294 "This network does not have a profile configured.\n\nWould you like to create one now?" )
1295 res = dlg.run()
1296 dlg.destroy()
1297 del dlg
1298 if res == gtk.RESPONSE_NO: return
1299 profile = get_new_profile()
1300 profile['essid'] = essid
1301 profile['bssid'] = bssid
1302 if not self.create_new_profile( widget, profile, data ):
1303 return
1304 self.connection.connect_to_network(self.confFile.get_profile(make_section_name(essid, bssid)), self.status_window)
1306 # Respond to a request to disconnect by calling ConnectionManager disconnect_interface().
1308 #Parameters:
1310 # 'widget' -- gtk.Widget - The widget sending the event.
1312 # 'data' -- tuple - list of arbitrary arguments (not used)
1314 #Returns:
1316 # nothing
1317 def disconnect_profile( self, widget, data=None ):
1318 if data == "cancel":
1319 self.status_window.update_message("Canceling connection...")
1320 if sys.modules.has_key("gtk"):
1321 while gtk.events_pending():
1322 gtk.main_iteration(False)
1323 sleep(1)
1324 self.connection.disconnect_interface()
1326 # Update the config file auto profile order from the on-screen order
1328 #Parameters:
1330 # 'widget' -- gtk.Widget - The widget sending the event.
1332 # 'data' -- tuple - list of arbitrary arguments (not used)
1334 # 'data2' -- tuple - list of arbitrary arguments (not used)
1336 #Returns:
1338 # nothing
1339 def update_auto_profile_order( self, widget = None, data = None, data2 = None ):
1340 # recreate the auto_profile_order
1341 auto_profile_order = []
1342 piter = self.pstore.get_iter_first()
1343 while piter:
1344 # only if it's known
1345 if self.pstore.get_value(piter, 2) == True:
1346 (essid, bssid) = self.pstore.get_value(piter, 0).split("\n")
1347 if bssid == ' Multiple APs':
1348 apname = make_section_name(essid, '')
1349 else:
1350 apname = make_section_name(essid, bssid)
1351 auto_profile_order.append(apname)
1352 piter = self.pstore.iter_next(piter)
1353 self.confFile.auto_profile_order = auto_profile_order
1354 try:
1355 self.confFile.write()
1356 except IOError, (error_number, error_str):
1357 if error_number == errno.ENOENT:
1358 error_dlg = ErrorDialog(self.window, "Could not save configuration file:\n%s\n\n%s" % (self.confFile.filename, error_str))
1359 del error_dlg
1360 else:
1361 raise IOError(error_number, error_str)
1364 # Button to allow user to choose a file and put value into specified gtk.Entry
1365 class file_browse_button(gtk.Button):
1366 # Create a button to simulate a File/Open
1368 #Parameters:
1370 # 'parent' -- gtk.Object -- Usually, the calling window.
1372 # 'entry' -- gtk.Entry -- The text entry to update with user selection.
1374 #Returns:
1376 # file_browse_button instance
1377 def __init__( self, parent, entry ):
1378 self.parent_window = parent
1379 self.entry = entry
1380 gtk.Button.__init__(self, "Browse", None)
1381 #self.
1382 self.browser_dialog = gtk.FileChooserDialog(None, self.parent_window, gtk.FILE_CHOOSER_ACTION_OPEN, ( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK ), None)
1383 self.connect("clicked", self.browse_files)
1385 # Show filechooser dialog and get user selection
1387 #Parameters:
1389 # 'widget' -- gtk.Widget -- The widget sending the event.
1391 #Returns:
1393 # nothing
1395 #NOTES:
1397 # updates entry value
1399 def browse_files( self, widget ):
1400 self.browser_dialog.set_filename(self.entry.get_text())
1401 self.browser_dialog.run()
1402 self.entry.set_text(self.browser_dialog.get_filename())
1403 self.browser_dialog.destroy()
1406 # Simple dialog to report an error to the user.
1407 class ErrorDialog:
1408 # Create a new ErrorDialog.
1410 #Parameters:
1412 # 'parent' -- gtk.Object - Usually, the calling window.
1414 # 'message' -- string - The message to display to the user.
1416 #Returns:
1418 # ErrorDialog instance
1419 def __init__( self, parent, message ):
1420 dialog = gtk.MessageDialog( parent, gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, message )
1421 dialog.run()
1422 dialog.destroy()
1423 del dialog
1426 # The preferences dialog. Edits non-profile sections of the config file.
1427 class preferences_dialog:
1428 # Create a new preferences_dialog.
1430 #Parameters:
1432 # 'parent' -- gtk.Object - Usually, the calling window.
1434 # 'confFile' -- ConfigFile - The config file in which to store/read settings.
1436 #Returns:
1438 # preferences_dialog instance
1439 def __init__( self, parent, confFile ):
1440 global wifi_radar_icon
1441 self.parent = parent
1442 self.confFile = confFile
1443 self.dialog = gtk.Dialog('WiFi Radar Preferences', self.parent.window,
1444 gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
1445 ( gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT ) )
1446 icon = gtk.gdk.pixbuf_new_from_inline( len( wifi_radar_icon[0] ), wifi_radar_icon[0], False )
1447 self.dialog.set_icon( icon )
1448 self.dialog.set_resizable( True )
1449 self.dialog.set_transient_for( self.parent.window )
1450 self.tooltips = gtk.Tooltips()
1452 # set up preferences widgets
1454 # build everything in a tabbed notebook
1455 self.prefs_notebook = gtk.Notebook()
1457 ### General tab
1458 self.general_page = gtk.VBox()
1459 # auto detect wireless device
1460 self.w_auto_detect = gtk.CheckButton("Auto-detect wireless device")
1462 print "prefs: ", self.confFile.get_opt('DEFAULT.interface')
1464 self.w_auto_detect.set_active( self.confFile.get_opt('DEFAULT.interface') == "auto_detect" )
1465 self.w_auto_detect.connect("toggled", self.toggle_auto_detect)
1466 self.tooltips.set_tip(self.w_auto_detect, "Automatically select wireless device to configure")
1467 self.general_page.pack_start(self.w_auto_detect, False, False, 5)
1469 # network interface selecter
1470 self.w_interface = gtk.combo_box_entry_new_text()
1471 iwconfig_info = Popen([self.confFile.get_opt('DEFAULT.iwconfig_command')], stdout=PIPE).stdout
1472 wireless_devices = [ (x[0:x.find(" ")]) for x in iwconfig_info if ("ESSID" in x)]
1473 for device in wireless_devices:
1474 if device != self.confFile.get_opt('DEFAULT.interface'):
1475 self.w_interface.append_text(device)
1476 if self.confFile.get_opt('DEFAULT.interface') != "auto_detect":
1477 self.w_interface.prepend_text( self.confFile.get_opt('DEFAULT.interface') )
1478 self.w_interface.set_active(0)
1479 self.w_interface_label = gtk.Label("Wireless device")
1480 self.w_hbox1 = gtk.HBox(False, 0)
1481 self.w_hbox1.pack_start(self.w_interface_label, False, False, 5)
1482 self.w_hbox1.pack_start(self.w_interface, True, True, 0)
1483 self.w_interface.set_sensitive( self.confFile.get_opt('DEFAULT.interface') != "auto_detect" )
1484 self.general_page.pack_start(self.w_hbox1, False, False, 5)
1486 # scan timeout (spin button of integers from 1 to 100)
1487 #self.time_in_seconds = gtk.Adjustment( self.confFile.get_opt_as_int('DEFAULT.scan_timeout'),1,100,1,1,0 )
1488 #self.w_scan_timeout = gtk.SpinButton(self.time_in_seconds, 1, 0)
1489 #self.w_scan_timeout.set_update_policy(gtk.UPDATE_IF_VALID)
1490 #self.w_scan_timeout.set_numeric(True)
1491 #self.w_scan_timeout.set_snap_to_ticks(True)
1492 #self.w_scan_timeout.set_wrap(False)
1493 #self.tooltips.set_tip(self.w_scan_timeout, "How long should WiFi Radar scan for access points?")
1494 #self.w_scan_timeout_label = gtk.Label("Scan timeout (seconds)")
1495 #self.w_hbox2 = gtk.HBox(False, 0)
1496 #self.w_hbox2.pack_start(self.w_scan_timeout_label, False, False, 5)
1497 #self.w_hbox2.pack_start(self.w_scan_timeout, True, True, 0)
1498 #self.general_page.pack_start(self.w_hbox2, False, False, 5)
1500 # speak up
1501 self.w_speak_up = gtk.CheckButton("Use speak-up")
1502 self.w_speak_up.set_active( self.confFile.get_opt_as_bool('DEFAULT.speak_up') )
1503 self.w_speak_up.connect("toggled", self.toggle_speak)
1504 self.tooltips.set_tip(self.w_speak_up, "Should I speak up when connecting to a network? (If you have a speech command)")
1505 self.general_page.pack_start(self.w_speak_up, False, False, 5)
1507 # speak up command
1508 self.w_speak_cmd = gtk.Entry()
1509 self.w_speak_cmd.set_width_chars(16)
1510 self.tooltips.set_tip(self.w_speak_cmd, "The command to use to speak feedback")
1511 self.w_speak_cmd.set_text(self.confFile.get_opt('DEFAULT.speak_command'))
1512 self.w_speak_cmd_label = gtk.Label("Speak Command")
1513 self.w_speak_cmd_button = file_browse_button(self.dialog, self.w_speak_cmd)
1514 self.w_speak_cmd_button.set_sensitive(self.w_speak_up.get_active())
1515 self.w_hbox3 = gtk.HBox(False, 0)
1516 self.w_hbox3.pack_start(self.w_speak_cmd_label, True, False, 5)
1517 self.w_hbox3.pack_start(self.w_speak_cmd, False, False, 0)
1518 self.w_hbox3.pack_start(self.w_speak_cmd_button, False, False, 0)
1519 self.w_speak_cmd.set_sensitive(self.w_speak_up.get_active())
1520 self.general_page.pack_start(self.w_hbox3, False, False, 5)
1522 # commit required
1523 self.w_commit_required = gtk.CheckButton("Commit required")
1524 self.w_commit_required.set_active( self.confFile.get_opt_as_bool('DEFAULT.commit_required') )
1525 self.tooltips.set_tip(self.w_commit_required, "Check this box if your card requires a \"commit\" command with iwconfig")
1526 self.general_page.pack_start(self.w_commit_required, False, False, 5)
1528 # ifup required
1529 self.w_ifup_required = gtk.CheckButton("Ifup required")
1530 self.w_ifup_required.set_active( self.confFile.get_opt_as_bool('DEFAULT.ifup_required') )
1531 self.tooltips.set_tip(self.w_ifup_required, "Check this box if your system requires the interface to be brought up first")
1532 self.general_page.pack_start(self.w_ifup_required, False, False, 5)
1534 self.prefs_notebook.append_page(self.general_page, gtk.Label("General"))
1535 ### End of General tab
1537 ### Advanced tab
1538 # table to use for layout of following command configurations
1539 self.cmds_table = gtk.Table()
1541 # ifconfig command
1542 self.ifconfig_cmd = gtk.Entry()
1543 self.ifconfig_cmd.set_width_chars(32)
1544 self.tooltips.set_tip(self.ifconfig_cmd, "The command to use to configure the network card")
1545 self.ifconfig_cmd.set_text(self.confFile.get_opt('DEFAULT.ifconfig_command'))
1546 self.ifconfig_cmd_label = gtk.Label("Network interface configure command")
1547 self.ifconfig_cmd_button = file_browse_button(self.dialog, self.ifconfig_cmd)
1548 # (widget, l, r, t, b, xopt, yopt, xpad, ypad)
1549 self.cmds_table.attach(self.ifconfig_cmd_label, 1, 2, 1, 2, True, False, 5, 0)
1550 self.cmds_table.attach(self.ifconfig_cmd, 2, 3, 1, 2, True, False, 0, 0)
1551 self.cmds_table.attach(self.ifconfig_cmd_button, 3, 4, 1, 2, False, False, 0, 0)
1553 # iwconfig command
1554 self.iwconfig_cmd = gtk.Entry()
1555 self.iwconfig_cmd.set_width_chars(32)
1556 self.tooltips.set_tip(self.iwconfig_cmd, "The command to use to configure the wireless connection")
1557 self.iwconfig_cmd.set_text(self.confFile.get_opt('DEFAULT.iwconfig_command'))
1558 self.iwconfig_cmd_label = gtk.Label("Wireless connection configure command")
1559 self.iwconfig_cmd_button = file_browse_button(self.dialog, self.iwconfig_cmd)
1560 # (widget, l, r, t, b, xopt, yopt, xpad, ypad)
1561 self.cmds_table.attach(self.iwconfig_cmd_label, 1, 2, 2, 3, True, False, 5, 0)
1562 self.cmds_table.attach(self.iwconfig_cmd, 2, 3, 2, 3, True, False, 0, 0)
1563 self.cmds_table.attach(self.iwconfig_cmd_button, 3, 4, 2, 3, False, False, 0, 0)
1565 # iwlist command
1566 self.iwlist_cmd = gtk.Entry()
1567 self.iwlist_cmd.set_width_chars(32)
1568 self.tooltips.set_tip(self.iwlist_cmd, "The command to use to scan for access points")
1569 self.iwlist_cmd.set_text(self.confFile.get_opt('DEFAULT.iwlist_command'))
1570 self.iwlist_cmd_label = gtk.Label("Wireless scanning command")
1571 self.iwlist_cmd_button = file_browse_button(self.dialog, self.iwlist_cmd)
1572 # (widget, l, r, t, b, xopt, yopt, xpad, ypad)
1573 self.cmds_table.attach(self.iwlist_cmd_label, 1, 2, 3, 4, True, False, 5, 0)
1574 self.cmds_table.attach(self.iwlist_cmd, 2, 3, 3, 4, True, False, 0, 0)
1575 self.cmds_table.attach(self.iwlist_cmd_button, 3, 4, 3, 4, False, False, 0, 0)
1577 # route command
1578 self.route_cmd = gtk.Entry()
1579 self.route_cmd.set_width_chars(32)
1580 self.tooltips.set_tip(self.route_cmd, "The command to use to configure the network routing")
1581 self.route_cmd.set_text(self.confFile.get_opt('DEFAULT.route_command'))
1582 self.route_cmd_label = gtk.Label("Network route configure command")
1583 self.route_cmd_button = file_browse_button(self.dialog, self.route_cmd)
1584 # (widget, l, r, t, b, xopt, yopt, xpad, ypad)
1585 self.cmds_table.attach(self.route_cmd_label, 1, 2, 4, 5, True, False, 5, 0)
1586 self.cmds_table.attach(self.route_cmd, 2, 3, 4, 5, True, False, 0, 0)
1587 self.cmds_table.attach(self.route_cmd_button, 3, 4, 4, 5, False, False, 0, 0)
1589 # log file
1590 self.logfile_entry = gtk.Entry()
1591 self.logfile_entry.set_width_chars(32)
1592 self.tooltips.set_tip(self.logfile_entry, "The file in which to save logging info")
1593 self.logfile_entry.set_text(self.confFile.get_opt('DEFAULT.logfile'))
1594 self.logfile_label = gtk.Label("Log file")
1595 self.logfile_button = file_browse_button(self.dialog, self.logfile_entry)
1596 # (widget, l, r, t, b, xopt, yopt, xpad, ypad)
1597 self.cmds_table.attach(self.logfile_label, 1, 2, 5, 6, True, False, 5, 0)
1598 self.cmds_table.attach(self.logfile_entry, 2, 3, 5, 6, True, False, 0, 0)
1599 self.cmds_table.attach(self.logfile_button, 3, 4, 5, 6, False, False, 0, 0)
1601 self.prefs_notebook.append_page(self.cmds_table, gtk.Label("Advanced"))
1602 ### End of Advanced tab
1604 ### DHCP tab
1605 # table to use for layout of DHCP prefs
1606 self.dhcp_table = gtk.Table()
1608 self.dhcp_cmd = gtk.Entry()
1609 self.dhcp_cmd.set_width_chars(32)
1610 self.tooltips.set_tip(self.dhcp_cmd, "The command to use for automatic network configuration")
1611 self.dhcp_cmd.set_text(self.confFile.get_opt('DHCP.command'))
1612 self.dhcp_cmd_label = gtk.Label("Command")
1613 self.dhcp_cmd_button = file_browse_button(self.dialog, self.dhcp_cmd)
1614 self.dhcp_table.attach(self.dhcp_cmd_label, 1, 2, 1, 2, True, False, 5, 0)
1615 self.dhcp_table.attach(self.dhcp_cmd, 2, 3, 1, 2, True, False, 0, 0)
1616 self.dhcp_table.attach(self.dhcp_cmd_button, 3, 4, 1, 2, False, False, 0, 0)
1618 self.dhcp_args = gtk.Entry()
1619 self.dhcp_args.set_width_chars(32)
1620 self.tooltips.set_tip(self.dhcp_args, "The start-up arguments to the DHCP command")
1621 self.dhcp_args.set_text(self.confFile.get_opt('DHCP.args'))
1622 self.dhcp_args_label = gtk.Label("Arguments")
1623 self.dhcp_table.attach(self.dhcp_args_label, 1, 2, 2, 3, True, False, 5, 0)
1624 self.dhcp_table.attach(self.dhcp_args, 2, 3, 2, 3, True, False, 0, 0)
1626 self.dhcp_kill_args = gtk.Entry()
1627 self.dhcp_kill_args.set_width_chars(32)
1628 self.tooltips.set_tip(self.dhcp_kill_args, "The shutdown arguments to the DHCP command")
1629 self.dhcp_kill_args.set_text(self.confFile.get_opt('DHCP.kill_args'))
1630 self.dhcp_kill_args_label = gtk.Label("Kill arguments")
1631 self.dhcp_table.attach(self.dhcp_kill_args_label, 1, 2, 3, 4, True, False, 5, 0)
1632 self.dhcp_table.attach(self.dhcp_kill_args, 2, 3, 3, 4, True, False, 0, 0)
1634 self.dhcp_timeout = gtk.Entry()
1635 self.dhcp_timeout.set_width_chars(32)
1636 self.tooltips.set_tip(self.dhcp_timeout, "The amount of time DHCP will spend trying to connect")
1637 self.dhcp_timeout.set_text(self.confFile.get_opt('DHCP.timeout'))
1638 self.dhcp_timeout_label = gtk.Label("DHCP connect timeout (seconds)")
1639 self.dhcp_table.attach(self.dhcp_timeout_label, 1, 2, 4, 5, True, False, 5, 0)
1640 self.dhcp_table.attach(self.dhcp_timeout, 2, 3, 4, 5, True, False, 0, 0)
1642 self.dhcp_pidfile = gtk.Entry()
1643 self.dhcp_pidfile.set_width_chars(32)
1644 self.tooltips.set_tip(self.dhcp_pidfile, "The file DHCP uses to store its PID")
1645 self.dhcp_pidfile.set_text(self.confFile.get_opt('DHCP.pidfile'))
1646 self.dhcp_pidfile_label = gtk.Label("PID file")
1647 self.dhcp_table.attach(self.dhcp_pidfile_label, 1, 2, 5, 6, True, False, 5, 0)
1648 self.dhcp_table.attach(self.dhcp_pidfile, 2, 3, 5, 6, True, False, 0, 0)
1650 self.prefs_notebook.append_page(self.dhcp_table, gtk.Label("DHCP"))
1651 ### End of DHCP tab
1653 ### WPA tab
1654 # table to use for layout of DHCP prefs
1655 self.wpa_table = gtk.Table()
1657 self.wpa_cmd = gtk.Entry()
1658 self.wpa_cmd.set_width_chars(32)
1659 self.tooltips.set_tip(self.wpa_cmd, "The command to use for WPA encrypted connections")
1660 self.wpa_cmd.set_text(self.confFile.get_opt('WPA.command'))
1661 self.wpa_cmd_label = gtk.Label("Command")
1662 self.wpa_cmd_button = file_browse_button(self.dialog, self.wpa_cmd)
1663 self.wpa_table.attach(self.wpa_cmd_label, 1, 2, 1, 2, True, False, 5, 0)
1664 self.wpa_table.attach(self.wpa_cmd, 2, 3, 1, 2, True, False, 0, 0)
1665 self.wpa_table.attach(self.wpa_cmd_button, 3, 4, 1, 2, False, False, 0, 0)
1667 self.wpa_args = gtk.Entry()
1668 self.wpa_args.set_width_chars(32)
1669 self.tooltips.set_tip(self.wpa_args, "The start-up arguments to the WPA command")
1670 self.wpa_args.set_text(self.confFile.get_opt('WPA.args'))
1671 self.wpa_args_label = gtk.Label("Arguments")
1672 self.wpa_table.attach(self.wpa_args_label, 1, 2, 2, 3, True, False, 5, 0)
1673 self.wpa_table.attach(self.wpa_args, 2, 3, 2, 3, True, False, 0, 0)
1675 self.wpa_kill_args = gtk.Entry()
1676 self.wpa_kill_args.set_width_chars(32)
1677 self.tooltips.set_tip(self.wpa_kill_args, "The shutdown arguments to the DHCP command")
1678 self.wpa_kill_args.set_text(self.confFile.get_opt('WPA.kill_command'))
1679 self.wpa_kill_args_label = gtk.Label("Kill command")
1680 self.wpa_table.attach(self.wpa_kill_args_label, 1, 2, 3, 4, True, False, 5, 0)
1681 self.wpa_table.attach(self.wpa_kill_args, 2, 3, 3, 4, True, False, 0, 0)
1683 self.wpa_config = gtk.Entry()
1684 self.wpa_config.set_width_chars(32)
1685 self.tooltips.set_tip(self.wpa_config, "The WPA configuration file to use")
1686 self.wpa_config.set_text(self.confFile.get_opt('WPA.configuration'))
1687 self.wpa_config_label = gtk.Label("Configuration file")
1688 self.wpa_table.attach(self.wpa_config_label, 1, 2, 4, 5, True, False, 5, 0)
1689 self.wpa_table.attach(self.wpa_config, 2, 3, 4, 5, True, False, 0, 0)
1691 self.wpa_driver = gtk.Entry()
1692 self.wpa_driver.set_width_chars(32)
1693 self.tooltips.set_tip(self.wpa_driver, "The WPA driver to use")
1694 self.wpa_driver.set_text(self.confFile.get_opt('WPA.driver'))
1695 self.wpa_driver_label = gtk.Label("Driver")
1696 self.wpa_table.attach(self.wpa_driver_label, 1, 2, 5, 6, True, False, 5, 0)
1697 self.wpa_table.attach(self.wpa_driver, 2, 3, 5, 6, True, False, 0, 0)
1699 self.wpa_pidfile = gtk.Entry()
1700 self.wpa_pidfile.set_width_chars(32)
1701 self.tooltips.set_tip(self.wpa_pidfile, "The file WPA uses to store its PID")
1702 self.wpa_pidfile.set_text(self.confFile.get_opt('WPA.pidfile'))
1703 self.wpa_pidfile_label = gtk.Label("PID file")
1704 self.wpa_table.attach(self.wpa_pidfile_label, 1, 2, 6, 7, True, False, 5, 0)
1705 self.wpa_table.attach(self.wpa_pidfile, 2, 3, 6, 7, True, False, 0, 0)
1707 self.prefs_notebook.append_page(self.wpa_table, gtk.Label("WPA"))
1708 ### End of WPA tab
1710 self.dialog.vbox.pack_start(self.prefs_notebook, False, False, 5)
1712 # Respond to Auto-detect checkbox toggle by activating/de-activating the interface combobox.
1714 #Parameters:
1716 # 'auto_detect_toggle' -- gtk.CheckButton - The checkbox sending the signal.
1718 # 'data' -- tuple - list of arbitrary arguments (not used)
1720 #Returns:
1722 # nothing
1723 def toggle_auto_detect(self, auto_detect_toggle, data=None):
1724 self.w_interface.set_sensitive(not auto_detect_toggle.get_active())
1726 # Respond to Speak-up checkbox toggle by activating/de-activating the Speak Cmd Entry.
1728 #Parameters:
1730 # 'speak_toggle' -- gtk.CheckButton - The checkbox sending the signal.
1732 # 'data' -- tuple - list of arbitrary arguments (not used)
1734 #Returns:
1736 # nothing
1737 def toggle_speak(self, speak_toggle, data=None):
1738 self.w_speak_cmd.set_sensitive(speak_toggle.get_active())
1739 self.w_speak_cmd_button.set_sensitive(speak_toggle.get_active())
1741 # Display preferences dialog and operate until canceled or okayed.
1743 #Parameters:
1745 # nothing
1747 #Returns:
1749 # integer -- gtk response ID
1750 def run(self):
1751 self.dialog.show_all()
1752 return self.dialog.run()
1754 # Write updated values to config file.
1756 #Parameters:
1758 # nothing
1760 #Returns:
1762 # nothing
1763 def save(self):
1764 if self.w_auto_detect.get_active():
1765 set_network_device("auto_detect")
1766 self.confFile.set_opt('DEFAULT.interface', "auto_detect")
1767 else:
1768 # get the selected interface, using a work-around suggested by PyGTK Tutorial
1769 interface = self.w_interface.get_model()[self.w_interface.get_active()][0]
1770 self.confFile.set_opt('DEFAULT.interface', interface)
1771 set_network_device(interface)
1772 #self.confFile.set_float_opt('DEFAULT.scan_timeout', self.w_scan_timeout.get_value())
1773 self.confFile.set_bool_opt('DEFAULT.speak_up', self.w_speak_up.get_active())
1774 self.confFile.set_bool_opt('DEFAULT.commit_required', self.w_commit_required.get_active())
1775 self.confFile.set_bool_opt('DEFAULT.ifup_required', self.w_ifup_required.get_active())
1776 self.confFile.set_opt('DEFAULT.speak_command', self.w_speak_cmd.get_text())
1777 self.confFile.set_opt('DEFAULT.ifconfig_command', self.ifconfig_cmd.get_text())
1778 self.confFile.set_opt('DEFAULT.iwconfig_command', self.iwconfig_cmd.get_text())
1779 self.confFile.set_opt('DEFAULT.iwlist_command', self.iwlist_cmd.get_text())
1780 self.confFile.set_opt('DEFAULT.route_command', self.route_cmd.get_text())
1781 self.confFile.set_opt('DEFAULT.logfile', self.logfile_entry.get_text())
1782 self.confFile.set_opt('DHCP.command', self.dhcp_cmd.get_text())
1783 self.confFile.set_opt('DHCP.args', self.dhcp_args.get_text())
1784 self.confFile.set_opt('DHCP.kill_args', self.dhcp_kill_args.get_text())
1785 self.confFile.set_opt('DHCP.timeout', self.dhcp_timeout.get_text())
1786 self.confFile.set_opt('DHCP.pidfile', self.dhcp_pidfile.get_text())
1787 self.confFile.set_opt('WPA.command', self.wpa_cmd.get_text())
1788 self.confFile.set_opt('WPA.args', self.wpa_args.get_text())
1789 self.confFile.set_opt('WPA.kill_command', self.wpa_kill_args.get_text())
1790 self.confFile.set_opt('WPA.configuration', self.wpa_config.get_text())
1791 self.confFile.set_opt('WPA.driver', self.wpa_driver.get_text())
1792 self.confFile.set_opt('WPA.pidfile', self.wpa_pidfile.get_text())
1793 try:
1794 self.confFile.write()
1795 except IOError, (error_number, error_str):
1796 if error_number == errno.ENOENT:
1797 error_dlg = ErrorDialog( self.window, "Could not save configuration file:\n%s\n\n%s" % (self.confFile.filename, error_str) )
1798 del error_dlg
1799 else:
1800 raise IOError(error_number, error_str)
1802 # Remove preferences window.
1804 #Parameters:
1806 # nothing
1808 #Returns:
1810 # nothing
1811 def destroy(self):
1812 self.dialog.destroy()
1813 del self.dialog
1816 # Edit and return an AP profile.
1817 class profile_dialog:
1818 # Create a new profile_dialog.
1820 #Parameters:
1822 # 'parent' -- gtk.Object - Usually, the calling window.
1824 # 'profile' -- dictionary - The profile to edit. May be mostly-empty default profile.
1826 #Returns:
1828 # profile_dialog instance
1829 def __init__( self, parent, profile ):
1830 global wifi_radar_icon
1832 # Labels
1833 WIFI_SET_LABEL = "WiFi Options"
1834 USE_DHCP_LABEL = "Automatic network configuration (DHCP)"
1835 USE_IP_LABEL = "Manual network configuration"
1836 USE_WPA_LABEL = "Use WPA"
1837 NO_WPA_LABEL = "No WPA"
1838 CON_PP_LABEL = "Connection Commands"
1839 DIS_PP_LABEL = "Disconnection Commands"
1841 self.parent = parent
1842 self.profile = profile.copy()
1843 self.WIFI_MODES = [ '', 'auto', 'Managed', 'Ad-Hoc', 'Master', 'Repeater', 'Secondary', 'Monitor' ]
1844 self.WIFI_SECURITY = [ '', 'open', 'restricted' ]
1845 self.WIFI_CHANNELS = [ '', 'auto', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14' ]
1846 self.dialog = gtk.Dialog('WiFi Profile', self.parent.window,
1847 gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
1848 ( gtk.STOCK_CANCEL, False, gtk.STOCK_SAVE, True ) )
1849 icon = gtk.gdk.pixbuf_new_from_inline( len( wifi_radar_icon[0] ), wifi_radar_icon[0], False )
1850 self.dialog.set_icon( icon )
1851 self.dialog.set_resizable( False )
1852 self.dialog.set_transient_for( self.parent.window )
1853 #self.dialog.set_size_request( 400, 400 )
1854 #################
1855 self.tooltips = gtk.Tooltips()
1857 general_table = gtk.Table()
1858 general_table.set_row_spacings(3)
1859 general_table.set_col_spacings(3)
1860 # The essid labels
1861 general_table.attach(gtk.Label('Network Name'), 0, 1, 0, 1)
1862 # The essid textboxes
1863 self.essid_entry = gtk.Entry(32)
1864 self.essid_entry.set_text(self.profile['essid'])
1865 general_table.attach(self.essid_entry, 1, 2, 0, 1)
1866 # Add the essid table to the dialog
1867 self.dialog.vbox.pack_start(general_table, True, True, 5)
1868 self.tooltips.set_tip(self.essid_entry, "The name of the network with which to connect.")
1870 # The bssid labels
1871 general_table.attach(gtk.Label('Network Address'), 0, 1, 1, 2)
1872 # The bssid textboxes
1873 self.bssid_entry = gtk.Entry(32)
1874 self.bssid_entry.set_text(self.profile['bssid'])
1875 self.bssid_entry.set_sensitive(not self.profile['roaming'])
1876 # Add the bssid table to the dialog
1877 general_table.attach(self.bssid_entry, 1, 2, 1, 2)
1878 self.tooltips.set_tip(self.bssid_entry, "The address of the network with which to connect.")
1879 # Add the roaming checkbox
1880 self.roaming_cb = gtk.CheckButton('Roaming')
1881 self.roaming_cb.set_active(self.profile['roaming'])
1882 self.roaming_cb.connect("toggled", self.toggle_roaming)
1883 general_table.attach(self.roaming_cb, 1, 2, 2, 3)
1884 self.tooltips.set_tip(self.roaming_cb, "Use the AP in this network which provides strongest signal?")
1885 # create the WiFi expander
1886 self.wifi_expander = gtk.Expander( WIFI_SET_LABEL )
1887 #self.wifi_expander.connect( 'notify::expanded', self.toggle_use_dhcp )
1888 wifi_table = gtk.Table( 4, 2, False )
1889 wifi_table.set_row_spacings( 3 )
1890 wifi_table.set_col_spacings( 3 )
1891 # The WiFi labels
1892 wifi_table.attach( gtk.Label( 'Mode' ), 0, 1, 0, 1 )
1893 wifi_table.attach( gtk.Label( 'Channel' ), 0, 1, 1, 2 )
1894 wifi_table.attach( gtk.Label( 'Key' ), 0, 1, 2, 3 )
1895 wifi_table.attach( gtk.Label( 'Security' ), 0, 1, 3, 4 )
1896 # The WiFi text boxes
1897 self.mode_combo = gtk.combo_box_new_text()
1898 for mode in self.WIFI_MODES:
1899 self.mode_combo.append_text( mode )
1900 self.mode_combo.set_active( self.get_array_index( self.profile['mode'], self.WIFI_MODES ) )
1901 wifi_table.attach( self.mode_combo, 1, 2, 0, 1 )
1902 self.tooltips.set_tip(self.mode_combo, "Method to use for connection. You probably want auto mode.")
1903 self.channel_combo = gtk.combo_box_new_text()
1904 for channel in self.WIFI_CHANNELS:
1905 self.channel_combo.append_text( channel )
1906 self.channel_combo.set_active( self.get_array_index( self.profile['channel'], self.WIFI_CHANNELS ) )
1907 wifi_table.attach( self.channel_combo, 1, 2, 1, 2 )
1908 self.tooltips.set_tip(self.channel_combo, "Channel the network uses. You probably want auto mode.")
1910 self.key_entry = gtk.Entry( 64 )
1911 self.key_entry.set_text( self.profile['key'] )
1912 wifi_table.attach( self.key_entry, 1, 2, 2, 3 )
1913 self.tooltips.set_tip(self.key_entry, "WEP key: Plain language or hex string to use for encrypted communication with the network.")
1915 self.security_combo = gtk.combo_box_new_text()
1916 for security in self.WIFI_SECURITY:
1917 self.security_combo.append_text( security )
1918 self.security_combo.set_active( self.get_array_index( self.profile['security'], self.WIFI_SECURITY ) )
1919 wifi_table.attach( self.security_combo, 1, 2, 3, 4 )
1920 self.tooltips.set_tip(self.security_combo, "Use Open to allow unencrypted communication and Restricted to force encrypted-only communication.")
1921 # Add the wifi table to the expander
1922 self.wifi_expander.add( wifi_table )
1923 # Add the expander to the dialog
1924 self.dialog.vbox.pack_start( self.wifi_expander, False, False, 5 )
1926 # create the wpa expander
1927 self.wpa_expander = gtk.Expander( NO_WPA_LABEL )
1928 self.wpa_expander.connect( 'notify::expanded', self.toggle_use_wpa )
1929 wpa_table = gtk.Table( 1, 2, False )
1930 wpa_table.set_row_spacings( 3 )
1931 wpa_table.set_col_spacings( 3 )
1932 # The labels
1933 wpa_table.attach( gtk.Label( 'Driver' ), 0, 1, 0, 1 )
1934 # The text boxes
1935 self.wpa_driver_entry = gtk.Entry()
1936 self.wpa_driver_entry.set_text( self.profile['wpa_driver'] )
1937 wpa_table.attach( self.wpa_driver_entry, 1, 2, 0, 1 )
1938 # Add the wpa table to the expander
1939 self.wpa_expander.add( wpa_table )
1940 # Add the expander to the dialog
1941 self.dialog.vbox.pack_start( self.wpa_expander, False, False, 5 )
1943 # create the dhcp expander
1944 self.dhcp_expander = gtk.Expander( USE_DHCP_LABEL )
1945 self.dhcp_expander.connect( 'notify::expanded', self.toggle_use_dhcp )
1946 ip_table = gtk.Table( 6, 2, False )
1947 ip_table.set_row_spacings( 3 )
1948 ip_table.set_col_spacings( 3 )
1949 # The IP labels
1950 ip_table.attach( gtk.Label( 'IP' ), 0, 1, 0, 1 )
1951 ip_table.attach( gtk.Label( 'Netmask' ), 0, 1, 1, 2 )
1952 ip_table.attach( gtk.Label( 'Gateway' ), 0, 1, 2, 3 )
1953 ip_table.attach( gtk.Label( 'Domain' ), 0, 1, 3, 4 )
1954 ip_table.attach( gtk.Label( 'DNS' ), 0, 1, 4, 5 )
1955 ip_table.attach( gtk.Label( 'DNS' ), 0, 1, 5, 6 )
1956 # The IP text boxes
1957 self.ip_entry = gtk.Entry( 15 )
1958 self.ip_entry.set_text( self.profile['ip'] )
1959 ip_table.attach( self.ip_entry, 1, 2, 0, 1 )
1960 self.netmask_entry = gtk.Entry( 15 )
1961 self.netmask_entry.set_text( self.profile['netmask'] )
1962 ip_table.attach( self.netmask_entry, 1, 2, 1, 2 )
1963 self.gw_entry = gtk.Entry( 15 )
1964 self.gw_entry.set_text( self.profile['gateway'] )
1965 ip_table.attach( self.gw_entry, 1, 2, 2, 3 )
1966 self.domain_entry = gtk.Entry( 32 )
1967 self.domain_entry.set_text( self.profile['domain'] )
1968 ip_table.attach( self.domain_entry, 1, 2, 3, 4 )
1969 self.dns1_entry = gtk.Entry( 15 )
1970 self.dns1_entry.set_text( self.profile['dns1'] )
1971 ip_table.attach( self.dns1_entry, 1, 2, 4, 5 )
1972 self.dns2_entry = gtk.Entry( 15 )
1973 self.dns2_entry.set_text( self.profile['dns2'] )
1974 ip_table.attach( self.dns2_entry, 1, 2, 5, 6 )
1975 # Add the ip table to the expander
1976 self.dhcp_expander.add( ip_table )
1977 # Add the expander to the dialog
1978 self.dialog.vbox.pack_start( self.dhcp_expander, False, False, 5 )
1980 # create the connection-building postpre expander
1981 self.con_pp_expander = gtk.Expander( CON_PP_LABEL )
1982 con_pp_table = gtk.Table( 2, 2, False )
1983 con_pp_table.set_row_spacings( 3 )
1984 con_pp_table.set_col_spacings( 3 )
1985 # The labels
1986 con_pp_table.attach( gtk.Label( 'Before' ), 0, 1, 0, 1 )
1987 con_pp_table.attach( gtk.Label( 'After' ), 0, 1, 1, 2 )
1988 # The text boxes
1989 self.con_prescript_entry = gtk.Entry()
1990 self.con_prescript_entry.set_text( self.profile['con_prescript'] )
1991 con_pp_table.attach( self.con_prescript_entry, 1, 2, 0, 1 )
1992 self.tooltips.set_tip(self.con_prescript_entry, "The local command to execute before trying to connect to the network.")
1993 self.con_postscript_entry = gtk.Entry()
1994 self.con_postscript_entry.set_text( self.profile['con_postscript'] )
1995 con_pp_table.attach( self.con_postscript_entry, 1, 2, 1, 2 )
1996 self.tooltips.set_tip(self.con_postscript_entry, "The local command to execute after connecting to the network.")
1997 # Add the pp table to the expander
1998 self.con_pp_expander.add( con_pp_table )
1999 # Add the expander to the dialog
2000 self.dialog.vbox.pack_start( self.con_pp_expander, False, False, 5 )
2002 # create the disconnection postpre expander
2003 self.dis_pp_expander = gtk.Expander( DIS_PP_LABEL )
2004 dis_pp_table = gtk.Table( 2, 2, False )
2005 dis_pp_table.set_row_spacings( 3 )
2006 dis_pp_table.set_col_spacings( 3 )
2007 # The labels
2008 dis_pp_table.attach( gtk.Label( 'Before' ), 0, 1, 0, 1 )
2009 dis_pp_table.attach( gtk.Label( 'After' ), 0, 1, 1, 2 )
2010 # The text boxes
2011 self.dis_prescript_entry = gtk.Entry()
2012 self.dis_prescript_entry.set_text( self.profile['dis_prescript'] )
2013 dis_pp_table.attach( self.dis_prescript_entry, 1, 2, 0, 1 )
2014 self.tooltips.set_tip(self.dis_prescript_entry, "The local command to execute before disconnecting from the network.")
2015 self.dis_postscript_entry = gtk.Entry()
2016 self.dis_postscript_entry.set_text( self.profile['dis_postscript'] )
2017 dis_pp_table.attach( self.dis_postscript_entry, 1, 2, 1, 2 )
2018 self.tooltips.set_tip(self.dis_postscript_entry, "The local command to execute after disconnecting from the network.")
2019 # Add the pp table to the expander
2020 self.dis_pp_expander.add( dis_pp_table )
2021 # Add the expander to the dialog
2022 self.dialog.vbox.pack_start( self.dis_pp_expander, False, False, 5 )
2024 # Display profile dialog, operate until canceled or okayed, and, possibly, return edited profile values.
2026 #Parameters:
2028 # nothing
2030 #Returns:
2032 # dictionary or None -- a profile, or None on cancel
2034 #NOTES:
2036 # Raises ValueError if an attempt is made to save an ESSID with no name.
2037 def run( self ):
2038 self.dialog.show_all()
2039 if self.dialog.run():
2040 if self.essid_entry.get_text().strip() == "":
2041 raise ValueError
2042 self.profile['known'] = True
2043 self.profile['essid'] = self.essid_entry.get_text().strip()
2044 if self.roaming_cb.get_active():
2045 self.profile['bssid'] = ''
2046 else:
2047 self.profile['bssid'] = self.bssid_entry.get_text().strip()
2048 self.profile['roaming'] = self.roaming_cb.get_active()
2049 self.profile['key'] = self.key_entry.get_text().strip()
2050 self.profile['mode'] = self.get_array_item( self.mode_combo.get_active(), self.WIFI_MODES )
2051 self.profile['security'] = self.get_array_item( self.security_combo.get_active(), self.WIFI_SECURITY )
2052 self.profile['encrypted'] = ( self.profile['security'] != '' )
2053 self.profile['channel'] = self.get_array_item( self.channel_combo.get_active(), self.WIFI_CHANNELS )
2054 self.profile['protocol'] = 'g'
2055 self.profile['available'] = ( self.profile['signal'] > 0 )
2056 self.profile['con_prescript'] = self.con_prescript_entry.get_text().strip()
2057 self.profile['con_postscript'] = self.con_postscript_entry.get_text().strip()
2058 self.profile['dis_prescript'] = self.dis_prescript_entry.get_text().strip()
2059 self.profile['dis_postscript'] = self.dis_postscript_entry.get_text().strip()
2060 # wpa
2061 self.profile['use_wpa'] = self.wpa_expander.get_expanded()
2062 self.profile['wpa_driver'] = self.wpa_driver_entry.get_text().strip()
2063 # dhcp
2064 self.profile['use_dhcp'] = not self.dhcp_expander.get_expanded()
2065 self.profile['ip'] = self.ip_entry.get_text().strip()
2066 self.profile['netmask'] = self.netmask_entry.get_text().strip()
2067 self.profile['gateway'] = self.gw_entry.get_text().strip()
2068 self.profile['domain'] = self.domain_entry.get_text().strip()
2069 self.profile['dns1'] = self.dns1_entry.get_text().strip()
2070 self.profile['dns2'] = self.dns2_entry.get_text().strip()
2071 return self.profile
2072 return None
2074 # Remove profile dialog.
2076 #Parameters:
2078 # nothing
2080 #Returns:
2082 # nothing
2083 def destroy( self ):
2084 self.dialog.destroy()
2085 del self.dialog
2087 # Respond to roaming checkbox toggle by activating/de-activating the BSSID text entry.
2089 #Parameters:
2091 # 'roaming_toggle' -- gtk.CheckButton - The checkbox sending the signal.
2093 # 'data' -- tuple - list of arbitrary arguments (not used)
2095 #Returns:
2097 # nothing
2098 def toggle_roaming(self, roaming_toggle, data=None):
2099 self.bssid_entry.set_sensitive(not roaming_toggle.get_active())
2101 # Respond to expanding/hiding IP segment.
2103 #Parameters:
2105 # 'widget' -- gtk.Widget - The widget sending the event.
2107 # 'data' -- tuple - List of arbitrary arguments (not used)
2109 #Returns:
2111 # nothing
2112 def toggle_use_dhcp( self, widget, data = None ):
2113 expanded = self.dhcp_expander.get_expanded()
2114 if expanded:
2115 self.dhcp_expander.set_label( USE_IP_LABEL )
2116 else:
2117 self.dhcp_expander.set_label( USE_DHCP_LABEL )
2119 # Respond to expanding/hiding WPA segment.
2121 #Parameters:
2123 # 'widget' -- gtk.Widget - The widget sending the event.
2125 # 'data' -- tuple - List of arbitrary arguments (not used)
2127 #Returns:
2129 # nothing
2130 def toggle_use_wpa( self, widget, data = None ):
2131 expanded = self.wpa_expander.get_expanded()
2132 if expanded:
2133 self.wpa_expander.set_label( USE_WPA_LABEL )
2134 else:
2135 self.wpa_expander.set_label( NO_WPA_LABEL )
2137 # Return the index where item matches a cell in array.
2139 #Parameters:
2141 # 'item' -- string - Item to find in array
2143 # 'array' -- list - List in which to find match.
2145 #Returns:
2147 # integer - 0 (no match) or higher (index of match)
2148 def get_array_index( self, item, array ):
2149 try:
2150 return array.index( item.strip() )
2151 except:
2152 pass
2153 return 0
2155 # Return the value in array[ index ]
2157 #Parameters:
2159 # 'index' -- integer - The index to look up.
2161 # 'array' -- list - List in which to look up value.
2163 #Returns:
2165 # string -- empty string (no match) or looked up value
2166 def get_array_item( self, index, array ):
2167 try:
2168 return array[ index ]
2169 except:
2170 pass
2171 return ''
2174 # A simple class for putting up a "Please wait" dialog so the user
2175 # doesn't think we've forgotten about them. Implements the status interface.
2176 class StatusWindow:
2177 # Create a new StatusWindow.
2179 #Parameters:
2181 # 'parent' -- gtk.Object - Usually, the calling window.
2183 #Returns:
2185 # StatusWindow instance
2187 #NOTE:
2189 # Sample implementation of status interface. Status interface
2190 #requires .show(), .update_message(message), and .hide() methods.
2191 def __init__( self, parent ):
2192 global wifi_radar_icon
2193 self.parent = parent
2194 self.dialog = gtk.Dialog("Working", self.parent.window, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
2195 icon = gtk.gdk.pixbuf_new_from_inline( len( wifi_radar_icon[0] ), wifi_radar_icon[0], False )
2196 self.dialog.set_icon( icon )
2197 self.lbl = gtk.Label("Please wait...")
2198 self.bar = gtk.ProgressBar()
2199 self.dialog.vbox.pack_start(self.lbl)
2200 self.dialog.vbox.pack_start(self.bar)
2201 self.cancel_button = self.dialog.add_button(gtk.STOCK_CANCEL, gtk.BUTTONS_CANCEL)
2202 self.timer = None
2204 # Change the message displayed to the user.
2206 #Parameters:
2208 # 'message' -- string - The message to show to the user.
2210 #Returns:
2212 # nothing
2213 def update_message( self, message ):
2214 self.lbl.set_text(message)
2216 # Update the StatusWindow progress bar.
2218 #Parameters:
2220 # nothing
2222 #Returns:
2224 # True -- always return True
2225 def update_window( self ):
2226 self.bar.pulse()
2227 return True
2229 # Display and operate the StatusWindow.
2231 #Parameters:
2233 # nothing
2235 #Returns:
2237 # nothing
2238 def run( self ):
2239 pass
2241 # Show all the widgets of the StatusWindow.
2243 #Parameters:
2245 # nothing
2247 #Returns:
2249 # nothing
2250 def show( self ):
2251 self.dialog.show_all()
2252 self.timer = gobject.timeout_add(250, self.update_window)
2253 return False
2255 # Hide all the widgets of the StatusWindow.
2257 #Parameters:
2259 # nothing
2261 #Returns:
2263 # nothing
2264 def hide( self ):
2265 if self.timer:
2266 gobject.source_remove(self.timer)
2267 self.timer = None
2268 self.dialog.hide_all()
2269 return False
2271 # Remove the StatusWindow.
2273 #Parameters:
2275 # nothing
2277 #Returns:
2279 # nothing
2280 def destroy( self ):
2281 if self.timer:
2282 gobject.source_remove(self.timer)
2283 self.dialog.destroy()
2284 del self.dialog
2287 # Manage a GTK About Dialog
2288 class about_dialog(gtk.AboutDialog):
2289 # Subclass GTK AboutDialog
2291 #Parameters:
2293 # nothing
2295 #Returns:
2297 # nothing
2298 def __init__( self ):
2299 global wifi_radar_icon
2301 gtk.AboutDialog.__init__(self)
2302 self.set_authors(["Ahmad Baitalmal <ahmad@baitalmal.com>", "Brian Elliott Finley <brian@thefinleys.com>", "Sean Robinson <seankrobinson@gmail.com>", "", "Contributors", "Douglas Breault", "Jon Collette", "David Decotigny", "Simon Gerber", "Joey Hurst", u"Ante Karamati\xc4\x87", "Richard Monk", "Brouard Nicolas", "Kevin Otte", "Nathanael Rebsch", "Patrick Winnertz"])
2303 self.set_comments("WiFi connection manager")
2304 self.set_copyright("Copyright 2004-2009 by various authors and contributors\nCurrent Maintainer: Sean Robinson <seankrobinson@gmail.com>")
2305 self.set_documenters(["Gary Case"])
2306 license = """
2307 This program is free software; you can redistribute it and/or modify
2308 it under the terms of the GNU General Public License as published by
2309 the Free Software Foundation; either version 2 of the License, or
2310 (at your option) any later version.
2312 This program is distributed in the hope that it will be useful,
2313 but WITHOUT ANY WARRANTY; without even the implied warranty of
2314 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2315 GNU General Public License for more details.
2317 You should have received a copy of the GNU General Public License
2318 along with this program; if not, write to the Free Software
2319 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"""
2320 self.set_license(license)
2321 logo = gtk.gdk.pixbuf_new_from_inline( len( wifi_radar_icon[0] ), wifi_radar_icon[0], False )
2322 self.set_logo(logo)
2323 self.set_name("WiFi Radar")
2324 self.set_version(WIFI_RADAR_VERSION)
2325 self.set_website("http://wifi-radar.berlios.de")
2329 # Manage the configuration for the application, including reading and writing the config from/to a file.
2330 class ConfigFile(ConfigParser.SafeConfigParser):
2331 # Create a new ConfigFile.
2333 #Parameters:
2335 # 'filename' -- string - The configuration file's name.
2337 # 'defaults' -- dictionary - Default values for the DEFAULT section.
2339 #Returns:
2341 # ConfigFile instance
2342 def __init__( self, filename, defaults, raw=False ):
2343 self.filename = filename
2344 self.raw = raw
2345 self.auto_profile_order = []
2346 ConfigParser.SafeConfigParser.__init__(self, defaults)
2348 # Set the contents of a section to values from a dictionary.
2350 #Parameters:
2352 # 'section_name' -- string - Configuration file section.
2354 # 'section_dict' -- dictionary - Values to add to section.
2356 #Returns:
2358 # nothing
2359 def set_section( self, section_name, section_dict ):
2360 try:
2361 self.add_section(section_name)
2362 except ConfigParser.DuplicateSectionError:
2363 pass
2364 for key in section_dict.keys():
2365 if type(section_dict[key]) == BooleanType:
2366 self.set_bool_opt(section_name + "." + key, section_dict[key])
2367 elif type(section_dict[key]) == IntType:
2368 self.set_int_opt(section_name + "." + key, section_dict[key])
2369 elif type(section_dict[key]) == FloatType:
2370 self.set_float_opt(section_name + "." + key, section_dict[key])
2371 else:
2372 self.set_opt(section_name + "." + key, section_dict[key])
2374 # Return the profile recorded in the specified section.
2376 #Parameters:
2378 # 'section_name' -- string - Configuration file section.
2380 #Returns:
2382 # dictionary or None - The specified profile or None if not found
2383 def get_profile( self, section_name ):
2384 if section_name in self.profiles():
2385 str_types = [ 'bssid', 'channel', 'essid', 'protocol', 'con_prescript', 'con_postscript', 'dis_prescript', 'dis_postscript', 'key', 'mode', 'security', 'wpa_driver', 'ip', 'netmask', 'gateway', 'domain', 'dns1', 'dns2' ]
2386 bool_types = [ 'known', 'available', 'roaming', 'encrypted', 'use_wpa', 'use_dhcp' ]
2387 int_types = [ 'signal' ]
2388 profile = get_new_profile()
2389 for option in bool_types:
2390 option_tmp = self.get_opt_as_bool(section_name + "." + option)
2391 if option_tmp:
2392 profile[option] = option_tmp
2393 for option in int_types:
2394 option_tmp = self.get_opt_as_int(section_name + "." + option)
2395 if option_tmp:
2396 profile[option] = option_tmp
2397 for option in str_types:
2398 option_tmp = self.get_opt(section_name + "." + option)
2399 if option_tmp:
2400 profile[option] = option_tmp
2401 return profile
2402 return None
2404 # Get a config option and handle exceptions.
2406 #Parameters:
2408 # 'option_path' -- string - Section (a.k.a. profile) name concatenated with a
2409 # period and the option key. (E.g. "DEFAULT.interface")
2411 #Returns:
2413 # string or None - option value as string or None on failure
2414 def get_opt( self, option_path ):
2415 #print "ConfigFile.get_opt: ", option_path
2416 (section, option) = option_path.split('.')
2417 try:
2418 return self.get(section, option, self.raw)
2419 except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
2420 return None
2422 # Get a config option and return as a boolean type.
2424 #Parameters:
2426 # 'option_path' -- string - Section (a.k.a. profile) name concatenated with a
2427 # period and the option key. (E.g. "DEFAULT.interface")
2429 #Returns:
2431 # boolean - option value as boolean
2432 def get_opt_as_bool( self, option_path ):
2433 option = self.get_opt(option_path)
2434 if isinstance(option, BooleanType) or isinstance(option, NoneType):
2435 return option
2436 if option == 'True':
2437 return True
2438 if option == 'False':
2439 return False
2440 raise ValueError, 'boolean option was not True or False'
2442 # Get a config option and return as an integer type.
2444 #Parameters:
2446 # 'option_path' -- string - Section (a.k.a. profile) name concatenated with a
2447 # period and the option key. (E.g. "DEFAULT.interface")
2449 #Returns:
2451 # integer- option value as integer
2452 def get_opt_as_int( self, option_path ):
2453 return int(float(self.get_opt(option_path)))
2455 # Convert boolean type to string and set config option.
2457 #Parameters:
2459 # 'option_path' -- string - Section (a.k.a. profile) name concatenated with a
2460 # period and the option key. (E.g. "DEFAULT.interface")
2462 # 'value' -- boolean - Value to set.
2464 #Returns:
2466 # nothing
2467 def set_bool_opt( self, option_path, value ):
2468 if ( value == True ) or ( value > 0 ) or ( value == 'True' ):
2469 value == 'True'
2470 elif ( value == False ) or ( value == 0 ) or ( value == 'False' ):
2471 value == 'False'
2472 else:
2473 raise ValueError, 'cannot convert value to string'
2474 self.set_opt(option_path, repr(value))
2476 # Convert integer type to string and set config option.
2478 #Parameters:
2480 # 'option_path' -- string - Section (a.k.a. profile) name concatenated with a
2481 # period and the option key. (E.g. "DEFAULT.interface")
2483 # 'value' -- integer - Value to set.
2485 #Returns:
2487 # nothing
2488 def set_int_opt( self, option_path, value ):
2489 if not isinstance(value, IntType):
2490 raise ValueError, 'value is not an integer'
2491 self.set_opt(option_path, repr(value))
2493 # Convert float type to string and set config option.
2495 #Parameters:
2497 # 'option_path' -- string - Section (a.k.a. profile) name concatenated with a
2498 # period and the option key. (E.g. "DEFAULT.interface")
2500 # 'value' -- float - Value to set.
2502 #Returns:
2504 # nothing
2505 def set_float_opt( self, option_path, value ):
2506 if not isinstance(value, FloatType):
2507 raise ValueError, 'value is not a float'
2508 self.set_opt(option_path, repr(int(value)))
2510 # Set a config option while handling exceptions.
2512 #Parameters:
2514 # 'option_path' -- string - Section (a.k.a. profile) name concatenated with a
2515 # period and the option key. (E.g. "DEFAULT.interface")
2517 # 'value' -- string - Value to set.
2519 #Returns:
2521 # nothing
2522 def set_opt( self, option_path, value ):
2523 (section, option) = option_path.split('.')
2524 try:
2525 self.set(section, option, value)
2526 except ConfigParser.NoSectionError:
2527 self.add_section(section)
2528 self.set_opt(option_path, value)
2530 # Return a list of the section names which denote AP profiles.
2532 #Parameters:
2534 # nothing
2536 #Returns:
2538 # list - profile names
2539 def profiles( self ):
2540 profile_list = []
2541 for section in self.sections():
2542 if ':' in section:
2543 profile_list.append(section)
2544 return profile_list
2546 # Read configuration file from disk into instance variables.
2548 #Parameters:
2550 # nothing
2552 #Returns:
2554 # nothing
2555 def read( self ):
2556 fp = open( self.filename, "r" )
2557 self.readfp(fp)
2558 # convert the auto_profile_order to a list for ordering
2559 self.auto_profile_order = eval(self.get_opt('DEFAULT.auto_profile_order'))
2560 for ap in self.profiles():
2561 self.set_bool_opt( ap + '.known', True)
2562 if ap in self.auto_profile_order: continue
2563 self.auto_profile_order.append( ap )
2564 fp.close()
2566 # Write configuration file to disk from instance variables. Copied from
2567 # ConfigParser and modified to write options in alphabetical order.
2569 #Parameters:
2571 # nothing
2573 #Returns:
2575 # nothing
2576 def write( self ):
2577 self.set_opt('DEFAULT.auto_profile_order', str(self.auto_profile_order))
2578 self.set_opt('DEFAULT.version', WIFI_RADAR_VERSION)
2579 fp = open( self.filename, "w" )
2580 # write DEFAULT section first
2581 if self._defaults:
2582 fp.write("[DEFAULT]\n")
2583 for key in sorted(self._defaults.keys()):
2584 fp.write("%s = %s\n" % (key, str(self._defaults[key]).replace('\n','\n\t')))
2585 fp.write("\n")
2586 # write non-profile sections first
2587 for section in self._sections:
2588 if section not in self.profiles():
2589 fp.write("[%s]\n" % section)
2590 for key in sorted(self._sections[section].keys()):
2591 if key != "__name__":
2592 fp.write("%s = %s\n" %
2593 (key, str(self._sections[section][key]).replace('\n', '\n\t')))
2594 fp.write("\n")
2595 # write profile sections
2596 for section in self._sections:
2597 if section in self.profiles():
2598 fp.write("[%s]\n" % section)
2599 for key in sorted(self._sections[section].keys()):
2600 if key != "__name__":
2601 fp.write("%s = %s\n" %
2602 (key, str(self._sections[section][key]).replace('\n', '\n\t')))
2603 fp.write("\n")
2604 fp.close()
2608 # Load our conf file and known profiles
2609 # Defaults, these may get overridden by values found in the conf file.
2610 config_defaults = { # The network interface you use.
2611 # Specify "auto_detect" as the interface to make wifi-radar automatically detect your wireless card.
2612 'interface': "auto_detect",
2613 # How long should the scan for access points last?
2614 #'scan_timeout': '5',
2615 # X1000 Linux has a say command (text to speech) to announce connecting to networks.
2616 # Set the speak_up option to false if you do not have or want this.
2617 'speak_command': '/usr/bin/say',
2618 # Should I speak up when connecting to a network? (If you have a speech command)
2619 'speak_up': 'False',
2620 # You may set this to true for cards that require a "commit" command with iwconfig
2621 'commit_required': 'False',
2622 # You may set this to true for cards that require the interface to be brought up first
2623 'ifup_required': 'False',
2624 # set the location of the log file
2625 'logfile': './wifi-radar.log',
2626 # Set the location of several important programs
2627 'iwlist_command': '/sbin/iwlist',
2628 'iwconfig_command': '/sbin/iwconfig',
2629 'ifconfig_command': '/sbin/ifconfig',
2630 'route_command': '/sbin/route',
2631 'auto_profile_order': '[]',
2632 'version': WIFI_RADAR_VERSION }
2634 config_dhcp = { # DHCP client
2635 'command': 'dhcpcd',
2636 # How long to wait for an IP addr from DHCP server
2637 'timeout': '30',
2638 # Arguments to use with DHCP client on connect
2639 'args': '-D -o -i dhcp_client -t %(timeout)s',
2640 # Argument to use with DHCP client on disconnect
2641 'kill_args': '-k',
2642 # The file where DHCP client PID is written
2643 'pidfile': '/etc/dhcpc/dhcpcd-%(interface)s.pid' }
2645 config_wpa = { # WPA Supplicant
2646 'command': '/usr/sbin/wpa_supplicant',
2647 # Arguments to use with WPA Supplicant on connect
2648 'args': '-B -i %(interface)s -c %(configuration)s -D %(driver)s -P %(pidfile)s',
2649 # Arguments to use with WPA Supplicant on disconnect
2650 'kill_command': '',
2651 # Where the WPA Supplicant config file can be found
2652 'configuration': '/etc/wpa_supplicant.conf',
2653 # Driver to use with WPA Supplicant
2654 'driver': 'wext',
2655 # The file where WPA Supplicant PID is written
2656 'pidfile': '/var/run/wpa_supplicant.pid' }
2658 # initialize config, with defaults
2659 confFile = ConfigFile(CONF_FILE, config_defaults)
2660 confFile.set_section("DHCP", config_dhcp)
2661 confFile.set_section("WPA", config_wpa)
2663 if not os.path.isfile( CONF_FILE ):
2664 confFile.set_bool_opt('DEFAULT.new_file', True)
2665 else:
2666 if not os.access(CONF_FILE, os.R_OK):
2667 print "Can't open " + CONF_FILE + "."
2668 print "Are you root?"
2669 sys.exit()
2670 confFile.read()
2673 ####################################################################################################
2674 # Embedded Images
2675 wifi_radar_icon = [ ""
2676 "GdkP"
2677 "\0\0\22""7"
2678 "\2\1\0\2"
2679 "\0\0\1\214"
2680 "\0\0\0c"
2681 "\0\0\0O"
2682 "\377\377\377\377\0\377\377\377\377\0\377\377\377\377\0\377\377\377\377"
2683 "\0\377\377\377\377\0\377\377\377\377\0\377\377\377\377\0\261\377\377"
2684 "\377\0\7\0\0\0\10\0\0\0\25\0\0\0\35\0\0\0%\0\0\0-\0\0\0\"\0\0\0\11\327"
2685 "\377\377\377\0\6\0\0\0\"\0\0\0_\0\0\0\213\0\0\0\266\0\0\0\341\0\0\0\376"
2686 "\206\0\0\0\377\6\0\0\0\356\0\0\0\324\0\0\0\265\0\0\0~\0\0\0@\0\0\0\10"
2687 "\315\377\377\377\0\4\0\0\0\2\0\0\0;\0\0\0\210\0\0\0\325\221\0\0\0\377"
2688 "\4\0\0\0\371\0\0\0\303\0\0\0w\0\0\0\31\310\377\377\377\0\3\0\0\0\6\0"
2689 "\0\0m\0\0\0\342\227\0\0\0\377\4\0\0\0\374\0\0\0\264\0\0\0Q\0\0\0\5\303"
2690 "\377\377\377\0\3\0\0\0\4\0\0\0d\0\0\0\341\234\0\0\0\377\3\0\0\0\341\0"
2691 "\0\0`\0\0\0\2\277\377\377\377\0\3\0\0\0\2\0\0\0[\0\0\0\333\240\0\0\0"
2692 "\377\2\0\0\0\323\0\0\0K\274\377\377\377\0\3\0\0\0\1\0\0\0R\0\0\0\324"
2693 "\244\0\0\0\377\2\0\0\0\276\0\0\0#\271\377\377\377\0\2\0\0\0\31\0\0\0"
2694 "\277\247\0\0\0\377\2\0\0\0\363\0\0\0c\267\377\377\377\0\2\0\0\0/\0\0"
2695 "\0\343\252\0\0\0\377\2\0\0\0\257\0\0\0\24\264\377\377\377\0\2\0\0\0M"
2696 "\0\0\0\363\220\0\0\0\377\14\0\0\0\357\0\0\0\304\0\0\0\230\0\0\0v\0\0"
2697 "\0l\0\0\0c\0\0\0[\0\0\0j\0\0\0\205\0\0\0\240\0\0\0\311\0\0\0\373\220"
2698 "\0\0\0\377\2\0\0\0\346\0\0\0""4\262\377\377\377\0\2\0\0\0q\0\0\0\375"
2699 "\215\0\0\0\377\4\0\0\0\373\0\0\0\300\0\0\0t\0\0\0)\213\377\377\377\0"
2700 "\4\0\0\0\14\0\0\0E\0\0\0\205\0\0\0\334\216\0\0\0\377\2\0\0\0\363\0\0"
2701 "\0D\257\377\377\377\0\2\0\0\0\4\0\0\0\230\215\0\0\0\377\3\0\0\0\372\0"
2702 "\0\0\231\0\0\0\34\221\377\377\377\0\4\0\0\0\1\0\0\0C\0\0\0\251\0\0\0"
2703 "\372\214\0\0\0\377\2\0\0\0\371\0\0\0W\255\377\377\377\0\2\0\0\0\17\0"
2704 "\0\0\272\214\0\0\0\377\3\0\0\0\375\0\0\0\241\0\0\0\"\226\377\377\377"
2705 "\0\2\0\0\0\"\0\0\0\252\214\0\0\0\377\2\0\0\0\375\0\0\0k\253\377\377\377"
2706 "\0\2\0\0\0\25\0\0\0\324\213\0\0\0\377\3\0\0\0\376\0\0\0\252\0\0\0(\232"
2707 "\377\377\377\0\2\0\0\0""9\0\0\0\312\214\0\0\0\377\1\0\0\0\200\251\377"
2708 "\377\377\0\2\0\0\0\5\0\0\0\303\213\0\0\0\377\2\0\0\0\332\0\0\0""1\235"
2709 "\377\377\377\0\3\0\0\0\4\0\0\0\201\0\0\0\374\213\0\0\0\377\1\0\0\0p\250"
2710 "\377\377\377\0\1\0\0\0\222\213\0\0\0\377\2\0\0\0\301\0\0\0\22\240\377"
2711 "\377\377\0\2\0\0\0:\0\0\0\336\212\0\0\0\377\2\0\0\0\374\0\0\0I\246\377"
2712 "\377\377\0\1\0\0\0[\213\0\0\0\377\2\0\0\0\241\0\0\0\6\212\377\377\377"
2713 "\0\15\0\0\0\2\0\0\0&\0\0\0U\0\0\0\203\0\0\0\242\0\0\0\243\0\0\0\234\0"
2714 "\0\0\225\0\0\0\215\0\0\0\206\0\0\0}\0\0\0\\\0\0\0!\213\377\377\377\0"
2715 "\2\0\0\0\22\0\0\0\307\212\0\0\0\377\2\0\0\0\361\0\0\0+\244\377\377\377"
2716 "\0\2\0\0\0.\0\0\0\365\211\0\0\0\377\2\0\0\0\376\0\0\0|\211\377\377\377"
2717 "\0\4\0\0\0#\0\0\0d\0\0\0\223\0\0\0\277\214\0\0\0\310\4\0\0\0\253\0\0"
2718 "\0l\0\0\0-\0\0\0\2\210\377\377\377\0\2\0\0\0\12\0\0\0\267\212\0\0\0\377"
2719 "\2\0\0\0\336\0\0\0\24\242\377\377\377\0\2\0\0\0\20\0\0\0\334\211\0\0"
2720 "\0\377\2\0\0\0\367\0\0\0W\210\377\377\377\0\2\0\0\0#\0\0\0\211\223\0"
2721 "\0\0\310\3\0\0\0\266\0\0\0t\0\0\0\27\207\377\377\377\0\2\0\0\0\5\0\0"
2722 "\0\244\212\0\0\0\377\2\0\0\0\302\0\0\0\6\240\377\377\377\0\2\0\0\0\1"
2723 "\0\0\0\264\211\0\0\0\377\2\0\0\0\363\0\0\0""9\207\377\377\377\0\3\0\0"
2724 "\0\34\0\0\0\201\0\0\0\306\226\0\0\0\310\3\0\0\0\277\0\0\0Y\0\0\0\2\206"
2725 "\377\377\377\0\2\0\0\0\1\0\0\0\217\212\0\0\0\377\1\0\0\0\203\240\377"
2726 "\377\377\0\1\0\0\0\177\212\0\0\0\377\1\0\0\0T\206\377\377\377\0\3\0\0"
2727 "\0\25\0\0\0z\0\0\0\305\232\0\0\0\310\2\0\0\0\242\0\0\0*\207\377\377\377"
2728 "\0\1\0\0\0\243\211\0\0\0\377\2\0\0\0\372\0\0\0,\236\377\377\377\0\2\0"
2729 "\0\0D\0\0\0\375\211\0\0\0\377\1\0\0\0\213\206\377\377\377\0\2\0\0\0""8"
2730 "\0\0\0\274\235\0\0\0\310\3\0\0\0\306\0\0\0u\0\0\0\14\205\377\377\377"
2731 "\0\2\0\0\0\7\0\0\0\306\211\0\0\0\377\2\0\0\0\306\0\0\0\2\234\377\377"
2732 "\377\0\2\0\0\0\4\0\0\0\331\211\0\0\0\377\2\0\0\0\276\0\0\0\3\205\377"
2733 "\377\377\0\2\0\0\0T\0\0\0\306\214\0\0\0\310\10\0\0\0\260\0\0\0\202\0"
2734 "\0\0v\0\0\0~\0\0\0\207\0\0\0\217\0\0\0\227\0\0\0\264\214\0\0\0\310\2"
2735 "\0\0\0\264\0\0\0""2\205\377\377\377\0\2\0\0\0\27\0\0\0\341\211\0\0\0"
2736 "\377\1\0\0\0k\234\377\377\377\0\1\0\0\0c\211\0\0\0\377\2\0\0\0\343\0"
2737 "\0\0\26\204\377\377\377\0\2\0\0\0\2\0\0\0s\212\0\0\0\310\4\0\0\0\265"
2738 "\0\0\0s\0\0\0D\0\0\0\26\207\377\377\377\0\4\0\0\0\1\0\0\0+\0\0\0j\0\0"
2739 "\0\250\212\0\0\0\310\2\0\0\0\303\0\0\0A\205\377\377\377\0\2\0\0\0/\0"
2740 "\0\0\364\210\0\0\0\377\2\0\0\0\362\0\0\0\33\232\377\377\377\0\2\0\0\0"
2741 "\7\0\0\0\341\210\0\0\0\377\2\0\0\0\371\0\0\0""7\204\377\377\377\0\2\0"
2742 "\0\0\12\0\0\0\217\211\0\0\0\310\3\0\0\0\271\0\0\0]\0\0\0\10\216\377\377"
2743 "\377\0\3\0\0\0\36\0\0\0t\0\0\0\306\210\0\0\0\310\2\0\0\0\306\0\0\0P\205"
2744 "\377\377\377\0\1\0\0\0a\211\0\0\0\377\1\0\0\0\257\232\377\377\377\0\1"
2745 "\0\0\0n\211\0\0\0\377\1\0\0\0h\204\377\377\377\0\2\0\0\0\20\0\0\0\245"
2746 "\210\0\0\0\310\3\0\0\0\274\0\0\0c\0\0\0\12\222\377\377\377\0\2\0\0\0"
2747 "*\0\0\0\242\211\0\0\0\310\1\0\0\0`\205\377\377\377\0\1\0\0\0\276\211"
2748 "\0\0\0\377\1\0\0\0:\230\377\377\377\0\2\0\0\0\13\0\0\0\350\210\0\0\0"
2749 "\377\1\0\0\0\250\204\377\377\377\0\2\0\0\0\3\0\0\0\230\210\0\0\0\310"
2750 "\2\0\0\0\213\0\0\0\15\225\377\377\377\0\3\0\0\0\2\0\0\0Z\0\0\0\277\210"
2751 "\0\0\0\310\1\0\0\0U\204\377\377\377\0\2\0\0\0%\0\0\0\370\210\0\0\0\377"
2752 "\1\0\0\0\265\230\377\377\377\0\1\0\0\0y\210\0\0\0\377\2\0\0\0\372\0\0"
2753 "\0\40\204\377\377\377\0\1\0\0\0o\210\0\0\0\310\2\0\0\0o\0\0\0\2\230\377"
2754 "\377\377\0\2\0\0\0\30\0\0\0\226\207\0\0\0\310\2\0\0\0\306\0\0\0""7\204"
2755 "\377\377\377\0\1\0\0\0|\211\0\0\0\377\1\0\0\0""0\226\377\377\377\0\2"
2756 "\0\0\0\20\0\0\0\356\210\0\0\0\377\1\0\0\0\226\204\377\377\377\0\1\0\0"
2757 "\0C\207\0\0\0\310\2\0\0\0\305\0\0\0R\233\377\377\377\0\2\0\0\0\5\0\0"
2758 "\0\210\207\0\0\0\310\2\0\0\0\273\0\0\0\37\203\377\377\377\0\2\0\0\0\6"
2759 "\0\0\0\325\210\0\0\0\377\1\0\0\0\251\226\377\377\377\0\1\0\0\0\204\210"
2760 "\0\0\0\377\2\0\0\0\366\0\0\0\32\203\377\377\377\0\2\0\0\0!\0\0\0\277"
2761 "\206\0\0\0\310\2\0\0\0\275\0\0\0""8\235\377\377\377\0\2\0\0\0\2\0\0\0"
2762 "|\207\0\0\0\310\2\0\0\0\254\0\0\0\15\203\377\377\377\0\1\0\0\0J\210\0"
2763 "\0\0\377\2\0\0\0\375\0\0\0&\224\377\377\377\0\2\0\0\0\26\0\0\0\364\210"
2764 "\0\0\0\377\1\0\0\0\214\203\377\377\377\0\2\0\0\0\12\0\0\0\251\206\0\0"
2765 "\0\310\2\0\0\0\305\0\0\0""0\240\377\377\377\0\1\0\0\0r\207\0\0\0\310"
2766 "\1\0\0\0[\204\377\377\377\0\1\0\0\0\317\210\0\0\0\377\1\0\0\0\236\224"
2767 "\377\377\377\0\1\0\0\0\204\210\0\0\0\377\2\0\0\0\362\0\0\0\24\203\377"
2768 "\377\377\0\1\0\0\0\206\207\0\0\0\310\1\0\0\0X\214\377\377\377\0\11\0"
2769 "\0\0\5\0\0\0$\0\0\0G\0\0\0X\0\0\0T\0\0\0O\0\0\0K\0\0\0B\0\0\0\35\214"
2770 "\377\377\377\0\2\0\0\0\2\0\0\0\214\206\0\0\0\310\2\0\0\0\307\0\0\0""1"
2771 "\203\377\377\377\0\1\0\0\0V\210\0\0\0\377\2\0\0\0\372\0\0\0\27\223\377"
2772 "\377\377\0\1\0\0\0\271\210\0\0\0\377\1\0\0\0\202\203\377\377\377\0\1"
2773 "\0\0\0@\207\0\0\0\310\1\0\0\0\204\212\377\377\377\0\4\0\0\0\7\0\0\0E"
2774 "\0\0\0u\0\0\0\222\210\0\0\0\226\4\0\0\0\204\0\0\0T\0\0\0$\0\0\0\1\211"
2775 "\377\377\377\0\2\0\0\0\12\0\0\0\245\206\0\0\0\310\2\0\0\0\251\0\0\0\5"
2776 "\202\377\377\377\0\2\0\0\0\2\0\0\0\331\210\0\0\0\377\1\0\0\0C\223\377"
2777 "\377\377\0\1\0\0\0\342\207\0\0\0\377\2\0\0\0\356\0\0\0\17\202\377\377"
2778 "\377\0\2\0\0\0\2\0\0\0\246\206\0\0\0\310\2\0\0\0\246\0\0\0\11\210\377"
2779 "\377\377\0\3\0\0\0\5\0\0\0D\0\0\0\212\216\0\0\0\226\2\0\0\0z\0\0\0\40"
2780 "\211\377\377\377\0\2\0\0\0\32\0\0\0\274\206\0\0\0\310\1\0\0\0d\203\377"
2781 "\377\377\0\1\0\0\0a\210\0\0\0\377\1\0\0\0b\222\377\377\377\0\2\0\0\0"
2782 "\10\0\0\0\375\207\0\0\0\377\1\0\0\0x\203\377\377\377\0\1\0\0\0G\206\0"
2783 "\0\0\310\2\0\0\0\275\0\0\0\36\210\377\377\377\0\2\0\0\0""3\0\0\0\207"
2784 "\221\0\0\0\226\3\0\0\0\225\0\0\0X\0\0\0\11\210\377\377\377\0\1\0\0\0"
2785 "R\206\0\0\0\310\2\0\0\0\302\0\0\0\23\202\377\377\377\0\2\0\0\0\5\0\0"
2786 "\0\342\207\0\0\0\377\1\0\0\0\201\223\377\377\377\0\1\0\0\0m\206\0\0\0"
2787 "\377\2\0\0\0\321\0\0\0\12\202\377\377\377\0\2\0\0\0\3\0\0\0\254\206\0"
2788 "\0\0\310\1\0\0\0J\207\377\377\377\0\2\0\0\0\1\0\0\0O\210\0\0\0\226\1"
2789 "\0\0\0\206\202\0\0\0h\3\0\0\0m\0\0\0s\0\0\0\214\207\0\0\0\226\2\0\0\0"
2790 "\210\0\0\0)\207\377\377\377\0\2\0\0\0\1\0\0\0\233\206\0\0\0\310\1\0\0"
2791 "\0l\203\377\377\377\0\2\0\0\0P\0\0\0\374\205\0\0\0\377\2\0\0\0\337\0"
2792 "\0\0\"\224\377\377\377\0\1\0\0\0s\204\0\0\0\377\2\0\0\0\315\0\0\0\23"
2793 "\203\377\377\377\0\1\0\0\0N\206\0\0\0\310\2\0\0\0\245\0\0\0\2\206\377"
2794 "\377\377\0\2\0\0\0\6\0\0\0f\206\0\0\0\226\3\0\0\0w\0\0\0""7\0\0\0\23"
2795 "\205\377\377\377\0\4\0\0\0\3\0\0\0*\0\0\0[\0\0\0\212\205\0\0\0\226\2"
2796 "\0\0\0\222\0\0\0*\207\377\377\377\0\2\0\0\0#\0\0\0\304\205\0\0\0\310"
2797 "\2\0\0\0\277\0\0\0\16\203\377\377\377\0\2\0\0\0]\0\0\0\376\203\0\0\0"
2798 "\377\2\0\0\0\332\0\0\0\35\226\377\377\377\0\5\0\0\0;\0\0\0j\0\0\0\223"
2799 "\0\0\0\244\0\0\0\20\203\377\377\377\0\2\0\0\0\5\0\0\0\260\206\0\0\0\310"
2800 "\1\0\0\0>\206\377\377\377\0\2\0\0\0\14\0\0\0z\205\0\0\0\226\2\0\0\0|"
2801 "\0\0\0/\213\377\377\377\0\3\0\0\0\10\0\0\0U\0\0\0\224\204\0\0\0\226\2"
2802 "\0\0\0\221\0\0\0%\207\377\377\377\0\1\0\0\0s\206\0\0\0\310\1\0\0\0d\204"
2803 "\377\377\377\0\5\0\0\0a\0\0\0\240\0\0\0\177\0\0\0]\0\0\0\26\237\377\377"
2804 "\377\0\1\0\0\0U\206\0\0\0\310\1\0\0\0\235\206\377\377\377\0\2\0\0\0\2"
2805 "\0\0\0r\204\0\0\0\226\3\0\0\0\225\0\0\0J\0\0\0\1\216\377\377\377\0\2"
2806 "\0\0\0\35\0\0\0w\204\0\0\0\226\2\0\0\0\217\0\0\0\40\206\377\377\377\0"
2807 "\2\0\0\0\27\0\0\0\304\205\0\0\0\310\2\0\0\0\273\0\0\0\12\247\377\377"
2808 "\377\0\1\0\0\0\236\206\0\0\0\310\1\0\0\0""5\206\377\377\377\0\1\0\0\0"
2809 "T\204\0\0\0\226\2\0\0\0\221\0\0\0""3\221\377\377\377\0\2\0\0\0\4\0\0"
2810 "\0l\204\0\0\0\226\2\0\0\0\215\0\0\0\34\206\377\377\377\0\1\0\0\0}\206"
2811 "\0\0\0\310\1\0\0\0E\247\377\377\377\0\1\0\0\0\276\205\0\0\0\310\1\0\0"
2812 "\0\224\206\377\377\377\0\1\0\0\0""4\204\0\0\0\226\2\0\0\0\214\0\0\0\40"
2813 "\223\377\377\377\0\2\0\0\0\5\0\0\0q\204\0\0\0\226\2\0\0\0\211\0\0\0\14"
2814 "\205\377\377\377\0\2\0\0\0\37\0\0\0\306\205\0\0\0\310\1\0\0\0`\246\377"
2815 "\377\377\0\2\0\0\0\12\0\0\0\277\205\0\0\0\310\1\0\0\0+\205\377\377\377"
2816 "\0\2\0\0\0\30\0\0\0\220\203\0\0\0\226\2\0\0\0\225\0\0\0*\225\377\377"
2817 "\377\0\2\0\0\0\10\0\0\0v\204\0\0\0\226\1\0\0\0X\206\377\377\377\0\1\0"
2818 "\0\0\207\205\0\0\0\310\1\0\0\0m\247\377\377\377\0\2\0\0\0""3\0\0\0\301"
2819 "\203\0\0\0\310\1\0\0\0[\206\377\377\377\0\1\0\0\0n\204\0\0\0\226\1\0"
2820 "\0\0G\227\377\377\377\0\2\0\0\0\12\0\0\0z\203\0\0\0\226\2\0\0\0\224\0"
2821 "\0\0\27\205\377\377\377\0\2\0\0\0\20\0\0\0\246\203\0\0\0\310\2\0\0\0"
2822 "\224\0\0\0\11\250\377\377\377\0\4\0\0\0,\0\0\0h\0\0\0\210\0\0\0R\206"
2823 "\377\377\377\0\1\0\0\0&\204\0\0\0\226\2\0\0\0f\0\0\0\1\230\377\377\377"
2824 "\0\2\0\0\0\26\0\0\0\224\203\0\0\0\226\1\0\0\0g\206\377\377\377\0\5\0"
2825 "\0\0\22\0\0\0\206\0\0\0y\0\0\0]\0\0\0\6\263\377\377\377\0\1\0\0\0t\203"
2826 "\0\0\0\226\2\0\0\0\216\0\0\0\13\232\377\377\377\0\1\0\0\0X\204\0\0\0"
2827 "\226\1\0\0\0#\274\377\377\377\0\1\0\0\0-\204\0\0\0\226\1\0\0\0K\233\377"
2828 "\377\377\0\2\0\0\0\15\0\0\0\217\203\0\0\0\226\1\0\0\0v\274\377\377\377"
2829 "\0\1\0\0\0t\203\0\0\0\226\2\0\0\0\213\0\0\0\10\213\377\377\377\0\5\0"
2830 "\0\0\5\0\0\0\30\0\0\0\40\0\0\0\36\0\0\0\22\214\377\377\377\0\1\0\0\0"
2831 "J\204\0\0\0\226\1\0\0\0*\273\377\377\377\0\1\0\0\0`\203\0\0\0\226\1\0"
2832 "\0\0E\212\377\377\377\0\3\0\0\0\13\0\0\0@\0\0\0Y\204\0\0\0Z\3\0\0\0Q"
2833 "\0\0\0""1\0\0\0\5\211\377\377\377\0\2\0\0\0\6\0\0\0\207\203\0\0\0\226"
2834 "\1\0\0\0\26\273\377\377\377\0\5\0\0\0""1\0\0\0\226\0\0\0\224\0\0\0n\0"
2835 "\0\0\5\211\377\377\377\0\2\0\0\0$\0\0\0U\202\0\0\0Z\4\0\0\0P\0\0\0E\0"
2836 "\0\0I\0\0\0X\202\0\0\0Z\2\0\0\0P\0\0\0\33\211\377\377\377\0\4\0\0\0""3"
2837 "\0\0\0\206\0\0\0\226\0\0\0\201\274\377\377\377\0\3\0\0\0\6\0\0\0""8\0"
2838 "\0\0\13\211\377\377\377\0\2\0\0\0\7\0\0\0A\202\0\0\0Z\2\0\0\0I\0\0\0"
2839 "\20\203\377\377\377\0\6\0\0\0\4\0\0\0\37\0\0\0O\0\0\0Z\0\0\0Y\0\0\0\36"
2840 "\212\377\377\377\0\2\0\0\0\34\0\0\0)\310\377\377\377\0\5\0\0\0<\0\0\0"
2841 "Z\0\0\0Y\0\0\0.\0\0\0\2\206\377\377\377\0\5\0\0\0\3\0\0\0;\0\0\0Z\0\0"
2842 "\0X\0\0\0\32\322\377\377\377\0\1\0\0\0\34\202\0\0\0Z\1\0\0\0\30\211\377"
2843 "\377\377\0\5\0\0\0\1\0\0\0>\0\0\0Z\0\0\0W\0\0\0\13\320\377\377\377\0"
2844 "\4\0\0\0\5\0\0\0P\0\0\0Z\0\0\0""5\213\377\377\377\0\4\0\0\0\2\0\0\0H"
2845 "\0\0\0Z\0\0\0:\320\377\377\377\0\4\0\0\0""4\0\0\0Z\0\0\0P\0\0\0\5\214"
2846 "\377\377\377\0\1\0\0\0\26\202\0\0\0Z\1\0\0\0\22\317\377\377\377\0\3\0"
2847 "\0\0+\0\0\0X\0\0\0\33\216\377\377\377\0\3\0\0\0>\0\0\0I\0\0\0\23\320"
2848 "\377\377\377\0\1\0\0\0\12\217\377\377\377\0\2\0\0\0\6\0\0\0\1\377\377"
2849 "\377\377\0\377\377\377\377\0\377\377\377\377\0\377\377\377\377\0\377"
2850 "\377\377\377\0\377\377\377\377\0\377\377\377\377\0\377\377\377\377\0"
2851 "\377\377\377\377\0\377\377\377\377\0\377\377\377\377\0\234\377\377\377"
2852 "\0"]
2854 known_profile_icon = [ ""
2855 "GdkP"
2856 "\0\0\5""0"
2857 "\2\1\0\2"
2858 "\0\0\0P"
2859 "\0\0\0\24"
2860 "\0\0\0\24"
2861 "\210\0\0\0\0\4\0\0\0\3\0\0\0\16\0\0\0\23\0\0\0\11\216\0\0\0\0\11\0\0"
2862 "\0\16\0\0\0h\0\0\0\301\0\0\0\345\0\0\0\352\0\0\0\331\0\0\0\237\0\0\0"
2863 "9\0\0\0\3\212\0\0\0\0\13\0\0\0@\0\0\0\323\0\0\0\376\0\0\0\350\0\0\0\304"
2864 "\0\0\0\271\0\0\0\323\0\0\0\367\0\0\0\370\0\0\0\227\0\0\0\17\210\0\0\0"
2865 "\0\15\0\0\0K\0\0\0\354\0\0\0\365\0\0\0\206\0\0\0#\0\0\0\6\0\0\0\3\0\0"
2866 "\0\15\0\0\0C\0\0\0\304\0\0\0\376\0\0\0\260\0\0\0\22\206\0\0\0\0\17\0"
2867 "\0\0""2\0\0\0\346\0\0\0\351\0\0\0L\0\0\0#\0\0\0u\0\0\0\246\0\0\0\257"
2868 "\0\0\0\223\0\0\0M\0\0\0\27\0\0\0\235\0\0\0\375\0\0\0\242\0\0\0\7\204"
2869 "\0\0\0\0\20\0\0\0\13\0\0\0\300\0\0\0\372\0\0\0W\0\0\0O\0\0\0\271\0\0"
2870 "\0\233\0\0\0b\0\0\0V\0\0\0z\0\0\0\267\0\0\0\223\0\0\0$\0\0\0\267\0\0"
2871 "\0\374\0\0\0X\204\0\0\0\0\7\0\0\0S\0\0\0\374\0\0\0\240\0\0\0H\0\0\0\275"
2872 "\0\0\0a\0\0\0\12\202\0\0\0\0\10\0\0\0\1\0\0\0%\0\0\0\240\0\0\0\241\0"
2873 "\0\0""9\0\0\0\352\0\0\0\320\0\0\0\12\203\0\0\0\0\21\0\0\0\262\0\0\0\351"
2874 "\0\0\0A\0\0\0\272\0\0\0g\0\0\0\6\0\0\0""4\0\0\0e\0\0\0l\0\0\0T\0\0\0"
2875 "\25\0\0\0\27\0\0\0\251\0\0\0v\0\0\0\214\0\0\0\367\0\0\0<\203\0\0\0\0"
2876 "\21\0\0\0""6\0\0\0G\0\0\0r\0\0\0\244\0\0\0\17\0\0\0P\0\0\0b\0\0\0#\0"
2877 "\0\0\27\0\0\0;\0\0\0s\0\0\0\33\0\0\0E\0\0\0\270\0\0\0""6\0\0\0\\\0\0"
2878 "\0\15\205\0\0\0\0\15\0\0\0T\0\0\0""8\0\0\0""0\0\0\0f\0\0\0\6\0\0\0\0"
2879 "\0\0\0\1\0\0\0\0\0\0\0(\0\0\0l\0\0\0\13\0\0\0k\0\0\0\33\206\0\0\0\0\16"
2880 "***;\210\210\210\356\223\223\223\377iii\377\204\204\204\377\216\216\216"
2881 "\377~~~\377zzz\377\203\203\203\377\215\215\215\377ddd\377\202\202\202"
2882 "\377xxx\356\40\40\40;\205\0\0\0\0\2&&&#\251\251\251\353\202\374\374\374"
2883 "\377\202\372\372\372\377\5\335\335\335\377\353\353\353\377\366\366\366"
2884 "\377\327\327\327\377\357\357\357\377\202\365\365\365\377\3\362\362\362"
2885 "\377\226\226\226\353\27\27\27)\204\0\0\0\0\21,,,p\354\354\354\377\355"
2886 "\355\355\377\351\351\351\377\346\346\346\377\342\342\342\377\335\335"
2887 "\335\377\334\334\334\377\330\330\330\377\324\324\324\377\320\320\320"
2888 "\377\316\316\316\377\313\313\313\377\307\307\307\377\314\314\314\377"
2889 "\35\35\35y\0\0\0\1\202\0\0\0\0\14\0\0\0\2(((\203\357\357\357\377\345"
2890 "\345\345\377\341\341\341\377\337\337\337\377\333\333\333\377\326\326"
2891 "\326\377\322\322\322\377\316\316\316\377\312\312\312\377\306\306\306"
2892 "\377\202\302\302\302\377\30\314\314\314\377\311\311\311\377\33\33\33"
2893 "\204\0\0\0\5\0\0\0\1\0\0\0\2\0\0\0\10&&&\210\356\356\356\377\342\342"
2894 "\342\377\347\347\347\377\346\346\346\377\324GG\377\337\337\337\377\324"
2895 "GG\377\333\322\322\377\324GG\377<\341@\377\324GG\377<\341@\377\321\321"
2896 "\321\377\276\276\276\377\27\27\27\214\0\0\0\15\202\0\0\0\4+\0\0\0\21"
2897 "$$$\221\355\355\355\377\345\345\345\377\344\344\344\377\340\340\340\377"
2898 "\334\334\334\377\331\331\331\377\325\325\325\377\321\321\321\377\316"
2899 "\316\316\377\312\312\312\377\306\306\306\377\307\307\307\377\313\313"
2900 "\313\377\272\272\272\377\24\24\24\226\0\0\0\30\0\0\0\10\0\0\0\5\0\0\0"
2901 "\27\"\"\"\231\354\354\354\377\346\346\346\377\342\342\342\377\337\337"
2902 "\337\377\333\333\333\377\327\327\327\377\324\324\324\377\320\320\320"
2903 "\377\314\314\314\377\310\310\310\377\305\305\305\377\301\301\301\377"
2904 "\276\276\276\377\271\271\271\377\23\23\23\235\0\0\0\35\0\0\0\10\0\0\0"
2905 "\4\0\0\0\32\40\40\40\223\310\310\310\376\202\274\274\274\377\4\272\272"
2906 "\272\377\271\271\271\377\270\270\270\377\267\267\267\377\202\271\271"
2907 "\271\377\16\270\270\270\377\266\266\266\377\265\265\265\377\264\264\264"
2908 "\377\231\231\231\376\16\16\16\240\0\0\0\35\0\0\0\6\0\0\0\2\0\0\0\12\0"
2909 "\0\0/\0\0\0n\0\0\0|\0\0\0\177\202\0\0\0\200\202\0\0\0\201\1\0\0\0\203"
2910 "\204\0\0\0\205\12\0\0\0\201\0\0\0y\0\0\0<\0\0\0\15\0\0\0\2\0\0\0\0\0"
2911 "\0\0\2\0\0\0\6\0\0\0\14\0\0\0\20\204\0\0\0\24\202\0\0\0\25\203\0\0\0"
2912 "\26\6\0\0\0\25\0\0\0\22\0\0\0\15\0\0\0\7\0\0\0\2\0\0\0\0"]
2914 unknown_profile_icon = [ ""
2915 "GdkP"
2916 "\0\0\5\22"
2917 "\2\1\0\2"
2918 "\0\0\0P"
2919 "\0\0\0\24"
2920 "\0\0\0\24"
2921 "\210\0\0\0\0\4\0\0\0\1\0\0\0\4\0\0\0\6\0\0\0\3\216\0\0\0\0\11\0\0\0\4"
2922 "\0\0\0\37\0\0\0""9\0\0\0D\0\0\0F\0\0\0@\0\0\0/\0\0\0\21\0\0\0\1\212\0"
2923 "\0\0\0\7\0\0\0\23\0\0\0\77\0\0\0K\0\0\0E\0\0\0:\0\0\0""7\0\0\0\77\202"
2924 "\0\0\0I\2\0\0\0-\0\0\0\4\210\0\0\0\0\15\0\0\0\26\0\0\0F\0\0\0I\0\0\0"
2925 "(\0\0\0\13\0\0\0\2\0\0\0\1\0\0\0\4\0\0\0\24\0\0\0:\0\0\0K\0\0\0""4\0"
2926 "\0\0\6\206\0\0\0\0\17\0\0\0\17\0\0\0D\0\0\0E\0\0\0\26\0\0\0\13\0\0\0"
2927 "#\0\0\0""1\0\0\0""4\0\0\0,\0\0\0\27\0\0\0\7\0\0\0/\0\0\0K\0\0\0""0\0"
2928 "\0\0\2\204\0\0\0\0\20\0\0\0\3\0\0\0""9\0\0\0J\0\0\0\32\0\0\0\30\0\0\0"
2929 "7\0\0\0.\0\0\0\35\0\0\0\32\0\0\0$\0\0\0""6\0\0\0,\0\0\0\13\0\0\0""6\0"
2930 "\0\0K\0\0\0\32\204\0\0\0\0\7\0\0\0\31\0\0\0K\0\0\0""0\0\0\0\25\0\0\0"
2931 "8\0\0\0\35\0\0\0\3\202\0\0\0\0\2\0\0\0\1\0\0\0\13\202\0\0\0""0\4\0\0"
2932 "\0\21\0\0\0F\0\0\0>\0\0\0\3\203\0\0\0\0\21\0\0\0""5\0\0\0E\0\0\0\23\0"
2933 "\0\0""7\0\0\0\37\0\0\0\2\0\0\0\20\0\0\0\36\0\0\0\40\0\0\0\31\0\0\0\6"
2934 "\0\0\0\7\0\0\0""2\0\0\0#\0\0\0)\0\0\0I\0\0\0\22\203\0\0\0\0\21\0\0\0"
2935 "\20\0\0\0\25\0\0\0\"\0\0\0""1\0\0\0\4\0\0\0\30\0\0\0\35\0\0\0\13\0\0"
2936 "\0\7\0\0\0\21\0\0\0\"\0\0\0\10\0\0\0\25\0\0\0""6\0\0\0\20\0\0\0\33\0"
2937 "\0\0\4\205\0\0\0\0\15\0\0\0\31\0\0\0\21\0\0\0\16\0\0\0\36\0\0\0\2\0\0"
2938 "\0\0\0\0\0\1\0\0\0\0\0\0\0\14\0\0\0\40\0\0\0\3\0\0\0\40\0\0\0\10\206"
2939 "\0\0\0\0\16***\21\210\210\210G\223\223\223LiiiL\204\204\204L\34=n\300"
2940 "\14""1i\361\12""0i\374\20""4j\342CXx}dddL\202\202\202LxxxG\40\40\40\21"
2941 "\205\0\0\0\0\2&&&\13\251\251\251F\202\374\374\374L\202\372\372\372L\5"
2942 "\"Cv\310Lf\217\226@]\211\245\12""0i\377\22""7n\353\202\365\365\365L\3"
2943 "\362\362\362L\226\226\226F\27\27\27\14\204\0\0\0\0\21,,,!\354\354\354"
2944 "L\355\355\355L\351\351\351L\346\346\346L\342\342\342L\335\335\335L\334"
2945 "\334\334L\210\227\255h\12""0i\377\21""6l\352\316\316\316L\313\313\313"
2946 "L\307\307\307L\314\314\314L\35\35\35$\0\0\0\1\202\0\0\0\0\14\0\0\0\1"
2947 "((('\357\357\357L\345\345\345L\341\341\341L\337\337\337L\333\333\333"
2948 "L\326\326\326L|\215\245l\20""5l\355\12""0i\374Sj\215\205\202\302\302"
2949 "\302L\4\314\314\314L\311\311\311L\33\33\33'\0\0\0\2\202\0\0\0\1\22\0"
2950 "\0\0\2&&&(\356\356\356L\342\342\342L\347\347\347L\346\346\346L\324GG"
2951 "L\337\337\337L\22""0g\351\12""0i\377^9Z\201<\341@L\324GGL<\341@L\321"
2952 "\321\321L\276\276\276L\27\27\27)\0\0\0\4\202\0\0\0\1\22\0\0\0\5$$$+\355"
2953 "\355\355L\345\345\345L\344\344\344L\340\340\340L\334\334\334L\331\331"
2954 "\331Law\227\177`u\226\177\316\316\316L\312\312\312L\306\306\306L\307"
2955 "\307\307L\313\313\313L\272\272\272L\24\24\24,\0\0\0\7\202\0\0\0\2\27"
2956 "\0\0\0\7\"\"\"-\354\354\354L\346\346\346L\342\342\342L\337\337\337L\333"
2957 "\333\333L\327\327\327LSk\217\212Qi\216\212\314\314\314L\310\310\310L"
2958 "\305\305\305L\301\301\301L\276\276\276L\271\271\271L\23\23\23/\0\0\0"
2959 "\10\0\0\0\2\0\0\0\1\0\0\0\10\40\40\40,\310\310\310K\202\274\274\274L"
2960 "\3\272\272\272L\271\271\271L\270\270\270L\202\12""0i\377\16\271\271\271"
2961 "L\270\270\270L\266\266\266L\265\265\265L\264\264\264L\231\231\231K\16"
2962 "\16\16""0\0\0\0\10\0\0\0\2\0\0\0\1\0\0\0\3\0\0\0\16\0\0\0!\0\0\0%\205"
2963 "\0\0\0&\205\0\0\0'\12\0\0\0&\0\0\0$\0\0\0\22\0\0\0\4\0\0\0\1\0\0\0\0"
2964 "\0\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\206\0\0\0\6\203\0\0\0\7\202\0\0\0\6"
2965 "\4\0\0\0\4\0\0\0\2\0\0\0\1\0\0\0\0"]
2967 signal_xpm_barely = [
2968 "20 20 10 1",
2969 " c None",
2970 ". c #C6C6C6",
2971 "+ c #CCCCCC",
2972 "@ c #DBDBDB",
2973 "# c #D3D3D3",
2974 "$ c #A9B099",
2975 "% c #95A173",
2976 "& c #6B8428",
2977 "* c #B4B7AC",
2978 "= c #80924D",
2979 " .+++.",
2980 " +@@@+",
2981 " +@@@+",
2982 " +@@@+",
2983 " +@@@+",
2984 " .++++#@@@+",
2985 " +@@@@@@@@+",
2986 " +@@@@@@@@+",
2987 " +@@@@@@@@+",
2988 " +@@@@@@@@+",
2989 " $%%%%#@@@@@@@@+",
2990 " %&&&&@@@@@@@@@+",
2991 " %&&&&@@@@@@@@@+",
2992 " %&&&&@@@@@@@@@+",
2993 " %&&&&@@@@@@@@@+",
2994 "*%%%%=&&&&@@@@@@@@@+",
2995 "%&&&&&&&&&@@@@@@@@@+",
2996 "%&&&&&&&&&@@@@@@@@@+",
2997 "%&&&&&&&&&@@@@@@@@@+",
2998 "*%%%%%%%%%+++++++++."
3002 signal_xpm_best = [
3003 "20 20 6 1",
3004 " c None",
3005 ". c #9DAABF",
3006 "+ c #7B96BF",
3007 "@ c #386EBF",
3008 "# c #5982BF",
3009 "$ c #AEB4BF",
3010 " .+++.",
3011 " +@@@+",
3012 " +@@@+",
3013 " +@@@+",
3014 " +@@@+",
3015 " .++++#@@@+",
3016 " +@@@@@@@@+",
3017 " +@@@@@@@@+",
3018 " +@@@@@@@@+",
3019 " +@@@@@@@@+",
3020 " .++++#@@@@@@@@+",
3021 " +@@@@@@@@@@@@@+",
3022 " +@@@@@@@@@@@@@+",
3023 " +@@@@@@@@@@@@@+",
3024 " +@@@@@@@@@@@@@+",
3025 "$++++#@@@@@@@@@@@@@+",
3026 "+@@@@@@@@@@@@@@@@@@+",
3027 "+@@@@@@@@@@@@@@@@@@+",
3028 "+@@@@@@@@@@@@@@@@@@+",
3029 "$++++++++++++++++++."
3032 signal_xpm_none = [
3033 "20 20 6 1",
3034 " c None",
3035 ". c #C6C6C6",
3036 "+ c #CCCCCC",
3037 "@ c #DBDBDB",
3038 "# c #D3D3D3",
3039 "$ c #C2C2C2",
3040 " .+++.",
3041 " +@@@+",
3042 " +@@@+",
3043 " +@@@+",
3044 " +@@@+",
3045 " .++++#@@@+",
3046 " +@@@@@@@@+",
3047 " +@@@@@@@@+",
3048 " +@@@@@@@@+",
3049 " +@@@@@@@@+",
3050 " .++++#@@@@@@@@+",
3051 " +@@@@@@@@@@@@@+",
3052 " +@@@@@@@@@@@@@+",
3053 " +@@@@@@@@@@@@@+",
3054 " +@@@@@@@@@@@@@+",
3055 "$++++#@@@@@@@@@@@@@+",
3056 "+@@@@@@@@@@@@@@@@@@+",
3057 "+@@@@@@@@@@@@@@@@@@+",
3058 "+@@@@@@@@@@@@@@@@@@+",
3059 "$++++++++++++++++++."
3062 signal_xpm_ok = [
3063 "20 20 10 1",
3064 " c None",
3065 ". c #C6C6C6",
3066 "+ c #CCCCCC",
3067 "@ c #DBDBDB",
3068 "# c #A1A5B2",
3069 "$ c #848DA5",
3070 "% c #D3D3D3",
3071 "& c #4A5B8C",
3072 "* c #677498",
3073 "= c #B0B2B8",
3074 " .+++.",
3075 " +@@@+",
3076 " +@@@+",
3077 " +@@@+",
3078 " +@@@+",
3079 " #$$$$%@@@+",
3080 " $&&&&@@@@+",
3081 " $&&&&@@@@+",
3082 " $&&&&@@@@+",
3083 " $&&&&@@@@+",
3084 " #$$$$*&&&&@@@@+",
3085 " $&&&&&&&&&@@@@+",
3086 " $&&&&&&&&&@@@@+",
3087 " $&&&&&&&&&@@@@+",
3088 " $&&&&&&&&&@@@@+",
3089 "=$$$$*&&&&&&&&&@@@@+",
3090 "$&&&&&&&&&&&&&&@@@@+",
3091 "$&&&&&&&&&&&&&&@@@@+",
3092 "$&&&&&&&&&&&&&&@@@@+",
3093 "=$$$$$$$$$$$$$$++++."
3097 signal_xpm_low = [
3098 "20 20 8 1",
3099 " c None",
3100 ". c #C6C6C6",
3101 "+ c #CCCCCC",
3102 "@ c #DBDBDB",
3103 "# c #D3D3D3",
3104 "$ c #BFB0B5",
3105 "% c #C18799",
3106 "& c #C54F74",
3107 " .+++.",
3108 " +@@@+",
3109 " +@@@+",
3110 " +@@@+",
3111 " +@@@+",
3112 " .++++#@@@+",
3113 " +@@@@@@@@+",
3114 " +@@@@@@@@+",
3115 " +@@@@@@@@+",
3116 " +@@@@@@@@+",
3117 " .++++#@@@@@@@@+",
3118 " +@@@@@@@@@@@@@+",
3119 " +@@@@@@@@@@@@@+",
3120 " +@@@@@@@@@@@@@+",
3121 " +@@@@@@@@@@@@@+",
3122 "$%%%%#@@@@@@@@@@@@@+",
3123 "%&&&&@@@@@@@@@@@@@@+",
3124 "%&&&&@@@@@@@@@@@@@@+",
3125 "%&&&&@@@@@@@@@@@@@@+",
3126 "$%%%%++++++++++++++."
3130 ####################################################################################################
3131 # Make so we can be imported
3132 if __name__ == "__main__":
3133 if len( sys.argv ) > 1 and ( sys.argv[1] == '--version' or sys.argv[1] == '-v' ):
3134 print "WiFi-Radar version %s" % WIFI_RADAR_VERSION
3135 else:
3136 import gtk, gobject
3137 gtk.gdk.threads_init()
3138 apQueue = Queue.Queue(100)
3139 commQueue = Queue.Queue(2)
3141 logger = logging.getLogger("wrlog")
3142 logger.setLevel(logging.WARNING)
3143 fileLogHandler = logging.handlers.RotatingFileHandler(confFile.get_opt('DEFAULT.logfile'), maxBytes=64*1024, backupCount=5)
3144 fileLogHandler.setFormatter(logging.Formatter('%(asctime)s: %(levelname)s: %(funcName)s: %(message)s'))
3145 logger.addHandler(fileLogHandler)
3146 if __debug__:
3147 logger.setLevel(logging.DEBUG)
3148 consoleLogHandler = logging.StreamHandler()
3149 consoleLogHandler.setFormatter(logging.Formatter('%(asctime)s: %(funcName)s: %(message)s'))
3150 logger.addHandler(consoleLogHandler)
3152 main_radar_window = radar_window(confFile, apQueue, commQueue, logger)
3153 threading.Thread(None, scanning_thread, None, (confFile, apQueue, commQueue, logger)).start()
3154 threading.Thread(None, update_profiles, None, (main_radar_window, confFile, apQueue, commQueue, logger)).start()
3155 main_radar_window.main()