Skip to content

Commit

Permalink
Merge branch 'release/v2.3.9' into 'master'
Browse files Browse the repository at this point in the history
Release/v2.3.9

See merge request megachat/MEGAchat!970
  • Loading branch information
sergiohs84 committed Nov 24, 2020
2 parents e70a1de + e45360d commit d839a0d
Show file tree
Hide file tree
Showing 20 changed files with 802 additions and 43 deletions.
8 changes: 8 additions & 0 deletions bindings/Objective-C/Karere.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
2F59F49F251C5B3600DDD2D0 /* MEGAChatGiphy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2F59F49E251C5B3600DDD2D0 /* MEGAChatGiphy.mm */; };
77875CDA2097A69400B8340F /* MEGAChatContainsMeta.mm in Sources */ = {isa = PBXBuildFile; fileRef = 77875CD92097A69400B8340F /* MEGAChatContainsMeta.mm */; };
77875CDD2097A80700B8340F /* MEGAChatRichPreview.mm in Sources */ = {isa = PBXBuildFile; fileRef = 77875CDC2097A80700B8340F /* MEGAChatRichPreview.mm */; };
77CB2DCF2356FFD50095FF8C /* OBJCCaptureModule.mm in Sources */ = {isa = PBXBuildFile; fileRef = 77CB2DCE2356FFD50095FF8C /* OBJCCaptureModule.mm */; };
Expand Down Expand Up @@ -66,6 +67,9 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
2F59F49D251C5B3600DDD2D0 /* MEGAChatGiphy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MEGAChatGiphy.h; sourceTree = "<group>"; };
2F59F49E251C5B3600DDD2D0 /* MEGAChatGiphy.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MEGAChatGiphy.mm; sourceTree = "<group>"; };
2F59F4A2251C5F9100DDD2D0 /* MEGAChatGiphy+init.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MEGAChatGiphy+init.h"; sourceTree = "<group>"; };
77875CD82097A69400B8340F /* MEGAChatContainsMeta.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MEGAChatContainsMeta.h; sourceTree = "<group>"; };
77875CD92097A69400B8340F /* MEGAChatContainsMeta.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MEGAChatContainsMeta.mm; sourceTree = "<group>"; };
77875CDB2097A80700B8340F /* MEGAChatRichPreview.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MEGAChatRichPreview.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -392,6 +396,7 @@
A8AA1BF72195B21800E15B60 /* DelegateMEGAChatNodeHistoryListener.h */,
A8AA1BF82195B21800E15B60 /* DelegateMEGAChatNodeHistoryListener.mm */,
A819DE8D219EE12E00EA9C22 /* MEGAChatGeolocation+init.h */,
2F59F4A2251C5F9100DDD2D0 /* MEGAChatGiphy+init.h */,
);
name = private;
path = Private;
Expand Down Expand Up @@ -437,6 +442,8 @@
8394CF9C211992A200A1634A /* MEGAChatSession.h */,
8394CF9D211992A200A1634A /* MEGAChatSession.mm */,
A8AA1BF62195B11B00E15B60 /* MEGAChatNodeHistoryDelegate.h */,
2F59F49D251C5B3600DDD2D0 /* MEGAChatGiphy.h */,
2F59F49E251C5B3600DDD2D0 /* MEGAChatGiphy.mm */,
A8F96C18219DE3A2005A3EB6 /* MEGAChatGeolocation.h */,
A8F96C19219DE3A2005A3EB6 /* MEGAChatGeolocation.mm */,
);
Expand Down Expand Up @@ -597,6 +604,7 @@
A835A8AB1F979CDC0075646F /* MEGAChatCall.mm in Sources */,
A879F3C21F96683A007C5394 /* presenced.cpp in Sources */,
A82750EE1E9788D8007CD9E2 /* DelegateMEGAChatListener.mm in Sources */,
2F59F49F251C5B3600DDD2D0 /* MEGAChatGiphy.mm in Sources */,
A82750D81E9788A3007CD9E2 /* MEGAChatRequest.mm in Sources */,
A8F96C1A219DE3A2005A3EB6 /* MEGAChatGeolocation.mm in Sources */,
A82750DB1E9788A3007CD9E2 /* MEGAChatSdk.mm in Sources */,
Expand Down
6 changes: 4 additions & 2 deletions bindings/Objective-C/MEGAChatContainsMeta.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

#import "MEGAChatRichPreview.h"
#import "MEGAChatGeolocation.h"
#import "MEGAChatGiphy.h"

typedef NS_ENUM(NSInteger, MEGAChatContainsMetaType) {
MEGAChatContainsMetaTypeInvalid = -1,
MEGAChatContainsMetaTypeRichPreview = 0,
MEGAChatContainsMetaTypeGeolocation = 1
MEGAChatContainsMetaTypeGeolocation = 1,
MEGAChatContainsMetaTypeGiphy = 3
};

@interface MEGAChatContainsMeta : NSObject
Expand All @@ -16,6 +18,6 @@ typedef NS_ENUM(NSInteger, MEGAChatContainsMetaType) {
@property (readonly, nonatomic) NSString *textMessage;
@property (readonly, nonatomic) MEGAChatRichPreview *richPreview;
@property (readonly, nonatomic) MEGAChatGeolocation *geolocation;

@property (readonly, nonatomic) MEGAChatGiphy *giphy;

@end
5 changes: 5 additions & 0 deletions bindings/Objective-C/MEGAChatContainsMeta.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#import "MEGAChatRichPreview+init.h"
#import "MEGAChatGeolocation+init.h"
#import "MEGAChatGiphy+init.h"

using namespace megachat;

Expand Down Expand Up @@ -60,4 +61,8 @@ - (MEGAChatGeolocation *)geolocation {
return self.megaChatContainsMeta->getGeolocation() ? [[MEGAChatGeolocation alloc] initWithMegaChatGeolocation:self.megaChatContainsMeta->getGeolocation()->copy() cMemoryOwn:YES] : nil;
}

- (MEGAChatGiphy *)giphy {
return self.megaChatContainsMeta->getGiphy() ? [[MEGAChatGiphy alloc] initWithMegaChatGiphy:self.megaChatContainsMeta->getGiphy()->copy() cMemoryOwn:YES] : nil;
}

@end
19 changes: 19 additions & 0 deletions bindings/Objective-C/MEGAChatGiphy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface MEGAChatGiphy : NSObject

@property (nullable, readonly, nonatomic) NSString *mp4Src;
@property (nullable, readonly, nonatomic) NSString *webpSrc;

@property (readonly, nonatomic) long mp4Size;
@property (readonly, nonatomic) long webpSize;
@property (nullable, readonly, nonatomic) NSString *title;
@property (readonly, nonatomic) int width;
@property (readonly, nonatomic) int height;

@end

NS_ASSUME_NONNULL_END
65 changes: 65 additions & 0 deletions bindings/Objective-C/MEGAChatGiphy.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

#import "MEGAChatGiphy.h"

#import "megachatapi.h"

using namespace megachat;

@interface MEGAChatGiphy ()

@property MegaChatGiphy *megaChatGiphy;
@property BOOL cMemoryOwn;

@end

@implementation MEGAChatGiphy

- (instancetype)initWithMegaChatGiphy:(MegaChatGiphy *)megaChatGiphy cMemoryOwn:(BOOL)cMemoryOwn {
NSParameterAssert(megaChatGiphy);

if (self = [super init]) {
_megaChatGiphy = megaChatGiphy;
_cMemoryOwn = cMemoryOwn;
}

return self;
}

- (NSString *)mp4Src {
if (!self.megaChatGiphy) return nil;
return self.megaChatGiphy->getMp4Src() ? [[NSString alloc] initWithUTF8String:self.megaChatGiphy->getMp4Src()] : nil;
}

- (NSString *)webpSrc {
if (!self.megaChatGiphy) return nil;
return self.megaChatGiphy->getWebpSrc() ? [[NSString alloc] initWithUTF8String:self.megaChatGiphy->getWebpSrc()] : nil;
}

- (NSString *)title {
if (!self.megaChatGiphy) return nil;
return self.megaChatGiphy->getTitle() ? [[NSString alloc] initWithUTF8String:self.megaChatGiphy->getTitle()] : nil;
}

- (long)mp4Size {
return self.megaChatGiphy->getMp4Size();
}

- (long)webpSize {
return self.megaChatGiphy->getWebpSize();
}

- (int)width {
return self.megaChatGiphy->getWidth();
}

- (int)height {
return self.megaChatGiphy->getHeight();
}

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

@end
1 change: 1 addition & 0 deletions bindings/Objective-C/MEGAChatSdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ typedef NS_ENUM (NSInteger, MEGAChatConnection) {
- (MEGAChatMessage *)forwardContactFromChat:(uint64_t)sourceChatId messageId:(uint64_t)messageId targetChatId:(uint64_t)targetChatId;
- (void)attachNodesToChat:(uint64_t)chatId nodes:(NSArray *)nodesArray delegate:(id<MEGAChatRequestDelegate>)delegate;
- (void)attachNodesToChat:(uint64_t)chatId nodes:(NSArray *)nodesArray;
- (MEGAChatMessage *)sendGiphyToChat:(uint64_t)chatId srcMp4:(NSString *)srcMp4 srcWebp:(NSString *)srcWebp sizeMp4:(uint64_t)sizeMp4 sizeWebp:(uint64_t)sizeWebp width:(int)width height:(int)height title:(NSString *)title;
- (MEGAChatMessage *)sendGeolocationToChat:(uint64_t)chatId longitude:(float)longitude latitude:(float)latitude image:(NSString *)image;
- (MEGAChatMessage *)editGeolocationForChat:(uint64_t)chatId messageId:(uint64_t)messageId longitude:(float)longitude latitude:(float)latitude image:(NSString *)image;
- (void)revokeAttachmentToChat:(uint64_t)chatId node:(uint64_t)nodeHandle delegate:(id<MEGAChatRequestDelegate>)delegate;
Expand Down
5 changes: 5 additions & 0 deletions bindings/Objective-C/MEGAChatSdk.mm
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,11 @@ - (void)attachNodesToChat:(uint64_t)chatId nodes:(NSArray *)nodesArray {
self.megaChatApi->attachNodes(chatId, (nodeList != nil) ? [nodeList getCPtr] : NULL);
}

- (MEGAChatMessage *)sendGiphyToChat:(uint64_t)chatId srcMp4:(NSString *)srcMp4 srcWebp:(NSString *)srcWebp sizeMp4:(uint64_t)sizeMp4 sizeWebp:(uint64_t)sizeWebp width:(int)width height:(int)height title:(NSString *)title {
MegaChatMessage *message = self.megaChatApi->sendGiphy(chatId, srcMp4.UTF8String, srcWebp.UTF8String, sizeMp4, sizeWebp, width, height, title.UTF8String);
return message ? [[MEGAChatMessage alloc] initWithMegaChatMessage:message cMemoryOwn:YES] : nil;
}

- (MEGAChatMessage *)sendGeolocationToChat:(uint64_t)chatId longitude:(float)longitude latitude:(float)latitude image:(NSString *)image {
MegaChatMessage *message = self.megaChatApi->sendGeolocation(chatId, longitude, latitude, image ? [image UTF8String] : NULL);
return message ? [[MEGAChatMessage alloc] initWithMegaChatMessage:message cMemoryOwn:YES] : nil;
Expand Down
13 changes: 13 additions & 0 deletions bindings/Objective-C/Private/MEGAChatGiphy+init.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

#import "MEGAChatGiphy.h"
#import "megachatapi.h"

NS_ASSUME_NONNULL_BEGIN

@interface MEGAChatGiphy (init)

- (instancetype)initWithMegaChatGiphy:(const megachat::MegaChatGiphy *)megaChatGiphy cMemoryOwn:(BOOL)cMemoryOwn;

@end

NS_ASSUME_NONNULL_END
33 changes: 33 additions & 0 deletions bindings/java/nz/mega/sdk/MegaChatApiJava.java
Original file line number Diff line number Diff line change
Expand Up @@ -2121,6 +2121,39 @@ public MegaChatMessage sendMessage(long chatid, String msg){
return megaChatApi.sendMessage(chatid, msg);
}

/**
* Sends a new giphy to the specified chatroom
*
* The MegaChatMessage object returned by this function includes a message transaction id,
* That id is not the definitive id, which will be assigned by the server. You can obtain the
* temporal id with MegaChatMessage::getTempId
*
* When the server confirms the reception of the message, the MegaChatRoomListener::onMessageUpdate
* is called, including the definitive id and the new status: MegaChatMessage::STATUS_SERVER_RECEIVED.
* At this point, the app should refresh the message identified by the temporal id and move it to
* the final position in the history, based on the reported index in the callback.
*
* If the message is rejected by the server, the message will keep its temporal id and will have its
* a message id set to MEGACHAT_INVALID_HANDLE.
*
* You take the ownership of the returned value.
*
*
* @param chatid MegaChatHandle that identifies the chat room
* @param srcMp4 Source location of the mp4
* @param srcWebp Source location of the webp
* @param sizeMp4 Size in bytes of the mp4
* @param sizeWebp Size in bytes of the webp
* @param width Width of the giphy
* @param height Height of the giphy
* @param title Title of the giphy
*
* @return MegaChatMessage that will be sent. The message id is not definitive, but temporal.
*/
public MegaChatMessage sendGiphy(long chatid, String srcMp4, String srcWebp, long sizeMp4, long sizeWebp, int width, int height, String title) {
return megaChatApi.sendGiphy(chatid, srcMp4, srcWebp, sizeMp4, sizeWebp, width, height, title);
}

/**
* Sends a contact or a group of contacts to the specified chatroom
*
Expand Down
22 changes: 22 additions & 0 deletions examples/qtmegachatapi/chatMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,28 @@ void ChatMessage::showContainsMetaData()
.append(geolocation->getImage() ? "yes" : "no");
break;
}
case megachat::MegaChatContainsMeta::CONTAINS_META_GIPHY:
{
const MegaChatGiphy *giphy = containsMeta->getGiphy();
text.append(tr("\nSubtype: Giphy"))
.append(tr("\nText content: "))
.append(containsMeta->getTextMessage())
.append(tr("\nTitle: "))
.append(giphy->getTitle())
.append(tr("\nMp4 source: "))
.append(giphy->getMp4Src())
.append(tr("\nWebp source: "))
.append(giphy->getWebpSrc())
.append(tr("\nMp4 Size: "))
.append(QString::number(giphy->getMp4Size()))
.append(tr("\nWebp Size: "))
.append(QString::number(giphy->getWebpSize()))
.append(tr("\ngiphy width: "))
.append(QString::number(giphy->getWidth()))
.append(tr("\ngiphy height: "))
.append(QString::number(giphy->getHeight()));
break;
}
default:
{
text.append(tr("\nSubtype: unkown"))
Expand Down
17 changes: 17 additions & 0 deletions examples/qtmegachatapi/chatWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1302,13 +1302,30 @@ void ChatWindow::createAttachMenu(QMenu& menu)
//Attach geolocation
auto actLocation = menu.addAction("Attach location");
connect(actLocation, &QAction::triggered, this, [=](){onAttachLocation();});

//Attach giphy
auto actGiphy = menu.addAction("Attach giphy");
connect(actGiphy, &QAction::triggered, this, [=](){onAttachGiphy();});
}

void ChatWindow::onAttachLocation()
{
mMegaChatApi->sendGeolocation(mChatRoom->getChatId(), -122.3316393, 47.5951518, NULL);
}

void ChatWindow::onAttachGiphy()
{
//giphy data
const char* srcMp4 = "giphy://media/Wm9XlKG2xIMiVcH4CP/200.mp4?cid=a2a900dl&rid=200.mp4&dom=bWVkaWEyLmdpcGh5LmNvbQ%3D%3D";
const char* srcWebp = "giphy://media/Wm9XlKG2xIMiVcH4CP/200.webp?cid=a2a900dl&rid=200.webp&dom=bWVkaWEyLmdpcGh5LmNvbQ%3D%3D";
long long sizeMp4 = 59970;
long long sizeWebp = 159970;
int giphyWidth = 200;
int giphyHeight = 200;
const char* giphyTitle = "TEST_SendGiphy";
mMegaChatApi->sendGiphy(mChatRoom->getChatId(), srcMp4, srcWebp, sizeMp4, sizeWebp, giphyWidth, giphyHeight, giphyTitle);
}

void ChatWindow::enableCallReconnect(bool enable)
{
if (enable)
Expand Down
1 change: 1 addition & 0 deletions examples/qtmegachatapi/chatWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class ChatWindow : public QDialog,

megachat::MegaChatApi *getMegaChatApi();
void onAttachLocation();
void onAttachGiphy();
void enableCallReconnect(bool enable);

#ifndef KARERE_DISABLE_WEBRTC
Expand Down
3 changes: 2 additions & 1 deletion src/chatdMsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,8 @@ class Message: public Buffer
{
kInvalid = 0xff,
kRichLink = 0x00,
kGeoLocation = 0x01
kGeoLocation = 0x01,
kGiphy = 0x03
};

enum Status
Expand Down
50 changes: 50 additions & 0 deletions src/megachatapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,11 @@ int MegaChatApi::loadAttachments(MegaChatHandle chatid, int count)
return pImpl->loadAttachments(chatid, count);
}

MegaChatMessage* megachat::MegaChatApi::sendGiphy(MegaChatHandle chatid, const char* srcMp4, const char* srcWebp, long long sizeMp4, long long sizeWebp, int width, int height, const char* title)
{
return pImpl->sendGiphy(chatid, srcMp4, srcWebp, sizeMp4, sizeWebp, width, height, title);
}

void MegaChatApi::addChatListener(MegaChatListener *listener)
{
pImpl->addChatListener(listener);
Expand Down Expand Up @@ -1941,6 +1946,11 @@ const MegaChatGeolocation *MegaChatContainsMeta::getGeolocation() const
return NULL;
}

const MegaChatGiphy* MegaChatContainsMeta::getGiphy() const
{
return nullptr;
}

const char *MegaChatRichPreview::getDomainName() const
{
return NULL;
Expand All @@ -1966,6 +1976,46 @@ const char *MegaChatGeolocation::getImage() const
return NULL;
}

MegaChatGiphy* MegaChatGiphy::copy() const
{
return nullptr;
}

const char* MegaChatGiphy::getMp4Src() const
{
return nullptr;
}

const char* MegaChatGiphy::getWebpSrc() const
{
return nullptr;
}

int megachat::MegaChatGiphy::getWidth() const
{
return 0;
}

int megachat::MegaChatGiphy::getHeight() const
{
return 0;
}

const char* megachat::MegaChatGiphy::getTitle() const
{
return nullptr;
}

long MegaChatGiphy::getMp4Size() const
{
return 0;
}

long MegaChatGiphy::getWebpSize() const
{
return 0;
}

void MegaChatNodeHistoryListener::onAttachmentLoaded(MegaChatApi */*api*/, MegaChatMessage */*msg*/)
{
}
Expand Down
Loading

0 comments on commit d839a0d

Please sign in to comment.