1/** 2 * @file MEGAEvent.mm 3 * @brief Provides information about an event 4 * 5 * (c) 2013-2017 by Mega Limited, Auckland, New Zealand 6 * 7 * This file is part of the MEGA SDK - Client Access Engine. 8 * 9 * Applications using the MEGA API must present a valid application key 10 * and comply with the the rules set forth in the Terms of Service. 11 * 12 * The MEGA SDK is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 * 16 * @copyright Simplified (2-clause) BSD License. 17 * 18 * You should have received a copy of the license along with this 19 * program. 20 */ 21 22#import "MEGAEvent.h" 23#import "megaapi.h" 24 25using namespace mega; 26 27@interface MEGAEvent () 28 29@property MegaEvent *megaEvent; 30@property BOOL cMemoryOwn; 31 32@end 33 34@implementation MEGAEvent 35 36- (instancetype)initWithMegaEvent:(MegaEvent *)megaEvent cMemoryOwn:(BOOL)cMemoryOwn { 37 self = [super init]; 38 39 if (self) { 40 _megaEvent = megaEvent; 41 _cMemoryOwn = cMemoryOwn; 42 } 43 44 return self; 45} 46 47- (void)dealloc { 48 if (self.cMemoryOwn) { 49 delete _megaEvent; 50 } 51} 52 53- (instancetype)clone { 54 return self.megaEvent ? [[MEGAEvent alloc] initWithMegaEvent:self.megaEvent->copy() cMemoryOwn:YES] : nil; 55} 56 57- (MegaEvent *)getCPtr { 58 return self.megaEvent; 59} 60 61- (Event)type { 62 return (Event) (self.megaEvent ? self.megaEvent->getType() : 0); 63} 64 65- (NSString *)text { 66 return self.megaEvent ? [[NSString alloc] initWithUTF8String:self.megaEvent->getText()] : nil; 67} 68 69- (NSInteger)number { 70 return self.megaEvent ? self.megaEvent->getNumber() : -1; 71} 72 73 74@end 75