diff --git a/sources/gui/src/mainwindow.cpp b/sources/gui/src/mainwindow.cpp index 6172367..ee45217 100644 --- a/sources/gui/src/mainwindow.cpp +++ b/sources/gui/src/mainwindow.cpp @@ -19,6 +19,7 @@ #include "ui_mainwindow.h" #include "netctlinteract.h" +#include "wpasupinteract.h" #include @@ -37,8 +38,11 @@ MainWindow::MainWindow(QWidget *parent) netctlPath = QString("/usr/bin/netctl"); profileDir = QString("/etc/netctl"); sudoPath = QString("/usr/bin/kdesu -c"); + wpaCliPath = QString("/usr/bin/wpa_cli"); + ifaceDir = QString("/sys/class/net/"); netctlCommand = new Netctl(this, netctlPath, profileDir, sudoPath); + wpaCliCommand = new WpaSup(this, wpaCliPath, ifaceDir); createActions(); updateMainTab(); @@ -71,6 +75,8 @@ void MainWindow::updateTabs(const int tab) { if (tab == 0) updateMainTab(); + else if (tab == 2) + updateWifiTab(); } @@ -98,6 +104,12 @@ void MainWindow::updateMainTab() } +void MainWindow::updateWifiTab() +{ + +} + + // main tab slots void MainWindow::mainTabEnableProfile() { diff --git a/sources/gui/src/mainwindow.h b/sources/gui/src/mainwindow.h index 66eebc4..33590a2 100644 --- a/sources/gui/src/mainwindow.h +++ b/sources/gui/src/mainwindow.h @@ -25,6 +25,7 @@ class Netctl; +class WpaSup; namespace Ui { class MainWindow; @@ -41,6 +42,7 @@ public: private slots: void updateTabs(const int tab); void updateMainTab(); + void updateWifiTab(); // main tab slots void mainTabEnableProfile(); void mainTabRestartProfile(); @@ -49,12 +51,16 @@ private slots: private: Netctl *netctlCommand; + WpaSup *wpaCliCommand; Ui::MainWindow *ui; void createActions(); // configuration QString netctlPath; QString profileDir; QString sudoPath; + QString wpaCliPath; + QString ifaceDir; }; + #endif /* MAINWINDOW_H */ diff --git a/sources/gui/src/mainwindow.ui b/sources/gui/src/mainwindow.ui index 367fa88..f46a8c5 100644 --- a/sources/gui/src/mainwindow.ui +++ b/sources/gui/src/mainwindow.ui @@ -17,6 +17,9 @@ + + 0 + Connect to profile @@ -124,6 +127,91 @@ Connect to Wi-Fi + + + + + Please install 'wpa_supplicant' before using + + + + + + + QAbstractItemView::NoEditTriggers + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + false + + + + Name + + + + + Status + + + + + Signal + + + + + Security + + + + + + + + + + Refresh + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Start + + + true + + + + + + diff --git a/sources/gui/src/netctlinteract.cpp b/sources/gui/src/netctlinteract.cpp index 0538f82..2c943a4 100644 --- a/sources/gui/src/netctlinteract.cpp +++ b/sources/gui/src/netctlinteract.cpp @@ -41,6 +41,12 @@ Netctl::~Netctl() // general information +QStringList Netctl::getProfileList() +{ + return profileDirectory->entryList(QDir::Files); +} + + QStringList Netctl::getProfileDescriptions(QStringList profileList) { QStringList descriptions; @@ -71,12 +77,6 @@ QStringList Netctl::getProfileDescriptions(QStringList profileList) } -QStringList Netctl::getProfileList() -{ - return profileDirectory->entryList(QDir::Files); -} - - QStringList Netctl::getProfileStatuses(QStringList profileList) { QStringList statuses; diff --git a/sources/gui/src/netctlinteract.h b/sources/gui/src/netctlinteract.h index 1059e43..47b8ca0 100644 --- a/sources/gui/src/netctlinteract.h +++ b/sources/gui/src/netctlinteract.h @@ -32,8 +32,8 @@ public: Netctl(MainWindow *wid, QString netctlPath, QString profileDir, QString sudoPath); ~Netctl(); // general information - QStringList getProfileDescriptions(QStringList profileList); QStringList getProfileList(); + QStringList getProfileDescriptions(QStringList profileList); QStringList getProfileStatuses(QStringList profileList); bool isProfileActive(QString profile); bool isProfileEnabled(QString profile); @@ -49,4 +49,5 @@ private: QString sudoCommand; }; + #endif /* NETCTLINTERACT_H */ diff --git a/sources/gui/src/wpasupinteract.cpp b/sources/gui/src/wpasupinteract.cpp new file mode 100644 index 0000000..8cfcfc9 --- /dev/null +++ b/sources/gui/src/wpasupinteract.cpp @@ -0,0 +1,52 @@ +/*************************************************************************** + * This file is part of netctl-plasmoid * + * * + * netctl-plasmoid is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * netctl-plasmoid is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "wpasupinteract.h" + +#include "mainwindow.h" +#include + + +WpaSup::WpaSup(MainWindow *wid, QString wpaCliPath, QString ifaceDir) + : parent(wid), + wpaCliCommand(wpaCliPath), + ifaceDirectory(new QDir(ifaceDir)) +{ + +} + + +WpaSup::~WpaSup() +{ + delete ifaceDirectory; +} + + +// general information +QStringList WpaSup::getInterfaceList() +{ + QStringList interfaces; + QStringList allInterfaces; + + allInterfaces = ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot); + for (int i=0; ipath() + QDir::separator() + allInterfaces[i] + + QDir::separator() + QString("wireless")).exists()) + interfaces.append(allInterfaces[i]); + + return interfaces; +} diff --git a/sources/gui/src/wpasupinteract.h b/sources/gui/src/wpasupinteract.h new file mode 100644 index 0000000..b285285 --- /dev/null +++ b/sources/gui/src/wpasupinteract.h @@ -0,0 +1,44 @@ +/*************************************************************************** + * This file is part of netctl-plasmoid * + * * + * netctl-plasmoid is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * netctl-plasmoid is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#ifndef WPASUPINTERACT_H +#define WPASUPINTERACT_H + +#include +#include + + +class MainWindow; + +class WpaSup : public QWidget +{ + Q_OBJECT + +public: + WpaSup(MainWindow *wid, QString wpaCliPath, QString ifaceDir); + ~WpaSup(); + // general information + QStringList getInterfaceList(); + +private: + MainWindow *parent; + QString wpaCliCommand; + QDir *ifaceDirectory; +}; + + +#endif /* WPASUPINTERACT_H */