Skip to content

Commit

Permalink
Merge pull request #924 from meganz/release/v2.3.7
Browse files Browse the repository at this point in the history
Release/v2.3.7
  • Loading branch information
sergiohs84 authored Sep 9, 2020
2 parents 30fd051 + 145baea commit 7e3adf4
Show file tree
Hide file tree
Showing 35 changed files with 1,485 additions and 342 deletions.
2 changes: 2 additions & 0 deletions bindings/Objective-C/MEGAChatRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ typedef NS_ENUM (NSInteger, MEGAChatRequestType) {
MEGAChatRequestTypeSetRetentionTime,
MEGAChatRequestTypeSetCallOnHold,
MEGAChatRequestTypeEnableAudioLevelMonitor,
MEGAChatRequestTypeManageReaction,
MEGAChatRequestTypeGetPeerAttributes,
};

enum {
Expand Down
7 changes: 0 additions & 7 deletions bindings/Objective-C/MEGAChatRoom.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,8 @@ typedef NS_ENUM (NSInteger, MEGAChatRoomPrivilege) {
- (instancetype)clone;

- (NSInteger)peerPrivilegeByHandle:(uint64_t)userHande;
- (NSString *)peerFirstnameByHandle:(uint64_t)userHande;
- (NSString *)peerLastnameByHandle:(uint64_t)userHande;
- (NSString *)peerFullnameByHandle:(uint64_t)userHande;
- (NSString *)peerEmailByHandle:(uint64_t)userHande;
- (uint64_t)peerHandleAtIndex:(NSUInteger)index;
- (MEGAChatRoomPrivilege)peerPrivilegeAtIndex:(NSUInteger)index;
- (NSString *)peerFirstnameAtIndex:(NSUInteger)index;
- (NSString *)peerLastnameAtIndex:(NSUInteger)index;
- (NSString *)peerFullnameAtIndex:(NSUInteger)index;
- (BOOL)hasChangedForType:(MEGAChatRoomChangeType)changeType;

+ (NSString *)stringForPrivilege:(MEGAChatRoomPrivilege)privilege;
Expand Down
50 changes: 0 additions & 50 deletions bindings/Objective-C/MEGAChatRoom.mm
Original file line number Diff line number Diff line change
Expand Up @@ -133,34 +133,6 @@ - (NSInteger)peerPrivilegeByHandle:(uint64_t)userHande {
return self.megaChatRoom ? self.megaChatRoom->getPeerPrivilegeByHandle(userHande) : -2;
}

- (NSString *)peerFirstnameByHandle:(uint64_t)userHande {
if (!self.megaChatRoom) return nil;
const char *ret = self.megaChatRoom->getPeerFirstnameByHandle(userHande);
return ret ? [[NSString alloc] initWithUTF8String:ret] : nil;
}

- (NSString *)peerLastnameByHandle:(uint64_t)userHande {
if (!self.megaChatRoom) return nil;
const char *ret = self.megaChatRoom->getPeerLastnameByHandle(userHande);
return ret ? [[NSString alloc] initWithUTF8String:ret] : nil;
}

- (NSString *)peerFullnameByHandle:(uint64_t)userHande {
const char *val = self.megaChatRoom->getPeerFullnameByHandle(userHande);
if (!val) return nil;

NSString *ret = [[NSString alloc] initWithUTF8String:val];

delete [] val;
return ret;
}

- (NSString *)peerEmailByHandle:(uint64_t)userHande {
if (!self.megaChatRoom) return nil;
const char *ret = self.megaChatRoom->getPeerEmailByHandle(userHande);
return ret ? [[NSString alloc] initWithUTF8String:ret] : nil;
}

- (uint64_t)peerHandleAtIndex:(NSUInteger)index {
return self.megaChatRoom ? self.megaChatRoom->getPeerHandle((int)index) : MEGACHAT_INVALID_HANDLE;
}
Expand All @@ -169,28 +141,6 @@ - (MEGAChatRoomPrivilege)peerPrivilegeAtIndex:(NSUInteger)index {
return (MEGAChatRoomPrivilege) (self.megaChatRoom ? self.megaChatRoom->getPeerPrivilege((int)index) : -2);
}

- (NSString *)peerFirstnameAtIndex:(NSUInteger)index {
if (!self.megaChatRoom) return nil;
const char *ret = self.megaChatRoom->getPeerFirstname((unsigned int)index);
return ret ? [[NSString alloc] initWithUTF8String:ret] : nil;
}

- (NSString *)peerLastnameAtIndex:(NSUInteger)index {
if (!self.megaChatRoom) return nil;
const char *ret = self.megaChatRoom->getPeerLastname((unsigned int)index);
return ret ? [[NSString alloc] initWithUTF8String:ret] : nil;
}

- (NSString *)peerFullnameAtIndex:(NSUInteger)index {
const char *val = self.megaChatRoom->getPeerFullname((unsigned int)index);
if (!val) return nil;

NSString *ret = [[NSString alloc] initWithUTF8String:val];

delete [] val;
return ret;
}

- (BOOL)hasChangedForType:(MEGAChatRoomChangeType)changeType {
return self.megaChatRoom ? self.megaChatRoom->hasChanged((int)changeType) : NO;
}
Expand Down
8 changes: 8 additions & 0 deletions bindings/Objective-C/MEGAChatSdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,17 @@ typedef NS_ENUM (NSInteger, MEGAChatConnection) {
- (void)userLastnameByUserHandle:(uint64_t)userHandle authorizationToken:(NSString *)authorizationToken delegate:(id<MEGAChatRequestDelegate>)delegate;
- (void)userLastnameByUserHandle:(uint64_t)userHandle authorizationToken:(NSString *)authorizationToken;

- (NSString *)userEmailFromCacheByUserHandle:(uint64_t)userHandle;
- (NSString *)userFirstnameFromCacheByUserHandle:(uint64_t)userHandle;
- (NSString *)userLastnameFromCacheByUserHandle:(uint64_t)userHandle;
- (NSString *)userFullnameFromCacheByUserHandle:(uint64_t)userHandle;

- (NSString *)contacEmailByHandle:(uint64_t)userHandle;
- (uint64_t)userHandleByEmail:(NSString *)email;

- (void)loadUserAttributesForChatId:(uint64_t)chatId usersHandles:(NSArray<NSNumber *> *)usersHandles delegate:(id<MEGAChatRequestDelegate>)delegate;
- (void)loadUserAttributesForChatId:(uint64_t)chatId usersHandles:(NSArray<NSNumber *> *)usersHandles;

#pragma mark - Chat management

- (void)createChatGroup:(BOOL)group peers:(MEGAChatPeerList *)peers delegate:(id<MEGAChatRequestDelegate>)delegate;
Expand Down
60 changes: 60 additions & 0 deletions bindings/Objective-C/MEGAChatSdk.mm
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,46 @@ - (void)userLastnameByUserHandle:(uint64_t)userHandle authorizationToken:(NSStri
self.megaChatApi->getUserLastname(userHandle, authorizationToken.UTF8String);
}

- (NSString *)userEmailFromCacheByUserHandle:(uint64_t)userHandle {
const char *val = self.megaChatApi->getUserEmailFromCache(userHandle);
if (!val) return nil;

NSString *ret = [[NSString alloc] initWithUTF8String:val];

delete [] val;
return ret;
}

- (NSString *)userFirstnameFromCacheByUserHandle:(uint64_t)userHandle {
const char *val = self.megaChatApi->getUserFirstnameFromCache(userHandle);
if (!val) return nil;

NSString *ret = [[NSString alloc] initWithUTF8String:val];

delete [] val;
return ret;
}

- (NSString *)userLastnameFromCacheByUserHandle:(uint64_t)userHandle {
const char *val = self.megaChatApi->getUserLastnameFromCache(userHandle);
if (!val) return nil;

NSString *ret = [[NSString alloc] initWithUTF8String:val];

delete [] val;
return ret;
}

- (NSString *)userFullnameFromCacheByUserHandle:(uint64_t)userHandle {
const char *val = self.megaChatApi->getUserFullnameFromCache(userHandle);
if (!val) return nil;

NSString *ret = [[NSString alloc] initWithUTF8String:val];

delete [] val;
return ret;
}

- (NSString *)contacEmailByHandle:(uint64_t)userHandle {
const char *val = self.megaChatApi->getContactEmail(userHandle);
if (!val) return nil;
Expand All @@ -567,6 +607,26 @@ - (uint64_t)userHandleByEmail:(NSString *)email {
return self.megaChatApi->getUserHandleByEmail([email UTF8String]);
}

- (void)loadUserAttributesForChatId:(uint64_t)chatId usersHandles:(NSArray<NSNumber *> *)usersHandles delegate:(id<MEGAChatRequestDelegate>)delegate {
MEGAHandleList *handleList = MEGAHandleList.alloc.init;

for (NSNumber *handle in usersHandles) {
[handleList addMegaHandle:handle.unsignedLongLongValue];
}

self.megaChatApi->loadUserAttributes(chatId, handleList.getCPtr, [self createDelegateMEGAChatRequestListener:delegate singleListener:YES]);
}

- (void)loadUserAttributesForChatId:(uint64_t)chatId usersHandles:(NSArray<NSNumber *> *)usersHandles {
MEGAHandleList *handleList = MEGAHandleList.alloc.init;

for (NSNumber *handle in usersHandles) {
[handleList addMegaHandle:handle.unsignedLongLongValue];
}

self.megaChatApi->loadUserAttributes(chatId, handleList.getCPtr);
}

#pragma mark - Chat management

- (void)createChatGroup:(BOOL)group peers:(MEGAChatPeerList *)peers delegate:(id<MEGAChatRequestDelegate>)delegate {
Expand Down
134 changes: 134 additions & 0 deletions bindings/java/nz/mega/sdk/MegaChatApiJava.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import java.util.LinkedHashSet;
import java.util.Set;

import mega.privacy.android.app.MegaApplication;
import mega.privacy.android.app.R;
import mega.privacy.android.app.utils.TextUtil;
import mega.privacy.android.app.utils.VideoCaptureUtils;

public class MegaChatApiJava {
Expand Down Expand Up @@ -1278,6 +1281,20 @@ public void getUserFirstname(long userhandle, String cauth, MegaChatRequestListe
megaChatApi.getUserFirstname(userhandle, cauth, createDelegateRequestListener(listener));
}

/**
* Returns the current firstname of the user
*
* Returns NULL if data is not cached yet.
*
* You take the ownership of returned value
*
* @param userhandle Handle of the user whose first name is requested.
* @return The first name from user
*/
public String getUserFirstnameFromCache(long userhandle) {
return megaChatApi.getUserFirstnameFromCache(userhandle);
}

/**
* Returns the current lastname of the user
*
Expand All @@ -1300,6 +1317,20 @@ public void getUserLastname(long userhandle, String cauth, MegaChatRequestListen
megaChatApi.getUserLastname(userhandle, cauth, createDelegateRequestListener(listener));
}

/**
* Returns the current lastname of the user
*
* Returns NULL if data is not cached yet.
*
* You take the ownership of returned value
*
* @param userhandle Handle of the user whose last name is requested.
* @return The last name from user
*/
public String getUserLastnameFromCache(long userhandle){
return megaChatApi.getUserLastnameFromCache(userhandle);
}

/**
* Returns the current email address of the contact
*
Expand All @@ -1326,6 +1357,83 @@ public void getUserEmail(long userhandle, MegaChatRequestListenerInterface liste
megaChatApi.getUserEmail(userhandle, createDelegateRequestListener(listener));
}

/**
* Returns the current email address of the user
*
* Returns NULL if data is not cached yet or it's not possible to get
*
* You take the ownership of returned value
*
* @param userhandle Handle of the user whose email is requested.
* @return The email from user
*/
public String getUserEmailFromCache(long userhandle){
return megaChatApi.getUserEmailFromCache(userhandle);
}

/**
* Returns the current fullname of the user
*
* Returns NULL if data is not cached yet.
*
* You take the ownership of returned value
*
* @param userhandle Handle of the user whose fullname is requested.
* @return The full name from user
*/
public String getUserFullnameFromCache(long userhandle){
return megaChatApi.getUserFullnameFromCache(userhandle);
}

/**
* Request to server user attributes
*
* This function is useful to get the email address, first name, last name and full name
* from chat link participants that they are not loaded
*
* After request is finished, you can call to MegaChatRoom::getPeerFirstnameByHandle,
* MegaChatRoom::getPeerLastnameByHandle, MegaChatRoom::getPeerFullnameByHandle,
* MegaChatRoom::getPeerEmailByHandle
*
* The associated request type with this request is MegaChatRequest::TYPE_GET_PEER_ATTRIBUTES
* Valid data in the MegaChatRequest object received on callbacks:
* - MegaChatRequest::getChatHandle - Returns the handle of chat
* - MegaChatRequest::getMegaHandleList - Returns the handles of user that attributes have been requested
* - MegaChatRequest::getLink - Returns the authorization token. Previewers of chatlinks are not allowed
* to retrieve user attributes like firstname or lastname, unless they provide a valid authorization token.
*
* @param chatid Handle of the chat whose member attributes requested
* @param userList List of user whose attributes has been requested
* @param listener MegaChatRequestListener to track this request
*/
public void loadUserAttributes(long chatid, MegaHandleList userList, MegaChatRequestListenerInterface listener) {
megaChatApi.loadUserAttributes(chatid, userList, createDelegateRequestListener(listener));
}

/**
* Request to server user attributes
*
* This function is useful to get the email address, first name, last name and full name
* from chat link participants that they are not loaded
*
* After request is finished, you can call to MegaChatRoom::getPeerFirstnameByHandle,
* MegaChatRoom::getPeerLastnameByHandle, MegaChatRoom::getPeerFullnameByHandle,
* MegaChatRoom::getPeerEmailByHandle
*
* The associated request type with this request is MegaChatRequest::TYPE_GET_PEER_ATTRIBUTES
* Valid data in the MegaChatRequest object received on callbacks:
* - MegaChatRequest::getChatHandle - Returns the handle of chat
* - MegaChatRequest::getMegaHandleList - Returns the handles of user that attributes have been requested
* - MegaChatRequest::getLink - Returns the authorization token. Previewers of chatlinks are not allowed
* to retrieve user attributes like firstname or lastname, unless they provide a valid authorization token.
*
* @param chatid Handle of the chat whose member attributes requested
* @param userList List of user whose attributes has been requested
*/
public void loadUserAttributes(long chatid, MegaHandleList userList) {
megaChatApi.loadUserAttributes(chatid, userList);
}

/**
* Returns the current email address of the user
*
Expand Down Expand Up @@ -1775,6 +1883,7 @@ public void checkChatLink(String link, MegaChatRequestListenerInterface listener
* - MegaChatError::ERROR_ARGS - If the chatroom is not groupal or public.
* - MegaChatError::ERROR_NOENT - If the chat room does not exists or the chatid is invalid.
* - MegaChatError::ERROR_ACCESS - If the caller is not an operator.
* - MegaChatError::ERROR_TOOMANY - If the chat is public and there are too many participants.
*
* Valid data in the MegaChatRequest object received in onRequestFinish when the error code
* is MegaError::ERROR_OK:
Expand Down Expand Up @@ -1924,6 +2033,17 @@ public int loadMessages(long chatid, int count){
return megaChatApi.loadMessages(chatid, count);
}

/**
* Checks whether the app has already loaded the full history of the chatroom
*
* @param chatid MegaChatHandle that identifies the chat room
*
* @return True the whole history is already loaded (including old messages from server).
*/
public boolean isFullHistoryLoaded(long chatid) {
return megaChatApi.isFullHistoryLoaded(chatid);
}

/**
* Returns the MegaChatMessage specified from the chat room.
*
Expand Down Expand Up @@ -2580,6 +2700,13 @@ public String getVideoDeviceSelected() {
* - MegaChatRequest::getChatHandle - Returns the chat identifier
* - MegaChatRequest::getFlag - Returns true if it is a video-audio call or false for audio call
*
* The request will fail with MegaChatError::ERROR_ACCESS when this function is
* called without being already connected to chatd ot when the chatroom is in preview mode.
*
* The request will fail with MegaChatError::ERROR_TOOMANY when there are too many participants
* in the call and we can't join to it, or when the chat is public and there are too many
* participants to start the call.
*
* NOTE: In case of group calls, if there is already too many peers sending video, the video flag
* will be disabled automatically and the MegaChatRequest::getFlag updated consequently.
*
Expand Down Expand Up @@ -2608,6 +2735,13 @@ public void startChatCall(long chatid, boolean enableVideo, MegaChatRequestListe
* - MegaChatRequest::getChatHandle - Returns the chat identifier
* - MegaChatRequest::getFlag - Returns true if it is a video-audio call or false for audio call
*
* The request will fail with MegaChatError::ERROR_ACCESS when this function is
* called without being already connected to chatd.
*
* The request will fail with MegaChatError::ERROR_TOOMANY when there are too many participants
* in the call and we can't join to it, or when the chat is public and there are too many participants
* to start the call.
*
* NOTE: In case of group calls, if there is already too many peers sending video, the video flag
* will be disabled automatically and the MegaChatRequest::getFlag updated consequently.
*
Expand Down
Loading

0 comments on commit 7e3adf4

Please sign in to comment.