diff --git a/kded/secretagent.h b/kded/secretagent.h --- a/kded/secretagent.h +++ b/kded/secretagent.h @@ -72,6 +72,9 @@ explicit SecretAgent(QObject* parent = nullptr); ~SecretAgent() override; +Q_SIGNALS: + void secretsError(const QString &connectionPath, const QString &message) const; + public Q_SLOTS: NMVariantMapMap GetSecrets(const NMVariantMapMap&, const QDBusObjectPath&, const QString&, const QStringList&, uint) override; void SaveSecrets(const NMVariantMapMap &connection, const QDBusObjectPath &connection_path) override; diff --git a/kded/secretagent.cpp b/kded/secretagent.cpp --- a/kded/secretagent.cpp +++ b/kded/secretagent.cpp @@ -39,6 +39,7 @@ #include #include +#include #include #include #include @@ -408,6 +409,7 @@ if (!Configuration::showPasswordDialog()) { sendError(SecretAgent::NoSecrets, "Cannot authenticate", request.message); + emit secretsError(request.connection_path.path(), i18n("Authentication to %1 failed. Wrong password?", request.connection.value("connection").value("id").toString())); return true; } else if (requestNew || (allowInteraction && !setting->needSecrets(requestNew).isEmpty()) || (allowInteraction && userRequested) || (isVpn && allowInteraction)) { m_dialog = new PasswordDialog(connectionSettings, request.flags, request.setting_name); diff --git a/kded/service.h b/kded/service.h --- a/kded/service.h +++ b/kded/service.h @@ -45,6 +45,8 @@ Q_SIGNALS: Q_SCRIPTABLE void registered(); + Q_SCRIPTABLE + void secretsError(const QString &connectionPath, const QString &message); private Q_SLOTS: void slotRegistered(const QDBusObjectPath &path); diff --git a/kded/service.cpp b/kded/service.cpp --- a/kded/service.cpp +++ b/kded/service.cpp @@ -66,6 +66,7 @@ if (!d->agent) { d->agent = new SecretAgent(this); + connect(d->agent, &SecretAgent::secretsError, this, &NetworkManagementService::secretsError); } if (!d->notification) { diff --git a/libs/handler.h b/libs/handler.h --- a/libs/handler.h +++ b/libs/handler.h @@ -104,13 +104,15 @@ private Q_SLOTS: void initKdedModule(); + void secretAgentError(const QString &a, const QString &b); void replyFinished(QDBusPendingCallWatcher *watcher); #if WITH_MODEMMANAGER_SUPPORT void unlockRequiredChanged(MMModemLock modemLock); #endif Q_SIGNALS: void wirelessScanTimerEnabled(bool enable); + void connectionActivationFailed(const QString &connectionPath, const QString &message); private: bool m_tmpWirelessEnabled; bool m_tmpWwanEnabled; diff --git a/libs/handler.cpp b/libs/handler.cpp --- a/libs/handler.cpp +++ b/libs/handler.cpp @@ -74,6 +74,12 @@ QStringLiteral("registered"), this, SLOT(initKdedModule())); + QDBusConnection::sessionBus().connect(QStringLiteral(AGENT_SERVICE), + QStringLiteral(AGENT_PATH), + QStringLiteral(AGENT_IFACE), + QStringLiteral("secretsError"), + this, SLOT(secretAgentError(QString, QString))); + // Interval (in ms) between attempts to scan for wifi networks m_wirelessScanRetryTimer.setInterval(2000); m_wirelessScanRetryTimer.setSingleShot(true); @@ -458,6 +464,13 @@ QDBusConnection::sessionBus().send(initMsg); } +void Handler::secretAgentError(const QString &connectionPath, const QString &message) +{ + // If the password was wrong, forget it + removeConnection(connectionPath); + emit connectionActivationFailed(connectionPath, message); +} + void Handler::replyFinished(QDBusPendingCallWatcher * watcher) { QDBusPendingReply<> reply = *watcher; diff --git a/mobile/wifi/package/contents/ui/NetworkListView.qml b/mobile/wifi/package/contents/ui/NetworkListView.qml --- a/mobile/wifi/package/contents/ui/NetworkListView.qml +++ b/mobile/wifi/package/contents/ui/NetworkListView.qml @@ -21,28 +21,48 @@ import QtQuick.Layouts 1.2 import QtQuick.Controls 2.2 as Controls import org.kde.plasma.networkmanagement 0.2 as PlasmaNM -import org.kde.kirigami 2.2 as Kirigami +import org.kde.kirigami 2.6 as Kirigami Kirigami.ScrollablePage { anchors.leftMargin: Kirigami.Units.largeSpacing * 2 - header: RowLayout { - id: layoutrow + header: ColumnLayout { width: parent.width - - Controls.Label { - anchors.left: parent.left - text: i18n("Wi-fi") + Kirigami.InlineMessage { + id: inlineError Layout.fillWidth: true - font.bold: true + showCloseButton: true + + visible: false + + type: Kirigami.MessageType.Warning + Connections { + target: handler + onConnectionActivationFailed: { + inlineError.text = message; + inlineError.visible = true; + } + } } - Controls.Switch { - id: wifiSwitchButton - checked: enabled && enabledConnections.wirelessEnabled - enabled: enabledConnections.wirelessHwEnabled - onClicked: { - handler.enableWireless(checked); + RowLayout { + id: layoutrow + Layout.fillWidth: true + + Controls.Label { + anchors.left: parent.left + text: i18n("Wi-fi") + Layout.fillWidth: true + font.bold: true + } + + Controls.Switch { + id: wifiSwitchButton + checked: enabled && enabledConnections.wirelessEnabled + enabled: enabledConnections.wirelessHwEnabled + onClicked: { + handler.enableWireless(checked); + } } } }