Skip to content

Commit

Permalink
Use the connectivy check URI reported by NetworkManager
Browse files Browse the repository at this point in the history
We were using the hardcoded URI `networkcheck.kde.org` to launch a
browser and let the user log into a captive portal

Use the URI reported by NetworkManager instead
  • Loading branch information
ismailof committed Dec 21, 2024
1 parent a8d9342 commit c718eeb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion applet/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ PlasmoidItem {
icon.name: "internet-web-browser-symbolic"
priority: PlasmaCore.Action.LowPriority
visible: networkStatus.connectivity === NMQt.NetworkManager.Portal
onTriggered: Qt.openUrlExternally("http://networkcheck.kde.org")
onTriggered: Qt.openUrlExternally(networkStatus.networkCheckUrl)
}
]

Expand Down
2 changes: 1 addition & 1 deletion kded/connectivitymonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void ConnectivityMonitor::connectivityChanged(NetworkManager::Connectivity conne

auto logInAction = m_notification->addAction(i18n("Log in"));
connect(logInAction, &KNotificationAction::activated, this, [this]() {
auto job = new KIO::OpenUrlJob(QUrl(QStringLiteral("http://networkcheck.kde.org")));
auto job = new KIO::OpenUrlJob(QUrl(NetworkManager::connectivityCheckUri()));
job->setStartupId(m_notification->xdgActivationToken().toUtf8());
job->start();
});
Expand Down
3 changes: 2 additions & 1 deletion libs/networkstatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ NetworkStatus::NetworkStatus(QObject *parent)
connect(NetworkManager::notifier(), &NetworkManager::Notifier::connectivityChanged, this, &NetworkStatus::connectivityChanged);
connect(NetworkManager::notifier(), &NetworkManager::Notifier::statusChanged, this, &NetworkStatus::statusChanged);
connect(NetworkManager::notifier(), &NetworkManager::Notifier::activeConnectionsChanged, this, QOverload<>::of(&NetworkStatus::activeConnectionsChanged));
connect(NetworkManager::notifier(), &NetworkManager::Notifier::connectivityCheckUriChanged, this, &NetworkStatus::networkCheckUrlChanged);

activeConnectionsChanged();
statusChanged(NetworkManager::status());
Expand All @@ -83,7 +84,7 @@ NetworkStatus::~NetworkStatus() = default;

QUrl NetworkStatus::networkCheckUrl()
{
return QUrl(QStringLiteral("http://networkcheck.kde.org/"));
return QUrl(NetworkManager::connectivityCheckUri());
}

QString NetworkStatus::activeConnections() const
Expand Down
3 changes: 2 additions & 1 deletion libs/networkstatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class NetworkStatus : public QObject
/**
* Returns the KDE portal network check website URL
*/
Q_PROPERTY(QUrl networkCheckUrl READ networkCheckUrl CONSTANT)
Q_PROPERTY(QUrl networkCheckUrl READ networkCheckUrl NOTIFY networkCheckUrlChanged)

/**
* Returns the network connectivity state
Expand Down Expand Up @@ -69,6 +69,7 @@ private Q_SLOTS:
Q_SIGNALS:
void activeConnectionsChanged(const QString &activeConnections);
void connectivityChanged(NetworkManager::Connectivity connectivity);
void networkCheckUrlChanged();

private:
QString m_activeConnections;
Expand Down

0 comments on commit c718eeb

Please sign in to comment.