ndgui/NetworkDiscovery
|
00001 /* 00002 * Copyright (c) 2010,2011 - RZ Uni Freiburg 00003 * Copyright (c) 2010,2011 - OpenSLX Project 00004 * 00005 * This program/file is free software distributed under the GPL version 2. 00006 * See http://openslx.org/COPYING 00007 * 00008 * If you have any feedback please consult http://openslx.org/feedback and 00009 * send your feedback to feedback@openslx.org 00010 * 00011 * General information about OpenSLX can be found under http://openslx.org 00012 * 00013 * 00014 * Main class of the fbgui: 00015 * - Manages display of components and their communications 00016 * 00017 */ 00018 00019 #ifndef FBGUI_H 00020 #define FBGUI_H 00021 00022 #include <QWSServer> 00023 #include <QtGui> 00024 #include <QtWebKit> 00025 #include <QxtCore> 00026 00027 // Internal default settings 00028 #define DEFAULT_URL "http://www.google.com" 00029 #define DEFAULT_DOWNLOAD_DIR "/tmp/fbgui" 00030 #define DEFAULT_CONFIG_PATH "/etc/fbgui.conf" 00031 #define DEFAULT_LOG_FILE_PATH "/tmp/fbgui.log" 00032 #define DEFAULT_UPDATE_INTERVAL 1; 00033 #define DEFAULT_QRC_HTML_DIR ":/html" 00034 #define DEFAULT_FILE_TRIGGER "/tmp/fbgui/trigger" 00035 00036 // Global settings variables 00037 extern QString logFilePath; 00038 extern QString ipConfigFilePath; 00039 extern QThread dmThread; 00040 extern QString serialLocation; 00041 extern QString fileToTriggerURL; 00042 extern QString sessionID; 00043 extern QString binPath; 00044 extern QString downloadPath; 00045 extern QUrl baseURL; 00046 extern int debugMode; 00047 extern int updateInterval; 00048 00049 class fbgui: public QMainWindow { 00050 Q_OBJECT 00051 00052 public: 00053 fbgui(); 00054 ~fbgui(); 00055 00056 public slots: 00057 void init(); 00058 00059 private: 00060 //------------------- 00061 // layout setup: 00062 //------------------- 00063 // Sets the layout depending on the debug mode: 00064 // no debug or debugMode = 0 -> only browser shown. 00065 // debugMode = 1 -> split main window in browser and debug console. 00066 void setupLayout(); 00067 // Create all actions for the GUI. (Currently only quit.) 00068 void createActions(); 00069 // Create a debug console widget as QTextEdit in order to print debug messages 00070 // directly within the GUI. This was needed since ttys can't really be used 00071 // for debugging purposes in the preboot environment. 00072 void createDebugConsole(); 00073 00074 //---------------------------------------- 00075 // control the display of components: 00076 //---------------------------------------- 00077 // watches for the file triggering the loading of the URL. 00078 // the file can be specified by the corresponding option. 00079 void watchForTrigger(); 00080 bool checkHost() const; 00081 void loadURL(); 00082 QByteArray generatePOSTData(); 00083 00084 //---------------------------------- 00085 // widgets constituing the gui: 00086 //---------------------------------- 00087 // QWebView for displaying internet content 00088 QWebView* _webView; 00089 // QSplitter to split the main window in two resizable frames. 00090 QSplitter* _splitter; 00091 // QTextEdit implementing a minimalistic debug console. 00092 QTextEdit* _debugConsole; 00093 00094 //------------------ 00095 // action list: 00096 //------------------ 00097 // closes the main window provoking the application to quit. 00098 QAction* _quit; 00099 // triggers toggleDebugConsole() 00100 QAction* _toggleDebugConsole; 00101 00102 // watcher to detect changes in the observed directory. 00103 QFileSystemWatcher* _watcher; 00104 00105 private slots: 00106 // toggles debug console when action _toggleDebugConsole happens. 00107 void toggleDebugConsole(); 00108 00109 // This function is triggered by fileChanged Signal of _watcher. 00110 // It deletes _watcher, since we don't need it anymore and tries to load URL. 00111 void prepareURLLoad(); 00112 void loadURLDone(bool success); 00113 00114 // shut off the system 00115 void performShutDown(); 00116 // reboot the system 00117 void performReboot(); 00118 // shows "loading system" page 00119 void loadSystem(); 00120 // prepares kexec by loading downloaded initramfs, kernel into kexec 00121 void prepareKexec(); 00122 // executes: kexec -e 00123 void runKexec(); 00124 }; 00125 00126 #endif // FBGUI_H