diff --git a/networkcreator.cpp b/networkcreator.cpp index 492591e..31918d8 100644 --- a/networkcreator.cpp +++ b/networkcreator.cpp @@ -7,7 +7,7 @@ NetworkCreator::NetworkCreator(QWidget *parent) : ui(new Ui::NetworkCreator) { ui->setupUi(this); - ui->connectionTypeComboBox->addItems(QStringList() << tr("Ethernet")); + ui->connectionTypeComboBox->addItems(QStringList() << tr("Ethernet") << tr("WiFi")); connect(ui->okButton, &QPushButton::clicked, this, &NetworkCreator::onOkButtonClicked); connect(ui->cancelButton, &QPushButton::clicked, this, &NetworkCreator::onCancelButtonClicked); } @@ -21,6 +21,7 @@ void NetworkCreator::onOkButtonClicked() { NetworkManager::ConnectionSettings::Ptr connSettings; NetworkManager::WiredSetting::Ptr wiredSetting; + NetworkManager::WirelessSetting::Ptr wirelessSetting; switch(ui->connectionTypeComboBox->currentIndex()) { case 0: // Ethernet @@ -28,15 +29,25 @@ void NetworkCreator::onOkButtonClicked() wiredSetting = connSettings->setting(NetworkManager::Setting::Wired).dynamicCast(); wiredSetting->setAutoNegotiate(true); break; + case 1: // WiFi + connSettings = NetworkManager::ConnectionSettings::Ptr(new NetworkManager::ConnectionSettings(NetworkManager::ConnectionSettings::Wireless)); + wirelessSetting = connSettings->setting(NetworkManager::Setting::Wireless).dynamicCast(); + wirelessSetting->setSsid(QString("test").toUtf8()); + break; } connSettings->setId(ui->connectionNameLineEdit->text()); connSettings->setUuid(NetworkManager::ConnectionSettings::createNewUuid()); - QDBusPendingReply<> reply = NetworkManager::addConnection(connSettings->toMap()); + NMVariantMapMap settingsMap = connSettings->toMap(); + if (!wiredSetting.isNull()) { + settingsMap.insert("802-3-ethernet", wiredSetting->toMap()); + } else if (!wirelessSetting.isNull()) { + settingsMap.insert("802-11-wireless", wirelessSetting->toMap()); + } + QDBusPendingReply<> reply = NetworkManager::addConnection(settingsMap); auto watcher = new QDBusPendingCallWatcher(reply); QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &NetworkCreator::createReplyFinished); - connSettings.clear(); } void NetworkCreator::onCancelButtonClicked() diff --git a/networkcreator.h b/networkcreator.h index 9aa47ed..b9d602a 100644 --- a/networkcreator.h +++ b/networkcreator.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include