|
|
|
@ -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<NetworkManager::WiredSetting>();
|
|
|
|
|
wiredSetting->setAutoNegotiate(true);
|
|
|
|
|
break;
|
|
|
|
|
case 1: // WiFi
|
|
|
|
|
connSettings = NetworkManager::ConnectionSettings::Ptr(new NetworkManager::ConnectionSettings(NetworkManager::ConnectionSettings::Wireless));
|
|
|
|
|
wirelessSetting = connSettings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
|
|
|
|
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()
|
|
|
|
|