411
411
self.button_help.set_sensitive(False)
413
413
self.gconfclient = gconf.client_get_default()
414
init_proxy(self.gconfclient)
417
417
self.restore_state()
418
418
self.window_main.show()
420
def init_proxy(self):
421
""" init proxy settings
423
* first check for http_proxy environment (always wins),
424
* then check the apt.conf http proxy,
425
* then look into synaptics conffile
428
SYNAPTIC_CONF_FILE = "%s/.synaptic/synaptic.conf" % pwd.getpwuid(0)[5]
431
if os.getenv("http_proxy"):
433
# generic apt config wins too
434
if apt_pkg.Config.Find("Acquire::http::Proxy") != '':
435
proxy = apt_pkg.Config.Find("Acquire::http::Proxy")
436
elif os.path.exists(SYNAPTIC_CONF_FILE):
437
cnf = apt_pkg.newConfiguration()
438
apt_pkg.ReadConfigFile(cnf, SYNAPTIC_CONF_FILE)
439
use_proxy = cnf.FindB("Synaptic::useProxy", False)
441
proxy_host = cnf.Find("Synaptic::httpProxy")
442
proxy_port = str(cnf.FindI("Synaptic::httpProxyPort"))
443
if proxy_host and proxy_port:
444
# FIXME: set the proxy for libapt here as well (e.g. for the
446
proxy = "http://%s:%s/" % (proxy_host, proxy_port)
447
elif self.gconfclient.get_bool("/system/http_proxy/use_http_proxy"):
448
host = self.gconfclient.get_string("/system/http_proxy/host")
449
port = self.gconfclient.get_int("/system/http_proxy/port")
450
use_auth = self.gconfclient.get_bool("/system/http_proxy/use_authentication")
453
auth_user = self.gconfclient.get_string("/system/http_proxy/authentication_user")
454
auth_pw = self.gconfclient.get_string("/system/http_proxy/authentication_password")
455
proxy = "http://%s:%s@%s:%s/" % (auth_user,auth_pw,host, port)
457
proxy = "http://%s:%s/" % (host, port)
459
proxy_support = urllib2.ProxyHandler({"http":proxy})
460
opener = urllib2.build_opener(proxy_support)
461
urllib2.install_opener(opener)
462
os.putenv("http_proxy",proxy)
464
420
def install_column_view_func(self, cell_layout, renderer, model, iter):
465
421
pkg = model.get_value(iter, LIST_PKG)
466
422
# hide it if we are only a header line