From 7bef27bc0a7464795bae4beaf95e3aadf8f4dcda Mon Sep 17 00:00:00 2001 From: kegechen Date: Sat, 3 Aug 2019 11:06:15 +0800 Subject: [PATCH] feat:add Wrapper of Gio::Mount and Gio::MountOperation (#16) * fix: move test code to test project * feat:add Wrapper of Gio::Mount and Gio::MountOperation --- gio-qt/include/dgiomount.h | 2 + gio-qt/include/dgiomountoperation.h | 20 ++++++++ gio-qt/source/dgiomount.cpp | 7 +++ gio-qt/source/dgiomountoperation.cpp | 77 ++++++++++++++++++++++++++++ test/tst_matchgioenum.cpp | 4 ++ 5 files changed, 110 insertions(+) diff --git a/gio-qt/include/dgiomount.h b/gio-qt/include/dgiomount.h index 37c6245..e8982e4 100644 --- a/gio-qt/include/dgiomount.h +++ b/gio-qt/include/dgiomount.h @@ -54,6 +54,8 @@ public: QExplicitlySharedDataPointer getDefaultLocationFile(); QExplicitlySharedDataPointer getVolume(); + QString getSortKey()const; + private: QScopedPointer d_ptr; diff --git a/gio-qt/include/dgiomountoperation.h b/gio-qt/include/dgiomountoperation.h index ecf779c..f8536cf 100644 --- a/gio-qt/include/dgiomountoperation.h +++ b/gio-qt/include/dgiomountoperation.h @@ -45,6 +45,14 @@ enum DGioMountOperationResult }; Q_ENUMS(DGioMountOperationResult); +enum DGioPasswordSave +{ + PASSWORD_SAVE_NEVER, + PASSWORD_SAVE_FOR_SESSION, + PASSWORD_SAVE_PERMANENTLY +}; +Q_ENUMS(DGioPasswordSave); + class DGioMountOperationPrivate; class DGioMountOperation : public QObject { @@ -54,6 +62,18 @@ public: ~DGioMountOperation(); QString username() const; + void setUsername(QString name); + QString password() const; + void setPassword(QString password); + DGioPasswordSave passwordSave(); + void setPasswordSave(DGioPasswordSave save); + QString domain() const; + void setDomain(QString domain); + + bool anonymous()const; + void setAnonymous(bool anonymous = true); + int choice()const; + void setChoice(int choice); void reply(DGioMountOperationResult result); diff --git a/gio-qt/source/dgiomount.cpp b/gio-qt/source/dgiomount.cpp index d195155..8c106ee 100644 --- a/gio-qt/source/dgiomount.cpp +++ b/gio-qt/source/dgiomount.cpp @@ -227,3 +227,10 @@ QExplicitlySharedDataPointer DGioMount::getVolume() return QExplicitlySharedDataPointer(nullptr); } +QString DGioMount::getSortKey()const +{ + Q_D(const DGioMount); + + return QString::fromStdString(d->getGmmMountInstance()->get_sort_key()); +} + diff --git a/gio-qt/source/dgiomountoperation.cpp b/gio-qt/source/dgiomountoperation.cpp index 2115888..07e43ec 100644 --- a/gio-qt/source/dgiomountoperation.cpp +++ b/gio-qt/source/dgiomountoperation.cpp @@ -117,6 +117,83 @@ QString DGioMountOperation::username() const return d->username(); } +void DGioMountOperation::setUsername(QString name) +{ + Q_D(DGioMountOperation); + + d->getGmmMountOperationInstance()->set_username(name.toStdString()); +} + +QString DGioMountOperation::password() const +{ + Q_D(const DGioMountOperation); + + return QString::fromStdString(d->getGmmMountOperationInstance()->get_password()); +} + +void DGioMountOperation::setPassword(QString password) +{ + Q_D(DGioMountOperation); + + d->getGmmMountOperationInstance()->set_password(password.toStdString()); +} + +DGioPasswordSave DGioMountOperation::passwordSave() +{ + Q_D(const DGioMountOperation); + + return static_cast(d->getGmmMountOperationInstance()->get_password_save()); +} + +void DGioMountOperation::setPasswordSave(DGioPasswordSave save) +{ + Q_D(DGioMountOperation); + + d->getGmmMountOperationInstance()->set_password_save(static_cast(save)); +} + +QString DGioMountOperation::domain() const +{ + Q_D(const DGioMountOperation); + + return QString::fromStdString(d->getGmmMountOperationInstance()->get_domain()); +} + +void DGioMountOperation::setDomain(QString domain) +{ + Q_D(DGioMountOperation); + + d->getGmmMountOperationInstance()->set_domain(domain.toStdString()); +} + +bool DGioMountOperation::anonymous() const +{ + Q_D(const DGioMountOperation); + + return d->getGmmMountOperationInstance()->get_anonymous(); +} + +void DGioMountOperation::setAnonymous(bool anonymous) +{ + Q_D(DGioMountOperation); + + d->getGmmMountOperationInstance()->set_anonymous(anonymous); +} + +int DGioMountOperation::choice() const +{ + Q_D(const DGioMountOperation); + + return d->getGmmMountOperationInstance()->get_choice(); +} + +void DGioMountOperation::setChoice(int choice) +{ + Q_D(DGioMountOperation); + + d->getGmmMountOperationInstance()->set_choice(choice); +} + void DGioMountOperation::reply(DGioMountOperationResult result) { Q_D(DGioMountOperation); diff --git a/test/tst_matchgioenum.cpp b/test/tst_matchgioenum.cpp index bf98a68..28a16ec 100644 --- a/test/tst_matchgioenum.cpp +++ b/test/tst_matchgioenum.cpp @@ -53,6 +53,10 @@ void DGioMatchGioEnumTest::testCase_DGioMountOperationClass() QCOMPARE(DGioAskPasswordFlag::ASK_PASSWORD_NEED_PASSWORD, Gio::ASK_PASSWORD_NEED_PASSWORD); QCOMPARE(DGioAskPasswordFlag::ASK_PASSWORD_NEED_DOMAIN, Gio::ASK_PASSWORD_NEED_DOMAIN); QCOMPARE(DGioAskPasswordFlag::ASK_PASSWORD_ANONYMOUS_SUPPORTED, Gio::ASK_PASSWORD_ANONYMOUS_SUPPORTED); + + QCOMPARE(DGioMountOperationResult::MOUNT_OPERATION_ABORTED, Gio::MountOperationResult::MOUNT_OPERATION_ABORTED); + QCOMPARE(DGioMountOperationResult::MOUNT_OPERATION_HANDLED, Gio::MountOperationResult::MOUNT_OPERATION_HANDLED); + QCOMPARE(DGioMountOperationResult::MOUNT_OPERATION_UNHANDLED, Gio::MountOperationResult::MOUNT_OPERATION_UNHANDLED); } QTEST_APPLESS_MAIN(DGioMatchGioEnumTest)