[PC-BSD Commits] r7685 - pcbsd/current/src-qt4/libpcbsd
svn at pcbsd.org
svn at pcbsd.org
Fri Oct 1 08:41:01 PDT 2010
Author: kris
Date: 2010-10-01 08:41:01 -0700 (Fri, 01 Oct 2010)
New Revision: 7685
Modified:
pcbsd/current/src-qt4/libpcbsd/pcbsd-utils.h
pcbsd/current/src-qt4/libpcbsd/utils.cpp
Log:
Added some new functions to libpcbsd utils, which we can use elsewhere in GUI for getting network /
mirror settings
Modified: pcbsd/current/src-qt4/libpcbsd/pcbsd-utils.h
===================================================================
--- pcbsd/current/src-qt4/libpcbsd/pcbsd-utils.h 2010-10-01 14:15:01 UTC (rev 7684)
+++ pcbsd/current/src-qt4/libpcbsd/pcbsd-utils.h 2010-10-01 15:41:01 UTC (rev 7685)
@@ -31,6 +31,13 @@
static QString sysctl(QString sysctl);
static long long sysctlAsInt(QString sysctl);
static QString bytesToHumanReadable(long long bytes);
+ static QString getValFromPBIConf(QString key);
+ static QString getProxyURL();
+ static QString getProxyUser();
+ static QString getProxyPass();
+ static QString getProxyType();
+ static QString getProxyPort();
+ static QString getMasterMirror();
};
#endif
Modified: pcbsd/current/src-qt4/libpcbsd/utils.cpp
===================================================================
--- pcbsd/current/src-qt4/libpcbsd/utils.cpp 2010-10-01 14:15:01 UTC (rev 7684)
+++ pcbsd/current/src-qt4/libpcbsd/utils.cpp 2010-10-01 15:41:01 UTC (rev 7685)
@@ -1,6 +1,6 @@
/***************************************************************************
- * Copyright (C) 2008 by Tim McCormick *
- * tim at pcbsd.org *
+ * Copyright (C) 2008 by Tim McCormick *
+ * tim at pcbsd.org *
* *
* Permission is hereby granted, free of charge, to any person obtaining *
* a copy of this software and associated documentation files (the *
@@ -25,10 +25,15 @@
#include <sys/types.h>
#include <sys/sysctl.h>
-#include <qstring.h>
+#include <QString>
+#include <QFile>
+#include <QTextStream>
#include "pcbsd-utils.h"
+// The default pbi.conf file
+#define PBI_ETCCONF "/usr/local/etc/pbi.conf"
+
QString Utils::sysctl(QString sysctl)
{
char result[1000];
@@ -74,3 +79,51 @@
QString result = QString::number(bytes) + pointval;
return result += suffix[i];
}
+
+
+// Function to get a value from a specific key in the pbi.conf file
+QString Utils::getValFromPBIConf(QString key) {
+
+ // Load from PBI_ETCCONF the default mirror
+ QFile confFile(PBI_ETCCONF);
+ if ( confFile.open( QIODevice::ReadOnly ) ) {
+ QTextStream stream( &confFile );
+ stream.setCodec("UTF-8");
+ QString line;
+ while ( !stream.atEnd() ) {
+ line = stream.readLine();
+ if ( line.indexOf(key + ": ") == 0 ) {
+ confFile.close();
+ return line.replace(key + ": ", "");
+ }
+
+ }
+ confFile.close();
+ }
+
+ return QString();
+}
+
+QString Utils::getProxyURL() {
+ return getValFromPBIConf("PBI_PROXYURL");
+}
+
+QString Utils::getProxyUser() {
+ return getValFromPBIConf("PBI_PROXYUSER");
+}
+
+QString Utils::getProxyPass() {
+ return getValFromPBIConf("PBI_PROXYPASS");
+}
+
+QString Utils::getProxyType() {
+ return getValFromPBIConf("PBI_PROXYTYPE");
+}
+
+QString Utils::getProxyPort() {
+ return getValFromPBIConf("PBI_PROXYPORT");
+}
+
+QString Utils::getMasterMirror() {
+ return getValFromPBIConf("PBI_MIRROR");
+}
More information about the Commits
mailing list