-
Notifications
You must be signed in to change notification settings - Fork 28
fix: update DBus service names for Qt6 compatibility #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Changed DBus service names and paths to use new naming convention for Qt6 version while maintaining backward compatibility with Qt5. The old service names 'com.deepin.filemanager.daemon' are replaced with 'org.deepin.Filemanager.MountControl' for Qt6 builds. Also removed unused error message key constant and improved code formatting for consistency. Log: Fixed network mount functionality for Qt6 compatibility Influence: 1. Test network device mounting and unmounting on both Qt5 and Qt6 environments 2. Verify DBus communication with the mount control service 3. Check error handling for authentication failures and authorization dismissals 4. Test network operations with different file protocols (SMB, etc.) fix: 更新 DBus 服务名称以支持 Qt6 兼容性 修改了 DBus 服务名称和路径,在 Qt6 版本中使用新的 命名约定,同时保持对 Qt5 的向后兼容性。Qt6 构建中将 旧的服务名称 'com.deepin.filemanager.daemon' 替换为 'org.deepin.Filemanager.MountControl'。同时移除了未使用的错误消息键常 量,并改进了代码格式以保持一致性。 Log: 修复网络挂载功能以支持 Qt6 兼容性 Influence: 1. 在 Qt5 和 Qt6 环境中测试网络设备的挂载和卸载功能 2. 验证与挂载控制服务的 DBus 通信 3. 检查认证失败和授权取消的错误处理 4. 测试不同文件协议(SMB 等)的网络操作
deepin pr auto review这段代码主要进行了一些重构和兼容性调整,以下是对代码的详细审查和改进建议: 1. 语法逻辑审查优点:
问题与建议:
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
static constexpr char kDaemonService[] { "org.deepin.Filemanager.MountControl" };
// ...
#else
static constexpr char kDaemonService[] { "com.deepin.filemanager.daemon" };
// ...
#endif
if (e.type() == QDBusError::NoReply || name == QStringLiteral("org.freedesktop.DBus.Error.NoReply")) {
2. 代码质量审查优点:
改进建议:
namespace DBusConstants {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
static constexpr char kDaemonService[] { "org.deepin.Filemanager.MountControl" };
#else
static constexpr char kDaemonService[] { "com.deepin.filemanager.daemon" };
#endif
// 其他常量...
}
if (name == QStringLiteral("org.freedesktop.DBus.Error.NoReply")) {
if (name == QLatin1String("org.freedesktop.DBus.Error.NoReply")) {
3. 代码性能审查
4. 代码安全审查
bool DNetworkMounter::unmountNetworkDevAsyncDetailed(const QString &mpt, int *errCode, QString *errMsg) {
if (mpt.isEmpty() || mpt.contains("..")) {
if (errCode) *errCode = static_cast<int>(DeviceError::kUserError);
if (errMsg) *errMsg = QStringLiteral("Invalid mount point");
return false;
}
// ...
}
5. 其他建议
修改后的代码示例:namespace DBusConstants {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
static constexpr char kDaemonService[] { "org.deepin.Filemanager.MountControl" };
static constexpr char kDaemonPath[] { "/org/deepin/Filemanager" };
static constexpr char kMountControlPath[] { "/org/deepin/Filemanager/MountControl" };
static constexpr char kMountControlIFace[] { "org.deepin.Filemanager.MountControl" };
#else
static constexpr char kDaemonService[] { "com.deepin.filemanager.daemon" };
static constexpr char kDaemonPath[] { "/com/deepin/filemanager/daemon" };
static constexpr char kMountControlPath[] { "/com/deepin/filemanager/daemon/MountControl" };
static constexpr char kMountControlIFace[] { "com.deepin.filemanager.daemon.MountControl" };
#endif
static constexpr char kDaemonIntro[] { "org.freedesktop.DBus.Introspectable" };
static constexpr char kDaemonIntroMethod[] { "Introspect" };
static constexpr char kMountControlMount[] { "Mount" };
static constexpr char kMountControlUnmount[] { "Unmount" };
}
bool DNetworkMounter::unmountNetworkDevAsyncDetailed(const QString &mpt, int *errCode, QString *errMsg) {
// 输入验证
if (mpt.isEmpty() || mpt.contains("..")) {
if (errCode) *errCode = static_cast<int>(DeviceError::kUserError);
if (errMsg) *errMsg = QStringLiteral("Invalid mount point");
return false;
}
// ... 其他代码 ...
if (!ret.isValid()) {
const auto &e = ret.error();
if (e.type() == QDBusError::NoReply) {
if (errCode) *errCode = static_cast<int>(DFMMOUNT::DeviceError::kGDBusErrorNoReply);
if (errMsg) *errMsg = QStringLiteral("Authorization pending (NoReply)");
return false;
}
// ... 其他错误处理 ...
}
// ... 其他代码 ...
}这些改进将使代码更加健壮、安全和易于维护。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: itsXuSt, Johnson-zs The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Changed DBus service names and paths to use new naming convention for Qt6 version while maintaining backward compatibility with Qt5. The old service names 'com.deepin.filemanager.daemon' are replaced with 'org.deepin.Filemanager.MountControl' for Qt6 builds. Also removed unused error message key constant and improved code formatting for consistency.
Log: Fixed network mount functionality for Qt6 compatibility
Influence:
fix: 更新 DBus 服务名称以支持 Qt6 兼容性
修改了 DBus 服务名称和路径,在 Qt6 版本中使用新的
命名约定,同时保持对 Qt5 的向后兼容性。Qt6 构建中将
旧的服务名称 'com.deepin.filemanager.daemon' 替换为
'org.deepin.Filemanager.MountControl'。同时移除了未使用的错误消息键常 量,并改进了代码格式以保持一致性。
Log: 修复网络挂载功能以支持 Qt6 兼容性
Influence: