summaryrefslogtreecommitdiff
path: root/raveos-calamares-module/wifi
diff options
context:
space:
mode:
Diffstat (limited to 'raveos-calamares-module/wifi')
-rw-r--r--raveos-calamares-module/wifi/NetworkManager.cpp54
-rw-r--r--raveos-calamares-module/wifi/NetworkManager.h2
-rw-r--r--raveos-calamares-module/wifi/WifiViewStep.cpp20
3 files changed, 0 insertions, 76 deletions
diff --git a/raveos-calamares-module/wifi/NetworkManager.cpp b/raveos-calamares-module/wifi/NetworkManager.cpp
index 8274e1a..cb88698 100644
--- a/raveos-calamares-module/wifi/NetworkManager.cpp
+++ b/raveos-calamares-module/wifi/NetworkManager.cpp
@@ -13,10 +13,8 @@
#include <QTextStream>
#include <QDateTime>
-// NetworkManager expects a{sa{sv}} type for connection settings
typedef QMap<QString, QVariantMap> NMConnectionSettings;
-// Log file path
static const QString LOG_FILE = "/tmp/calamares-wifi.log";
static void wifiLog(const QString& message)
@@ -24,7 +22,6 @@ static void wifiLog(const QString& message)
QString timestamp = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz");
QString logLine = QString("[%1] %2\n").arg(timestamp, message);
- // Write to file
QFile file(LOG_FILE);
if (file.open(QIODevice::Append | QIODevice::Text))
{
@@ -33,17 +30,14 @@ static void wifiLog(const QString& message)
file.close();
}
- // Also print to debug output
qDebug().noquote() << "[WiFi Module]" << message;
}
NetworkManager::NetworkManager(QObject* parent)
: QObject(parent)
{
- // Register the custom DBus type
qDBusRegisterMetaType<NMConnectionSettings>();
- // Clear log file on start
QFile file(LOG_FILE);
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
{
@@ -56,7 +50,6 @@ NetworkManager::NetworkManager(QObject* parent)
scan();
updateConnectionState();
- // Periodic connection state update
QTimer* timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &NetworkManager::updateConnectionState);
timer->start(3000);
@@ -88,7 +81,6 @@ void NetworkManager::updateConnectionState()
bool newState = false;
- // Method 1: Check PrimaryConnection
QDBusObjectPath primary =
nm.property("PrimaryConnection").value<QDBusObjectPath>();
@@ -97,7 +89,6 @@ void NetworkManager::updateConnectionState()
newState = true;
}
- // Method 2: Check if any WiFi device is in activated state (100)
if (!newState)
{
QDBusReply<QList<QDBusObjectPath>> devices = nm.call("GetDevices");
@@ -118,7 +109,6 @@ void NetworkManager::updateConnectionState()
"DeviceType"
);
- // DeviceType 2 = WiFi
if (typeReply.isValid() && typeReply.value().toUInt() == 2)
{
QDBusReply<QVariant> stateReply = devProps.call(
@@ -127,7 +117,6 @@ void NetworkManager::updateConnectionState()
"State"
);
- // State 100 = NM_DEVICE_STATE_ACTIVATED
if (stateReply.isValid())
{
uint state = stateReply.value().toUInt();
@@ -184,7 +173,6 @@ void NetworkManager::scan()
bool foundWireless = false;
for (const auto& dev : devices.value())
{
- // Check DeviceType first - type 2 = WiFi
QDBusInterface devProps(
"org.freedesktop.NetworkManager",
dev.path(),
@@ -207,7 +195,6 @@ void NetworkManager::scan()
foundWireless = true;
wifiLog(QString("Found wireless device: %1").arg(dev.path()));
- // Now use the Wireless interface for scanning
QDBusInterface wirelessIf(
"org.freedesktop.NetworkManager",
dev.path(),
@@ -215,7 +202,6 @@ void NetworkManager::scan()
QDBusConnection::systemBus()
);
- // Request a new scan - this is async
QDBusMessage reply = wirelessIf.call("RequestScan", QVariantMap());
if (reply.type() == QDBusMessage::ErrorMessage) {
wifiLog(QString("Scan request failed: %1").arg(reply.errorMessage()));
@@ -228,7 +214,6 @@ void NetworkManager::scan()
wifiLog("No wireless devices found!");
}
- // Wait for scan to complete, then fetch results
QTimer::singleShot(2000, this, &NetworkManager::fetchAccessPoints);
}
@@ -262,7 +247,6 @@ void NetworkManager::fetchAccessPoints()
for (const auto& dev : devices.value())
{
- // Check DeviceType first - type 2 = WiFi
QDBusInterface devProps(
"org.freedesktop.NetworkManager",
dev.path(),
@@ -308,7 +292,6 @@ void NetworkManager::fetchAccessPoints()
QByteArray ssidRaw = apIf.property("Ssid").toByteArray();
QString ssid = QString::fromUtf8(ssidRaw);
- // Get frequency to show 2.4G vs 5G
uint frequency = apIf.property("Frequency").toUInt();
QString band = (frequency > 4000) ? "5GHz" : "2.4GHz";
@@ -319,7 +302,6 @@ void NetworkManager::fetchAccessPoints()
}
}
- // Sort networks alphabetically
m_networks.sort(Qt::CaseInsensitive);
wifiLog(QString("Total networks found: %1").arg(m_networks.size()));
@@ -343,7 +325,6 @@ void NetworkManager::connectTo(const QString& ssid, const QString& password)
return;
}
- // Find the wireless device
QDBusReply<QList<QDBusObjectPath>> devices = nm.call("GetDevices");
if (!devices.isValid())
{
@@ -372,13 +353,11 @@ void NetworkManager::connectTo(const QString& ssid, const QString& password)
"DeviceType"
);
- // DeviceType 2 = WiFi
if (typeReply.isValid() && typeReply.value().toUInt() == 2)
{
wirelessDevice = dev;
wifiLog(QString("Using wireless device: %1").arg(dev.path()));
- // Find the access point for this SSID
QDBusInterface wirelessIf(
"org.freedesktop.NetworkManager",
dev.path(),
@@ -402,7 +381,6 @@ void NetworkManager::connectTo(const QString& ssid, const QString& password)
if (QString::fromUtf8(apSsid) == ssid)
{
accessPoint = ap;
- // Get security flags from AP
apFlags = apIf.property("Flags").toUInt();
apWpaFlags = apIf.property("WpaFlags").toUInt();
apRsnFlags = apIf.property("RsnFlags").toUInt();
@@ -423,25 +401,17 @@ void NetworkManager::connectTo(const QString& ssid, const QString& password)
return;
}
- // Determine security type from AP flags
- // NM_802_11_AP_SEC flags:
- // 0x100 = KEY_MGMT_PSK (WPA/WPA2 Personal)
- // 0x200 = KEY_MGMT_802_1X (WPA/WPA2 Enterprise)
- // 0x400 = KEY_MGMT_SAE (WPA3)
- // 0x800 = KEY_MGMT_OWE (Enhanced Open)
bool apSupportsPsk = ((apWpaFlags & 0x100) != 0) || ((apRsnFlags & 0x100) != 0);
bool apSupportsSae = (apRsnFlags & 0x400) != 0; // WPA3
bool apSupportsEnterprise = ((apWpaFlags & 0x200) != 0) || ((apRsnFlags & 0x200) != 0);
bool apIsOpen = (apFlags == 0) && (apWpaFlags == 0) && (apRsnFlags == 0);
- // Privacy flag (0x1) means network is secured (WEP or better)
bool apHasPrivacy = (apFlags & 0x1) != 0;
wifiLog(QString("Security detection: PSK=%1, SAE=%2, Enterprise=%3, Open=%4, Privacy=%5")
.arg(apSupportsPsk).arg(apSupportsSae).arg(apSupportsEnterprise).arg(apIsOpen).arg(apHasPrivacy));
- // Build connection settings using proper NM types
QVariantMap connection;
connection["type"] = QString("802-11-wireless");
connection["id"] = ssid;
@@ -451,7 +421,6 @@ void NetworkManager::connectTo(const QString& ssid, const QString& password)
wifi["ssid"] = ssid.toUtf8();
wifi["mode"] = QString("infrastructure");
- // For hidden networks, we need to set hidden flag
bool isHiddenNetwork = (accessPoint.path() == "/" || accessPoint.path().isEmpty());
if (isHiddenNetwork)
{
@@ -459,7 +428,6 @@ void NetworkManager::connectTo(const QString& ssid, const QString& password)
wifiLog("Treating as hidden network");
}
- // Build settings map
NMConnectionSettings settings;
settings["connection"] = connection;
@@ -471,28 +439,21 @@ void NetworkManager::connectTo(const QString& ssid, const QString& password)
ipv6["method"] = QString("auto");
settings["ipv6"] = ipv6;
- // Determine and apply security settings based on AP capabilities
if (!password.isEmpty() && (apSupportsPsk || apSupportsSae || isHiddenNetwork))
{
- // Password provided and AP supports PSK or SAE (or it's hidden, assume PSK)
QVariantMap wifiSecurity;
if (apSupportsSae && !apSupportsPsk)
{
- // WPA3-only network
wifiLog("Using WPA3-SAE security");
wifiSecurity["key-mgmt"] = QString("sae");
wifiSecurity["psk"] = password;
- // PMF (Protected Management Frames) is MANDATORY for WPA3-SAE
- // 0 = default, 1 = disable, 2 = optional, 3 = required
wifiSecurity["pmf"] = 3;
}
else if (apSupportsPsk)
{
- // Check if this is WPA2/WPA3 transition mode (supports both PSK and SAE)
if (apSupportsSae)
{
- // Transition mode: prefer WPA3-SAE if available
wifiLog("Using WPA3-SAE (transition mode - both PSK and SAE available)");
wifiSecurity["key-mgmt"] = QString("sae");
wifiSecurity["psk"] = password;
@@ -500,7 +461,6 @@ void NetworkManager::connectTo(const QString& ssid, const QString& password)
}
else
{
- // Pure WPA/WPA2-PSK network (most common)
wifiLog("Using WPA-PSK security");
wifiSecurity["key-mgmt"] = QString("wpa-psk");
wifiSecurity["psk"] = password;
@@ -508,7 +468,6 @@ void NetworkManager::connectTo(const QString& ssid, const QString& password)
}
else if (isHiddenNetwork)
{
- // Hidden network with password - assume WPA-PSK
wifiLog("Hidden network with password, assuming WPA-PSK");
wifiSecurity["key-mgmt"] = QString("wpa-psk");
wifiSecurity["psk"] = password;
@@ -520,34 +479,28 @@ void NetworkManager::connectTo(const QString& ssid, const QString& password)
}
else if (apSupportsEnterprise)
{
- // Enterprise networks require more complex configuration
wifiLog("WARNING: Enterprise (802.1X) networks are not supported by this simple connector");
return;
}
else if (apIsOpen || (!apHasPrivacy && !apSupportsPsk && !apSupportsSae))
{
- // Open network - no security settings needed
wifiLog("Connecting to open network (no security)");
settings["802-11-wireless"] = wifi;
}
else if (!password.isEmpty() && !apSupportsPsk && !apSupportsSae)
{
- // Password provided but AP doesn't support PSK/SAE
- // This is the error case from the log!
wifiLog("WARNING: Password provided but AP does not support PSK/SAE authentication!");
wifiLog("Attempting to connect as open network...");
settings["802-11-wireless"] = wifi;
}
else
{
- // Fallback - no password, assume open
wifiLog("No password provided, treating as open network");
settings["802-11-wireless"] = wifi;
}
wifiLog("Calling AddAndActivateConnection...");
- // Use AddAndActivateConnection with proper DBus argument
QDBusMessage msg = QDBusMessage::createMethodCall(
"org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager",
@@ -555,7 +508,6 @@ void NetworkManager::connectTo(const QString& ssid, const QString& password)
"AddAndActivateConnection"
);
- // Serialize settings properly for DBus
QDBusArgument settingsArg;
settingsArg.beginMap(QMetaType::fromType<QString>(), QMetaType::fromType<QVariantMap>());
for (auto it = settings.constBegin(); it != settings.constEnd(); ++it)
@@ -580,12 +532,10 @@ void NetworkManager::connectTo(const QString& ssid, const QString& password)
else
{
wifiLog("Connection initiated successfully");
- // Save credentials for later use (to be saved to installed system)
m_lastConnectedSsid = ssid;
m_lastConnectedPassword = password;
wifiLog(QString("Stored credentials - SSID: '%1', Password length: %2").arg(m_lastConnectedSsid).arg(m_lastConnectedPassword.length()));
- // Determine and save security type
if (apSupportsSae && !apSupportsPsk)
{
m_lastSecurityType = "sae";
@@ -604,10 +554,7 @@ void NetworkManager::connectTo(const QString& ssid, const QString& password)
}
wifiLog(QString("Stored security type: '%1'").arg(m_lastSecurityType));
- // Note: WiFi persistence to installed system is disabled
- // Connection only works during installation
- // Check connection state multiple times (WPA3-SAE can be slow)
m_connectionCheckCount = 0;
startConnectionCheck();
}
@@ -626,7 +573,6 @@ void NetworkManager::startConnectionCheck()
return;
}
- // Retry up to 10 times (every 1 second = 10 seconds total)
if (m_connectionCheckCount < 10)
{
QTimer::singleShot(1000, this, &NetworkManager::startConnectionCheck);
diff --git a/raveos-calamares-module/wifi/NetworkManager.h b/raveos-calamares-module/wifi/NetworkManager.h
index ff9dbf2..dd58a9a 100644
--- a/raveos-calamares-module/wifi/NetworkManager.h
+++ b/raveos-calamares-module/wifi/NetworkManager.h
@@ -16,7 +16,6 @@ public:
QStringList networks() const;
bool isConnected() const;
- // Get the last connected network credentials (for saving to installed system)
QString lastConnectedSsid() const { return m_lastConnectedSsid; }
QString lastConnectedPassword() const { return m_lastConnectedPassword; }
QString lastSecurityType() const { return m_lastSecurityType; } // "wpa-psk" or "sae"
@@ -40,7 +39,6 @@ private:
QStringList m_networks;
bool m_connected = false;
- // Store credentials for saving to installed system
QString m_lastConnectedSsid;
QString m_lastConnectedPassword;
QString m_lastSecurityType; // "wpa-psk", "sae", or "" (open)
diff --git a/raveos-calamares-module/wifi/WifiViewStep.cpp b/raveos-calamares-module/wifi/WifiViewStep.cpp
index 5b55078..350bd43 100644
--- a/raveos-calamares-module/wifi/WifiViewStep.cpp
+++ b/raveos-calamares-module/wifi/WifiViewStep.cpp
@@ -121,23 +121,18 @@ bool WifiViewStep::isAtEnd() const
Calamares::JobList WifiViewStep::jobs() const
{
- // WiFi persistence disabled - connection only works during installation
- // The WiFi module only provides network connectivity for the installer
return Calamares::JobList();
}
void WifiViewStep::onActivate()
{
- // Force update locale from GlobalStorage
QString newLocale = getLocale();
m_locale = newLocale;
- // Update QML context property
if (m_quickWidget)
{
m_quickWidget->rootContext()->setContextProperty("systemLocale", m_locale);
- // Force QML to re-read the locale by calling a method on root object
QQuickItem* root = m_quickWidget->rootObject();
if (root)
{
@@ -145,13 +140,10 @@ void WifiViewStep::onActivate()
}
}
- // Start network check timer
m_networkCheckTimer->start(2000);
- // Check initial network state
m_lastNetworkState = hasActiveNetwork();
- // Auto-skip ONLY on first activation AND if there's network
if (m_firstActivation && m_lastNetworkState)
{
m_firstActivation = false;
@@ -159,13 +151,10 @@ void WifiViewStep::onActivate()
return;
}
- // Mark as no longer first activation
m_firstActivation = false;
- // Normal activation - show WiFi setup
m_networkManager->scan();
- // Emit initial state
emit nextStatusChanged(m_lastNetworkState);
}
@@ -225,9 +214,7 @@ QString WifiViewStep::getLocale() const
if (gs)
{
- // Check all possible locale keys that Calamares might use
- // Key 1: "locale" (direct string)
if (gs->contains("locale"))
{
QString loc = gs->value("locale").toString();
@@ -235,7 +222,6 @@ QString WifiViewStep::getLocale() const
return loc;
}
- // Key 2: "lang" (some modules use this)
if (gs->contains("lang"))
{
QString loc = gs->value("lang").toString();
@@ -243,7 +229,6 @@ QString WifiViewStep::getLocale() const
return loc;
}
- // Key 3: "language"
if (gs->contains("language"))
{
QString loc = gs->value("language").toString();
@@ -251,7 +236,6 @@ QString WifiViewStep::getLocale() const
return loc;
}
- // Key 4: "localeConf" map with LANG key
if (gs->contains("localeConf"))
{
QVariantMap localeConf = gs->value("localeConf").toMap();
@@ -263,7 +247,6 @@ QString WifiViewStep::getLocale() const
}
}
- // Key 5: Check for region-based locale
if (gs->contains("locationRegion"))
{
QString region = gs->value("locationRegion").toString();
@@ -273,12 +256,9 @@ QString WifiViewStep::getLocale() const
}
}
- // Key 6: "localeIndex" - welcome module sometimes stores index
- // We'd need to map this to actual locale
}
}
- // Fallback to system locale
return QLocale::system().name();
}