Skip to content

Commit

Permalink
Merge branch 'task/CHT-875_change-calls-to-deprecated-megaapi-sendeve…
Browse files Browse the repository at this point in the history
…nt' into 'develop'

CHT-875. Change calls to deprecated MegaApi::sendEvent()

Closes CHT-875

See merge request megachat/MEGAchat!1582
  • Loading branch information
vmgaGH committed May 15, 2023
2 parents fc89d70 + a04882d commit a85179f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
16 changes: 8 additions & 8 deletions src/chatClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,7 @@ bool Client::checkSyncWithSdkDb(const std::string& scsn,
KR_LOG_DEBUG("Db sync ok, karere scsn matches with the one from sdk");
return true;
}
api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99012, "Karere db out of sync with sdk - scsn-s don't match");
api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99012, "Karere db out of sync with sdk - scsn-s don't match", false, static_cast<const char*>(nullptr));
}

// We are not in sync, probably karere is one or more commits behind
Expand Down Expand Up @@ -1832,7 +1832,7 @@ void Client::sendStats()

std::string stats = mInitStats.onCompleted(api.sdk.getNumNodes(), chats->size(), mContactList->size());
KR_LOG_DEBUG("Init stats: %s", stats.c_str());
api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99008, jsonUnescape(stats).c_str());
api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99008, jsonUnescape(stats).c_str(), false, static_cast<const char*>(nullptr));
}

InitStats& Client::initStats()
Expand Down Expand Up @@ -2519,7 +2519,7 @@ GroupChatRoom::GroupChatRoom(ChatRoomList& parent, const mega::MegaTextChat& aCh
{
KR_LOG_ERROR("Invalid size for unified key");
isUnifiedKeyEncrypted = strongvelope::kUndecryptable;
parent.mKarereClient.api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99002, "invalid unified-key detected");
parent.mKarereClient.api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99002, "invalid unified-key detected", false, static_cast<const char*>(nullptr));
}
else
{
Expand Down Expand Up @@ -3316,7 +3316,7 @@ promise::Promise<void> GroupChatRoom::decryptTitle()
{
KR_LOG_ERROR("Failed to base64-decode chat title for chat %s: %s. Falling back to member names", ID_CSTR(mChatid), e.what());

parent.mKarereClient.api.call(&mega::MegaApi::sendEvent, 99007, "Decryption of chat topic failed");
parent.mKarereClient.api.call(&mega::MegaApi::sendEvent, 99007, "Decryption of chat topic failed", false, static_cast<const char*>(nullptr));
updateTitleInDb(mEncryptedTitle, strongvelope::kUndecryptable);
makeTitleFromMemberNames();

Expand All @@ -3338,7 +3338,7 @@ promise::Promise<void> GroupChatRoom::decryptTitle()

KR_LOG_ERROR("Error decrypting chat title for chat %s: %s. Falling back to member names.", ID_CSTR(chatid()), err.what());

parent.mKarereClient.api.call(&mega::MegaApi::sendEvent, 99007, "Decryption of chat topic failed");
parent.mKarereClient.api.call(&mega::MegaApi::sendEvent, 99007, "Decryption of chat topic failed", false, static_cast<const char*>(nullptr));
updateTitleInDb(mEncryptedTitle, strongvelope::kUndecryptable);
makeTitleFromMemberNames();

Expand Down Expand Up @@ -3936,7 +3936,7 @@ bool GroupChatRoom::publicChat() const
return (mChat->crypto()->isPublicChat());
}

parent.mKarereClient.api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99011, "GroupChatRoom::publicChat(), chatd::Chat isn't yet created");
parent.mKarereClient.api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99011, "GroupChatRoom::publicChat(), chatd::Chat isn't yet created", false, static_cast<const char*>(nullptr));

return false;
}
Expand All @@ -3949,7 +3949,7 @@ uint64_t GroupChatRoom::getPublicHandle() const
return (mChat->getPublicHandle());
}

parent.mKarereClient.api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99011, "GroupChatRoom::getPublicHandle(), chatd::Chat isn't yet created");
parent.mKarereClient.api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99011, "GroupChatRoom::getPublicHandle(), chatd::Chat isn't yet created", false, static_cast<const char*>(nullptr));
return karere::Id::inval();
}

Expand Down Expand Up @@ -4181,7 +4181,7 @@ bool GroupChatRoom::syncWithApi(const mega::MegaTextChat& chat)
else
{
KR_LOG_DEBUG("Skip re-join chatd, since it's already joining right now");
parent.mKarereClient.api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99003, "Skip re-join chatd");
parent.mKarereClient.api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99003, "Skip re-join chatd", false, static_cast<const char*>(nullptr));
}
}
KR_LOG_DEBUG("Chatroom[%s]: API event: We were re/invited", ID_CSTR(mChatid));
Expand Down
12 changes: 6 additions & 6 deletions src/chatd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ void Connection::onSocketClose(int errcode, int errtype, const std::string& reas
if (!mRetryCtrl)
{
CHATDS_LOG_ERROR("There's no retry controller instance when calling onSocketClose in kDisconnected state");
mChatdClient.mKarereClient->api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99013, "There's no retry controller instance when calling onSocketClose in kDisconnected state");
mChatdClient.mKarereClient->api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99013, "There's no retry controller instance when calling onSocketClose in kDisconnected state", false, static_cast<const char*>(nullptr));
reconnect(); // start retry controller
}
return;
Expand Down Expand Up @@ -697,7 +697,7 @@ void Connection::sendEcho()
mEchoTimer = 0;

CHATDS_LOG_DEBUG("Echo response not received in %d secs. Reconnecting...", kEchoTimeout);
mChatdClient.mKarereClient->api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99001, "ECHO response timed out");
mChatdClient.mKarereClient->api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99001, "ECHO response timed out", false, static_cast<const char*>(nullptr));

setState(kStateDisconnected);
abortRetryController();
Expand Down Expand Up @@ -774,7 +774,7 @@ void Connection::setState(State state)
mConnectTimer = 0;

CHATDS_LOG_DEBUG("Reconnection attempt has not succeed after %d. Reconnecting...", kConnectTimeout);
mChatdClient.mKarereClient->api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99004, "Reconnection timed out");
mChatdClient.mKarereClient->api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99004, "Reconnection timed out", false, static_cast<const char*>(nullptr));

retryPendingConnection(true);

Expand Down Expand Up @@ -3700,7 +3700,7 @@ bool Chat::msgEncryptAndSend(OutputQueue::iterator it)
delete msgCmd;
mEncryptionHalted = false;
msgRemoveFromSending(msg->id(), 0);
mChatdClient.mKarereClient->api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99015, "Failed to encrypt message");
mChatdClient.mKarereClient->api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99015, "Failed to encrypt message", false, static_cast<const char*>(nullptr));
return err;
});

Expand Down Expand Up @@ -5131,7 +5131,7 @@ Idx Chat::msgIncoming(bool isNew, Message* message, bool isLocal)
if (mHasMoreHistoryInDb)
{ //we have db history that is not loaded, so we determine the index
//by the db, and don't add the message to RAM
mChatdClient.mKarereClient->api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99016, "msgIncoming: incoming message is older than the oldest we have");
mChatdClient.mKarereClient->api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99016, "msgIncoming: incoming message is older than the oldest we have", false, static_cast<const char*>(nullptr));
assert(false);
idx = mDbInterface->getOldestIdx()-1;
}
Expand Down Expand Up @@ -5632,7 +5632,7 @@ void Chat::verifyMsgOrder(const Message& msg, Idx idx)
if (targetIdx >= idx)
{
CALL_LISTENER(onMsgOrderVerificationFail, msg, idx, "Message order verification failed, possible history tampering");
client().mKarereClient->api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99000, "order tampering native");
client().mKarereClient->api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99000, "order tampering native", false, static_cast<const char*>(nullptr));
return;
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/megachatapi_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ void MegaChatApiImpl::sendPendingRequests()
{
if (wptr.deleted())
{
mMegaApi->sendEvent(99014, "karere client instance was removed upon TYPE_LOAD_PREVIEW");
mMegaApi->sendEvent(99014, "karere client instance was removed upon TYPE_LOAD_PREVIEW", false, static_cast<const char*>(nullptr));
}

bool createChat = request->getFlag();
Expand Down Expand Up @@ -1544,15 +1544,15 @@ void MegaChatApiImpl::sendPendingRequests()
ChatRoom *room = findChatRoom(chatid);
if (!room)
{
mMegaApi->sendEvent(99006, "iOS PUSH received for non-existing chatid");
mMegaApi->sendEvent(99006, "iOS PUSH received for non-existing chatid", false, static_cast<const char*>(nullptr));

MegaChatErrorPrivate *megaChatError = new MegaChatErrorPrivate(MegaChatError::ERROR_NOENT);
fireOnChatRequestFinish(request, megaChatError);
return;
}
else if (wasArchived && room->isArchived()) // don't want to generate notifications for archived chats
{
mMegaApi->sendEvent(99009, "PUSH received for archived chatid (and still archived)");
mMegaApi->sendEvent(99009, "PUSH received for archived chatid (and still archived)", false, static_cast<const char*>(nullptr));

// since a PUSH could be received before the actionpacket updating flags (
MegaChatErrorPrivate *megaChatError = new MegaChatErrorPrivate(MegaChatError::ERROR_ACCESS);
Expand Down Expand Up @@ -1843,7 +1843,7 @@ void MegaChatApiImpl::sendPendingRequests()
logMsg.append(call->getChatid().toString().c_str());
logMsg.append(" userid: ");
logMsg.append(mClient->myHandle().toString().c_str());
mMegaApi->sendEvent(99015, logMsg.c_str());
mMegaApi->sendEvent(99015, logMsg.c_str(), false, static_cast<const char*>(nullptr));
}

assert(call->isOwnPrivModerator() == chatroom->ownPriv());
Expand Down Expand Up @@ -2336,7 +2336,7 @@ void MegaChatApiImpl::sendPendingRequests()
logMsg.append(call->getChatid().toString().c_str());
logMsg.append(" userid: ");
logMsg.append(mClient->myHandle().toString().c_str());
mMegaApi->sendEvent(99015, logMsg.c_str());
mMegaApi->sendEvent(99015, logMsg.c_str(), false, static_cast<const char*>(nullptr));
}

API_LOG_ERROR("MegaChatRequest::TYPE_APPROVE_SPEAK - You need moderator role to approve speak request");
Expand Down
2 changes: 1 addition & 1 deletion src/net/websocketsIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ bool WebsocketsClient::wsConnect(WebsocketsIO *websocketIO, const char *ip, cons
if (ctx)
{
WEBSOCKETS_LOG_ERROR("Valid context at connect()");
websocketIO->mApi.sdk.sendEvent(99010, "A valid previous context existed upon new wsConnect");
websocketIO->mApi.sdk.sendEvent(99010, "A valid previous context existed upon new wsConnect", false, static_cast<const char*>(nullptr));
delete ctx;
}

Expand Down
4 changes: 2 additions & 2 deletions src/presenced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void Client::onSocketClose(int errcode, int errtype, const std::string& reason)
if (!mRetryCtrl)
{
PRESENCED_LOG_ERROR("There's no retry controller instance when calling onSocketClose in kDisconnected state");
mKarereClient->api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99013, "There's no retry controller instance when calling onSocketClose in kDisconnected state");
mKarereClient->api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99013, "There's no retry controller instance when calling onSocketClose in kDisconnected state", false, static_cast<const char*>(nullptr));
reconnect(); //start retry controller
}
return;
Expand Down Expand Up @@ -1392,7 +1392,7 @@ void Client::setConnState(ConnState newState)
mConnectTimer = 0;

PRESENCED_LOG_DEBUG("Reconnection attempt has not succeed after %d. Reconnecting...", kConnectTimeout);
mKarereClient->api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99005, "Reconnection timed out (presenced)");
mKarereClient->api.callIgnoreResult(&::mega::MegaApi::sendEvent, 99005, "Reconnection timed out (presenced)", false, static_cast<const char*>(nullptr));

retryPendingConnection(true);

Expand Down

0 comments on commit a85179f

Please sign in to comment.