diff --git a/native/android/app/src/cpp/PlatformSpecificTools.cpp b/native/android/app/src/cpp/PlatformSpecificTools.cpp --- a/native/android/app/src/cpp/PlatformSpecificTools.cpp +++ b/native/android/app/src/cpp/PlatformSpecificTools.cpp @@ -65,6 +65,13 @@ return method(cls, backupID)->toStdString(); } + static std::string getSIWEBackupMessagePath(std::string backupID) { + static const auto cls = javaClassStatic(); + static auto method = + cls->getStaticMethod("getSIWEBackupMessagePath"); + return method(cls, backupID)->toStdString(); + } + static void removeBackupDirectory() { static const auto cls = javaClassStatic(); static auto method = cls->getStaticMethod("removeBackupDirectory"); @@ -135,6 +142,15 @@ return path; } +std::string +PlatformSpecificTools::getSIWEBackupMessagePath(std::string backupID) { + std::string path; + NativeAndroidAccessProvider::runTask([&path, backupID]() { + path = PlatformSpecificToolsJavaClass::getSIWEBackupMessagePath(backupID); + }); + return path; +} + void PlatformSpecificTools::removeBackupDirectory() { NativeAndroidAccessProvider::runTask( []() { PlatformSpecificToolsJavaClass::removeBackupDirectory(); }); diff --git a/native/android/app/src/main/java/app/comm/android/fbjni/PlatformSpecificTools.java b/native/android/app/src/main/java/app/comm/android/fbjni/PlatformSpecificTools.java --- a/native/android/app/src/main/java/app/comm/android/fbjni/PlatformSpecificTools.java +++ b/native/android/app/src/main/java/app/comm/android/fbjni/PlatformSpecificTools.java @@ -87,6 +87,12 @@ return String.join(File.separator, backupDirPath, filename); } + public static String getSIWEBackupMessagePath(String backupID) { + String backupDirPath = PlatformSpecificTools.getBackupDirectoryPath(); + String filename = String.join("-", "backup", backupID, "msgbackup"); + return String.join(File.separator, backupDirPath, filename); + } + public static void removeBackupDirectory() { String backupDirPath = PlatformSpecificTools.getBackupDirectoryPath(); try { diff --git a/native/cpp/CommonCpp/Tools/PlatformSpecificTools.h b/native/cpp/CommonCpp/Tools/PlatformSpecificTools.h --- a/native/cpp/CommonCpp/Tools/PlatformSpecificTools.h +++ b/native/cpp/CommonCpp/Tools/PlatformSpecificTools.h @@ -17,6 +17,7 @@ std::string logID, bool isAttachments); static std::string getBackupUserKeysFilePath(std::string backupID); + static std::string getSIWEBackupMessagePath(std::string backupID); static void removeBackupDirectory(); }; diff --git a/native/ios/Comm/PlatformSpecificTools.mm b/native/ios/Comm/PlatformSpecificTools.mm --- a/native/ios/Comm/PlatformSpecificTools.mm +++ b/native/ios/Comm/PlatformSpecificTools.mm @@ -122,6 +122,16 @@ return [[backupDir URLByAppendingPathComponent:filename].path UTF8String]; } +std::string +PlatformSpecificTools::getSIWEBackupMessagePath(std::string backupID) { + NSURL *backupDir = getBackupDirAsURL(); + NSString *backupIDObjC = [NSString stringWithCString:backupID.c_str() + encoding:NSUTF8StringEncoding]; + NSString *filename = [@[ @"backup", backupIDObjC, @"msgbackup" ] + componentsJoinedByString:@"-"]; + return [[backupDir URLByAppendingPathComponent:filename].path UTF8String]; +} + void PlatformSpecificTools::removeBackupDirectory() { NSURL *backupDir = getBackupDirAsURL(); if (![NSFileManager.defaultManager fileExistsAtPath:backupDir.path]) { diff --git a/native/native_rust_library/RustBackupExecutor.h b/native/native_rust_library/RustBackupExecutor.h --- a/native/native_rust_library/RustBackupExecutor.h +++ b/native/native_rust_library/RustBackupExecutor.h @@ -9,6 +9,7 @@ rust::String getBackupLogFilePath(rust::Str backupID, rust::Str logID, bool isAttachments); rust::String getBackupUserKeysFilePath(rust::Str backupID); +rust::String getSIWEBackupMessagePath(rust::Str backupID); void createMainCompaction(rust::Str backupID, size_t futureID); void restoreFromMainCompaction( rust::Str mainCompactionPath, diff --git a/native/native_rust_library/RustBackupExecutor.cpp b/native/native_rust_library/RustBackupExecutor.cpp --- a/native/native_rust_library/RustBackupExecutor.cpp +++ b/native/native_rust_library/RustBackupExecutor.cpp @@ -26,6 +26,11 @@ PlatformSpecificTools::getBackupUserKeysFilePath(std::string(backupID))); } +rust::String getSIWEBackupMessagePath(rust::Str backupID) { + return rust::String( + PlatformSpecificTools::getSIWEBackupMessagePath(std::string(backupID))); +} + void createMainCompaction(rust::Str backupID, size_t futureID) { BackupOperationsExecutor::createMainCompaction( std::string(backupID), futureID); diff --git a/native/native_rust_library/src/lib.rs b/native/native_rust_library/src/lib.rs --- a/native/native_rust_library/src/lib.rs +++ b/native/native_rust_library/src/lib.rs @@ -401,6 +401,9 @@ #[cxx_name = "getBackupUserKeysFilePath"] fn get_backup_user_keys_file_path(backup_id: &str) -> Result; + #[cxx_name = "getSIWEBackupMessagePath"] + fn get_siwe_backup_message_path(backup_id: &str) -> Result; + #[cxx_name = "createMainCompaction"] fn create_main_compaction(backup_id: &str, future_id: usize);