Skip to content

Commit

Permalink
feat: [mount] add ismountbydaemon interface
Browse files Browse the repository at this point in the history
add ismountbydaemon interface

Log: add ismountbydaemon interface
Bug: https://pms.uniontech.com/bug-view-259823.html
  • Loading branch information
pppanghu77 authored and max-lvs committed Jul 5, 2024
1 parent d6d62da commit 4e23c2d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 2 additions & 0 deletions include/dfm-mount/dfm-mount/dprotocoldevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 7 additions & 2 deletions src/dfm-mount/lib/dprotocoldevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<DProtocolDevice> data;
DProtocolDevicePrivate *d { nullptr };
Expand Down Expand Up @@ -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<DDevicePrivate, DProtocolDevicePrivate>(d.data());
Expand Down
11 changes: 8 additions & 3 deletions src/dfm-mount/private/dnetworkmounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/dfm-mount/private/dnetworkmounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4e23c2d

Please sign in to comment.