Skip to content

Commit

Permalink
Merge pull request #738 from meganz/release/v3.1.8
Browse files Browse the repository at this point in the history
release/v3.1.8
  • Loading branch information
sergiohs84 authored Jul 18, 2017
2 parents b081a0a + 3c930d0 commit 03eab52
Show file tree
Hide file tree
Showing 23 changed files with 743 additions and 161 deletions.
8 changes: 8 additions & 0 deletions bindings/ios/MEGASDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
940BF01919ED97B9007E7FA2 /* MEGAUserList.mm in Sources */ = {isa = PBXBuildFile; fileRef = 940BF00919ED97B9007E7FA2 /* MEGAUserList.mm */; };
A81790101EFACE6400110E91 /* MEGAHandleList.mm in Sources */ = {isa = PBXBuildFile; fileRef = A817900F1EFACE6400110E91 /* MEGAHandleList.mm */; };
A81790151EFADDDE00110E91 /* MEGAEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = A81790141EFADDDE00110E91 /* MEGAEvent.mm */; };
A8827A5C1F178A0D0097B5DE /* DelegateMEGATreeProcessorListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = A8827A5B1F178A0D0097B5DE /* DelegateMEGATreeProcessorListener.mm */; };
A8FD7B641E93B40E0031FC50 /* osxutils.mm in Sources */ = {isa = PBXBuildFile; fileRef = A8FD7B631E93B40E0031FC50 /* osxutils.mm */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -253,6 +254,9 @@
A81790121EFAD24F00110E91 /* MEGAHandleList+init.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MEGAHandleList+init.h"; sourceTree = "<group>"; };
A81790131EFADDDE00110E91 /* MEGAEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MEGAEvent.h; sourceTree = "<group>"; };
A81790141EFADDDE00110E91 /* MEGAEvent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MEGAEvent.mm; sourceTree = "<group>"; };
A8827A591F176BCA0097B5DE /* MEGATreeProcessorDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MEGATreeProcessorDelegate.h; sourceTree = "<group>"; };
A8827A5A1F178A0D0097B5DE /* DelegateMEGATreeProcessorListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DelegateMEGATreeProcessorListener.h; sourceTree = "<group>"; };
A8827A5B1F178A0D0097B5DE /* DelegateMEGATreeProcessorListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DelegateMEGATreeProcessorListener.mm; sourceTree = "<group>"; };
A8EBFDD21EFAE14C00DF89DA /* MEGAEvent+init.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MEGAEvent+init.h"; sourceTree = "<group>"; };
A8FD7B611E93B3ED0031FC50 /* osxutils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = osxutils.h; path = osx/osxutils.h; sourceTree = "<group>"; };
A8FD7B631E93B40E0031FC50 /* osxutils.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = osxutils.mm; path = ../../src/osx/osxutils.mm; sourceTree = "<group>"; };
Expand Down Expand Up @@ -383,6 +387,7 @@
940BF09219EDBD62007E7FA2 /* MEGARequestDelegate.h */,
940BF09619EDBD62007E7FA2 /* MEGATransferDelegate.h */,
41AD7A7B1A1E0F1B00D66856 /* MEGALoggerDelegate.h */,
A8827A591F176BCA0097B5DE /* MEGATreeProcessorDelegate.h */,
940BF08F19EDBD62007E7FA2 /* MEGANode.h */,
940BF00119ED97B9007E7FA2 /* MEGANode.mm */,
940BF09019EDBD62007E7FA2 /* MEGANodeList.h */,
Expand Down Expand Up @@ -524,6 +529,8 @@
940BF09B19EDBD62007E7FA2 /* Private */ = {
isa = PBXGroup;
children = (
A8827A5A1F178A0D0097B5DE /* DelegateMEGATreeProcessorListener.h */,
A8827A5B1F178A0D0097B5DE /* DelegateMEGATreeProcessorListener.mm */,
41AD7A7D1A1E10F900D66856 /* DelegateMEGALoggerListener.h */,
41AD7A7C1A1E10F900D66856 /* DelegateMEGALoggerListener.mm */,
41B2AED11A0A859C006C40FB /* DelegateMEGAGlobalListener.h */,
Expand Down Expand Up @@ -701,6 +708,7 @@
41AD7A7E1A1E10F900D66856 /* DelegateMEGALoggerListener.mm in Sources */,
41A990731A5D305700B2094A /* mega_utf8proc.cpp in Sources */,
A81790101EFACE6400110E91 /* MEGAHandleList.mm in Sources */,
A8827A5C1F178A0D0097B5DE /* DelegateMEGATreeProcessorListener.mm in Sources */,
41B2AEDC1A0A859C006C40FB /* DelegateMEGATransferListener.mm in Sources */,
41B538CC1A0284CB00EABDC9 /* MEGAPricing.mm in Sources */,
940BEFD419ED92C2007E7FA2 /* utils.cpp in Sources */,
Expand Down
123 changes: 109 additions & 14 deletions bindings/ios/MEGASdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#import "MEGATransferDelegate.h"
#import "MEGAGlobalDelegate.h"
#import "MEGALoggerDelegate.h"
#import "MEGATreeProcessorDelegate.h"

typedef NS_ENUM (NSInteger, MEGASortOrderType) {
MEGASortOrderTypeNone,
Expand Down Expand Up @@ -77,8 +78,17 @@ typedef NS_ENUM (NSInteger, MEGAAttributeType) {
};

typedef NS_ENUM(NSInteger, MEGAUserAttribute) {
MEGAUserAttributeFirstname = 1,
MEGAUserAttributeLastname = 2
MEGAUserAttributeAvatar = 0, // public - char array
MEGAUserAttributeFirstname = 1, // public - char array
MEGAUserAttributeLastname = 2, // public - char array
MEGAUserAttributeAuthRing = 3, // private - byte array
MEGAUserAttributeLastInteraction = 4, // private - byte array
MEGAUserAttributeED25519PublicKey = 5, // public - char array
MEGAUserAttributeCU25519PublicKey = 6, // public - char array
MEGAUserAttributeKeyring = 7, // private - byte array
MEGAUserAttributeSigRsaPublicKey = 8, // public - char array
MEGAUserAttributeSigCU255PublicKey = 9, // public - char array
MEGAUserAttributeLanguage = 14 // private - byte array
};

typedef NS_ENUM(NSInteger, MEGAPaymentMethod) {
Expand Down Expand Up @@ -199,6 +209,11 @@ typedef NS_ENUM(NSUInteger, PushNotificationTokenType) {
*/
@property (readonly, nonatomic) NSNumber *totalsUploadedBytes;

/**
* @brief The total number of nodes in the account
*/
@property (readonly, nonatomic) NSUInteger totalNodes;

/**
* @brief The master key of the account.
*
Expand Down Expand Up @@ -2099,9 +2114,11 @@ typedef NS_ENUM(NSUInteger, PushNotificationTokenType) {
* Valid values are:
*
* MEGAUserAttributeFirstname = 1
* Get the firstname of the user
* Get the firstname of the user (public)
* MEGAUserAttributeLastname = 2
* Get the lastname of the user
* Get the lastname of the user (public)
* MEGAUserAttributeLanguage = 14
* Get the preferred language of the user (private, non-encrypted)
*
*/
- (void)getUserAttributeForUser:(MEGAUser *)user type:(MEGAUserAttribute)type;
Expand All @@ -2125,9 +2142,11 @@ typedef NS_ENUM(NSUInteger, PushNotificationTokenType) {
* Valid values are:
*
* MEGAUserAttributeFirstname = 1
* Get the firstname of the user
* Get the firstname of the user (public)
* MEGAUserAttributeLastname = 2
* Get the lastname of the user
* Get the lastname of the user (public)
* MEGAUserAttributeLanguage = 14
* Get the preferred language of the user (private, non-encrypted)
*
* @param delegate MEGARequestDelegate to track this request
*/
Expand All @@ -2149,9 +2168,11 @@ typedef NS_ENUM(NSUInteger, PushNotificationTokenType) {
* Valid values are:
*
* MEGAUserAttributeFirstname = 1
* Get the firstname of the user
* Get the firstname of the user (public)
* MEGAUserAttributeLastname = 2
* Get the lastname of the user
* Get the lastname of the user (public)
* MEGAUserAttributeLanguage = 14
* Get the preferred language of the user (private, non-encrypted)
*/
- (void)getUserAttributeType:(MEGAUserAttribute)type;

Expand All @@ -2171,9 +2192,11 @@ typedef NS_ENUM(NSUInteger, PushNotificationTokenType) {
* Valid values are:
*
* MEGAUserAttributeFirstname = 1
* Get the firstname of the user
* Get the firstname of the user (public)
* MEGAUserAttributeLastname = 2
* Get the lastname of the user
* Get the lastname of the user (public)
* MEGAUserAttributeLanguage = 14
* Get the preferred language of the user (private, non-encrypted)
*
* @param delegate MEGARequestDelegate to track this request
*/
Expand All @@ -2193,9 +2216,9 @@ typedef NS_ENUM(NSUInteger, PushNotificationTokenType) {
* Valid values are:
*
* MEGAUserAttributeFirstname = 1
* Get the firstname of the user
* Set the firstname of the user
* MEGAUserAttributeLastname = 2
* Get the lastname of the user
* Set the lastname of the user
*
* @param value New attribute value
*/
Expand All @@ -2214,9 +2237,9 @@ typedef NS_ENUM(NSUInteger, PushNotificationTokenType) {
* Valid values are:
*
* MEGAUserAttributeFirstname = 1
* Get the firstname of the user
* Set the firstname of the user
* MEGAUserAttributeLastname = 2
* Get the lastname of the user
* Set the lastname of the user
*
* @param value New attribute value
* @param delegate MEGARequestDelegate to track this request
Expand Down Expand Up @@ -3607,6 +3630,18 @@ typedef NS_ENUM(NSUInteger, PushNotificationTokenType) {
*/
- (MEGANodeList *)nodeListSearchForNode:(MEGANode *)node searchString:(NSString *)searchString;

/**
* @brief Process a node tree using a MEGATreeProcessorDelegate implementation
* @param node The parent node of the tree to explore
* @param recursive YES if you want to recursively process the whole node tree.
* @param delegate MEGATreeProcessorDelegate that will receive callbacks for every node in the tree
* NO if you want to process the children of the node only
*
* @return YES if all nodes were processed. NO otherwise (the operation can be
* cancelled by [MEGATreeProcessorDelegate processMEGANode:])
*/
- (BOOL)processMEGANodeTree:(MEGANode *)node recursive:(BOOL)recursive delegate:(id<MEGATreeProcessorDelegate>)delegate;

/**
* @brief Returns a MEGANode that can be downloaded with any instance of MEGASdk
*
Expand Down Expand Up @@ -3689,6 +3724,58 @@ typedef NS_ENUM(NSUInteger, PushNotificationTokenType) {
*/
-(BOOL)setLanguageCode:(NSString *)languageCode;

/**
* @brief Set the preferred language of the user
*
* Valid data in the MEGARequest object received in onRequestFinish:
* - [MEGARequest text] - Return the language code
*
* If the language code is unknown for the SDK, the error code will be MEGAErrorTypeApiENoent
*
* This attribute is automatically created by the server. Apps only need
* to set the new value when the user changes the language.
*
* @param languageCode code to be set
* @param delegate MEGARequestDelegate to track this request
*/
- (void)setLanguangePreferenceCode:(NSString *)languageCode delegate:(id<MEGARequestDelegate>)delegate;

/**
* @brief Set the preferred language of the user
*
* Valid data in the MEGARequest object received in onRequestFinish:
* - [MEGARequest text] - Return the language code
*
* If the language code is unknown for the SDK, the error code will be MEGAErrorTypeApiENoent
*
* This attribute is automatically created by the server. Apps only need
* to set the new value when the user changes the language.
*
* @param languageCode code to be set
*/
- (void)setLanguangePreferenceCode:(NSString *)languageCode;

/**
* @brief Get the preferred language of the user
*
* Valid data in the MEGARequest object received in onRequestFinish when the error code
* is MEGAErrorTypeApiOk:
* - [MEGARequest text] - Return the language code
*
* @param delegate MEGARequestDelegate to track this request
*/
- (void)getLanguagePreferenceWithDelegate:(id<MEGARequestDelegate>)delegate;

/**
* @brief Get the preferred language of the user
*
* Valid data in the MEGARequest object received in onRequestFinish when the error code
* is MEGAErrorTypeApiOk:
* - [MEGARequest text] - Return the language code
*
*/
- (void)getLanguagePreference;

/**
* @brief Create a thumbnail for an image
* @param imagePath Image path
Expand All @@ -3705,6 +3792,14 @@ typedef NS_ENUM(NSUInteger, PushNotificationTokenType) {
*/
- (BOOL)createPreview:(NSString *)imagePath destinatioPath:(NSString *)destinationPath;

/**
* @brief Create an avatar for an image
* @param imagePath Image path
* @param destinationPath Destination path for the avatar (including the file name)
* @return YES if the avatar was successfully created, otherwise NO.
*/
- (BOOL)createAvatar:(NSString *)imagePath destinationPath:(NSString *)destinationPath;

#ifdef HAVE_LIBUV

#pragma mark - HTTP Proxy Server
Expand Down
39 changes: 39 additions & 0 deletions bindings/ios/MEGASdk.mm
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#import "DelegateMEGAGlobalListener.h"
#import "DelegateMEGAListener.h"
#import "DelegateMEGALoggerListener.h"
#import "DelegateMEGATreeProcessorListener.h"
#import "MEGAInputStream.h"

#import <set>
Expand Down Expand Up @@ -112,6 +113,10 @@ - (NSNumber *)totalsUploadedBytes {
return [[NSNumber alloc] initWithLongLong:self.megaApi->getTotalUploadedBytes()];
}

- (NSUInteger)totalNodes {
return self.megaApi->getNumNodes();
}

- (NSString *)masterKey {
const char *val = self.megaApi->exportMasterKey();
if (!val) return nil;
Expand Down Expand Up @@ -1331,6 +1336,10 @@ - (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];
}

- (BOOL)processMEGANodeTree:(MEGANode *)node recursive:(BOOL)recursive delegate:(id<MEGATreeProcessorDelegate>)delegate {
return self.megaApi->processMegaTree(node ? [node getCPtr] : NULL, [self createMegaTreeProcessor:delegate], recursive);
}

- (MEGANode *)authorizeNode:(MEGANode *)node {
return [[MEGANode alloc] initWithMegaNode:self.megaApi->authorizeNode((node != nil) ? [node getCPtr] : NULL) cMemoryOwn:YES];
}
Expand Down Expand Up @@ -1371,6 +1380,22 @@ - (BOOL)setLanguageCode:(NSString *)languageCode {
return self.megaApi->setLanguage(languageCode ? [languageCode UTF8String] : NULL);
}

- (void)setLanguangePreferenceCode:(NSString *)languageCode delegate:(id<MEGARequestDelegate>)delegate {
self.megaApi->setLanguagePreference(languageCode ? [languageCode UTF8String] : NULL, [self createDelegateMEGARequestListener:delegate singleListener:YES]);
}

- (void)setLanguangePreferenceCode:(NSString *)languageCode {
self.megaApi->setLanguagePreference(languageCode ? [languageCode UTF8String] : NULL);
}

- (void)getLanguagePreferenceWithDelegate:(id<MEGARequestDelegate>)delegate {
self.megaApi->getLanguagePreference([self createDelegateMEGARequestListener:delegate singleListener:YES]);
}

- (void)getLanguagePreference {
self.megaApi->getLanguagePreference();
}

- (BOOL)createThumbnail:(NSString *)imagePath destinatioPath:(NSString *)destinationPath {
if (imagePath == nil || destinationPath == nil) return NO;

Expand All @@ -1383,6 +1408,12 @@ - (BOOL)createPreview:(NSString *)imagePath destinatioPath:(NSString *)destinati
return self.megaApi->createPreview([imagePath UTF8String], [destinationPath UTF8String]);
}

- (BOOL)createAvatar:(NSString *)imagePath destinationPath:(NSString *)destinationPath {
if (imagePath == nil || destinationPath == nil) return NO;

return self.megaApi->createAvatar([imagePath UTF8String], [destinationPath UTF8String]);
}

#ifdef HAVE_LIBUV

#pragma mark - HTTP Proxy Server
Expand Down Expand Up @@ -1553,6 +1584,14 @@ - (MegaLogger *)createDelegateMegaLogger:(id<MEGALoggerDelegate>)delegate {
return delegateListener;
}

- (MegaTreeProcessor *)createMegaTreeProcessor:(id<MEGATreeProcessorDelegate>)delegate {
if (delegate == nil) return nil;

DelegateMEGATreeProcessorListener *delegateListener = new DelegateMEGATreeProcessorListener(delegate);

return delegateListener;
}

- (void)freeRequestListener:(DelegateMEGARequestListener *)delegate {
if (delegate == nil) return;

Expand Down
43 changes: 43 additions & 0 deletions bindings/ios/MEGATreeProcessorDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @file MEGATreeProcessorDelegate.h
* @brief Delegate to process node trees
*
* (c) 2013-2017 by Mega Limited, Auckland, New Zealand
*
* This file is part of the MEGA SDK - Client Access Engine.
*
* Applications using the MEGA API must present a valid application key
* and comply with the the rules set forth in the Terms of Service.
*
* The MEGA SDK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @copyright Simplified (2-clause) BSD License.
*
* You should have received a copy of the license along with this
* program.
*/

#import <Foundation/Foundation.h>
#import "MEGANode.h"

/**
* @brief Protocol to process node trees
*
* An implementation of this class can be used to process a node tree passing a pointer to
* [MEGASdk processMEGANodeTree:recursive:delegate:]
*
* The implementation will receive callbacks from an internal worker thread.
*
*/
@protocol MEGATreeProcessorDelegate <NSObject>

/**
* @brief Function that will be called for all nodes in a node tree
* @param node MEGANode to be processed
* @return YES to continue processing nodes, NO to stop
*/
- (BOOL)processMEGANode:(MEGANode *)node;

@end
Loading

0 comments on commit 03eab52

Please sign in to comment.