diff feedworm-gui.py @ 87:b8bfd1bd6c55

use a proxy if one is configured. TODO: GUI for configuring the proxy server
author Dirk Olmes <dirk@xanthippe.ping.de>
date Wed, 17 Nov 2010 21:22:31 +0100
parents 12ed8b5fa08c
children 04a730f9d07d
line wrap: on
line diff
--- a/feedworm-gui.py	Thu Sep 09 16:47:38 2010 +0200
+++ b/feedworm-gui.py	Wed Nov 17 21:22:31 2010 +0100
@@ -3,17 +3,28 @@
 from MainWindow import MainWindow
 from Preferences import Preferences
 from PyQt4 import QtGui
+from PyQt4.QtNetwork import QNetworkProxy
 import sys
 import util
 
+def setupProxy(preferences):
+    if preferences.isProxyConfigured():
+        proxyHost = preferences.proxyHost()
+        proxyPort = preferences.proxyPort()
+        proxy = QNetworkProxy(QNetworkProxy.HttpProxy, proxyHost, proxyPort)
+        QNetworkProxy.setApplicationProxy(proxy)
+
 if __name__ == '__main__':
     util.configureLogging()
     session = Database.createSession()
-    
+    preferences = Preferences(session)
+
+    setupProxy(preferences)
+
     app = QtGui.QApplication(sys.argv)
     mainWindow = MainWindow(session)
-    
-    maximized = Preferences(session).startMaximized()
+
+    maximized = preferences.startMaximized()
     if maximized:
         mainWindow.showMaximized()
     else: