Skip to content
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

feat: [mount] add ismountbydaemon interface #77

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading