Skip to content

Commit

Permalink
Merge pull request #735 from meganz/release/v2.2.0
Browse files Browse the repository at this point in the history
Release/v2.2.0
  • Loading branch information
sergiohs84 authored Nov 5, 2019
2 parents 7116e2f + 3e16257 commit 969d528
Show file tree
Hide file tree
Showing 38 changed files with 1,829 additions and 218 deletions.
3 changes: 2 additions & 1 deletion bindings/qt/QTMegaChatEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class QTMegaChatEvent: public QEvent
OnAttachmentLoaded,
OnAttachmentReceived,
OnAttachmentDeleted,
OnAttachmentTruncated
OnAttachmentTruncated,
OnReactionUpdated,
};

QTMegaChatEvent(MegaChatApi *megaChatApi, Type type);
Expand Down
12 changes: 12 additions & 0 deletions bindings/qt/QTMegaChatRoomListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ void QTMegaChatRoomListener::onMessageReceived(MegaChatApi *api, MegaChatMessage
QCoreApplication::postEvent(this, event, INT_MIN);
}

void QTMegaChatRoomListener::onReactionUpdate(MegaChatApi *api, MegaChatHandle msgid, const char *reaction, int count)
{
QTMegaChatEvent *event = new QTMegaChatEvent(api, (QEvent::Type)QTMegaChatEvent::OnReactionUpdated);
event->setChatHandle(msgid);
event->setWidth(count);
event->setBuffer(::mega::MegaApi::strdup(reaction));
QCoreApplication::postEvent(this, event, INT_MIN);
}

void QTMegaChatRoomListener::onMessageUpdate(MegaChatApi *api, MegaChatMessage *msg)
{
QTMegaChatEvent *event = new QTMegaChatEvent(api, (QEvent::Type)QTMegaChatEvent::OnMessageUpdate);
Expand Down Expand Up @@ -76,6 +85,9 @@ void QTMegaChatRoomListener::customEvent(QEvent *e)
case QTMegaChatEvent::OnHistoryReloaded:
if (listener) listener->onHistoryReloaded(event->getMegaChatApi(), event->getChatRoom());
break;
case QTMegaChatEvent::OnReactionUpdated:
if (listener) listener->onReactionUpdate(event->getMegaChatApi(), event->getChatHandle(), event->getBuffer(), event->getWidth());
break;
default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/qt/QTMegaChatRoomListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class QTMegaChatRoomListener : public QObject, public MegaChatRoomListener
virtual void onMessageReceived(MegaChatApi* api, MegaChatMessage *msg);
virtual void onMessageUpdate(MegaChatApi* api, MegaChatMessage *msg);
virtual void onHistoryReloaded(MegaChatApi *api, MegaChatRoom *chat);

virtual void onReactionUpdate(MegaChatApi *api, MegaChatHandle msgid, const char *reaction, int count);

protected:
virtual void customEvent(QEvent * event);
Expand Down
9 changes: 6 additions & 3 deletions contrib/QtCreator/MEGAChatQt/MEGAChatQt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ SOURCES += ../../../examples/qtmegachatapi/MegaChatApplication.cpp \
../../../examples/qtmegachatapi/chatMessage.cpp \
../../../examples/qtmegachatapi/chatGroupDialog.cpp \
../../../examples/qtmegachatapi/listItemController.cpp \
../../../examples/qtmegachatapi/SettingWindow.cpp
../../../examples/qtmegachatapi/SettingWindow.cpp \
../../../examples/qtmegachatapi/reaction.cpp

HEADERS += ../../../examples/qtmegachatapi/MegaChatApplication.h \
../../../examples/qtmegachatapi/MainWindow.h \
Expand All @@ -56,7 +57,8 @@ HEADERS += ../../../examples/qtmegachatapi/MegaChatApplication.h \
../../../examples/qtmegachatapi/chatMessage.h \
../../../examples/qtmegachatapi/chatGroupDialog.h \
../../../examples/qtmegachatapi/listItemController.h \
../../../examples/qtmegachatapi/SettingWindow.h
../../../examples/qtmegachatapi/SettingWindow.h \
../../../examples/qtmegachatapi/reaction.h

FORMS += ../../../examples/qtmegachatapi/LoginDialog.ui \
../../../examples/qtmegachatapi/MainWindow.ui \
Expand All @@ -65,7 +67,8 @@ FORMS += ../../../examples/qtmegachatapi/LoginDialog.ui \
../../../examples/qtmegachatapi/settingsDialog.ui \
../../../examples/qtmegachatapi/chatMessageWidget.ui \
../../../examples/qtmegachatapi/chatGroupDialog.ui \
../../../examples/qtmegachatapi/SettingWindow.ui
../../../examples/qtmegachatapi/SettingWindow.ui \
../../../examples/qtmegachatapi/reaction.ui

CONFIG(USE_WEBRTC) {
SOURCES += ../../../examples/qtmegachatapi/callGui.cpp \
Expand Down
40 changes: 31 additions & 9 deletions examples/megaclc/megaclc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2988,6 +2988,7 @@ struct ls_flags
bool mtime = false;
bool size = false;
bool versions = false;
int order = 1;
};


Expand Down Expand Up @@ -3041,7 +3042,7 @@ void ls(m::MegaNode* node, const string& basepath, const ls_flags& flags, int de
if (show && depth > 0) cout << endl;
if (flags.recursive || depth == 0)
{
unique_ptr<m::MegaNodeList> children(g_megaApi->getChildren(node));
unique_ptr<m::MegaNodeList> children(g_megaApi->getChildren(node, flags.order));
if (children) for (int i = 0; i < children->size(); ++i)
{
ls(children->get(i), basepath, flags, depth + 1);
Expand All @@ -3053,14 +3054,19 @@ void ls(m::MegaNode* node, const string& basepath, const ls_flags& flags, int de

void exec_ls(ac::ACState& s)
{
string orderstring;
ls_flags flags;
flags.recursive = extractflag("-recursive", s.words);
flags.regexfilter = extractflagparam("-refilter", flags.regexfilterstring, s.words);
flags.handle = extractflag("-handles", s.words);
flags.ctime = extractflag("-ctime", s.words);
flags.mtime = extractflag("-mtime", s.words);
flags.size = extractflag("-size", s.words);
flags.versions = extractflag("-versions", s.words);
flags.recursive = s.extractflag("-recursive");
flags.regexfilter = s.extractflagparam("-refilter", flags.regexfilterstring);
flags.handle = s.extractflag("-handles");
flags.ctime = s.extractflag("-ctime");
flags.mtime = s.extractflag("-mtime");
flags.size = s.extractflag("-size");
flags.versions = s.extractflag("-versions");
if (s.extractflagparam("-order", orderstring))
{
flags.order = std::stoi(orderstring);
}

if (flags.regexfilter)
{
Expand Down Expand Up @@ -3275,6 +3281,21 @@ void exec_getCameraUploadsFolder(ac::ACState& s)
}


void exec_getContact(ac::ACState& s)
{

unique_ptr<m::MegaUser> user(g_megaApi->getContact(s.words[1].s.c_str()));
if (user)
{
conlock(cout) << "found with handle: " << ch_s(user->getHandle()) << " timestamp: " << user->getTimestamp() << endl;
}
else
{
conlock(cout) << "No user found with that email" << endl;
}
}


ac::ACN autocompleteSyntax()
{
using namespace ac;
Expand Down Expand Up @@ -3419,7 +3440,7 @@ ac::ACN autocompleteSyntax()
p->Add(exec_createpreview, sequence(text("createpreview"), localFSFile(), localFSFile()));
p->Add(exec_testAllocation, sequence(text("testAllocation"), param("count"), param("size")));
p->Add(exec_getnodebypath, sequence(text("getnodebypath"), param("remotepath")));
p->Add(exec_ls, sequence(text("ls"), repeat(either(flag("-recursive"), flag("-handles"), flag("-ctime"), flag("-mtime"), flag("-size"), flag("-versions"), sequence(flag("-refilter"), param("regex")))), param("path")));
p->Add(exec_ls, sequence(text("ls"), repeat(either(flag("-recursive"), flag("-handles"), flag("-ctime"), flag("-mtime"), flag("-size"), flag("-versions"), sequence(flag("-order"), param("order")), sequence(flag("-refilter"), param("regex")))), param("path")));
p->Add(exec_renamenode, sequence(text("renamenode"), param("remotepath"), param("newname")));

p->Add(exec_pushreceived, sequence(text("pushreceived"), opt(flag("-beep")), opt(param("chatid"))));
Expand All @@ -3430,6 +3451,7 @@ ac::ACN autocompleteSyntax()
p->Add(exec_setCameraUploadsFolder, sequence(text("setcamerauploadsfolder"), param("remotedst")));
p->Add(exec_getCameraUploadsFolder, sequence(text("getcamerauploadsfolder")));

p->Add(exec_getContact, sequence(text("getcontact"), param("email")));

return p;
}
Expand Down
5 changes: 5 additions & 0 deletions examples/qtmegachatapi/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ void MainWindow::onChatCallUpdate(megachat::MegaChatApi */*api*/, megachat::Mega
}
}

MegaChatApplication* MainWindow::getApp() const
{
return mApp;
}

#endif

ChatWindow *MainWindow::getChatWindowIfExists(MegaChatHandle chatId)
Expand Down
1 change: 1 addition & 0 deletions examples/qtmegachatapi/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class MainWindow :
#ifndef KARERE_DISABLE_WEBRTC
void onChatCallUpdate(megachat::MegaChatApi *api, megachat::MegaChatCall *call);
#endif
MegaChatApplication* getApp() const;

protected:
MegaLoggerApplication *mLogger;
Expand Down
19 changes: 11 additions & 8 deletions examples/qtmegachatapi/chatItemWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ ChatItemWidget::ChatItemWidget(MainWindow *mainWindow, const megachat::MegaChatL

void ChatItemWidget::updateToolTip(const megachat::MegaChatListItem *item, const char *author)
{
megachat::MegaChatRoom *chatRoom = mMegaChatApi->getChatRoom(mChatId);
QString text = NULL;
std::string senderHandle;
megachat::MegaChatRoom *chatRoom = mMegaChatApi->getChatRoom(mChatId);
megachat::MegaChatHandle lastMessageId = item->getLastMessageId();
int lastMessageType = item->getLastMessageType();
std::string lastMessage;
Expand Down Expand Up @@ -324,15 +324,18 @@ const char *ChatItemWidget::getLastMessageSenderName(megachat::MegaChatHandle ms
else
{
megachat::MegaChatRoom *chatRoom = this->mMegaChatApi->getChatRoom(mChatId);
const char *msg = chatRoom->getPeerFirstnameByHandle(msgUserId);
size_t len = msg ? strlen(msg) : 0;
if (len)
if (chatRoom)
{
msgAuthor = new char[len + 1];
strncpy(msgAuthor, msg, len);
msgAuthor[len] = '\0';
const char *msg = chatRoom->getPeerFirstnameByHandle(msgUserId);
size_t len = msg ? strlen(msg) : 0;
if (len)
{
msgAuthor = new char[len + 1];
strncpy(msgAuthor, msg, len);
msgAuthor[len] = '\0';
}
delete chatRoom;
}
delete chatRoom;
}
return msgAuthor;
}
Expand Down
Loading

0 comments on commit 969d528

Please sign in to comment.