From 4e23c2dcb27f3c835301d72655aa566df0fa2a07 Mon Sep 17 00:00:00 2001 From: liujinchang Date: Tue, 2 Jul 2024 14:39:32 +0800 Subject: [PATCH] feat: [mount] add ismountbydaemon interface add ismountbydaemon interface Log: add ismountbydaemon interface Bug: https://pms.uniontech.com/bug-view-259823.html --- include/dfm-mount/dfm-mount/dprotocoldevice.h | 2 ++ src/dfm-mount/lib/dprotocoldevice.cpp | 9 +++++++-- src/dfm-mount/private/dnetworkmounter.cpp | 11 ++++++++--- src/dfm-mount/private/dnetworkmounter.h | 1 + 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/dfm-mount/dfm-mount/dprotocoldevice.h b/include/dfm-mount/dfm-mount/dprotocoldevice.h index 2917331..616063e 100644 --- a/include/dfm-mount/dfm-mount/dprotocoldevice.h +++ b/include/dfm-mount/dfm-mount/dprotocoldevice.h @@ -42,6 +42,8 @@ class DProtocolDevice final : public DDevice GetUserChoice getUserChoice, DeviceOperateCallbackWithMessage mountResult, int secs = 0); + static bool isMountByDaemon(const QString &address); + void setOperatorTimeout(int msecs); private: diff --git a/src/dfm-mount/lib/dprotocoldevice.cpp b/src/dfm-mount/lib/dprotocoldevice.cpp index 44075dd..9ddba63 100644 --- a/src/dfm-mount/lib/dprotocoldevice.cpp +++ b/src/dfm-mount/lib/dprotocoldevice.cpp @@ -25,9 +25,9 @@ struct CallbackProxyWithData { CallbackProxyWithData() = delete; explicit CallbackProxyWithData(DeviceOperateCallback cb) - : caller(cb) { } + : caller(cb) {} explicit CallbackProxyWithData(DeviceOperateCallbackWithMessage cb) - : caller(cb) { } + : caller(cb) {} CallbackProxy caller; QPointer data; DProtocolDevicePrivate *d { nullptr }; @@ -151,6 +151,11 @@ void DProtocolDevice::mountNetworkDevice(const QString &address, GetMountPassInf DNetworkMounter::mountNetworkDev(address, getPassInfo, getUserChoice, mountResult, secs); } +bool DProtocolDevice::isMountByDaemon(const QString &address) +{ + return DNetworkMounter::isMountByDae(address); +} + void DProtocolDevice::setOperatorTimeout(int msecs) { auto dp = Utils::castClassFromTo(d.data()); diff --git a/src/dfm-mount/private/dnetworkmounter.cpp b/src/dfm-mount/private/dnetworkmounter.cpp index d23cd77..c857f97 100644 --- a/src/dfm-mount/private/dnetworkmounter.cpp +++ b/src/dfm-mount/private/dnetworkmounter.cpp @@ -177,14 +177,19 @@ void DNetworkMounter::mountNetworkDev(const QString &address, GetMountPassInfo g GetUserChoice getUserChoice, DeviceOperateCallbackWithMessage mountResult, int secs) { - QUrl u(address); - // don't mount samba's root by Daemon - if (u.scheme() == "smb" && !u.path().remove("/").isEmpty() && isDaemonMountEnable()) + if (isMountByDae(address)) mountByDaemon(address, getPassInfo, mountResult, secs); else mountByGvfs(address, getPassInfo, getUserChoice, mountResult, secs); } +bool DNetworkMounter::isMountByDae(const QString &address) +{ + QUrl u(address); + // don't mount samba's root by Daemon + return u.scheme() == "smb" && !u.path().remove("/").isEmpty() && isDaemonMountEnable(); +} + bool DNetworkMounter::unmountNetworkDev(const QString &mpt) { QDBusInterface mntCtrl(kDaemonService, kMountControlPath, kMountControlIFace, diff --git a/src/dfm-mount/private/dnetworkmounter.h b/src/dfm-mount/private/dnetworkmounter.h index 37dbd71..9a3c968 100644 --- a/src/dfm-mount/private/dnetworkmounter.h +++ b/src/dfm-mount/private/dnetworkmounter.h @@ -21,6 +21,7 @@ class DNetworkMounter { public: static bool isDaemonMountEnable(); + static bool isMountByDae(const QString &address); static void mountNetworkDev(const QString &, GetMountPassInfo, GetUserChoice, DeviceOperateCallbackWithMessage, int); static bool unmountNetworkDev(const QString &); static void unmountNetworkDevAsync(const QString &, DeviceOperateCallback);