diff --git a/native/cpp/CommonCpp/BlobClient/BlobClient.h b/native/cpp/CommonCpp/BlobClient/BlobClient.h new file mode 100644 --- /dev/null +++ b/native/cpp/CommonCpp/BlobClient/BlobClient.h @@ -0,0 +1,17 @@ +#include "lib.rs.h" + +#include +#include + +namespace comm { +class UploadBlobClient { + std::unique_ptr<::rust::Box<::UploadState>> uploadState; + +public: + UploadBlobClient(); + void startUploadBlocking(const std::string &holder, const std::string &hash); + void uploadChunkBlocking(std::uint8_t *chunk, size_t chunk_length); + bool completeUploadBlocking(); + ~UploadBlobClient(); +}; +} // namespace comm diff --git a/native/cpp/CommonCpp/BlobClient/BlobClient.cpp b/native/cpp/CommonCpp/BlobClient/BlobClient.cpp new file mode 100644 --- /dev/null +++ b/native/cpp/CommonCpp/BlobClient/BlobClient.cpp @@ -0,0 +1,32 @@ +#include "./BlobClient.h" + +namespace comm { +UploadBlobClient::UploadBlobClient() { + this->uploadState = std::make_unique<::rust::Box<::UploadState>>( + ::initialize_upload_state_blocking()); +} + +void UploadBlobClient::startUploadBlocking( + const std::string &holder, + const std::string &hash) { + ::start_upload_blocking(*this->uploadState, holder, hash); +} + +void UploadBlobClient::uploadChunkBlocking( + std::uint8_t *chunk, + size_t chunk_length) { + ::upload_chunk_blocking( + *this->uploadState, + ::rust::Slice(chunk, chunk_length)); +} + +bool UploadBlobClient::completeUploadBlocking() { + return ::complete_upload_blocking(std::move(*this->uploadState.release())); +} + +UploadBlobClient::~UploadBlobClient() { + if (this->uploadState) { + ::complete_upload_blocking(std::move(*this->uploadState.release())); + } +} +} // namespace comm diff --git a/native/ios/Comm.xcodeproj/project.pbxproj b/native/ios/Comm.xcodeproj/project.pbxproj --- a/native/ios/Comm.xcodeproj/project.pbxproj +++ b/native/ios/Comm.xcodeproj/project.pbxproj @@ -67,6 +67,7 @@ CB4821AF27CFB19D001AB7E1 /* PlatformSpecificTools.mm in Sources */ = {isa = PBXBuildFile; fileRef = 71762A74270D8AAE00F565ED /* PlatformSpecificTools.mm */; }; CB4821B127CFB1FA001AB7E1 /* GlobalNetworkSingleton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 726E5D762731A5E10032361D /* GlobalNetworkSingleton.cpp */; }; CB4821B227CFB20E001AB7E1 /* SQLiteQueryExecutor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 71BE84412636A944002849D2 /* SQLiteQueryExecutor.cpp */; }; + CBDA4E7B28D8A28D00203CE4 /* BlobClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CBDA4E7928D8A28D00203CE4 /* BlobClient.cpp */; }; CBFE58292885852B003B94C9 /* ThreadOperations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CBFE58282885852B003B94C9 /* ThreadOperations.cpp */; }; D7DB6E0F85B2DBE15B01EC21 /* libPods-Comm.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 994BEBDD4E4959F69CEA0BC3 /* libPods-Comm.a */; }; F02C296C528B51ADAB5AA19D /* libPods-NotificationService.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3EE4DCB430B05EC9DE7D7B01 /* libPods-NotificationService.a */; }; @@ -222,6 +223,8 @@ CB38F2BE286C6C980010535C /* DeleteEntryMessageSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DeleteEntryMessageSpec.h; path = PersistentStorageUtilities/MessageOperationsUtilities/MessageSpecs/DeleteEntryMessageSpec.h; sourceTree = ""; }; CB38F2BF286C6C980010535C /* UpdateRelationshipMessageSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UpdateRelationshipMessageSpec.h; path = PersistentStorageUtilities/MessageOperationsUtilities/MessageSpecs/UpdateRelationshipMessageSpec.h; sourceTree = ""; }; CB3C621327CE66540054F24C /* libEXSecureStore.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libEXSecureStore.a; sourceTree = BUILT_PRODUCTS_DIR; }; + CBDA4E7928D8A28D00203CE4 /* BlobClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BlobClient.cpp; path = BlobClient/BlobClient.cpp; sourceTree = ""; }; + CBDA4E7A28D8A28D00203CE4 /* BlobClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BlobClient.h; path = BlobClient/BlobClient.h; sourceTree = ""; }; CBFE58272885852B003B94C9 /* ThreadOperations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadOperations.h; path = PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperations.h; sourceTree = ""; }; CBFE58282885852B003B94C9 /* ThreadOperations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadOperations.cpp; path = PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperations.cpp; sourceTree = ""; }; F53DA7B3F26C2798DCE74A94 /* Pods-Comm.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Comm.debug.xcconfig"; path = "Target Support Files/Pods-Comm/Pods-Comm.debug.xcconfig"; sourceTree = ""; }; @@ -353,6 +356,7 @@ 71BE84372636A944002849D2 /* CommonCpp */ = { isa = PBXGroup; children = ( + CBDA4E7828D8A27B00203CE4 /* BlobClient */, 71F971B4270726C000DDC5BF /* _generated */, 718A3C0426F22BD100F04A8D /* grpc */, 71BF5B6A26B3FCFF00EDE27D /* CryptoTools */, @@ -584,6 +588,15 @@ name = MessageSpecs; sourceTree = ""; }; + CBDA4E7828D8A27B00203CE4 /* BlobClient */ = { + isa = PBXGroup; + children = ( + CBDA4E7928D8A28D00203CE4 /* BlobClient.cpp */, + CBDA4E7A28D8A28D00203CE4 /* BlobClient.h */, + ); + name = BlobClient; + sourceTree = ""; + }; CBED0E2C284E086100CD3863 /* PersistentStorageUtilities */ = { isa = PBXGroup; children = ( @@ -1029,6 +1042,7 @@ 71762A75270D8AAE00F565ED /* PlatformSpecificTools.mm in Sources */, 71BF5B7126B3FF0900EDE27D /* Session.cpp in Sources */, 726E5D752731A4790032361D /* NetworkModule.cpp in Sources */, + CBDA4E7B28D8A28D00203CE4 /* BlobClient.cpp in Sources */, 71BF5B7526B401D300EDE27D /* Tools.cpp in Sources */, 13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */, 71142A7726C2650B0039DCBD /* CommSecureStoreIOSWrapper.mm in Sources */,