Skip to content

Commit

Permalink
Merge pull request #1578 from meganz/release/v3.6.2
Browse files Browse the repository at this point in the history
Release/v3.6.2
  • Loading branch information
sergiohs84 authored Aug 27, 2019
2 parents 313fac3 + 274b061 commit 3fc9f58
Show file tree
Hide file tree
Showing 61 changed files with 3,069 additions and 667 deletions.
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@
*.exe
*.out
*.app
/tests/sdk_test
/tests/misc_test
/tests/purge_account
/tests/sync_test
/tests/test_unit
/tests/test_integration
/tests/tool_purge_account
examples/megacli
examples/megasimplesync
examples/linux/megafuse
Expand Down Expand Up @@ -65,6 +64,7 @@ config.log
config.status
config.sub
py-compile
/sdk_build

# Documentation generator
doc/_build
Expand All @@ -83,10 +83,12 @@ doc/example/lsmega
Debug
Release
/contrib/QtCreator/build-*
/contrib/QtCreator/MEGAsdk.pro.user
/contrib/QtCreator/MEGAcli/MEGAcli.pro.user
/contrib/QtCreator/MEGAtests/MEGAtests.pro.user
/contrib/QtCreator/MEGAsymplesync/MEGAsymplesync.pro.user
/contrib/QtCreator/megacli.creator.user
/contrib/build-MEGAsdk-Desktop-*
/contrib/cmake/cmake-build-*
/contrib/build-cmake-Desktop-*
/contrib/cmake/CMakeLists.txt.user
Expand Down
15 changes: 15 additions & 0 deletions bindings/ios/MEGARequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#import "MEGAAchievementsDetails.h"
#import "MEGAFolderInfo.h"
#import "MEGATimeZoneDetails.h"
#import "MEGAStringList.h"

typedef NS_ENUM (NSInteger, MEGARequestType) {
MEGARequestTypeLogin,
Expand Down Expand Up @@ -484,6 +485,20 @@ typedef NS_ENUM (NSInteger, MEGANodeAccessLevel) {
*/
@property (readonly, nonatomic) NSInteger numDetails;

/**
* @brief Returns a dictionary of mega string list.
*/
@property (readonly, nonatomic) NSDictionary<NSString *, MEGAStringList*> *megaStringListDictionary;

/**
* @brief Gets the string table response from a request mapped into a collection of NSArray of NSStrings.
*
* This value is valid for these requests:
* - [MEGASdk getRegisteredContacts:] - Obtains the user contacts registered in MEGA and verificated through SMS.
*
*/
@property (readonly, nonatomic) NSArray<NSArray<NSString *> *> *stringTableArray;

/**
* @brief Creates a copy of this MEGARequest object
*
Expand Down
30 changes: 30 additions & 0 deletions bindings/ios/MEGARequest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#import "MEGAAchievementsDetails+init.h"
#import "MEGAFolderInfo+init.h"
#import "MEGATimeZoneDetails+init.h"
#import "MEGAStringList+init.h"

using namespace mega;

Expand Down Expand Up @@ -185,6 +186,20 @@ - (MEGAFolderInfo *)megaFolderInfo {
return self.megaRequest ? [[MEGAFolderInfo alloc] initWithMegaFolderInfo:self.megaRequest->getMegaFolderInfo()->copy() cMemoryOwn:YES] : nil;
}

- (NSDictionary<NSString *, MEGAStringList *> *)megaStringListDictionary {
MegaStringListMap *map = self.megaRequest->getMegaStringListMap();
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:map->size()];
MegaStringList *keyList = map->getKeys();
for (int i = 0; i < keyList->size(); i++) {
const char *key = keyList->get(i);
dict[@(key)] = [[MEGAStringList alloc] initWithMegaStringList:(MegaStringList *)map->get(key)->copy() cMemoryOwn:YES];
}

delete keyList;

return [dict copy];
}

- (NSInteger)transferTag {
return self.megaRequest ? self.megaRequest->getTransferTag() : 0;
}
Expand All @@ -193,4 +208,19 @@ - (NSInteger)numDetails {
return self.megaRequest ? self.megaRequest->getNumDetails() : 0;
}

- (NSArray<NSArray<NSString *> *> *)stringTableArray {
MegaStringTable *table = self.megaRequest->getMegaStringTable();
NSMutableArray<NSArray <NSString *> *> *stringTableArray = [NSMutableArray.alloc initWithCapacity:table->size()];
for (int i = 0; i < table->size(); i++) {
const MegaStringList *stringList = table->get(i);
NSMutableArray<NSString *> *stringsArray = [NSMutableArray.alloc initWithCapacity:stringList->size()];
for (int j = 0; j < stringList->size(); j++) {
[stringsArray addObject:[NSString stringWithUTF8String:stringList->get(j)]];
}
[stringTableArray addObject:stringsArray.copy];
}

return stringTableArray.copy;
}

@end
109 changes: 109 additions & 0 deletions bindings/ios/MEGASdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,21 @@ typedef NS_ENUM(NSUInteger, StorageState) {
StorageStateChange = 3
};

typedef NS_ENUM(NSInteger, SMSState) {
SMSStateNotAllowed = 0,
SMSStateOnlyUnblock = 1,
SMSStateOptInAndUnblock = 2,
};

typedef NS_ENUM(NSInteger, AccountSuspensionType) {
AccountSuspensionTypeNone = 0, // The account is not blocked
AccountSuspensionTypeNonCopyright = 200, // suspension for any type of suspension, but copyright suspension
AccountSuspensionTypeCopyright = 300, // suspension only for multiple copyright violations
AccountSuspensionTypeBusinessDisabled = 400, // the subuser of a business account has been disabled
AccountSuspensionTypeBusinessRemoved = 401, // the subuser of a business account has been removed
AccountSuspensionTypeSMSVerification = 500, // The account needs to be verified by an SMS code.
};

typedef NS_ENUM(NSInteger, BusinessStatus) {
BusinessStatusExpired = -1,
BusinessStatusInactive = 0, // no business subscription
Expand Down Expand Up @@ -7038,6 +7053,100 @@ typedef NS_ENUM(NSInteger, BusinessStatus) {
*/
- (void)getPublicLinkInformationWithFolderLink:(NSString *)folderLink;

#pragma mark - SMS

/**
* @brief Check if the opt-in or account ublocking SMS is allowed.
*
* The result indicated whether the sendSMSVerificationCode() function can be used.
*
* @return SMSState enum to indicate the SMS state for the current account.
*/
- (SMSState)smsAllowedState;

/**
* @brief Requests the currently available country calling codes
*
* The response value is stored as a dictionary of mapping from two-letter country code
* to a list of calling codes. For instance:
* {
* "AD": ["376"],
* "AE": ["971", "13"],
* }
*
* Valid data in the delegate object received in onRequestFinish when the error code
* is MEGAErrorTypeApiOk
*
* @param delegate MEGARequestDelegate to track this request
*/
- (void)getCountryCallingCodesWithDelegate:(id<MEGARequestDelegate>)delegate;

/**
* @brief Send a verification code txt to the supplied phone number
*
* Sends a 6 digit code to the user's phone. The phone number is supplied in this function call.
* The code is sent by SMS to the user. Once the user receives it, they can type it into the app
* and the call checkSMSVerificationCode:delegate: in MEGASdk to validate the user did
* receive the verification code, so that really is their phone number.
*
* The frequency with which this call can be used is very limited (the API allows at most
* two SMS mssages sent for phone number per 24 hour period), so it's important to get the
* number right on the first try. The result will be MEGAErrorTypeApiETempUnavail if it has
* been tried too frequently.
*
* Make sure to test the result of smsAllowedState in MEGASdk before calling this function.
*
* Valid data in the MegaRequest object received on callbacks:
* - text in MEGARequest - the phoneNumber as supplied to this function
*
* When the operation completes, MEGAErrorType can be:
* - MEGAErrorTypeApiETempUnavail if a limit is reached.
* - MEGAErrorTypeApiEAccess if your account is already verified with an SMS number
* - MEGAErrorTypeApiEExist if the number is already verified for some other account.
* - MEGAErrorTypeApiEArgs if the phone number is badly formatted or invalid.
* - MEGAErrorTypeApiOk is returned upon success.
*
* @param phoneNumber The phone number to txt the code to, supplied by the user.
* @param delegate A MEGARequestDelegate callback to track this request
*/
- (void)sendSMSVerificationCodeToPhoneNumber:(NSString *)phoneNumber delegate:(id<MEGARequestDelegate>)delegate;

/**
* @brief Check a verification code that the user should have received via txt
*
* This function validates that the user received the verification code sent by sendSMSVerificationCodeToPhoneNumber:delegate in MEGASdk.
*
* Valid data in the MEGARequest object received on callbacks:
* - text in MEGARequest - the verificationCode as supplied to this function
*
* When the operation completes, MEGAErrorType can be:
* - MEGAErrorTypeApiEAccess if you have reached the verification limits.
* - MEGAErrorTypeApiEFailed if the verification code does not match.
* - MEGAErrorTypeApiEExpired if the phone number was verified on a different account.
* - MEGAErrorTypeApiOk is returned upon success.
*
* @param verificationCode A string supplied by the user, that they should have received via txt.
* @param delegate A MEGARequestDelegate callback to track this request
*/
- (void)checkSMSVerificationCode:(NSString *)verificationCode delegate:(id<MEGARequestDelegate>)delegate;

/*
* @brief Requests the user contacts registered in MEGA and verificated through SMS.
*
* Valid data in the MEGARequest object received on callbacks:
* - [MegaRequest getMegaStringTable] Returns the array with registered contacts
*
* The associated request type with this request is MegaRequest::TYPE_GET_REGISTERED_CONTACTS
* On the onRequestFinish error, the error code associated to the MegaError can be:
* - MEGAErrorTypeApiEArgs if your contact details are invalid (malformed SMS number for example).
* - MEGAErrorTypeApiETooMany if the request exceeds the details limit that can be looked up per account.
* - MEGAErrorTypeApiOk is returned upon success.
*
* @param contacts An NSArray containing user contacts (NSDictionary "phoneNumber":"userName").
* @param listener MEGARequestDelegate to track this request
*/
- (void)getRegisteredContacts:(NSArray<NSDictionary *> *)contacts delegate:(id<MEGARequestDelegate>)delegate;

#pragma mark - Debug log messages

/**
Expand Down
31 changes: 31 additions & 0 deletions bindings/ios/MEGASdk.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2160,6 +2160,37 @@ - (void)getPublicLinkInformationWithFolderLink:(NSString *)folderLink {
self.megaApi->getPublicLinkInformation(folderLink.UTF8String);
}

#pragma mark - SMS

- (SMSState)smsAllowedState {
return (SMSState)self.megaApi->smsAllowedState();
}

- (void)getRegisteredContacts:(NSArray<NSDictionary *> *)contacts delegate:(id<MEGARequestDelegate>)delegate {
MegaStringMap *stringMapContacts = MegaStringMap::createInstance();
for (NSDictionary *contact in contacts) {
NSString *key = contact.allKeys.firstObject;
NSString *value = contact.allValues.firstObject;
stringMapContacts->set(key.UTF8String, value.UTF8String);
}

self.megaApi->getRegisteredContacts(stringMapContacts, [self createDelegateMEGARequestListener:delegate singleListener:YES]);

delete stringMapContacts;
}

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

- (void)sendSMSVerificationCodeToPhoneNumber:(NSString *)phoneNumber delegate:(id<MEGARequestDelegate>)delegate {
self.megaApi->sendSMSVerificationCode([phoneNumber UTF8String], [self createDelegateMEGARequestListener:delegate singleListener:YES], YES);
}

- (void)checkSMSVerificationCode:(NSString *)verificationCode delegate:(id<MEGARequestDelegate>)delegate {
self.megaApi->checkSMSVerificationCode([verificationCode UTF8String], [self createDelegateMEGARequestListener:delegate singleListener:YES]);
}

#pragma mark - Debug log messages

+ (void)setLogLevel:(MEGALogLevel)logLevel {
Expand Down
73 changes: 73 additions & 0 deletions bindings/java/nz/mega/sdk/MegaApiJava.java
Original file line number Diff line number Diff line change
Expand Up @@ -8396,6 +8396,79 @@ static ArrayList<MegaRecentActionBucket> recentActionsToArray(MegaRecentActionBu
return result;
}

/**
* Provide a phone number to get verification code.
*
* @param phoneNumber the phone number to receive the txt with verification code.
* @param listener callback of this request.
*/
public void sendSMSVerificationCode(String phoneNumber,nz.mega.sdk.MegaRequestListenerInterface listener) {
megaApi.sendSMSVerificationCode(phoneNumber,createDelegateRequestListener(listener));
}

public void sendSMSVerificationCode(String phoneNumber,nz.mega.sdk.MegaRequestListenerInterface listener,boolean reverifying_whitelisted) {
megaApi.sendSMSVerificationCode(phoneNumber,createDelegateRequestListener(listener),reverifying_whitelisted);
}

/**
* Send the verification code to verifiy phone number.
*
* @param verificationCode received 6 digits verification code.
* @param listener callback of this request.
*/
public void checkSMSVerificationCode(String verificationCode,nz.mega.sdk.MegaRequestListenerInterface listener) {
megaApi.checkSMSVerificationCode(verificationCode,createDelegateRequestListener(listener));
}

/**
* Get the verified phone number of the mega account.
*
* @return verified phone number.
*/
public String smsVerifiedPhoneNumber() {
return megaApi.smsVerifiedPhoneNumber();
}

/**
* Requests the contacts that are registered at MEGA (currently verified through SMS)
*
* @param contacts The map of contacts to get registered contacts from
* @param listener MegaRequestListener to track this request
*/
public void getRegisteredContacts(MegaStringMap contacts, nz.mega.sdk.MegaRequestListenerInterface listener) {
megaApi.getRegisteredContacts(contacts, createDelegateRequestListener(listener));
}

/**
* Requests the currently available country calling codes
*
* @param listener MegaRequestListener to track this request
*/
public void getCountryCallingCodes(nz.mega.sdk.MegaRequestListenerInterface listener) {
megaApi.getCountryCallingCodes(createDelegateRequestListener(listener));
}

/**
* Get the state to see whether blocked account could do SMS verification
*
* @return the state
*/
public int smsAllowedState() {
return megaApi.smsAllowedState();
}

/**
* @brief Returns the email of the user who made the changes
*
* The SDK retains the ownership of the returned value. It will be valid until
* the MegaRecentActionBucket object is deleted.
*
* @return The associated user's email
*/
public void getUserEmail(long handle, nz.mega.sdk.MegaRequestListenerInterface listener) {
megaApi.getUserEmail(handle, createDelegateRequestListener(listener));
}

/**
* @brief Cancel a registration process
*
Expand Down
3 changes: 1 addition & 2 deletions bindings/qt/sdk.pri
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ CONFIG(USE_MEGAAPI) {
}
}

CONFIG += c++11
!win32 {
QMAKE_CXXFLAGS += -std=c++11
QMAKE_CXXFLAGS += -std=c++11 -Wextra -Wconversion -Wno-unused-parameter

unix:!macx {
GCC_VERSION = $$system("g++ -dumpversion")
Expand Down
5 changes: 0 additions & 5 deletions contrib/QtCreator/MEGATestSuite/MEGATestSuite.pro

This file was deleted.

2 changes: 1 addition & 1 deletion contrib/QtCreator/MEGAsdk.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ TEMPLATE = subdirs

SUBDIRS += MEGAcli
SUBDIRS += MEGAsimplesync
SUBDIRS += MEGATestSuite
SUBDIRS += MEGAtests
Loading

0 comments on commit 3fc9f58

Please sign in to comment.