summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-11-10 01:17:58 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-11-10 01:17:58 -0600
commit7373f047c26807b3834f17f3ed97bab85b05db91 (patch)
treecf7a721c001ba35670d1fab0764e182e8abbf469 /ui
parent4dfbc5e1d78e8adb74e4af068cf3b89b3aee26b8 (diff)
downloadhorizon-7373f047c26807b3834f17f3ed97bab85b05db91.tar.gz
horizon-7373f047c26807b3834f17f3ed97bab85b05db91.tar.bz2
horizon-7373f047c26807b3834f17f3ed97bab85b05db91.tar.xz
horizon-7373f047c26807b3834f17f3ed97bab85b05db91.zip
Qt UI: Initial work on Networking page
Diffstat (limited to 'ui')
-rw-r--r--ui/qt5/CMakeLists.txt2
-rw-r--r--ui/qt5/horizonwizard.cc80
-rw-r--r--ui/qt5/horizonwizard.hh11
-rw-r--r--ui/qt5/networkingpage.cc59
-rw-r--r--ui/qt5/networkingpage.hh1
5 files changed, 130 insertions, 23 deletions
diff --git a/ui/qt5/CMakeLists.txt b/ui/qt5/CMakeLists.txt
index 0dd441b..647c833 100644
--- a/ui/qt5/CMakeLists.txt
+++ b/ui/qt5/CMakeLists.txt
@@ -20,6 +20,6 @@ install(TARGETS horizon-qt5 DESTINATION bin)
IF(INSTALL)
pkg_check_modules(XKBFile REQUIRED xkbfile)
pkg_check_modules(LIBX11 REQUIRED x11)
- target_link_libraries(horizon-qt5 ${LIBX11_LIBRARIES} ${XKBFile_LIBRARIES})
+ target_link_libraries(horizon-qt5 ${LIBUDEV_LIBRARIES} ${LIBX11_LIBRARIES} ${XKBFile_LIBRARIES})
# add_executable(horizon-run-qt5 ${RUN_QT_SOURCES})
ENDIF(INSTALL)
diff --git a/ui/qt5/horizonwizard.cc b/ui/qt5/horizonwizard.cc
index f3a97f9..dc80dea 100644
--- a/ui/qt5/horizonwizard.cc
+++ b/ui/qt5/horizonwizard.cc
@@ -19,6 +19,10 @@
#include <map>
#include <string>
+#ifdef HAS_INSTALL_ENV
+# include <libudev.h>
+#endif /* HAS_INSTALL_ENV */
+
#include "intropage.hh"
#include "inputpage.hh"
#include "networkingpage.hh"
@@ -54,6 +58,78 @@ static std::map<int, std::string> help_id_map = {
#endif /* !HAS_INSTALL_ENV */
};
+
+#ifdef HAS_INSTALL_ENV
+std::map<std::string, HorizonWizard::NetworkInterfaceType> probe_ifaces(void) {
+ struct udev *udev;
+ struct udev_enumerate *if_list;
+ struct udev_list_entry *first, *candidate;
+ struct udev_device *device = nullptr;
+
+ std::map<std::string, HorizonWizard::NetworkInterfaceType> ifaces;
+
+ udev = udev_new();
+ if(udev == nullptr) {
+ qDebug() << "Can't connect to UDev.";
+ return ifaces;
+ }
+
+ if_list = udev_enumerate_new(udev);
+ if(if_list == nullptr) {
+ qDebug() << "Uh oh. UDev is unhappy.";
+ udev_unref(udev);
+ return ifaces;
+ }
+
+ udev_enumerate_add_match_subsystem(if_list, "net");
+ udev_enumerate_scan_devices(if_list);
+ first = udev_enumerate_get_list_entry(if_list);
+ udev_list_entry_foreach(candidate, first) {
+ const char *syspath = udev_list_entry_get_name(candidate);
+ const char *devtype, *cifname;
+
+ if(device != nullptr) udev_device_unref(device);
+ device = udev_device_new_from_syspath(udev, syspath);
+ if(device == nullptr) continue;
+ devtype = udev_device_get_devtype(device);
+ if(devtype == nullptr) {
+ devtype = udev_device_get_sysattr_value(device, "type");
+ if(devtype == nullptr) {
+ qDebug() << syspath << " skipped; no device type.";
+ continue;
+ }
+ }
+
+ cifname = udev_device_get_property_value(device, "INTERFACE");
+ if(cifname == nullptr) {
+ qDebug() << syspath << " has no interface name.";
+ continue;
+ }
+
+ std::string ifname(cifname);
+ if(strstr(devtype, "wlan")) {
+ ifaces.insert({ifname, HorizonWizard::Wireless});
+ } else if(strstr(devtype, "bond")) {
+ ifaces.insert({ifname, HorizonWizard::Bonded});
+ } else if(strstr(syspath, "/virtual/")) {
+ /* Skip lo, tuntap, etc */
+ continue;
+ } else if(strstr(devtype, "1")) {
+ ifaces.insert({ifname, HorizonWizard::Ethernet});
+ } else {
+ ifaces.insert({ifname, HorizonWizard::Unknown});
+ }
+ }
+
+ if(device != nullptr) udev_device_unref(device);
+
+ udev_enumerate_unref(if_list);
+ udev_unref(udev);
+ return ifaces;
+}
+#endif /* HAS_INSTALL_ENV */
+
+
HorizonWizard::HorizonWizard(QWidget *parent) : QWizard(parent) {
setWindowTitle(tr("Adélie Linux System Installation"));
@@ -136,4 +212,8 @@ HorizonWizard::HorizonWizard(QWidget *parent) : QWizard(parent) {
connect(f8, &QShortcut::activated,
button(NextButton), &QAbstractButton::click);
f8->setWhatsThis(tr("Goes forward to the next page."));
+
+#ifdef HAS_INSTALL_ENV
+ interfaces = probe_ifaces();
+#endif /* HAS_INSTALL_ENV */
}
diff --git a/ui/qt5/horizonwizard.hh b/ui/qt5/horizonwizard.hh
index e4e8897..3f3454b 100644
--- a/ui/qt5/horizonwizard.hh
+++ b/ui/qt5/horizonwizard.hh
@@ -15,6 +15,7 @@
#include <QShortcut>
#include <QWizard>
+#include <map>
#include <string>
class HorizonWizard : public QWizard {
@@ -49,8 +50,18 @@ public:
#endif /* !HAS_INSTALL_ENV */
};
+ enum NetworkInterfaceType {
+ Ethernet,
+ Wireless,
+ Bonded,
+ Unknown
+ };
+
HorizonWizard(QWidget *parent = nullptr);
QShortcut *f1, *f3, *f5, *f8;
+
+ std::map<std::string, NetworkInterfaceType> interfaces;
+ std::string chosen_auto_iface;
};
#endif /* !HORIZONWIZARD_HH */
diff --git a/ui/qt5/networkingpage.cc b/ui/qt5/networkingpage.cc
index eb8d883..8379877 100644
--- a/ui/qt5/networkingpage.cc
+++ b/ui/qt5/networkingpage.cc
@@ -17,31 +17,40 @@
#include <QVBoxLayout>
NetworkingPage::NetworkingPage(QWidget *parent) : HorizonWizardPage(parent) {
- QLabel *descLabel;
- QVBoxLayout *layout;
-
loadWatermark("network");
setTitle(tr("Networking Setup"));
+}
- descLabel = new QLabel(tr(
- "If you have a typical network connection where your computer is "
- "directly connected to the Internet via Ethernet or Wi-Fi using a "
- "modem or router, choose Automatic. If you need to set a static IP "
- "address, or you use a VPN or proxy server, choose Manual.\n\n"
+void NetworkingPage::initializePage() {
+ QLabel *descLabel;
+ QVBoxLayout *layout;
- "If you don't want to configure networking or you don't want to use "
- "this computer on the Internet, choose Skip."));
+ if(horizonWizard()->interfaces.empty()) {
+ descLabel = new QLabel(tr(
+ "No supported network interfaces have been detected on your computer.\n\n"
+ "You will not be able to connect to a network nor the Internet.\n\n"
+ "If you have a network interface attached to your computer, it may not be supported by Adélie Linux. Please contact our community at https://help.adelielinux.org/ for help."));
+ } else {
+ descLabel = new QLabel(tr(
+ "If your computer is directly connected to the Internet via Ethernet or Wi-Fi using a modem or router, choose Automatic.\n\n"
+ "If you need to set a static IP address, or you use a VPN or proxy server, choose Manual.\n\n"
+ "If you don't want to configure networking or you don't want to use this computer on the Internet, choose Skip."));
+ }
descLabel->setWordWrap(true);
- simple = new QRadioButton(tr("&Automatic - my computer connects to the Internet directly\n"
- "or via a modem/router."));
- advanced = new QRadioButton(tr("&Manual - my computer connects to an enterprise network,\n"
- "or I use a static IP address, VPN, or 802.1X."));
+ if(!horizonWizard()->interfaces.empty()) {
+ simple = new QRadioButton(tr("&Automatic - my computer connects to the Internet directly\n"
+ "or via a modem/router."));
+ advanced = new QRadioButton(tr("&Manual - my computer connects to an enterprise network,\n"
+ "or I use a static IP address, VPN, or 802.1X."));
+ }
skip = new QRadioButton(tr("&Skip - I don't want to connect to a network or the Internet."));
radioGroup = new QButtonGroup(this);
- radioGroup->addButton(simple);
- radioGroup->addButton(advanced);
+ if(!horizonWizard()->interfaces.empty()) {
+ radioGroup->addButton(simple);
+ radioGroup->addButton(advanced);
+ }
radioGroup->addButton(skip);
QObject::connect(radioGroup, static_cast<void (QButtonGroup:: *)(QAbstractButton *)>(&QButtonGroup::buttonClicked),
@@ -52,8 +61,10 @@ NetworkingPage::NetworkingPage(QWidget *parent) : HorizonWizardPage(parent) {
layout = new QVBoxLayout;
layout->addWidget(descLabel);
layout->addSpacing(50);
- layout->addWidget(simple);
- layout->addWidget(advanced);
+ if(!horizonWizard()->interfaces.empty()) {
+ layout->addWidget(simple);
+ layout->addWidget(advanced);
+ }
layout->addWidget(skip);
setLayout(layout);
}
@@ -64,11 +75,14 @@ bool NetworkingPage::isComplete() const {
int NetworkingPage::nextId() const {
if(radioGroup->checkedButton() == simple) {
- if(false) {
- return HorizonWizard::Page_Network_Wireless;
+ if(horizonWizard()->interfaces.size() > 1) {
+ return HorizonWizard::Page_Network_Iface;
} else {
- if(false) {
- return HorizonWizard::Page_Network_Iface;
+ horizonWizard()->chosen_auto_iface =
+ (horizonWizard()->interfaces.begin())->first;
+ if((horizonWizard()->interfaces.begin())->second
+ == HorizonWizard::Wireless) {
+ return HorizonWizard::Page_Network_Wireless;
} else {
return HorizonWizard::Page_Network_DHCP;
}
@@ -76,6 +90,7 @@ int NetworkingPage::nextId() const {
} else if(radioGroup->checkedButton() == advanced) {
return HorizonWizard::Page_Network_Manual;
} else {
+ /* REQ: UI.Network.AddressType.Skip */
return HorizonWizard::Page_DateTime;
}
}
diff --git a/ui/qt5/networkingpage.hh b/ui/qt5/networkingpage.hh
index 5914af2..a5f08e5 100644
--- a/ui/qt5/networkingpage.hh
+++ b/ui/qt5/networkingpage.hh
@@ -22,6 +22,7 @@ class NetworkingPage : public HorizonWizardPage {
public:
NetworkingPage(QWidget *parent = nullptr);
+ void initializePage() override;
bool isComplete() const;
int nextId() const;
private: