diff --git a/src/mambatray b/src/mambatray index d9a478e..beb9c09 100755 --- a/src/mambatray +++ b/src/mambatray @@ -1,12 +1,13 @@ #!/usr/bin/python -# mambatray2 -# Copyright (C) 2011 by Silvan Calarco +# mambatray 2 +# Copyright (C) 2011-2013 by Silvan Calarco # Copyright (C) 2011 by michiamophil # Distributed under the terms of the GPL version 3 FLOSS License # import sys import os import gettext +import libproxy from PyQt4.QtCore import SIGNAL from PyQt4 import QtGui from PyQt4 import QtCore @@ -93,6 +94,19 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): # the first time check for SRPMS updates after 4 minutes checkSRPMSUpdatesTimer.start( 4 * 60000 ) + def setProxyForSmart(self): + setProxyProcess = QtCore.QProcess(self) + pf = libproxy.ProxyFactory() + for protocol in ["http","https","ftp"]: + proxies = pf.getProxies("%s://www.openmamba.org" % protocol) + for proxy in proxies: + if proxy == "direct://": + setProxyProcess.execute("smart",['config','--remove','%s_proxy' % protocol]) + break + else: + setProxyProcess.execute("smart",['config','--set','%s_proxy=%s' %(protocol,proxy)]) + break + def iconActivated(self, reason): if reason in (QtGui.QSystemTrayIcon.Trigger, QtGui.QSystemTrayIcon.DoubleClick): menu.popup(self.geometry().center()) @@ -110,7 +124,7 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): version = _("Error: Unable to find /etc/openmamba-release") QtGui.QMessageBox.about(menu, _("About"), "
"+_("openmamba control center")+"" - "

Copyright(c) 2011 by Silvan Calarco" + "

Copyright(c) 2011-2013 by Silvan Calarco" "
Copyright(c) 2011 by michiamophil" "

"+_("System info:")+"
" ""+_(version)+"
http://www.openmamba.org
") @@ -125,17 +139,21 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): return result def softwareManager(self): + self.setProxyForSmart() if desktop_session == 'kde': softwareManagerProcess.execute("/opt/kde/bin/apper") else: softwareManagerProcess.execute("/usr/bin/gpk-application") def softwareCheckUpgrades(self): + self.setProxyForSmart() if desktop_session == 'kde': softwareCheckUpgradesProcess.start("/opt/kde/bin/apper", ['--updates']) else: softwareCheckUpgradesProcess.start("/usr/bin/gpk-update-viewer") + def refreshPackagesCache(self): + self.setProxyForSmart() refreshPackagesTimer.stop() refreshPackagesCacheProcess.start("/usr/bin/pkcon", ['refresh']) @@ -176,6 +194,7 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): networkProxyProcess.execute("/opt/kde/bin/kcmshell4", QtCore.QStringList(list(set(['proxy'])))) elif desktop_session == 'gnome': networkProxyProcess.execute("/usr/bin/gnome-control-center", "network") + self.setProxyForSmart() def SRPMSCheckUpgradeList(self): checkSRPMSUpdatesTimer.stop()