From f553dc96b8b2fe34f8c4dff317071f978a1b0b64 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Mon, 6 Apr 2026 13:36:35 +0200 Subject: [PATCH] Generate logging category for AutoDetectAPN --- kded/autodetectapn/CMakeLists.txt | 7 +++++++ kded/autodetectapn/autodetectapn.cpp | 15 +++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/kded/autodetectapn/CMakeLists.txt b/kded/autodetectapn/CMakeLists.txt index 670525db..c49bd8bd 100644 --- a/kded/autodetectapn/CMakeLists.txt +++ b/kded/autodetectapn/CMakeLists.txt @@ -20,3 +20,10 @@ target_link_libraries(kded_plasma_mobile_autodetect_apn PRIVATE KF6::ModemManagerQt QCoro::DBus ) + +ecm_qt_declare_logging_category(kded_plasma_mobile_autodetect_apn + HEADER autodetectapn_debug.h + IDENTIFIER AUTODETECTAPN_LOG + CATEGORY_NAME org.kde.plasma.autodetectapn + DESCRIPTION "Plasma Mobile Autodetect APNs" +) diff --git a/kded/autodetectapn/autodetectapn.cpp b/kded/autodetectapn/autodetectapn.cpp index ccaefa5c..0b3d0bee 100644 --- a/kded/autodetectapn/autodetectapn.cpp +++ b/kded/autodetectapn/autodetectapn.cpp @@ -27,11 +27,10 @@ #include #include "autodetectapn.h" +#include "autodetectapn_debug.h" K_PLUGIN_FACTORY_WITH_JSON(StartFactory, "kded_plasma_mobile_autodetectapn.json", registerPlugin();) -static const QLoggingCategory LOGGING_CATEGORY("plasma-mobile-autodetectapn"); - AutoDetectAPN::AutoDetectAPN(QObject *parent, const QList &) : KDEDModule{parent} { @@ -41,11 +40,11 @@ AutoDetectAPN::AutoDetectAPN(QObject *parent, const QList &) QCoro::Task AutoDetectAPN::checkAndAddAutodetectedAPN() { if (!KRuntimePlatform::runtimePlatform().contains(QStringLiteral("phone"))) { - qCDebug(LOGGING_CATEGORY) << "Not running APN autodetection because this is not a Plasma Mobile session..."; + qCDebug(AUTODETECTAPN_LOG) << "Not running APN autodetection because this is not a Plasma Mobile session..."; co_return; } - qCDebug(LOGGING_CATEGORY) << "Running APN autodetection..."; + qCDebug(AUTODETECTAPN_LOG) << "Running APN autodetection..."; for (ModemManager::ModemDevice::Ptr mmDevice : ModemManager::modemDevices()) { ModemManager::Modem::Ptr mmModem = mmDevice->modemInterface(); @@ -65,7 +64,7 @@ QCoro::Task AutoDetectAPN::checkAndAddAutodetectedAPN() // TODO: currently just check if there are any NM connections, this doesn't work if the user swapped out their SIM. // we need something that detects when this occurs if (!nmModem->availableConnections().empty()) { - qCDebug(LOGGING_CATEGORY) << "Modem" << nmModem->uni() << "already has a connection configured"; + qCDebug(AUTODETECTAPN_LOG) << "Modem" << nmModem->uni() << "already has a connection configured"; continue; } @@ -78,7 +77,7 @@ QCoro::Task AutoDetectAPN::checkAndAddAutodetectedAPN() // Autodetect an APN std::optional detectedAPNOpt = findAPN(operatorCode, gid1, spn, imsi); if (detectedAPNOpt == std::nullopt || (*detectedAPNOpt).apn.isEmpty()) { - qCDebug(LOGGING_CATEGORY) << "Could not find an APN for the SIM with code" << operatorCode; + qCDebug(AUTODETECTAPN_LOG) << "Could not find an APN for the SIM with code" << operatorCode; continue; } @@ -115,9 +114,9 @@ QCoro::Task AutoDetectAPN::checkAndAddAutodetectedAPN() } if (!reply.isValid()) { - qCWarning(LOGGING_CATEGORY) << "Error adding autodetected connection:" << reply.error().message(); + qCWarning(AUTODETECTAPN_LOG) << "Error adding autodetected connection:" << reply.error().message(); } else { - qCDebug(LOGGING_CATEGORY) << "Successfully autodetected" << detectedAPN.carrier << "with APN" << detectedAPN.apn << "."; + qCDebug(AUTODETECTAPN_LOG) << "Successfully autodetected" << detectedAPN.carrier << "with APN" << detectedAPN.apn << "."; } } }