[PC-BSD Commits] r15515 - pcbsd/current/src-qt4/pc-sysmanager

svn at pcbsd.org svn at pcbsd.org
Wed Feb 22 07:24:23 PST 2012


Author: kris
Date: 2012-02-22 15:24:23 +0000 (Wed, 22 Feb 2012)
New Revision: 15515

Modified:
   pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp
   pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.h
Log:

Add proxy support to system manager when fetching mirror listing



Modified: pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp	2012-02-22 13:55:25 UTC (rev 15514)
+++ pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp	2012-02-22 15:24:23 UTC (rev 15515)
@@ -16,6 +16,7 @@
 #include <QTextStream>
 #include <QNetworkAccessManager>
 #include <QNetworkReply>
+#include <QNetworkProxy>
 #include <QProgressDialog>
 #include <QDebug>
 #include "../config.h"
@@ -31,6 +32,9 @@
     CheckUname();
     // Set the PC-BSD Version on the General Tab
     CheckPBVer();
+
+    // See if we need to setup a proxy
+    checkProxy();
     
     //Get & Set CPU Type
     labelCPU->setText(Utils::sysctl("hw.model").simplified());
@@ -417,7 +421,7 @@
 
   mirrorJob = new QNetworkAccessManager(this);
   mirrorJobBuf.clear();
-    
+
   QNetworkRequest netRequest;
   netRequest.setUrl(QUrl(URL));
   mirrorReply = mirrorJob->get(netRequest);
@@ -1195,3 +1199,31 @@
          ++it;
         }
 }
+
+void PBSystemTab::checkProxy()
+{
+  bool ok;
+  int port;
+
+  // If no proxy set
+  if ( Utils::getProxyURL().isEmpty() )
+    return;
+
+  QNetworkProxy proxy;
+  if ( Utils::getProxyType() == "SOCKS5" )
+    proxy.setType(QNetworkProxy::Socks5Proxy);
+  else
+    proxy.setType(QNetworkProxy::HttpProxy);
+
+  proxy.setHostName(Utils::getProxyURL());
+
+  port = Utils::getProxyPort().toInt(&ok);
+  if ( ! Utils::getProxyPort().isEmpty() && ok )
+    proxy.setPort(port);
+  if ( ! Utils::getProxyUser().isEmpty() )
+    proxy.setUser(Utils::getProxyUser());
+  if ( ! Utils::getProxyPass().isEmpty() )
+    proxy.setPassword(Utils::getProxyPass());
+
+  QNetworkProxy::setApplicationProxy(proxy);
+}

Modified: pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.h
===================================================================
--- pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.h	2012-02-22 13:55:25 UTC (rev 15514)
+++ pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.h	2012-02-22 15:24:23 UTC (rev 15515)
@@ -120,6 +120,7 @@
     QString mirrorJobBuf;
     QNetworkAccessManager *mirrorJob;
     QNetworkReply *mirrorReply;
+    void checkProxy();
 
     // Meta pkg stuff
     bool allChildrenPkgsChecked(QString parent);



More information about the Commits mailing list