Skip to content

Commit

Permalink
Merge branch 'hotfix/SDK-3536_Spreadsheets-PDFs-and-presentations-not…
Browse files Browse the repository at this point in the history
…-included-with-documents-filter' into 'release/v5.2.1'

SDK-3536. Add bindings for iOS and Android (hotfix for v5.2.1)

See merge request sdk/sdk!5204
  • Loading branch information
catalinr-m committed Jan 16, 2024
2 parents 702020e + 73e7246 commit 334ffa4
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 5 deletions.
10 changes: 9 additions & 1 deletion bindings/ios/include/MEGASdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ typedef NS_ENUM (NSInteger, MEGANodeFormatType) {
MEGANodeFormatTypeArchive,
MEGANodeFormatTypeProgram,
MEGANodeFormatTypeMisc,
MEGANodeFormatTypeSpreadsheet
MEGANodeFormatTypeSpreadsheet,
MEGANodeFormatTypeAllDocs
};

typedef NS_ENUM (NSInteger, MEGAFolderTargetType) {
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions bindings/java/nz/mega/sdk/MegaApiJava.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -9396,7 +9396,7 @@ public ArrayList<MegaNode> 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 = 11
* @param target Target type where this method will search
* Valid values for this parameter are
* - SEARCH_TARGET_INSHARE = 0
Expand Down Expand Up @@ -9472,7 +9472,7 @@ public ArrayList<MegaNode> 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 = 11
* @param target Target type where this method will search
* Valid values for this parameter are
* - SEARCH_TARGET_INSHARE = 0
Expand Down Expand Up @@ -9562,7 +9562,7 @@ public ArrayList<MegaNode> 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 = 11
* @return List of nodes that match with the search parameters
*/
public ArrayList<MegaNode> searchByType(MegaNode node, String searchString,
Expand Down
3 changes: 3 additions & 0 deletions include/mega/megaclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/megaapi_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11946,6 +11946,11 @@ 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_ALL_DOCS:
return client->nodeIsDocument(node) || client->nodeIsPdf(node) ||
client->nodeIsPresentation(node) || client->nodeIsSpreadsheet(node);
case MegaApi::FILE_TYPE_DEFAULT:
default:
return true;
Expand Down
5 changes: 5 additions & 0 deletions src/megaclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
20 changes: 20 additions & 0 deletions tests/integration/SdkTest_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15625,6 +15625,26 @@ 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);

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);
}

Expand Down

0 comments on commit 334ffa4

Please sign in to comment.