Skip to content

fix: 支持原版NetworkManager, 且增加编译开关保留deepin私有NM支持 - #672

Open
LFRon wants to merge 2 commits into
linuxdeepin:masterfrom
LFRon:master
Open

LFRon wants to merge 2 commits into
linuxdeepin:masterfrom
LFRon:master

Conversation

@LFRon

@LFRon LFRon commented Dec 2, 2026 •

Copy link
Copy Markdown
  1. Add a build-time USE_DEEPIN_NM option (default OFF) and select the NetworkManager ABI in nmnetworkmanager.{h,cpp}. OFF uses the standard ActivateConnection/AddAndActivateConnection2 methods and drops the Deepin-only flags option; ON keeps ActivateConnection2 and the flags option unchanged.
  2. Route every activation call through activateConnection2() and addAndActivateConnection2Compat(), and log D-Bus activation errors instead of silently ignoring them.
  3. Mask Reapply flags on stock NM to the standard PRESERVE_EXTERNAL_IP bit and watch the reply, so an unsupported PRESERVE_DHCP value no longer fails silently. Link the network service plugin against dde-network-core6 for the compat helpers.
  4. Correct the session network D-Bus service name and hook object path: use org.deepin.dde.Network1 and prefix the hook path with a slash.
  5. Do not prefill the previous secret when NetworkManager requests a new one after an authentication failure, and use a regular Qt::Dialog on Wayland so Treeland can map the password prompt.

Log: Wi-Fi and VPN activation works against Fedora's stock NetworkManager; Deepin builds keep the private activation path by passing -DUSE_DEEPIN_NM=ON.
PMS: None
Influence:

  1. On stock NetworkManager, connect to a Wi-Fi network and verify the standard ActivateConnection path is used without "Unknown method" or "Invalid flags specified" errors.
  2. On Deepin's NetworkManager, build with -DUSE_DEEPIN_NM=ON and verify ActivateConnection2 receives the flags option and Reapply keeps PRESERVE_DHCP.
  3. Retry a wrong Wi-Fi password and verify the dialog is empty; check that the dialog is visible on Wayland/Treeland and connects with the correct password.

fix: 适配原版 NetworkManager 的 D-Bus API

  1. 新增编译期 USE_DEEPIN_NM 选项(默认 OFF),在 nmnetworkmanager.{h,cpp} 中选择 NetworkManager ABI。OFF 使用标准 ActivateConnection/AddAndActivateConnection2 并去掉 Deepin 私有的 flags 参数;ON 保留 ActivateConnection2 与 flags。
  2. 所有激活调用统一走 activateConnection2() 与 addAndActivateConnection2Compat(),并记录 D-Bus 激活错误,不再 静默忽略失败。
  3. 原版 NM 下把 Reapply flags 收敛到标准的 PRESERVE_EXTERNAL_IP 位, 并监听回复,避免不支持的 PRESERVE_DHCP 值静默失败。网络服务插件 链接 dde-network-core6 以复用兼容函数。
  4. 修正会话网络 D-Bus 服务名与 hook 对象路径:使用 org.deepin.dde.Network1,并给 hook 路径补上前导斜杠。
  5. NetworkManager 在认证失败后请求新密码时不再预填旧密码;Wayland 下改用普通 Qt::Dialog,确保 Treeland 能正常映射密码框。

Log: 原版 NetworkManager 下 Wi-Fi/VPN 可正常激活;Deepin 构建传入 -DUSE_DEEPIN_NM=ON 后保留私有激活路径。
PMS: None
Influence:

  1. 在原版 NetworkManager 上连接 Wi-Fi,确认走标准 ActivateConnection,且不再出现 "Unknown method" 或 "Invalid flags specified"。
  2. 在 Deepin NetworkManager 上以 -DUSE_DEEPIN_NM=ON 构建,确认 ActivateConnection2 收到 flags,Reapply 保留 PRESERVE_DHCP。
  3. 输错 Wi-Fi 密码后重试,确认密码框为空;在 Wayland/Treeland 下 确认密码框可见,输入正确密码后连接成功。

Summary by Sourcery

Support stock NetworkManager while retaining an opt-in path for Deepin-specific NetworkManager behavior.

New Features:

  • Add a build-time option, disabled by default, to select Deepin NetworkManager compatibility behavior.

Bug Fixes:

  • Enable network activation against standard NetworkManager by using supported activation APIs and filtering unsupported activation and reapply options.
  • Log activation and reapply D-Bus failures instead of silently ignoring them.
  • Show a usable password prompt on Wayland/Treeland and leave the password field empty when retrying after authentication failure.
  • Use the corrected session network D-Bus service identifiers and hook object path.

Build:

  • Link the network service plugin against dde-network-core6 and expose the core source include path for compatibility helpers.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LFRon

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

API

Define the shared NetworkManager compatibility helpers and implement the build-selected standard or Deepin activation behavior, including option and Reapply-flag filtering.

  • src/impl/networkmanager/nmnetworkmanager.cpp L7-80
  • src/impl/networkmanager/nmnetworkmanager.h L7-59

Uses of the API

Route activation and Reapply callers through the compatibility helpers, preserving asynchronous error reporting where applicable.

  • net-view/operation/private/netmanagerthreadprivate.cpp L1061, L1700, L1747-1762
  • net-view/operation/private/netwirelessconnect.cpp L21, L426-429, L454-460
  • network-service-plugin/src/system/nmaccess.cpp L7, L19, L573-583
  • src/impl/networkmanager/devicemanagerrealize.cpp L838

Use the corrected session network service identifiers when checking connectivity and issuing the portal connectivity request.

  • network-service-plugin/src/session/sessioncontainer.cpp L53, L118

UI

Leave the password field empty for a renewed secret request and use a regular dialog on Wayland so Treeland can map the prompt.

  • network-service-plugin/dde-network-secret-dialog/src/networksecretdialog.cpp L85-87
  • network-service-plugin/src/session/networksecretagent.cpp L703-706

Configuration

Expose the Deepin NetworkManager build option and link the network service plugin to the compatibility helpers.

  • CMakeLists.txt L11, L40-43
  • network-service-plugin/CMakeLists.txt L48, L67

Record the Debian build-option change and updated session network plugin metadata.

  • debian/rules L13-16
  • network-service-plugin/src/session/plugin-session-network.json L13

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

Hi @LFRon. Thanks for your PR. 😃

@deepin-ci-robot

Copy link
Copy Markdown

Hi @LFRon. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@BLumia
BLumia requested review from 52cyb and caixr23 December 2, 2026 06:21

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 6 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="network-service-plugin/src/session/sessioncontainer.cpp" line_range="53" />
<code_context>
 {
     // 检测初始化的状态是否为门户认证,这种情况下需要先打开Url
-    QDBusInterface dbusInter("org.deepin.service.SystemNetwork", "/org/deepin/service/SystemNetwork", "org.deepin.service.SystemNetwork", QDBusConnection::systemBus());
+    QDBusInterface dbusInter(networkService, networkPath, networkInterface, QDBusConnection::systemBus());
     network::service::Connectivity connectivity = static_cast<network::service::Connectivity>(dbusInter.property("Connectivity").toInt());
     if (connectivity == network::service::Connectivity::Portal) {
</code_context>
<issue_to_address>
**Captive portal launches arbitrary URI handlers**

When a connected network returns a captive-portal redirect using a non-HTTP URI scheme, `HttpReply` accepts the response’s `Location` as the portal URL, and `SessionContainer` passes it through `UrlHelper::openUrl` to `xdg-open` without restricting the scheme. A hostile portal can therefore trigger desktop URI handlers or open local resources for the logged-in user.

Validate portal URLs before opening them, allowing only explicitly supported schemes such as HTTP and HTTPS.
</issue_to_address>

### Comment 2
<location path="src/impl/networkmanager/nmnetworkmanager.cpp" line_range="23" />
<code_context>
-    if (extra_connection_parameter.isEmpty()) {
-        extra_connection_parameter = QLatin1String("/");
+    QVariantMap result = options;
+    if constexpr (USE_DEEPIN_NM == 0)
+        result.remove(QStringLiteral("flags"));
+    return result;
</code_context>
<issue_to_address>
**Core fails strict C++14 builds**

When the project is built with a strict C++14 compiler, `if constexpr` requires C++17, but `src/CMakeLists.txt:10` sets the core target to C++14. A compiler that rejects this C++17 extension fails to build the core library.

Replace these `if constexpr` statements with C++14-compatible `if` statements or raise the core target's standard to C++17.
</issue_to_address>

### Comment 3
<location path="network-service-plugin/src/session/sessioncontainer.cpp" line_range="53" />
<code_context>
 {
     // 检测初始化的状态是否为门户认证,这种情况下需要先打开Url
-    QDBusInterface dbusInter("org.deepin.service.SystemNetwork", "/org/deepin/service/SystemNetwork", "org.deepin.service.SystemNetwork", QDBusConnection::systemBus());
+    QDBusInterface dbusInter(networkService, networkPath, networkInterface, QDBusConnection::systemBus());
     network::service::Connectivity connectivity = static_cast<network::service::Connectivity>(dbusInter.property("Connectivity").toInt());
     if (connectivity == network::service::Connectivity::Portal) {
</code_context>
<issue_to_address>
**Portal and connectivity checks fail**

When sessionContainer performs portal or connectivity checks, sessionContainer sends the system-bus calls to `org.deepin.dde.Network1`, but the system-service factory registers `org.deepin.dde.Network10`, so the calls do not reach the service and portal handling and connectivity checks fail.

Use the registered system-service name consistently for these calls and the related signal subscriptions.

Also at `network-service-plugin/src/session/sessioncontainer.cpp:118`.
</issue_to_address>

### Comment 4
<location path="net-view/operation/private/netmanagerthreadprivate.cpp" line_range="1762" />
<code_context>
+                    NetworkManager::activateConnection(connection->path(), devPath, QString());
+                    break;
+                }
+                [[fallthrough]];
             }
             // case ConnectionSettings::Wired:
</code_context>
<issue_to_address>
**Connections receive duplicate activation requests**

When `USE_DEEPIN_NM` is enabled and the wireless or PPPoE branch executes, the Deepin branch completes `activateConnection2()` and falls through to the standard `activateConnection()` call for the same connection, causing a redundant activation request that can interrupt or restart the connection.

Stop the Deepin branch from falling through to the standard activation call.
</issue_to_address>

### Comment 5
<location path="net-view/operation/private/netmanagerthreadprivate.cpp" line_range="1759" />
<code_context>
+                    if (reply.isError())
+                        qCWarning(DNC) << "Failed to activate connection:" << reply.error().message();
+                } else {
+                    NetworkManager::activateConnection(connection->path(), devPath, QString());
+                    break;
+                }
</code_context>
<issue_to_address>
**Failed activations go unreported**

When the stock NetworkManager activation request fails, the standard branch discards the asynchronous reply from `NetworkManager::activateConnection()` without waiting or checking it, so the failure is not logged or reported to the caller.

Wait for or watch the activation reply, then log and report any error.
</issue_to_address>

### Comment 6
<location path="net-view/operation/private/netmanagerthreadprivate.cpp" line_range="1061" />
<code_context>
                 options.insert("flags", MANULCONNECTION);
                 applyDadTimeout(settings);
-                QDBusPendingReply<QDBusObjectPath, QDBusObjectPath> reply = NetworkManager::addAndActivateConnection2(settings->toMap(), devPath, ap->path(), options);
+                QDBusPendingReply<QDBusObjectPath, QDBusObjectPath> reply = NetworkManager::addAndActivateConnection2Compat(settings->toMap(), devPath, ap->path(), options);
                 if (reply.isError()) {
                     qCWarning(DNC) << "activateConnection fiald:" << reply.error().message();
</code_context>
<issue_to_address>
**Activation errors remain silent**

When the compatibility call returns before NetworkManager has replied and then fails, the pending reply is checked with `isError()` immediately, without waiting for completion. An asynchronous D-Bus failure therefore passes the check and is not logged, leaving this activation path silent on failure.

Wait for the reply or attach a completion watcher before checking and logging its error.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

{
// 检测初始化的状态是否为门户认证,这种情况下需要先打开Url
QDBusInterface dbusInter("org.deepin.service.SystemNetwork", "/org/deepin/service/SystemNetwork", "org.deepin.service.SystemNetwork", QDBusConnection::systemBus());
QDBusInterface dbusInter(networkService, networkPath, networkInterface, QDBusConnection::systemBus());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Captive portal launches arbitrary URI handlers

When a connected network returns a captive-portal redirect using a non-HTTP URI scheme, HttpReply accepts the response’s Location as the portal URL, and SessionContainer passes it through UrlHelper::openUrl to xdg-open without restricting the scheme. A hostile portal can therefore trigger desktop URI handlers or open local resources for the logged-in user.

Validate portal URLs before opening them, allowing only explicitly supported schemes such as HTTP and HTTPS.

Prompt for AI agents
In `network-service-plugin/src/session/sessioncontainer.cpp` at line 53:

**Captive portal launches arbitrary URI handlers**

When a connected network returns a captive-portal redirect using a non-HTTP URI scheme, `HttpReply` accepts the response’s `Location` as the portal URL, and `SessionContainer` passes it through `UrlHelper::openUrl` to `xdg-open` without restricting the scheme. A hostile portal can therefore trigger desktop URI handlers or open local resources for the logged-in user.

Validate portal URLs before opening them, allowing only explicitly supported schemes such as HTTP and HTTPS.

{
// 检测初始化的状态是否为门户认证,这种情况下需要先打开Url
QDBusInterface dbusInter("org.deepin.service.SystemNetwork", "/org/deepin/service/SystemNetwork", "org.deepin.service.SystemNetwork", QDBusConnection::systemBus());
QDBusInterface dbusInter(networkService, networkPath, networkInterface, QDBusConnection::systemBus());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · Portal and connectivity checks fail

When sessionContainer performs portal or connectivity checks, sessionContainer sends the system-bus calls to org.deepin.dde.Network1, but the system-service factory registers org.deepin.dde.Network10, so the calls do not reach the service and portal handling and connectivity checks fail.

Use the registered system-service name consistently for these calls and the related signal subscriptions.

Also at network-service-plugin/src/session/sessioncontainer.cpp:118.

Prompt for AI agents
In `network-service-plugin/src/session/sessioncontainer.cpp` at line 53:

**Portal and connectivity checks fail**

When sessionContainer performs portal or connectivity checks, sessionContainer sends the system-bus calls to `org.deepin.dde.Network1`, but the system-service factory registers `org.deepin.dde.Network10`, so the calls do not reach the service and portal handling and connectivity checks fail.

Use the registered system-service name consistently for these calls and the related signal subscriptions.

Also at `network-service-plugin/src/session/sessioncontainer.cpp:118`.

if (reply.isError())
qCWarning(DNC) << "Failed to activate connection:" << reply.error().message();
} else {
NetworkManager::activateConnection(connection->path(), devPath, QString());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Failed activations go unreported

When the stock NetworkManager activation request fails, the standard branch discards the asynchronous reply from NetworkManager::activateConnection() without waiting or checking it, so the failure is not logged or reported to the caller.

Wait for or watch the activation reply, then log and report any error.

Prompt for AI agents
In `net-view/operation/private/netmanagerthreadprivate.cpp` at line 1759:

**Failed activations go unreported**

When the stock NetworkManager activation request fails, the standard branch discards the asynchronous reply from `NetworkManager::activateConnection()` without waiting or checking it, so the failure is not logged or reported to the caller.

Wait for or watch the activation reply, then log and report any error.

options.insert("flags", MANULCONNECTION);
applyDadTimeout(settings);
QDBusPendingReply<QDBusObjectPath, QDBusObjectPath> reply = NetworkManager::addAndActivateConnection2(settings->toMap(), devPath, ap->path(), options);
QDBusPendingReply<QDBusObjectPath, QDBusObjectPath> reply = NetworkManager::addAndActivateConnection2Compat(settings->toMap(), devPath, ap->path(), options);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Activation errors remain silent

When the compatibility call returns before NetworkManager has replied and then fails, the pending reply is checked with isError() immediately, without waiting for completion. An asynchronous D-Bus failure therefore passes the check and is not logged, leaving this activation path silent on failure.

Wait for the reply or attach a completion watcher before checking and logging its error.

Prompt for AI agents
In `net-view/operation/private/netmanagerthreadprivate.cpp` at line 1061:

**Activation errors remain silent**

When the compatibility call returns before NetworkManager has replied and then fails, the pending reply is checked with `isError()` immediately, without waiting for completion. An asynchronous D-Bus failure therefore passes the check and is not logged, leaving this activation path silent on failure.

Wait for the reply or attach a completion watcher before checking and logging its error.

Comment thread CMakeLists.txt Resolved
Comment thread debian/rules Resolved
1. Restore the existing ENABLE_DEEPIN_NMQT CMake option and its
   USE_DEEPIN_NMQT definition instead of adding a second ABI switch.
   Fedora builds pass -DENABLE_DEEPIN_NMQT=OFF; Deepin's debian/rules
   already passes ON.  OFF calls the standard activation
   methods, drops the private flags option, masks the Reapply
   PRESERVE_DHCP bit, and logs activation and Reapply errors.  ON keeps
   ActivateConnection2 and the flags option unchanged.
2. Route every activation call through activateConnection2() and
   addAndActivateConnection2Compat().  Keep the original asynchronous
   D-Bus behavior by reporting errors through QDBusPendingCallWatcher
   instead of blocking with waitForFinished().
3. Watch Reapply replies and link the network service plugin against
   dde-network-core6 for the compat helpers.
4. Correct the session network D-Bus service name and hook object path:
   use org.deepin.dde.Network1 and prefix the hook path with a slash.
5. Do not prefill the previous secret when NetworkManager requests a new
   one after an authentication failure; remove the now-unreachable
   prefill branch.  Use a regular Qt::Dialog on Wayland so Treeland can
   map the password prompt.

Log: Wi-Fi and VPN activation works against Fedora's stock
NetworkManager; Deepin builds keep the private activation path through
the existing ENABLE_DEEPIN_NMQT switch.
PMS: None
Influence:
1. On stock NetworkManager, connect to a Wi-Fi network and verify the
   standard ActivateConnection path is used without "Unknown method" or
   "Invalid flags specified" errors.
2. On Deepin's NetworkManager, build with -DENABLE_DEEPIN_NMQT=ON and
   verify ActivateConnection2 receives the flags option and Reapply
   keeps PRESERVE_DHCP.
3. Retry a wrong Wi-Fi password and verify the dialog is empty; check
   that the dialog is visible on Wayland/Treeland and connects with the
   correct password.

fix: 适配原版 NetworkManager 的 D-Bus API

1. 恢复原有 ENABLE_DEEPIN_NMQT CMake 选项及其 USE_DEEPIN_NMQT 宏,
   不再新增第二套 ABI 开关。Fedora 构建传
   -DENABLE_DEEPIN_NMQT=OFF;Deepin 的 debian/rules 已传 ON。OFF
   使用标准激活接口,去掉私有 flags 参数,屏蔽 Reapply 的
   PRESERVE_DHCP 位,并记录激活与 Reapply 错误;ON 保留
   ActivateConnection2 与 flags 参数。
2. 所有激活调用统一走 activateConnection2() 与
   addAndActivateConnection2Compat()。保留原有异步 D-Bus 行为,用
   QDBusPendingCallWatcher 记录错误,不再用 waitForFinished() 阻塞。
3. 监听 Reapply 回复,并让网络服务插件链接 dde-network-core6 以复用
   兼容函数。
4. 修正会话网络 D-Bus 服务名与 hook 对象路径:使用
   org.deepin.dde.Network1,并给 hook 路径补上前导斜杠。
5. NetworkManager 在认证失败后请求新密码时不再预填旧密码,并删除已经
   不可达的预填分支;Wayland 下改用普通 Qt::Dialog,确保 Treeland
   能正常映射密码框。

Log: 原版 NetworkManager 下 Wi-Fi/VPN 可正常激活;Deepin 构建通过
现有 ENABLE_DEEPIN_NMQT 开关保留私有激活路径。
PMS: None
Influence:
1. 在原版 NetworkManager 上连接 Wi-Fi,确认走标准
   ActivateConnection,且不再出现 "Unknown method" 或
   "Invalid flags specified"。
2. 在 Deepin NetworkManager 上以 -DENABLE_DEEPIN_NMQT=ON 构建,确认
   ActivateConnection2 收到 flags,Reapply 保留 PRESERVE_DHCP。
3. 输错 Wi-Fi 密码后重试,确认密码框为空;在 Wayland/Treeland 下
   确认密码框可见,输入正确密码后连接成功。
Comment thread debian/rules Resolved
Keep the CMake option OFF by default so standard GNU/Linux builds use
the stock NetworkManager API.  The Debian packaging targets Deepin 25
and its NetworkManagerQt private extensions, so enable the option
unconditionally in debian/rules instead of probing lsb_release.

Fedora packages still pass -DENABLE_DEEPIN_NMQT=OFF.

Log: Deepin 25 Debian builds enable the private NetworkManager ABI;
other builds default to the stock API.
PMS: None
@LFRon

LFRon commented Dec 2, 2026

Copy link
Copy Markdown
Author

针对研发大佬们指出的问题, 回复如下:

  1. netwirelessconnect.cpp 的 waitForFinished()
    原来这里为了记录新增的激活错误,确实加了同步等待,破坏了原来的异步行为。现在改成 QDBusPendingCallWatcher:
    auto reply = NetworkManager::activateConnection2(conn->path(),
    m_device->path(),
    accessPointPath,
    options);
    auto *watcher = new QDBusPendingCallWatcher(reply, this);
    connect(watcher, &QDBusPendingCallWatcher::finished, watcher, watcher {
    if (watcher->isError())
    qCWarning(DNC) << "Failed to activate connection:"
    << watcher->error().message();
    watcher->deleteLater();
    });
    这样提交请求后立即返回,错误在 finished 回调里记录,和原来的异步行为一致。
    需要注意,文件里还有两处 waitForFinished():
  • addAndActivateConnection2Compat() 那一处是上游原本就同步等待的路径;
  • conn->update() 那一处也是原有代码。
    这两处不是这次为记录错误新增的阻塞,所以没有改动。开发者指的第 454 行是新增的 activateConnection2() 路径,已经改为 watcher。
  1. networksecretagent.cpp 的不可达判断
    原代码是:
    if (!requestNew && !secretStr.isEmpty()) {
    setting.insert(secretKey, secretStr);
    } else if (allowInteraction && isMustAsk(...)) {
    askItems.append(secretKey);
    if (!requestNew && !secretStr.isEmpty()) { // 永远不成立
    propMap.insert(secretKey, secretStr);
    }
    }
    进入 else if 的前提就是外层条件为假,所以内层 !requestNew && !secretStr.isEmpty() 必然为假,确实不可达。
    现在已经把整个内层分支删掉,只保留:
    } else if (allowInteraction && isMustAsk(...)) {
    askItems.append(secretKey);
    // Do not pre-fill the old secret when NetworkManager asks
    // for a new one after an authentication failure. Keeping
    // the old value makes it far too easy to resend the same
    // wrong password and loop forever.
    }
    这样既消除了不可达代码,也保证认证失败后密码框不会回填旧密码。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants