From d919f49c9daa2db08fda3a3981129e9d87ee1921 Mon Sep 17 00:00:00 2001 From: Yenel Date: Tue, 16 Jan 2024 14:46:51 +0100 Subject: [PATCH 1/5] Add Android bindings --- bindings/java/nz/mega/sdk/MegaApiJava.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bindings/java/nz/mega/sdk/MegaApiJava.java b/bindings/java/nz/mega/sdk/MegaApiJava.java index af3cecb251..f6cbc6163b 100644 --- a/bindings/java/nz/mega/sdk/MegaApiJava.java +++ b/bindings/java/nz/mega/sdk/MegaApiJava.java @@ -230,7 +230,7 @@ void runCallback(Runnable runnable) { public final static int FILE_TYPE_PHOTO = MegaApi.FILE_TYPE_PHOTO; public final static int FILE_TYPE_AUDIO = MegaApi.FILE_TYPE_AUDIO; public final static int FILE_TYPE_VIDEO = MegaApi.FILE_TYPE_VIDEO; - public final static int FILE_TYPE_DOCUMENT = MegaApi.FILE_TYPE_DOCUMENT; + public final static int FILE_TYPE_ALL_DOCS = MegaApi.FILE_TYPE_ALL_DOCS; public final static int SEARCH_TARGET_INSHARE = MegaApi.SEARCH_TARGET_INSHARE; public final static int SEARCH_TARGET_OUTSHARE = MegaApi.SEARCH_TARGET_OUTSHARE; @@ -9396,7 +9396,7 @@ public ArrayList searchOnPublicLinks(String searchString, @NotNull Meg * - MegaApi::FILE_TYPE_PHOTO = 1 * - MegaApi::FILE_TYPE_AUDIO = 2 * - MegaApi::FILE_TYPE_VIDEO = 3 - * - MegaApi::FILE_TYPE_DOCUMENT = 4 + * - MegaApi::FILE_TYPE_ALL_DOCS = 4 * @param target Target type where this method will search * Valid values for this parameter are * - SEARCH_TARGET_INSHARE = 0 @@ -9472,7 +9472,7 @@ public ArrayList searchByType(MegaNode node, String searchString, * - MegaApi::FILE_TYPE_PHOTO = 1 * - MegaApi::FILE_TYPE_AUDIO = 2 * - MegaApi::FILE_TYPE_VIDEO = 3 - * - MegaApi::FILE_TYPE_DOCUMENT = 4 + * - MegaApi::FILE_TYPE_ALL_DOCS = 4 * @param target Target type where this method will search * Valid values for this parameter are * - SEARCH_TARGET_INSHARE = 0 @@ -9562,7 +9562,7 @@ public ArrayList searchByType(@NotNull MegaCancelToken cancelToken, in * - MegaApi::FILE_TYPE_PHOTO = 1 * - MegaApi::FILE_TYPE_AUDIO = 2 * - MegaApi::FILE_TYPE_VIDEO = 3 - * - MegaApi::FILE_TYPE_DOCUMENT = 4 + * - MegaApi::FILE_TYPE_ALL_DOCS = 4 * @return List of nodes that match with the search parameters */ public ArrayList searchByType(MegaNode node, String searchString, From 6992ee792f5936f2ca54d738ee7f6b5c4c325ba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kuz=CC=81ma?= Date: Tue, 16 Jan 2024 15:28:07 +0100 Subject: [PATCH 2/5] SDK-3536: Add iOS bindings for AllDocs node type, update documentation --- bindings/ios/include/MEGASdk.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bindings/ios/include/MEGASdk.h b/bindings/ios/include/MEGASdk.h index a497263d17..6287599b25 100644 --- a/bindings/ios/include/MEGASdk.h +++ b/bindings/ios/include/MEGASdk.h @@ -101,7 +101,8 @@ typedef NS_ENUM (NSInteger, MEGANodeFormatType) { MEGANodeFormatTypeArchive, MEGANodeFormatTypeProgram, MEGANodeFormatTypeMisc, - MEGANodeFormatTypeSpreadsheet + MEGANodeFormatTypeSpreadsheet, + MEGANodeFormatTypeAllDocs }; typedef NS_ENUM (NSInteger, MEGAFolderTargetType) { @@ -8216,6 +8217,13 @@ typedef NS_ENUM(NSInteger, AdsFlag) { * - MEGANodeFormatTypeAudio = 2 * - MEGANodeFormatTypeVideo = 3 * - MEGANodeFormatTypeDocument = 4 + * - MEGANodeFormatTypePdf = 5, + * - MEGANodeFormatTypePresentation = 6, + * - MEGANodeFormatTypeArchive = 7, + * - MEGANodeFormatTypeProgram = 8, + * - MEGANodeFormatTypeMisc = 9, + * - MEGANodeFormatTypeSpreadsheet = 10, + * - MEGANodeFormatTypeAllDocs = 11 * * @param folderTargetType Target type where this method will search * Valid values for this parameter are From 15c88016d2516049ed99d99610d1af1b81244e4b Mon Sep 17 00:00:00 2001 From: Catalin Date: Tue, 16 Jan 2024 16:49:11 +0200 Subject: [PATCH 3/5] Add support for Spreadsheet type to (deprecated) searchByType() --- include/mega/megaclient.h | 3 +++ src/megaapi_impl.cpp | 2 ++ src/megaclient.cpp | 5 +++++ tests/integration/SdkTest_test.cpp | 6 ++++++ 4 files changed, 16 insertions(+) diff --git a/include/mega/megaclient.h b/include/mega/megaclient.h index c60f8f1fb5..6972956007 100644 --- a/include/mega/megaclient.h +++ b/include/mega/megaclient.h @@ -1884,6 +1884,9 @@ class MEGA_API MegaClient // determine if the file is miscellaneous. bool nodeIsMiscellaneous(const Node* n) const; + // determine if the file is a spreadsheet. + bool nodeIsSpreadsheet(const Node* n) const; + // functions for determining whether we can clone a node instead of upload // or whether two files are the same so we can just upload/download the data once bool treatAsIfFileDataEqual(const FileFingerprint& nodeFingerprint, const LocalPath& file2, const string& filenameExtensionLowercaseNoDot); diff --git a/src/megaapi_impl.cpp b/src/megaapi_impl.cpp index cd36b32c0b..48d948fcd7 100644 --- a/src/megaapi_impl.cpp +++ b/src/megaapi_impl.cpp @@ -11946,6 +11946,8 @@ bool MegaApiImpl::isValidTypeNode(const Node *node, int type) const return client->nodeIsProgram(node); case MegaApi::FILE_TYPE_MISC: return client->nodeIsMiscellaneous(node); + case MegaApi::FILE_TYPE_SPREADSHEET: + return client->nodeIsSpreadsheet(node); case MegaApi::FILE_TYPE_DEFAULT: default: return true; diff --git a/src/megaclient.cpp b/src/megaclient.cpp index f9011f8386..5d518fc3f3 100644 --- a/src/megaclient.cpp +++ b/src/megaclient.cpp @@ -17020,6 +17020,11 @@ bool MegaClient::nodeIsMiscellaneous(const Node* n) const return n->isIncludedForMimetype(MimeType_t::MIME_TYPE_MISC); } +bool MegaClient::nodeIsSpreadsheet(const Node *n) const +{ + return n->isIncludedForMimetype(MimeType_t::MIME_TYPE_SPREADSHEET); +} + bool MegaClient::treatAsIfFileDataEqual(const FileFingerprint& node1, const LocalPath& file2, const string& filenameExtensionLowercaseNoDot) { // if equal, upload or download could be skipped diff --git a/tests/integration/SdkTest_test.cpp b/tests/integration/SdkTest_test.cpp index e5700eab36..8533e9d309 100644 --- a/tests/integration/SdkTest_test.cpp +++ b/tests/integration/SdkTest_test.cpp @@ -15625,6 +15625,12 @@ TEST_F(SdkTest, SdkTestGetNodeByMimetype) ASSERT_EQ(nodeList->get(2)->getHandle(), handlePdfFile); ASSERT_EQ(nodeList->get(3)->getHandle(), handleTxtFile); + /// + /// search using old and deprecated API, to make sure we don't break it in the future + nodeList.reset(megaApi[0]->searchByType(nullptr, "", nullptr, true, MegaApi::ORDER_DEFAULT_ASC, MegaApi::FILE_TYPE_SPREADSHEET)); // order Alphabetical asc + ASSERT_EQ(nodeList->size(), 1); + ASSERT_EQ(nodeList->get(0)->getHandle(), handleSpreadsheetFile); + deleteFile(PUBLICFILE); } From 8eaca70c1ea2f28ed053ed463e698171c74ede00 Mon Sep 17 00:00:00 2001 From: Catalin Date: Tue, 16 Jan 2024 16:50:01 +0200 Subject: [PATCH 4/5] Add support for FILE_TYPE_ALL_DOCS to (deprecated) searchByType() --- src/megaapi_impl.cpp | 3 +++ src/node.cpp | 2 ++ tests/integration/SdkTest_test.cpp | 14 ++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/src/megaapi_impl.cpp b/src/megaapi_impl.cpp index 48d948fcd7..252ae7113c 100644 --- a/src/megaapi_impl.cpp +++ b/src/megaapi_impl.cpp @@ -11948,6 +11948,9 @@ bool MegaApiImpl::isValidTypeNode(const Node *node, int type) const return client->nodeIsMiscellaneous(node); case MegaApi::FILE_TYPE_SPREADSHEET: return client->nodeIsSpreadsheet(node); + case MegaApi::FILE_TYPE_ALL_DOCS: + return client->nodeIsDocument(node) || client->nodeIsPdf(node) || + client->nodeIsPresentation(node) || client->nodeIsSpreadsheet(node); case MegaApi::FILE_TYPE_DEFAULT: default: return true; diff --git a/src/node.cpp b/src/node.cpp index 6fbc5fcb65..9cf95a0f3a 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -489,6 +489,8 @@ bool Node::isOfMimetype(MimeType_t mimetype, const string& ext) return Node::isMiscellaneous(ext); case MimeType_t::MIME_TYPE_SPREADSHEET: return Node::isSpreadsheet(ext); + case MimeType_t::MIME_TYPE_ALL_DOCS: + return Node::isDocument(ext) || Node::isPdf(ext) || Node::isPresentation(ext) || Node::isSpreadsheet(ext); default: return false; } diff --git a/tests/integration/SdkTest_test.cpp b/tests/integration/SdkTest_test.cpp index 8533e9d309..c6315f9f51 100644 --- a/tests/integration/SdkTest_test.cpp +++ b/tests/integration/SdkTest_test.cpp @@ -15631,6 +15631,20 @@ TEST_F(SdkTest, SdkTestGetNodeByMimetype) ASSERT_EQ(nodeList->size(), 1); ASSERT_EQ(nodeList->get(0)->getHandle(), handleSpreadsheetFile); + nodeList.reset(megaApi[0]->searchByType(rootnode.get(), "", nullptr, false, MegaApi::ORDER_DEFAULT_ASC, MegaApi::FILE_TYPE_ALL_DOCS)); // order Alphabetical asc + ASSERT_EQ(nodeList->size(), 4); + ASSERT_EQ(nodeList->get(0)->getHandle(), handleDocumentFile); + ASSERT_EQ(nodeList->get(1)->getHandle(), handleSpreadsheetFile); + ASSERT_EQ(nodeList->get(2)->getHandle(), handlePdfFile); + ASSERT_EQ(nodeList->get(3)->getHandle(), handleTxtFile); + + nodeList.reset(megaApi[0]->searchByType(nullptr, "", nullptr, true, MegaApi::ORDER_DEFAULT_ASC, MegaApi::FILE_TYPE_ALL_DOCS)); // order Alphabetical asc + ASSERT_EQ(nodeList->size(), 4); + ASSERT_EQ(nodeList->get(0)->getHandle(), handleDocumentFile); + ASSERT_EQ(nodeList->get(1)->getHandle(), handleSpreadsheetFile); + ASSERT_EQ(nodeList->get(2)->getHandle(), handlePdfFile); + ASSERT_EQ(nodeList->get(3)->getHandle(), handleTxtFile); + deleteFile(PUBLICFILE); } From 73e7246a0d87af6a75b3172e7ed94cf2a22aa4b0 Mon Sep 17 00:00:00 2001 From: Yenel Date: Tue, 16 Jan 2024 15:56:46 +0100 Subject: [PATCH 5/5] Update Android Bindings documentation --- bindings/java/nz/mega/sdk/MegaApiJava.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bindings/java/nz/mega/sdk/MegaApiJava.java b/bindings/java/nz/mega/sdk/MegaApiJava.java index f6cbc6163b..f0aaaa32f3 100644 --- a/bindings/java/nz/mega/sdk/MegaApiJava.java +++ b/bindings/java/nz/mega/sdk/MegaApiJava.java @@ -9396,7 +9396,7 @@ public ArrayList searchOnPublicLinks(String searchString, @NotNull Meg * - MegaApi::FILE_TYPE_PHOTO = 1 * - MegaApi::FILE_TYPE_AUDIO = 2 * - MegaApi::FILE_TYPE_VIDEO = 3 - * - MegaApi::FILE_TYPE_ALL_DOCS = 4 + * - MegaApi::FILE_TYPE_ALL_DOCS = 11 * @param target Target type where this method will search * Valid values for this parameter are * - SEARCH_TARGET_INSHARE = 0 @@ -9472,7 +9472,7 @@ public ArrayList searchByType(MegaNode node, String searchString, * - MegaApi::FILE_TYPE_PHOTO = 1 * - MegaApi::FILE_TYPE_AUDIO = 2 * - MegaApi::FILE_TYPE_VIDEO = 3 - * - MegaApi::FILE_TYPE_ALL_DOCS = 4 + * - MegaApi::FILE_TYPE_ALL_DOCS = 11 * @param target Target type where this method will search * Valid values for this parameter are * - SEARCH_TARGET_INSHARE = 0 @@ -9562,7 +9562,7 @@ public ArrayList searchByType(@NotNull MegaCancelToken cancelToken, in * - MegaApi::FILE_TYPE_PHOTO = 1 * - MegaApi::FILE_TYPE_AUDIO = 2 * - MegaApi::FILE_TYPE_VIDEO = 3 - * - MegaApi::FILE_TYPE_ALL_DOCS = 4 + * - MegaApi::FILE_TYPE_ALL_DOCS = 11 * @return List of nodes that match with the search parameters */ public ArrayList searchByType(MegaNode node, String searchString,