diff options
| -rw-r--r-- | src/JSObject.cpp | 39 | ||||
| -rw-r--r-- | src/JSObject.h | 29 | ||||
| -rw-r--r-- | src/fbbrowser.cpp | 4 | ||||
| -rw-r--r-- | src/html/webkitTest.html | 2 |
4 files changed, 30 insertions, 44 deletions
diff --git a/src/JSObject.cpp b/src/JSObject.cpp index 57fa984..5d29d72 100644 --- a/src/JSObject.cpp +++ b/src/JSObject.cpp @@ -15,41 +15,24 @@ JSObject::JSObject(QWebFrame* qwf) { //------------------------------------------------------------------------------------------------------- JSObject::~JSObject() {} //------------------------------------------------------------------------------------------------------- -void JSObject::enableJavascriptAccess() +void JSObject::attachToDOM() { // Attaches itself to the DOM owner->addToJavaScriptWindowObject(QString("jsObject"), this); - - // connect the signals of the jsObject to the slots of the fbbrowser - QObject::connect(this, SIGNAL(closeBrowser()), this, SLOT(quitAll())); - QObject::connect(this, SIGNAL(startDownload(QString)), this, SLOT(startDownload_Slot(QString))); - QObject::connect(this, SIGNAL(getMacAddress()), this, SLOT(getMacAddress_Slot())); - QObject::connect(this, SIGNAL(showTime()), this, SLOT(showTime_Slot())); - QObject::connect(this, SIGNAL(showHelloWorld()), this, SLOT(showHelloWorld_Slot())); - - // for testing reasons - QObject::connect(this, SIGNAL(showDate()), this, SLOT(showDate_Slot())); - - // TODO: Implement this? - QObject::connect(this, SIGNAL(getIpAddress()), this, SLOT(getIpAddress_Slot())); - QObject::connect(this, SIGNAL(getIntegratedHardwareDevices()), - this, SLOT(getIntegratedHardwareDevices_Slot())); - QObject::connect(this, SIGNAL(getUsbDevices()), this, SLOT(getUsbDevices_Slot())); - QObject::connect(this, SIGNAL(getHardDrives()), this, SLOT(getHardDrives_Slot())); } //------------------------------------------------------------------------------------------------------- -void JSObject::startDownload_Slot(QString filename) +void JSObject::startDownload(QString filename) { emit downloadFile(filename); } //------------------------------------------------------------------------------------------------------- -void JSObject::updateProgressSlot(int i) +void JSObject::updateProgress(int i) { QString code = QString("updateProgress(\%1)").arg(i); owner->evaluateJavaScript(code); } //------------------------------------------------------------------------------------------------------- -void JSObject::getMacAddress_Slot() +void JSObject::getMacAddress() { QNetworkInterface *qNetI = new QNetworkInterface(); QList<QNetworkInterface> list; @@ -68,7 +51,7 @@ void JSObject::getMacAddress_Slot() owner->evaluateJavaScript(code); } //------------------------------------------------------------------------------------------------------- -void JSObject::showTime_Slot() +void JSObject::showTime() { qDebug() << "---- call: showTime_Slot"; QString time = QTime::currentTime().toString("hh:mm:ss"); @@ -79,14 +62,14 @@ void JSObject::showTime_Slot() owner->evaluateJavaScript(code); } //------------------------------------------------------------------------------------------------------- -void JSObject::showDate_Slot() +void JSObject::showDate() { QString date = QDate::currentDate().toString("dd.MM.yyyy"); //TODO:: edit jsFunction name owner->evaluateJavaScript(""); } //------------------------------------------------------------------------------------------------------- -void JSObject::showHelloWorld_Slot() +void JSObject::showHelloWorld() { owner->evaluateJavaScript("alert(\"Hello World\")"); } @@ -107,10 +90,10 @@ void JSObject::getSysInfo(){ */ } //------------------------------------------------------------------------------------------------------- -void JSObject::getIpAddress_Slot(){} +void JSObject::getIpAddress(){} //------------------------------------------------------------------------------------------------------- -void JSObject::getIntegratedHardwareDevices_Slot(){} +void JSObject::getIntegratedHardwareDevices(){} //------------------------------------------------------------------------------------------------------- -void JSObject::getUsbDevices_Slot(){} +void JSObject::getUsbDevices(){} //------------------------------------------------------------------------------------------------------- -void JSObject::getHardDrives_Slot(){} +void JSObject::getHardDrives(){} diff --git a/src/JSObject.h b/src/JSObject.h index 5d543e0..282b232 100644 --- a/src/JSObject.h +++ b/src/JSObject.h @@ -43,14 +43,16 @@ public: // define all the needed signals. // every action gets its own signal. (the former enum is not needed anymore) // the signals will be connected in the fbbrowser class with slots of the fbbrowser class + signals: + void downloadFile(QString filename); + void signalQuitAll(); + /* // should be the last signal to be emited. // Will close the browser and continues the boot sequenze void closeBrowser(); - void signalQuitAll(); // will start the download of all needed files for the following boot sequence void startDownload(QString filename); - void downloadFile(QString filename); // starts the slot which is responsible for extracting the MAC address of the machine // the MAC Address will be the parameter of a javascript function which will present it on the webpage void getMacAddress(); @@ -71,28 +73,29 @@ signals: void showTime(); void showDate(); void showHelloWorld(); + */ public slots: - void enableJavascriptAccess(); + void attachToDOM(); // slots which are emited by the jsObject signals void quitAll(); - void startDownload_Slot(QString filename); - void updateProgressSlot(int i); + void startDownload(QString filename); + void updateProgress(int i); // System info stuff void getSysInfo(); - void getMacAddress_Slot(); - void getIpAddress_Slot(); - void getIntegratedHardwareDevices_Slot(); - void getUsbDevices_Slot(); - void getHardDrives_Slot(); + void getMacAddress(); + void getIpAddress(); + void getIntegratedHardwareDevices(); + void getUsbDevices(); + void getHardDrives(); // for testing reasons - void showTime_Slot(); - void showDate_Slot(); - void showHelloWorld_Slot(); + void showTime(); + void showDate(); + void showHelloWorld(); }; diff --git a/src/fbbrowser.cpp b/src/fbbrowser.cpp index 6c7f642..7436c85 100644 --- a/src/fbbrowser.cpp +++ b/src/fbbrowser.cpp @@ -42,13 +42,13 @@ fbbrowser::fbbrowser(const QUrl & url) qwf = view->page()->mainFrame(); jso = new JSObject(qwf); QObject::connect(qwf, SIGNAL(javaScriptWindowObjectCleared()), - jso, SLOT(enableJavascriptAccess())); + jso, SLOT(attachToDOM())); QObject::connect(jso, SIGNAL(signalQuitAll()), this, SLOT(quit())); // Initialize Download Manager. dm = new DownloadManager(baseUrl); QObject::connect(jso, SIGNAL(downloadFile(QString)), dm, SLOT(downloadFile(QString))); - QObject::connect(dm, SIGNAL(updateProgress(int)), jso, SLOT(updateProgressSlot(int))); + QObject::connect(dm, SIGNAL(updateProgress(int)), jso, SLOT(updateProgress(int))); // Remove the window decoration, form to fullscreen, central view? this->setWindowFlags(Qt::SplashScreen); diff --git a/src/html/webkitTest.html b/src/html/webkitTest.html index 37fc963..3f117ea 100644 --- a/src/html/webkitTest.html +++ b/src/html/webkitTest.html @@ -30,7 +30,7 @@ function printMacAddress(macAddress){ } function quitProgramm(){ - jsObject.closeBrowser(); + jsObject.quitAll(); } function downloadFile(){ |
