mirror of
https://github.com/linuxdeepin/gio-qt.git
synced 2024-12-26 06:56:25 +01:00
feat:add Wrapper of Gio::File::mount_enclosing_volume
use DGioFile::mountEnclosingVolume to mount "smb://..."
This commit is contained in:
parent
4c412bb5bf
commit
1912f6f4e0
4 changed files with 46 additions and 0 deletions
|
@ -38,6 +38,7 @@ Q_DECLARE_FLAGS(DGioFileQueryInfoFlags, DGioFileQueryInfoFlag)
|
|||
|
||||
class DGioFileInfo;
|
||||
class DGioFileIterator;
|
||||
class DGioMountOperation;
|
||||
class DGioFilePrivate;
|
||||
class DGioFile : public QObject, public QSharedData
|
||||
{
|
||||
|
@ -58,8 +59,11 @@ public:
|
|||
QExplicitlySharedDataPointer<DGioFileIterator> createFileIterator(QString attr = "*", DGioFileQueryInfoFlags queryInfoFlags = FILE_QUERY_INFO_NONE);
|
||||
void createFileIteratorAsync(QString attr = "*", DGioFileQueryInfoFlags queryInfoFlags = FILE_QUERY_INFO_NONE);
|
||||
|
||||
void mountEnclosingVolume(DGioMountOperation *dgioMountOperation);
|
||||
|
||||
Q_SIGNALS:
|
||||
void createFileIteratorReady(QExplicitlySharedDataPointer<DGioFileIterator> iter);
|
||||
void mountEnclosingVolumeReady(bool result, QString msg);
|
||||
|
||||
private:
|
||||
QScopedPointer<DGioFilePrivate> d_ptr;
|
||||
|
|
|
@ -23,6 +23,14 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
namespace Glib{
|
||||
template <class T_CppObject>
|
||||
class RefPtr;
|
||||
}
|
||||
namespace Gio{
|
||||
class MountOperation;
|
||||
}
|
||||
|
||||
enum DGioAskPasswordFlag
|
||||
{
|
||||
ASK_PASSWORD_NEED_PASSWORD = (1 << 0),
|
||||
|
@ -77,6 +85,9 @@ public:
|
|||
|
||||
void reply(DGioMountOperationResult result);
|
||||
|
||||
// do not release the ptr returned
|
||||
Glib::RefPtr<Gio::MountOperation> getGIOMountOperationObj();
|
||||
|
||||
Q_SIGNALS:
|
||||
void askPassword(QString message, QString defaultUser, QString defaultDomain, DGioAskPasswordFlags flags);
|
||||
void askQuestion(QString message, QStringList choices);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <giomm/fileenumerator.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <dgiomountoperation.h>
|
||||
|
||||
using namespace Gio;
|
||||
|
||||
|
@ -48,6 +49,8 @@ private:
|
|||
|
||||
void slot_enumerateChildrenAsyncResult(const Glib::RefPtr<Gio::AsyncResult>& result);
|
||||
|
||||
void slot_mountEnclosingVolumeResult(const Glib::RefPtr<Gio::AsyncResult>& result);
|
||||
|
||||
Q_DECLARE_PUBLIC(DGioFile)
|
||||
};
|
||||
|
||||
|
@ -82,6 +85,20 @@ void DGioFilePrivate::slot_enumerateChildrenAsyncResult(const Glib::RefPtr<Async
|
|||
}
|
||||
}
|
||||
|
||||
void DGioFilePrivate::slot_mountEnclosingVolumeResult(const Glib::RefPtr<AsyncResult> &result)
|
||||
{
|
||||
Q_Q(DGioFile);
|
||||
|
||||
try {
|
||||
bool res = m_gmmFilePtr->mount_enclosing_volume_finish(result);
|
||||
|
||||
Q_EMIT q->mountEnclosingVolumeReady(res, "");
|
||||
} catch (const Glib::Error & error) {
|
||||
qDebug() << QString::fromStdString(error.what().raw());
|
||||
Q_EMIT q->mountEnclosingVolumeReady(false, QString::fromStdString(error.what().raw()));
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
|
||||
DGioFile::DGioFile(File* gmmFilePtr, QObject *parent)
|
||||
|
@ -293,3 +310,11 @@ void DGioFile::createFileIteratorAsync(QString attr, DGioFileQueryInfoFlags quer
|
|||
d->getGmmFileInstance()->enumerate_children_async(sigc::mem_fun(d, &DGioFilePrivate::slot_enumerateChildrenAsyncResult),
|
||||
attr.toStdString(), flags);
|
||||
}
|
||||
|
||||
void DGioFile::mountEnclosingVolume(DGioMountOperation *dgioMountOperation)
|
||||
{
|
||||
Q_D(DGioFile);
|
||||
|
||||
d->getGmmFileInstance()->mount_enclosing_volume(dgioMountOperation->getGIOMountOperationObj(),
|
||||
sigc::mem_fun(d, &DGioFilePrivate::slot_mountEnclosingVolumeResult));
|
||||
}
|
||||
|
|
|
@ -200,3 +200,9 @@ void DGioMountOperation::reply(DGioMountOperationResult result)
|
|||
|
||||
d->getGmmMountOperationInstance()->reply(static_cast<MountOperationResult>(result));
|
||||
}
|
||||
|
||||
Glib::RefPtr<MountOperation> DGioMountOperation::getGIOMountOperationObj()
|
||||
{
|
||||
Q_D(const DGioMountOperation);
|
||||
return d->getGmmMountOperationInstance();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue