summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/CommandLineOptions.cpp42
-rw-r--r--src/CommandLineOptions.h16
-rw-r--r--src/DownloadManager.h2
-rw-r--r--src/JSObject.cpp2
-rw-r--r--src/fbbrowser.cpp1
-rw-r--r--src/fbbrowser.h8
-rw-r--r--src/fbgui.cpp61
-rw-r--r--src/fbgui.pro6
8 files changed, 93 insertions, 45 deletions
diff --git a/src/CommandLineOptions.cpp b/src/CommandLineOptions.cpp
new file mode 100644
index 0000000..fae5c29
--- /dev/null
+++ b/src/CommandLineOptions.cpp
@@ -0,0 +1,42 @@
+/*
+ * This class parses the command line options.
+ */
+
+
+#include <getopt.h>
+#include <cstdlib>
+#include "CommandLineOptions.h"
+
+CommandLineOptions::CommandLineOptions(int argc, char * const argv[]){
+ // Parse command line arguments.
+ int longIndex = 0;
+ // Declare the short options as a char*, these have exactly one - followed by letter from optString.
+ // For example: ./fbbrowser -h
+ // Declare the long options in the const struct, these have two - followed by a string found in longOpts[].
+ // Same as: ./fbbrowser --help
+ // Note: I included 'qwsdiplay' here to not have errors, when setting fbbrowser to be the server app aswell.
+ static const char *optString = "hqwsdiplay";
+ static const struct option longOpts[] =
+ {
+ // If an option requires parameters, write this number instead of no_argument.
+ // The last argument, is the corresponding char to the option string.
+ {"debug", no_argument, NULL, 'D'},
+ {"help", no_argument, NULL, 'h'}
+ };
+ // getopt_long returns the index of the next argument to be read, -1 if there are no more arguments.
+ int opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
+ while (opt != -1)
+ {
+ switch(opt)
+ {
+ case 'h':
+ //printUsage();
+ break;
+ }
+ opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
+ }
+}
+
+CommandLineOptions::~CommandLineOptions(){
+
+}
diff --git a/src/CommandLineOptions.h b/src/CommandLineOptions.h
new file mode 100644
index 0000000..a8b15d4
--- /dev/null
+++ b/src/CommandLineOptions.h
@@ -0,0 +1,16 @@
+#ifndef COMMANDLINEOPTIONS_H
+#define COMMANDLINEOPTIONS_H
+
+#include <QMap>
+
+class CommandLineOptions {
+ public:
+ CommandLineOptions(int argc, char * const argv[]);
+ ~CommandLineOptions();
+ private:
+ QMap<QString, QString> options;
+};
+
+
+
+#endif // COMMANDLINEOPTIONS_H
diff --git a/src/DownloadManager.h b/src/DownloadManager.h
index b11e6b1..5007b27 100644
--- a/src/DownloadManager.h
+++ b/src/DownloadManager.h
@@ -3,7 +3,7 @@
#include "fbbrowser.h"
#include <QObject>
-#include <QtWebKit>
+#include <QtNetwork>
class DownloadManager : public QObject
{
diff --git a/src/JSObject.cpp b/src/JSObject.cpp
index 5d29d72..3624a89 100644
--- a/src/JSObject.cpp
+++ b/src/JSObject.cpp
@@ -28,6 +28,8 @@ void JSObject::startDownload(QString filename)
//-------------------------------------------------------------------------------------------------------
void JSObject::updateProgress(int i)
{
+ if (i == 0)
+ return;
QString code = QString("updateProgress(\%1)").arg(i);
owner->evaluateJavaScript(code);
}
diff --git a/src/fbbrowser.cpp b/src/fbbrowser.cpp
index 2b8bc7a..853030a 100644
--- a/src/fbbrowser.cpp
+++ b/src/fbbrowser.cpp
@@ -2,6 +2,7 @@
#include "JSObject.h"
#include "DownloadManager.h"
+
#include <QFile>
#include <QFileInfo>
#include <QtWebKit>
diff --git a/src/fbbrowser.h b/src/fbbrowser.h
index 7c09cef..926cd6c 100644
--- a/src/fbbrowser.h
+++ b/src/fbbrowser.h
@@ -1,13 +1,15 @@
#ifndef FBBROWSER_H
#define FBBROWSER_H
-#include "JSObject.h"
-#include "DownloadManager.h"
#include <QString>
#include <QtGui>
-#include <QtNetwork>
+#include <QtWebKit>
+
+#include "JSObject.h"
+#include "DownloadManager.h"
class QWebView;
+class QWebFrame;
class JSObject;
class DownloadManager;
diff --git a/src/fbgui.cpp b/src/fbgui.cpp
index 8cd58bc..5552643 100644
--- a/src/fbgui.cpp
+++ b/src/fbgui.cpp
@@ -1,16 +1,20 @@
#include "fbgui.h"
+#include "CommandLineOptions.h"
#include "fbbrowser.h"
#include "DownloadManager.h"
-#include <getopt.h>
-#include <limits.h>
-#include <unistd.h>
+
#include <QApplication>
-#include <QThread>
+#include <QSettings>
+
+//#include <getopt.h>
+//#include <limits.h>
+//#include <unistd.h>
+
void printUsage()
{
- // Prints usage information, incomplete.
- // Q: How is the -qws option handled, mention it here or not?
+ // Prints usage information.
+ // TODO: Complete usage info.
QTextStream qout(stdout);
qout << QObject::tr("Usage: ./fbgui [OPTIONS] <URL>") << endl;
qout << QObject::tr("Options:") << endl;
@@ -22,45 +26,24 @@ void printUsage()
int main(int argc, char *argv[])
{
- // Parse command line arguments.
- int opt = 0;
- int longIndex = 0;
- // Declare the short options as a char*, these have exactly one - followed by letter from optString.
- // For example: ./fbbrowser -h
- // Declare the long options in the const struct, these have two - followed by a string found in longOpts[].
- // Same as: ./fbbrowser --help
- // Note: I included 'qws' here to not have errors, when setting fbbrowser to be the server app aswell.
- static const char *optString = "hqwsdiplay";
- static const struct option longOpts[] =
- {
- // If an option requires parameters, write this number instead of no_argument.
- // The last argument, is the corresponding char to the option string.
- {"help", no_argument, NULL, 'h'}
- };
- // getopt_long returns the index of the next argument to be read, -1 if there are no more arguments.
- opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
- while (opt != -1)
- {
- switch(opt)
- {
- case 'h':
- printUsage();
- break;
- }
- opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
- }
+ /* SETTINGS TEST */
+ //CommandLineOptions clOptions(argc, argv);
+
+ // TODO: parse url arg from CommmandLineOptions object.
+ // hackfix for now...
+ QUrl url(argv[4]);
+ QUrl defaultUrl = QUrl("http://132.230.4.3/webkitTest.html");
+ qDebug() << "URL given: " << url.toString();
+
+ /* SETTINGS TEST */
+
// This is the main object of a QT Application.
QApplication a(argc, argv);
// Get the application path and prints on screen.
qDebug() << "Application Path: " << a.applicationDirPath();
// Is this really needed, since we kill the app through the fbbrowser object?
QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
- // This part reads the URL to load from the arguments given through the commandline.
- QUrl url;
- if (argc > 1)
- url = QUrl(argv[1]);
- else //Default URL to load
- url = QUrl("http://132.230.4.3/webkitTest.html");
+
// Create a new Framebuffer-Browser object for displaying the given URL.
fbbrowser* fbb = new fbbrowser(url);
diff --git a/src/fbgui.pro b/src/fbgui.pro
index ab75949..7c1a19e 100644
--- a/src/fbgui.pro
+++ b/src/fbgui.pro
@@ -6,10 +6,12 @@ QT += core \
gui \
webkit \
network
-HEADERS += JSObject.h \
+HEADERS += CommandLineOptions.h \
+ JSObject.h \
DownloadManager.h \
fbbrowser.h
-SOURCES += JSObject.cpp \
+SOURCES += CommandLineOptions.cpp \
+ JSObject.cpp \
fbgui.cpp \
DownloadManager.cpp \
fbbrowser.cpp