Commit 63a541c4 authored by Marco Martin's avatar Marco Martin

send a signal over dbus when the wrong password is provided

Summary:
On Plasma Mobile we can't actually show a qwidgets based dialog
when the password is wrong, and preferably not any additional window over the $
this adds a signal to the kded when it fails to authenticate,
the handler will forget such password so that the password field will appear again and the kcm shows an error message when this happens

Test Plan: tried to connect with wrong password

Reviewers: #plasma, jgrulich, bshah

Reviewed By: jgrulich

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D19306
parent 5824bea8
......@@ -39,6 +39,7 @@
#include <QStringBuilder>
#include <QDialog>
#include <KLocalizedString>
#include <KPluginFactory>
#include <KWindowSystem>
#include <KConfig>
......@@ -408,6 +409,7 @@ bool SecretAgent::processGetSecrets(SecretsRequest &request) const
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);
......
......@@ -72,6 +72,9 @@ public:
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;
......
......@@ -66,6 +66,7 @@ void NetworkManagementService::init()
if (!d->agent) {
d->agent = new SecretAgent(this);
connect(d->agent, &SecretAgent::secretsError, this, &NetworkManagementService::secretsError);
}
if (!d->notification) {
......
......@@ -45,6 +45,8 @@ public Q_SLOTS:
Q_SIGNALS:
Q_SCRIPTABLE void registered();
Q_SCRIPTABLE
void secretsError(const QString &connectionPath, const QString &message);
private Q_SLOTS:
void slotRegistered(const QDBusObjectPath &path);
......
......@@ -74,6 +74,12 @@ Handler::Handler(QObject *parent)
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 @@ void Handler::initKdedModule()
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;
......
......@@ -104,6 +104,7 @@ public Q_SLOTS:
private Q_SLOTS:
void initKdedModule();
void secretAgentError(const QString &connectionPath, const QString &message);
void replyFinished(QDBusPendingCallWatcher *watcher);
#if WITH_MODEMMANAGER_SUPPORT
void unlockRequiredChanged(MMModemLock modemLock);
......@@ -111,6 +112,7 @@ private Q_SLOTS:
Q_SIGNALS:
void wirelessScanTimerEnabled(bool enable);
void connectionActivationFailed(const QString &connectionPath, const QString &message);
private:
bool m_tmpWirelessEnabled;
bool m_tmpWwanEnabled;
......
......@@ -21,28 +21,48 @@ import QtQuick 2.6
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);
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment