|
|
@ -7,7 +7,7 @@ NetworkCreator::NetworkCreator(QWidget *parent) :
|
|
|
|
ui(new Ui::NetworkCreator)
|
|
|
|
ui(new Ui::NetworkCreator)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
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->okButton, &QPushButton::clicked, this, &NetworkCreator::onOkButtonClicked);
|
|
|
|
connect(ui->cancelButton, &QPushButton::clicked, this, &NetworkCreator::onCancelButtonClicked);
|
|
|
|
connect(ui->cancelButton, &QPushButton::clicked, this, &NetworkCreator::onCancelButtonClicked);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -21,6 +21,7 @@ void NetworkCreator::onOkButtonClicked()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
NetworkManager::ConnectionSettings::Ptr connSettings;
|
|
|
|
NetworkManager::ConnectionSettings::Ptr connSettings;
|
|
|
|
NetworkManager::WiredSetting::Ptr wiredSetting;
|
|
|
|
NetworkManager::WiredSetting::Ptr wiredSetting;
|
|
|
|
|
|
|
|
NetworkManager::WirelessSetting::Ptr wirelessSetting;
|
|
|
|
|
|
|
|
|
|
|
|
switch(ui->connectionTypeComboBox->currentIndex()) {
|
|
|
|
switch(ui->connectionTypeComboBox->currentIndex()) {
|
|
|
|
case 0: // Ethernet
|
|
|
|
case 0: // Ethernet
|
|
|
@ -28,15 +29,25 @@ void NetworkCreator::onOkButtonClicked()
|
|
|
|
wiredSetting = connSettings->setting(NetworkManager::Setting::Wired).dynamicCast<NetworkManager::WiredSetting>();
|
|
|
|
wiredSetting = connSettings->setting(NetworkManager::Setting::Wired).dynamicCast<NetworkManager::WiredSetting>();
|
|
|
|
wiredSetting->setAutoNegotiate(true);
|
|
|
|
wiredSetting->setAutoNegotiate(true);
|
|
|
|
break;
|
|
|
|
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->setId(ui->connectionNameLineEdit->text());
|
|
|
|
connSettings->setUuid(NetworkManager::ConnectionSettings::createNewUuid());
|
|
|
|
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);
|
|
|
|
auto watcher = new QDBusPendingCallWatcher(reply);
|
|
|
|
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &NetworkCreator::createReplyFinished);
|
|
|
|
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &NetworkCreator::createReplyFinished);
|
|
|
|
connSettings.clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void NetworkCreator::onCancelButtonClicked()
|
|
|
|
void NetworkCreator::onCancelButtonClicked()
|
|
|
|