summaryrefslogtreecommitdiff
path: root/ui/qt5
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-12-15 16:38:55 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-12-15 16:38:55 -0600
commit40dd47f07dbbf1859331274d8724d00c09faeaf6 (patch)
tree717d4fabadb807aaa0a2dd9bb3f3155c5058bbcb /ui/qt5
parent558414ac570b0b95cdbea7179ba973bd2857eb93 (diff)
downloadhorizon-40dd47f07dbbf1859331274d8724d00c09faeaf6.tar.gz
horizon-40dd47f07dbbf1859331274d8724d00c09faeaf6.tar.bz2
horizon-40dd47f07dbbf1859331274d8724d00c09faeaf6.tar.xz
horizon-40dd47f07dbbf1859331274d8724d00c09faeaf6.zip
Qt UI: More Wi-Fi stuff
Diffstat (limited to 'ui/qt5')
-rw-r--r--ui/qt5/netsimplewifipage.cc59
-rw-r--r--ui/qt5/netsimplewifipage.hh4
2 files changed, 58 insertions, 5 deletions
diff --git a/ui/qt5/netsimplewifipage.cc b/ui/qt5/netsimplewifipage.cc
index 1337442..c3c22c9 100644
--- a/ui/qt5/netsimplewifipage.cc
+++ b/ui/qt5/netsimplewifipage.cc
@@ -18,7 +18,9 @@
#include <QVBoxLayout>
#ifdef HAS_INSTALL_ENV
+# include <QApplication>
# include <QMessageBox>
+# include <QProgressBar>
int scanResults(wpactrl_t *control, char const *s, size_t len, void *page, tain_t *) {
NetworkSimpleWirelessPage *our_page = reinterpret_cast<NetworkSimpleWirelessPage *>(page);
return our_page->processScan(control, s, len);
@@ -48,7 +50,11 @@ NetworkSimpleWirelessPage::NetworkSimpleWirelessPage(QWidget *parent)
#ifdef HAS_INSTALL_ENV
exchange_item.filter = "CTRL-EVENT-SCAN-RESULTS";
exchange_item.cb = &scanResults;
+ wpactrl_filter_add(&control, "CTRL-EVENT-ASSOC-REJECT");
+ wpactrl_filter_add(&control, "CTRL-EVENT-AUTH-REJECT");
+ wpactrl_filter_add(&control, "CTRL-EVENT-CONNECTED");
notify = nullptr;
+ connNotify = nullptr;
#endif /* HAS_INSTALL_ENV */
passphrase = new QLineEdit(this);
@@ -306,24 +312,69 @@ bool NetworkSimpleWirelessPage::validatePage() {
return false;
}
- const char *ssid, *pass;
+ if(dialog != nullptr) dialog->deleteLater();
+ dialog = new QProgressDialog(this);
+ dialog->setCancelButton(nullptr);
+
+ QProgressBar *bar = new QProgressBar;
+ bar->setRange(0, 0);
+ bar->setFixedSize(QSize(150, 24));
+ dialog->setBar(bar);
+ dialog->setLabelText(tr("Connecting..."));
+ dialog->setMinimumDuration(1);
+
+ dialog->show();
+ QApplication::processEvents(QEventLoop::AllEvents, 1000);
+
+ if(connNotify != nullptr) {
+ connNotify->setEnabled(false);
+ connNotify->deleteLater();
+ connNotify = nullptr;
+ }
+
+ connNotify = new QSocketNotifier(wpactrl_fd(&control), QSocketNotifier::Read, this);
+ connect(connNotify, &QSocketNotifier::activated, [=](int) {
+ QString status;
+
+ if(wpactrl_update(&control) < 0) {
+ dialog->setLabelText(tr("Issue communicating with wireless subsystem."));
+ } else {
+ char *msg = wpactrl_msg(&control);
+ if(msg == nullptr) {
+ return;
+ }
+ wpactrl_ackmsg(&control);
+ qDebug() << msg;
+ }
+ connNotify->setEnabled(false);
+ connNotify->deleteLater();
+ connNotify = nullptr;
+ return;
+ });
+
+ char *ssid, *pass;
if(passphrase->isHidden()) {
pass = nullptr;
} else {
std::string password = ("\"" + passphrase->text().toStdString() + "\"");
- pass = password.c_str();
+ pass = strdup(password.c_str());
}
std::string network = ("\"" + items[0]->text().toStdString() + "\"");
- ssid = network.c_str();
+ ssid = strdup(network.c_str());
tain_now_g();
if(wpactrl_associate_g(&control, ssid, pass) == 0) {
+ dialog->hide();
QMessageBox::critical(this, tr("Could Not Connect"),
tr("An issue occurred connecting to the specified wireless network. "
"Ensure your passphrase is correct and try again."));
- return false;
}
+
+ dialog->setLabelText(tr("Associating..."));
+ free(ssid);
+ free(pass);
+ return false;
#endif /* HAS_INSTALL_ENV */
/* What a hack!
diff --git a/ui/qt5/netsimplewifipage.hh b/ui/qt5/netsimplewifipage.hh
index 33c716d..ab0e125 100644
--- a/ui/qt5/netsimplewifipage.hh
+++ b/ui/qt5/netsimplewifipage.hh
@@ -24,6 +24,7 @@
#include <QLabel>
#include <QLineEdit>
#include <QListWidget>
+#include <QProgressDialog>
#include <QPushButton>
class NetworkSimpleWirelessPage : public HorizonWizardPage {
@@ -50,7 +51,8 @@ private:
wpactrl_t control;
wpactrl_xchg_t exchange;
wpactrl_xchgitem_t exchange_item;
- QSocketNotifier *notify;
+ QSocketNotifier *notify, *connNotify;
+ QProgressDialog *dialog;
int processScan(wpactrl_t *, const char *, size_t);
friend int scanResults(wpactrl_t *, char const *, size_t, void *, tain_t *);