diff --git a/README.md b/README.md index ddd6d2e..10affe1 100644 --- a/README.md +++ b/README.md @@ -65,11 +65,9 @@ TODO (wish list) ---------------- * plasmoid helper integration -* gui helper|systemd integration -* helper uid/euid check to allow use /Ctrl interface +* `==` checking to avoid segfaults * include security notes / project architecture to about window -* DBus API description -* tests +* autotests Links ----- diff --git a/sources/gui/CMakeLists.txt b/sources/gui/CMakeLists.txt index ada71d1..998fd89 100644 --- a/sources/gui/CMakeLists.txt +++ b/sources/gui/CMakeLists.txt @@ -5,6 +5,7 @@ message (STATUS "Subproject ${SUBPROJECT}") # set directories set (SUBPROJECT_BINARY_DIR bin) set (SUBPROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) +set (SUBPROJECT_DOCS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/docs) set (SUBPROJECT_RESOURCE_DIR ${PROJECT_RESOURCE_DIR}) set (SUBPROJECT_TRANSLATION_DIR ${SUBPROJECT_RESOURCE_DIR}/translations) # executable path @@ -15,6 +16,7 @@ set (TARGETS "") set (HEADERS "") add_subdirectory (${SUBPROJECT_SOURCE_DIR}) +add_subdirectory (${SUBPROJECT_DOCS_DIR}) # build man file (GLOB SUBPROJECT_MAN_IN *.1) file (RELATIVE_PATH SUBPROJECT_MAN ${CMAKE_SOURCE_DIR} ${SUBPROJECT_MAN_IN}) diff --git a/sources/gui/docs/CMakeLists.txt b/sources/gui/docs/CMakeLists.txt new file mode 100644 index 0000000..1569b7f --- /dev/null +++ b/sources/gui/docs/CMakeLists.txt @@ -0,0 +1,9 @@ +# build pages +file (GLOB SUBPROJECT_DOCS_IN *.html) +foreach (DOC_IN ${SUBPROJECT_DOCS_IN}) + file (RELATIVE_PATH ONE_DOC ${CMAKE_SOURCE_DIR} ${DOC_IN}) + configure_file (${DOC_IN} ${CMAKE_CURRENT_BINARY_DIR}/${ONE_DOC}) + set (SUBPROJECT_DOCS ${SUBPROJECT_DOCS} ${CMAKE_CURRENT_BINARY_DIR}/${ONE_DOC}) +endforeach () + +install (FILES ${SUBPROJECT_DOCS} DESTINATION share/doc/${PROJECT_NAME}) diff --git a/sources/gui/docs/netctl-gui-dbus-api.html b/sources/gui/docs/netctl-gui-dbus-api.html new file mode 100644 index 0000000..8dbba4e --- /dev/null +++ b/sources/gui/docs/netctl-gui-dbus-api.html @@ -0,0 +1,325 @@ + + + + netctl-gui DBus API desription + +

netctl-gui DBus API description

+

Project version : @PROJECT_VERSION@

+
    +
  1. DBus API
  2. +
  3. Helper API
  4. + +
  5. GUI API
  6. + +
  7. External links
  8. +
+ + + +

DBus API

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
methodresponcerun as root
org.netctlgui.helper service (system bus)
/ctrl path
bool Active()true if helper is activeno
QString ApiDocs()returns path to this API documentationno
bool Close()true and closes the helperno
QString LibraryDocs()returns path to the library documentationno
QString SecurityDocs()returns path to the security documentationno
QStringList Settings()current helper settings KEY=VALUEno
bool Update()calls update helper configuration. Returns trueno
bool Enable(QString profile)enables or disables the profile. Returns true if action has been performed successfullyyes
bool Restart(QString profile)restarts the profile. Returns true if action has been performed successfullyyes
bool Start(QString profile)starts or stops the profile. Returns true if action has been performed successfullyyes
bool SwitchTo(QString profile)switchs to the profile. Returns true if action has been performed successfullyyes
bool Create(QString profile, QStringList settingsList)creates the profile with specified settings. Settings should be given in the format KEY==VALUE. Returns true if action has been performed successfullyyes
bool Remove(QString profile)removes the profile. Returns true if action has been performed successfullyyes
bool autoDisableAll()disables all profiles (netctl-auto). Returns true if action has been performed successfullyno?
bool autoEnable(QString profile)enables or disables the profile (netctl-auto). Returns true if action has been performed successfullyno?
bool autoEnableAll()enables all profiles (netctl-auto). Returns true if action has been performed successfullyno?
bool autoStart(QString profile)switchs to the profile (netctl-auto). Returns true if action has been performed successfullyno?
bool autoServiceEnable()enables or disables netctl-auto systemd service. Returns true if action has been performed successfullyyes
bool autoServiceRestart()restarts netctl-auto systemd service. Returns true if action has been performed successfullyyes
bool autoServiceStart()starts or stops netctl-auto systemd service. Returns true if action has been performed successfullyyes
QStringList WiFi()returns available WiFi points in format NAME|SECURITY|SIGNAL|ACTIVE|EXISTSyes
/netctl path
QString ActiveProfile()returns active profile from netctl or netctl-autono
QString ActiveProfileStatus()returns active profile status from netctl or netctl-auto. May be netctl-auto, active (enabled), active (static), inactive (enabled), inactive (static)no
QStringList Information()returns general information in format [ActiveProfile, ActiveProfileStatus]no
QStringList ProfileList()returns available profiles in format NAME|DESCRIPTION|ACTIVE|ENABLEDno
QStringList WirelessInterface()returns wireless interfacesno
bool isProfileActive(QString profile)returns true if the profile is activeno
bool isProfileEnabled(QString profile)returns true if the profile is enabledno
bool autoIsProfileActive(QString profile)returns true if the profile is active (netctl-auto)no
bool autoIsProfileEnabled(QString profile)returns true if the profile is enabled (netctl-auto)no
bool isNetctlAutoActive()returns true if netctl-auto is activeno
bool isNetctlAutoEnabled()returns true if netctl-auto is enabledno
QStringList Profile(QString profile)returns the profile settings in format KEY==VALUEno
QString ProfileByEssid(QString essid)returns the profile name by the given ESSID or empty lineno
QString ProfileValue(QString profile, QString key)returns value of the key by the given profile or empty lineno
org.netctlgui.netctlgui service (session bus)
/netctlgui path
void ApiDocs()opens this API documentationno
bool Close()true and closes the applicationno
QString Information()the same as org.netctlgui.helper /netctl Informationno
void LibraryDocs()opens the library documentationno
bool Restore()true and restores the applicationno
void SecurityDocs()opens the security documentationno
QStringList Settings()current application settings KEY=VALUEno
bool ShowAbout()true and shows about windowno
bool ShowMain()true and shows main windowno
bool ShowNetctlAuto()true and shows netctl-auto windowno
bool ShowSettings()true and shows settings windowno
+ +

External links

+ + +

+ © 2014-@CURRENT_YEAR@ @PROJECT_AUTHOR@
+ This software is licensed under @PROJECT_LICENSE@ +

+ + + \ No newline at end of file diff --git a/sources/gui/docs/netctl-gui-security-notes.html b/sources/gui/docs/netctl-gui-security-notes.html new file mode 100644 index 0000000..a715704 --- /dev/null +++ b/sources/gui/docs/netctl-gui-security-notes.html @@ -0,0 +1,29 @@ + + + + netctl-gui secutiry notes + +

netctl-gui security notes

+

Project version : @PROJECT_VERSION@

+
    +
  1. External links
  2. +
+ + + +

External links

+ + +

+ © 2014-@CURRENT_YEAR@ @PROJECT_AUTHOR@
+ This software is licensed under @PROJECT_LICENSE@ +

+ + + \ No newline at end of file diff --git a/sources/gui/netctl-gui.1 b/sources/gui/netctl-gui.1 index c453988..d25dc22 100644 --- a/sources/gui/netctl-gui.1 +++ b/sources/gui/netctl-gui.1 @@ -63,7 +63,15 @@ show this help and exit Configuration file .RE .SH SEE ALSO -.BR netctl-gui (1) +.BR netctlgui-helper (1) +.SH STANDARDS +See +.B @CMAKE_INSTALL_PREFIX@/share/doc/netctl-gui/netctl-gui-dbus-api.html +for more details. +.SH SECURITY CONSIDERATIONS +See +.B @CMAKE_INSTALL_PREFIX@/share/doc/netctl-gui/netctl-gui-security-notes.html +for more details. .SH AUTHOR @PROJECT_AUTHOR@ <\fI@PROJECT_CONTACT@\fR> .SH LICENSE diff --git a/sources/gui/src/about.ui b/sources/gui/src/about.ui index fe73b21..f1f0b87 100644 --- a/sources/gui/src/about.ui +++ b/sources/gui/src/about.ui @@ -6,80 +6,121 @@ 0 0 - 388 - 288 + 452 + 361 - - - - - - - - Qt::AlignJustify|Qt::AlignVCenter - - - Qt::TextBrowserInteraction - - - - - - - - - - Qt::AlignCenter - - - Qt::TextBrowserInteraction - - - - - - - - - - Qt::AlignCenter - - - Qt::TextBrowserInteraction - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::RichText - - + + + + true - - Qt::TextBrowserInteraction - + + + + 0 + 0 + 436 + 324 + + + + + + + + + + Qt::AlignCenter + + + true + + + Qt::TextBrowserInteraction + + + + + + + + + + Qt::AlignCenter + + + true + + + Qt::TextBrowserInteraction + + + + + + + + + + Qt::AlignJustify|Qt::AlignVCenter + + + true + + + Qt::TextBrowserInteraction + + + + + + + + + + true + + + + + + + + + + Qt::RichText + + + true + + + true + + + Qt::TextBrowserInteraction + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + - + @@ -90,6 +131,9 @@ Qt::AlignCenter + + true + true @@ -98,13 +142,6 @@ - - - - - - - diff --git a/sources/gui/src/aboutwindow.cpp b/sources/gui/src/aboutwindow.cpp index 73fcac0..4fb3e96 100644 --- a/sources/gui/src/aboutwindow.cpp +++ b/sources/gui/src/aboutwindow.cpp @@ -79,13 +79,10 @@ void AboutWindow::createUi() QWidget *aboutWidget = new QWidget(); uiAbout = new Ui::About; uiAbout->setupUi(aboutWidget); - ui->verticalLayout->addWidget(aboutWidget); + ui->verticalLayout->insertWidget(0, aboutWidget); createText(); - QDialogButtonBox *buttonBox = new QDialogButtonBox; - buttonBox->addButton(QDialogButtonBox::Close); - ui->verticalLayout->addWidget(buttonBox); - connect(buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked(bool)), this, SLOT(close())); + connect(ui->buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked(bool)), this, SLOT(close())); } diff --git a/sources/gui/src/aboutwindow.ui b/sources/gui/src/aboutwindow.ui index bc66642..53299d1 100644 --- a/sources/gui/src/aboutwindow.ui +++ b/sources/gui/src/aboutwindow.ui @@ -6,15 +6,23 @@ 0 0 - 380 - 307 + 516 + 431 About - + + + + + QDialogButtonBox::Close + + + + diff --git a/sources/gui/src/mainactions.cpp b/sources/gui/src/mainactions.cpp index d715ee8..0bd2154 100644 --- a/sources/gui/src/mainactions.cpp +++ b/sources/gui/src/mainactions.cpp @@ -117,6 +117,39 @@ void MainWindow::showSettingsWindow() } +void MainWindow::showApi() +{ + if (debug) qDebug() << "[MainWindow]" << "[showApi]"; + + if (QDesktopServices::openUrl(QUrl(QString(DOCS_PATH) + QString("netctl-gui-dbus-api.html")))) + ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); + else + ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); +} + + +void MainWindow::showLibrary() +{ + if (debug) qDebug() << "[MainWindow]" << "[showLibrary]"; + + if (QDesktopServices::openUrl(QUrl(QString(DOCS_PATH) + QString("html/index.html")))) + ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); + else + ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); +} + + +void MainWindow::showSecurityNotes() +{ + if (debug) qDebug() << "[MainWindow]" << "[showSecurityNotes]"; + + if (QDesktopServices::openUrl(QUrl(QString(DOCS_PATH) + QString("netctl-gui-security-notes.html")))) + ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); + else + ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); +} + + bool MainWindow::forceStartHelper() { if (debug) qDebug() << "[MainWindow]" << "[forceStartHelper]"; diff --git a/sources/gui/src/mainwindow.cpp b/sources/gui/src/mainwindow.cpp index d0eced9..fc4323a 100644 --- a/sources/gui/src/mainwindow.cpp +++ b/sources/gui/src/mainwindow.cpp @@ -243,9 +243,12 @@ void MainWindow::createActions() connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int))); connect(ui->actionAbout, SIGNAL(triggered(bool)), this, SLOT(showAboutWindow())); + connect(ui->actionApi, SIGNAL(triggered(bool)), this, SLOT(showApi())); + connect(ui->actionLibrary, SIGNAL(triggered(bool)), this, SLOT(showLibrary())); connect(ui->actionNetctlAuto, SIGNAL(triggered(bool)), this, SLOT(showNetctlAutoWindow())); - connect(ui->actionSettings, SIGNAL(triggered(bool)), this, SLOT(showSettingsWindow())); connect(ui->actionReport, SIGNAL(triggered(bool)), this, SLOT(reportABug())); + connect(ui->actionSecurity, SIGNAL(triggered(bool)), this, SLOT(showSecurityNotes())); + connect(ui->actionSettings, SIGNAL(triggered(bool)), this, SLOT(showSettingsWindow())); connect(ui->actionQuit, SIGNAL(triggered(bool)), this, SLOT(closeMainWindow())); // actions menu @@ -391,17 +394,6 @@ void MainWindow::deleteObjects() } -void MainWindow::setIconsToTabs() -{ - if (debug) qDebug() << "[MainWindow]" << "[setIconsToTabs]"; - - // tab widget - ui->tabWidget->setTabIcon(0, QIcon(":icon")); - ui->tabWidget->setTabIcon(1, QIcon::fromTheme("document-new")); - ui->tabWidget->setTabIcon(2, QIcon(":wifi")); -} - - QMap MainWindow::parseOptions(const QString options) { if (debug) qDebug() << "[MainWindow]" << "[parseOptions]"; @@ -464,7 +456,6 @@ void MainWindow::updateConfiguration(const QMap args) // update ui setTab(args[QString("tab")].toInt() - 1); createActions(); - setIconsToTabs(); // tray if (isDaemon) diff --git a/sources/gui/src/mainwindow.h b/sources/gui/src/mainwindow.h index 488d3c2..8469259 100644 --- a/sources/gui/src/mainwindow.h +++ b/sources/gui/src/mainwindow.h @@ -71,6 +71,10 @@ public slots: void showMainWindow(); void showNetctlAutoWindow(); void showSettingsWindow(); + // open docs + void showApi(); + void showLibrary(); + void showSecurityNotes(); // helper bool forceStartHelper(); bool forceStopHelper(); @@ -146,7 +150,6 @@ private: void createObjects(); void deleteObjects(); void keyPressEvent(QKeyEvent *pressedKey); - void setIconsToTabs(); QString configPath; bool debug = false; bool hiddenNetwork; diff --git a/sources/gui/src/mainwindow.ui b/sources/gui/src/mainwindow.ui index fa1f013..d496f41 100644 --- a/sources/gui/src/mainwindow.ui +++ b/sources/gui/src/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 475 - 503 + 471 + 499 @@ -21,6 +21,10 @@ 0 + + + :/icon.png:/icon.png + Connect to profile @@ -105,7 +109,9 @@ Refresh - + + + Ctrl+R @@ -137,7 +143,9 @@ Restart - + + + true @@ -153,7 +161,9 @@ Start - + + + true @@ -171,6 +181,9 @@ 0 + + + Create a new profile @@ -212,8 +225,8 @@ 0 0 - 443 - 345 + 439 + 340 @@ -234,7 +247,9 @@ Clear - + + + @@ -257,7 +272,9 @@ Save - + + + @@ -266,6 +283,10 @@ + + + :/wifi.png:/wifi.png + Connect to Wi-Fi @@ -342,7 +363,9 @@ Refresh - + + + Ctrl+R @@ -374,7 +397,9 @@ Start - + + + true @@ -394,7 +419,7 @@ 0 0 - 475 + 471 22 @@ -429,6 +454,10 @@ Help + + + + @@ -608,6 +637,26 @@ Report a bug + + + DBus API reference + + + + + + + + + + Security notes + + + + + Library documentation + + tabWidget @@ -622,6 +671,8 @@ pushButton_wifiRefresh pushButton_wifiStart - + + + diff --git a/sources/gui/src/messages.cpp b/sources/gui/src/messages.cpp index 451c72d..f34970d 100644 --- a/sources/gui/src/messages.cpp +++ b/sources/gui/src/messages.cpp @@ -136,6 +136,12 @@ QString infoMessage() infoMessage += QString("\tDBUS_HELPER_INTERFACE=%1\n").arg(QString(DBUS_HELPER_INTERFACE)); infoMessage += QString("\tDBUS_CTRL_PATH=%1\n").arg(QString(DBUS_CTRL_PATH)); infoMessage += QString("\tDBUS_LIB_PATH=%1\n").arg(QString(DBUS_LIB_PATH)); + // docs path + infoMessage += QString("%1:\n").arg(QCoreApplication::translate("NetctlHelper", "Documentation")); + infoMessage += QString("\tDOCS_PATH=%1\n").arg(QString(DOCS_PATH)); + QStringList docs = QDir(QString(DOCS_PATH)).entryList(QDir::NoDotAndDotDot); + for (int i=0; ishowApi(); +} + + bool NetctlGuiAdaptor::Close() { mainWindow->closeMainWindow(); @@ -45,6 +51,12 @@ QString NetctlGuiAdaptor::Information() } +void NetctlGuiAdaptor::LibraryDocs() +{ + return mainWindow->showLibrary(); +} + + bool NetctlGuiAdaptor::Restore() { mainWindow->show(); @@ -52,6 +64,12 @@ bool NetctlGuiAdaptor::Restore() } +void NetctlGuiAdaptor::SecurityDocs() +{ + return mainWindow->showSecurityNotes(); +} + + QStringList NetctlGuiAdaptor::Settings() { return mainWindow->printSettings(); diff --git a/sources/gui/src/netctlguiadaptor.h b/sources/gui/src/netctlguiadaptor.h index ae98426..828fe0a 100644 --- a/sources/gui/src/netctlguiadaptor.h +++ b/sources/gui/src/netctlguiadaptor.h @@ -34,9 +34,12 @@ public: ~NetctlGuiAdaptor(); public slots: + void ApiDocs(); bool Close(); QString Information(); + void LibraryDocs(); bool Restore(); + void SecurityDocs(); QStringList Settings(); bool ShowAbout(); bool ShowMain(); diff --git a/sources/gui/src/settingswindow.ui b/sources/gui/src/settingswindow.ui index 2194965..788910e 100644 --- a/sources/gui/src/settingswindow.ui +++ b/sources/gui/src/settingswindow.ui @@ -6,8 +6,8 @@ 0 0 - 654 - 315 + 686 + 403 @@ -136,8 +136,8 @@ 0 0 - 438 - 254 + 470 + 342 @@ -211,8 +211,8 @@ 0 0 - 438 - 254 + 470 + 342 @@ -352,6 +352,12 @@ Qt::Vertical + + + 20 + 40 + + @@ -829,8 +835,8 @@ 0 0 - 438 - 254 + 436 + 252 diff --git a/sources/helper/netctlgui-helper.1 b/sources/helper/netctlgui-helper.1 index 4fda74a..4ede1d8 100644 --- a/sources/helper/netctlgui-helper.1 +++ b/sources/helper/netctlgui-helper.1 @@ -56,9 +56,13 @@ and edit copied file to avoid upgrade problems. .SH SEE ALSO .BR netctl-gui (1) .SH STANDARDS -Some text will be here +See +.B @CMAKE_INSTALL_PREFIX@/share/doc/netctl-gui/netctl-gui-dbus-api.html +for more details. .SH SECURITY CONSIDERATIONS -Some text will be here. +See +.B @CMAKE_INSTALL_PREFIX@/share/doc/netctl-gui/netctl-gui-security-notes.html +for more details. .SH AUTHOR @PROJECT_AUTHOR@ <\fI@PROJECT_CONTACT@\fR> .SH LICENSE diff --git a/sources/helper/src/controladaptor.cpp b/sources/helper/src/controladaptor.cpp index 3239e58..e0c6517 100644 --- a/sources/helper/src/controladaptor.cpp +++ b/sources/helper/src/controladaptor.cpp @@ -18,6 +18,7 @@ #include "controladaptor.h" #include "netctlhelper.h" +#include "version.h" ControlAdaptor::ControlAdaptor(NetctlHelper *parent, const QMap configuration) @@ -46,6 +47,12 @@ bool ControlAdaptor::Active() } +QString ControlAdaptor::ApiDocs() +{ + return (QString(DOCS_PATH) + QString("netctl-gui-dbus-api.html")); +} + + bool ControlAdaptor::Close() { helper->quitHelper(); @@ -53,6 +60,18 @@ bool ControlAdaptor::Close() } +QString ControlAdaptor::LibraryDocs() +{ + return (QString(DOCS_PATH) + QString("html/index.html")); +} + + +QString ControlAdaptor::SecurityDocs() +{ + return (QString(DOCS_PATH) + QString("netctl-gui-security-notes.html")); +} + + QStringList ControlAdaptor::Settings() { return helper->printSettings(); diff --git a/sources/helper/src/controladaptor.h b/sources/helper/src/controladaptor.h index 688a078..40f6d97 100644 --- a/sources/helper/src/controladaptor.h +++ b/sources/helper/src/controladaptor.h @@ -38,7 +38,10 @@ public: public slots: // helper bool Active(); + QString ApiDocs(); bool Close(); + QString LibraryDocs(); + QString SecurityDocs(); QStringList Settings(); bool Update(); // netctlCommand diff --git a/sources/helper/src/messages.cpp b/sources/helper/src/messages.cpp index 48c6622..aa5427a 100644 --- a/sources/helper/src/messages.cpp +++ b/sources/helper/src/messages.cpp @@ -95,6 +95,12 @@ QString infoMessage() infoMessage += QString("\tDBUS_HELPER_INTERFACE=%1\n").arg(QString(DBUS_HELPER_INTERFACE)); infoMessage += QString("\tDBUS_CTRL_PATH=%1\n").arg(QString(DBUS_CTRL_PATH)); infoMessage += QString("\tDBUS_LIB_PATH=%1\n").arg(QString(DBUS_LIB_PATH)); + // docs path + infoMessage += QString("%1:\n").arg(QCoreApplication::translate("NetctlHelper", "Documentation")); + infoMessage += QString("\tDOCS_PATH=%1\n").arg(QString(DOCS_PATH)); + QStringList docs = QDir(QString(DOCS_PATH)).entryList(QDir::NoDotAndDotDot); + for (int i=0; i