Git commit e4b5b8dab07fc9b803c8b2800069c1b5bd20a267 by Valentin Rusu. Committed on 13/08/2015 at 10:57. Pushed by vrusu into branch 'master'. All API calls should return the status along with the returned value M +10 -10 src/runtime/ksecrets_store/ksecrets_store.cpp M +29 -15 src/runtime/ksecrets_store/ksecrets_store.h http://commits.kde.org/ksecrets/e4b5b8dab07fc9b803c8b2800069c1b5bd20a267 diff --git a/src/runtime/ksecrets_store/ksecrets_store.cpp b/src/runtime/ks= ecrets_store/ksecrets_store.cpp index c3bf0d1..edeb777 100644 --- a/src/runtime/ksecrets_store/ksecrets_store.cpp +++ b/src/runtime/ksecrets_store/ksecrets_store.cpp @@ -201,33 +201,33 @@ KSecretsStorePrivate::SecretsFile::~SecretsFile() } } = -KSecretsStore::CollectionNames KSecretsStore::dirCollections() const noexc= ept +KSecretsStore::DirCollectionsResult KSecretsStore::dirCollections() const = noexcept { // TODO - return CollectionNames(); + return DirCollectionsResult(); } = -KSecretsStore::CollectionPtr KSecretsStore::createCollection(const char*) = noexcept +KSecretsStore::CreateCollectionResult KSecretsStore::createCollection(cons= t char*) noexcept { // TODO - return CollectionPtr(); + return CreateCollectionResult(); } = -KSecretsStore::CollectionPtr KSecretsStore::readCollection(const char*) co= nst noexcept +KSecretsStore::ReadCollectionResult KSecretsStore::readCollection(const ch= ar*) const noexcept { // TODO - return CollectionPtr(); + return ReadCollectionResult(); } = -bool KSecretsStore::deleteCollection(CollectionPtr) noexcept +KSecretsStore::DeleteCollectionResult KSecretsStore::deleteCollection(Coll= ectionPtr) noexcept { // TODO - return false; + return DeleteCollectionResult(); } = -bool KSecretsStore::deleteCollection(const char*) noexcept +KSecretsStore::DeleteCollectionResult KSecretsStore::deleteCollection(cons= t char*) noexcept { // TODO - return false; + return DeleteCollectionResult(); } // vim: tw=3D220:ts=3D4 diff --git a/src/runtime/ksecrets_store/ksecrets_store.h b/src/runtime/ksec= rets_store/ksecrets_store.h index bf5296d..dacdedc 100644 --- a/src/runtime/ksecrets_store/ksecrets_store.h +++ b/src/runtime/ksecrets_store/ksecrets_store.h @@ -106,6 +106,7 @@ public: = std::time_t createdTime() const noexcept; std::time_t modifiedTime() const noexcept; + protected: Item(); friend class KSecretsStore; @@ -164,7 +165,7 @@ public: * possible. So please check it via it's operator bool() before us= ing * it. */ - ItemPtr createItem(const char *label, ItemValue&&) noexcept; + ItemPtr createItem(const char* label, ItemValue&&) noexcept; = bool deleteItem(ItemPtr) noexcept; = @@ -215,13 +216,19 @@ public: * It introduces a bool() operator client applications could use to ch= eck the correct * issue of the respective API call. */ - template - struct CallResult { + template struct CallResult { StoreStatus status_; int errno_; operator bool() const { return status_ =3D=3D G; } }; = + /** + * @brief Small structure returned by API calls that create things + */ + template struct CallResultWithValue : publ= ic CallResult { + R result_; + }; + using SetupResult =3D CallResult; = /** @@ -233,7 +240,7 @@ public: * * @return SetupResult whose operator bool could be used to check the = error condition */ - std::future setup(const char* path, bool readOnly =3Dtrue= ); + std::future setup(const char* path, bool readOnly =3D tru= e); = using CredentialsResult =3D CallResult; = @@ -249,22 +256,29 @@ public: bool isGood() const noexcept; = using CollectionNames =3D std::vector; - CollectionNames dirCollections() const noexcept; - /* - * @return CollectionPtr which can empty if the call did not succeed. - * Please check that with operator bool(). - * If it fails, have you already called setup()? + using DirCollectionsResult =3D CallResultWithValue; + DirCollectionsResult dirCollections() const noexcept; + + using CreateCollectionResult =3D CallResultWithValue; + /** + * @return CollectionPtr which can empty if the call did not succeed + * Please check that with operator bool() + * If it fails, have you already called setup()? + * */ - CollectionPtr createCollection(const char*) noexcept; - /* + CreateCollectionResult createCollection(const char*) noexcept; + + using ReadCollectionResult =3D CallResultWithValue; + /** * @return CollectionPtr which can empty if the call did not succeed, = e.g. - * the collection was not found. + * the collection was not found * Please check that with operator bool() */ - CollectionPtr readCollection(const char*) const noexcept; + ReadCollectionResult readCollection(const char*) const noexcept; = - bool deleteCollection(CollectionPtr) noexcept; - bool deleteCollection(const char*) noexcept; + using DeleteCollectionResult =3D CallResultWithValue; + DeleteCollectionResult deleteCollection(CollectionPtr) noexcept; + DeleteCollectionResult deleteCollection(const char*) noexcept; = private: std::unique_ptr d;