Skip to content

Commit

Permalink
Merge pull request #2313 from meganz/release/v3.7.6
Browse files Browse the repository at this point in the history
Release/v3.7.6
  • Loading branch information
sergiohs84 authored Nov 11, 2020
2 parents 98764ae + 87bfccc commit c5df88d
Show file tree
Hide file tree
Showing 22 changed files with 1,312 additions and 132 deletions.
55 changes: 55 additions & 0 deletions bindings/ios/MEGAError.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@ typedef NS_ENUM(NSInteger, MEGAErrorContext) {
MEGAErrorContextUpload = 3 ///< Upload transfer context.
};

/**
* @brief User custom error details
*/
typedef NS_ENUM(NSInteger, MEGAUserErrorCode) {
MEGAUserErrorCodeETDUnknown = -1, ///< Unknown state
MEGAUserErrorCodeETDSuspension = 7 ///< Account suspend by an ETD/ToS 'severe'
};

/**
* @brief Link custom error details
*/
typedef NS_ENUM(NSInteger, MEGALinkErrorCode) {
MEGALinkErrorCodeUnknown = -1, ///< Unknown state
MEGALinkErrorCodeUndeleted = 0, ///< Link is undeleted
MEGALinkErrorCodeUndeletedDown = 1, ///< Link is deleted or down
MEGALinkErrorCodeDownETD = 2 ///< Link is down due to an ETD specifically
};

/**
* @brief Provides information about an error.
*/
Expand All @@ -92,6 +110,43 @@ typedef NS_ENUM(NSInteger, MEGAErrorContext) {
*/
@property (readonly, nonatomic) long long value;

/**
* @brief YES if error has extra info
*
* @note Can return YES for:
* - MEGARequestTypeFetchnodes with error MEGAErrorTypeApiENoent
* - MEGARequestTypeGetPublicNode with error MEGAErrorTypeApiETooMany
* - MEGARequestTypeImportLink with error MEGAErrorTypeApiETooMany
* - [MEGATransferDelegate onTransferFinish:transfer:error:] with error MEGAErrorTypeApiETooMany
*/
@property (readonly, nonatomic, getter=hasExtraInfo) BOOL extraInfo;

/**
* @brief The user status
*
* This property contains valid value when extraInfo is YES
* Possible values:
* MEGAUserErrorCodeETDSuspension
*
* Otherwise, it value is MEGAUserErrorCodeETDUnknown
*
*/
@property (readonly, nonatomic) MEGAUserErrorCode userStatus;

/**
* @brief The link status
*
* This property contains valid value when extraInfo is YES
* Possible values:
* MEGALinkErrorCodeUndeleted
* MEGALinkErrorCodeUndeletedDown
* MEGALinkErrorCodeDownETD
*
* Otherwise, it value is MEGALinkErrorCodeUnknown
*
*/
@property (readonly, nonatomic) MEGALinkErrorCode linkStatus;

/**
* @brief Creates a copy of this MEGAError object.
*
Expand Down
12 changes: 12 additions & 0 deletions bindings/ios/MEGAError.mm
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ - (long long)value {
return self.megaError ? self.megaError->getValue() : 0;
}

- (BOOL)hasExtraInfo {
return self.megaError ? self.megaError->hasExtraInfo() : NO;
}

- (MEGAUserErrorCode)userStatus {
return self.megaError ? MEGAUserErrorCode(self.megaError->getUserStatus()) : MEGAUserErrorCodeETDUnknown;
}

- (MEGALinkErrorCode)linkStatus {
return self.megaError ? MEGALinkErrorCode(self.megaError->getLinkStatus()) : MEGALinkErrorCodeUnknown;
}

- (NSString *)nameWithErrorCode:(NSInteger)errorCode {
return MegaError::getErrorString((int)errorCode) ? [[NSString alloc] initWithUTF8String:MegaError::getErrorString((int)errorCode)] : nil;
}
Expand Down
141 changes: 141 additions & 0 deletions bindings/ios/MEGASdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ typedef NS_ENUM (NSInteger, MEGASortOrderType) {
MEGASortOrderTypeFavouriteDesc
};

typedef NS_ENUM (NSInteger, MEGANodeFormatType) {
MEGANodeFormatTypeUnknown = 0,
MEGANodeFormatTypePhoto,
MEGANodeFormatTypeAudio,
MEGANodeFormatTypeVideo,
MEGANodeFormatTypeDocument,
};

typedef NS_ENUM (NSInteger, MEGAFolderTargetType) {
MEGAFolderTargetTypeInShare = 0,
MEGAFolderTargetTypeOutShare,
MEGAFolderTargetTypePublicLink,
MEGAFolderTargetTypeRootNode,
MEGAFolderTargetTypeAll,
};

typedef NS_ENUM (NSInteger, MEGAEventType) {
MEGAEventTypeFeedback = 0,
MEGAEventTypeDebug,
Expand Down Expand Up @@ -7096,6 +7112,8 @@ typedef NS_ENUM(NSInteger, AffiliateType) {
/**
* @brief Check if a node has an access level.
*
* @deprecated Use checkAccessErrorExtendedForNode
*
* @param node Node to check.
* @param level Access level to check.
* Valid values for this parameter are:
Expand All @@ -7113,8 +7131,31 @@ typedef NS_ENUM(NSInteger, AffiliateType) {
*/
- (MEGAError *)checkAccessForNode:(MEGANode *)node level:(MEGAShareType)level;

/**
* @brief Check if a node has an access level
*
* @param node Node to check
* @param level Access level to check
* Valid values for this parameter are:
* - MEGAShareTypeAccessOwner
* - MEGAShareTypeAccessFull
* - MEGAShareTypeAccessReadWrite
* - MEGAShareTypeAccessRead
*
* @return Error with the result.
* Valid values for the error code are:
* - MEGAErrorTypeApiOk - The node has the required access level
* - MEGAErrorTypeApiEAccess - The node doesn't have the required access level
* - MEGAErrorTypeApiENoent - The node doesn't exist in the account
* - MEGAErrorTypeApiEArgs - Invalid parameters
*/
- (MEGAError *)checkAccessErrorExtendedForNode:(MEGANode *)node level:(MEGAShareType)level;

/**
* @brief Check if a node can be moved to a target node.
*
* @deprecated User checkMoveErrorExtendedForNode
*
* @param node Node to check.
* @param target Target for the move operation.
* @return MEGAError object with the result:
Expand All @@ -7127,6 +7168,21 @@ typedef NS_ENUM(NSInteger, AffiliateType) {
*/
- (MEGAError *)checkMoveForNode:(MEGANode *)node target:(MEGANode *)target;

/**
* @brief Check if a node can be moved to a target node.
*
* @param node Node to check.
* @param target Target for the move operation.
* @return MEGAError object with the result:
* Valid values for the error code are:
* - MEGAErrorTypeApiOk - The node can be moved to the target
* - MEGAErrorTypeApiEAccess - The node can't be moved because of permissions problems
* - MEGAErrorTypeApiECircular - The node can't be moved because that would create a circular linkage
* - MEGAErrorTypeApiENoent - The node or the target doesn't exist in the account
* - MEGAErrorTypeApiEArgs - Invalid parameters
*/
- (MEGAError *)checkMoveErrorExtendedForNode:(MEGANode *)node target:(MEGANode *)target;

/**
* @brief Check if a node is in the Rubbish bin tree
*
Expand Down Expand Up @@ -7242,6 +7298,91 @@ typedef NS_ENUM(NSInteger, AffiliateType) {
*/
- (MEGANodeList *)nodeListSearchForNode:(MEGANode *)node searchString:(NSString *)searchString;

/**
* @brief Search nodes containing a search string in their name.
*
* The search is case-insensitive.
*
* @param node The parent node of the tree to explore.
* @param searchString Search string. The search is case-insensitive.
* If the search string is not provided but nodeFormatType has any value apart from MEGANodeFormatTypeUnknown
* this method will return a list that contains nodes of the same type as provided.
* @param cancelToken MEGACancelToken to be able to cancel the processing at any time.
* @param recursive YES if you want to seach recursively in the node tree.
* NO if you want to seach in the children of the node only
* @param orderType MEGASortOrderType for the returned list.
* Valid values for this parameter are:
* - MEGASortOrderTypeNone = 0
* Undefined order
*
* - MEGASortOrderTypeDefaultAsc = 1
* Folders first in alphabetical order, then files in the same order
*
* - MEGASortOrderTypeDefaultDesc = 2
* Files first in reverse alphabetical order, then folders in the same order
*
* - MEGASortOrderTypeSizeAsc = 3
* Sort by size, ascending
*
* - MEGASortOrderTypeSizeDesc = 4
* Sort by size, descending
*
* - MEGASortOrderTypeCreationAsc = 5
* Sort by creation time in MEGA, ascending
*
* - MEGASortOrderTypeCreationDesc = 6
* Sort by creation time in MEGA, descending
*
* - MEGASortOrderTypeModificationAsc = 7
* Sort by modification time of the original file, ascending
*
* - MEGASortOrderTypeModificationDesc = 8
* Sort by modification time of the original file, descending
*
* - MEGASortOrderTypeAlphabeticalAsc = 9
* Same behavior than MEGASortOrderTypeDefaultAsc
*
* - MEGASortOrderTypeAlphabeticalDesc = 10
* Same behavior than MEGASortOrderTypeDefaultDesc
*
* - MEGASortOrderTypePhotoAsc = 11
* Sort with photos first, then by date ascending
*
* - MEGASortOrderTypePhotoDesc = 12
* Sort with photos first, then by date descending
*
* - MEGASortOrderTypeVideoAsc = 13
* Sort with videos first, then by date ascending
*
* - MEGASortOrderTypeVideoDesc = 14
* Sort with videos first, then by date descending
*
* @param nodeFormatType Type of nodes requested in the search
* Valid values for this parameter are:
* - MEGANodeFormatTypeUnknown = 0
* - MEGANodeFormatTypePhoto = 1
* - MEGANodeFormatTypeAudio = 2
* - MEGANodeFormatTypeVideo = 3
* - MEGANodeFormatTypeDocument = 4
*
* @param folderTargetType Target type where this method will search
* Valid values for this parameter are
* - MEGAFolderTargetTypeInShare = 0
* - MEGAFolderTargetTypeOutShare = 1
* - MEGAFolderTargetTypePublicLink = 2
* - MEGAFolderTargetTypeRootNode = 3
* - MEGAFolderTargetTypeAll = 4
*
* @return List of nodes that contain the desired string in their name.
*/
- (MEGANodeList *)nodeListSearchForNode:(MEGANode *)node
searchString:(nullable NSString *)searchString
cancelToken:(MEGACancelToken *)cancelToken
recursive:(BOOL)recursive
orderType:(MEGASortOrderType)orderType
nodeFormatType:(MEGANodeFormatType)nodeFormatType
folderTargetType:(MEGAFolderTargetType)folderTargetType;

/**
* @brief Return an array of buckets, each bucket containing a list of recently added/modified nodes
*
Expand Down
18 changes: 18 additions & 0 deletions bindings/ios/MEGASdk.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2074,6 +2074,10 @@ - (MEGAError *)checkAccessForNode:(MEGANode *)node level:(MEGAShareType)level {
return [[MEGAError alloc] initWithMegaError:self.megaApi->checkAccess((node != nil) ? [node getCPtr] : NULL, (int) level).copy() cMemoryOwn:YES];
}

- (MEGAError *)checkAccessErrorExtendedForNode:(MEGANode *)node level:(MEGAShareType)level {
return [[MEGAError alloc] initWithMegaError:self.megaApi->checkAccessErrorExtended(node.getCPtr, (int)level) cMemoryOwn:YES];
}

- (BOOL)isNodeInRubbish:(MEGANode *)node {
return self.megaApi->isInRubbish(node ? [node getCPtr] : NULL);
}
Expand All @@ -2082,6 +2086,10 @@ - (MEGAError *)checkMoveForNode:(MEGANode *)node target:(MEGANode *)target {
return [[MEGAError alloc] initWithMegaError:self.megaApi->checkMove((node != nil) ? [node getCPtr] : NULL, (target != nil) ? [target getCPtr] : NULL).copy() cMemoryOwn:YES];
}

- (MEGAError *)checkMoveErrorExtendedForNode:(MEGANode *)node target:(MEGANode *)target {
return [[MEGAError alloc] initWithMegaError:self.megaApi->checkMoveErrorExtended(node.getCPtr, target.getCPtr) cMemoryOwn:YES];
}

- (MEGANodeList *)nodeListSearchForNode:(MEGANode *)node searchString:(NSString *)searchString recursive:(BOOL)recursive {
return [[MEGANodeList alloc] initWithNodeList:self.megaApi->search((node != nil) ? [node getCPtr] : NULL, (searchString != nil) ? [searchString UTF8String] : NULL, recursive) cMemoryOwn:YES];
}
Expand All @@ -2094,6 +2102,16 @@ - (MEGANodeList *)nodeListSearchForNode:(MEGANode *)node searchString:(NSString
return [[MEGANodeList alloc] initWithNodeList:self.megaApi->search((node != nil) ? [node getCPtr] : NULL, (searchString != nil) ? [searchString UTF8String] : NULL, YES) cMemoryOwn:YES];
}

- (MEGANodeList *)nodeListSearchForNode:(MEGANode *)node
searchString:(nullable NSString *)searchString
cancelToken:(MEGACancelToken *)cancelToken
recursive:(BOOL)recursive
orderType:(MEGASortOrderType)orderType
nodeFormatType:(MEGANodeFormatType)nodeFormatType
folderTargetType:(MEGAFolderTargetType)folderTargetType {

return [MEGANodeList.alloc initWithNodeList:self.megaApi->searchByType(node ? [node getCPtr] : NULL, searchString.UTF8String, cancelToken ? [cancelToken getCPtr] : NULL, recursive, (int)orderType, (int)nodeFormatType, (int)folderTargetType) cMemoryOwn:YES];
}
- (NSMutableArray *)recentActions {
MegaRecentActionBucketList *megaRecentActionBucketList = self.megaApi->getRecentActions();
int count = megaRecentActionBucketList->size();
Expand Down
7 changes: 7 additions & 0 deletions bindings/ios/MEGATransfer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
#import <Foundation/Foundation.h>
#import "MEGANode.h"
#import "MEGAError.h"

typedef NS_ENUM (NSInteger, MEGATransferType) {
MEGATransferTypeDownload,
Expand Down Expand Up @@ -191,6 +192,12 @@ typedef NS_ENUM (NSInteger, MEGATransferState) {
*/
@property (readonly, nonatomic) BOOL isStreamingTransfer;

/**
* @brief The last error related to the transfer with extra info
*
*/
@property (readonly, nonatomic) MEGAError *lastErrorExtended;

/**
* @brief YES if it's a folder transfer, otherwise (file transfer) it returns NO
*/
Expand Down
6 changes: 6 additions & 0 deletions bindings/ios/MEGATransfer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
#import "MEGATransfer.h"
#import "MEGANode+init.h"
#import "MEGAError+init.h"

using namespace mega;

Expand Down Expand Up @@ -145,6 +146,11 @@ - (BOOL)isStreamingTransfer {
return self.megaTransfer ? (BOOL) self.megaTransfer->isStreamingTransfer() : NO;
}

- (MEGAError *)lastErrorExtended {
mega::MegaError *e = (mega::MegaError *)self.megaTransfer->getLastErrorExtended();
return e ? [[MEGAError alloc] initWithMegaError:e cMemoryOwn:NO] : nil;
}

- (BOOL)isFolderTransfer {
return self.megaTransfer ? (BOOL) self.megaTransfer->isFolderTransfer() : NO;
}
Expand Down
Loading

0 comments on commit c5df88d

Please sign in to comment.