Skip to content

Commit

Permalink
Merge pull request #702 from meganz/release/v3.1.5
Browse files Browse the repository at this point in the history
Release/v3.1.5
  • Loading branch information
sergiohs84 authored Jun 27, 2017
2 parents 3a2bc39 + cf6d266 commit feddf4d
Show file tree
Hide file tree
Showing 62 changed files with 2,041 additions and 478 deletions.
32 changes: 32 additions & 0 deletions bindings/ios/MEGADelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#import "MEGANodeList.h"
#import "MEGAUserList.h"
#import "MEGAContactRequestList.h"
#import "MEGAEvent.h"

@class MEGASdk;

Expand Down Expand Up @@ -148,6 +149,10 @@

/**
* @brief This function is called when the account has been updated (confirmed/upgraded/downgraded)
*
* The usage of this delegate to handle the external account confirmation is deprecated.
* Instead, you should use [MEGAGlobalDelegate onEvent:event:].
*
* @param api MEGASdk object connected to the account
*/
- (void)onAccountUpdate:(MEGASdk *)api;
Expand All @@ -172,4 +177,31 @@
*/
- (void)onReloadNeeded:(MEGASdk *)api;


/**
* The details about the event, like the type of event and optionally any
* additional parameter, is received in the \c params parameter.
*
* Currently, the following type of events are notified:
*
* - EventCommitDB: when the SDK commits the ongoing DB transaction.
* This event can be used to keep synchronization between the SDK cache and the
* cache managed by the app thanks to the sequence number.
*
* Valid data in the MegaEvent object received in the callback:
* - [MEGAEvent text]: sequence number recorded by the SDK when this event happened
*
* - EventAccountConfirmation: when a new account is finally confirmed
* by the user by confirming the signup link.
*
* Valid data in the MegaEvent object received in the callback:
* - [MEGAEvent text]: email address used to confirm the account
*
* You can check the type of event by calling [MEGAEvent type]
*
* @param api MEGASdk object connected to the account
* @param event Details about the event
*/
- (void)onEvent:(MEGASdk *)api event:(MEGAEvent *)event;

@end
60 changes: 60 additions & 0 deletions bindings/ios/MEGAEvent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* @file MEGAEvent.h
* @brief Provides information about an event
*
* (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>

typedef NS_ENUM(NSUInteger, Event) {
EventCommitDB,
EventAccountConfirmation = 1
};

/**
* @brief Provides information about an event
*
* Objects of this class aren't live, they are snapshots of the state of the event
* when the object is created, they are immutable.
*/
@interface MEGAEvent : NSObject

/**
* @brief The type of the event associated with the object
*/
@property (nonatomic, readonly) Event type;

/**
* @brief Text relative to this event
*/
@property (nonatomic, readonly) NSString *text;

/**
* @brief Creates a copy of this MEGAEvent object
*
* The resulting object is fully independent of the source MEGAEvent,
* it contains a copy of all internal attributes, so it will be valid after
* the original object is deleted.
*
* You are the owner of the returned object
*
* @return Copy of the MEGAEvent object
*/
- (instancetype)clone;

@end
70 changes: 70 additions & 0 deletions bindings/ios/MEGAEvent.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* @file MEGAEvent.mm
* @brief Provides information about an event
*
* (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 "MEGAEvent.h"
#import "megaapi.h"

using namespace mega;

@interface MEGAEvent ()

@property MegaEvent *megaEvent;
@property BOOL cMemoryOwn;

@end

@implementation MEGAEvent

- (instancetype)initWithMegaEvent:(MegaEvent *)megaEvent cMemoryOwn:(BOOL)cMemoryOwn {
self = [super init];

if (self) {
_megaEvent = megaEvent;
_cMemoryOwn = cMemoryOwn;
}

return self;
}

- (void)dealloc {
if (self.cMemoryOwn) {
delete _megaEvent;
}
}

- (instancetype)clone {
return self.megaEvent ? [[MEGAEvent alloc] initWithMegaEvent:self.megaEvent->copy() cMemoryOwn:YES] : nil;
}

- (MegaEvent *)getCPtr {
return self.megaEvent;
}

- (Event)type {
return (Event) (self.megaEvent ? self.megaEvent->getType() : 0);
}

- (NSString *)text {
return self.megaEvent ? [[NSString alloc] initWithUTF8String:self.megaEvent->getText()] : nil;
}


@end
30 changes: 30 additions & 0 deletions bindings/ios/MEGAGlobalDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@

/**
* @brief This function is called when the account has been updated (confirmed/upgraded/downgraded)
*
* The usage of this delegate to handle the external account confirmation is deprecated.
* Instead, you should use [MEGAGlobalDelegate onEvent:event:].
*
* @param api MEGASdk object connected to the account
*/
- (void)onAccountUpdate:(MEGASdk *)api;
Expand All @@ -76,4 +80,30 @@
*/
- (void)onReloadNeeded:(MEGASdk *)api;

/**
* The details about the event, like the type of event and optionally any
* additional parameter, is received in the \c params parameter.
*
* Currently, the following type of events are notified:
*
* - EventCommitDB: when the SDK commits the ongoing DB transaction.
* This event can be used to keep synchronization between the SDK cache and the
* cache managed by the app thanks to the sequence number.
*
* Valid data in the MegaEvent object received in the callback:
* - [MEGAEvent text]: sequence number recorded by the SDK when this event happened
*
* - EventAccountConfirmation: when a new account is finally confirmed
* by the user by confirming the signup link.
*
* Valid data in the MegaEvent object received in the callback:
* - [MEGAEvent text]: email address used to confirm the account
*
* You can check the type of event by calling [MEGAEvent type]
*
* @param api MEGASdk object connected to the account
* @param event Details about the event
*/
- (void)onEvent:(MEGASdk *)api event:(MEGAEvent *)event;

@end
65 changes: 65 additions & 0 deletions bindings/ios/MEGAHandleList.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* @file MEGAHandleList.h
* @brief List of MegaHandle
*
* (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>

/**
* @brief List of MegaHandle objects
*
*/
@interface MEGAHandleList : NSObject

/**
* @brief The number of handles in the list
*/
@property (readonly, nonatomic) NSUInteger size;

/**
* @brief Creates a copy of this MEGAHandleList object
*
* The resulting object is fully independent of the source MEGAHandleList,
* it contains a copy of all internal attributes, so it will be valid after
* the original object is deleted.
*
* You are the owner of the returned object
*
* @return Copy of the MEGAHandleList object
*/
- (instancetype)clone;

/**
* @brief Add new handle to handleList
* @param handle to be added.
*/
- (void)addMegaHandle:(uint64_t)handle;

/**
* @brief Returns the MegaHandle at the position index in the MEGAHandleList
*
*
* If the index is >= the size of the list, this function returns INVALID_HANDLE.
*
* @param index Position of the MegaHandle that we want to get for the list
* @return handle at the position iindex in the list
*/
- (uint64_t)megaHandleAtIndex:(NSUInteger)index;

@end
89 changes: 89 additions & 0 deletions bindings/ios/MEGAHandleList.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/**
* @file MEGAHandleList.mm
* @brief List of MegaHandle
*
* (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 "MEGAHandleList.h"
#import "megaapi.h"

using namespace mega;

@interface MEGAHandleList ()

@property MegaHandleList *megaHandleList;
@property BOOL cMemoryOwn;

@end

@implementation MEGAHandleList

- (instancetype)init {
self = [super init];

if (self != nil) {
_megaHandleList = MegaHandleList::createInstance();
}

return self;
}

- (instancetype)initWithMegaHandleList:(MegaHandleList *)megaHandleList cMemoryOwn:(BOOL)cMemoryOwn {
self = [super init];

if (self) {
_megaHandleList = megaHandleList;
_cMemoryOwn = cMemoryOwn;
}

return self;
}

- (void)dealloc {
if (self.cMemoryOwn) {
delete _megaHandleList;
}
}

- (instancetype)clone {
return self.megaHandleList ? [[MEGAHandleList alloc] initWithMegaHandleList:self.megaHandleList cMemoryOwn:YES] : nil;
}

- (MegaHandleList *)getCPtr {
return self.megaHandleList;
}

- (NSString *)description {
return [NSString stringWithFormat:@"<%@: size=%ld>",
[self class], (long)self.size];
}

- (NSUInteger)size {
return self.megaHandleList ? self.megaHandleList->size() : 0;
}

- (void)addMegaHandle:(uint64_t)handle {
if (!self.megaHandleList) return;
self.megaHandleList->addMegaHandle(handle);
}

- (uint64_t)megaHandleAtIndex:(NSUInteger)index {
return self.megaHandleList ? self.megaHandleList->get((unsigned int)index) : INVALID_HANDLE;
}

@end
Loading

0 comments on commit feddf4d

Please sign in to comment.