]> git.sur5r.net Git - minitube/commitdiff
adjust indent.
authorKiwamu Okabe <kiwamu@gmail.com>
Tue, 1 Sep 2009 22:00:09 +0000 (07:00 +0900)
committerKiwamu Okabe <kiwamu@gmail.com>
Tue, 1 Sep 2009 22:00:09 +0000 (07:00 +0900)
src/global.h

index e3ebdef5281d433309682fee77ed7617ad742a4d..2736ac1cbbcc3959e9d940077f564e0a3d6fe996 100644 (file)
@@ -5,7 +5,7 @@
 #include <QStringList>
 #include <QNetworkProxy>
 #include <QNetworkAccessManager>
-#include <stdlib.h>
+#include <cstdlib>
 #include "networkaccess.h"
 
 namespace The {
@@ -27,60 +27,66 @@ namespace The {
     }
 
     void networkHttpProxySetting() {
-           char *http_proxy_env;
-           http_proxy_env = getenv("http_proxy");
-
-           if (http_proxy_env) {
-                   QString proxy_host = "";
-                   QString proxy_port = "";
-                   QString proxy_user = "";
-                   QString proxy_pass = "";
-                   QString http_proxy = QString(http_proxy_env);
-                   http_proxy.remove(QRegExp("^http://"));
-
-                   if (http_proxy.contains(QChar('@'))) {
-                           QStringList http_proxy_list = http_proxy.split(QChar('@'));
-                           QStringList http_proxy_user_pass = http_proxy_list[0].split(QChar(':'));
-                           if (http_proxy_user_pass.size() > 0) {
-                                   proxy_user = http_proxy_user_pass[0];
-                           }
-                           if (http_proxy_user_pass.size() == 2) {
-                                   proxy_pass = http_proxy_user_pass[1];
-                           }
-                           if (http_proxy_list.size() > 1) {
-                                   http_proxy = http_proxy_list[1];
-                           }
-                   }
-
-                   QStringList http_proxy_list = http_proxy.split(QChar(':'));
-                   if (http_proxy_list.size() > 0) {
-                           proxy_host = http_proxy_list[0];
-                   }
-                   if (http_proxy_list.size() > 1) {
-                           proxy_port = http_proxy_list[1];
-                   }
-
-                   qDebug() << "proxy_host: " << proxy_host;
-                   qDebug() << "proxy_port: " << proxy_port;
-                   qDebug() << "proxy_user: " << proxy_user;
-                   qDebug() << "proxy_pass: " << proxy_pass;
-
-                   if (!proxy_host.isEmpty()) {
-                           QNetworkProxy proxy;
-                           proxy.setType(QNetworkProxy::HttpProxy);
-                           proxy.setHostName(proxy_host);
-                           if (!proxy_port.isEmpty()) {
-                                   proxy.setPort(proxy_port.toUShort());
-                           }
-                           if (!proxy_user.isEmpty()) {
-                                   proxy.setUser(proxy_user);
-                           }
-                           if (!proxy_pass.isEmpty()) {
-                                   proxy.setPassword(proxy_pass);
-                           }
-                           QNetworkProxy::setApplicationProxy(proxy);
-                   }
-           }
+        char *http_proxy_env;
+        http_proxy_env = std::getenv("http_proxy");
+        if (!http_proxy_env) {
+            http_proxy_env = std::getenv("HTTP_PROXY");
+        }
+
+        if (http_proxy_env) {
+            QString proxy_host = "";
+            QString proxy_port = "";
+            QString proxy_user = "";
+            QString proxy_pass = "";
+            QString http_proxy = QString(http_proxy_env);
+            http_proxy.remove(QRegExp("^http://"));
+
+            // parse username and password
+            if (http_proxy.contains(QChar('@'))) {
+                QStringList http_proxy_list = http_proxy.split(QChar('@'));
+                QStringList http_proxy_user_pass = http_proxy_list[0].split(QChar(':'));
+                if (http_proxy_user_pass.size() > 0) {
+                    proxy_user = http_proxy_user_pass[0];
+                }
+                if (http_proxy_user_pass.size() == 2) {
+                    proxy_pass = http_proxy_user_pass[1];
+                }
+                if (http_proxy_list.size() > 1) {
+                    http_proxy = http_proxy_list[1];
+                }
+            }
+
+            // parse hostname and port
+            QStringList http_proxy_list = http_proxy.split(QChar(':'));
+            if (http_proxy_list.size() > 0) {
+                proxy_host = http_proxy_list[0];
+            }
+            if (http_proxy_list.size() > 1) {
+                proxy_port = http_proxy_list[1];
+            }
+
+            qDebug() << "proxy_host: " << proxy_host;
+            qDebug() << "proxy_port: " << proxy_port;
+            qDebug() << "proxy_user: " << proxy_user;
+            qDebug() << "proxy_pass: " << proxy_pass;
+
+            // set proxy setting
+            if (!proxy_host.isEmpty()) {
+                QNetworkProxy proxy;
+                proxy.setType(QNetworkProxy::HttpProxy);
+                proxy.setHostName(proxy_host);
+                if (!proxy_port.isEmpty()) {
+                    proxy.setPort(proxy_port.toUShort());
+                }
+                if (!proxy_user.isEmpty()) {
+                    proxy.setUser(proxy_user);
+                }
+                if (!proxy_pass.isEmpty()) {
+                    proxy.setPassword(proxy_pass);
+                }
+                QNetworkProxy::setApplicationProxy(proxy);
+            }
+        }
     }
 
     static QNetworkAccessManager *nam = 0;
@@ -112,3 +118,10 @@ namespace The {
 }
 
 #endif // GLOBAL_H
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */