summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/downloadManager.cpp6
-rw-r--r--src/downloadManager.h6
-rw-r--r--src/fbgui.cpp6
-rw-r--r--src/javascriptInterface.cpp12
-rw-r--r--src/javascriptInterface.h10
-rw-r--r--src/sysInfo.cpp11
-rw-r--r--src/sysInfo.h16
7 files changed, 34 insertions, 33 deletions
diff --git a/src/downloadManager.cpp b/src/downloadManager.cpp
index 9b4c162..43c27e9 100644
--- a/src/downloadManager.cpp
+++ b/src/downloadManager.cpp
@@ -38,18 +38,18 @@ void downloadManager::checkDownloadDirectory()
else qxtLog->debug() << "Download directory: " << downloadDir.path() << " exists.";
}
// ----------------------------------------------------------------------------------------
-void downloadManager::downloadFile(QString& filename)
+void downloadManager::downloadFile(const QString& filename)
{
QUrl fileUrl(baseURL.resolved(QUrl(filename)));
this->processDownloadRequest(fileUrl);
}
// ----------------------------------------------------------------------------------------
-void downloadManager::downloadFile(QUrl& fileUrl)
+void downloadManager::downloadFile(const QUrl& fileUrl)
{
this->processDownloadRequest(fileUrl);
}
// ----------------------------------------------------------------------------------------
-void downloadManager::processDownloadRequest(QUrl& url)
+void downloadManager::processDownloadRequest(const QUrl& url)
{
if (url.isEmpty()){
qxtLog->debug() << "No URL specified for download.";
diff --git a/src/downloadManager.h b/src/downloadManager.h
index 8e11313..c80e58a 100644
--- a/src/downloadManager.h
+++ b/src/downloadManager.h
@@ -38,7 +38,7 @@ private:
// checks for valid download directory, ran once in constructor
void checkDownloadDirectory();
// private control function for queueing mechanism.
- void processDownloadRequest(QUrl& url);
+ void processDownloadRequest(const QUrl& url);
// base objects for downloading
QNetworkAccessManager* qnam;
@@ -66,8 +66,8 @@ signals:
public slots:
// public slots to receive download requests.
- void downloadFile(QUrl& fileUrl);
- void downloadFile(QString& fileUrl);
+ void downloadFile(const QUrl& fileUrl);
+ void downloadFile(const QString& fileUrl);
private slots:
// private slots to manage the downloading process
diff --git a/src/fbgui.cpp b/src/fbgui.cpp
index e43d36e..bec4eb5 100644
--- a/src/fbgui.cpp
+++ b/src/fbgui.cpp
@@ -48,9 +48,9 @@ fbgui::fbgui()
downloadManager* dm = new downloadManager();
QObject::connect(dm, SIGNAL(downloadInfo(const QString&, const double&)),
jsi, SLOT(downloadInfo(const QString&, const double&)));
- QObject::connect(dm, SIGNAL(notify(QString)),
- jsi, SLOT(notify(QString)));
- QObject::connect(jsi, SIGNAL(requestFile(QString&)), dm, SLOT(downloadFile(QString&)));
+ QObject::connect(dm, SIGNAL(notify(const QString&)),
+ jsi, SLOT(notify(const QString&)));
+ QObject::connect(jsi, SIGNAL(requestFile(const QString&)), dm, SLOT(downloadFile(const QString&)));
QObject::connect(dm, SIGNAL(updateProgress(const int&, const double&, const QString&)),
jsi, SLOT(updateProgressBar(const int&, const double&, const QString&)));
QObject::connect(dm, SIGNAL(downloadQueueEmpty()), jsi, SLOT(callbackOnDlQueueFinished()));
diff --git a/src/javascriptInterface.cpp b/src/javascriptInterface.cpp
index c70347c..a15cf8d 100644
--- a/src/javascriptInterface.cpp
+++ b/src/javascriptInterface.cpp
@@ -2,16 +2,16 @@
#include "javascriptInterface.h"
#include "sysInfo.h"
+
//-------------------------------------------------------------------------------------------------------
javascriptInterface::javascriptInterface(QWebFrame *parent){
qxtLog->debug() << "Initializing javascript interface...";
- //TODO: check for better way to use evaluateJavaScript()
_parent = parent;
}
//-------------------------------------------------------------------------------------------------------
javascriptInterface::~javascriptInterface() {}
//-------------------------------------------------------------------------------------------------------
-QString javascriptInterface::getSysInfo(const QString& info){
+const QString javascriptInterface::getSysInfo(const QString& info){
sysInfo si;
return si.getInfo(info);
}
@@ -20,7 +20,7 @@ void javascriptInterface::attachToDOM(){
_parent->addToJavaScriptWindowObject(QString("fbgui"), this);
}
//-------------------------------------------------------------------------------------------------------
-void javascriptInterface::startDownload(QString filename){
+void javascriptInterface::startDownload(const QString& filename){
// ignore if empty filename
if (filename.isEmpty()){
_parent->evaluateJavaScript("alert(\"No filename!\")");
@@ -46,12 +46,12 @@ void javascriptInterface::updateProgressBar(const int& percent, const double& sp
_parent->evaluateJavaScript(code);
}
//-------------------------------------------------------------------------------------------------------
-void javascriptInterface::setCallbackOnDlQueueFinished(QString jsFunction){
- callBackOnDownloadsFinished = jsFunction;
+void javascriptInterface::setCallbackOnDlQueueFinished(QString& jsFunction){
+ _callBackOnDownloadsFinished = jsFunction;
}
//-------------------------------------------------------------------------------------------------------
void javascriptInterface::callbackOnDlQueueFinished(){
- QString code = QString("\%1").arg(callBackOnDownloadsFinished);
+ QString code = QString("\%1").arg(_callBackOnDownloadsFinished);
_parent->evaluateJavaScript(code);
}
//-------------------------------------------------------------------------------------------------------
diff --git a/src/javascriptInterface.h b/src/javascriptInterface.h
index a139780..20bd206 100644
--- a/src/javascriptInterface.h
+++ b/src/javascriptInterface.h
@@ -25,25 +25,25 @@ class javascriptInterface : public QObject
Q_OBJECT
private:
QWebFrame* _parent;
- QString callBackOnDownloadsFinished;
+ QString _callBackOnDownloadsFinished;
public:
javascriptInterface(QWebFrame* parent);
virtual ~javascriptInterface();
signals:
- void requestFile(QString& filename);
+ void requestFile(const QString& filename);
void quitFbgui();
public slots:
void attachToDOM();
- void startDownload(QString filename);
- void setCallbackOnDlQueueFinished(QString fctOnDownloadsFinished);
+ void startDownload(const QString& filename);
+ void setCallbackOnDlQueueFinished(QString& fctOnDownloadsFinished);
void callbackOnDlQueueFinished();
void updateProgressBar(const int& percent, const double& speed, const QString& unit);
void downloadInfo(const QString& filename, const double& filesize);
void notify(const QString& msg);
- QString getSysInfo(const QString& info);
+ const QString getSysInfo(const QString& info);
void quit();
};
diff --git a/src/sysInfo.cpp b/src/sysInfo.cpp
index ff114e8..e7ed8a8 100644
--- a/src/sysInfo.cpp
+++ b/src/sysInfo.cpp
@@ -2,12 +2,11 @@
// ------------------------------------------------------------------------------------------------
-sysInfo::sysInfo(){
-}
+sysInfo::sysInfo(){}
// ------------------------------------------------------------------------------------------------
sysInfo::~sysInfo(){}
// ------------------------------------------------------------------------------------------------
-QString sysInfo::getInfo(const QString& infoName){
+const QString sysInfo::getInfo(const QString& infoName){
qxtLog->debug() << "[sysInfo] requested " << infoName;
if (infoName == QString("mac"))
return getMACAddress();
@@ -21,7 +20,7 @@ QString sysInfo::getInfo(const QString& infoName){
return "info_error";
}
// ------------------------------------------------------------------------------------------------
-QString sysInfo::getMACAddress(){
+const QString sysInfo::getMACAddress(){
// Returns MAC address of eth0 for now
QNetworkInterface qni = QNetworkInterface::interfaceFromName(QString("eth0"));
if (!qni.isValid()){
@@ -32,7 +31,7 @@ QString sysInfo::getMACAddress(){
return qni.hardwareAddress();
}
// ------------------------------------------------------------------------------------------------
-QString sysInfo::getIPAddress(){
+const QString sysInfo::getIPAddress(){
// Again for eth0 only at the moment.
// TODO: this doesn't quite work yet...
QNetworkInterface qni = QNetworkInterface::interfaceFromName(QString("eth0"));
@@ -48,7 +47,7 @@ QString sysInfo::getIPAddress(){
return "ip_error";
}
// ------------------------------------------------------------------------------------------------
-QByteArray sysInfo::getNames(){
+const QByteArray sysInfo::getNames(){
QVariantMap foo;
foo.insert("name", "foo");
diff --git a/src/sysInfo.h b/src/sysInfo.h
index 4e6988e..21ed78b 100644
--- a/src/sysInfo.h
+++ b/src/sysInfo.h
@@ -25,17 +25,19 @@ class sysInfo {
public:
sysInfo();
~sysInfo();
- // public access. infoName
- QString getInfo(const QString& infoName);
+ // public access, valid infoName: "mac", "ip", ...
+ const QString getInfo(const QString& infoName);
private:
- QJson::Serializer serializer;
-
- QByteArray getNames();
- QString getMACAddress();
- QString getIPAddress();
+ // private system information readers
+ const QString getMACAddress();
+ const QString getIPAddress();
QString getAllInfos();
QString getScriptOutput(QString cmd);
+
+ // JSon testing
+ QJson::Serializer serializer;
+ const QByteArray getNames();
};
#endif // SYSTINFO_H